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 |
|---|---|---|---|---|---|
uber/fbthrift | thrift/test/lua/test_basic_server.lua | 2 | 1779 | -- Copyright 2004-present Facebook. All Rights Reserved.
--------------------------------------------------------------------------------
-- Handler
TestHandler = ThriftTestIface:new{}
-- Stops the server
function TestHandler:testVoid()
self.__server:stop()
end
function TestHandler:testString(str)
return str .. 'bar'
end
function TestHandler:testByte(byte)
return byte
end
function TestHandler:testI32(i32)
return i32
end
function TestHandler:testI64(i64)
return i64
end
function TestHandler:testDouble(d)
return d
end
function TestHandler:testStruct(thing)
return thing
end
--------------------------------------------------------------------------------
-- Test
local server
function luaunit:teardown()
if server then
server:close()
end
end
function luaunit:testBasicServer()
-- Handler & Processor
local handler = TestHandler:new{}
self:assertNotNil(handler, 'Failed to create handler')
local processor = ThriftTestProcessor:new{
handler = handler
}
self:assertNotNil(processor, 'Failed to create processor')
-- Server Socket
local socket = TServerSocket:new{
port = 30118
}
self:assertNotNil(socket, 'Failed to create server socket')
-- Transport & Factory
local trans_factory = TFramedTransportFactory:new{}
self:assertNotNil(trans_factory, 'Failed to create framed transport factory')
local prot_factory = TBinaryProtocolFactory:new{}
self:assertNotNil(prot_factory, 'Failed to create binary protocol factory')
-- Simple Server
server = TSimpleServer:new{
processor = processor,
serverTransport = socket,
transportFactory = trans_factory,
protocolFactory = prot_factory
}
self:assertNotNil(server, 'Failed to create server')
-- Serve
server:serve()
server = nil
end
| apache-2.0 |
mercury233/ygopro-scripts | c3285551.lua | 2 | 2928 | --アラメシアの儀
function c3285551.initial_effect(c)
aux.AddCodeList(c,3285552)
--activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_TOKEN)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCountLimit(1,3285551+EFFECT_COUNT_CODE_OATH)
e1:SetCondition(c3285551.condition)
e1:SetCost(c3285551.cost)
e1:SetTarget(c3285551.target)
e1:SetOperation(c3285551.operation)
c:RegisterEffect(e1)
Duel.AddCustomActivityCounter(3285551,ACTIVITY_CHAIN,c3285551.chainfilter)
end
function c3285551.chainfilter(re,tp,cid)
local rc=re:GetHandler()
local loc=Duel.GetChainInfo(cid,CHAININFO_TRIGGERING_LOCATION)
return not (re:IsActiveType(TYPE_MONSTER) and loc==LOCATION_MZONE and not rc:IsSummonType(SUMMON_TYPE_SPECIAL))
end
function c3285551.cfilter0(c)
return c:IsCode(3285552) and c:IsFaceup()
end
function c3285551.condition(e,tp,eg,ep,ev,re,r,rp)
return not Duel.IsExistingMatchingCard(c3285551.cfilter0,tp,LOCATION_ONFIELD,0,1,nil)
end
function c3285551.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetCustomActivityCount(3285551,tp,ACTIVITY_CHAIN)==0 end
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CANNOT_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_OATH)
e1:SetTargetRange(1,0)
e1:SetValue(c3285551.aclimit)
e1:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e1,tp)
end
function c3285551.aclimit(e,re,tp)
local rc=re:GetHandler()
return re:IsActiveType(TYPE_MONSTER) and not rc:IsSummonType(SUMMON_TYPE_SPECIAL) and rc:IsLocation(LOCATION_MZONE)
end
function c3285551.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,3285552,0,TYPES_TOKEN_MONSTER,2000,2000,4,RACE_FAIRY,ATTRIBUTE_EARTH) end
Duel.SetOperationInfo(0,CATEGORY_TOKEN,nil,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,0)
end
function c3285551.cfilter(c)
return c:IsCode(39568067) and c:IsFaceup()
end
function c3285551.setfilter(c)
return c:IsCode(39568067) and not c:IsForbidden()
end
function c3285551.operation(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0
or not Duel.IsPlayerCanSpecialSummonMonster(tp,3285552,0,TYPES_TOKEN_MONSTER,2000,2000,4,RACE_FAIRY,ATTRIBUTE_EARTH) then return end
local token=Duel.CreateToken(tp,3285552)
Duel.SpecialSummon(token,0,tp,tp,false,false,POS_FACEUP)
local g=Duel.GetMatchingGroup(c3285551.setfilter,tp,LOCATION_DECK,0,nil)
if not Duel.IsExistingMatchingCard(c3285551.cfilter,tp,LOCATION_SZONE,0,1,nil)
and Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and g:GetCount()>0
and Duel.SelectYesNo(tp,aux.Stringid(3285551,0)) then
Duel.BreakEffect()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOFIELD)
local sg=g:Select(tp,1,1,nil)
Duel.MoveToField(sg:GetFirst(),tp,tp,LOCATION_SZONE,POS_FACEUP,true)
end
end
| gpl-2.0 |
mercury233/ygopro-scripts | c81997228.lua | 2 | 3249 | --プランキッズ・ハウスバトラー
function c81997228.initial_effect(c)
--fusion material
c:EnableReviveLimit()
aux.AddFusionProcCode3(c,81119816,18236002,55725117,true,true)
--spsummon condition
local e0=Effect.CreateEffect(c)
e0:SetType(EFFECT_TYPE_SINGLE)
e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e0:SetCode(EFFECT_SPSUMMON_CONDITION)
e0:SetValue(aux.fuslimit)
c:RegisterEffect(e0)
--destroy
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(81997228,0))
e1:SetCategory(CATEGORY_DESTROY)
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetRange(LOCATION_MZONE)
e1:SetCost(c81997228.descost)
e1:SetTarget(c81997228.destg)
e1:SetOperation(c81997228.desop)
c:RegisterEffect(e1)
--spsum
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(81997228,1))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e2:SetCode(EVENT_TO_GRAVE)
e2:SetCountLimit(1,81997228)
e2:SetCondition(c81997228.spcon)
e2:SetTarget(c81997228.sptg)
e2:SetOperation(c81997228.spop)
c:RegisterEffect(e2)
end
function c81997228.excostfilter(c,tp)
return (c:IsFaceup() or c:IsLocation(LOCATION_GRAVE)) and c:IsAbleToRemoveAsCost() and c:IsHasEffect(25725326,tp)
end
function c81997228.descost(e,tp,eg,ep,ev,re,r,rp,chk)
local g=Duel.GetMatchingGroup(c81997228.excostfilter,tp,LOCATION_MZONE+LOCATION_GRAVE,0,nil,tp)
if e:GetHandler():IsReleasable() then g:AddCard(e:GetHandler()) end
if chk==0 then return #g>0 end
local tc
if #g>1 then
Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(25725326,0))
tc=g:Select(tp,1,1,nil):GetFirst()
else
tc=g:GetFirst()
end
local te=tc:IsHasEffect(25725326,tp)
if te then
te:UseCountLimit(tp)
Duel.Remove(tc,POS_FACEUP,REASON_COST+REASON_REPLACE)
else
Duel.Release(tc,REASON_COST)
end
end
function c81997228.destg(e,tp,eg,ep,ev,re,r,rp,chk)
local g=Duel.GetMatchingGroup(aux.TRUE,tp,0,LOCATION_MZONE,nil)
if chk==0 then return #g>0 end
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,#g,0,0,nil)
end
function c81997228.desop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(aux.TRUE,tp,0,LOCATION_MZONE,nil)
Duel.Destroy(g,REASON_EFFECT)
end
function c81997228.spcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return rp==1-tp and c:IsPreviousControler(tp)
end
function c81997228.spfilter(c,e,tp)
return not c:IsType(TYPE_FUSION) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c81997228.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and c81997228.spfilter(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(c81997228.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c81997228.spfilter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c81997228.spop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc and tc:IsRelateToEffect(e) then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
end
end
| gpl-2.0 |
mercury233/ygopro-scripts | c23756165.lua | 2 | 4404 | --魅惑の女王 LV5
function c23756165.initial_effect(c)
--equip
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_SPSUMMON_SUCCESS)
e1:SetOperation(c23756165.regop)
c:RegisterEffect(e1)
--special summon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(23756165,1))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetRange(LOCATION_MZONE)
e2:SetCode(EVENT_PHASE+PHASE_STANDBY)
e2:SetCondition(c23756165.spcon)
e2:SetCost(c23756165.spcost)
e2:SetTarget(c23756165.sptg)
e2:SetOperation(c23756165.spop)
e2:SetLabelObject(e1)
c:RegisterEffect(e2)
end
c23756165.lvup={50140163,87257460}
c23756165.lvdn={87257460}
function c23756165.regop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:GetSummonType()==SUMMON_TYPE_SPECIAL+SUMMON_VALUE_LV then
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(23756165,0))
e1:SetCategory(CATEGORY_EQUIP)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1)
e1:SetCondition(c23756165.eqcon)
e1:SetTarget(c23756165.eqtg)
e1:SetOperation(c23756165.eqop)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_DISABLE)
e1:SetLabelObject(e)
c:RegisterEffect(e1)
end
end
function c23756165.eqcon(e,tp,eg,ep,ev,re,r,rp)
local ec=e:GetLabelObject():GetLabelObject()
return ec==nil or ec:GetFlagEffect(23756165)==0
end
function c23756165.filter(c)
return c:IsLevelBelow(5) and c:IsFaceup() and c:IsAbleToChangeControler()
end
function c23756165.eqtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1-tp) and c23756165.filter(chkc) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0
and Duel.IsExistingTarget(c23756165.filter,tp,0,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
local g=Duel.SelectTarget(tp,c23756165.filter,tp,0,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,g,1,0,0)
end
function c23756165.eqlimit(e,c)
return e:GetOwner()==c and not c:IsDisabled()
end
function c23756165.eqop(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 atk=tc:GetTextAttack()
local def=tc:GetTextDefense()
if atk<0 then atk=0 end
if def<0 then def=0 end
if not Duel.Equip(tp,tc,c,false) then return end
--Add Equip limit
tc:RegisterFlagEffect(23756165,RESET_EVENT+RESETS_STANDARD,0,0)
e:GetLabelObject():SetLabelObject(tc)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_COPY_INHERIT+EFFECT_FLAG_OWNER_RELATE)
e1:SetCode(EFFECT_EQUIP_LIMIT)
e1:SetReset(RESET_EVENT+RESETS_STANDARD)
e1:SetValue(c23756165.eqlimit)
tc:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_EQUIP)
e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE+EFFECT_FLAG_OWNER_RELATE)
e2:SetCode(EFFECT_DESTROY_SUBSTITUTE)
e2:SetReset(RESET_EVENT+RESETS_STANDARD)
e2:SetValue(c23756165.repval)
tc:RegisterEffect(e2)
end
end
function c23756165.repval(e,re,r,rp)
return bit.band(r,REASON_BATTLE)~=0
end
function c23756165.spcon(e,tp,eg,ep,ev,re,r,rp)
local ec=e:GetLabelObject():GetLabelObject()
return Duel.GetTurnPlayer()==tp and ec and ec:GetFlagEffect(23756165)~=0
end
function c23756165.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToGraveAsCost() end
Duel.SendtoGrave(e:GetHandler(),REASON_COST)
end
function c23756165.spfilter(c,e,tp)
return c:IsCode(50140163) and c:IsCanBeSpecialSummoned(e,SUMMON_VALUE_LV,tp,true,false)
end
function c23756165.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>-1
and Duel.IsExistingMatchingCard(c23756165.spfilter,tp,LOCATION_HAND+LOCATION_DECK,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND+LOCATION_DECK)
end
function c23756165.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,c23756165.spfilter,tp,LOCATION_HAND+LOCATION_DECK,0,1,1,nil,e,tp)
local tc=g:GetFirst()
if tc then
Duel.SpecialSummon(tc,SUMMON_VALUE_LV,tp,tp,true,false,POS_FACEUP)
tc:CompleteProcedure()
end
end
| gpl-2.0 |
yuhangwang/LuaExtensions | src/modules/file_module.lua | 1 | 4073 | --------------------------------------------
-- Group files by their extension
--------------------------------------------
-- Author: Yuhang Wang ---------------------
-- Date: 06/12/2015 ------------------------
-- Require: "Lua File System | lfs"
--------------------------------------------
local M = {}
local SysM = require("lfs")
local StringM = require("string_module")
function M.extract_columns(file_Input, file_Output, list_Columns, int_NumberOfRowsToSkip, char_CommentSymbol)
local list_Output = {}
local int_NumberOfRowsToSkip = int_NumberOfRowsToSkip or 0
local char_CommentSymbol = char_CommentSymbol or '#'
local str_CommentPattern = string.format("^%s.*", char_CommentSymbol)
local ccc = 0 -- line counter
for line in io.lines(file_Input) do
ccc = ccc + 1
if (ccc > int_NumberOfRowsToSkip) and ( not string.match(line, str_CommentPattern) ) then
list_Items = StringM.split(line)
local list_ExtractedColumns = {}
for _, i_Column in pairs(list_Columns) do
table.insert(list_ExtractedColumns, list_Items[i_Column])
end
local line = table.concat(list_ExtractedColumns, ' ')
table.insert(list_Output, line)
end
end
local io_FileOutput = io.open(file_Output, 'w')
local str_Output = table.concat(list_Output, '\n')
io.output(io_FileOutput)
io.write(str_Output)
io.close(io_FileOutput)
end
function M.read_file_to_list(file_name)
-- read an input file and return a list of the content
local list_Output = {}
for line in io.lines(file_name) do
table.insert(list_Output, line)
end
return list_Output
end
function M.read_file_to_2D_list(file_name)
-- read an input file and return a 2D list
local list2D = {}
for line in io.lines(file_name) do
local list_current = StringM.split(line, ' ')
table.insert(list2D, list_current)
end
return list2D
end
function M.ls(dir)
-- Get a list of file names at dir --
local list_file_names = {}
for file_name in SysM.dir(dir) do
if (file_name ~= ".") and (file_name ~= "..") then
table.insert(list_file_names, file_name)
end
end
return list_file_names
end
function M.copy(file_source, new_dir)
-- copy file
local cmd = string.format("cp %s %s", file_source, new_dir)
os.execute(cmd)
end
function M.write_str_to_file (output_file_name, str, mode)
-- Write a string into an output file
local mode = mode or 'w'
local OUT = io.open(output_file_name, mode)
io.output(OUT)
io.write(str)
io.close(OUT)
end
function M.get_file_ext(file_name)
-- Get file extension name --
return string.match(file_name, ".-%.?([^%.\\/]*)$")
end
function M.get_file_content(file_name)
local IN = io.open(file_name, 'r')
io.input(IN)
local content = io.read("*all")
io.close(IN)
return content
end
function M.group_files_by_ext(list_file_names)
-- Group files by extension name --
-- return: dict (key: extension, value: file names)
local dict_files_grouped = {}
for i, file_name in pairs(list_file_names) do
local ext = M.get_file_ext(file_name)
dict_files_grouped[ext] = file_name
end
return dict_files_grouped
end
function M.concat(list_file_names, output_file_name, skip_number_of_lines)
-- Concatenate files
local number_skip = skip_number_of_lines or 0
local OUT = io.open(output_file_name, "w")
io.output(OUT)
local list_lines = {}
for i, file_name in pairs(list_file_names) do
local ccc = 0
for line in io.lines(file_name) do
ccc = ccc + 1
if ccc > number_skip then
table.insert(list_lines, line)
end
end
end
local text_body = table.concat(list_lines, '\n')
io.write(text_body)
io.close(OUT)
end
function M.insert_id_column(file_input, file_output, scaling_factor)
local id_scaling_factor = scaling_factor or 1
local OUT = io.open(file_output, 'w')
io.output(OUT)
local ccc = 0 -- counter
for line in io.lines(file_input) do
local id = ccc * id_scaling_factor
io.write(string.format("%s %s\n", id, line))
ccc = ccc + 1
end
io.close(OUT)
end
function M.insert_id_column_before(file_input, file_output, scaling_factor)
M.insert_id_column(file_input, file_output, scaling_factor)
end
return M
| mit |
mercury233/ygopro-scripts | c27383719.lua | 2 | 3004 | --S-Force ラプスウェル
function c27383719.initial_effect(c)
--equip
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(27383719,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SPSUMMON_SUCCESS)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e1:SetCountLimit(1,27383719)
e1:SetTarget(c27383719.sptg)
e1:SetOperation(c27383719.spop)
c:RegisterEffect(e1)
--salvage
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_DESTROY)
e2:SetDescription(aux.Stringid(27383719,1))
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1,27383720)
e2:SetCost(c27383719.descost)
e2:SetTarget(c27383719.destg)
e2:SetOperation(c27383719.desop)
c:RegisterEffect(e2)
end
function c27383719.spfilter(c,e,tp)
return c:IsSetCard(0x156) and not c:IsCode(27383719)
and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c27383719.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c27383719.filter(chkc,e,tp) end
if chk==0 then return Duel.GetMZoneCount(tp)>0
and Duel.IsExistingTarget(c27383719.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c27383719.spfilter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c27383719.spop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
end
end
function c27383719.costfilter(c,e,tp)
if c:IsLocation(LOCATION_HAND) then
return c:IsSetCard(0x156) and c:IsAbleToRemoveAsCost()
else
return e:GetHandler():IsSetCard(0x156) and c:IsHasEffect(55049722,tp) and c:IsAbleToRemoveAsCost()
end
end
function c27383719.descost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c27383719.costfilter,tp,LOCATION_HAND+LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local tg=Duel.SelectMatchingCard(tp,c27383719.costfilter,tp,LOCATION_HAND+LOCATION_GRAVE,0,1,1,nil,e,tp)
local te=tg:GetFirst():IsHasEffect(55049722,tp)
if te then
te:UseCountLimit(tp)
Duel.Remove(tg,POS_FACEUP,REASON_REPLACE)
else
Duel.Remove(tg,POS_FACEUP,REASON_COST)
end
end
function c27383719.ggfilter(c,tp)
return c:IsSetCard(0x156) and c:IsFaceup() and c:IsLocation(LOCATION_MZONE) and c:IsControler(tp)
end
function c27383719.desfilter(c,tp)
local g=c:GetColumnGroup()
return g:IsExists(c27383719.ggfilter,1,nil,tp)
end
function c27383719.destg(e,tp,eg,ep,ev,re,r,rp,chk)
local g=Duel.GetMatchingGroup(c27383719.desfilter,tp,0,LOCATION_MZONE,nil,tp)
if chk==0 then return #g>0 end
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,#g,0,0)
end
function c27383719.desop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(c27383719.desfilter,tp,0,LOCATION_MZONE,nil,tp)
Duel.Destroy(g,REASON_EFFECT)
end
| gpl-2.0 |
mercury233/ygopro-scripts | c17241370.lua | 2 | 1504 | --リチュア・ナタリア
function c17241370.initial_effect(c)
--spirit return
aux.EnableSpiritReturn(c,EVENT_SUMMON_SUCCESS,EVENT_FLIP)
--cannot special summon
local e1=Effect.CreateEffect(c)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SPSUMMON_CONDITION)
e1:SetValue(aux.FALSE)
c:RegisterEffect(e1)
--to deck
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(17241370,1))
e4:SetCategory(CATEGORY_TODECK)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e4:SetProperty(EFFECT_FLAG_CARD_TARGET)
e4:SetCode(EVENT_SUMMON_SUCCESS)
e4:SetTarget(c17241370.tdtg)
e4:SetOperation(c17241370.tdop)
c:RegisterEffect(e4)
local e5=e4:Clone()
e5:SetCode(EVENT_FLIP)
c:RegisterEffect(e5)
end
function c17241370.filter(c)
return c:IsSetCard(0x3a) and c:IsType(TYPE_MONSTER) and c:IsAbleToDeck()
end
function c17241370.tdtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and c17241370.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c17241370.filter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
local g=Duel.SelectTarget(tp,c17241370.filter,tp,LOCATION_GRAVE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TODECK,g,1,0,0)
end
function c17241370.tdop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SendtoDeck(tc,nil,SEQ_DECKTOP,REASON_EFFECT)
end
end
| gpl-2.0 |
mercury233/ygopro-scripts | c24668830.lua | 2 | 2034 | --細菌感染
function c24668830.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(c24668830.target)
e1:SetOperation(c24668830.operation)
c:RegisterEffect(e1)
--atkdown
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_PHASE+PHASE_STANDBY)
e2:SetRange(LOCATION_SZONE)
e2:SetCountLimit(1)
e2:SetCondition(c24668830.atkcon)
e2:SetOperation(c24668830.atkop)
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(c24668830.eqlimit)
c:RegisterEffect(e3)
end
function c24668830.eqlimit(e,c)
return not c:IsRace(RACE_MACHINE)
end
function c24668830.filter(c)
return c:IsFaceup() and not c:IsRace(RACE_MACHINE)
end
function c24668830.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and c24668830.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c24668830.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
Duel.SelectTarget(tp,c24668830.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0)
end
function c24668830.operation(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if e:GetHandler():IsRelateToEffect(e) and tc:IsRelateToEffect(e) and tc:IsFaceup() then
Duel.Equip(tp,e:GetHandler(),tc)
end
end
function c24668830.atkcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()==tp
end
function c24668830.atkop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local ec=c:GetEquipTarget()
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(-300)
e1:SetReset(RESET_EVENT+RESETS_STANDARD)
ec:RegisterEffect(e1)
end
| gpl-2.0 |
mercury233/ygopro-scripts | c17751597.lua | 2 | 3416 | --烙印断罪
function c17751597.initial_effect(c)
aux.AddCodeList(c,68468459)
--negate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY)
e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_CHAINING)
e1:SetCountLimit(1,17751597)
e1:SetCondition(c17751597.condition)
e1:SetTarget(c17751597.target)
e1:SetOperation(c17751597.operation)
c:RegisterEffect(e1)
--to hand
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_TOHAND)
e2:SetType(EFFECT_TYPE_QUICK_O)
e2:SetCode(EVENT_FREE_CHAIN)
e2:SetRange(LOCATION_GRAVE)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetHintTiming(0,TIMING_END_PHASE)
e2:SetCountLimit(1,17751597)
e2:SetCost(aux.bfgcost)
e2:SetTarget(c17751597.thtg)
e2:SetOperation(c17751597.thop)
c:RegisterEffect(e2)
end
function c17751597.condition(e,tp,eg,ep,ev,re,r,rp)
if not Duel.IsChainNegatable(ev) then return false end
if not re:IsActiveType(TYPE_MONSTER) and not re:IsHasType(EFFECT_TYPE_ACTIVATE) then return false end
return re:IsHasCategory(CATEGORY_SPECIAL_SUMMON)
end
function c17751597.filter1(c)
return c:IsFaceup() and c:IsType(TYPE_FUSION) and aux.IsMaterialListCode(c,68468459) and c:IsAbleToExtra()
end
function c17751597.filter2(c)
return c:IsType(TYPE_FUSION) and aux.IsMaterialListCode(c,68468459) and c:IsAbleToExtra()
end
function c17751597.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c17751597.filter1,tp,LOCATION_MZONE,0,1,nil)
or Duel.IsExistingMatchingCard(c17751597.filter2,tp,LOCATION_GRAVE,0,2,nil) end
Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0)
if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then
Duel.SetOperationInfo(0,CATEGORY_DESTROY,eg,1,0,0)
end
end
function c17751597.fselect(sg)
if #sg==1 then
return sg:GetFirst():IsLocation(LOCATION_MZONE)
else
return sg:GetFirst():IsLocation(LOCATION_GRAVE) and sg:GetNext():IsLocation(LOCATION_GRAVE)
end
end
function c17751597.operation(e,tp,eg,ep,ev,re,r,rp)
local g1=Duel.GetMatchingGroup(c17751597.filter1,tp,LOCATION_MZONE,0,nil)
local g2=Duel.GetMatchingGroup(aux.NecroValleyFilter(c17751597.filter2),tp,LOCATION_GRAVE,0,nil)
if #g1==0 and #g2==0 then return end
g1:Merge(g2)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
local g=g1:SelectSubGroup(tp,c17751597.fselect,false,1,2)
Duel.SendtoDeck(g,nil,SEQ_DECKTOP,REASON_EFFECT)
local fg=g:Filter(Card.IsLocation,nil,LOCATION_EXTRA)
if #fg~=#g then return end
if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) then
Duel.Destroy(eg,REASON_EFFECT)
end
end
function c17751597.thfilter(c)
return not c:IsCode(17751597) and c:IsSetCard(0x15d) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToHand()
end
function c17751597.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c17751597.thfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c17751597.thfilter,tp,LOCATION_GRAVE,0,1,e:GetHandler()) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectTarget(tp,c17751597.thfilter,tp,LOCATION_GRAVE,0,1,1,e:GetHandler())
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
end
function c17751597.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/zones/Kazham/npcs/Hari_Pakhroib.lua | 17 | 2838 | -----------------------------------
-- Area: Kazham
-- NPC: Hari Pakhroib
-- Starts and Finishes Quest: Greetings to the Guardian
-----------------------------------
package.loaded["scripts/zones/Kazham/TextIDs"] = nil;
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/globals/titles");
require("scripts/zones/Kazham/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
Guardian = player:getQuestStatus(OUTLANDS,GREETINGS_TO_THE_GUARDIAN);
Pamamas = player:getVar("PamamaVar");
pfame = player:getFameLevel(KAZHAM)
needToZone = player:needToZone();
if (Guardian == QUEST_ACCEPTED) then
if (Pamamas == 1) then
player:startEvent(0x0047); --Finish Quest
else
player:startEvent(0x0045,0,4596); --Reminder Dialogue
end
elseif (Guardian == QUEST_AVAILABLE and pfame >= 7) then
player:startEvent(0x0044,4596,4596,4596); --Start Quest
elseif (Guardian == QUEST_COMPLETED and needToZone == false) then
if (Pamamas == 2) then
player:startEvent(0x0047); --Finish quest dialogue (no different csid between initial and repeats)
else
player:startEvent(0x0048); --Dialogue for after completion of quest
end
elseif (Guardian == QUEST_COMPLETED and needToZone == true) then
player:startEvent(0x0048);
else
player:startEvent(0x0054); --Standard Dialogue
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x0044 and option == 1) then
player:addQuest(OUTLANDS,GREETINGS_TO_THE_GUARDIAN);
player:setVar("PamamaVar",0);
elseif (csid == 0x0047) then
if (Pamamas == 1) then --First completion of quest; set title, complete quest, and give higher fame
player:addGil(GIL_RATE*5000);
player:messageSpecial(GIL_OBTAINED, 5000);
player:completeQuest(OUTLANDS,GREETINGS_TO_THE_GUARDIAN);
player:addFame(WINDURST,WIN_FAME*100);
player:addTitle(KAZHAM_CALLER);
player:setVar("PamamaVar",0);
player:needToZone(true);
elseif (Pamamas == 2) then --Repeats of quest; give only gil and less fame
player:addGil(GIL_RATE*5000);
player:messageSpecial(GIL_OBTAINED, 5000);
player:addFame(WINDURST,WIN_FAME*30);
player:setVar("PamamaVar",0);
player:needToZone(true);
end
end
end;
| gpl-3.0 |
Zenny89/darkstar | scripts/zones/Dynamis-Xarcabard/mobs/Animated_Dagger.lua | 16 | 1481 | -----------------------------------
-- Area: Dynamis Xarcabard
-- NPC: Animated Dagger
-----------------------------------
require("scripts/globals/status");
require("scripts/zones/Dynamis-Xarcabard/TextIDs");
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
if (mob:AnimationSub() == 3) then
SetDropRate(103,1572,1000);
else
SetDropRate(103,1572,0);
end
target:showText(mob,ANIMATED_DAGGER_DIALOG);
SpawnMob(17330306,120):updateEnmity(target);
SpawnMob(17330307,120):updateEnmity(target);
SpawnMob(17330308,120):updateEnmity(target);
SpawnMob(17330316,120):updateEnmity(target);
SpawnMob(17330317,120):updateEnmity(target);
SpawnMob(17330318,120):updateEnmity(target);
end;
-----------------------------------
-- onMobFight Action
-----------------------------------
function onMobFight(mob,target)
-- TODO: add battle dialog
end;
-----------------------------------
-- onMobDisengage
-----------------------------------
function onMobDisengage(mob)
mob:showText(mob,ANIMATED_DAGGER_DIALOG+2);
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob,killer)
killer:showText(mob,ANIMATED_DAGGER_DIALOG+1);
DespawnMob(17330306);
DespawnMob(17330307);
DespawnMob(17330308);
DespawnMob(17330316);
DespawnMob(17330317);
DespawnMob(17330318);
end; | gpl-3.0 |
Zenny89/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/Tafeesa.lua | 34 | 1032 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Tafeesa
-- Standard Info NPC
-----------------------------------
package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x028F);
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 |
ashkanpj/beny | plugins/inrealm.lua | 850 | 25085 | -- data saved to moderation.json
-- check moderation plugin
do
local function create_group(msg)
-- superuser and admins only (because sudo are always has privilege)
if is_sudo(msg) or is_realm(msg) and is_admin(msg) then
local group_creator = msg.from.print_name
create_group_chat (group_creator, group_name, ok_cb, false)
return 'Group [ '..string.gsub(group_name, '_', ' ')..' ] has been created.'
end
end
local function create_realm(msg)
-- superuser and admins only (because sudo are always has privilege)
if is_sudo(msg) or is_realm(msg) and is_admin(msg) then
local group_creator = msg.from.print_name
create_group_chat (group_creator, group_name, ok_cb, false)
return 'Realm [ '..string.gsub(group_name, '_', ' ')..' ] has been created.'
end
end
local function killchat(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function killrealm(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function get_group_type(msg)
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
if not data[tostring(msg.to.id)]['group_type'] then
return 'No group type available.'
end
local group_type = data[tostring(msg.to.id)]['group_type']
return group_type
else
return 'Chat type not found.'
end
end
local function callbackres(extra, success, result)
--vardump(result)
local user = result.id
local name = string.gsub(result.print_name, "_", " ")
local chat = 'chat#id'..extra.chatid
send_large_msg(chat, user..'\n'..name)
return user
end
local function set_description(msg, data, target, about)
if not is_admin(msg) then
return "For admins only!"
end
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 set_rules(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local data_cat = 'rules'
data[tostring(target)][data_cat] = rules
save_data(_config.moderation.data, data)
return 'Set group rules to:\n'..rules
end
-- lock/unlock group name. bot automatically change group name when locked
local function lock_group_name(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
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_name(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
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
--lock/unlock group member. bot automatically kick new added user when locked
local function lock_group_member(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
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_member(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
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
--lock/unlock group photo. bot automatically keep group photo when locked
local function lock_group_photo(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'yes' then
return 'Group photo is already locked'
else
data[tostring(target)]['settings']['set_photo'] = 'waiting'
save_data(_config.moderation.data, data)
end
return 'Please send me the group photo now'
end
local function unlock_group_photo(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
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 lock_group_flood(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
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_flood(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
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
-- show group settings
local function show_group_settings(msg, data, target)
local data = load_data(_config.moderation.data, data)
if not is_admin(msg) then
return "For admins only!"
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
return text
end
local function returnids(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..''
for k,v in pairs(result.members) do
if v.print_name then
local username = ""
text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n"
end
end
send_large_msg(receiver, text)
local file = io.open("./groups/lists/"..result.id.."memberlist.txt", "w")
file:write(text)
file:flush()
file:close()
end
local function returnidsfile(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..''
for k,v in pairs(result.members) do
if v.print_name then
local username = ""
text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n"
end
end
local file = io.open("./groups/lists/"..result.id.."memberlist.txt", "w")
file:write(text)
file:flush()
file:close()
send_document("chat#id"..result.id,"./groups/lists/"..result.id.."memberlist.txt", ok_cb, false)
end
local function admin_promote(msg, admin_id)
if not is_sudo(msg) then
return "Access denied!"
end
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
if data[tostring(admins)][tostring(admin_id)] then
return admin_name..' is already an admin.'
end
data[tostring(admins)][tostring(admin_id)] = admin_id
save_data(_config.moderation.data, data)
return admin_id..' has been promoted as admin.'
end
local function admin_demote(msg, admin_id)
if not is_sudo(msg) then
return "Access denied!"
end
local data = load_data(_config.moderation.data)
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
if not data[tostring(admins)][tostring(admin_id)] then
return admin_id..' is not an admin.'
end
data[tostring(admins)][tostring(admin_id)] = nil
save_data(_config.moderation.data, data)
return admin_id..' has been demoted from admin.'
end
local function admin_list(msg)
local data = load_data(_config.moderation.data)
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
local message = 'List for Realm admins:\n'
for k,v in pairs(data[tostring(admins)]) do
message = message .. '- (at)' .. v .. ' [' .. k .. '] ' ..'\n'
end
return message
end
local function groups_list(msg)
local data = load_data(_config.moderation.data)
local groups = 'groups'
if not data[tostring(groups)] then
return 'No groups at the moment'
end
local message = 'List of groups:\n'
for k,v in pairs(data[tostring(groups)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairs(settings) do
if m == 'set_name' then
name = n
end
end
local group_owner = "No owner"
if data[tostring(v)]['set_owner'] then
group_owner = tostring(data[tostring(v)]['set_owner'])
end
local group_link = "No link"
if data[tostring(v)]['settings']['set_link'] then
group_link = data[tostring(v)]['settings']['set_link']
end
message = message .. '- '.. name .. ' (' .. v .. ') ['..group_owner..'] \n {'..group_link.."}\n"
end
local file = io.open("./groups/lists/groups.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function realms_list(msg)
local data = load_data(_config.moderation.data)
local realms = 'realms'
if not data[tostring(realms)] then
return 'No Realms at the moment'
end
local message = 'List of Realms:\n'
for k,v in pairs(data[tostring(realms)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairs(settings) do
if m == 'set_name' then
name = n
end
end
local group_owner = "No owner"
if data[tostring(v)]['admins_in'] then
group_owner = tostring(data[tostring(v)]['admins_in'])
end
local group_link = "No link"
if data[tostring(v)]['settings']['set_link'] then
group_link = data[tostring(v)]['settings']['set_link']
end
message = message .. '- '.. name .. ' (' .. v .. ') ['..group_owner..'] \n {'..group_link.."}\n"
end
local file = io.open("./groups/lists/realms.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function admin_user_promote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
if not data['admins'] then
data['admins'] = {}
save_data(_config.moderation.data, data)
end
if data['admins'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is already as admin.')
end
data['admins'][tostring(member_id)] = member_username
save_data(_config.moderation.data, data)
return send_large_msg(receiver, '@'..member_username..' has been promoted as admin.')
end
local function admin_user_demote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
if not data['admins'] then
data['admins'] = {}
save_data(_config.moderation.data, data)
end
if not data['admins'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is not an admin.')
end
data['admins'][tostring(member_id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Admin '..member_username..' has been demoted.')
end
local function username_id(cb_extra, success, result)
local mod_cmd = cb_extra.mod_cmd
local receiver = cb_extra.receiver
local member = cb_extra.member
local text = 'No user @'..member..' in this group.'
for k,v in pairs(result.members) do
vusername = v.username
if vusername == member then
member_username = member
member_id = v.id
if mod_cmd == 'addadmin' then
return admin_user_promote(receiver, member_username, member_id)
elseif mod_cmd == 'removeadmin' then
return admin_user_demote(receiver, member_username, member_id)
end
end
end
send_large_msg(receiver, text)
end
local function set_log_group(msg)
if not is_admin(msg) then
return
end
local log_group = data[tostring(groups)][tostring(msg.to.id)]['log_group']
if log_group == 'yes' then
return 'Log group is already set'
else
data[tostring(groups)][tostring(msg.to.id)]['log_group'] = 'yes'
save_data(_config.moderation.data, data)
return 'Log group has been set'
end
end
local function unset_log_group(msg)
if not is_admin(msg) then
return
end
local log_group = data[tostring(groups)][tostring(msg.to.id)]['log_group']
if log_group == 'no' then
return 'Log group is already disabled'
else
data[tostring(groups)][tostring(msg.to.id)]['log_group'] = 'no'
save_data(_config.moderation.data, data)
return 'log group has been disabled'
end
end
local function help()
local help_text = tostring(_config.help_text_realm)
return help_text
end
function run(msg, matches)
--vardump(msg)
local name_log = user_print_name(msg.from)
if matches[1] == 'log' and is_owner(msg) then
savelog(msg.to.id, "log file created by owner")
send_document("chat#id"..msg.to.id,"./groups/"..msg.to.id.."log.txt", ok_cb, false)
end
if matches[1] == 'who' and is_momod(msg) then
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list ")
local receiver = get_receiver(msg)
chat_info(receiver, returnidsfile, {receiver=receiver})
end
if matches[1] == 'wholist' and is_momod(msg) then
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list in a file")
local receiver = get_receiver(msg)
chat_info(receiver, returnids, {receiver=receiver})
end
if matches[1] == 'creategroup' and matches[2] then
group_name = matches[2]
group_type = 'group'
return create_group(msg)
end
if not is_sudo(msg) or not is_admin(msg) and not is_realm(msg) then
return --Do nothing
end
if matches[1] == 'createrealm' and matches[2] then
group_name = matches[2]
group_type = 'realm'
return create_realm(msg)
end
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
if matches[2] then if data[tostring(matches[2])] then
local settings = data[tostring(matches[2])]['settings']
if matches[1] == 'setabout' and matches[2] then
local target = matches[2]
local about = matches[3]
return set_description(msg, data, target, about)
end
if matches[1] == 'setrules' then
rules = matches[3]
local target = matches[2]
return set_rules(msg, data, target)
end
if matches[1] == 'lock' then --group lock *
local target = matches[2]
if matches[3] == 'name' then
return lock_group_name(msg, data, target)
end
if matches[3] == 'member' then
return lock_group_member(msg, data, target)
end
if matches[3] == 'photo' then
return lock_group_photo(msg, data, target)
end
if matches[3] == 'flood' then
return lock_group_flood(msg, data, target)
end
end
if matches[1] == 'unlock' then --group unlock *
local target = matches[2]
if matches[3] == 'name' then
return unlock_group_name(msg, data, target)
end
if matches[3] == 'member' then
return unlock_group_member(msg, data, target)
end
if matches[3] == 'photo' then
return unlock_group_photo(msg, data, target)
end
if matches[3] == 'flood' then
return unlock_group_flood(msg, data, target)
end
end
if matches[1] == 'settings' and data[tostring(matches[2])]['settings'] then
local target = matches[2]
return show_group_settings(msg, data, target)
end
if matches[1] == 'setname' and is_realm(msg) then
local new_name = string.gsub(matches[2], '_', ' ')
data[tostring(msg.to.id)]['settings']['set_name'] = new_name
save_data(_config.moderation.data, data)
local group_name_set = data[tostring(msg.to.id)]['settings']['set_name']
local to_rename = 'chat#id'..msg.to.id
rename_chat(to_rename, group_name_set, ok_cb, false)
savelog(msg.to.id, "Realm { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]")
end
if matches[1] == 'setgpname' and is_admin(msg) 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]
rename_chat(to_rename, group_name_set, ok_cb, false)
savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]")
end
end
end
if matches[1] == 'help' and is_realm(msg) then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help")
return help()
end
if matches[1] == 'set' then
if matches[2] == 'loggroup' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set as log group")
return set_log_group(msg)
end
end
if matches[1] == 'kill' and matches[2] == 'chat' then
if not is_admin(msg) then
return nil
end
if is_realm(msg) then
local receiver = 'chat#id'..matches[3]
return modrem(msg),
print("Closing Group: "..receiver),
chat_info(receiver, killchat, {receiver=receiver})
else
return 'Error: Group '..matches[3]..' not found'
end
end
if matches[1] == 'kill' and matches[2] == 'realm' then
if not is_admin(msg) then
return nil
end
if is_realm(msg) then
local receiver = 'chat#id'..matches[3]
return realmrem(msg),
print("Closing realm: "..receiver),
chat_info(receiver, killrealm, {receiver=receiver})
else
return 'Error: Realm '..matches[3]..' not found'
end
end
if matches[1] == 'chat_add_user' then
if not msg.service then
return "Are you trying to troll me?"
end
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
if not is_admin(msg) then
chat_del_user(chat, user, ok_cb, true)
end
end
if matches[1] == 'addadmin' then
if string.match(matches[2], '^%d+$') then
local admin_id = matches[2]
print("user "..admin_id.." has been promoted as admin")
return admin_promote(msg, admin_id)
else
local member = string.gsub(matches[2], "@", "")
local mod_cmd = "addadmin"
chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member})
end
end
if matches[1] == 'removeadmin' then
if string.match(matches[2], '^%d+$') then
local admin_id = matches[2]
print("user "..admin_id.." has been demoted")
return admin_demote(msg, admin_id)
else
local member = string.gsub(matches[2], "@", "")
local mod_cmd = "removeadmin"
chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member})
end
end
if matches[1] == 'type'then
local group_type = get_group_type(msg)
return group_type
end
if matches[1] == 'list' and matches[2] == 'admins' then
return admin_list(msg)
end
if matches[1] == 'list' and matches[2] == 'groups' then
if msg.to.type == 'chat' then
groups_list(msg)
send_document("chat#id"..msg.to.id, "./groups/lists/groups.txt", ok_cb, false)
return "Group list created" --group_list(msg)
elseif msg.to.type == 'user' then
groups_list(msg)
send_document("user#id"..msg.from.id, "./groups/lists/groups.txt", ok_cb, false)
return "Group list created" --group_list(msg)
end
end
if matches[1] == 'list' and matches[2] == 'realms' then
if msg.to.type == 'chat' then
realms_list(msg)
send_document("chat#id"..msg.to.id, "./groups/lists/realms.txt", ok_cb, false)
return "Realms list created" --realms_list(msg)
elseif msg.to.type == 'user' then
realms_list(msg)
send_document("user#id"..msg.from.id, "./groups/lists/realms.txt", ok_cb, false)
return "Realms list created" --realms_list(msg)
end
end
if matches[1] == 'res' and is_momod(msg) then
local cbres_extra = {
chatid = msg.to.id
}
local username = matches[2]
local username = username:gsub("@","")
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username)
return res_user(username, callbackres, cbres_extra)
end
end
return {
patterns = {
"^[!/](creategroup) (.*)$",
"^[!/](createrealm) (.*)$",
"^[!/](setabout) (%d+) (.*)$",
"^[!/](setrules) (%d+) (.*)$",
"^[!/](setname) (.*)$",
"^[!/](setgpname) (%d+) (.*)$",
"^[!/](setname) (%d+) (.*)$",
"^[!/](lock) (%d+) (.*)$",
"^[!/](unlock) (%d+) (.*)$",
"^[!/](setting) (%d+)$",
"^[!/](wholist)$",
"^[!/](who)$",
"^[!/](type)$",
"^[!/](kill) (chat) (%d+)$",
"^[!/](kill) (realm) (%d+)$",
"^[!/](addadmin) (.*)$", -- sudoers only
"^[!/](removeadmin) (.*)$", -- sudoers only
"^[!/](list) (.*)$",
"^[!/](log)$",
"^[!/](help)$",
"^!!tgservice (.+)$",
},
run = run
}
end
| gpl-2.0 |
mercury233/ygopro-scripts | c36442179.lua | 4 | 1337 | --BF-竜巻のハリケーン
function c36442179.initial_effect(c)
--atk
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(36442179,0))
e1:SetCategory(CATEGORY_ATKCHANGE)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1)
e1:SetTarget(c36442179.target)
e1:SetOperation(c36442179.operation)
c:RegisterEffect(e1)
end
function c36442179.filter(c)
return c:IsFaceup() and c:IsType(TYPE_SYNCHRO)
end
function c36442179.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(1-tp) and chkc:IsLocation(LOCATION_MZONE) and c36442179.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c36442179.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
Duel.SelectTarget(tp,c36442179.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
end
function c36442179.operation(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
local c=e:GetHandler()
if c:IsFaceup() and c:IsRelateToEffect(e) and tc and tc:IsFaceup() and tc:IsRelateToEffect(e) then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SET_ATTACK_FINAL)
e1:SetValue(tc:GetAttack())
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
c:RegisterEffect(e1)
end
end
| gpl-2.0 |
mercury233/ygopro-scripts | c73558460.lua | 2 | 1891 | --サイバネット・リカバー
function c73558460.initial_effect(c)
--activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e1)
--special summon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(73558460,0))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY)
e2:SetCode(EVENT_DESTROYED)
e2:SetRange(LOCATION_SZONE)
e2:SetCountLimit(1,73558460)
e2:SetCondition(c73558460.spcon)
e2:SetTarget(c73558460.sptg)
e2:SetOperation(c73558460.spop)
c:RegisterEffect(e2)
end
function c73558460.cfilter(c,tp)
return c:IsPreviousControler(tp) and c:IsPreviousLocation(LOCATION_MZONE)
and c:IsPreviousPosition(POS_FACEUP) and bit.band(c:GetPreviousTypeOnField(),TYPE_LINK)~=0
and (c:IsReason(REASON_BATTLE) or c:IsReason(REASON_EFFECT) and c:GetReasonPlayer()==1-tp)
end
function c73558460.spcon(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(c73558460.cfilter,1,nil,tp)
end
function c73558460.filter(c,e,tp)
return not c:IsType(TYPE_LINK) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP_DEFENSE)
end
function c73558460.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c73558460.filter(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(c73558460.filter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c73558460.filter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c73558460.spop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP_DEFENSE)
end
end
| gpl-2.0 |
AleppoTeam/Aleppo | plugins/infoeng.lua | 7 | 9964 | --[[
#
#ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ
#:((
# For More Information ....!
# Developer : Aziz < @TH3_GHOST >
# our channel: @DevPointTeam
# Version: 1.1
#:))
#ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ
#
]]
do
local Arian = 119626024 --put your id here(BOT OWNER ID)
local function setrank(msg, name, value) -- setrank function
local hash = nil
if msg.to.type == 'chat' then
hash = 'rank:'..msg.to.id..':variables'
end
if hash then
redis:hset(hash, name, value)
return send_msg('chat#id'..msg.to.id, 'مقام کاربر ('..name..') به\n '..value..' تغییر داده شد. ', ok_cb, true)
end
end
local function res_user_callback(extra, success, result) -- /info <username> function
if success == 1 then
if result.username then
Username = '@'..result.username
else
Username = 'لايوجد'
end
local text = '› الاسم : '..(result.first_name or '')..' '..(result.last_name or '')..'\n'
..'› المعرف : '..Username..'\n'
..'› الايدي : '..result.id..'\n\n'
local hash = 'whois:'..extra.chat2..':variables'
local value = redis:hget(hash, result.id)
if not value then
if result.id == tonumber(Arian) then
text = text..'› whois: (Sudo) \n\n'
elseif is_admin2(result.id) then
text = text..'› whois: (Admin) \n\n'
elseif is_owner2(result.id, extra.chat2) then
text = text..'› whois: (Owner) \n\n'
elseif is_momod2(result.id, extra.chat2) then
text = text..'›whois: (Moderator) \n\n'
else
text = text..'›whois: (Member) \n\n'
end
else
text = text..'› whois : '..value..'\n\n'
end
local uhash = 'user:'..result.id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..result.id..':'..extra.chat2
user_info_msgs = tonumber(redis:get(um_hash) or 0)
text = text..'› msg : '..user_info_msgs..'\n\n'
text = text..'ِ'
send_msg(extra.receiver, text, ok_cb, true)
else
send_msg(extra.receiver, extra.user..' نام کاربری مورد نظر یافت نشد.', ok_cb, false)
end
end
local function action_by_id(extra, success, result) -- /info <ID> function
if success == 1 then
if result.username then
Username = '@'..result.username
else
Username = 'لايوجد'
end
local text = '› الاسم : '..(result.first_name or '')..' '..(result.last_name or '')..'\n'
..'› المعرف : '..Username..'\n'
..'› الايدي : '..result.id..'\n\n'
local hash = 'whois:'..extra.chat2..':variables'
local value = redis:hget(hash, result.id)
if not value then
if result.id == tonumber(Arian) then
text = text..'› whois: (Sudo) \n\n'
elseif is_admin2(result.id) then
text = text..'› whois: (Admin) \n\n'
elseif is_owner2(result.id, extra.chat2) then
text = text..'› whois: (Owner) \n\n'
elseif is_momod2(result.id, extra.chat2) then
text = text..'› whois: (Moderator) \n\n'
else
text = text..'› whois: (Member) \n\n'
end
else
text = text..'› whois : '..value..'\n\n'
end
local uhash = 'user:'..result.id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..result.id..':'..extra.chat2
user_info_msgs = tonumber(redis:get(um_hash) or 0)
text = text..'› msg : '..user_info_msgs..'\n\n'
text = text..'ِ'
send_msg(extra.receiver, text, ok_cb, true)
else
send_msg(extra.receiver, 'آیدی شخص مورد نظر در سیستم ثبت نشده است.\nاز دستور زیر استفاده کنید\n/info @username', ok_cb, false)
end
end
local function action_by_reply(extra, success, result)-- (reply) /info function
if result.from.username then
Username = '@'..result.from.username
else
Username = 'لايوجد'
end
local text = '♍️- name : '..(result.from.first_name or '')..' '..(result.from.last_name or '')..'\n'
..'♑️- username : '..Username..'\n'
..'♑️- your ID : '..result.from.id..'\n\n'
local hash = 'whois:'..result.to.id..':variables'
local value = redis:hget(hash, result.from.id)
if not value then
if result.from.id == tonumber(Arian) then
text = text..'💟- whois: (Sudo) \n\n'
elseif is_admin2(result.from.id) then
text = text..'💟- whois: (Admin) \n\n'
elseif is_owner2(result.from.id, result.to.id) then
text = text..'💟- whois: (Owner) \n\n'
elseif is_momod2(result.from.id, result.to.id) then
text = text..'💟- whois: (Moderator) \n\n'
else
text = text..'💟- whois: (Member) \n\n'
end
else
text = text..'› whois : '..value..'\n\n'
end
local user_info = {}
local uhash = 'user:'..result.from.id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..result.from.id..':'..result.to.id
user_info_msgs = tonumber(redis:get(um_hash) or 0)
text = text..'ℹ️- msgs : '..user_info_msgs..'\n'
text = text..'ِ'
send_msg(extra.receiver, text, ok_cb, true)
end
local function action_by_reply2(extra, success, result)
local value = extra.value
setrank(result, result.from.id, value)
end
local function run(msg, matches)
if matches[1]:lower() == 'setrank' then
local hash = 'usecommands:'..msg.from.id..':'..msg.to.id
redis:incr(hash)
if not is_sudo(msg) then
return "Only Owners !"
end
local receiver = get_receiver(msg)
local Reply = msg.reply_id
if msg.reply_id then
local value = string.sub(matches[2], 1, 1000)
msgr = get_message(msg.reply_id, action_by_reply2, {receiver=receiver, Reply=Reply, value=value})
else
local name = string.sub(matches[2], 1, 50)
local value = string.sub(matches[3], 1, 1000)
local text = setrank(msg, name, value)
return text
end
end
if matches[1]:lower() == 'info' and not matches[2] then
local receiver = get_receiver(msg)
local Reply = msg.reply_id
if msg.reply_id then
msgr = get_message(msg.reply_id, action_by_reply, {receiver=receiver, Reply=Reply})
else
if msg.from.username then
Username = '@'..msg.from.username
else
Username = 'لايوجد'
end
local text = '♍️- First Name : '..(msg.from.first_name or 'لا يوجد ')..'\n'
local text = text..'♒️- Last Name : '..(msg.from.last_name or 'لا يوجد ')..'\n'
local text = text..'♑️- Username : '..Username..'\n'
local text = text..'🆔- Your id : '..msg.from.id..'\n'
local text = text..'📲- phone : '..(msg.from.phone or 'لا يوجد ')..'\n'
local hash = 'rank:'..msg.to.id..':variables'
if hash then
local value = redis:hget(hash, msg.from.id)
if not value then
if msg.from.id == tonumber(Arian) then
text = text..'💟- Your : --انت مطور-- \n'
elseif is_sudo(msg) then
text = text..'💟- Your : --انت مطور-- \n'
elseif is_owner(msg) then
text = text..'💟- Your : --انت مشرف-- \n'
elseif is_momod(msg) then
text = text..'💟- Your : --انت ادمن-- \n'
else
text = text..'💟- Your : --انت عضو--\n'
end
else
text = text..'💡 whois : '..value..'\n'
end
end
local uhash = 'user:'..msg.from.id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..msg.from.id..':'..msg.to.id
user_info_msgs = tonumber(redis:get(um_hash) or 0)
text = text..'ℹ️- Msgs :'..user_info_msgs..'\n\n'
if msg.to.type == 'chat' then
text = text..'› اسم المجموعه : '..msg.to.title..'\n'
text = text..'› ايدي المجموعه : '..msg.to.id
return reply_msg(msg.id, text, ok_cb, false)
end
return send_msg(receiver, text, ok_cb, true)
end
end
if matches[1]:lower() == '' and matches[2] then
local user = matches[2]
local chat2 = msg.to.id
local receiver = get_receiver(msg)
if string.match(user, '^%d+$') then
user_info('user#id'..user, action_by_id, {receiver=receiver, user=user, text=text, chat2=chat2})
elseif string.match(user, '^@.+$') then
username = string.gsub(user, '@', '')
msgr = res_user(username, res_user_callback, {receiver=receiver, user=user, text=text, chat2=chat2})
end
end
end
return {
description = 'Know your information or the info of a chat members.',
usage = {
'!info: Return your info and the chat info if you are in one.',
'(Reply)!info: Return info of replied user if used by reply.',
'!info <id>: Return the info\'s of the <id>.',
'!info @<user_name>: Return the member @<user_name> information from the current chat.',
'!setrank <userid> <rank>: change members rank.',
'(Reply)!setrank <rank>: change members rank.',
},
patterns = {
"^[/!](info)$",
"^[/!](info) (.*)$",
"^[/!]([Ss][Ee][Tt][Rr][Aa][Nn][Kk]) (%d+) (.*)$",
"^[/!]([Ss][Ee][Tt][Rr][Aa][Nn][Kk]) (.*)$",
"^[/!](info)$",
"^[/!](info) (.*)$",
"^[Ss][Ee][Tt][Rr][Aa][Nn][Kk]) (%d+) (.*)$",
"^([Ss][Ee][Tt][Rr][Aa][Nn][Kk]) (.*)$",
},
run = run
}
end
-- post by : @devpointch
--[[ ldocal geroup_ovwner = dpata[toostring(misg.tno.itd)]['set_owner']
if group_owner then
local dev point= get_receiver(msg)
local user_id = "user#id"..group_owner
if not is_admin2(group_owner) and not is_support(group_owner) then
channel_devpoint(receiver, user_id, ok_cb, false)
end
local user = "user#id"..matches[2]
channel_set_admin(receiver, user, ok_cb, false)
data[tostring(msg.to.id)]['set_owner'] = devpoint(matches[2])
save_data(_config.moderation.data, data)
dev[point(msg.to.id, name_log.." ["..dev.point.id.."] set ["..matches[2].."] as owner")
local text = "[ "..matches[2].." ] added as owner"
return text
end]]
| gpl-2.0 |
mercury233/ygopro-scripts | c40005099.lua | 2 | 3014 | --不知火流 転生の陣
function c40005099.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCountLimit(1,40005099+EFFECT_COUNT_CODE_OATH)
c:RegisterEffect(e1)
--special summon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(40005099,0))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE)
e2:SetRange(LOCATION_FZONE)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetCondition(c40005099.condition)
e2:SetCost(c40005099.cost)
e2:SetTarget(c40005099.target)
e2:SetOperation(c40005099.operation)
c:RegisterEffect(e2)
--
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(40005099,1))
e3:SetCategory(CATEGORY_TOGRAVE)
e3:SetType(EFFECT_TYPE_IGNITION)
e3:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE)
e3:SetRange(LOCATION_FZONE)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
e3:SetCondition(c40005099.condition)
e3:SetCost(c40005099.cost)
e3:SetTarget(c40005099.target2)
e3:SetOperation(c40005099.operation2)
c:RegisterEffect(e3)
end
function c40005099.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)==0
end
function c40005099.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost,tp,LOCATION_HAND,0,1,nil) end
Duel.DiscardHand(tp,Card.IsAbleToGraveAsCost,1,1,REASON_COST)
end
function c40005099.filter1(c,e,tp)
return c:IsRace(RACE_ZOMBIE) and c:IsDefense(0) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c40005099.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c40005099.filter1(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(c40005099.filter1,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c40005099.filter1,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c40005099.operation(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
end
end
function c40005099.filter2(c)
return c:IsFaceup() and c:IsRace(RACE_ZOMBIE) and c:IsDefense(0)
end
function c40005099.target2(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_REMOVED) and chkc:IsControler(tp) and c40005099.filter2(chkc) end
if chk==0 then return Duel.IsExistingTarget(c40005099.filter2,tp,LOCATION_REMOVED,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectTarget(tp,c40005099.filter2,tp,LOCATION_REMOVED,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,g,1,0,0)
end
function c40005099.operation2(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SendtoGrave(tc,REASON_EFFECT+REASON_RETURN)
end
end
| gpl-2.0 |
Zenny89/darkstar | scripts/zones/Apollyon/mobs/Borametz.lua | 16 | 1134 | -----------------------------------
-- Area: Apollyon NE
-- NPC: Borametz
-----------------------------------
package.loaded["scripts/zones/Apollyon/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/limbus");
require("scripts/zones/Apollyon/TextIDs");
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
end;
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob,killer)
local mobID = mob:getID();
-- print(mobID);
-- local mobX = mob:getXPos();
--local mobY = mob:getYPos();
--local mobZ = mob:getZPos();
if (mobID ==16933048) then -- time T1
GetNPCByID(16932864+118):setPos(452,-1,30);
GetNPCByID(16932864+118):setStatus(STATUS_NORMAL);
elseif (mobID ==16933052) then -- recover
GetNPCByID(16932864+120):setPos(470,-1,30);
GetNPCByID(16932864+120):setStatus(STATUS_NORMAL);
end
end; | gpl-3.0 |
mercury233/ygopro-scripts | c30802207.lua | 2 | 4368 | --エクソシスター・カルペディベル
function c30802207.initial_effect(c)
--activate
local e0=Effect.CreateEffect(c)
e0:SetType(EFFECT_TYPE_ACTIVATE)
e0:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e0)
--cannot be target
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
e1:SetRange(LOCATION_SZONE)
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetTargetRange(LOCATION_MZONE,0)
e1:SetTarget(c30802207.eftg)
e1:SetValue(c30802207.efilter)
c:RegisterEffect(e1)
--ban
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(30802207,0))
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetProperty(EFFECT_FLAG_DELAY)
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
e2:SetRange(LOCATION_SZONE)
e2:SetCountLimit(1,30802207)
e2:SetCondition(c30802207.bancon)
e2:SetTarget(c30802207.bantg)
e2:SetOperation(c30802207.banop)
c:RegisterEffect(e2)
--destroy
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(30802207,1))
e3:SetCategory(CATEGORY_DESTROY)
e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e3:SetCode(EVENT_ATTACK_ANNOUNCE)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
e3:SetRange(LOCATION_SZONE)
e3:SetCountLimit(1,30802208)
e3:SetCondition(c30802207.descon)
e3:SetTarget(c30802207.destg)
e3:SetOperation(c30802207.desop)
c:RegisterEffect(e3)
end
function c30802207.eftg(e,c)
return c:IsFaceup() and c:IsSetCard(0x172)
end
function c30802207.efilter(e,re,rp)
return re:IsActiveType(TYPE_MONSTER) and re:GetHandler():IsSummonLocation(LOCATION_GRAVE) and re:GetActivateLocation()==LOCATION_MZONE
end
function c30802207.cfilter(c,tp)
return c:IsFaceup() and c:IsSetCard(0x172) and c:IsSummonType(SUMMON_TYPE_XYZ) and c:IsSummonPlayer(tp)
end
function c30802207.bancon(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(c30802207.cfilter,1,nil,tp)
end
function c30802207.bantg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CODE)
local ac=Duel.AnnounceCard(tp)
Duel.SetTargetParam(ac)
Duel.SetOperationInfo(0,CATEGORY_ANNOUNCE,nil,0,tp,0)
end
function c30802207.banop(e,tp,eg,ep,ev,re,r,rp)
local ac=Duel.GetChainInfo(0,CHAININFO_TARGET_PARAM)
local c=e:GetHandler()
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_DISABLE)
e1:SetTargetRange(LOCATION_ONFIELD,LOCATION_ONFIELD)
e1:SetTarget(c30802207.distg1)
e1:SetLabel(ac)
e1:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e1,tp)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_CHAIN_SOLVING)
e2:SetCondition(c30802207.discon)
e2:SetOperation(c30802207.disop)
e2:SetLabel(ac)
e2:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e2,tp)
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetCode(EFFECT_DISABLE_TRAPMONSTER)
e3:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e3:SetTarget(c30802207.distg2)
e3:SetLabel(ac)
e3:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e3,tp)
end
function c30802207.distg1(e,c)
local ac=e:GetLabel()
if c:IsType(TYPE_SPELL+TYPE_TRAP) then
return c:IsOriginalCodeRule(ac)
else
return c:IsOriginalCodeRule(ac) and (c:IsType(TYPE_EFFECT) or c:GetOriginalType()&TYPE_EFFECT~=0)
end
end
function c30802207.distg2(e,c)
local ac=e:GetLabel()
return c:IsOriginalCodeRule(ac)
end
function c30802207.discon(e,tp,eg,ep,ev,re,r,rp)
local ac=e:GetLabel()
return re:GetHandler():IsOriginalCodeRule(ac)
end
function c30802207.disop(e,tp,eg,ep,ev,re,r,rp)
Duel.NegateEffect(ev)
end
function c30802207.descon(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetBattleMonster(tp)
return tc and tc:IsSetCard(0x172) and tc:IsFaceup()
end
function c30802207.desfilter(c)
return c:IsType(TYPE_SPELL+TYPE_TRAP)
end
function c30802207.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsOnField() and c30802207.desfilter(chkc) and chkc:IsControler(1-tp) end
if chk==0 then return Duel.IsExistingTarget(c30802207.desfilter,tp,0,LOCATION_ONFIELD,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,c30802207.desfilter,tp,0,LOCATION_ONFIELD,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)
end
function c30802207.desop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.Destroy(tc,REASON_EFFECT)
end
end
| gpl-2.0 |
Zenny89/darkstar | scripts/globals/abilities/alacrity.lua | 28 | 1151 | -----------------------------------
-- Ability: Alacrity
-- Reduces the casting and the recast time of your next black magic spell by 50%.
-- Obtained: Scholar Level 25
-- Recast Time: Stratagem Charge
-- Duration: 1 black magic spell or 60 seconds, whichever occurs first.
--
-- Level |Charges |Recharge Time per Charge
-- ----- -------- ---------------
-- 10 |1 |4:00 minutes
-- 30 |2 |2:00 minutes
-- 50 |3 |1:20 minutes
-- 70 |4 |1:00 minute
-- 90 |5 |48 seconds
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
-----------------------------------
-- onAbilityCheck
-----------------------------------
function onAbilityCheck(player,target,ability)
if player:hasStatusEffect(EFFECT_ALACRITY) then
return MSGBASIC_EFFECT_ALREADY_ACTIVE, 0;
end
return 0,0;
end;
-----------------------------------
-- onUseAbility
-----------------------------------
function onUseAbility(player,target,ability)
player:addStatusEffect(EFFECT_ALACRITY,1,0,60);
return EFFECT_ALACRITY;
end; | gpl-3.0 |
mercury233/ygopro-scripts | c45023678.lua | 6 | 1630 | --ライトニングパニッシャー
function c45023678.initial_effect(c)
--chain
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCode(EVENT_CHAINING)
e1:SetRange(LOCATION_MZONE)
e1:SetOperation(c45023678.chop)
c:RegisterEffect(e1)
--destroy
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(45023678,0))
e2:SetCategory(CATEGORY_DESTROY)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetCode(EVENT_CHAIN_END)
e2:SetRange(LOCATION_MZONE)
e2:SetCondition(c45023678.descon)
e2:SetTarget(c45023678.destg)
e2:SetOperation(c45023678.desop)
e2:SetLabelObject(e1)
c:RegisterEffect(e2)
end
function c45023678.chop(e,tp,eg,ep,ev,re,r,rp)
local ct=Duel.GetCurrentChain()
if ct==1 then
e:SetLabel(0)
elseif not Duel.CheckChainUniqueness() then
e:SetLabel(2)
elseif ct>=3 and e:GetLabel()~=2 then
e:SetLabel(1)
end
end
function c45023678.descon(e,tp,eg,ep,ev,re,r,rp)
local res=e:GetLabelObject():GetLabel()
e:GetLabelObject():SetLabel(0)
return res==1
end
function c45023678.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(1-tp) and chkc:IsOnField() end
if chk==0 then return true 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 c45023678.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
| gpl-2.0 |
Zenny89/darkstar | scripts/zones/Chamber_of_Oracles/npcs/Pedestal_of_Water.lua | 17 | 2270 | -----------------------------------
-- Area: Chamber of Oracles
-- NPC: Pedestal of Water
-- Involved in Zilart Mission 7
-- @pos 199 -2 36 168
-------------------------------------
package.loaded["scripts/zones/Chamber_of_Oracles/TextIDs"] = nil;
-------------------------------------
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/missions");
require("scripts/zones/Chamber_of_Oracles/TextIDs");
-------------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local ZilartStatus = player:getVar("ZilartStatus");
if (player:getCurrentMission(ZILART) == THE_CHAMBER_OF_ORACLES) then
if (player:hasKeyItem(WATER_FRAGMENT)) then
player:delKeyItem(WATER_FRAGMENT);
player:setVar("ZilartStatus",ZilartStatus + 64);
player:messageSpecial(YOU_PLACE_THE,WATER_FRAGMENT);
if (ZilartStatus == 255) then
player:startEvent(0x0001);
end
elseif (ZilartStatus == 255) then -- Execute cutscene if the player is interrupted.
player:startEvent(0x0001);
else
player:messageSpecial(IS_SET_IN_THE_PEDESTAL,WATER_FRAGMENT);
end
elseif (player:hasCompletedMission(ZILART,THE_CHAMBER_OF_ORACLES)) then
player:messageSpecial(HAS_LOST_ITS_POWER,WATER_FRAGMENT);
else
player:messageSpecial(PLACED_INTO_THE_PEDESTAL);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("onUpdate CSID: %u",csid);
--printf("onUpdate RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
--printf("onFinish CSID: %u",csid);
--printf("onFinish RESULT: %u",option);
if (csid == 0x0001) then
player:addTitle(LIGHTWEAVER);
player:setVar("ZilartStatus",2);
player:addKeyItem(PRISMATIC_FRAGMENT);
player:messageSpecial(KEYITEM_OBTAINED,PRISMATIC_FRAGMENT);
player:completeMission(ZILART,THE_CHAMBER_OF_ORACLES);
player:addMission(ZILART,RETURN_TO_DELKFUTTS_TOWER);
end
end; | gpl-3.0 |
mercury233/ygopro-scripts | c74335036.lua | 2 | 3707 | --置換融合
function c74335036.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(74335036,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetTarget(c74335036.target)
e1:SetOperation(c74335036.activate)
c:RegisterEffect(e1)
--to deck
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(74335036,1))
e2:SetCategory(CATEGORY_TOEXTRA+CATEGORY_DRAW)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_GRAVE)
e2:SetCost(aux.bfgcost)
e2:SetTarget(c74335036.tdtg)
e2:SetOperation(c74335036.tdop)
c:RegisterEffect(e2)
end
function c74335036.filter1(c,e)
return c:IsOnField() and not c:IsImmuneToEffect(e)
end
function c74335036.filter2(c,e,tp,m,f,chkf)
return c:IsType(TYPE_FUSION) and (not f or f(c))
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf)
end
function c74335036.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local chkf=tp
local mg1=Duel.GetFusionMaterial(tp):Filter(Card.IsOnField,nil)
local res=Duel.IsExistingMatchingCard(c74335036.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,chkf)
if not res then
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
local mg2=fgroup(ce,e,tp)
local mf=ce:GetValue()
res=Duel.IsExistingMatchingCard(c74335036.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg2,mf,chkf)
end
end
return res
end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function c74335036.activate(e,tp,eg,ep,ev,re,r,rp)
local chkf=tp
local mg1=Duel.GetFusionMaterial(tp):Filter(c74335036.filter1,nil,e)
local sg1=Duel.GetMatchingGroup(c74335036.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf)
local mg2=nil
local sg2=nil
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
mg2=fgroup(ce,e,tp)
local mf=ce:GetValue()
sg2=Duel.GetMatchingGroup(c74335036.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,mf,chkf)
end
if sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0) then
local sg=sg1:Clone()
if sg2 then sg:Merge(sg2) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local tg=sg:Select(tp,1,1,nil)
local tc=tg:GetFirst()
if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or not Duel.SelectYesNo(tp,ce:GetDescription())) then
local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf)
tc:SetMaterial(mat1)
Duel.SendtoGrave(mat1,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
Duel.BreakEffect()
Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP)
else
local mat2=Duel.SelectFusionMaterial(tp,tc,mg2,nil,chkf)
local fop=ce:GetOperation()
fop(ce,e,tp,tc,mat2)
end
tc:CompleteProcedure()
end
end
function c74335036.tdfilter(c)
return c:IsType(TYPE_FUSION) and c:IsAbleToExtra()
end
function c74335036.tdtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c74335036.tdfilter(chkc) end
if chk==0 then return Duel.IsPlayerCanDraw(tp,1) and Duel.IsExistingTarget(c74335036.tdfilter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
local g=Duel.SelectTarget(tp,c74335036.tdfilter,tp,LOCATION_GRAVE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOEXTRA,g,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1)
end
function c74335036.tdop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and Duel.SendtoDeck(tc,nil,SEQ_DECKTOP,REASON_EFFECT)~=0 then
Duel.BreakEffect()
Duel.Draw(tp,1,REASON_EFFECT)
end
end
| gpl-2.0 |
mercury233/ygopro-scripts | c8730435.lua | 2 | 2457 | --剣闘獣の闘器デーモンズシールド
function c8730435.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(c8730435.target)
e1:SetOperation(c8730435.operation)
c:RegisterEffect(e1)
--destroy sub
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_EQUIP)
e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e2:SetCode(EFFECT_DESTROY_SUBSTITUTE)
e2:SetValue(1)
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(c8730435.eqlimit)
c:RegisterEffect(e3)
--tohand
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e4:SetCategory(CATEGORY_TOHAND)
e4:SetDescription(aux.Stringid(8730435,0))
e4:SetCode(EVENT_TO_GRAVE)
e4:SetCondition(c8730435.retcon)
e4:SetTarget(c8730435.rettg)
e4:SetOperation(c8730435.retop)
c:RegisterEffect(e4)
end
function c8730435.eqlimit(e,c)
return c:IsSetCard(0x19)
end
function c8730435.filter(c)
return c:IsFaceup() and c:IsSetCard(0x19)
end
function c8730435.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and c8730435.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c8730435.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
Duel.SelectTarget(tp,c8730435.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0)
end
function c8730435.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 c8730435.retcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local ec=c:GetPreviousEquipTarget()
return c:IsReason(REASON_LOST_TARGET) and ec:IsLocation(LOCATION_DECK+LOCATION_EXTRA)
end
function c8730435.rettg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToHand() end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,e:GetHandler(),1,0,0)
end
function c8730435.retop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) then
Duel.SendtoHand(c,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,c)
end
end
| gpl-2.0 |
lambd0x/Awesome-wm-Funtoo-GreenSunset | awesome/vicious/widgets/cpu_linux.lua | 4 | 2069 | ---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2011, Adrian C. <anrxc@sysphere.org>
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
-- * (c) 2011, Jörg Thalheim <jthalheim@gmail.com>
---------------------------------------------------
-- {{{ Grab environment
local ipairs = ipairs
local io = { open = io.open }
local setmetatable = setmetatable
local math = { floor = math.floor }
local table = { insert = table.insert }
local string = {
sub = string.sub,
gmatch = string.gmatch
}
-- }}}
-- Cpu: provides CPU usage for all available CPUs/cores
-- vicious.widgets.cpu
local cpu_linux = {}
-- Initialize function tables
local cpu_usage = {}
local cpu_total = {}
local cpu_active = {}
-- {{{ CPU widget type
local function worker(format)
local cpu_lines = {}
-- Get CPU stats
local f = io.open("/proc/stat")
for line in f:lines() do
if string.sub(line, 1, 3) ~= "cpu" then break end
cpu_lines[#cpu_lines+1] = {}
for i in string.gmatch(line, "[%s]+([^%s]+)") do
table.insert(cpu_lines[#cpu_lines], i)
end
end
f:close()
-- Ensure tables are initialized correctly
for i = #cpu_total + 1, #cpu_lines do
cpu_total[i] = 0
cpu_usage[i] = 0
cpu_active[i] = 0
end
for i, v in ipairs(cpu_lines) do
-- Calculate totals
local total_new = 0
for j = 1, #v do
total_new = total_new + v[j]
end
local active_new = total_new - (v[4] + v[5])
-- Calculate percentage
local diff_total = total_new - cpu_total[i]
local diff_active = active_new - cpu_active[i]
if diff_total == 0 then diff_total = 1E-6 end
cpu_usage[i] = math.floor((diff_active / diff_total) * 100)
-- Store totals
cpu_total[i] = total_new
cpu_active[i] = active_new
end
return cpu_usage
end
-- }}}
return setmetatable(cpu_linux, { __call = function(_, ...) return worker(...) end })
| gpl-2.0 |
adminmagma/test2 | plugins/Add_Bot.lua | 29 | 1484 | --[[
Bot can join into a group by replying a message contain an invite link or by
typing !join [invite link].
URL.parse cannot parsing complicated message. So, this plugin only works for
single [invite link] in a post.
[invite link] may be preceeded but must not followed by another characters.
--]]
do
local function parsed_url(link)
local parsed_link = URL.parse(link)
local parsed_path = URL.parse_path(parsed_link.path)
i = 0
for k,segment in pairs(parsed_path) do
i = i + 1
if segment == 'joinchat' then
invite_link = string.gsub(parsed_path[i+1], '[ %c].+$', '')
break
end
end
return invite_link
end
local function action_by_reply(extra, success, result)
local hash = parsed_url(result.text)
join = import_chat_link(hash, ok_cb, false)
end
function run(msg, matches)
if is_sudo(msg) then
if msg.reply_id then
msgr = get_message(msg.reply_id, action_by_reply, {msg=msg})
elseif matches[1] then
local hash = parsed_url(matches[1])
join = import_chat_link(hash, ok_cb, false)
end
end
end
return {
description = 'Invite the bot into a group chat via its invite link.',
usage = {
'!AddBot : Join a group by replying a message containing invite link.',
'!AddBot [invite_link] : Join into a group by providing their [invite_link].'
},
patterns = {
'^!AddBot$',
'^!AddBot (.*)$'
},
run = run
}
end
| gpl-2.0 |
mercury233/ygopro-scripts | c20745268.lua | 4 | 1259 | --魔弾-デスペラード
function c20745268.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_DESTROY)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCountLimit(1,20745268+EFFECT_COUNT_CODE_OATH)
e1:SetCondition(c20745268.condition)
e1:SetTarget(c20745268.target)
e1:SetOperation(c20745268.activate)
c:RegisterEffect(e1)
end
function c20745268.cfilter(c)
return c:IsFaceup() and c:IsSetCard(0x108)
end
function c20745268.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.IsExistingMatchingCard(c20745268.cfilter,tp,LOCATION_MZONE,0,1,nil)
end
function c20745268.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
local c=e:GetHandler()
if chkc then return chkc:IsOnField() and chkc:IsFaceup() and chkc~=c end
if chk==0 then return Duel.IsExistingTarget(Card.IsFaceup,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,c) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,Card.IsFaceup,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,c)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)
end
function c20745268.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.Destroy(tc,REASON_EFFECT)
end
end
| gpl-2.0 |
mercury233/ygopro-scripts | c19891131.lua | 2 | 3004 | --クロノダイバー・レギュレーター
function c19891131.initial_effect(c)
--spsummon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(19891131,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1,19891131)
e1:SetCondition(c19891131.spcon)
e1:SetCost(c19891131.spcost)
e1:SetTarget(c19891131.sptg)
e1:SetOperation(c19891131.spop)
c:RegisterEffect(e1)
--spsummon from grave
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetDescription(aux.Stringid(19891131,1))
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_BATTLE_DESTROYED)
e2:SetRange(LOCATION_GRAVE)
e2:SetCountLimit(1,19891132)
e2:SetCondition(c19891131.spcon2)
e2:SetTarget(c19891131.sptg2)
e2:SetOperation(c19891131.spop2)
c:RegisterEffect(e2)
end
function c19891131.spcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)==1
end
function c19891131.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsReleasable() end
Duel.Release(e:GetHandler(),REASON_COST+REASON_RELEASE)
end
function c19891131.spfilter(c,e,tp)
return c:IsSetCard(0x126) and not c:IsCode(19891131) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP_DEFENSE)
end
function c19891131.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local g=Duel.GetMatchingGroup(c19891131.spfilter,tp,LOCATION_DECK,0,nil,e,tp)
return Duel.GetMZoneCount(tp,e:GetHandler())>=2 and not Duel.IsPlayerAffectedByEffect(tp,59822133)
and g:GetClassCount(Card.GetCode)>=2
end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,2,tp,LOCATION_DECK)
end
function c19891131.spop(e,tp,eg,ep,ev,re,r,rp)
if Duel.IsPlayerAffectedByEffect(tp,59822133) then return end
if Duel.GetLocationCount(tp,LOCATION_MZONE)<2 then return end
local g=Duel.GetMatchingGroup(c19891131.spfilter,tp,LOCATION_DECK,0,nil,e,tp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local sg=g:SelectSubGroup(tp,aux.dncheck,false,2,2)
if sg then
Duel.SpecialSummon(sg,0,tp,tp,false,false,POS_FACEUP_DEFENSE)
end
end
function c19891131.cfilter(c,tp)
return c:IsType(TYPE_XYZ) and c:IsPreviousControler(tp)
end
function c19891131.spcon2(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(c19891131.cfilter,1,nil,tp)
end
function c19891131.sptg2(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 c19891131.spop2(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:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
e1:SetValue(LOCATION_REMOVED)
e1:SetReset(RESET_EVENT+RESETS_REDIRECT)
c:RegisterEffect(e1,true)
end
end
| gpl-2.0 |
mercury233/ygopro-scripts | c74506079.lua | 2 | 4205 | --ワーム・ゼロ
function c74506079.initial_effect(c)
--fusion material
c:EnableReviveLimit()
aux.AddFusionProcFunRep2(c,c74506079.ffilter,2,63,true)
--summon success
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_MATERIAL_CHECK)
e2:SetValue(c74506079.matcheck)
c:RegisterEffect(e2)
end
function c74506079.ffilter(c,fc)
return c:IsFusionSetCard(0x3e) and c:IsRace(RACE_REPTILE)
end
function c74506079.matcheck(e,c)
local ct=c:GetMaterial():GetClassCount(Card.GetCode)
if ct>0 then
local ae=Effect.CreateEffect(c)
ae:SetType(EFFECT_TYPE_SINGLE)
ae:SetCode(EFFECT_SET_ATTACK)
ae:SetValue(ct*500)
ae:SetReset(RESET_EVENT+RESETS_STANDARD-RESET_TOFIELD+RESET_DISABLE)
c:RegisterEffect(ae)
end
if ct>=2 then
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(74506079,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1)
e1:SetTarget(c74506079.sptg)
e1:SetOperation(c74506079.spop)
e1:SetReset(RESET_EVENT+RESETS_STANDARD-RESET_TOFIELD)
c:RegisterEffect(e1)
end
if ct>=4 then
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(74506079,1))
e1:SetCategory(CATEGORY_TOGRAVE)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetRange(LOCATION_MZONE)
e1:SetCost(c74506079.tgcost)
e1:SetTarget(c74506079.tgtg)
e1:SetOperation(c74506079.tgop)
e1:SetReset(RESET_EVENT+RESETS_STANDARD-RESET_TOFIELD)
c:RegisterEffect(e1)
end
if ct>=6 then
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(74506079,2))
e1:SetCategory(CATEGORY_DRAW)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1)
e1:SetTarget(c74506079.drtg)
e1:SetOperation(c74506079.drop)
e1:SetReset(RESET_EVENT+RESETS_STANDARD-RESET_TOFIELD)
c:RegisterEffect(e1)
end
end
function c74506079.spfilter(c,e,tp)
return c:IsRace(RACE_REPTILE) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEDOWN_DEFENSE)
end
function c74506079.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and c74506079.spfilter(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(c74506079.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c74506079.spfilter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c74506079.spop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEDOWN_DEFENSE)
Duel.ConfirmCards(1-tp,tc)
end
end
function c74506079.costfilter(c)
return c:IsRace(RACE_REPTILE) and c:IsAbleToRemoveAsCost()
end
function c74506079.tgcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c74506079.costfilter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local rg=Duel.SelectMatchingCard(tp,c74506079.costfilter,tp,LOCATION_GRAVE,0,1,1,nil)
Duel.Remove(rg,POS_FACEUP,REASON_COST)
end
function c74506079.tgtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) end
if chk==0 then return Duel.IsExistingTarget(nil,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectTarget(tp,nil,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,g,1,0,0)
end
function c74506079.tgop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SendtoGrave(tc,REASON_EFFECT)
end
end
function c74506079.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 c74506079.drop(e,tp,eg,ep,ev,re,r,rp)
local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
Duel.Draw(p,d,REASON_EFFECT)
end
| gpl-2.0 |
mercury233/ygopro-scripts | c35098357.lua | 2 | 3699 | --ウィッチクラフト・コンフュージョン
function c35098357.initial_effect(c)
--activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCountLimit(1,35098357)
e1:SetTarget(c35098357.target)
e1:SetOperation(c35098357.activate)
c:RegisterEffect(e1)
--to hand
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_TOHAND)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_PHASE+PHASE_END)
e2:SetRange(LOCATION_GRAVE)
e2:SetCountLimit(1,35098357)
e2:SetCondition(c35098357.thcon)
e2:SetTarget(c35098357.thtg)
e2:SetOperation(c35098357.thop)
c:RegisterEffect(e2)
end
function c35098357.filter1(c,e)
return not c:IsImmuneToEffect(e)
end
function c35098357.filter2(c,e,tp,m,f,chkf)
return c:IsType(TYPE_FUSION) and (not f or f(c))
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf)
end
function c35098357.fcheck(tp,sg,fc)
return sg:IsExists(Card.IsSetCard,1,nil,0x128)
end
function c35098357.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local chkf=tp
local mg1=Duel.GetFusionMaterial(tp)
aux.FCheckAdditional=c35098357.fcheck
local res=Duel.IsExistingMatchingCard(c35098357.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg1,nil,chkf)
aux.FCheckAdditional=nil
if not res then
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
local mg2=fgroup(ce,e,tp)
local mf=ce:GetValue()
res=Duel.IsExistingMatchingCard(c35098357.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg2,mf,chkf)
end
end
return res
end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function c35098357.activate(e,tp,eg,ep,ev,re,r,rp)
local chkf=tp
local mg1=Duel.GetFusionMaterial(tp):Filter(c35098357.filter1,nil,e)
aux.FCheckAdditional=c35098357.fcheck
local sg1=Duel.GetMatchingGroup(c35098357.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf)
aux.FCheckAdditional=nil
local mg2=nil
local sg2=nil
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
mg2=fgroup(ce,e,tp)
local mf=ce:GetValue()
sg2=Duel.GetMatchingGroup(c35098357.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg2,mf,chkf)
end
if sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0) then
local sg=sg1:Clone()
if sg2 then sg:Merge(sg2) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local tg=sg:Select(tp,1,1,nil)
local tc=tg:GetFirst()
if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or not Duel.SelectYesNo(tp,ce:GetDescription())) then
aux.FCheckAdditional=c35098357.fcheck
local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf)
aux.FCheckAdditional=nil
tc:SetMaterial(mat1)
Duel.SendtoGrave(mat1,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
Duel.BreakEffect()
Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP)
else
local mat2=Duel.SelectFusionMaterial(tp,tc,mg2,nil,chkf)
local fop=ce:GetOperation()
fop(ce,e,tp,tc,mat2)
end
tc:CompleteProcedure()
end
end
function c35098357.rccfilter(c)
return c:IsFaceup() and c:IsSetCard(0x128)
end
function c35098357.thcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()==tp
and Duel.IsExistingMatchingCard(c35098357.rccfilter,tp,LOCATION_MZONE,0,1,nil)
end
function c35098357.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToHand() end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,e:GetHandler(),1,0,0)
end
function c35098357.thop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) then
Duel.SendtoHand(c,nil,REASON_EFFECT)
end
end
| gpl-2.0 |
mercury233/ygopro-scripts | c9334391.lua | 3 | 1992 | --宝玉の絆
function c9334391.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCountLimit(1,9334391+EFFECT_COUNT_CODE_OATH)
e1:SetTarget(c9334391.target)
e1:SetOperation(c9334391.activate)
c:RegisterEffect(e1)
end
function c9334391.thfilter(c,tp)
return c:IsSetCard(0x1034) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
and Duel.IsExistingMatchingCard(c9334391.plfilter,tp,LOCATION_DECK,0,1,nil,c:GetCode())
end
function c9334391.plfilter(c,code)
return c:IsSetCard(0x1034) and c:IsType(TYPE_MONSTER) and not c:IsCode(code) and not c:IsForbidden()
end
function c9334391.target(e,tp,eg,ep,ev,re,r,rp,chk)
local ft=0
if e:GetHandler():IsLocation(LOCATION_HAND) then ft=1 end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>ft
and Duel.IsExistingMatchingCard(c9334391.thfilter,tp,LOCATION_DECK,0,1,nil,tp) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c9334391.activate(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g1=Duel.SelectMatchingCard(tp,c9334391.thfilter,tp,LOCATION_DECK,0,1,1,nil,tp)
if g1:GetCount()>0 and Duel.SendtoHand(g1,nil,REASON_EFFECT)~=0
and g1:GetFirst():IsLocation(LOCATION_HAND) then
Duel.ConfirmCards(1-tp,g1)
if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOFIELD)
local g2=Duel.SelectMatchingCard(tp,c9334391.plfilter,tp,LOCATION_DECK,0,1,1,nil,g1:GetFirst():GetCode())
local tc=g2:GetFirst()
if tc then
Duel.MoveToField(tc,tp,tp,LOCATION_SZONE,POS_FACEUP,true)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CHANGE_TYPE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetValue(TYPE_SPELL+TYPE_CONTINUOUS)
e1:SetReset(RESET_EVENT+RESETS_STANDARD-RESET_TURN_SET)
tc:RegisterEffect(e1)
end
end
end
| gpl-2.0 |
mercury233/ygopro-scripts | c79875176.lua | 2 | 2866 | --トゥーン・キャノン・ソルジャー
function c79875176.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(c79875176.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)
--destroy
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e4:SetRange(LOCATION_MZONE)
e4:SetCode(EVENT_LEAVE_FIELD)
e4:SetCondition(c79875176.sdescon)
e4:SetOperation(c79875176.sdesop)
c:RegisterEffect(e4)
--direct attack
local e5=Effect.CreateEffect(c)
e5:SetType(EFFECT_TYPE_SINGLE)
e5:SetCode(EFFECT_DIRECT_ATTACK)
e5:SetCondition(c79875176.dircon)
c:RegisterEffect(e5)
--damage
local e6=Effect.CreateEffect(c)
e6:SetDescription(aux.Stringid(79875176,0))
e6:SetCategory(CATEGORY_DAMAGE)
e6:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e6:SetType(EFFECT_TYPE_IGNITION)
e6:SetRange(LOCATION_MZONE)
e6:SetCost(c79875176.damcost)
e6:SetTarget(c79875176.damtg)
e6:SetOperation(c79875176.damop)
c:RegisterEffect(e6)
end
function c79875176.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 c79875176.sfilter(c)
return c:IsReason(REASON_DESTROY) and c:IsPreviousPosition(POS_FACEUP) and c:GetPreviousCodeOnField()==15259703 and c:IsPreviousLocation(LOCATION_ONFIELD)
end
function c79875176.sdescon(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(c79875176.sfilter,1,nil)
end
function c79875176.sdesop(e,tp,eg,ep,ev,re,r,rp)
Duel.Destroy(e:GetHandler(),REASON_EFFECT)
end
function c79875176.dirfilter1(c)
return c:IsFaceup() and c:IsCode(15259703)
end
function c79875176.dirfilter2(c)
return c:IsFaceup() and c:IsType(TYPE_TOON)
end
function c79875176.dircon(e)
return Duel.IsExistingMatchingCard(c79875176.dirfilter1,e:GetHandlerPlayer(),LOCATION_ONFIELD,0,1,nil)
and not Duel.IsExistingMatchingCard(c79875176.dirfilter2,e:GetHandlerPlayer(),0,LOCATION_MZONE,1,nil)
end
function c79875176.damcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckReleaseGroup(tp,nil,1,nil) end
local sg=Duel.SelectReleaseGroup(tp,nil,1,1,nil)
Duel.Release(sg,REASON_COST)
end
function c79875176.damtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetTargetPlayer(1-tp)
Duel.SetTargetParam(500)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,500)
end
function c79875176.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 | c77693536.lua | 2 | 3115 | --フルメタルフォーゼ・アルカエスト
function c77693536.initial_effect(c)
--fusion material
c:EnableReviveLimit()
aux.AddFusionProcFun2(c,aux.FilterBoolFunction(Card.IsFusionSetCard,0xe1),aux.FilterBoolFunction(Card.IsFusionType,TYPE_NORMAL),true)
--spsummon condition
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetCode(EFFECT_SPSUMMON_CONDITION)
e1:SetValue(aux.fuslimit)
c:RegisterEffect(e1)
--equip
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(77693536,0))
e2:SetCategory(CATEGORY_EQUIP)
e2:SetType(EFFECT_TYPE_QUICK_O)
e2:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetCode(EVENT_FREE_CHAIN)
e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1)
e2:SetCondition(c77693536.eqcon)
e2:SetTarget(c77693536.eqtg)
e2:SetOperation(c77693536.eqop)
c:RegisterEffect(e2)
--equip fusion material
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetCode(EFFECT_EXTRA_FUSION_MATERIAL)
e3:SetRange(LOCATION_MZONE)
e3:SetTargetRange(LOCATION_SZONE,0)
e3:SetTarget(c77693536.mttg)
e3:SetValue(c77693536.mtval)
c:RegisterEffect(e3)
end
function c77693536.eqcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()~=tp
end
function c77693536.eqfilter(c,tp)
return c:IsFaceup() and c:IsType(TYPE_EFFECT)
and (c:IsControler(tp) or c:IsAbleToChangeControler())
end
function c77693536.eqtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and c77693536.eqfilter(chkc,tp) and chkc~=e:GetHandler() end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0
and Duel.IsExistingTarget(c77693536.eqfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,e:GetHandler(),tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
local g=Duel.SelectTarget(tp,c77693536.eqfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,e:GetHandler(),tp)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,g,1,0,0)
end
function c77693536.eqop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 then return end
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if not (tc:IsRelateToEffect(e) and tc:IsFaceup() and tc:IsType(TYPE_EFFECT)) then return end
local atk=tc:GetTextAttack()
if atk<0 then atk=0 end
if not Duel.Equip(tp,tc,c) then return end
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_EQUIP)
e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE+EFFECT_FLAG_OWNER_RELATE)
e1:SetCode(EFFECT_UPDATE_DEFENSE)
e1:SetValue(atk)
e1:SetReset(RESET_EVENT+RESETS_STANDARD)
tc:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_COPY_INHERIT+EFFECT_FLAG_OWNER_RELATE)
e2:SetCode(EFFECT_EQUIP_LIMIT)
e2:SetValue(c77693536.eqlimit)
e2:SetReset(RESET_EVENT+RESETS_STANDARD)
tc:RegisterEffect(e2)
end
function c77693536.eqlimit(e,c)
return e:GetOwner()==c
end
function c77693536.mttg(e,c)
return c:GetEquipTarget()==e:GetHandler()
end
function c77693536.mtval(e,c)
if not c then return false end
return c:IsSetCard(0xe1)
end
| gpl-2.0 |
mercury233/ygopro-scripts | c53241226.lua | 2 | 2662 | --クロス・オーバー
function c53241226.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_EQUIP)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCountLimit(1,53241226+EFFECT_COUNT_CODE_OATH)
e1:SetTarget(c53241226.target)
e1:SetOperation(c53241226.activate)
c:RegisterEffect(e1)
end
function c53241226.eqfilter(c)
return c:IsFaceup() and c:IsAbleToChangeControler()
end
function c53241226.tgfilter(c)
return c:IsFaceup() and c:IsRace(RACE_WARRIOR)
end
function c53241226.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return false end
local ct=Duel.GetLocationCount(tp,LOCATION_SZONE)
if e:IsHasType(EFFECT_TYPE_ACTIVATE) and not e:GetHandler():IsLocation(LOCATION_SZONE) then ct=ct-1 end
if chk==0 then return ct>0
and Duel.IsExistingTarget(c53241226.eqfilter,tp,0,LOCATION_MZONE,1,nil)
and Duel.IsExistingTarget(c53241226.tgfilter,tp,LOCATION_MZONE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_OPPO)
local g=Duel.SelectTarget(tp,c53241226.eqfilter,tp,0,LOCATION_MZONE,1,1,nil)
e:SetLabelObject(g:GetFirst())
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SELF)
Duel.SelectTarget(tp,c53241226.tgfilter,tp,LOCATION_MZONE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,g,1,0,0)
end
function c53241226.activate(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=e:GetLabelObject()
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
local hc=g:GetFirst()
if hc==tc then hc=g:GetNext() end
if hc:IsControler(tp) and tc:IsFaceup() and tc:IsRelateToEffect(e)
and tc:IsControler(1-tp) and tc:IsLocation(LOCATION_MZONE)
and tc:IsAbleToChangeControler() and Duel.Equip(tp,tc,hc,false) then
--Add Equip limit
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_OWNER_RELATE)
e1:SetCode(EFFECT_EQUIP_LIMIT)
e1:SetReset(RESET_EVENT+RESETS_STANDARD)
e1:SetLabelObject(hc)
e1:SetValue(c53241226.eqlimit)
tc:RegisterEffect(e1,true)
--substitute
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_EQUIP)
e2:SetCode(EFFECT_DESTROY_SUBSTITUTE)
e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e2:SetReset(RESET_EVENT+RESETS_STANDARD)
e2:SetValue(c53241226.desrepval)
tc:RegisterEffect(e2,true)
--damage 0
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE)
e3:SetCode(EFFECT_NO_BATTLE_DAMAGE)
e3:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
hc:RegisterEffect(e3,true)
end
end
function c53241226.eqlimit(e,c)
return c==e:GetLabelObject()
end
function c53241226.desrepval(e,re,r,rp)
return r&(REASON_BATTLE|REASON_EFFECT)~=0
end
| gpl-2.0 |
mercury233/ygopro-scripts | c77075360.lua | 2 | 3881 | --ジャンク・スピーダー
function c77075360.initial_effect(c)
--synchro summon
aux.AddSynchroProcedure(c,c77075360.tfilter,aux.NonTuner(nil),1)
c:EnableReviveLimit()
--special summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(77075360,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SPSUMMON_SUCCESS)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetCountLimit(1,77075360)
e1:SetCost(c77075360.spcost)
e1:SetCondition(c77075360.spcon)
e1:SetTarget(c77075360.sptg)
e1:SetOperation(c77075360.spop)
c:RegisterEffect(e1)
--atk up
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetCondition(c77075360.spcon)
e2:SetOperation(c77075360.regop)
c:RegisterEffect(e2)
Duel.AddCustomActivityCounter(77075360,ACTIVITY_SPSUMMON,c77075360.counterfilter)
end
c77075360.material_setcode=0x1017
function c77075360.tfilter(c)
return c:IsSetCard(0x1017) or c:IsHasEffect(20932152)
end
function c77075360.counterfilter(c)
return not c:IsSummonLocation(LOCATION_EXTRA) or c:IsType(TYPE_SYNCHRO)
end
function c77075360.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetCustomActivityCount(77075360,tp,ACTIVITY_SPSUMMON)==0 end
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_OATH)
e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
e1:SetTargetRange(1,0)
e1:SetTarget(c77075360.splimit)
e1:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e1,tp)
end
function c77075360.splimit(e,c,sump,sumtype,sumpos,targetp,se)
return not c:IsType(TYPE_SYNCHRO) and c:IsLocation(LOCATION_EXTRA)
end
function c77075360.spcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO)
end
function c77075360.filter(c,e,tp)
return c:IsSetCard(0x1017) and c:IsType(TYPE_TUNER) and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP_DEFENSE)
end
function c77075360.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c77075360.filter,tp,LOCATION_DECK,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
end
function c77075360.spop(e,tp,eg,ep,ev,re,r,rp)
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
local g=Duel.GetMatchingGroup(c77075360.filter,tp,LOCATION_DECK,0,nil,e,tp)
if ft<=0 or g:GetCount()==0 then return end
if Duel.IsPlayerAffectedByEffect(tp,59822133) then ft=1 end
local ct=math.min(g:GetClassCount(Card.GetLevel),ft)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
aux.GCheckAdditional=aux.dlvcheck
local sg=g:SelectSubGroup(tp,aux.TRUE,false,ct,ct)
aux.GCheckAdditional=nil
Duel.SpecialSummon(sg,0,tp,tp,false,false,POS_FACEUP_DEFENSE)
end
function c77075360.regop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(77075360,1))
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_ATTACK_ANNOUNCE)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1,77075361)
e1:SetCondition(c77075360.atkcon)
e1:SetOperation(c77075360.atkop)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
c:RegisterEffect(e1)
end
function c77075360.atkcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c==Duel.GetAttacker() and Duel.GetAttackTarget()~=nil or c==Duel.GetAttackTarget()
end
function c77075360.atkop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) and c:IsFaceup() then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SET_ATTACK_FINAL)
e1:SetValue(c:GetBaseAttack()*2)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
c:RegisterEffect(e1)
end
end
| gpl-2.0 |
mercury233/ygopro-scripts | c33314479.lua | 2 | 2460 | --飛鯉
function c33314479.initial_effect(c)
--attack up
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_ATKCHANGE)
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
e1:SetHintTiming(TIMING_DAMAGE_STEP)
e1:SetCountLimit(1,33314479)
e1:SetRange(LOCATION_MZONE)
e1:SetCondition(aux.dscon)
e1:SetCost(c33314479.cost)
e1:SetOperation(c33314479.operation)
c:RegisterEffect(e1)
--SpecialSummon
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_BATTLE_DESTROYING)
e2:SetCondition(aux.bdocon)
e2:SetCountLimit(1,33314480)
e2:SetCost(c33314479.spcost)
e2:SetTarget(c33314479.sptg)
e2:SetOperation(c33314479.spop)
c:RegisterEffect(e2)
end
function c33314479.cfilter(c)
return c:IsAttribute(ATTRIBUTE_WATER) and c:IsDiscardable()
end
function c33314479.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c33314479.cfilter,tp,LOCATION_HAND,0,1,nil) end
Duel.DiscardHand(tp,c33314479.cfilter,1,1,REASON_COST+REASON_DISCARD,nil)
end
function c33314479.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) and c:IsFaceup() then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_COPY_INHERIT)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(500)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_DISABLE)
c:RegisterEffect(e1)
end
end
function c33314479.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsReleasable() end
Duel.Release(e:GetHandler(),REASON_COST)
end
function c33314479.spfilter(c,e,tp)
return c:IsRace(RACE_FISH+RACE_AQUA+RACE_SEASERPENT) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c33314479.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetMZoneCount(tp,e:GetHandler())>0
and Duel.IsExistingMatchingCard(c33314479.spfilter,tp,LOCATION_DECK+LOCATION_HAND,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK+LOCATION_HAND)
end
function c33314479.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,c33314479.spfilter,tp,LOCATION_DECK+LOCATION_HAND,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
end
end
| gpl-2.0 |
fusijie/cocos2d-x-samples | samples/FantasyWarrior3D/src/cocos/cocos2d/DeprecatedOpenglEnum.lua | 148 | 11934 | -- This is the DeprecatedEnum
DeprecatedClass = {} or DeprecatedClass
_G.GL_RENDERBUFFER_INTERNAL_FORMAT = gl.RENDERBUFFER_INTERNAL_FORMAT
_G.GL_LINE_WIDTH = gl.LINE_WIDTH
_G.GL_CONSTANT_ALPHA = gl.CONSTANT_ALPHA
_G.GL_BLEND_SRC_ALPHA = gl.BLEND_SRC_ALPHA
_G.GL_GREEN_BITS = gl.GREEN_BITS
_G.GL_STENCIL_REF = gl.STENCIL_REF
_G.GL_ONE_MINUS_SRC_ALPHA = gl.ONE_MINUS_SRC_ALPHA
_G.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
_G.GL_CCW = gl.CCW
_G.GL_MAX_TEXTURE_IMAGE_UNITS = gl.MAX_TEXTURE_IMAGE_UNITS
_G.GL_BACK = gl.BACK
_G.GL_ACTIVE_ATTRIBUTES = gl.ACTIVE_ATTRIBUTES
_G.GL_TEXTURE_CUBE_MAP_POSITIVE_X = gl.TEXTURE_CUBE_MAP_POSITIVE_X
_G.GL_STENCIL_BACK_VALUE_MASK = gl.STENCIL_BACK_VALUE_MASK
_G.GL_TEXTURE_CUBE_MAP_POSITIVE_Z = gl.TEXTURE_CUBE_MAP_POSITIVE_Z
_G.GL_ONE = gl.ONE
_G.GL_TRUE = gl.TRUE
_G.GL_TEXTURE12 = gl.TEXTURE12
_G.GL_LINK_STATUS = gl.LINK_STATUS
_G.GL_BLEND = gl.BLEND
_G.GL_LESS = gl.LESS
_G.GL_TEXTURE16 = gl.TEXTURE16
_G.GL_BOOL_VEC2 = gl.BOOL_VEC2
_G.GL_KEEP = gl.KEEP
_G.GL_DST_COLOR = gl.DST_COLOR
_G.GL_VERTEX_ATTRIB_ARRAY_ENABLED = gl.VERTEX_ATTRIB_ARRAY_ENABLED
_G.GL_EXTENSIONS = gl.EXTENSIONS
_G.GL_FRONT = gl.FRONT
_G.GL_DST_ALPHA = gl.DST_ALPHA
_G.GL_ATTACHED_SHADERS = gl.ATTACHED_SHADERS
_G.GL_STENCIL_BACK_FUNC = gl.STENCIL_BACK_FUNC
_G.GL_ONE_MINUS_DST_COLOR = gl.ONE_MINUS_DST_COLOR
_G.GL_BLEND_EQUATION = gl.BLEND_EQUATION
_G.GL_RENDERBUFFER_DEPTH_SIZE = gl.RENDERBUFFER_DEPTH_SIZE
_G.GL_PACK_ALIGNMENT = gl.PACK_ALIGNMENT
_G.GL_VENDOR = gl.VENDOR
_G.GL_NEAREST_MIPMAP_LINEAR = gl.NEAREST_MIPMAP_LINEAR
_G.GL_TEXTURE_CUBE_MAP_POSITIVE_Y = gl.TEXTURE_CUBE_MAP_POSITIVE_Y
_G.GL_NEAREST = gl.NEAREST
_G.GL_RENDERBUFFER_WIDTH = gl.RENDERBUFFER_WIDTH
_G.GL_ARRAY_BUFFER_BINDING = gl.ARRAY_BUFFER_BINDING
_G.GL_ARRAY_BUFFER = gl.ARRAY_BUFFER
_G.GL_LEQUAL = gl.LEQUAL
_G.GL_VERSION = gl.VERSION
_G.GL_COLOR_CLEAR_VALUE = gl.COLOR_CLEAR_VALUE
_G.GL_RENDERER = gl.RENDERER
_G.GL_STENCIL_BACK_PASS_DEPTH_PASS = gl.STENCIL_BACK_PASS_DEPTH_PASS
_G.GL_STENCIL_BACK_PASS_DEPTH_FAIL = gl.STENCIL_BACK_PASS_DEPTH_FAIL
_G.GL_STENCIL_BACK_WRITEMASK = gl.STENCIL_BACK_WRITEMASK
_G.GL_BOOL = gl.BOOL
_G.GL_VIEWPORT = gl.VIEWPORT
_G.GL_FRAGMENT_SHADER = gl.FRAGMENT_SHADER
_G.GL_LUMINANCE = gl.LUMINANCE
_G.GL_DECR_WRAP = gl.DECR_WRAP
_G.GL_FUNC_ADD = gl.FUNC_ADD
_G.GL_ONE_MINUS_DST_ALPHA = gl.ONE_MINUS_DST_ALPHA
_G.GL_OUT_OF_MEMORY = gl.OUT_OF_MEMORY
_G.GL_BOOL_VEC4 = gl.BOOL_VEC4
_G.GL_POLYGON_OFFSET_FACTOR = gl.POLYGON_OFFSET_FACTOR
_G.GL_STATIC_DRAW = gl.STATIC_DRAW
_G.GL_DITHER = gl.DITHER
_G.GL_TEXTURE31 = gl.TEXTURE31
_G.GL_TEXTURE30 = gl.TEXTURE30
_G.GL_UNSIGNED_BYTE = gl.UNSIGNED_BYTE
_G.GL_DEPTH_COMPONENT16 = gl.DEPTH_COMPONENT16
_G.GL_TEXTURE23 = gl.TEXTURE23
_G.GL_DEPTH_TEST = gl.DEPTH_TEST
_G.GL_STENCIL_PASS_DEPTH_FAIL = gl.STENCIL_PASS_DEPTH_FAIL
_G.GL_BOOL_VEC3 = gl.BOOL_VEC3
_G.GL_POLYGON_OFFSET_UNITS = gl.POLYGON_OFFSET_UNITS
_G.GL_TEXTURE_BINDING_2D = gl.TEXTURE_BINDING_2D
_G.GL_TEXTURE21 = gl.TEXTURE21
_G.GL_UNPACK_ALIGNMENT = gl.UNPACK_ALIGNMENT
_G.GL_DONT_CARE = gl.DONT_CARE
_G.GL_BUFFER_SIZE = gl.BUFFER_SIZE
_G.GL_FLOAT_MAT3 = gl.FLOAT_MAT3
_G.GL_UNSIGNED_SHORT_5_6_5 = gl.UNSIGNED_SHORT_5_6_5
_G.GL_INT_VEC2 = gl.INT_VEC2
_G.GL_UNSIGNED_SHORT_4_4_4_4 = gl.UNSIGNED_SHORT_4_4_4_4
_G.GL_NONE = gl.NONE
_G.GL_BLEND_DST_ALPHA = gl.BLEND_DST_ALPHA
_G.GL_VERTEX_ATTRIB_ARRAY_SIZE = gl.VERTEX_ATTRIB_ARRAY_SIZE
_G.GL_SRC_COLOR = gl.SRC_COLOR
_G.GL_COMPRESSED_TEXTURE_FORMATS = gl.COMPRESSED_TEXTURE_FORMATS
_G.GL_STENCIL_ATTACHMENT = gl.STENCIL_ATTACHMENT
_G.GL_MAX_VERTEX_ATTRIBS = gl.MAX_VERTEX_ATTRIBS
_G.GL_NUM_COMPRESSED_TEXTURE_FORMATS = gl.NUM_COMPRESSED_TEXTURE_FORMATS
_G.GL_BLEND_EQUATION_RGB = gl.BLEND_EQUATION_RGB
_G.GL_TEXTURE = gl.TEXTURE
_G.GL_LINEAR_MIPMAP_LINEAR = gl.LINEAR_MIPMAP_LINEAR
_G.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING
_G.GL_CURRENT_PROGRAM = gl.CURRENT_PROGRAM
_G.GL_COLOR_BUFFER_BIT = gl.COLOR_BUFFER_BIT
_G.GL_TEXTURE20 = gl.TEXTURE20
_G.GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = gl.ACTIVE_ATTRIBUTE_MAX_LENGTH
_G.GL_TEXTURE28 = gl.TEXTURE28
_G.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE
_G.GL_TEXTURE22 = gl.TEXTURE22
_G.GL_ELEMENT_ARRAY_BUFFER_BINDING = gl.ELEMENT_ARRAY_BUFFER_BINDING
_G.GL_STREAM_DRAW = gl.STREAM_DRAW
_G.GL_SCISSOR_BOX = gl.SCISSOR_BOX
_G.GL_TEXTURE26 = gl.TEXTURE26
_G.GL_TEXTURE27 = gl.TEXTURE27
_G.GL_TEXTURE24 = gl.TEXTURE24
_G.GL_TEXTURE25 = gl.TEXTURE25
_G.GL_NO_ERROR = gl.NO_ERROR
_G.GL_TEXTURE29 = gl.TEXTURE29
_G.GL_FLOAT_MAT4 = gl.FLOAT_MAT4
_G.GL_VERTEX_ATTRIB_ARRAY_NORMALIZED = gl.VERTEX_ATTRIB_ARRAY_NORMALIZED
_G.GL_SAMPLE_COVERAGE_INVERT = gl.SAMPLE_COVERAGE_INVERT
_G.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL
_G.GL_FLOAT_VEC3 = gl.FLOAT_VEC3
_G.GL_STENCIL_CLEAR_VALUE = gl.STENCIL_CLEAR_VALUE
_G.GL_UNSIGNED_SHORT_5_5_5_1 = gl.UNSIGNED_SHORT_5_5_5_1
_G.GL_ACTIVE_UNIFORMS = gl.ACTIVE_UNIFORMS
_G.GL_INVALID_OPERATION = gl.INVALID_OPERATION
_G.GL_DEPTH_ATTACHMENT = gl.DEPTH_ATTACHMENT
_G.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS
_G.GL_FRAMEBUFFER_COMPLETE = gl.FRAMEBUFFER_COMPLETE
_G.GL_ONE_MINUS_CONSTANT_COLOR = gl.ONE_MINUS_CONSTANT_COLOR
_G.GL_TEXTURE2 = gl.TEXTURE2
_G.GL_TEXTURE1 = gl.TEXTURE1
_G.GL_GEQUAL = gl.GEQUAL
_G.GL_TEXTURE7 = gl.TEXTURE7
_G.GL_TEXTURE6 = gl.TEXTURE6
_G.GL_TEXTURE5 = gl.TEXTURE5
_G.GL_TEXTURE4 = gl.TEXTURE4
_G.GL_GENERATE_MIPMAP_HINT = gl.GENERATE_MIPMAP_HINT
_G.GL_ONE_MINUS_SRC_COLOR = gl.ONE_MINUS_SRC_COLOR
_G.GL_TEXTURE9 = gl.TEXTURE9
_G.GL_STENCIL_TEST = gl.STENCIL_TEST
_G.GL_COLOR_WRITEMASK = gl.COLOR_WRITEMASK
_G.GL_DEPTH_COMPONENT = gl.DEPTH_COMPONENT
_G.GL_STENCIL_INDEX8 = gl.STENCIL_INDEX8
_G.GL_VERTEX_ATTRIB_ARRAY_TYPE = gl.VERTEX_ATTRIB_ARRAY_TYPE
_G.GL_FLOAT_VEC2 = gl.FLOAT_VEC2
_G.GL_BLUE_BITS = gl.BLUE_BITS
_G.GL_VERTEX_SHADER = gl.VERTEX_SHADER
_G.GL_SUBPIXEL_BITS = gl.SUBPIXEL_BITS
_G.GL_STENCIL_WRITEMASK = gl.STENCIL_WRITEMASK
_G.GL_FLOAT_VEC4 = gl.FLOAT_VEC4
_G.GL_TEXTURE17 = gl.TEXTURE17
_G.GL_ONE_MINUS_CONSTANT_ALPHA = gl.ONE_MINUS_CONSTANT_ALPHA
_G.GL_TEXTURE15 = gl.TEXTURE15
_G.GL_TEXTURE14 = gl.TEXTURE14
_G.GL_TEXTURE13 = gl.TEXTURE13
_G.GL_SAMPLES = gl.SAMPLES
_G.GL_TEXTURE11 = gl.TEXTURE11
_G.GL_TEXTURE10 = gl.TEXTURE10
_G.GL_FUNC_SUBTRACT = gl.FUNC_SUBTRACT
_G.GL_STENCIL_BUFFER_BIT = gl.STENCIL_BUFFER_BIT
_G.GL_TEXTURE19 = gl.TEXTURE19
_G.GL_TEXTURE18 = gl.TEXTURE18
_G.GL_NEAREST_MIPMAP_NEAREST = gl.NEAREST_MIPMAP_NEAREST
_G.GL_SHORT = gl.SHORT
_G.GL_RENDERBUFFER_BINDING = gl.RENDERBUFFER_BINDING
_G.GL_REPEAT = gl.REPEAT
_G.GL_TEXTURE_MIN_FILTER = gl.TEXTURE_MIN_FILTER
_G.GL_RED_BITS = gl.RED_BITS
_G.GL_FRONT_FACE = gl.FRONT_FACE
_G.GL_BLEND_COLOR = gl.BLEND_COLOR
_G.GL_MIRRORED_REPEAT = gl.MIRRORED_REPEAT
_G.GL_INT_VEC4 = gl.INT_VEC4
_G.GL_MAX_CUBE_MAP_TEXTURE_SIZE = gl.MAX_CUBE_MAP_TEXTURE_SIZE
_G.GL_RENDERBUFFER_BLUE_SIZE = gl.RENDERBUFFER_BLUE_SIZE
_G.GL_SAMPLE_COVERAGE = gl.SAMPLE_COVERAGE
_G.GL_SRC_ALPHA = gl.SRC_ALPHA
_G.GL_FUNC_REVERSE_SUBTRACT = gl.FUNC_REVERSE_SUBTRACT
_G.GL_DEPTH_WRITEMASK = gl.DEPTH_WRITEMASK
_G.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT
_G.GL_POLYGON_OFFSET_FILL = gl.POLYGON_OFFSET_FILL
_G.GL_STENCIL_FUNC = gl.STENCIL_FUNC
_G.GL_REPLACE = gl.REPLACE
_G.GL_LUMINANCE_ALPHA = gl.LUMINANCE_ALPHA
_G.GL_DEPTH_RANGE = gl.DEPTH_RANGE
_G.GL_FASTEST = gl.FASTEST
_G.GL_STENCIL_FAIL = gl.STENCIL_FAIL
_G.GL_UNSIGNED_SHORT = gl.UNSIGNED_SHORT
_G.GL_RENDERBUFFER_HEIGHT = gl.RENDERBUFFER_HEIGHT
_G.GL_STENCIL_BACK_FAIL = gl.STENCIL_BACK_FAIL
_G.GL_BLEND_SRC_RGB = gl.BLEND_SRC_RGB
_G.GL_TEXTURE3 = gl.TEXTURE3
_G.GL_RENDERBUFFER = gl.RENDERBUFFER
_G.GL_RGB5_A1 = gl.RGB5_A1
_G.GL_RENDERBUFFER_ALPHA_SIZE = gl.RENDERBUFFER_ALPHA_SIZE
_G.GL_RENDERBUFFER_STENCIL_SIZE = gl.RENDERBUFFER_STENCIL_SIZE
_G.GL_NOTEQUAL = gl.NOTEQUAL
_G.GL_BLEND_DST_RGB = gl.BLEND_DST_RGB
_G.GL_FRONT_AND_BACK = gl.FRONT_AND_BACK
_G.GL_TEXTURE_BINDING_CUBE_MAP = gl.TEXTURE_BINDING_CUBE_MAP
_G.GL_MAX_RENDERBUFFER_SIZE = gl.MAX_RENDERBUFFER_SIZE
_G.GL_ZERO = gl.ZERO
_G.GL_TEXTURE0 = gl.TEXTURE0
_G.GL_SAMPLE_ALPHA_TO_COVERAGE = gl.SAMPLE_ALPHA_TO_COVERAGE
_G.GL_BUFFER_USAGE = gl.BUFFER_USAGE
_G.GL_ACTIVE_TEXTURE = gl.ACTIVE_TEXTURE
_G.GL_BYTE = gl.BYTE
_G.GL_CW = gl.CW
_G.GL_DYNAMIC_DRAW = gl.DYNAMIC_DRAW
_G.GL_RENDERBUFFER_RED_SIZE = gl.RENDERBUFFER_RED_SIZE
_G.GL_FALSE = gl.FALSE
_G.GL_GREATER = gl.GREATER
_G.GL_RGBA4 = gl.RGBA4
_G.GL_VALIDATE_STATUS = gl.VALIDATE_STATUS
_G.GL_STENCIL_BITS = gl.STENCIL_BITS
_G.GL_RGB = gl.RGB
_G.GL_INT = gl.INT
_G.GL_DEPTH_FUNC = gl.DEPTH_FUNC
_G.GL_SAMPLER_2D = gl.SAMPLER_2D
_G.GL_NICEST = gl.NICEST
_G.GL_MAX_VIEWPORT_DIMS = gl.MAX_VIEWPORT_DIMS
_G.GL_CULL_FACE = gl.CULL_FACE
_G.GL_INT_VEC3 = gl.INT_VEC3
_G.GL_ALIASED_POINT_SIZE_RANGE = gl.ALIASED_POINT_SIZE_RANGE
_G.GL_INVALID_ENUM = gl.INVALID_ENUM
_G.GL_INVERT = gl.INVERT
_G.GL_CULL_FACE_MODE = gl.CULL_FACE_MODE
_G.GL_TEXTURE8 = gl.TEXTURE8
_G.GL_VERTEX_ATTRIB_ARRAY_POINTER = gl.VERTEX_ATTRIB_ARRAY_POINTER
_G.GL_TEXTURE_WRAP_S = gl.TEXTURE_WRAP_S
_G.GL_VERTEX_ATTRIB_ARRAY_STRIDE = gl.VERTEX_ATTRIB_ARRAY_STRIDE
_G.GL_LINES = gl.LINES
_G.GL_EQUAL = gl.EQUAL
_G.GL_LINE_LOOP = gl.LINE_LOOP
_G.GL_TEXTURE_WRAP_T = gl.TEXTURE_WRAP_T
_G.GL_DEPTH_BUFFER_BIT = gl.DEPTH_BUFFER_BIT
_G.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS
_G.GL_SHADER_TYPE = gl.SHADER_TYPE
_G.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME
_G.GL_TEXTURE_CUBE_MAP_NEGATIVE_X = gl.TEXTURE_CUBE_MAP_NEGATIVE_X
_G.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = gl.TEXTURE_CUBE_MAP_NEGATIVE_Y
_G.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
_G.GL_DECR = gl.DECR
_G.GL_DELETE_STATUS = gl.DELETE_STATUS
_G.GL_DEPTH_BITS = gl.DEPTH_BITS
_G.GL_INCR = gl.INCR
_G.GL_SAMPLE_COVERAGE_VALUE = gl.SAMPLE_COVERAGE_VALUE
_G.GL_ALPHA_BITS = gl.ALPHA_BITS
_G.GL_FLOAT_MAT2 = gl.FLOAT_MAT2
_G.GL_LINE_STRIP = gl.LINE_STRIP
_G.GL_SHADER_SOURCE_LENGTH = gl.SHADER_SOURCE_LENGTH
_G.GL_INVALID_VALUE = gl.INVALID_VALUE
_G.GL_NEVER = gl.NEVER
_G.GL_INCR_WRAP = gl.INCR_WRAP
_G.GL_BLEND_EQUATION_ALPHA = gl.BLEND_EQUATION_ALPHA
_G.GL_TEXTURE_MAG_FILTER = gl.TEXTURE_MAG_FILTER
_G.GL_POINTS = gl.POINTS
_G.GL_COLOR_ATTACHMENT0 = gl.COLOR_ATTACHMENT0
_G.GL_RGBA = gl.RGBA
_G.GL_SRC_ALPHA_SATURATE = gl.SRC_ALPHA_SATURATE
_G.GL_SAMPLER_CUBE = gl.SAMPLER_CUBE
_G.GL_FRAMEBUFFER = gl.FRAMEBUFFER
_G.GL_TEXTURE_CUBE_MAP = gl.TEXTURE_CUBE_MAP
_G.GL_SAMPLE_BUFFERS = gl.SAMPLE_BUFFERS
_G.GL_LINEAR = gl.LINEAR
_G.GL_LINEAR_MIPMAP_NEAREST = gl.LINEAR_MIPMAP_NEAREST
_G.GL_ACTIVE_UNIFORM_MAX_LENGTH = gl.ACTIVE_UNIFORM_MAX_LENGTH
_G.GL_STENCIL_BACK_REF = gl.STENCIL_BACK_REF
_G.GL_ELEMENT_ARRAY_BUFFER = gl.ELEMENT_ARRAY_BUFFER
_G.GL_CLAMP_TO_EDGE = gl.CLAMP_TO_EDGE
_G.GL_TRIANGLE_STRIP = gl.TRIANGLE_STRIP
_G.GL_CONSTANT_COLOR = gl.CONSTANT_COLOR
_G.GL_COMPILE_STATUS = gl.COMPILE_STATUS
_G.GL_RENDERBUFFER_GREEN_SIZE = gl.RENDERBUFFER_GREEN_SIZE
_G.GL_UNSIGNED_INT = gl.UNSIGNED_INT
_G.GL_DEPTH_CLEAR_VALUE = gl.DEPTH_CLEAR_VALUE
_G.GL_ALIASED_LINE_WIDTH_RANGE = gl.ALIASED_LINE_WIDTH_RANGE
_G.GL_SHADING_LANGUAGE_VERSION = gl.SHADING_LANGUAGE_VERSION
_G.GL_FRAMEBUFFER_UNSUPPORTED = gl.FRAMEBUFFER_UNSUPPORTED
_G.GL_INFO_LOG_LENGTH = gl.INFO_LOG_LENGTH
_G.GL_STENCIL_PASS_DEPTH_PASS = gl.STENCIL_PASS_DEPTH_PASS
_G.GL_STENCIL_VALUE_MASK = gl.STENCIL_VALUE_MASK
_G.GL_ALWAYS = gl.ALWAYS
_G.GL_MAX_TEXTURE_SIZE = gl.MAX_TEXTURE_SIZE
_G.GL_FLOAT = gl.FLOAT
_G.GL_FRAMEBUFFER_BINDING = gl.FRAMEBUFFER_BINDING
_G.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
_G.GL_TRIANGLE_FAN = gl.TRIANGLE_FAN
_G.GL_INVALID_FRAMEBUFFER_OPERATION = gl.INVALID_FRAMEBUFFER_OPERATION
_G.GL_TEXTURE_2D = gl.TEXTURE_2D
_G.GL_ALPHA = gl.ALPHA
_G.GL_CURRENT_VERTEX_ATTRIB = gl.CURRENT_VERTEX_ATTRIB
_G.GL_SCISSOR_TEST = gl.SCISSOR_TEST
_G.GL_TRIANGLES = gl.TRIANGLES
| mit |
fusijie/cocos2d-x-samples | samples/KillBug/src/cocos/cocos2d/DeprecatedOpenglEnum.lua | 148 | 11934 | -- This is the DeprecatedEnum
DeprecatedClass = {} or DeprecatedClass
_G.GL_RENDERBUFFER_INTERNAL_FORMAT = gl.RENDERBUFFER_INTERNAL_FORMAT
_G.GL_LINE_WIDTH = gl.LINE_WIDTH
_G.GL_CONSTANT_ALPHA = gl.CONSTANT_ALPHA
_G.GL_BLEND_SRC_ALPHA = gl.BLEND_SRC_ALPHA
_G.GL_GREEN_BITS = gl.GREEN_BITS
_G.GL_STENCIL_REF = gl.STENCIL_REF
_G.GL_ONE_MINUS_SRC_ALPHA = gl.ONE_MINUS_SRC_ALPHA
_G.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
_G.GL_CCW = gl.CCW
_G.GL_MAX_TEXTURE_IMAGE_UNITS = gl.MAX_TEXTURE_IMAGE_UNITS
_G.GL_BACK = gl.BACK
_G.GL_ACTIVE_ATTRIBUTES = gl.ACTIVE_ATTRIBUTES
_G.GL_TEXTURE_CUBE_MAP_POSITIVE_X = gl.TEXTURE_CUBE_MAP_POSITIVE_X
_G.GL_STENCIL_BACK_VALUE_MASK = gl.STENCIL_BACK_VALUE_MASK
_G.GL_TEXTURE_CUBE_MAP_POSITIVE_Z = gl.TEXTURE_CUBE_MAP_POSITIVE_Z
_G.GL_ONE = gl.ONE
_G.GL_TRUE = gl.TRUE
_G.GL_TEXTURE12 = gl.TEXTURE12
_G.GL_LINK_STATUS = gl.LINK_STATUS
_G.GL_BLEND = gl.BLEND
_G.GL_LESS = gl.LESS
_G.GL_TEXTURE16 = gl.TEXTURE16
_G.GL_BOOL_VEC2 = gl.BOOL_VEC2
_G.GL_KEEP = gl.KEEP
_G.GL_DST_COLOR = gl.DST_COLOR
_G.GL_VERTEX_ATTRIB_ARRAY_ENABLED = gl.VERTEX_ATTRIB_ARRAY_ENABLED
_G.GL_EXTENSIONS = gl.EXTENSIONS
_G.GL_FRONT = gl.FRONT
_G.GL_DST_ALPHA = gl.DST_ALPHA
_G.GL_ATTACHED_SHADERS = gl.ATTACHED_SHADERS
_G.GL_STENCIL_BACK_FUNC = gl.STENCIL_BACK_FUNC
_G.GL_ONE_MINUS_DST_COLOR = gl.ONE_MINUS_DST_COLOR
_G.GL_BLEND_EQUATION = gl.BLEND_EQUATION
_G.GL_RENDERBUFFER_DEPTH_SIZE = gl.RENDERBUFFER_DEPTH_SIZE
_G.GL_PACK_ALIGNMENT = gl.PACK_ALIGNMENT
_G.GL_VENDOR = gl.VENDOR
_G.GL_NEAREST_MIPMAP_LINEAR = gl.NEAREST_MIPMAP_LINEAR
_G.GL_TEXTURE_CUBE_MAP_POSITIVE_Y = gl.TEXTURE_CUBE_MAP_POSITIVE_Y
_G.GL_NEAREST = gl.NEAREST
_G.GL_RENDERBUFFER_WIDTH = gl.RENDERBUFFER_WIDTH
_G.GL_ARRAY_BUFFER_BINDING = gl.ARRAY_BUFFER_BINDING
_G.GL_ARRAY_BUFFER = gl.ARRAY_BUFFER
_G.GL_LEQUAL = gl.LEQUAL
_G.GL_VERSION = gl.VERSION
_G.GL_COLOR_CLEAR_VALUE = gl.COLOR_CLEAR_VALUE
_G.GL_RENDERER = gl.RENDERER
_G.GL_STENCIL_BACK_PASS_DEPTH_PASS = gl.STENCIL_BACK_PASS_DEPTH_PASS
_G.GL_STENCIL_BACK_PASS_DEPTH_FAIL = gl.STENCIL_BACK_PASS_DEPTH_FAIL
_G.GL_STENCIL_BACK_WRITEMASK = gl.STENCIL_BACK_WRITEMASK
_G.GL_BOOL = gl.BOOL
_G.GL_VIEWPORT = gl.VIEWPORT
_G.GL_FRAGMENT_SHADER = gl.FRAGMENT_SHADER
_G.GL_LUMINANCE = gl.LUMINANCE
_G.GL_DECR_WRAP = gl.DECR_WRAP
_G.GL_FUNC_ADD = gl.FUNC_ADD
_G.GL_ONE_MINUS_DST_ALPHA = gl.ONE_MINUS_DST_ALPHA
_G.GL_OUT_OF_MEMORY = gl.OUT_OF_MEMORY
_G.GL_BOOL_VEC4 = gl.BOOL_VEC4
_G.GL_POLYGON_OFFSET_FACTOR = gl.POLYGON_OFFSET_FACTOR
_G.GL_STATIC_DRAW = gl.STATIC_DRAW
_G.GL_DITHER = gl.DITHER
_G.GL_TEXTURE31 = gl.TEXTURE31
_G.GL_TEXTURE30 = gl.TEXTURE30
_G.GL_UNSIGNED_BYTE = gl.UNSIGNED_BYTE
_G.GL_DEPTH_COMPONENT16 = gl.DEPTH_COMPONENT16
_G.GL_TEXTURE23 = gl.TEXTURE23
_G.GL_DEPTH_TEST = gl.DEPTH_TEST
_G.GL_STENCIL_PASS_DEPTH_FAIL = gl.STENCIL_PASS_DEPTH_FAIL
_G.GL_BOOL_VEC3 = gl.BOOL_VEC3
_G.GL_POLYGON_OFFSET_UNITS = gl.POLYGON_OFFSET_UNITS
_G.GL_TEXTURE_BINDING_2D = gl.TEXTURE_BINDING_2D
_G.GL_TEXTURE21 = gl.TEXTURE21
_G.GL_UNPACK_ALIGNMENT = gl.UNPACK_ALIGNMENT
_G.GL_DONT_CARE = gl.DONT_CARE
_G.GL_BUFFER_SIZE = gl.BUFFER_SIZE
_G.GL_FLOAT_MAT3 = gl.FLOAT_MAT3
_G.GL_UNSIGNED_SHORT_5_6_5 = gl.UNSIGNED_SHORT_5_6_5
_G.GL_INT_VEC2 = gl.INT_VEC2
_G.GL_UNSIGNED_SHORT_4_4_4_4 = gl.UNSIGNED_SHORT_4_4_4_4
_G.GL_NONE = gl.NONE
_G.GL_BLEND_DST_ALPHA = gl.BLEND_DST_ALPHA
_G.GL_VERTEX_ATTRIB_ARRAY_SIZE = gl.VERTEX_ATTRIB_ARRAY_SIZE
_G.GL_SRC_COLOR = gl.SRC_COLOR
_G.GL_COMPRESSED_TEXTURE_FORMATS = gl.COMPRESSED_TEXTURE_FORMATS
_G.GL_STENCIL_ATTACHMENT = gl.STENCIL_ATTACHMENT
_G.GL_MAX_VERTEX_ATTRIBS = gl.MAX_VERTEX_ATTRIBS
_G.GL_NUM_COMPRESSED_TEXTURE_FORMATS = gl.NUM_COMPRESSED_TEXTURE_FORMATS
_G.GL_BLEND_EQUATION_RGB = gl.BLEND_EQUATION_RGB
_G.GL_TEXTURE = gl.TEXTURE
_G.GL_LINEAR_MIPMAP_LINEAR = gl.LINEAR_MIPMAP_LINEAR
_G.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING
_G.GL_CURRENT_PROGRAM = gl.CURRENT_PROGRAM
_G.GL_COLOR_BUFFER_BIT = gl.COLOR_BUFFER_BIT
_G.GL_TEXTURE20 = gl.TEXTURE20
_G.GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = gl.ACTIVE_ATTRIBUTE_MAX_LENGTH
_G.GL_TEXTURE28 = gl.TEXTURE28
_G.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE
_G.GL_TEXTURE22 = gl.TEXTURE22
_G.GL_ELEMENT_ARRAY_BUFFER_BINDING = gl.ELEMENT_ARRAY_BUFFER_BINDING
_G.GL_STREAM_DRAW = gl.STREAM_DRAW
_G.GL_SCISSOR_BOX = gl.SCISSOR_BOX
_G.GL_TEXTURE26 = gl.TEXTURE26
_G.GL_TEXTURE27 = gl.TEXTURE27
_G.GL_TEXTURE24 = gl.TEXTURE24
_G.GL_TEXTURE25 = gl.TEXTURE25
_G.GL_NO_ERROR = gl.NO_ERROR
_G.GL_TEXTURE29 = gl.TEXTURE29
_G.GL_FLOAT_MAT4 = gl.FLOAT_MAT4
_G.GL_VERTEX_ATTRIB_ARRAY_NORMALIZED = gl.VERTEX_ATTRIB_ARRAY_NORMALIZED
_G.GL_SAMPLE_COVERAGE_INVERT = gl.SAMPLE_COVERAGE_INVERT
_G.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = gl.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL
_G.GL_FLOAT_VEC3 = gl.FLOAT_VEC3
_G.GL_STENCIL_CLEAR_VALUE = gl.STENCIL_CLEAR_VALUE
_G.GL_UNSIGNED_SHORT_5_5_5_1 = gl.UNSIGNED_SHORT_5_5_5_1
_G.GL_ACTIVE_UNIFORMS = gl.ACTIVE_UNIFORMS
_G.GL_INVALID_OPERATION = gl.INVALID_OPERATION
_G.GL_DEPTH_ATTACHMENT = gl.DEPTH_ATTACHMENT
_G.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS
_G.GL_FRAMEBUFFER_COMPLETE = gl.FRAMEBUFFER_COMPLETE
_G.GL_ONE_MINUS_CONSTANT_COLOR = gl.ONE_MINUS_CONSTANT_COLOR
_G.GL_TEXTURE2 = gl.TEXTURE2
_G.GL_TEXTURE1 = gl.TEXTURE1
_G.GL_GEQUAL = gl.GEQUAL
_G.GL_TEXTURE7 = gl.TEXTURE7
_G.GL_TEXTURE6 = gl.TEXTURE6
_G.GL_TEXTURE5 = gl.TEXTURE5
_G.GL_TEXTURE4 = gl.TEXTURE4
_G.GL_GENERATE_MIPMAP_HINT = gl.GENERATE_MIPMAP_HINT
_G.GL_ONE_MINUS_SRC_COLOR = gl.ONE_MINUS_SRC_COLOR
_G.GL_TEXTURE9 = gl.TEXTURE9
_G.GL_STENCIL_TEST = gl.STENCIL_TEST
_G.GL_COLOR_WRITEMASK = gl.COLOR_WRITEMASK
_G.GL_DEPTH_COMPONENT = gl.DEPTH_COMPONENT
_G.GL_STENCIL_INDEX8 = gl.STENCIL_INDEX8
_G.GL_VERTEX_ATTRIB_ARRAY_TYPE = gl.VERTEX_ATTRIB_ARRAY_TYPE
_G.GL_FLOAT_VEC2 = gl.FLOAT_VEC2
_G.GL_BLUE_BITS = gl.BLUE_BITS
_G.GL_VERTEX_SHADER = gl.VERTEX_SHADER
_G.GL_SUBPIXEL_BITS = gl.SUBPIXEL_BITS
_G.GL_STENCIL_WRITEMASK = gl.STENCIL_WRITEMASK
_G.GL_FLOAT_VEC4 = gl.FLOAT_VEC4
_G.GL_TEXTURE17 = gl.TEXTURE17
_G.GL_ONE_MINUS_CONSTANT_ALPHA = gl.ONE_MINUS_CONSTANT_ALPHA
_G.GL_TEXTURE15 = gl.TEXTURE15
_G.GL_TEXTURE14 = gl.TEXTURE14
_G.GL_TEXTURE13 = gl.TEXTURE13
_G.GL_SAMPLES = gl.SAMPLES
_G.GL_TEXTURE11 = gl.TEXTURE11
_G.GL_TEXTURE10 = gl.TEXTURE10
_G.GL_FUNC_SUBTRACT = gl.FUNC_SUBTRACT
_G.GL_STENCIL_BUFFER_BIT = gl.STENCIL_BUFFER_BIT
_G.GL_TEXTURE19 = gl.TEXTURE19
_G.GL_TEXTURE18 = gl.TEXTURE18
_G.GL_NEAREST_MIPMAP_NEAREST = gl.NEAREST_MIPMAP_NEAREST
_G.GL_SHORT = gl.SHORT
_G.GL_RENDERBUFFER_BINDING = gl.RENDERBUFFER_BINDING
_G.GL_REPEAT = gl.REPEAT
_G.GL_TEXTURE_MIN_FILTER = gl.TEXTURE_MIN_FILTER
_G.GL_RED_BITS = gl.RED_BITS
_G.GL_FRONT_FACE = gl.FRONT_FACE
_G.GL_BLEND_COLOR = gl.BLEND_COLOR
_G.GL_MIRRORED_REPEAT = gl.MIRRORED_REPEAT
_G.GL_INT_VEC4 = gl.INT_VEC4
_G.GL_MAX_CUBE_MAP_TEXTURE_SIZE = gl.MAX_CUBE_MAP_TEXTURE_SIZE
_G.GL_RENDERBUFFER_BLUE_SIZE = gl.RENDERBUFFER_BLUE_SIZE
_G.GL_SAMPLE_COVERAGE = gl.SAMPLE_COVERAGE
_G.GL_SRC_ALPHA = gl.SRC_ALPHA
_G.GL_FUNC_REVERSE_SUBTRACT = gl.FUNC_REVERSE_SUBTRACT
_G.GL_DEPTH_WRITEMASK = gl.DEPTH_WRITEMASK
_G.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT
_G.GL_POLYGON_OFFSET_FILL = gl.POLYGON_OFFSET_FILL
_G.GL_STENCIL_FUNC = gl.STENCIL_FUNC
_G.GL_REPLACE = gl.REPLACE
_G.GL_LUMINANCE_ALPHA = gl.LUMINANCE_ALPHA
_G.GL_DEPTH_RANGE = gl.DEPTH_RANGE
_G.GL_FASTEST = gl.FASTEST
_G.GL_STENCIL_FAIL = gl.STENCIL_FAIL
_G.GL_UNSIGNED_SHORT = gl.UNSIGNED_SHORT
_G.GL_RENDERBUFFER_HEIGHT = gl.RENDERBUFFER_HEIGHT
_G.GL_STENCIL_BACK_FAIL = gl.STENCIL_BACK_FAIL
_G.GL_BLEND_SRC_RGB = gl.BLEND_SRC_RGB
_G.GL_TEXTURE3 = gl.TEXTURE3
_G.GL_RENDERBUFFER = gl.RENDERBUFFER
_G.GL_RGB5_A1 = gl.RGB5_A1
_G.GL_RENDERBUFFER_ALPHA_SIZE = gl.RENDERBUFFER_ALPHA_SIZE
_G.GL_RENDERBUFFER_STENCIL_SIZE = gl.RENDERBUFFER_STENCIL_SIZE
_G.GL_NOTEQUAL = gl.NOTEQUAL
_G.GL_BLEND_DST_RGB = gl.BLEND_DST_RGB
_G.GL_FRONT_AND_BACK = gl.FRONT_AND_BACK
_G.GL_TEXTURE_BINDING_CUBE_MAP = gl.TEXTURE_BINDING_CUBE_MAP
_G.GL_MAX_RENDERBUFFER_SIZE = gl.MAX_RENDERBUFFER_SIZE
_G.GL_ZERO = gl.ZERO
_G.GL_TEXTURE0 = gl.TEXTURE0
_G.GL_SAMPLE_ALPHA_TO_COVERAGE = gl.SAMPLE_ALPHA_TO_COVERAGE
_G.GL_BUFFER_USAGE = gl.BUFFER_USAGE
_G.GL_ACTIVE_TEXTURE = gl.ACTIVE_TEXTURE
_G.GL_BYTE = gl.BYTE
_G.GL_CW = gl.CW
_G.GL_DYNAMIC_DRAW = gl.DYNAMIC_DRAW
_G.GL_RENDERBUFFER_RED_SIZE = gl.RENDERBUFFER_RED_SIZE
_G.GL_FALSE = gl.FALSE
_G.GL_GREATER = gl.GREATER
_G.GL_RGBA4 = gl.RGBA4
_G.GL_VALIDATE_STATUS = gl.VALIDATE_STATUS
_G.GL_STENCIL_BITS = gl.STENCIL_BITS
_G.GL_RGB = gl.RGB
_G.GL_INT = gl.INT
_G.GL_DEPTH_FUNC = gl.DEPTH_FUNC
_G.GL_SAMPLER_2D = gl.SAMPLER_2D
_G.GL_NICEST = gl.NICEST
_G.GL_MAX_VIEWPORT_DIMS = gl.MAX_VIEWPORT_DIMS
_G.GL_CULL_FACE = gl.CULL_FACE
_G.GL_INT_VEC3 = gl.INT_VEC3
_G.GL_ALIASED_POINT_SIZE_RANGE = gl.ALIASED_POINT_SIZE_RANGE
_G.GL_INVALID_ENUM = gl.INVALID_ENUM
_G.GL_INVERT = gl.INVERT
_G.GL_CULL_FACE_MODE = gl.CULL_FACE_MODE
_G.GL_TEXTURE8 = gl.TEXTURE8
_G.GL_VERTEX_ATTRIB_ARRAY_POINTER = gl.VERTEX_ATTRIB_ARRAY_POINTER
_G.GL_TEXTURE_WRAP_S = gl.TEXTURE_WRAP_S
_G.GL_VERTEX_ATTRIB_ARRAY_STRIDE = gl.VERTEX_ATTRIB_ARRAY_STRIDE
_G.GL_LINES = gl.LINES
_G.GL_EQUAL = gl.EQUAL
_G.GL_LINE_LOOP = gl.LINE_LOOP
_G.GL_TEXTURE_WRAP_T = gl.TEXTURE_WRAP_T
_G.GL_DEPTH_BUFFER_BIT = gl.DEPTH_BUFFER_BIT
_G.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS
_G.GL_SHADER_TYPE = gl.SHADER_TYPE
_G.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME
_G.GL_TEXTURE_CUBE_MAP_NEGATIVE_X = gl.TEXTURE_CUBE_MAP_NEGATIVE_X
_G.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = gl.TEXTURE_CUBE_MAP_NEGATIVE_Y
_G.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
_G.GL_DECR = gl.DECR
_G.GL_DELETE_STATUS = gl.DELETE_STATUS
_G.GL_DEPTH_BITS = gl.DEPTH_BITS
_G.GL_INCR = gl.INCR
_G.GL_SAMPLE_COVERAGE_VALUE = gl.SAMPLE_COVERAGE_VALUE
_G.GL_ALPHA_BITS = gl.ALPHA_BITS
_G.GL_FLOAT_MAT2 = gl.FLOAT_MAT2
_G.GL_LINE_STRIP = gl.LINE_STRIP
_G.GL_SHADER_SOURCE_LENGTH = gl.SHADER_SOURCE_LENGTH
_G.GL_INVALID_VALUE = gl.INVALID_VALUE
_G.GL_NEVER = gl.NEVER
_G.GL_INCR_WRAP = gl.INCR_WRAP
_G.GL_BLEND_EQUATION_ALPHA = gl.BLEND_EQUATION_ALPHA
_G.GL_TEXTURE_MAG_FILTER = gl.TEXTURE_MAG_FILTER
_G.GL_POINTS = gl.POINTS
_G.GL_COLOR_ATTACHMENT0 = gl.COLOR_ATTACHMENT0
_G.GL_RGBA = gl.RGBA
_G.GL_SRC_ALPHA_SATURATE = gl.SRC_ALPHA_SATURATE
_G.GL_SAMPLER_CUBE = gl.SAMPLER_CUBE
_G.GL_FRAMEBUFFER = gl.FRAMEBUFFER
_G.GL_TEXTURE_CUBE_MAP = gl.TEXTURE_CUBE_MAP
_G.GL_SAMPLE_BUFFERS = gl.SAMPLE_BUFFERS
_G.GL_LINEAR = gl.LINEAR
_G.GL_LINEAR_MIPMAP_NEAREST = gl.LINEAR_MIPMAP_NEAREST
_G.GL_ACTIVE_UNIFORM_MAX_LENGTH = gl.ACTIVE_UNIFORM_MAX_LENGTH
_G.GL_STENCIL_BACK_REF = gl.STENCIL_BACK_REF
_G.GL_ELEMENT_ARRAY_BUFFER = gl.ELEMENT_ARRAY_BUFFER
_G.GL_CLAMP_TO_EDGE = gl.CLAMP_TO_EDGE
_G.GL_TRIANGLE_STRIP = gl.TRIANGLE_STRIP
_G.GL_CONSTANT_COLOR = gl.CONSTANT_COLOR
_G.GL_COMPILE_STATUS = gl.COMPILE_STATUS
_G.GL_RENDERBUFFER_GREEN_SIZE = gl.RENDERBUFFER_GREEN_SIZE
_G.GL_UNSIGNED_INT = gl.UNSIGNED_INT
_G.GL_DEPTH_CLEAR_VALUE = gl.DEPTH_CLEAR_VALUE
_G.GL_ALIASED_LINE_WIDTH_RANGE = gl.ALIASED_LINE_WIDTH_RANGE
_G.GL_SHADING_LANGUAGE_VERSION = gl.SHADING_LANGUAGE_VERSION
_G.GL_FRAMEBUFFER_UNSUPPORTED = gl.FRAMEBUFFER_UNSUPPORTED
_G.GL_INFO_LOG_LENGTH = gl.INFO_LOG_LENGTH
_G.GL_STENCIL_PASS_DEPTH_PASS = gl.STENCIL_PASS_DEPTH_PASS
_G.GL_STENCIL_VALUE_MASK = gl.STENCIL_VALUE_MASK
_G.GL_ALWAYS = gl.ALWAYS
_G.GL_MAX_TEXTURE_SIZE = gl.MAX_TEXTURE_SIZE
_G.GL_FLOAT = gl.FLOAT
_G.GL_FRAMEBUFFER_BINDING = gl.FRAMEBUFFER_BINDING
_G.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
_G.GL_TRIANGLE_FAN = gl.TRIANGLE_FAN
_G.GL_INVALID_FRAMEBUFFER_OPERATION = gl.INVALID_FRAMEBUFFER_OPERATION
_G.GL_TEXTURE_2D = gl.TEXTURE_2D
_G.GL_ALPHA = gl.ALPHA
_G.GL_CURRENT_VERTEX_ATTRIB = gl.CURRENT_VERTEX_ATTRIB
_G.GL_SCISSOR_TEST = gl.SCISSOR_TEST
_G.GL_TRIANGLES = gl.TRIANGLES
| mit |
Xavyrr/LOVE | game/start.lua | 2 | 1526 | function gameStates.start.load()
start = {}
start.timer = -3
start.state = 0
start.image0 = love.graphics.newImage('img/start/start0.png')
start.image1 = love.graphics.newImage('img/start/start1.png')
start.image2 = love.graphics.newImage('img/start/start2.png')
start.image3 = love.graphics.newImage('img/start/start3.png')
start.noise = love.audio.newSource('snd/snd_intronoise.wav')
start.noise:setLooping(false)
end
function gameStates.start.draw()
love.graphics.setScreen('top')
love.graphics.setColor(255, 255, 255, 255)
love.graphics.setDepth(0)
if start.state == 1 then
love.graphics.draw(start.image0, 0, 0)
love.graphics.setDepth(-2)
love.graphics.draw(start.image1, 0, 0)
elseif start.state == 2 then
love.graphics.draw(start.image2, 0, 0)
love.graphics.setDepth(-2)
love.graphics.draw(start.image3, 0, 0)
end
end
function gameStates.start.update(gt)
start.timer = start.timer + gt
if start.timer >= 0 and start.state == 0 then
start.state = 1
start.noise:play()
elseif start.timer >= 5 and start.state == 1 then
start.state = start.state + 1
start.depth = 0
start.noise:play()
elseif start.timer >= 10 and start.state == 2 then
start.state = start.state + 1
start.depth = 0
start.noise:play()
elseif start.timer >= 13 and start.state == 3 then
gameState = 'menu'
start.noise = nil
love.load()
elseif love.keyboard.isDown("a") then
gameState = 'menu'
love.audio.stop()
love.load()
end
end
| apache-2.0 |
mercury233/ygopro-scripts | c34109611.lua | 4 | 1132 | --ダイガスタ・ファルコス
function c34109611.initial_effect(c)
--synchro summon
aux.AddSynchroProcedure(c,nil,aux.NonTuner(Card.IsSetCard,0x10),1)
c:EnableReviveLimit()
--atkup
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(34109611,0))
e1:SetCategory(CATEGORY_ATKCHANGE)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e1:SetCode(EVENT_SPSUMMON_SUCCESS)
e1:SetCondition(c34109611.condition)
e1:SetOperation(c34109611.operation)
c:RegisterEffect(e1)
end
function c34109611.condition(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO)
end
function c34109611.filter(c)
return c:IsFaceup() and c:IsSetCard(0x10)
end
function c34109611.operation(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(c34109611.filter,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:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetReset(RESET_EVENT+RESETS_STANDARD)
e1:SetValue(600)
tc:RegisterEffect(e1)
tc=g:GetNext()
end
end
| gpl-2.0 |
Zenny89/darkstar | scripts/globals/mobskills/Spike_Flail.lua | 18 | 1248 | ---------------------------------------------------
-- Spike Flail
-- Deals extreme damage in a threefold attack to targets behind the user.
---------------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------------
function onMobSkillCheck(target,mob,skill)
if (mob:hasStatusEffect(EFFECT_MIGHTY_STRIKES)) then
return 1;
elseif (mob:hasStatusEffect(EFFECT_SUPER_BUFF)) then
return 1;
elseif (mob:hasStatusEffect(EFFECT_INVINCIBLE)) then
return 1;
elseif (mob:hasStatusEffect(EFFECT_BLOOD_WEAPON)) then
return 1;
elseif (target:isBehind(mob, 48) == false) then
return 1;
elseif (mob:AnimationSub() == 1) then
return 1;
end
return 0;
end;
function onMobWeaponSkill(target, mob, skill)
local numhits = 1;
local accmod = 2;
local dmgmod = math.random(5,7);
local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,TP_DMG_VARIES,2,3,4);
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_PHYSICAL,MOBPARAM_SLASH,MOBPARAM_3_SHADOW);
target:delHP(dmg);
return dmg;
end;
| gpl-3.0 |
amirTg/TELEHONES | plugins/ingroup.lua | 371 | 44212 | do
-- Check Member
local function check_member_autorealm(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Realm',
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes'
}
}
save_data(_config.moderation.data, data)
local realms = 'realms'
if not data[tostring(realms)] then
data[tostring(realms)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(realms)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Welcome to your new realm !')
end
end
end
local function check_member_realm_add(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Realm',
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes'
}
}
save_data(_config.moderation.data, data)
local realms = 'realms'
if not data[tostring(realms)] then
data[tostring(realms)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(realms)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Realm has been added!')
end
end
end
function check_member_group(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Group',
moderators = {},
set_owner = member_id ,
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes',
}
}
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'You have been promoted as the owner.')
end
end
end
local function check_member_modadd(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
group_type = 'Group',
moderators = {},
set_owner = member_id ,
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes',
}
}
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Group is added and you have been promoted as the owner ')
end
end
end
local function automodadd(msg)
local data = load_data(_config.moderation.data)
if msg.action.type == 'chat_created' then
receiver = get_receiver(msg)
chat_info(receiver, check_member_group,{receiver=receiver, data=data, msg = msg})
end
end
local function autorealmadd(msg)
local data = load_data(_config.moderation.data)
if msg.action.type == 'chat_created' then
receiver = get_receiver(msg)
chat_info(receiver, check_member_autorealm,{receiver=receiver, data=data, msg = msg})
end
end
local function check_member_realmrem(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Realm configuration removal
data[tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
local realms = 'realms'
if not data[tostring(realms)] then
data[tostring(realms)] = nil
save_data(_config.moderation.data, data)
end
data[tostring(realms)][tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Realm has been removed!')
end
end
end
local function check_member_modrem(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration removal
data[tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = nil
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Group has been removed')
end
end
end
--End Check Member
local function show_group_settingsmod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
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 bots_protection = "Yes"
if data[tostring(msg.to.id)]['settings']['lock_bots'] then
bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots']
end
local leave_ban = "no"
if data[tostring(msg.to.id)]['settings']['leave_ban'] then
leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban']
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.."\nLock group leave : "..leave_ban.."\nflood sensitivity : "..NUM_MSG_MAX.."\nBot protection : "..bots_protection--"\nPublic: "..public
return text
end
local function set_descriptionmod(msg, data, target, about)
if not is_momod(msg) then
return "For moderators only!"
end
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 get_description(msg, data)
local data_cat = 'description'
if not data[tostring(msg.to.id)][data_cat] then
return 'No description available.'
end
local about = data[tostring(msg.to.id)][data_cat]
local about = string.gsub(msg.to.print_name, "_", " ")..':\n\n'..about
return 'About '..about
end
local function lock_group_arabic(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic']
if group_arabic_lock == 'yes' then
return 'Arabic is already locked'
else
data[tostring(target)]['settings']['lock_arabic'] = 'yes'
save_data(_config.moderation.data, data)
return 'Arabic has been locked'
end
end
local function unlock_group_arabic(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic']
if group_arabic_lock == 'no' then
return 'Arabic is already unlocked'
else
data[tostring(target)]['settings']['lock_arabic'] = 'no'
save_data(_config.moderation.data, data)
return 'Arabic has been unlocked'
end
end
local function lock_group_bots(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_bots_lock = data[tostring(target)]['settings']['lock_bots']
if group_bots_lock == 'yes' then
return 'Bots protection is already enabled'
else
data[tostring(target)]['settings']['lock_bots'] = 'yes'
save_data(_config.moderation.data, data)
return 'Bots protection has been enabled'
end
end
local function unlock_group_bots(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_bots_lock = data[tostring(target)]['settings']['lock_bots']
if group_bots_lock == 'no' then
return 'Bots protection is already disabled'
else
data[tostring(target)]['settings']['lock_bots'] = 'no'
save_data(_config.moderation.data, data)
return 'Bots protection has been disabled'
end
end
local function lock_group_namemod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
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)
if not is_momod(msg) then
return "For moderators only!"
end
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)
if not is_owner(msg) then
return "Only admins can do it for now"
end
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)
if not is_owner(msg) then
return "Only admins can do it for now"
end
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)
if not is_momod(msg) then
return "For moderators only!"
end
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)
if not is_momod(msg) then
return "For moderators only!"
end
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 set_public_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['public']
if group_member_lock == 'yes' then
return 'Group is already public'
else
data[tostring(target)]['settings']['public'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Group is now: public'
end
local function unset_public_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['public']
if group_member_lock == 'no' then
return 'Group is not public'
else
data[tostring(target)]['settings']['public'] = 'no'
save_data(_config.moderation.data, data)
return 'Group is now: not public'
end
end
local function lock_group_leave(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban']
if leave_ban == 'yes' then
return 'Leaving users will be banned'
else
data[tostring(msg.to.id)]['settings']['leave_ban'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Leaving users will be banned'
end
local function unlock_group_leave(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban']
if leave_ban == 'no' then
return 'Leaving users will not be banned'
else
data[tostring(msg.to.id)]['settings']['leave_ban'] = 'no'
save_data(_config.moderation.data, data)
return 'Leaving users will not be banned'
end
end
local function unlock_group_photomod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
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 set_rulesmod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
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 modadd(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if is_group(msg) then
return 'Group is already added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_modadd,{receiver=receiver, data=data, msg = msg})
end
local function realmadd(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if is_realm(msg) then
return 'Realm is already added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_realm_add,{receiver=receiver, data=data, msg = msg})
end
-- Global functions
function modrem(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if not is_group(msg) then
return 'Group is not added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_modrem,{receiver=receiver, data=data, msg = msg})
end
function realmrem(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if not is_realm(msg) then
return 'Realm is not added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_realmrem,{receiver=receiver, data=data, msg = msg})
end
local function get_rules(msg, data)
local data_cat = 'rules'
if not data[tostring(msg.to.id)][data_cat] then
return 'No rules available.'
end
local rules = data[tostring(msg.to.id)][data_cat]
local rules = 'Chat rules:\n'..rules
return rules
end
local function set_group_photo(msg, success, result)
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
if success then
local file = 'data/photos/chat_photo_'..msg.to.id..'.jpg'
print('File downloaded to:', result)
os.rename(result, file)
print('File moved to:', file)
chat_set_photo (receiver, file, ok_cb, false)
data[tostring(msg.to.id)]['settings']['set_photo'] = file
save_data(_config.moderation.data, data)
data[tostring(msg.to.id)]['settings']['lock_photo'] = 'yes'
save_data(_config.moderation.data, data)
send_large_msg(receiver, 'Photo saved!', ok_cb, false)
else
print('Error downloading: '..msg.id)
send_large_msg(receiver, 'Failed, please try again!', ok_cb, false)
end
end
local function promote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
local group = string.gsub(receiver, 'chat#id', '')
if not data[group] then
return send_large_msg(receiver, 'Group is not added.')
end
if data[group]['moderators'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is already a moderator.')
end
data[group]['moderators'][tostring(member_id)] = member_username
save_data(_config.moderation.data, data)
return send_large_msg(receiver, member_username..' has been promoted.')
end
local function promote_by_reply(extra, success, result)
local msg = result
local full_name = (msg.from.first_name or '')..' '..(msg.from.last_name or '')
if msg.from.username then
member_username = '@'.. msg.from.username
else
member_username = full_name
end
local member_id = msg.from.id
if msg.to.type == 'chat' then
return promote(get_receiver(msg), member_username, member_id)
end
end
local function demote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
local group = string.gsub(receiver, 'chat#id', '')
if not data[group] then
return send_large_msg(receiver, 'Group is not added.')
end
if not data[group]['moderators'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is not a moderator.')
end
data[group]['moderators'][tostring(member_id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, member_username..' has been demoted.')
end
local function demote_by_reply(extra, success, result)
local msg = result
local full_name = (msg.from.first_name or '')..' '..(msg.from.last_name or '')
if msg.from.username then
member_username = '@'..msg.from.username
else
member_username = full_name
end
local member_id = msg.from.id
if msg.to.type == 'chat' then
return demote(get_receiver(msg), member_username, member_id)
end
end
local function setowner_by_reply(extra, success, result)
local msg = result
local receiver = get_receiver(msg)
local data = load_data(_config.moderation.data)
local name_log = msg.from.print_name:gsub("_", " ")
data[tostring(msg.to.id)]['set_owner'] = tostring(msg.from.id)
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] setted ["..msg.from.id.."] as owner")
local text = msg.from.print_name:gsub("_", " ").." is the owner now"
return send_large_msg(receiver, text)
end
local function promote_demote_res(extra, success, result)
--vardump(result)
--vardump(extra)
local member_id = result.id
local member_username = "@"..result.username
local chat_id = extra.chat_id
local mod_cmd = extra.mod_cmd
local receiver = "chat#id"..chat_id
if mod_cmd == 'promote' then
return promote(receiver, member_username, member_id)
elseif mod_cmd == 'demote' then
return demote(receiver, member_username, member_id)
end
end
local function modlist(msg)
local data = load_data(_config.moderation.data)
local groups = "groups"
if not data[tostring(groups)][tostring(msg.to.id)] then
return 'Group is not added.'
end
-- determine if table is empty
if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way
return 'No moderator in this group.'
end
local i = 1
local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n'
for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do
message = message ..i..' - '..v..' [' ..k.. '] \n'
i = i + 1
end
return message
end
local function callbackres(extra, success, result)
--vardump(result)
local user = result.id
local name = string.gsub(result.print_name, "_", " ")
local chat = 'chat#id'..extra.chatid
send_large_msg(chat, user..'\n'..name)
return user
end
local function help()
local help_text = tostring(_config.help_text)
return help_text
end
local function cleanmember(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user(v.id, result.id)
end
end
local function killchat(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function killrealm(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function user_msgs(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 = tonumber(redis:get(um_hash) or 0)
return user_info
end
local function kick_zero(cb_extra, success, result)
local chat_id = cb_extra.chat_id
local chat = "chat#id"..chat_id
local ci_user
local re_user
for k,v in pairs(result.members) do
local si = false
ci_user = v.id
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
for i = 1, #users do
re_user = users[i]
if tonumber(ci_user) == tonumber(re_user) then
si = true
end
end
if not si then
if ci_user ~= our_id then
if not is_momod2(ci_user, chat_id) then
chat_del_user(chat, 'user#id'..ci_user, ok_cb, true)
end
end
end
end
end
local function kick_inactive(chat_id, num, receiver)
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = user_msgs(user_id, chat_id)
local nmsg = user_info
if tonumber(nmsg) < tonumber(num) then
if not is_momod2(user_id, chat_id) then
chat_del_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, true)
end
end
end
return chat_info(receiver, kick_zero, {chat_id = chat_id})
end
local function run(msg, matches)
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
local name_log = user_print_name(msg.from)
local group = msg.to.id
if msg.media then
if msg.media.type == 'photo' and data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' and is_chat_msg(msg) and is_momod(msg) then
load_photo(msg.id, set_group_photo, msg)
end
end
if matches[1] == 'add' and not matches[2] then
if is_realm(msg) then
return 'Error: Already a realm.'
end
print("group "..msg.to.print_name.."("..msg.to.id..") added")
return modadd(msg)
end
if matches[1] == 'add' and matches[2] == 'realm' then
if is_group(msg) then
return 'Error: Already a group.'
end
print("group "..msg.to.print_name.."("..msg.to.id..") added as a realm")
return realmadd(msg)
end
if matches[1] == 'rem' and not matches[2] then
print("group "..msg.to.print_name.."("..msg.to.id..") removed")
return modrem(msg)
end
if matches[1] == 'rem' and matches[2] == 'realm' then
print("group "..msg.to.print_name.."("..msg.to.id..") removed as a realm")
return realmrem(msg)
end
if matches[1] == 'chat_created' and msg.from.id == 0 and group_type == "group" then
return automodadd(msg)
end
if matches[1] == 'chat_created' and msg.from.id == 0 and group_type == "realm" then
return autorealmadd(msg)
end
if msg.to.id and data[tostring(msg.to.id)] then
local settings = data[tostring(msg.to.id)]['settings']
if matches[1] == 'chat_add_user' then
if not msg.service then
return "Are you trying to troll me?"
end
local group_member_lock = settings.lock_member
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
if group_member_lock == 'yes' and not is_owner2(msg.action.user.id, msg.to.id) then
chat_del_user(chat, user, ok_cb, true)
elseif group_member_lock == 'yes' and tonumber(msg.from.id) == tonumber(our_id) then
return nil
elseif group_member_lock == 'no' then
return nil
end
end
if matches[1] == 'chat_del_user' then
if not msg.service then
-- return "Are you trying to troll me?"
end
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..user)
end
if matches[1] == 'chat_delete_photo' then
if not msg.service then
return "Are you trying to troll me?"
end
local group_photo_lock = settings.lock_photo
if group_photo_lock == 'yes' then
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:incr(picturehash)
---
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
local picprotectionredis = redis:get(picturehash)
if picprotectionredis then
if tonumber(picprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(picprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:set(picturehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to deleted picture but failed ")
chat_set_photo(receiver, settings.set_photo, ok_cb, false)
elseif group_photo_lock == 'no' then
return nil
end
end
if matches[1] == 'chat_change_photo' and msg.from.id ~= 0 then
if not msg.service then
return "Are you trying to troll me?"
end
local group_photo_lock = settings.lock_photo
if group_photo_lock == 'yes' then
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:incr(picturehash)
---
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
local picprotectionredis = redis:get(picturehash)
if picprotectionredis then
if tonumber(picprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(picprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:set(picturehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change picture but failed ")
chat_set_photo(receiver, settings.set_photo, ok_cb, false)
elseif group_photo_lock == 'no' then
return nil
end
end
if matches[1] == 'chat_rename' then
if not msg.service then
return "Are you trying to troll me?"
end
local group_name_set = settings.set_name
local group_name_lock = settings.lock_name
local to_rename = 'chat#id'..msg.to.id
if group_name_lock == 'yes' then
if group_name_set ~= tostring(msg.to.print_name) then
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
redis:incr(namehash)
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
local nameprotectionredis = redis:get(namehash)
if nameprotectionredis then
if tonumber(nameprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(nameprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
redis:set(namehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change name but failed ")
rename_chat(to_rename, group_name_set, ok_cb, false)
end
elseif group_name_lock == 'no' then
return nil
end
end
if matches[1] == 'setname' and is_momod(msg) then
local new_name = string.gsub(matches[2], '_', ' ')
data[tostring(msg.to.id)]['settings']['set_name'] = new_name
save_data(_config.moderation.data, data)
local group_name_set = data[tostring(msg.to.id)]['settings']['set_name']
local to_rename = 'chat#id'..msg.to.id
rename_chat(to_rename, group_name_set, ok_cb, false)
savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]")
end
if matches[1] == 'setphoto' and is_momod(msg) then
data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting'
save_data(_config.moderation.data, data)
return 'Please send me new group photo now'
end
if matches[1] == 'promote' and not matches[2] then
if not is_owner(msg) then
return "Only the owner can prmote new moderators"
end
if type(msg.reply_id)~="nil" then
msgr = get_message(msg.reply_id, promote_by_reply, false)
end
end
if matches[1] == 'promote' and matches[2] then
if not is_momod(msg) then
return
end
if not is_owner(msg) then
return "Only owner can promote"
end
local member = matches[2]
savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted @".. member)
local cbres_extra = {
chat_id = msg.to.id,
mod_cmd = 'promote',
from_id = msg.from.id
}
local username = matches[2]
local username = string.gsub(matches[2], '@', '')
return res_user(username, promote_demote_res, cbres_extra)
end
if matches[1] == 'demote' and not matches[2] then
if not is_owner(msg) then
return "Only the owner can demote moderators"
end
if type(msg.reply_id)~="nil" then
msgr = get_message(msg.reply_id, demote_by_reply, false)
end
end
if matches[1] == 'demote' and matches[2] then
if not is_momod(msg) then
return
end
if not is_owner(msg) then
return "Only owner can demote"
end
if string.gsub(matches[2], "@", "") == msg.from.username and not is_owner(msg) then
return "You can't demote yourself"
end
local member = matches[2]
savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted @".. member)
local cbres_extra = {
chat_id = msg.to.id,
mod_cmd = 'demote',
from_id = msg.from.id
}
local username = matches[2]
local username = string.gsub(matches[2], '@', '')
return res_user(username, promote_demote_res, cbres_extra)
end
if matches[1] == 'modlist' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group modlist")
return modlist(msg)
end
if matches[1] == 'about' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group description")
return get_description(msg, data)
end
if matches[1] == 'rules' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group rules")
return get_rules(msg, data)
end
if matches[1] == 'set' then
if matches[2] == 'rules' then
rules = matches[3]
local target = msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group rules to ["..matches[3].."]")
return set_rulesmod(msg, data, target)
end
if matches[2] == 'about' then
local data = load_data(_config.moderation.data)
local target = msg.to.id
local about = matches[3]
savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group description to ["..matches[3].."]")
return set_descriptionmod(msg, data, target, about)
end
end
if matches[1] == 'lock' then
local target = msg.to.id
if matches[2] == 'name' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked name ")
return lock_group_namemod(msg, data, target)
end
if matches[2] == 'member' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked member ")
return lock_group_membermod(msg, data, target)
end
if matches[2] == 'flood' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked flood ")
return lock_group_floodmod(msg, data, target)
end
if matches[2] == 'arabic' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked arabic ")
return lock_group_arabic(msg, data, target)
end
if matches[2] == 'bots' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked bots ")
return lock_group_bots(msg, data, target)
end
if matches[2] == 'leave' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked leaving ")
return lock_group_leave(msg, data, target)
end
end
if matches[1] == 'unlock' then
local target = msg.to.id
if matches[2] == 'name' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked name ")
return unlock_group_namemod(msg, data, target)
end
if matches[2] == 'member' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked member ")
return unlock_group_membermod(msg, data, target)
end
if matches[2] == 'photo' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked photo ")
return unlock_group_photomod(msg, data, target)
end
if matches[2] == 'flood' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked flood ")
return unlock_group_floodmod(msg, data, target)
end
if matches[2] == 'arabic' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked arabic ")
return unlock_group_arabic(msg, data, target)
end
if matches[2] == 'bots' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked bots ")
return unlock_group_bots(msg, data, target)
end
if matches[2] == 'leave' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked leaving ")
return unlock_group_leave(msg, data, target)
end
end
if matches[1] == 'settings' then
local target = msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group settings ")
return show_group_settingsmod(msg, data, target)
end
--[[if matches[1] == 'public' then
local target = msg.to.id
if matches[2] == 'yes' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: public")
return set_public_membermod(msg, data, target)
end
if matches[2] == 'no' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: not public")
return unset_public_membermod(msg, data, target)
end
end]]
if matches[1] == 'newlink' and not is_realm(msg) then
if not is_momod(msg) then
return "For moderators only!"
end
local function callback (extra , success, result)
local receiver = 'chat#'..msg.to.id
if success == 0 then
return send_large_msg(receiver, '*Error: Invite link failed* \nReason: Not creator.')
end
send_large_msg(receiver, "Created a new link")
data[tostring(msg.to.id)]['settings']['set_link'] = result
save_data(_config.moderation.data, data)
end
local receiver = 'chat#'..msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] revoked group link ")
return export_chat_link(receiver, callback, true)
end
if matches[1] == 'link' then
if not is_momod(msg) then
return "For moderators only!"
end
local group_link = data[tostring(msg.to.id)]['settings']['set_link']
if not group_link then
return "Create a link using /newlink first !"
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group link ["..group_link.."]")
return "Group link:\n"..group_link
end
if matches[1] == 'setowner' and matches[2] then
if not is_owner(msg) then
return "For owner only!"
end
data[tostring(msg.to.id)]['set_owner'] = matches[2]
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set ["..matches[2].."] as owner")
local text = matches[2].." added as owner"
return text
end
if matches[1] == 'setowner' and not matches[2] then
if not is_owner(msg) then
return "only for the owner!"
end
if type(msg.reply_id)~="nil" then
msgr = get_message(msg.reply_id, setowner_by_reply, false)
end
end
if matches[1] == 'owner' then
local group_owner = data[tostring(msg.to.id)]['set_owner']
local user_info = redis:hgetall('user:'..group_owner)
if not group_owner then
return "no owner,ask admins in support groups to set owner for your group"
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] used /owner")
if user_info.username then
return "Group onwer is @"..user_info.username.." ["..group_owner.."]"
else
return "Group owner is ["..group_owner..']'
end
end
if matches[1] == 'setgpowner' then
local receiver = "chat#id"..matches[2]
if not is_admin(msg) then
return "For admins only!"
end
data[tostring(matches[2])]['set_owner'] = matches[3]
save_data(_config.moderation.data, data)
local text = matches[3].." added as owner"
send_large_msg(receiver, text)
return
end
if matches[1] == 'setflood' then
if not is_momod(msg) then
return "For moderators only!"
end
if tonumber(matches[2]) < 5 or tonumber(matches[2]) > 20 then
return "Wrong number,range is [5-20]"
end
local flood_max = matches[2]
data[tostring(msg.to.id)]['settings']['flood_msg_max'] = flood_max
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set flood to ["..matches[2].."]")
return 'Group flood has been set to '..matches[2]
end
if matches[1] == 'clean' then
if not is_owner(msg) then
return "Only owner can clean"
end
if matches[2] == 'member' then
if not is_owner(msg) then
return "Only admins can clean members"
end
local receiver = get_receiver(msg)
chat_info(receiver, cleanmember, {receiver=receiver})
end
if matches[2] == 'modlist' then
if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way
return 'No moderator in this group.'
end
local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n'
for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do
data[tostring(msg.to.id)]['moderators'][tostring(k)] = nil
save_data(_config.moderation.data, data)
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned modlist")
end
if matches[2] == 'rules' then
local data_cat = 'rules'
data[tostring(msg.to.id)][data_cat] = nil
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned rules")
end
if matches[2] == 'about' then
local data_cat = 'description'
data[tostring(msg.to.id)][data_cat] = nil
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned about")
end
end
if matches[1] == 'kill' and matches[2] == 'chat' then
if not is_admin(msg) then
return nil
end
if not is_realm(msg) then
local receiver = get_receiver(msg)
return modrem(msg),
print("Closing Group..."),
chat_info(receiver, killchat, {receiver=receiver})
else
return 'This is a realm'
end
end
if matches[1] == 'kill' and matches[2] == 'realm' then
if not is_admin(msg) then
return nil
end
if not is_group(msg) then
local receiver = get_receiver(msg)
return realmrem(msg),
print("Closing Realm..."),
chat_info(receiver, killrealm, {receiver=receiver})
else
return 'This is a group'
end
end
if matches[1] == 'help' then
if not is_momod(msg) or is_realm(msg) then
return
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help")
return help()
end
if matches[1] == 'res' and is_momod(msg) then
local cbres_extra = {
chatid = msg.to.id
}
local username = matches[2]
local username = username:gsub("@","")
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username)
return res_user(username, callbackres, cbres_extra)
end
if matches[1] == 'kickinactive' then
--send_large_msg('chat#id'..msg.to.id, 'I\'m in matches[1]')
if not is_momod(msg) then
return 'Only a moderator can kick inactive users'
end
local num = 1
if matches[2] then
num = matches[2]
end
local chat_id = msg.to.id
local receiver = get_receiver(msg)
return kick_inactive(chat_id, num, receiver)
end
end
end
return {
patterns = {
"^[!/](add)$",
"^[!/](add) (realm)$",
"^[!/](rem)$",
"^[!/](rem) (realm)$",
"^[!/](rules)$",
"^[!/](about)$",
"^[!/](setname) (.*)$",
"^[!/](setphoto)$",
"^[!/](promote) (.*)$",
"^[!/](promote)",
"^[!/](help)$",
"^[!/](clean) (.*)$",
"^[!/](kill) (chat)$",
"^[!/](kill) (realm)$",
"^[!/](demote) (.*)$",
"^[!/](demote)",
"^[!/](set) ([^%s]+) (.*)$",
"^[!/](lock) (.*)$",
"^[!/](setowner) (%d+)$",
"^[!/](setowner)",
"^[!/](owner)$",
"^[!/](res) (.*)$",
"^[!/](setgpowner) (%d+) (%d+)$",-- (group id) (owner id)
"^[!/](unlock) (.*)$",
"^[!/](setflood) (%d+)$",
"^[!/](settings)$",
-- "^[!/](public) (.*)$",
"^[!/](modlist)$",
"^[!/](newlink)$",
"^[!/](link)$",
"^[!/](kickinactive)$",
"^[!/](kickinactive) (%d+)$",
"%[(photo)%]",
"^!!tgservice (.+)$",
},
run = run
}
end
| gpl-2.0 |
Zenny89/darkstar | scripts/zones/Windurst_Woods/npcs/Hae_Jakkya.lua | 17 | 1334 | -----------------------------------
-- Area: Windurst Woods
-- NPC: Hae Jakkya
-- Working 100%
-----------------------------------
require("scripts/globals/settings");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
chasingStatus = player:getQuestStatus(WINDURST,CHASING_TALES);
if (player:hasKeyItem(126) ==true) then
player:startEvent(0x0196);
elseif (player:getVar("CHASING_TALES_TRACK_BOOK") == 1) then
player:startEvent(0x0193);
elseif (player:hasKeyItem(149)) then
player:startEvent(0x0192); -- Neeed CS here
else
player:startEvent(0x29);
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 == 0x0192) then
player:setVar("CHASING_TALES_TRACK_BOOK",1);
end
end;
| gpl-3.0 |
Zenny89/darkstar | scripts/zones/Bibiki_Bay/mobs/Shen.lua | 16 | 1239 | -----------------------------------
-- Area: Bibiki Bay
-- NPC: Shen
-----------------------------------
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
end;
-----------------------------------
-- onMobFight Action
-----------------------------------
function onMobFight(mob,target)
local Shen = mob:getID();
if (mob:getBattleTime() % 45 == 0) then
if (GetMobAction(Shen+1) == 0) then
SpawnMob(Shen+1,300):updateEnmity(target);
elseif (GetMobAction(Shen+2) == 0) then
SpawnMob(Shen+2,300):updateEnmity(target);
end
end
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, killer)
end;
-----------------------------------
-- onMonsterMagicPrepare
-----------------------------------
function onMonsterMagicPrepare(mob,target)
-- casts Water IV, Waterga III, Flood, Drown
rnd = math.random();
if (rnd < 0.5) then
return 201; -- waterga 3
elseif (rnd < 0.7) then
return 172; -- water 4
elseif (rnd < 0.9) then
return 214; -- flood
else
return 240; -- drown
end
end; | gpl-3.0 |
appaquet/torch-android | src/3rdparty/nnx/SpatialSparseCriterion.lua | 6 | 2486 | local SpatialSparseCriterion, parent = torch.class('nn.SpatialSparseCriterion', 'nn.SparseCriterion')
function SpatialSparseCriterion:__init(...)
parent.__init(self)
xlua.unpack_class(self, {...},
'nn.SpatialSparseCriterion',
'A spatial extension of the SparseCriterion class.\n'
..' Provides a set of parameters to deal with spatial mini-batch training.',
{arg='nbGradients', type='number', help='number of gradients to backpropagate (-1:all, >=1:nb)', default=-1},
{arg='sizeAverage', type='number', help='if true, forward() returns an average instead of a sum of errors', default=true}
)
end
function SpatialSparseCriterion:updateOutput(input)
self.fullOutput = self.fullOutput or torch.Tensor()
self.fullOutput:resize(input:size(2), input:size(3))
input.nn.SpatialSparseCriterion_updateOutput(self, input)
if self.sizeAverage then
self.output = self.fullOutput:mean()
else
self.output = self.fullOutput:sum()
end
return self.output
end
function SpatialSparseCriterion:updateGradInput(input,target)
-- (1) retrieve adjusted target
target = self.target
-- (2) resize input gradient map
self.gradInput:resizeAs(input):zero()
-- (3) compute input gradients, based on the nbGradients param
if self.nbGradients == -1 then
-- dense gradients
input.nn.SpatialSparseCriterion_updateGradInput(self, input, self.gradInput)
elseif self.nbGradients == 1 then
-- only 1 gradient is computed, sampled in the center
self.fullGradInput = torch.Tensor() or self.fullGradInput
self.fullGradInput:resizeAs(input):zero()
input.nn.SpatialSparseCriterion_updateGradInput(self, input, self.fullGradInput)
local y = math.ceil(self.gradInput:size(2)/2)
local x = math.ceil(self.gradInput:size(3)/2)
self.gradInput:select(3,x):select(2,y):copy(self.fullGradInput:select(3,x):select(2,y))
else
-- only N gradients are computed, sampled in random locations
self.fullGradInput = torch.Tensor() or self.fullGradInput
self.fullGradInput:resizeAs(input):zero()
input.nn.SpatialSparseCriterion_updateGradInput(self, input, self.fullGradInput)
for i = 1,self.nbGradients do
local x = math.random(1,self.gradInput:size(1))
local y = math.random(1,self.gradInput:size(2))
self.gradInput:select(3,x):select(2,y):copy(self.fullGradInput:select(3,x):select(2,y))
end
end
return self.gradInput
end
| bsd-3-clause |
alirezanile/Lanmij | plugins/bot_on_off.lua | 292 | 1641 | -- Checks if bot was disabled on specific chat
local function is_channel_disabled( receiver )
if not _config.disabled_channels then
return false
end
if _config.disabled_channels[receiver] == nil then
return false
end
return _config.disabled_channels[receiver]
end
local function enable_channel(receiver)
if not _config.disabled_channels then
_config.disabled_channels = {}
end
if _config.disabled_channels[receiver] == nil then
return 'Robot is Online'
end
_config.disabled_channels[receiver] = false
save_config()
return "Robot is Online"
end
local function disable_channel( receiver )
if not _config.disabled_channels then
_config.disabled_channels = {}
end
_config.disabled_channels[receiver] = true
save_config()
return "Robot is Offline"
end
local function pre_process(msg)
local receiver = get_receiver(msg)
-- If sender is moderator then re-enable the channel
--if is_sudo(msg) then
if is_momod(msg) then
if msg.text == "[!/]bot on" then
enable_channel(receiver)
end
end
if is_channel_disabled(receiver) then
msg.text = ""
end
return msg
end
local function run(msg, matches)
local receiver = get_receiver(msg)
-- Enable a channel
if matches[1] == 'on' then
return enable_channel(receiver)
end
-- Disable a channel
if matches[1] == 'off' then
return disable_channel(receiver)
end
end
return {
description = "Robot Switch",
usage = {
"/bot on : enable robot in group",
"/bot off : disable robot in group" },
patterns = {
"^[!/]bot? (on)",
"^[!/]bot? (off)" },
run = run,
privileged = true,
--moderated = true,
pre_process = pre_process
}
| gpl-2.0 |
actboy168/YDWE | Development/Component/script/ydwe/stringify_slk.lua | 2 | 1444 | local table_concat = table.concat
local current_x, current_y
local function get_data(x, y, k)
local str = {}
str[#str+1] = 'C'
if x ~= current_x then
current_x = x
str[#str+1] = ('X%d'):format(x)
end
if y ~= current_y then
current_y = y
str[#str+1] = ('Y%d'):format(y)
end
if tonumber(k) then
str[#str+1] = ('K%s'):format(k)
else
str[#str+1] = ('K"%s"'):format(k)
end
return table_concat(str, ';')
end
local current_titles
local function insert_title(buf, title)
local x = #current_titles+1
current_titles[x] = title
current_titles[title] = x
buf[#buf+1] = get_data(x, 1, title)
return x
end
local function get_title(buf, title)
return current_titles[title] or insert_title(buf, title)
end
local function insert_obj(buf, tbl)
local y = 1
for name, obj in pairs(tbl) do
y = y + 1
buf[#buf+1] = get_data(1, y, name)
for key, value in pairs(obj) do
local str = get_data(get_title(buf, key), y, value)
buf[#buf+1] = str
end
end
return y
end
return function(t, id_title)
local buf = {'ID;PWXL;N;E', ''}
current_x = nil
current_y = nil
current_titles = {}
insert_title(buf, id_title)
local y = insert_obj(buf, t)
buf[#buf+1] = 'E'
buf[2] = ('B;X%d;Y%d;D%d'):format(#current_titles, y, 0)
return table_concat(buf, '\r\n')
end
| gpl-3.0 |
nasomi/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/Isdebaaq.lua | 30 | 3597 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Isdebaaq
-- Type: Assault Mission Giver
-- @pos 127.565 0.161 -43.846 50
-----------------------------------
package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs");
require("scripts/globals/besieged");
require("scripts/globals/missions");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local rank = getMercenaryRank(player);
local haveimperialIDtag;
local assaultPoints = player:getAssaultPoint(MAMOOL_ASSAULT_POINT);
if (player:hasKeyItem(IMPERIAL_ARMY_ID_TAG)) then
haveimperialIDtag = 1;
else
haveimperialIDtag = 0;
end
if (rank > 0) then
player:startEvent(274,rank,haveimperialIDtag,assaultPoints,player:getCurrentAssault());
else
player:startEvent(280); -- no rank
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 == 274) then
local selectiontype = bit.band(option, 0xF);
if (selectiontype == 1) then
-- taken assault mission
player:addAssault(bit.rshift(option,4));
player:delKeyItem(IMPERIAL_ARMY_ID_TAG);
player:addKeyItem(MAMOOL_JA_ASSAULT_ORDERS);
player:messageSpecial(KEYITEM_OBTAINED,MAMOOL_JA_ASSAULT_ORDERS);
elseif (selectiontype == 2) then
-- purchased an item
local item = bit.rshift(option,14);
local itemID = 0;
local price = 0;
-- Copy/pasted from Famad, TODO: fill in the actual IDs/prices for Isdebaaq
--[[if (item == 1) then
itemID = 15972;
price = 3000;
elseif (item == 2) then
itemID = 15777;
price = 5000;
elseif (item == 3) then
itemID = 15523;
price = 8000;
elseif (item == 4) then
itemID = 15886;
price = 10000;
elseif (item == 5) then
itemID = 15492;
price = 10000;
elseif (item == 6) then
itemID = 18583;
price = 10000;
elseif (item == 7) then
itemID = 18388;
price = 15000;
elseif (item == 8) then
itemID = 18417;
price = 15000;
elseif (item == 9) then
itemID = 14940;
price = 15000;
elseif (item == 10) then
itemID = 15690;
price = 20000;
elseif (item == 11) then
itemID = 14525;
price = 20000;
else
return;
end
player:addItem(itemID);
player:messageSpecial(ITEM_OBTAINED,itemID);
player:delAssaultPoint(LEBROS_ASSAULT_POINT,price);]]
end
end
end;
| gpl-3.0 |
nasomi/darkstar | scripts/globals/weaponskills/tornado_kick.lua | 30 | 2115 | -------------------------------
-- Auth : Thief
-- Skill: Tornado Kick
-- Class: H2H Weapon Skill
-- Level: 225
-- Mods : STR:37.5% VIT:30%
-- 100%TP 200%TP 300%TP
-- 2.0x 2.75x 3.5x
-- Delivers a twofold attack. Damage varies with TP.
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
-----------------------------------
function onUseWeaponSkill(player, target, wsID)
local params = {};
--number of normal hits for ws
params.numHits = 2;
--stat-modifiers (0.0 = 0%, 0.2 = 20%, 0.5 = 50%..etc)
params.str_wsc = 0.5; params.dex_wsc = 0.0;
params.vit_wsc = 0.5; params.agi_wsc = 0.0;
params.int_wsc = 0.0; params.mnd_wsc = 0.0;
params.chr_wsc = 0.0;
--ftp damage mods (for Damage Varies with TP; lines are calculated in the function ftp)
params.ftp100 = 2.0; params.ftp200 = 2.75; params.ftp300 = 3.5;
--critical modifiers (0.0 = 0%, 0.2 = 20%, 0.5 = 50%..etc)
params.crit100 = 0.0; params.crit200=0.0; params.crit300=0.0;
params.canCrit = false;
--params.accuracy modifiers (0.0 = 0%, 0.2 = 20%, 0.5 = 50%..etc) Keep 0 if ws doesn't have accuracy modification.
params.acc100 = 0.0; params.acc200=0.0; params.acc300=0.0;
--attack multiplier (only some WSes use this, this varies the actual ratio value, see Tachi: Kasha) 1 is default.
params.atkmulti = 1;
-- Tornado kick is not considered a kick attack and is not modified by Footwork http://www.bluegartr.com/threads/121610-Rehauled-Weapon-Skills-tier-lists?p=6140907&viewfull=1#post6140907
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.ftp100 = 2.25; params.ftp200 = 4.25; params.ftp300 = 7.5;
params.str_wsc = 0.4; params.dex_wsc = 0.4; 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.atkmulti = 1.5;
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, params);
damage = damage * WEAPON_SKILL_POWER
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
thesabbir/luci | modules/luci-mod-admin-full/luasrc/controller/admin/network.lua | 36 | 11355 | -- Copyright 2008 Steven Barth <steven@midlink.org>
-- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
-- Licensed to the public under the Apache License 2.0.
module("luci.controller.admin.network", package.seeall)
function index()
local uci = require("luci.model.uci").cursor()
local page
page = node("admin", "network")
page.target = firstchild()
page.title = _("Network")
page.order = 50
page.index = true
-- if page.inreq then
local has_switch = false
uci:foreach("network", "switch",
function(s)
has_switch = true
return false
end)
if has_switch then
page = node("admin", "network", "vlan")
page.target = cbi("admin_network/vlan")
page.title = _("Switch")
page.order = 20
page = entry({"admin", "network", "switch_status"}, call("switch_status"), nil)
page.leaf = true
end
local has_wifi = false
uci:foreach("wireless", "wifi-device",
function(s)
has_wifi = true
return false
end)
if has_wifi then
page = entry({"admin", "network", "wireless_join"}, call("wifi_join"), nil)
page.leaf = true
page = entry({"admin", "network", "wireless_add"}, call("wifi_add"), nil)
page.leaf = true
page = entry({"admin", "network", "wireless_delete"}, call("wifi_delete"), nil)
page.leaf = true
page = entry({"admin", "network", "wireless_status"}, call("wifi_status"), nil)
page.leaf = true
page = entry({"admin", "network", "wireless_reconnect"}, call("wifi_reconnect"), nil)
page.leaf = true
page = entry({"admin", "network", "wireless_shutdown"}, call("wifi_shutdown"), nil)
page.leaf = true
page = entry({"admin", "network", "wireless"}, arcombine(template("admin_network/wifi_overview"), cbi("admin_network/wifi")), _("Wifi"), 15)
page.leaf = true
page.subindex = true
if page.inreq then
local wdev
local net = require "luci.model.network".init(uci)
for _, wdev in ipairs(net:get_wifidevs()) do
local wnet
for _, wnet in ipairs(wdev:get_wifinets()) do
entry(
{"admin", "network", "wireless", wnet:id()},
alias("admin", "network", "wireless"),
wdev:name() .. ": " .. wnet:shortname()
)
end
end
end
end
page = entry({"admin", "network", "iface_add"}, cbi("admin_network/iface_add"), nil)
page.leaf = true
page = entry({"admin", "network", "iface_delete"}, call("iface_delete"), nil)
page.leaf = true
page = entry({"admin", "network", "iface_status"}, call("iface_status"), nil)
page.leaf = true
page = entry({"admin", "network", "iface_reconnect"}, call("iface_reconnect"), nil)
page.leaf = true
page = entry({"admin", "network", "iface_shutdown"}, call("iface_shutdown"), nil)
page.leaf = true
page = entry({"admin", "network", "network"}, arcombine(cbi("admin_network/network"), cbi("admin_network/ifaces")), _("Interfaces"), 10)
page.leaf = true
page.subindex = true
if page.inreq then
uci:foreach("network", "interface",
function (section)
local ifc = section[".name"]
if ifc ~= "loopback" then
entry({"admin", "network", "network", ifc},
true, ifc:upper())
end
end)
end
if nixio.fs.access("/etc/config/dhcp") then
page = node("admin", "network", "dhcp")
page.target = cbi("admin_network/dhcp")
page.title = _("DHCP and DNS")
page.order = 30
page = entry({"admin", "network", "dhcplease_status"}, call("lease_status"), nil)
page.leaf = true
page = node("admin", "network", "hosts")
page.target = cbi("admin_network/hosts")
page.title = _("Hostnames")
page.order = 40
end
page = node("admin", "network", "routes")
page.target = cbi("admin_network/routes")
page.title = _("Static Routes")
page.order = 50
page = node("admin", "network", "diagnostics")
page.target = template("admin_network/diagnostics")
page.title = _("Diagnostics")
page.order = 60
page = entry({"admin", "network", "diag_ping"}, call("diag_ping"), nil)
page.leaf = true
page = entry({"admin", "network", "diag_nslookup"}, call("diag_nslookup"), nil)
page.leaf = true
page = entry({"admin", "network", "diag_traceroute"}, call("diag_traceroute"), nil)
page.leaf = true
page = entry({"admin", "network", "diag_ping6"}, call("diag_ping6"), nil)
page.leaf = true
page = entry({"admin", "network", "diag_traceroute6"}, call("diag_traceroute6"), nil)
page.leaf = true
-- end
end
function wifi_join()
local function param(x)
return luci.http.formvalue(x)
end
local function ptable(x)
x = param(x)
return x and (type(x) ~= "table" and { x } or x) or {}
end
local dev = param("device")
local ssid = param("join")
if dev and ssid then
local cancel = (param("cancel") or param("cbi.cancel")) and true or false
if cancel then
luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless_join?device=" .. dev))
else
local cbi = require "luci.cbi"
local tpl = require "luci.template"
local map = luci.cbi.load("admin_network/wifi_add")[1]
if map:parse() ~= cbi.FORM_DONE then
tpl.render("header")
map:render()
tpl.render("footer")
end
end
else
luci.template.render("admin_network/wifi_join")
end
end
function wifi_add()
local dev = luci.http.formvalue("device")
local ntm = require "luci.model.network".init()
dev = dev and ntm:get_wifidev(dev)
if dev then
local net = dev:add_wifinet({
mode = "ap",
ssid = "OpenWrt",
encryption = "none"
})
ntm:save("wireless")
luci.http.redirect(net:adminlink())
end
end
function wifi_delete(network)
local ntm = require "luci.model.network".init()
local wnet = ntm:get_wifinet(network)
if wnet then
local dev = wnet:get_device()
local nets = wnet:get_networks()
if dev then
ntm:del_wifinet(network)
ntm:commit("wireless")
local _, net
for _, net in ipairs(nets) do
if net:is_empty() then
ntm:del_network(net:name())
ntm:commit("network")
end
end
luci.sys.call("env -i /bin/ubus call network reload >/dev/null 2>/dev/null")
end
end
luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless"))
end
function iface_status(ifaces)
local netm = require "luci.model.network".init()
local rv = { }
local iface
for iface in ifaces:gmatch("[%w%.%-_]+") do
local net = netm:get_network(iface)
local device = net and net:get_interface()
if device then
local data = {
id = iface,
proto = net:proto(),
uptime = net:uptime(),
gwaddr = net:gwaddr(),
dnsaddrs = net:dnsaddrs(),
name = device:shortname(),
type = device:type(),
ifname = device:name(),
macaddr = device:mac(),
is_up = device:is_up(),
rx_bytes = device:rx_bytes(),
tx_bytes = device:tx_bytes(),
rx_packets = device:rx_packets(),
tx_packets = device:tx_packets(),
ipaddrs = { },
ip6addrs = { },
subdevices = { }
}
local _, a
for _, a in ipairs(device:ipaddrs()) do
data.ipaddrs[#data.ipaddrs+1] = {
addr = a:host():string(),
netmask = a:mask():string(),
prefix = a:prefix()
}
end
for _, a in ipairs(device:ip6addrs()) do
if not a:is6linklocal() then
data.ip6addrs[#data.ip6addrs+1] = {
addr = a:host():string(),
netmask = a:mask():string(),
prefix = a:prefix()
}
end
end
for _, device in ipairs(net:get_interfaces() or {}) do
data.subdevices[#data.subdevices+1] = {
name = device:shortname(),
type = device:type(),
ifname = device:name(),
macaddr = device:mac(),
macaddr = device:mac(),
is_up = device:is_up(),
rx_bytes = device:rx_bytes(),
tx_bytes = device:tx_bytes(),
rx_packets = device:rx_packets(),
tx_packets = device:tx_packets(),
}
end
rv[#rv+1] = data
else
rv[#rv+1] = {
id = iface,
name = iface,
type = "ethernet"
}
end
end
if #rv > 0 then
luci.http.prepare_content("application/json")
luci.http.write_json(rv)
return
end
luci.http.status(404, "No such device")
end
function iface_reconnect(iface)
local netmd = require "luci.model.network".init()
local net = netmd:get_network(iface)
if net then
luci.sys.call("env -i /sbin/ifup %q >/dev/null 2>/dev/null" % iface)
luci.http.status(200, "Reconnected")
return
end
luci.http.status(404, "No such interface")
end
function iface_shutdown(iface)
local netmd = require "luci.model.network".init()
local net = netmd:get_network(iface)
if net then
luci.sys.call("env -i /sbin/ifdown %q >/dev/null 2>/dev/null" % iface)
luci.http.status(200, "Shutdown")
return
end
luci.http.status(404, "No such interface")
end
function iface_delete(iface)
local netmd = require "luci.model.network".init()
local net = netmd:del_network(iface)
if net then
luci.sys.call("env -i /sbin/ifdown %q >/dev/null 2>/dev/null" % iface)
luci.http.redirect(luci.dispatcher.build_url("admin/network/network"))
netmd:commit("network")
netmd:commit("wireless")
return
end
luci.http.status(404, "No such interface")
end
function wifi_status(devs)
local s = require "luci.tools.status"
local rv = { }
local dev
for dev in devs:gmatch("[%w%.%-]+") do
rv[#rv+1] = s.wifi_network(dev)
end
if #rv > 0 then
luci.http.prepare_content("application/json")
luci.http.write_json(rv)
return
end
luci.http.status(404, "No such device")
end
local function wifi_reconnect_shutdown(shutdown, wnet)
local netmd = require "luci.model.network".init()
local net = netmd:get_wifinet(wnet)
local dev = net:get_device()
if dev and net then
dev:set("disabled", nil)
net:set("disabled", shutdown and 1 or nil)
netmd:commit("wireless")
luci.sys.call("env -i /bin/ubus call network reload >/dev/null 2>/dev/null")
luci.http.status(200, shutdown and "Shutdown" or "Reconnected")
return
end
luci.http.status(404, "No such radio")
end
function wifi_reconnect(wnet)
wifi_reconnect_shutdown(false, wnet)
end
function wifi_shutdown(wnet)
wifi_reconnect_shutdown(true, wnet)
end
function lease_status()
local s = require "luci.tools.status"
luci.http.prepare_content("application/json")
luci.http.write('[')
luci.http.write_json(s.dhcp_leases())
luci.http.write(',')
luci.http.write_json(s.dhcp6_leases())
luci.http.write(']')
end
function switch_status(switches)
local s = require "luci.tools.status"
luci.http.prepare_content("application/json")
luci.http.write_json(s.switch_status(switches))
end
function diag_command(cmd, addr)
if addr and addr:match("^[a-zA-Z0-9%-%.:_]+$") then
luci.http.prepare_content("text/plain")
local util = io.popen(cmd % addr)
if util then
while true do
local ln = util:read("*l")
if not ln then break end
luci.http.write(ln)
luci.http.write("\n")
end
util:close()
end
return
end
luci.http.status(500, "Bad address")
end
function diag_ping(addr)
diag_command("ping -c 5 -W 1 %q 2>&1", addr)
end
function diag_traceroute(addr)
diag_command("traceroute -q 1 -w 1 -n %q 2>&1", addr)
end
function diag_nslookup(addr)
diag_command("nslookup %q 2>&1", addr)
end
function diag_ping6(addr)
diag_command("ping6 -c 5 %q 2>&1", addr)
end
function diag_traceroute6(addr)
diag_command("traceroute6 -q 1 -w 2 -n %q 2>&1", addr)
end
| apache-2.0 |
Hello23-Ygopro/ygopro-ds | expansions/script/c27004144.lua | 1 | 1157 | --SD4-05 Namekian Bond Saonel
local ds=require "expansions.utility_dbscg"
local scard,sid=ds.GetID()
function scard.initial_effect(c)
ds.EnableBattleAttribute(c)
ds.AddSetcode(c,SPECIAL_TRAIT_ALIEN,SPECIAL_TRAIT_UNIVERSE_6,SPECIAL_TRAIT_NAMEKIAN,SPECIAL_TRAIT_INCLUDES_UNIVERSE)
ds.AddPlayProcedure(c,COLOR_GREEN,1,2)
--draw (bond)
ds.EnableBond(c)
ds.AddSingleAutoPlay(c,0,nil,nil,scard.drop,DS_EFFECT_FLAG_CARD_CHOOSE,scard.drcon)
end
scard.dragon_ball_super_card=true
scard.combo_cost=0
function scard.bondfilter(c)
return c:IsBattle() and c:IsSpecialTrait(SPECIAL_TRAIT_NAMEKIAN)
end
scard.drcon=ds.BondCondition(3,scard.bondfilter)
function scard.drop(e,tp,eg,ep,ev,re,r,rp)
Duel.Draw(tp,1,DS_REASON_SKILL)
local g1=Duel.SelectLifeTarget(tp,nil,tp,0,2,nil,e)
if g1:GetCount()==0 then return end
Duel.BreakEffect()
if Duel.SendtoHand(g1,PLAYER_OWNER,DS_REASON_SKILL)==0 then return end
Duel.Hint(HINT_SELECTMSG,tp,DS_HINTMSG_KO)
local g2=Duel.SelectMatchingCard(tp,ds.BattleAreaFilter(Card.IsCanBeSkillTarget),tp,0,DS_LOCATION_BATTLE,0,1,nil,e)
if g2:GetCount()==0 then return end
Duel.SetTargetCard(g2)
Duel.KO(g2,DS_REASON_SKILL)
end
| gpl-3.0 |
aikon-com-cn/NoxicDB | other/calendar_events/[INCOMPLETE]Wintergrasp/BattlefieldWG.lua | 1 | 51288 | local TIME_TO_BATTLE = 9000 -- How much time there will be between the battles.
local BATTLE_TIMER = 1800 -- How long time will the battle last for. (if attacker towers are not destroyed)
local timer_nextbattle = os.time() + TIME_TO_BATTLE
local timer_battle = 0
local controll = math.random(1,2)
local jointimer_1 = 120 -- Send SMSG_BATTLEFIELD_MGR_ENTRY_INVITE
local jointimer_2 = 30 -- SMSG_BATTLEFIELD_MGR_QUEUE_INVITE
local battle = 0
local states = 0
local stateuiset = 0
local add_tokens = 1
local starttimer = 0
local spawnobjects = 0
local npcstarted = false
local south_towers = 3
local ATTACKER = " "
local DEFENDER = " "
-- Old capture bar controller. Will be removed or reused
local C_BAR_NEUTRAL = 80 -- the neutral vallue of the capture bar. MUST BE UNDER 100.
local C_BAR_CAPTURE = (100 - C_BAR_NEUTRAL)/2
-- GO FACTION (not working for now)
local GAMEOBJECT_FACTION = 0x0006 + 0x0009
-- Factions
local FACTION_HORDE = 1735
local FACTION_ALLIANCE = 1732
local FACTION_NEUTRAL = 35
-- vehicle workshops capture bar controllers
local eastspark_progress = 0
local westspark_progress = 0
local sunkenring_progress = 0
local brokentemple_progres = 0
-- Worldstate workshop controllers
local vehicle_vallue_a = 0
local vehicle_vallue_h = 0
if(controll == 2)then
eastspark_progress = 100
westspark_progress = 100
sunkenring_progress = 100
brokentemple_progres = 100
vehicle_vallue_h = 8
vehicle_vallue_a = 16
else
eastspark_progress = 0
westspark_progress = 0
sunkenring_progress = 0
brokentemple_progres = 0
vehicle_vallue_h = 16
vehicle_vallue_a = 8
end
-- UI STATES
local WG_STATE_NEXT_BATTLE_TIME = 4354
local WG_STATE_END_BATTLE_TIME = 3781
local WG_HORDE_CONTROLLED = 3802
local WG_ALLIANCE_CONTROLLED = 3803
local WG_STATE_BATTLE_UI = 3710
local WG_STATE_BATTLE_TIME = 3781
local WG_STATE_NEXT_BATTLE_TIMER = 3801
local WG_STATE_CURRENT_H_VEHICLES = 3490
local WG_STATE_MAX_H_VEHICLES = 3491
local WG_STATE_CURRENT_A_VEHICLES = 3680
local WG_STATE_MAX_A_VEHICLES = 3681
local WG_STATE_BATTLEFIELD_STATUS_MAP = 3804
-- Map states:
local WG_STATE_KEEP_GATE_ANDGY = 3773
-- Dynamic capturebar states
local WG_STATE_SOUTH_SHOW = 3501
local WG_STATE_SOUTH_PROGRESS = 3502
local WG_STATE_SOUTH_NEUTRAL = 3508
-- Npc's
local NPC_DETECTION_UNIT = 27869
local NPC_GOBLIN_ENGINEER = 30400
local NPC_GNOME_ENGINEER = 30499
local NPC_NOT_IMMUNE_PC_NPC = 23472
local NPC_INVISIBLE_STALKER = 15214
local NPC_VEHICLE_CATAPULT = 27881
local NPC_VEHICLE_DEMOLISHER = 28094
local NPC_VEHICLE_SIEGE_ENGINE_H = 32627
local NPC_VEHICLE_SIEGE_ENGINE_A = 28312
-- Objects
local GO_WINTERGRASP_TITAN_RELIC = 192829
local GO_WINTERGRASP_VAULT_GATE = 191810
local GO_WINTERGRASP_KEEP_COLLISION_WALL = 194162
local GO_WINTERGRASP_FW_TOWER = 190358
local GO_WINTERGRASP_WE_TOWER = 190357
local GO_WINTERGRASP_SS_TOWER = 190356
local GO_WINTERGRASP_DEFENDER_H = 190763
local GO_WINTERGRASP_DEFENDER_A = 191575
local GO_WINTERGRASP_DEFENDER_N = 192819
local GO_WINTERGRASP_VEHICLE_TELEPORTER = 192951
-- Map info
local MAP_NORTHREND = 571
-- Areass
local ZONE_WG = 4197
local AREA_FORTRESS = 4575
local AREA_EASTSPARK = 4612
local AREA_WESTSPARK = 4611
local AREA_BROKENTEMPLE = 4539
local AREA_SUNKENRING = 4538
local AREA_FLAMEWATCH_T = 4581
local AREA_WINTERSEDGE_T = 4582
local AREA_SHADOWSIGHT_T = 4583
local AREA_C_BRIDGE = 4576
local AREA_E_BRIDGE = 4557
local AREA_W_BRIDGE = 4578
-- Spells
local SPELL_RECRUIT = 37795
local SPELL_CORPORAL = 33280
local SPELL_LIEUTENANT = 55629
local SPELL_TENACITY = 58549
local SPELL_TENACITY_VEHICLE = 59911
local SPELL_TOWER_CONTROL = 62064
local SPELL_SPIRITUAL_IMMUNITY = 58729
local SPELL_GREAT_HONOR = 58555
local SPELL_GREATER_HONOR = 58556
local SPELL_GREATEST_HONOR = 58557
local SPELL_ALLIANCE_FLAG = 14268
local SPELL_HORDE_FLAG = 14267
local SPELL_GRAB_PASSENGER = 61178
local SPELL_TELEPORT_DEFENDER = 54643
local SPELL_TELEPORT_VEHICLE = 49759
local SPELL_BUILD_CATAPULT = 56663
local SPELL_BUILD_DEMOLISHER = 56575
local SPELL_BUILD_ENGINE_A = 56661
local SPELL_BUILD_ENGINE_H = 61408
-- Reward spells
local SPELL_VICTORY_REWARD = 56902
local SPELL_DEFEAT_REWARD = 58494
local SPELL_DAMAGED_TOWER = 59135
local SPELL_DESTROYED_TOWER = 59136
local SPELL_DAMAGED_BUILDING = 59201
local SPELL_INTACT_BUILDING = 59203
local SPELL_TELEPORT_BRIDGE = 59096
local SPELL_TELEPORT_FORTRESS = 60035
local SPELL_TELEPORT_DALARAN = 53360
local SPELL_VICTORY_AURA = 60044
local SPELL_WINTERGRASP_WATER = 36444
local SPELL_ESSENCE_OF_WINTERGRASP = 57940
local SPELL_WINTERGRASP_RESTRICTED_FLIGHT_AREA = 58730
-- Phasing spells
local SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT = 56618 -- phase 16
local SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT = 56617 -- phase 32
local SPELL_HORDE_CONTROL_PHASE_SHIFT = 55773 -- phase 64
local SPELL_ALLIANCE_CONTROL_PHASE_SHIFT = 55774 -- phase 128
-- achievements
local ACHIEVEMENT_VICTORY = 1717
local ACHIEVEMENT_WIN_OUR_GRASP = 1755
local ACHIEVEMENT_LEANING_T = 1727
-- Quests
local QUEST_WG_VICTORY_A = 13181
local QUEST_WG_VICTORY_H = 13183
local QUEST_WG_TOPPING_TOWERS = 13539
local QUEST_WG_SOUTHEN_SABOTAGE = 13538
local QUEST_WG_DEFEND_SIEDGE_A = 13222
local QUEST_WG_DEFEND_SIEDGE_H = 13223
-- Opcodes
local SMSG_PLAY_SOUND = 0x2D2
local SMSG_BATTLEFIELD_MGR_ENTRY_INVITE = 0x4DE
local CMSG_BATTLEFIELD_MGR_ENTRY_INVITE_RESPONSE = 0x4DF
local SMSG_BATTLEFIELD_MGR_ENTERED = 0x4E0
local SMSG_BATTLEFIELD_MGR_QUEUE_INVITE = 0x4E1
local CMSG_BATTLEFIELD_MGR_QUEUE_INVITE_RESPONSE = 0x4E2
local CMSG_BATTLEFIELD_MGR_QUEUE_REQUEST = 0x4E3
local SMSG_BATTLEFIELD_MGR_QUEUE_REQUEST_RESPONSE = 0x4E4
local SMSG_BATTLEFIELD_MGR_EJECT_PENDING = 0x4E5
local SMSG_BATTLEFIELD_MGR_EJECTED = 0x4E6
local CMSG_BATTLEFIELD_MGR_EXIT_REQUEST = 0x4E7
local SMSG_BATTLEFIELD_MGR_STATE_CHANGE = 0x4E8
local CMSG_BATTLEFIELD_MANAGER_ADVANCE_STATE = 0x4E9
local CMSG_BATTLEFIELD_MANAGER_SET_NEXT_TRANSITION_TIME = 0x4EA
local CMSG_START_BATTLEFIELD_CHEAT = 0x4CB
local CMSG_END_BATTLEFIELD_CHEAT = 0x4CC
local CMSG_LEAVE_BATTLEFIELD = 0x2E1
local CMSG_BATTLEFIELD_PORT = 0x2D5
local CMSG_BATTLEFIELD_STATUS = 0x2D3
local SMSG_BATTLEFIELD_STATUS = 0x2D4
local CMSG_BATTLEFIELD_LIST = 0x23C
local SMSG_BATTLEFIELD_LIST = 0x23D
local CMSG_BATTLEFIELD_JOIN = 0x23E
local SMSG_BATTLEFIELD_PORT_DENIED = 0x14B
local SMSG_AREA_SPIRIT_HEALER_TIME = 0x2E4
-- Fortress destructable objects
local go_wall = {
{190219, 3749},
{190220, 3750},
{191802, 3751},
{191803, 3752},
{190369, 3753},
{190371, 3754},
{190374, 3755},
{190376, 3756},
{190372, 3757},
{190370, 3758},
{191807, 3759},
{191808, 3760},
{191809, 3761},
{191799, 3762},
{191795, 3764},
{191797, 3765},
{191800, 3766},
{191804, 3767},
{191805, 3768},
{191806, 3769},
{191801, 3770},
{191798, 3771},
{191796, 3772},
{191810, 3773},
{190375, 3763};
};
-- Fortress towers
local go_f_tower = {
{190221, 3711},
{190378, 3712},
{190373, 3713},
{190377, 3714};
};
-- South towers
local go_s_tower = {
{190356, 3704},
{190357, 3705},
{190358, 3706};
};
-- Workshop data
local workshop_data = {
{192028, 3698, -1, -1, -1,2,4},
{192029, 3699, -1, -1, -1,2,4},
{192030, 3700, brokentemple_progres, 4539, 190487,2},
{192031, 3701, sunkenring_progress, 4538, 190475,2},
{192032, 3702, westspark_progress, 4611, 194962,2},
{192033, 3703, eastspark_progress, 4612, 194959,2};
};
-- Zone ID's for wg buff
local buff_areas = {
4494,
4277,
4100,
4723,
4196,
4416,
4820,
4813,
4809,
4265,
4228,
4415,
4272,
4264,
206,
1196,
3537,
2817,
4395,
65,
394,
495,
4742,
210,
3711,
67,
66;
};
local pvp_detection_data = {
{3723, 5051.19, 2849.41},
{3724, 4488.25, 2823.86},
{3725, 4748.14, 2877.06},
{3726, 5015.43, 2588.31},
{3727, 4736.71, 2418.49},
{3728, 4491.45, 2326.30},
{3729, 5049.93, 3183.56},
{3730, 4814.13, 3304.06},
{3731, 4492.49, 3336.17},
{3737, 4774.71, 2045.71},
{3738, 4516.30, 2087.43},
{3739, 5016.75, 2733.45},
{3740, 4820.90, 2618.30},
{3741, 4450.00, 2528.82},
{3742, 4403.17, 3091.06},
{3743, 4788.79, 3066.96},
{3744, 5045.93, 3016.11},
{3745, 4393.02, 3468.74},
{3746, 4555.75, 3479.11},
{3747, 4832.32, 3457.11},
{3748, 5075.76, 3445.33},
{3774, 5217.59, 2842.80},
{3775, 5214.62, 2995.52},
{3776, 5206.28, 2683.36},
{3777, 5335.53, 2706.81},
{3778, 5333.18, 2840.28},
{3779, 5338.16, 2981.39},
{3788, 4948.71, 3332.18},
{3790, 4932.04, 2440.23},
{3791, 4403.33, 2349.30},
{3792, 4394.57, 3294.98},
{3793, 4531.44, 3584.90},
{3794, 4481.27, 1994.00},
{3795, 4446.45, 2820.81},
{3796, 4683.09, 3824.08},
{3797, 4860.65, 2023.60},
{3798, 4310.05, 1811.11},
{3799, 4506.89, 4030.26};
};
local self = getfenv(1)
function Aura()
for k,l in pairs(GetPlayersInWorld())do
if(l:GetZoneId() ~= ZONE_WG and l:GetAreaId() ~= ZONE_WG)then
if(l:HasAura(SPELL_RECRUIT))then
l:RemoveAura(SPELL_RECRUIT)
end
if(l:HasAura(SPELL_CORPORAL))then
l:RemoveAura(SPELL_CORPORAL)
end
if(l:HasAura(SPELL_LIEUTENANT))then
l:RemoveAura(SPELL_LIEUTENANT)
end
if(l:HasAura(SPELL_TOWER_CONTROL))then
l:RemoveAura(SPELL_TOWER_CONTROL)
end
if(l:HasAura(SPELL_GREAT_HONOR))then
l:RemoveAura(SPELL_GREAT_HONOR)
end
if(l:HasAura(SPELL_GREATER_HONOR))then
l:RemoveAura(SPELL_GREATER_HONOR)
end
if(l:HasAura(SPELL_GREATEST_HONOR))then
l:RemoveAura(SPELL_GREATEST_HONOR)
end
if(l:HasAura(SPELL_VICTORY_AURA))then
l:RemoveAura(SPELL_VICTORY_AURA)
end
end
if(l:GetAreaId() == AREA_EASTSPARK)then
if(eastspark_progress > C_BAR_CAPTURE + C_BAR_NEUTRAL)then
if(l:HasAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT))then
l:RemoveAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT)
end
if(l:HasAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT) == false)then
l:CastSpell(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT)
end
elseif(eastspark_progress < C_BAR_CAPTURE + C_BAR_NEUTRAL and eastspark_progress > C_BAR_CAPTURE)then
if(l:HasAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT))then
l:RemoveAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT)
end
if(l:HasAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT))then
l:RemoveAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT)
end
elseif(eastspark_progress < C_BAR_CAPTURE)then
if(l:HasAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT) == false)then
l:CastSpell(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT)
end
if(l:HasAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT))then
l:RemoveAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT)
end
end
elseif(l:GetAreaId() == AREA_WESTSPARK)then
if(westspark_progress > C_BAR_CAPTURE + C_BAR_NEUTRAL)then
if(l:HasAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT))then
l:RemoveAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT)
end
if(l:HasAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT) == false)then
l:CastSpell(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT)
end
elseif(westspark_progress < C_BAR_CAPTURE + C_BAR_NEUTRAL and westspark_progress > C_BAR_CAPTURE)then
if(l:HasAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT))then
l:RemoveAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT)
end
if(l:HasAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT))then
l:RemoveAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT)
end
elseif(westspark_progress < C_BAR_CAPTURE)then
if(l:HasAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT) == false)then
l:CastSpell(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT)
end
if(l:HasAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT))then
l:RemoveAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT)
end
end
elseif(l:GetAreaId() == AREA_SUNKENRING)then
if(sunkenring_progress > C_BAR_CAPTURE + C_BAR_NEUTRAL)then
if(l:HasAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT))then
l:RemoveAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT)
end
if(l:HasAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT) == false)then
l:CastSpell(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT)
end
elseif(sunkenring_progress < C_BAR_CAPTURE + C_BAR_NEUTRAL and sunkenring_progress > C_BAR_CAPTURE)then
if(l:HasAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT))then
l:RemoveAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT)
end
if(l:HasAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT))then
l:RemoveAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT)
end
elseif(sunkenring_progress < C_BAR_CAPTURE)then
if(l:HasAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT) == false)then
l:CastSpell(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT)
end
if(l:HasAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT))then
l:RemoveAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT)
end
end
elseif(l:GetAreaId() == AREA_BROKENTEMPLE)then
if(brokentemple_progres > C_BAR_CAPTURE + C_BAR_NEUTRAL)then
if(l:HasAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT))then
l:RemoveAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT)
end
if(l:HasAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT) == false)then
l:CastSpell(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT)
end
elseif(brokentemple_progres < C_BAR_CAPTURE + C_BAR_NEUTRAL and brokentemple_progres > C_BAR_CAPTURE)then
if(l:HasAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT))then
l:RemoveAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT)
end
if(l:HasAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT))then
l:RemoveAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT)
end
elseif(brokentemple_progres < C_BAR_CAPTURE)then
if(l:HasAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT) == false)then
l:CastSpell(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT)
end
if(l:HasAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT))then
l:RemoveAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT)
end
end
else
if(l:HasAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT))then
l:RemoveAura(SPELL_ALLIANCE_CONTROLS_FACTORY_PHASE_SHIFT)
end
if(l:HasAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT))then
l:RemoveAura(SPELL_HORDE_CONTROLS_FACTORY_PHASE_SHIFT)
end
end
if(l:GetZoneId() == ZONE_WG and controll == 1 and l:GetTeam() == 1 and battle == 1)then
if(l:HasAura(SPELL_TOWER_CONTROL) == false and south_towers > 0)then
l:CastSpell(SPELL_TOWER_CONTROL)
elseif(l:HasAura(SPELL_TOWER_CONTROL) and south_towers > 0 and l:GetAuraStackCount(SPELL_TOWER_CONTROL) < south_towers)then
l:CastSpell(SPELL_TOWER_CONTROL)
elseif(l:HasAura(SPELL_TOWER_CONTROL) and south_towers < l:GetAuraStackCount(SPELL_TOWER_CONTROL))then
l:RemoveAura(SPELL_TOWER_CONTROL)
end
elseif(l:GetZoneId() == ZONE_WG and controll == 2 and l:GetTeam() == 0 and battle == 1)then
if(l:HasAura(SPELL_TOWER_CONTROL) == false and south_towers > 0)then
l:CastSpell(SPELL_TOWER_CONTROL)
elseif(l:HasAura(SPELL_TOWER_CONTROL) and south_towers > 0 and l:GetAuraStackCount(SPELL_TOWER_CONTROL) < south_towers)then
l:CastSpell(SPELL_TOWER_CONTROL)
elseif(l:HasAura(SPELL_TOWER_CONTROL) and south_towers < l:GetAuraStackCount(SPELL_TOWER_CONTROL))then
l:RemoveAura(SPELL_TOWER_CONTROL)
end
elseif(l:GetZoneId() == ZONE_WG and battle == 0)then
if(l:HasAura(SPELL_TOWER_CONTROL))then
l:RemoveAura(SPELL_TOWER_CONTROL)
end
end
end
end
function WGUpdate()
if(timer_nextbattle <= os.time() and timer_battle == 0)then
timer_battle = os.time() + BATTLE_TIMER
timer_nextbattle = 0
battle = 1
stateuiset = 0
states = 0
add_tokens = 0
starttimer = os.time()
if(controll == 1)then
eastspark_progress = 0
westspark_progress = 0
elseif(controll == 2)then
eastspark_progress = 100
westspark_progress = 100
end
for k,v in pairs(GetPlayersInZone(ZONE_WG))do
v:SendAreaTriggerMessage("Let the battle begin!")
local packetssound = LuaPacket:CreatePacket(SMSG_PLAY_SOUND, 4)
packetssound:WriteULong(3439)
v:SendPacketToPlayer(packetssound)
end
elseif(timer_nextbattle == 0 and timer_battle <= os.time())then
timer_battle = 0
timer_nextbattle = os.time() + TIME_TO_BATTLE
battle = 0
stateuiset = 0
states = 0
starttimer = 0
south_towers = 3
for k,v in pairs(GetPlayersInZone(ZONE_WG))do
local packetseound = LuaPacket:CreatePacket(SMSG_PLAY_SOUND, 4)
if(controll == 1)then
packetseound:WriteULong(8455)
v:SendPacketToPlayer(packetseound)
v:SendAreaTriggerMessage("The Alliance has successfully defended the Wintergrasp fortress!")
elseif(controll == 2)then
packetseound:WriteULong(8454)
v:SendPacketToPlayer(packetseound)
v:SendAreaTriggerMessage("The Horde has successfully defended the Wintergrasp fortress!")
end
end
elseif(timer_nextbattle == os.time() + jointimer_1)then
local p = LuaPacket:CreatePacket(SMSG_BATTLEFIELD_MGR_ENTRY_INVITE, 12)
p:WriteULong(1)
p:WriteULong(4197)
p:WriteULong(timer_nextbattle)
SendPacketToZone(p, ZONE_WG)
elseif(timer_nextbattle == os.time() + jointimer_2)then
local p = LuaPacket:CreatePacket(SMSG_BATTLEFIELD_MGR_QUEUE_INVITE, 5)
p:WriteULong(1)
p:WriteUByte(1)
SendPacketToZone(p, ZONE_WG)
end
for k,v in pairs(GetPlayersInMap(MAP_NORTHREND))do
if(v:GetZoneId() == ZONE_WG or v:GetAreaId() == ZONE_WG)then
if(south_towers == 0)then
timer_battle = timer_battle - 600 -- if all southen towers are destroyed, the attackers loose 10 min.
v:SetWorldStateForZone(WG_STATE_BATTLE_TIME, timer_battle)
south_towers = -1
end
if(v:IsPvPFlagged() ~= true)then
v:FlagPvP()
end
if(battle == 1)then
if(v:HasAura(SPELL_RECRUIT) == false)then
if(v:HasAura(SPELL_CORPORAL) == false)then
if(v:HasAura(SPELL_LIEUTENANT) == false)then
v:AddAura(SPELL_RECRUIT,0)
end
end
end
elseif(battle == 0)then
if(v:HasAura(SPELL_RECRUIT))then
v:RemoveAura(SPELL_RECRUIT)
end
if(v:HasAura(SPELL_CORPORAL))then
v:RemoveAura(SPELL_CORPORAL)
end
if(v:HasAura(SPELL_LIEUTENANT))then
v:RemoveAura(SPELL_LIEUTENANT)
end
end
if(controll == 1 and battle == 0 and add_tokens == 0)then
if(v:GetTeam() == 0)then
v:CastSpell(SPELL_VICTORY_REWARD)
v:CastSpell(SPELL_VICTORY_AURA)
if(v:HasQuest(QUEST_WG_VICTORY_A) and v:GetQuestObjectiveCompletion(QUEST_WG_VICTORY_A, 0) == 0)then
v:AdvanceQuestObjective(QUEST_WG_VICTORY_A, 0)
end
elseif(v:GetTeam() == 1)then
v:CastSpell(SPELL_DEFEAT_REWARD)
end
add_tokens = 1
end
if(controll == 2 and battle == 0 and add_tokens == 0)then
if(v:GetTeam() == 1)then
v:CastSpell(SPELL_VICTORY_REWARD)
v:CastSpell(SPELL_VICTORY_AURA)
if(v:HasQuest(QUEST_WG_VICTORY_H) and v:GetQuestObjectiveCompletion(QUEST_WG_VICTORY_H, 0) == 0)then
v:AdvanceQuestObjective(QUEST_WG_VICTORY_H, 0)
end
elseif(v:GetTeam() == 0)then
v:CastSpell(SPELL_DEFEAT_REWARD)
end
add_tokens = 1
end
if(v:GetAreaId() == AREA_FORTRESS or v:GetAreaId() == AREA_FLAMEWATCH_T or v:GetAreaId() == AREA_WINTERSEDGE_T or v:GetAreaId() == AREA_SHADOWSIGHT_T or v:GetAreaId() == AREA_C_BRIDGE or v:GetAreaId() == AREA_W_BRIDGE or v:GetAreaId() == AREA_E_BRIDGE or v:GetAreaId() == ZONE_WG)then
if(controll == 1)then
if(v:HasAura(SPELL_HORDE_CONTROL_PHASE_SHIFT))then
v:RemoveAura(SPELL_HORDE_CONTROL_PHASE_SHIFT)
end
v:CastSpell(SPELL_ALLIANCE_CONTROL_PHASE_SHIFT)
elseif(controll == 2)then
if(v:HasAura(SPELL_ALLIANCE_CONTROL_PHASE_SHIFT))then
v:RemoveAura(SPELL_ALLIANCE_CONTROL_PHASE_SHIFT)
end
v:CastSpell(SPELL_HORDE_CONTROL_PHASE_SHIFT)
end
elseif(v:GetAreaId() ~= AREA_FORTRESS and v:GetAreaId() ~= AREA_FLAMEWATCH_T and v:GetAreaId() ~= AREA_WINTERSEDGE_T and v:GetAreaId() ~= AREA_SHADOWSIGHT_T and v:GetAreaId() ~= AREA_C_BRIDGE and v:GetAreaId() ~= AREA_W_BRIDGE and v:GetAreaId() ~= AREA_E_BRIDGE and v:GetAreaId() ~= ZONE_WG)then
if(v:HasAura(SPELL_HORDE_CONTROL_PHASE_SHIFT))then
v:RemoveAura(SPELL_HORDE_CONTROL_PHASE_SHIFT)
end
if(v:HasAura(SPELL_ALLIANCE_CONTROL_PHASE_SHIFT))then
v:RemoveAura(SPELL_ALLIANCE_CONTROL_PHASE_SHIFT)
end
end
if(stateuiset == 0)then
if(battle == 1)then
v:SetWorldStateForZone(WG_HORDE_CONTROLLED, 0)
v:SetWorldStateForZone(WG_ALLIANCE_CONTROLLED, 0)
v:SetWorldStateForZone(WG_STATE_BATTLE_UI, 1)
v:SetWorldStateForZone(WG_STATE_BATTLE_TIME, timer_battle)
v:SetWorldStateForZone(WG_STATE_NEXT_BATTLE_TIMER, 0)
v:SetWorldStateForZone(WG_STATE_NEXT_BATTLE_TIME, 0)
v:SetWorldStateForZone(WG_STATE_BATTLEFIELD_STATUS_MAP, 3)
v:SetWorldStateForZone(WG_STATE_MAX_A_VEHICLES, vehicle_vallue_a)
v:SetWorldStateForZone(WG_STATE_MAX_H_VEHICLES, vehicle_vallue_h)
stateuiset = 1
elseif(battle == 0 and controll == 1)then
v:SetWorldStateForZone(WG_STATE_NEXT_BATTLE_TIMER, 1)
v:SetWorldStateForZone(WG_ALLIANCE_CONTROLLED, 1)
v:SetWorldStateForZone(WG_STATE_BATTLE_UI, 0)
v:SetWorldStateForZone(WG_STATE_BATTLE_TIME, 0)
v:SetWorldStateForZone(WG_STATE_NEXT_BATTLE_TIME, timer_nextbattle)
v:SetWorldStateForZone(WG_STATE_BATTLEFIELD_STATUS_MAP, 2)
stateuiset = 1
elseif(battle == 0 and controll == 2)then
v:SetWorldStateForZone(WG_STATE_NEXT_BATTLE_TIMER, 1)
v:SetWorldStateForZone(WG_HORDE_CONTROLLED, 1)
v:SetWorldStateForZone(WG_STATE_BATTLE_UI, 0)
v:SetWorldStateForZone(WG_STATE_BATTLE_TIME, 0)
v:SetWorldStateForZone(WG_STATE_NEXT_BATTLE_TIME, timer_nextbattle)
v:SetWorldStateForZone(WG_STATE_BATTLEFIELD_STATUS_MAP, 1)
stateuiset = 1
end
end
if(controll == 1)then
if(states == 0)then
v:SetWorldStateForZone(3698, 7)
v:SetWorldStateForZone(3699, 7)
v:SetWorldStateForZone(3704, 4)
v:SetWorldStateForZone(3705, 4)
v:SetWorldStateForZone(3706, 4)
v:SetWorldStateForZone(3711, 7)
v:SetWorldStateForZone(3712, 7)
v:SetWorldStateForZone(3713, 7)
v:SetWorldStateForZone(3714, 7)
v:SetWorldStateForZone(3749, 7)
v:SetWorldStateForZone(3750, 7)
v:SetWorldStateForZone(3751, 7)
v:SetWorldStateForZone(3752, 7)
v:SetWorldStateForZone(3753, 7)
v:SetWorldStateForZone(3754, 7)
v:SetWorldStateForZone(3755, 7)
v:SetWorldStateForZone(3756, 7)
v:SetWorldStateForZone(3757, 7)
v:SetWorldStateForZone(3758, 7)
v:SetWorldStateForZone(3759, 7)
v:SetWorldStateForZone(3760, 7)
v:SetWorldStateForZone(3761, 7)
v:SetWorldStateForZone(3762, 7)
v:SetWorldStateForZone(3764, 7)
v:SetWorldStateForZone(3765, 7)
v:SetWorldStateForZone(3766, 7)
v:SetWorldStateForZone(3767, 7)
v:SetWorldStateForZone(3768, 7)
v:SetWorldStateForZone(3769, 7)
v:SetWorldStateForZone(3770, 7)
v:SetWorldStateForZone(3771, 7)
v:SetWorldStateForZone(3772, 7)
v:SetWorldStateForZone(3763, 7)
v:SetWorldStateForZone(WG_STATE_KEEP_GATE_ANDGY, 7)
v:SetWorldStateForZone(3702, 4)
v:SetWorldStateForZone(3703, 4)
v:SetWorldStateForZone(3700, 4)
v:SetWorldStateForZone(3701, 4)
eastspark_progress = 0
westspark_progress = 0
sunkenring_progress = 0
brokentemple_progres = 0
states = 1
ATTACKER = "Horde"
DEFENDER = "Alliance"
end
elseif(controll == 2)then
if(states == 0)then
v:SetWorldStateForZone(3698, 4)
v:SetWorldStateForZone(3699, 4)
v:SetWorldStateForZone(3704, 7)
v:SetWorldStateForZone(3705, 7)
v:SetWorldStateForZone(3706, 7)
v:SetWorldStateForZone(3711, 4)
v:SetWorldStateForZone(3712, 4)
v:SetWorldStateForZone(3713, 4)
v:SetWorldStateForZone(3714, 4)
v:SetWorldStateForZone(3749, 4)
v:SetWorldStateForZone(3750, 4)
v:SetWorldStateForZone(3751, 4)
v:SetWorldStateForZone(3752, 4)
v:SetWorldStateForZone(3753, 4)
v:SetWorldStateForZone(3754, 4)
v:SetWorldStateForZone(3755, 4)
v:SetWorldStateForZone(3756, 4)
v:SetWorldStateForZone(3757, 4)
v:SetWorldStateForZone(3758, 4)
v:SetWorldStateForZone(3759, 4)
v:SetWorldStateForZone(3760, 4)
v:SetWorldStateForZone(3761, 4)
v:SetWorldStateForZone(3762, 4)
v:SetWorldStateForZone(3764, 4)
v:SetWorldStateForZone(3765, 4)
v:SetWorldStateForZone(3766, 4)
v:SetWorldStateForZone(3767, 4)
v:SetWorldStateForZone(3768, 4)
v:SetWorldStateForZone(3769, 4)
v:SetWorldStateForZone(3770, 4)
v:SetWorldStateForZone(3771, 4)
v:SetWorldStateForZone(3772, 4)
v:SetWorldStateForZone(3763, 4)
v:SetWorldStateForZone(WG_STATE_KEEP_GATE_ANDGY, 4)
v:SetWorldStateForZone(3702, 7)
v:SetWorldStateForZone(3703, 7)
v:SetWorldStateForZone(3700, 7)
v:SetWorldStateForZone(3701, 7)
eastspark_progress = 100
westspark_progress = 100
sunkenring_progress = 100
brokentemple_progres = 100
states = 1
ATTACKER = "Alliance"
DEFENDER = "Horde"
end
end
end
end
end
function DetectionUnitOnSpawn(pUnit, event)
if(pUnit:GetMapId() == MAP_NORTHREND)then
pUnit:RegisterAIUpdateEvent(1000)
end
end
function DetectionUnitAIUpdate(pUnit)
if(pUnit == nil)then
pUnit:RemoveAIUpdateEvent()
end
if(pUnit:GetWorldStateForZone(WG_STATE_KEEP_GATE_ANDGY) == 0 or pUnit:GetWorldStateForZone(WG_STATE_KEEP_GATE_ANDGY) == 1)then
if(npcstarted == false)then
stateuiset = 0
states = 0
npcstarted = true
end
else
npcstarted = true
end
for k,m in pairs(GetPlayersInZone(ZONE_WG))do
if(m:HasAura(SPELL_VICTORY_AURA))then
if(m:HasAchievement(ACHIEVEMENT_VICTORY) == false)then
m:AddAchievement(ACHIEVEMENT_VICTORY)
end
m:RemoveAura(SPELL_VICTORY_AURA)
end
end
if(spawnobjects == 0 and battle == 1)then
PerformIngameSpawn(2,GO_WINTERGRASP_TITAN_RELIC,MAP_NORTHREND,5439.66,2840.83,430.282,6.20393,100,2300000)
PerformIngameSpawn(2,GO_WINTERGRASP_KEEP_COLLISION_WALL,MAP_NORTHREND,5397.11,2841.54,425.901,3.14159,100,2300000)
spawnobjects = 1
end
if(battle == 0 and spawnobjects == 1)then
spawnobjects = 0
local relick = pUnit:GetGameObjectNearestCoords(5439.66,2840.83,430.282,GO_WINTERGRASP_TITAN_RELIC)
local collision = pUnit:GetGameObjectNearestCoords(5397.11,2841.54,425.901,GO_WINTERGRASP_KEEP_COLLISION_WALL)
if(relick ~= nil)then
relick:Despawn(1,0)
end
if(collision ~= nil)then
collision:Despawn(1,0)
end
end
for k,v in pairs(pUnit:GetInRangeObjects())do
if(v:GetHP() ~= nil)then -- filter all non destructable objects.
if(battle == 0 and v:GetHP() < v:GetMaxHP())then -- rebuild all if there is no battle and anything is damaged.
v:Rebuild()
end
if(v:GetUInt32Value(GAMEOBJECT_FACTION) ~= FACTION_HORDE and battle == 1 and controll == 2 and v:GetAreaId() == AREA_FORTRESS)then -- this changes the faction of the objects but for some reason they can not be damaged as they should by the vehicles.
v:SetUInt32Value(GAMEOBJECT_FACTION,FACTION_HORDE)
elseif(battle == 1 and v:GetUInt32Value(GAMEOBJECT_FACTION) ~= FACTION_NEUTRAL)then
v:SetUInt32Value(GAMEOBJECT_FACTION,FACTION_NEUTRAL)
elseif(v:GetUInt32Value(GAMEOBJECT_FACTION) ~= FACTION_ALLIANCE and battle == 1 and controll == 1 and v:GetAreaId() == AREA_FORTRESS)then
v:SetUInt32Value(GAMEOBJECT_FACTION,FACTION_ALLIANCE)
elseif((v:GetAreaId() == AREA_FLAMEWATCH_T or v:GetAreaId() == AREA_WINTERSEDGE_T or v:GetAreaId() == AREA_SHADOWSIGHT_T))then
if(battle == 1 and controll == 2 and v:GetUInt32Value(GAMEOBJECT_FACTION) ~= FACTION_ALLIANCE)then
v:SetUInt32Value(GAMEOBJECT_FACTION,FACTION_ALLIANCE)
elseif(battle == 1 and controll == 1 and v:GetUInt32Value(GAMEOBJECT_FACTION) ~= FACTION_HORDE)then
v:SetUInt32Value(GAMEOBJECT_FACTION,FACTION_HORDE)
elseif(battle == 0 and v:GetUInt32Value(GAMEOBJECT_FACTION) ~= FACTION_NEUTRAL)then
v:SetUInt32Value(GAMEOBJECT_FACTION,FACTION_NEUTRAL)
end
end
end
end
end
function TitanRelickOnUse(pGO, event, pPlayer)
if(battle == 1)then
local timebattle = os.time() - starttimer
if(controll == 1 and pPlayer:GetTeam() == 1 and pGO:GetWorldStateForZone(WG_STATE_KEEP_GATE_ANDGY) == 9)then
timer_battle = 0
timer_nextbattle = os.time() + TIME_TO_BATTLE
battle = 0
controll = 2
states = 0
pGO:Despawn(1,0)
stateuiset = 0
starttimer = 0
south_towers = 3
for k,v in pairs (GetPlayersInZone(ZONE_WG))do
v:SendAreaTriggerMessage("The Wintergrasp fortress has been captured by the Horde!")
local packetseound = LuaPacket:CreatePacket(SMSG_PLAY_SOUND, 4)
packetseound:WriteULong(8454)
v:SendPacketToPlayer(packetseound)
if(v:GetTeam() == 1)then
v:CastSpell(SPELL_VICTORY_REWARD)
v:CastSpell(SPELL_VICTORY_AURA)
if(timebattle <= 600)then
if(v:HasAchievement(ACHIEVEMENT_WIN_OUR_GRASP) == false)then
v:AddAchievement(ACHIEVEMENT_WIN_OUR_GRASP)
end
end
if(v:HasQuest(QUEST_WG_VICTORY_H) and v:GetQuestObjectiveCompletion(QUEST_WG_VICTORY_H, 0) == 0)then
v:AdvanceQuestObjective(QUEST_WG_VICTORY_H, 0)
end
elseif(v:GetTeam() == 0)then
v:CastSpell(SPELL_DEFEAT_REWARD)
end
end
end
if(controll == 2 and pPlayer:GetTeam() == 0 and pGO:GetWorldStateForZone(WG_STATE_KEEP_GATE_ANDGY) == 6)then
timer_battle = 0
timer_nextbattle = os.time() + TIME_TO_BATTLE
battle = 0
controll = 1
states = 0
pGO:Despawn(1,0)
stateuiset = 0
starttimer = 0
south_towers = 3
for k,v in pairs (GetPlayersInZone(ZONE_WG))do
v:SendAreaTriggerMessage("The Wintergrasp fortress has been captured by the Alliance!")
local packetseound = LuaPacket:CreatePacket(SMSG_PLAY_SOUND, 4)
packetseound:WriteULong(8455)
v:SendPacketToPlayer(packetseound)
if(v:GetTeam() == 0)then
v:CastSpell(SPELL_VICTORY_REWARD)
v:CastSpell(SPELL_VICTORY_AURA)
if(timebattle <= 600)then
if(v:HasAchievement(ACHIEVEMENT_WIN_OUR_GRASP) == false)then
v:AddAchievement(ACHIEVEMENT_WIN_OUR_GRASP)
end
end
if(v:HasQuest(QUEST_WG_VICTORY_A) and v:GetQuestObjectiveCompletion(QUEST_WG_VICTORY_A, 0) == 0)then
v:AdvanceQuestObjective(QUEST_WG_VICTORY_A, 0)
end
elseif(v:GetTeam() == 1)then
v:CastSpell(SPELL_DEFEAT_REWARD)
end
end
end
end
end
function DebugWG(event, pPlayer, message, type, language)
if(pPlayer:IsGm() and pPlayer:GetZoneId() == ZONE_WG and battle == 0)then
if(message == "#debug WG")then
timer_nextbattle = os.time() + 10
for k,v in pairs(GetPlayersInWorld())do
v:SendBroadcastMessage("Wintergrasp battle starts after 10 sec. Battlefield started by GM "..pPlayer:GetName()..".|r")
end
local p = LuaPacket:CreatePacket(SMSG_BATTLEFIELD_MGR_QUEUE_INVITE, 5)
p:WriteULong(1)
p:WriteUByte(1)
SendPacketToZone(p, ZONE_WG)
pPlayer:SetWorldStateForZone(WG_STATE_NEXT_BATTLE_TIME, timer_nextbattle)
end
end
end
function PortalOnUse(pGO, event, pPlayer)
if(pGO:GetMapId() == MAP_NORTHREND)then
if(pPlayer:HasAura(SPELL_TELEPORT_DEFENDER) == false)then
local teleportunit = pGO:GetCreatureNearestCoords(pGO:GetX(),pGO:GetY(),pGO:GetZ(),NPC_NOT_IMMUNE_PC_NPC)
if(teleportunit ~= nil)then
local xu,yu,zu,ou = teleportunit:GetSpawnLocation()
pPlayer:Teleport(MAP_NORTHREND,xu,yu,zu,ou)
pPlayer:CastSpell(SPELL_TELEPORT_DEFENDER)
end
else
pPlayer:SendAreaTriggerMessage("You can't do that yet!")
end
else
pPlayer:CastSpell(54640)
end
end
function OnLoadVehicleTeleporter(pGO)
pGO:RegisterAIUpdateEvent(1000)
end
function OnAIUpdateVehicleTeleporter(pGO)
if(pGO == nil)then
pGO:RemoveAIUpdateEvent()
end
for k,v in pairs(pGO:GetInRangeUnits()) do
if(v:IsCreature())then
if(pGO:GetDistance(v) < 10 and battle == 1)then
if((v:GetFaction() == FACTION_ALLIANCE and controll == 1) or (v:GetFaction() == FACTION_HORDE and controll == 2))then
if(v:HasAura(SPELL_TELEPORT_VEHICLE) == false)then
if(v:GetEntry() == NPC_VEHICLE_CATAPULT or v:GetEntry() == NPC_VEHICLE_DEMOLISHER or v:GetEntry() == NPC_VEHICLE_SIEGE_ENGINE_H or v:GetEntry() == NPC_VEHICLE_SIEGE_ENGINE_A)then
local teleportunit = pGO:GetCreatureNearestCoords(pGO:GetX(),pGO:GetY(),pGO:GetZ(),NPC_NOT_IMMUNE_PC_NPC)
if(teleportunit ~= nil)then
local xu,yu,zu = teleportunit:GetSpawnLocation()
v:TeleportCreature(xu,yu,zu)
v:CastSpell(SPELL_TELEPORT_VEHICLE)
end
end
end
end
end
end
end
end
function OnSP_Cpoint(pGO)
self[tostring(pGO)] = {
data = 0,
health = 0,
state = 0,
plrvall = 0
}
pGO:RegisterAIUpdateEvent(300)
end
function AIUpdate_Cpoint(pGO)
if(pGO == nil)then
pGO:RemoveAIUpdateEvent()
end
local vars = self[tostring(pGO)]
for k,m in pairs (pGO:GetInRangePlayers())do
if(m:IsPvPFlagged() and m:IsStealthed() == false and m:IsAlive() and battle == 1)then
if(pGO:GetDistance(m) <= 5500)then
if(m:GetTeam() == 0)then
vars.plrvall = vars.plrvall + 1
elseif(m:GetTeam() == 1)then
vars.plrvall = vars.plrvall - 1
end
m:SetWorldStateForPlayer(WG_STATE_SOUTH_SHOW,1)
for i = 1, #workshop_data do
if(pGO:GetEntry() == workshop_data[i][5])then
m:SetWorldStateForPlayer(WG_STATE_SOUTH_PROGRESS,workshop_data[i][3])
end
end
m:SetWorldStateForPlayer(WG_STATE_SOUTH_NEUTRAL,80)
else
m:SetWorldStateForPlayer(WG_STATE_SOUTH_SHOW,0)
m:SetWorldStateForPlayer(WG_STATE_SOUTH_PROGRESS,0)
m:SetWorldStateForPlayer(WG_STATE_SOUTH_NEUTRAL,0)
end
end
end
for i = 1, #workshop_data do
if(pGO:GetEntry() == workshop_data[i][5] and pGO:GetWorldStateForZone(workshop_data[i][2])~=3 and pGO:GetWorldStateForZone(workshop_data[i][2])~=6 and pGO:GetWorldStateForZone(workshop_data[i][2])~=9)then
if(workshop_data[i][3] <= 100.9 and workshop_data[i][3] >= -0.9)then
workshop_data[i][3] = workshop_data[i][3] + (vars.plrvall/10)
elseif(workshop_data[i][3] > 100)then
workshop_data[i][3] = 100
elseif(workshop_data[i][3] < 0)then
workshop_data[i][3] = 0
end
if(workshop_data[i][5] == pGO:GetEntry())then
if(workshop_data[i][3] >= 90 and workshop_data[i][6] == 2 and pGO:GetWorldStateForZone(workshop_data[i][2])==1)then
pGO:SetWorldStateForZone(workshop_data[i][2],7)
vehicle_vallue_a = vehicle_vallue_a + 4
pGO:SetWorldStateForZone(WG_STATE_MAX_A_VEHICLES,vehicle_vallue_a)
elseif(workshop_data[i][3] < 90 and workshop_data[i][3] > 10 and workshop_data[i][6] == 2 and pGO:GetWorldStateForZone(workshop_data[i][2])==7)then
pGO:SetWorldStateForZone(workshop_data[i][2],1)
vehicle_vallue_a = vehicle_vallue_a - 4
pGO:SetWorldStateForZone(WG_STATE_MAX_A_VEHICLES,vehicle_vallue_a)
elseif(workshop_data[i][3] < 90 and workshop_data[i][3] > 10 and workshop_data[i][6] == 2 and pGO:GetWorldStateForZone(workshop_data[i][2])==4)then
pGO:SetWorldStateForZone(workshop_data[i][2],1)
vehicle_vallue_h = vehicle_vallue_h - 4
pGO:SetWorldStateForZone(WG_STATE_MAX_H_VEHICLES,vehicle_vallue_h)
elseif(workshop_data[i][3] <= 10 and workshop_data[i][6] == 2 and pGO:GetWorldStateForZone(workshop_data[i][2])==1)then
pGO:SetWorldStateForZone(workshop_data[i][2],4)
vehicle_vallue_h = vehicle_vallue_h + 4
pGO:SetWorldStateForZone(WG_STATE_MAX_H_VEHICLES,vehicle_vallue_h)
elseif(workshop_data[i][3] >= 90 and workshop_data[i][6] == 1 and pGO:GetWorldStateForZone(workshop_data[i][2])==2)then
pGO:SetWorldStateForZone(workshop_data[i][2],8)
vehicle_vallue_a = vehicle_vallue_a + 2
pGO:SetWorldStateForZone(WG_STATE_MAX_A_VEHICLES,vehicle_vallue_a)
elseif(workshop_data[i][3] < 90 and workshop_data[i][3] > 10 and workshop_data[i][6] == 1 and pGO:GetWorldStateForZone(workshop_data[i][2])==8)then
pGO:SetWorldStateForZone(workshop_data[i][2],2)
vehicle_vallue_a = vehicle_vallue_a - 2
pGO:SetWorldStateForZone(WG_STATE_MAX_A_VEHICLES,vehicle_vallue_a)
elseif(workshop_data[i][3] < 90 and workshop_data[i][3] > 10 and workshop_data[i][6] == 1 and pGO:GetWorldStateForZone(workshop_data[i][2])==5)then
pGO:SetWorldStateForZone(workshop_data[i][2],2)
vehicle_vallue_h = vehicle_vallue_h - 2
pGO:SetWorldStateForZone(WG_STATE_MAX_H_VEHICLES,vehicle_vallue_h)
elseif(workshop_data[i][3] <= 10 and workshop_data[i][6] == 1 and pGO:GetWorldStateForZone(workshop_data[i][2])==2)then
pGO:SetWorldStateForZone(workshop_data[i][2],5)
vehicle_vallue_h = vehicle_vallue_h + 2
pGO:SetWorldStateForZone(WG_STATE_MAX_H_VEHICLES,vehicle_vallue_h)
end
end
end
end
vars.plrvall = 0
end
function KillCreature(pUnit, event, pLastTarget)
if(battle == 1)then
for k,v in pairs(pUnit:GetInRangePlayers())do
if(v:IsPlayer())then
if(v:HasAura(SPELL_RECRUIT))then
if(v:GetAuraStackCount(SPELL_RECRUIT) < 5)then
v:CastSpell(SPELL_RECRUIT)
else
pUnit:SendChatMessageToPlayer(42, 0, "You have reached Rank 1: Corporal", v)
v:RemoveAura(SPELL_RECRUIT)
v:RemoveAura(SPELL_RECRUIT)
v:RemoveAura(SPELL_RECRUIT)
v:RemoveAura(SPELL_RECRUIT)
v:RemoveAura(SPELL_RECRUIT)
v:RemoveAura(SPELL_RECRUIT)
v:CastSpell(SPELL_CORPORAL)
end
elseif(v:HasAura(SPELL_CORPORAL))then
if(v:GetAuraStackCount(SPELL_CORPORAL) < 5)then
v:CastSpell(SPELL_CORPORAL)
else
pUnit:SendChatMessageToPlayer(42, 0, "You have reached Rank 2: Lieutenant", v)
v:RemoveAura(SPELL_CORPORAL)
v:RemoveAura(SPELL_CORPORAL)
v:RemoveAura(SPELL_CORPORAL)
v:RemoveAura(SPELL_CORPORAL)
v:RemoveAura(SPELL_CORPORAL)
v:RemoveAura(SPELL_CORPORAL)
v:AddAura(SPELL_LIEUTENANT,0)
end
end
end
end
end
end
function KillPlayer(event, pKiller, pVictim)
if(battle == 1)then
for k,v in pairs(pVictim:GetInRangePlayers())do
if(pVictim:GetTeam() ~= v:GetTeam())then
if(v:HasAura(SPELL_RECRUIT))then
if(v:GetAuraStackCount(SPELL_RECRUIT) < 5)then
v:CastSpell(SPELL_RECRUIT)
else
v:SendAreaTriggerMessage("You have reached Rank 1: Corporal")
v:RemoveAura(SPELL_RECRUIT)
v:RemoveAura(SPELL_RECRUIT)
v:RemoveAura(SPELL_RECRUIT)
v:RemoveAura(SPELL_RECRUIT)
v:RemoveAura(SPELL_RECRUIT)
v:RemoveAura(SPELL_RECRUIT)
v:CastSpell(SPELL_CORPORAL)
end
elseif(v:HasAura(SPELL_CORPORAL))then
if(v:GetAuraStackCount(SPELL_CORPORAL) < 5)then
v:CastSpell(SPELL_CORPORAL)
else
v:SendAreaTriggerMessage("You have reached Rank 2: Lieutenant")
v:RemoveAura(SPELL_CORPORAL)
v:RemoveAura(SPELL_CORPORAL)
v:RemoveAura(SPELL_CORPORAL)
v:RemoveAura(SPELL_CORPORAL)
v:RemoveAura(SPELL_CORPORAL)
v:RemoveAura(SPELL_CORPORAL)
v:AddAura(SPELL_LIEUTENANT,0)
end
end
end
end
end
end
function AGengineerOnGossip(pUnit, event, pPlayer)
if(pUnit:GetWorldStateForZone(WG_STATE_MAX_A_VEHICLES) > pUnit:GetWorldStateForZone(WG_STATE_CURRENT_A_VEHICLES))then
if(pPlayer:HasAura(SPELL_CORPORAL) or pPlayer:HasAura(SPELL_LIEUTENANT) and battle == 1)then
if(pPlayer:HasAura(SPELL_CORPORAL))then
pUnit:GossipCreateMenu(13798, pPlayer, 0)
pUnit:GossipMenuAddItem(0, "I'd like to build a catapult.", 1, 0)
pUnit:GossipSendMenu(pPlayer)
elseif(pPlayer:HasAura(SPELL_LIEUTENANT))then
pUnit:GossipCreateMenu(13798, pPlayer, 0)
pUnit:GossipMenuAddItem(0, "I'd like to build a catapult.", 1, 0)
pUnit:GossipMenuAddItem(0, "I'd like to build a demolisher.", 2, 0)
pUnit:GossipMenuAddItem(0, "I'd like to build a siege engine.", 3, 0)
pUnit:GossipSendMenu(pPlayer)
else
pUnit:GossipCreateMenu(14172, pPlayer, 0)
pUnit:GossipSendMenu(pPlayer)
end
end
else
pUnit:GossipCreateMenu(14172, pPlayer, 0)
pUnit:GossipSendMenu(pPlayer)
end
end
function AOnSelect(pUnit, event, pPlayer, id, intid, code)
if(pUnit:GetWorldStateForZone(WG_STATE_MAX_A_VEHICLES) > pUnit:GetWorldStateForZone(WG_STATE_CURRENT_A_VEHICLES))then
local arms = pPlayer:GetCreatureNearestCoords(pPlayer:GetX(),pPlayer:GetY(),pPlayer:GetZ(),NPC_NOT_IMMUNE_PC_NPC)
if(intid == 1)then
if(arms ~= nil)then
arms:SpawnCreature(NPC_VEHICLE_CATAPULT, arms:GetX(), arms:GetY(),arms:GetZ(), arms:GetO(), FACTION_ALLIANCE, 3300000, 35, 0, 0, 241, 0)
end
-- pPlayer:FullCastSpell(SPELL_BUILD_CATAPULT)
pPlayer:GossipComplete()
elseif(intid == 2)then
if(arms ~= nil)then
arms:SpawnCreature(NPC_VEHICLE_DEMOLISHER, arms:GetX(), arms:GetY(),arms:GetZ(), arms:GetO(), FACTION_ALLIANCE, 3300000, 35, 0, 0, 241, 0)
end
-- pPlayer:FullCastSpell(SPELL_BUILD_DEMOLISHER)
pPlayer:GossipComplete()
elseif(intid == 3)then
if(arms ~= nil)then
arms:SpawnCreature(NPC_VEHICLE_SIEGE_ENGINE_A, arms:GetX(), arms:GetY(),arms:GetZ(), arms:GetO(), FACTION_ALLIANCE, 3300000, 35, 0, 0, 241, 0)
end
-- pPlayer:FullCastSpell(SPELL_BUILD_ENGINE_A)
pPlayer:GossipComplete()
end
end
end
function HGengineerOnGossip(pUnit, event, pPlayer)
if(pUnit:GetWorldStateForZone(WG_STATE_MAX_H_VEHICLES) > pUnit:GetWorldStateForZone(WG_STATE_CURRENT_H_VEHICLES))then
if(pPlayer:HasAura(SPELL_CORPORAL) or pPlayer:HasAura(SPELL_LIEUTENANT) and battle == 1)then
if(pPlayer:HasAura(SPELL_CORPORAL))then
pUnit:GossipCreateMenu(13798, pPlayer, 0)
pUnit:GossipMenuAddItem(0, "I'd like to build a catapult.", 1, 0)
pUnit:GossipSendMenu(pPlayer)
elseif(pPlayer:HasAura(SPELL_LIEUTENANT))then
pUnit:GossipCreateMenu(13798, pPlayer, 0)
pUnit:GossipMenuAddItem(0, "I'd like to build a catapult.", 1, 0)
pUnit:GossipMenuAddItem(0, "I'd like to build a demolisher.", 2, 0)
pUnit:GossipMenuAddItem(0, "I'd like to build a siege engine.", 3, 0)
pUnit:GossipSendMenu(pPlayer)
else
pUnit:GossipCreateMenu(14172, pPlayer, 0)
pUnit:GossipSendMenu(pPlayer)
end
end
else
pUnit:GossipCreateMenu(14172, pPlayer, 0)
pUnit:GossipSendMenu(pPlayer)
end
end
function HOnSelect(pUnit, event, pPlayer, id, intid, code)
if(pUnit:GetWorldStateForZone(WG_STATE_MAX_H_VEHICLES) > pUnit:GetWorldStateForZone(WG_STATE_CURRENT_H_VEHICLES))then
if(intid == 1)then
if(arms ~= nil)then
arms:SpawnCreature(NPC_VEHICLE_CATAPULT, arms:GetX(), arms:GetY(),arms:GetZ(), arms:GetO(), FACTION_HORDE, 3300000, 35, 0, 0, 241, 0)
end
-- pPlayer:FullCastSpell(SPELL_BUILD_CATAPULT)
pPlayer:GossipComplete()
elseif(intid == 2)then
if(arms ~= nil)then
arms:SpawnCreature(NPC_VEHICLE_DEMOLISHER, arms:GetX(), arms:GetY(),arms:GetZ(), arms:GetO(), FACTION_HORDE, 3300000, 35, 0, 0, 241, 0)
end
-- pPlayer:FullCastSpell(SPELL_BUILD_DEMOLISHER)
pPlayer:GossipComplete()
elseif(intid == 3)then
if(arms ~= nil)then
arms:SpawnCreature(NPC_VEHICLE_SIEGE_ENGINE_H, arms:GetX(), arms:GetY(),arms:GetZ(), arms:GetO(), FACTION_HORDE, 3300000, 35, 0, 0, 241, 0)
end
-- pPlayer:FullCastSpell(SPELL_BUILD_ENGINE_H)
pPlayer:GossipComplete()
end
end
end
function OnZoneEnter(event, pPlayer, ZoneId, OldZoneId)
if(ZoneId == ZONE_WG)then
if(battle == 0)then
if(timer_nextbattle <= os.time() + jointimer_1 and timer_nextbattle >= os.time() + jointimer_2)then
local p = LuaPacket:CreatePacket(SMSG_BATTLEFIELD_MGR_ENTRY_INVITE, 12)
p:WriteULong(1)
p:WriteULong(4197)
p:WriteULong(timer_nextbattle)
pPlayer:SendPacketToPlayer(p)
elseif(timer_nextbattle <= os.time() + jointimer_2)then
local p = LuaPacket:CreatePacket(SMSG_BATTLEFIELD_MGR_QUEUE_INVITE, 5)
p:WriteULong(1)
p:WriteUByte(1)
pPlayer:SendPacketToPlayer(p)
end
elseif(battle == 1)then
end
end
function zonecheck(buff_areas, ZoneId)
for key, value in pairs(buff_areas) do
if(value == ZoneId)then
if not(pPlayer:HasAura(SPELL_ESSENCE_OF_WINTERGRASP))then
if(controll == pPlayer:GetTeam()+1)then
pPlayer:AddAura(SPELL_ESSENCE_OF_WINTERGRASP,0)
end
end
return true end
end
if(pPlayer:HasAura(SPELL_ESSENCE_OF_WINTERGRASP))then
pPlayer:RemoveAura(SPELL_ESSENCE_OF_WINTERGRASP)
end
return false
end
print(zonecheck(buff_areas, ZoneId))
end
function OnEnterBuff(event, pPlayer)
local ZoneId = pPlayer:GetZoneId()
function zonecheck(buff_areas, ZoneId)
for key, value in pairs(buff_areas) do
if(value == ZoneId)then
if not(pPlayer:HasAura(SPELL_ESSENCE_OF_WINTERGRASP))then
if(controll == pPlayer:GetTeam()+1)then
pPlayer:AddAura(SPELL_ESSENCE_OF_WINTERGRASP,0)
end
end
return true end
end
if(pPlayer:HasAura(SPELL_ESSENCE_OF_WINTERGRASP))then
pPlayer:RemoveAura(SPELL_ESSENCE_OF_WINTERGRASP)
end
return false
end
print(zonecheck(buff_areas, ZoneId))
end
function WallOnDamage(pGO, damage)
for i = 1, #go_wall do
if(pGO:GetEntry() == go_wall[i][1])then
if(pGO:GetHP() < pGO:GetMaxHP()/2 and (pGO:GetWorldStateForZone(go_wall[i][2])== 1 or pGO:GetWorldStateForZone(go_wall[i][2])== 4 or pGO:GetWorldStateForZone(go_wall[i][2])== 7))then
pGO:SetWorldStateForZone(go_wall[i][2],pGO:GetWorldStateForZone(go_wall[i][2])+1)
end
end
end
end
function WallOnDestroy(pGO)
for i = 1, #go_wall do
if(pGO:GetEntry() == go_wall[i][1])then
if(pGO:GetWorldStateForZone(go_wall[i][2])== 2 or pGO:GetWorldStateForZone(go_wall[i][2])== 5 or pGO:GetWorldStateForZone(go_wall[i][2])== 8)then
pGO:SetWorldStateForZone(go_wall[i][2],pGO:GetWorldStateForZone(go_wall[i][2])+1)
end
if(pGO:GetEntry() == 191810)then
local wall = pGO:GetGameObjectNearestCoords(pGO:GetX(),pGO:GetY(),pGO:GetZ(),GO_WINTERGRASP_KEEP_COLLISION_WALL)
if(wall)then
wall:Despawn(1,0)
end
end
end
end
end
function FTOnDamage(pGO, damage)
for i = 1, #go_f_tower do
if(pGO:GetEntry() == go_f_tower[i][1])then
if(pGO:GetHP() < pGO:GetMaxHP()/2 and (pGO:GetWorldStateForZone(go_f_tower[i][2])== 1 or pGO:GetWorldStateForZone(go_f_tower[i][2])== 4 or pGO:GetWorldStateForZone(go_f_tower[i][2])== 7))then
pGO:SetWorldStateForZone(go_f_tower[i][2],pGO:GetWorldStateForZone(go_f_tower[i][2])+1)
end
end
end
end
function FTOnDestroy(pGO)
for i = 1, #go_f_tower do
if(pGO:GetEntry() == go_f_tower[i][1])then
if(pGO:GetWorldStateForZone(go_f_tower[i][2])== 2 or pGO:GetWorldStateForZone(go_f_tower[i][2])== 5 or pGO:GetWorldStateForZone(go_f_tower[i][2])== 8)then
pGO:SetWorldStateForZone(go_f_tower[i][2],pGO:GetWorldStateForZone(go_f_tower[i][2])+1)
end
end
for k,g in pairs(pGO:GetInRangePlayers())do
if(DEFENDER == "Horde")then
if(g:GetTeam() == 0)then
if not(g:HasAchievement(ACHIEVEMENT_LEANING_T))then
g:AddAchievement(ACHIEVEMENT_LEANING_T)
end
end
elseif(DEFENDER == "Alliance")then
if(g:GetTeam() == 1)then
if not(g:HasAchievement(ACHIEVEMENT_LEANING_T))then
g:AddAchievement(ACHIEVEMENT_LEANING_T)
end
end
end
end
end
end
function STOnDamage(pGO, damage)
for i = 1, #go_s_tower do
if(pGO:GetEntry() == go_s_tower[i][1])then
if(pGO:GetHP() < pGO:GetMaxHP()/2 and (pGO:GetWorldStateForZone(go_s_tower[i][2])== 1 or pGO:GetWorldStateForZone(go_s_tower[i][2])== 4 or pGO:GetWorldStateForZone(go_s_tower[i][2])== 7))then
pGO:SetWorldStateForZone(go_s_tower[i][2],pGO:GetWorldStateForZone(go_s_tower[i][2])+1)
end
end
end
end
function STOnDestroy(pGO)
for i = 1, #go_s_tower do
if(pGO:GetEntry() == go_s_tower[i][1])then
if(pGO:GetWorldStateForZone(go_s_tower[i][2])== 2 or pGO:GetWorldStateForZone(go_s_tower[i][2])== 5 or pGO:GetWorldStateForZone(go_s_tower[i][2])== 8)then
pGO:SetWorldStateForZone(go_s_tower[i][2],pGO:GetWorldStateForZone(go_s_tower[i][2])+1)
end
end
end
for k,g in pairs(pGO:GetInRangePlayers())do
if(DEFENDER == "Alliance")then
if(g:GetTeam() == 0)then
if not(g:HasAchievement(ACHIEVEMENT_LEANING_T))then
g:AddAchievement(ACHIEVEMENT_LEANING_T)
end
if(g:HasQuest(QUEST_WG_SOUTHEN_SABOTAGE) and g:GetQuestObjectiveCompletion(QUEST_WG_SOUTHEN_SABOTAGE, 0) == 0)then
g:AdvanceQuestObjective(QUEST_WG_SOUTHEN_SABOTAGE, 0)
end
end
elseif(DEFENDER == "Horde")then
if(g:GetTeam() == 1)then
if not(g:HasAchievement(ACHIEVEMENT_LEANING_T))then
g:AddAchievement(ACHIEVEMENT_LEANING_T)
end
if(g:HasQuest(QUEST_WG_TOPPING_TOWERS) and g:GetQuestObjectiveCompletion(QUEST_WG_TOPPING_TOWERS, 0) == 0)then
g:AdvanceQuestObjective(QUEST_WG_TOPPING_TOWERS, 0)
end
end
end
if(pGO:GetEntry() == GO_WINTERGRASP_SS_TOWER)then
south_towers = south_towers - 1
for k,g in pairs(GetPlayersInZone(ZONE_WG))do
g:SendBroadcastMessage("The Shadowsight Tower was destroyed by the "..DEFENDER.."!")
g:SendAreaTriggerMessage("The Shadowsight Tower was destroyed by the "..DEFENDER.."!")
end
elseif(pGO:GetEntry() == GO_WINTERGRASP_WE_TOWER)then
south_towers = south_towers - 1
for k,g in pairs(GetPlayersInZone(ZONE_WG))do
g:SendBroadcastMessage("The Winter's Edge Tower was destroyed by the "..DEFENDER.."!")
g:SendAreaTriggerMessage("The Winter's Edge Tower was destroyed by the "..DEFENDER.."!")
end
elseif(pGO:GetEntry() == GO_WINTERGRASP_FW_TOWER)then
south_towers = south_towers - 1
for k,g in pairs(GetPlayersInZone(ZONE_WG))do
g:SendBroadcastMessage("The Flamewatch Tower was destroyed by the "..DEFENDER.."!")
g:SendAreaTriggerMessage("The Flamewatch Tower was destroyed by the "..DEFENDER.."!")
end
end
end
end
function ShopOnDamage(pGO, damage)
for i = 1, #workshop_data do
if(pGO:GetEntry() == workshop_data[i][1])then
if(pGO:GetHP() < pGO:GetMaxHP()/2 and (pGO:GetWorldStateForZone(workshop_data[i][2])== 1 or pGO:GetWorldStateForZone(workshop_data[i][2])== 4 or pGO:GetWorldStateForZone(workshop_data[i][2])== 7))then
if(pGO:GetWorldStateForZone(workshop_data[i][2]) == 4)then
vehicle_vallue_h = vehicle_vallue_h - 2
pGO:SetWorldStateForZone(WG_STATE_MAX_H_VEHICLES,vehicle_vallue_h)
elseif(pGO:GetWorldStateForZone(workshop_data[i][2]) == 7)then
vehicle_vallue_a = vehicle_vallue_a - 2
pGO:SetWorldStateForZone(WG_STATE_MAX_A_VEHICLES,vehicle_vallue_a)
end
workshop_data[i][6] = 1
pGO:SetWorldStateForZone(workshop_data[i][2],pGO:GetWorldStateForZone(workshop_data[i][2])+1)
end
end
end
end
function ShopOnDestroy(pGO)
for i = 1, #workshop_data do
if(pGO:GetEntry() == workshop_data[i][1])then
if(pGO:GetWorldStateForZone(workshop_data[i][2])== 2 or pGO:GetWorldStateForZone(workshop_data[i][2])== 5 or pGO:GetWorldStateForZone(workshop_data[i][2])== 8)then
if(pGO:GetWorldStateForZone(workshop_data[i][2]) == 5)then
vehicle_vallue_h = vehicle_vallue_h - 2
pGO:SetWorldStateForZone(WG_STATE_MAX_H_VEHICLES,vehicle_vallue_h)
elseif(pGO:GetWorldStateForZone(workshop_data[i][2]) == 8)then
vehicle_vallue_a = vehicle_vallue_a - 2
pGO:SetWorldStateForZone(WG_STATE_MAX_A_VEHICLES,vehicle_vallue_a)
end
workshop_data[i][6] = 0
pGO:SetWorldStateForZone(workshop_data[i][2],pGO:GetWorldStateForZone(workshop_data[i][2])+1)
end
end
end
end
RegisterUnitGossipEvent(NPC_GOBLIN_ENGINEER,2,HOnSelect)
RegisterUnitGossipEvent(NPC_GOBLIN_ENGINEER,1,HGengineerOnGossip)
RegisterUnitGossipEvent(NPC_GNOME_ENGINEER,2,AOnSelect)
RegisterUnitGossipEvent(NPC_GNOME_ENGINEER,1,AGengineerOnGossip)
for i = 1, #workshop_data do
if(workshop_data[i][5] > 0)then
RegisterGameObjectEvent(workshop_data[i][5],5,AIUpdate_Cpoint)
RegisterGameObjectEvent(workshop_data[i][5],2,OnSP_Cpoint)
end
end
RegisterGameObjectEvent(GO_WINTERGRASP_VEHICLE_TELEPORTER,5,OnAIUpdateVehicleTeleporter)
RegisterGameObjectEvent(GO_WINTERGRASP_VEHICLE_TELEPORTER,2,OnLoadVehicleTeleporter)
RegisterGameObjectEvent(GO_WINTERGRASP_DEFENDER_A,4,PortalOnUse)
RegisterGameObjectEvent(GO_WINTERGRASP_DEFENDER_H,4,PortalOnUse)
RegisterGameObjectEvent(GO_WINTERGRASP_DEFENDER_N,4,PortalOnUse)
RegisterGameObjectEvent(GO_WINTERGRASP_TITAN_RELIC,4,TitanRelickOnUse)
RegisterUnitEvent(NPC_DETECTION_UNIT,18,DetectionUnitOnSpawn)
RegisterUnitEvent(NPC_DETECTION_UNIT,21,DetectionUnitAIUpdate)
RegisterTimedEvent("WGUpdate", 1000, 0)
RegisterTimedEvent("Aura", 1000, 0)
RegisterServerHook(16, "DebugWG")
RegisterServerHook(2,KillPlayer)
RegisterServerHook(15,OnZoneEnter)
RegisterServerHook(4,OnEnterBuff)
RegisterUnitEvent(30739,4,KillCreature)
RegisterUnitEvent(30740,4,KillCreature)
for i = 1, #go_wall do
RegisterGameObjectEvent(go_wall[i][1],7,WallOnDamage)
RegisterGameObjectEvent(go_wall[i][1],8,WallOnDestroy)
end
for i = 1, #go_f_tower do
RegisterGameObjectEvent(go_f_tower[i][1],7,FTOnDamage)
RegisterGameObjectEvent(go_f_tower[i][1],8,FTOnDestroy)
end
for i = 1, #go_s_tower do
RegisterGameObjectEvent(go_s_tower[i][1],7,STOnDamage)
RegisterGameObjectEvent(go_s_tower[i][1],8,STOnDestroy)
end
for i = 1, #workshop_data do
RegisterGameObjectEvent(workshop_data[i][1],7,ShopOnDamage)
RegisterGameObjectEvent(workshop_data[i][1],8,ShopOnDestroy)
end
print("-- Wintergrasp loaded --") | agpl-3.0 |
TeamHypersomnia/Augmentations | hypersomnia/content/official/gfx/ao44_magazine.meta.lua | 2 | 1899 | return {
extra_loadables = {
enabled_generate_neon_map = {
alpha_multiplier = 1,
amplification = 80,
light_colors = {
"255 255 255 255"
},
radius = {
x = 80,
y = 80
},
standard_deviation = 6
},
generate_desaturation = false
},
offsets = {
gun = {
bullet_spawn = {
x = 0,
y = 0
},
detachable_magazine = {
pos = {
x = 0,
y = 0
},
rotation = 0
}
},
item = {
attachment_anchor = {
pos = {
x = 0,
y = 0
},
rotation = 0
},
back_anchor = {
pos = {
x = 0,
y = 0
},
rotation = 0
},
beep_offset = {
pos = {
x = 0,
y = 0
},
rotation = 0
},
hand_anchor = {
pos = {
x = 0,
y = 0
},
rotation = 0
},
head_anchor = {
pos = {
x = 0,
y = 0
},
rotation = 0
}
},
legs = {
foot = {
x = 0,
y = 0
}
},
torso = {
back = {
pos = {
x = 0,
y = 0
},
rotation = 0
},
head = {
pos = {
x = 0,
y = 0
},
rotation = 0
},
legs = {
pos = {
x = 0,
y = 0
},
rotation = 0
},
primary_hand = {
pos = {
x = 0,
y = 0
},
rotation = 0
},
secondary_hand = {
pos = {
x = 0,
y = 0
},
rotation = 0
}
}
},
usage_as_button = {
bbox_expander = {
x = 0,
y = 0
},
flip = {
horizontally = false,
vertically = false
}
}
} | agpl-3.0 |
nasomi/darkstar | scripts/zones/The_Sanctuary_of_ZiTah/npcs/Ochocho_WW.lua | 30 | 3072 | -----------------------------------
-- Area: The Sanctuary of Zi'Tah
-- NPC: Ochocho, W.W.
-- Border Conquest Guards
-- @pos -252.454 -1.958 624.366 121
-----------------------------------
package.loaded["scripts/zones/The_Sanctuary_of_ZiTah/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/conquest");
require("scripts/zones/The_Sanctuary_of_ZiTah/TextIDs");
local guardnation = WINDURST; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno
local guardtype = 4; -- 1: city, 2: foreign, 3: outpost, 4: border
local region = LITELOR;
local csid = 0x7ff6;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
tradeConquestGuard(player,npc,trade,guardnation,guardtype);
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:hasKeyItem(getSupplyKey(region)) and player:getNation() == guardnation) then
if (supplyRunFresh(player) == 1) then
player:startEvent(csid,16,0,0,0,1,0,0,255); -- you have brought us supplies !
else
player:showText(npc, CONQUEST - 1); -- "Hmm... These supplies you have brought us are too old to be of any use."
player:delKeyItem(getSupplyKey(region));
player:messageSpecial(KEYITEM_OBTAINED + 1, getSupplyKey(region));
player:setVar("supplyQuest_region",0);
end
else
local arg1 = getArg1(guardnation, player) - 1;
if (arg1 >= 1792) then -- foreign, non-allied
player:startEvent(csid,1808,0,0,0,0,player:getRank(),0,0);
else -- citizen or allied
player:startEvent(csid,arg1,0,0x3F0000,0,0,getArg6(player),0,0);
end
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("OPTION: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("OPTION: %u",option);
if (option == 1) then
local duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600;
player:delStatusEffect(EFFECT_SIGIL);
player:delStatusEffect(EFFECT_SANCTION);
player:delStatusEffect(EFFECT_SIGNET);
player:addStatusEffect(EFFECT_SIGNET,0,0,duration); -- Grant Signet
elseif (option == 2) then
player:delKeyItem(getSupplyKey(region));
player:addCP(supplyReward[region + 1])
player:messageSpecial(CONQUEST); -- "You've earned conquest points!"
if (hasOutpost(player, region+5) == 0) then
local supply_quests = 2^(region+5);
player:addNationTeleport(guardnation,supply_quests);
player:setVar("supplyQuest_region",0);
end
elseif (option == 4) then
if (player:delGil(giltosetHP(guardnation,player))) then
player:setHomePoint();
player:messageSpecial(CONQUEST + 94); -- "Your home point has been set."
else
player:messageSpecial(CONQUEST + 95); -- "You do not have enough gil to set your home point here."
end
end
end; | gpl-3.0 |
MaxxUAV/ardupilot | Tools/CHDK-Scripts/Cannon SX260/3DR_EAI_SX260.lua | 182 | 29665 |
--[[
KAP UAV Exposure Control Script v3.1
-- Released under GPL by waterwingz and wayback/peabody
http://chdk.wikia.com/wiki/KAP_%26_UAV_Exposure_Control_Script
3DR EAI 1.0 is a fork of KAP 3.1 with settings specific to Canon cameras triggered off the Pixhawk autopilot.
Changelog:
-Modified Tv, Av, and ISO settings for the Canon SX260
-Added an option to turn the GPS on and off
-Added control of GPS settings in Main Loop
-Changed USB OneShot mode to listen for 100ms command pulse from Pixhawk
@title 3DR EAI 1.0 - Lets Map!
@param i Shot Interval (sec)
@default i 2
@range i 2 120
@param s Total Shots (0=infinite)
@default s 0
@range s 0 10000
@param j Power off when done?
@default j 0
@range j 0 1
@param e Exposure Comp (stops)
@default e 6
@values e -2.0 -1.66 -1.33 -1.0 -0.66 -0.33 0.0 0.33 0.66 1.00 1.33 1.66 2.00
@param d Start Delay Time (sec)
@default d 0
@range d 0 10000
@param y Tv Min (sec)
@default y 5
@values y None 1/60 1/100 1/200 1/400 1/640
@param t Target Tv (sec)
@default t 7
@values t 1/100 1/200 1/400 1/640 1/800 1/1000 1/1250 1/1600 1/2000
@param x Tv Max (sec)
@default x 4
@values x 1/1000 1/1250 1/1600 1/2000 1/3200 1/5000 1/10000
@param f Av Low(f-stop)
@default f 6
@values f 1.8 2.0 2.2 2.6 2.8 3.2 3.5 4.0 4.5 5.0 5.6 6.3 7.1 8.0
@param a Av Target (f-stop)
@default a 7
@values a 1.8 2.0 2.2 2.6 2.8 3.2 3.5 4.0 4.5 5.0 5.6 6.3 7.1 8.0
@param m Av Max (f-stop)
@default m 13
@values m 1.8 2.0 2.2 2.6 2.8 3.2 3.5 4.0 4.5 5.0 5.6 6.3 7.1 8.0
@param p ISO Min
@default p 0
@values p 80 100 200 400 800 1250 1600
@param q ISO Max1
@default q 1
@values q 100 200 400 800 1250 1600
@param r ISO Max2
@default r 3
@values r 100 200 400 800 1250 1600
@param n Allow use of ND filter?
@default n 0
@values n No Yes
@param z Zoom position
@default z 0
@values z Off 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%
@param c Focus @ Infinity Mode
@default c 3
@values c None @Shot AFL MF
@param v Video Interleave (shots)
@default v 0
@values v Off 1 5 10 25 50 100
@param w Video Duration (sec)
@default w 10
@range w 5 300
@param u Trigger Type
@default u 2
@values u Interval Cont. USB PWM
@param g GPS On
@default g 1
@range g 0 1
@param b Backlight Off?
@default b 1
@range b 0 1
@param l Logging
@default l 3
@values l Off Screen SDCard Both
--]]
props=require("propcase")
capmode=require("capmode")
-- convert user parameter to usable variable names and values
tv_table = { -320, 576, 640, 736, 832, 896, 928, 960, 992, 1024, 1056, 1113, 1180, 1276}
tv96target = tv_table[t+3]
tv96max = tv_table[x+8]
tv96min = tv_table[y+1]
sv_table = { 381, 411, 507, 603, 699, 761, 795 }
sv96min = sv_table[p+1]
sv96max1 = sv_table[q+2]
sv96max2 = sv_table[r+2]
av_table = { 171, 192, 218, 265, 285, 322, 347, 384, 417, 446, 477, 510, 543, 576 }
av96target = av_table[a+1]
av96minimum = av_table[f+1]
av96max = av_table[m+1]
ec96adjust = (e - 6)*32
video_table = { 0, 1, 5, 10, 25, 50, 100 }
video_mode = video_table[v+1]
video_duration = w
interval = i*1000
max_shots = s
poff_if_done = j
start_delay = d
backlight = b
log_mode= l
focus_mode = c
usb_mode = u
gps = g
if ( z==0 ) then zoom_setpoint = nil else zoom_setpoint = (z-1)*10 end
-- initial configuration values
nd96offset=3*96 -- ND filter's number of equivalent f-stops (f * 96)
infx = 50000 -- focus lock distance in mm (approximately 55 yards)
shot_count = 0 -- shot counter
blite_timer = 300 -- backlight off delay in 100mSec increments
old_console_timeout = get_config_value( 297 )
shot_request = false -- pwm mode flag to request a shot be taken
-- check camera Av configuration ( variable aperture and/or ND filter )
if n==0 then -- use of nd filter allowed?
if get_nd_present()==1 then -- check for ND filter only
Av_mode = 0 -- 0 = ND disabled and no iris available
else
Av_mode = 1 -- 1 = ND disabled and iris available
end
else
Av_mode = get_nd_present()+1 -- 1 = iris only , 2=ND filter only, 3= both ND & iris
end
function printf(...)
if ( log_mode == 0) then return end
local str=string.format(...)
if (( log_mode == 1) or (log_mode == 3)) then print(str) end
if ( log_mode > 1 ) then
local logname="A/3DR_EAI_log.log"
log=io.open(logname,"a")
log:write(os.date("%Y%b%d %X ")..string.format(...),"\n")
log:close()
end
end
tv_ref = { -- note : tv_ref values set 1/2 way between shutter speed values
-608, -560, -528, -496, -464, -432, -400, -368, -336, -304,
-272, -240, -208, -176, -144, -112, -80, -48, -16, 16,
48, 80, 112, 144, 176, 208, 240, 272, 304, 336,
368, 400, 432, 464, 496, 528, 560, 592, 624, 656,
688, 720, 752, 784, 816, 848, 880, 912, 944, 976,
1008, 1040, 1072, 1096, 1129, 1169, 1192, 1225, 1265, 1376 }
tv_str = {
">64",
"64", "50", "40", "32", "25", "20", "16", "12", "10", "8.0",
"6.0", "5.0", "4.0", "3.2", "2.5", "2.0", "1.6", "1.3", "1.0", "0.8",
"0.6", "0.5", "0.4", "0.3", "1/4", "1/5", "1/6", "1/8", "1/10", "1/13",
"1/15", "1/20", "1/25", "1/30", "1/40", "1/50", "1/60", "1/80", "1/100", "1/125",
"1/160", "1/200", "1/250", "1/320", "1/400", "1/500", "1/640", "1/800", "1/1000","1/1250",
"1/1600","1/2000","1/2500","1/3200","1/4000","1/5000","1/6400","1/8000","1/10000","hi" }
function print_tv(val)
if ( val == nil ) then return("-") end
local i = 1
while (i <= #tv_ref) and (val > tv_ref[i]) do i=i+1 end
return tv_str[i]
end
av_ref = { 160, 176, 208, 243, 275, 304, 336, 368, 400, 432, 464, 480, 496, 512, 544, 592, 624, 656, 688, 720, 752, 784 }
av_str = {"n/a","1.8", "2.0","2.2","2.6","2.8","3.2","3.5","4.0","4.5","5.0","5.6","5.9","6.3","7.1","8.0","9.0","10.0","11.0","13.0","14.0","16.0","hi"}
function print_av(val)
if ( val == nil ) then return("-") end
local i = 1
while (i <= #av_ref) and (val > av_ref[i]) do i=i+1 end
return av_str[i]
end
sv_ref = { 370, 397, 424, 456, 492, 523, 555, 588, 619, 651, 684, 731, 779, 843, 907 }
sv_str = {"n/a","80","100","120","160","200","250","320","400","500","640","800","1250","1600","3200","hi"}
function print_sv(val)
if ( val == nil ) then return("-") end
local i = 1
while (i <= #sv_ref) and (val > sv_ref[i]) do i=i+1 end
return sv_str[i]
end
function pline(message, line) -- print line function
fg = 258 bg=259
end
-- switch between shooting and playback modes
function switch_mode( m )
if ( m == 1 ) then
if ( get_mode() == false ) then
set_record(1) -- switch to shooting mode
while ( get_mode() == false ) do
sleep(100)
end
sleep(1000)
end
else
if ( get_mode() == true ) then
set_record(0) -- switch to playback mode
while ( get_mode() == true ) do
sleep(100)
end
sleep(1000)
end
end
end
-- focus lock and unlock
function lock_focus()
if (focus_mode > 1) then -- focus mode requested ?
if ( focus_mode == 2 ) then -- method 1 : set_aflock() command enables MF
if (chdk_version==120) then
set_aflock(1)
set_prop(props.AF_LOCK,1)
else
set_aflock(1)
end
if (get_prop(props.AF_LOCK) == 1) then printf(" AFL enabled") else printf(" AFL failed ***") end
else -- mf mode requested
if (chdk_version==120) then -- CHDK 1.2.0 : call event proc or levents to try and enable MF mode
if call_event_proc("SS.Create") ~= -1 then
if call_event_proc("SS.MFOn") == -1 then
call_event_proc("PT_MFOn")
end
elseif call_event_proc("RegisterShootSeqEvent") ~= -1 then
if call_event_proc("PT_MFOn") == -1 then
call_event_proc("MFOn")
end
end
if (get_prop(props.FOCUS_MODE) == 0 ) then -- MF not set - try levent PressSw1AndMF
post_levent_for_npt("PressSw1AndMF")
sleep(500)
end
elseif (chdk_version >= 130) then -- CHDK 1.3.0 : set_mf()
if ( set_mf(1) == 0 ) then set_aflock(1) end -- as a fall back, try setting AFL is set_mf fails
end
if (get_prop(props.FOCUS_MODE) == 1) then printf(" MF enabled") else printf(" MF enable failed ***") end
end
sleep(1000)
set_focus(infx)
sleep(1000)
end
end
function unlock_focus()
if (focus_mode > 1) then -- focus mode requested ?
if (focus_mode == 2 ) then -- method 1 : AFL
if (chdk_version==120) then
set_aflock(0)
set_prop(props.AF_LOCK,0)
else
set_aflock(0)
end
if (get_prop(props.AF_LOCK) == 0) then printf(" AFL unlocked") else printf(" AFL unlock failed") end
else -- mf mode requested
if (chdk_version==120) then -- CHDK 1.2.0 : call event proc or levents to try and enable MF mode
if call_event_proc("SS.Create") ~= -1 then
if call_event_proc("SS.MFOff") == -1 then
call_event_proc("PT_MFOff")
end
elseif call_event_proc("RegisterShootSeqEvent") ~= -1 then
if call_event_proc("PT_MFOff") == -1 then
call_event_proc("MFOff")
end
end
if (get_prop(props.FOCUS_MODE) == 1 ) then -- MF not reset - try levent PressSw1AndMF
post_levent_for_npt("PressSw1AndMF")
sleep(500)
end
elseif (chdk_version >= 130) then -- CHDK 1.3.0 : set_mf()
if ( set_mf(0) == 0 ) then set_aflock(0) end -- fall back so reset AFL is set_mf fails
end
if (get_prop(props.FOCUS_MODE) == 0) then printf(" MF disabled") else printf(" MF disable failed") end
end
sleep(100)
end
end
-- zoom position
function update_zoom(zpos)
local count = 0
if(zpos ~= nil) then
zstep=((get_zoom_steps()-1)*zpos)/100
printf("setting zoom to "..zpos.." percent step="..zstep)
sleep(200)
set_zoom(zstep)
sleep(2000)
press("shoot_half")
repeat
sleep(100)
count = count + 1
until (get_shooting() == true ) or (count > 40 )
release("shoot_half")
end
end
-- restore camera settings on shutdown
function restore()
set_config_value(121,0) -- USB remote disable
set_config_value(297,old_console_timeout) -- restore console timeout value
if (backlight==1) then set_lcd_display(1) end -- display on
unlock_focus()
if( zoom_setpoint ~= nil ) then update_zoom(0) end
if( shot_count >= max_shots) and ( max_shots > 1) then
if ( poff_if_done == 1 ) then -- did script ending because # of shots done ?
printf("power off - shot count at limit") -- complete power down
sleep(2000)
post_levent_to_ui('PressPowerButton')
else
set_record(0) end -- just retract lens
end
end
-- Video mode
function check_video(shot)
local capture_mode
if ((video_mode>0) and(shot>0) and (shot%video_mode == 0)) then
unlock_focus()
printf("Video mode started. Button:"..tostring(video_button))
if( video_button ) then
click "video"
else
capture_mode=capmode.get()
capmode.set('VIDEO_STD')
press("shoot_full")
sleep(300)
release("shoot_full")
end
local end_second = get_day_seconds() + video_duration
repeat
wait_click(500)
until (is_key("menu")) or (get_day_seconds() > end_second)
if( video_button ) then
click "video"
else
press("shoot_full")
sleep(300)
release("shoot_full")
capmode.set(capture_mode)
end
printf("Video mode finished.")
sleep(1000)
lock_focus()
return(true)
else
return(false)
end
end
-- PWM USB pulse functions
function ch1up()
printf(" * usb pulse = ch1up")
shot_request = true
end
function ch1mid()
printf(" * usb pulse = ch1mid")
if ( get_mode() == false ) then
switch_mode(1)
lock_focus()
end
end
function ch1down()
printf(" * usb pulse = ch1down")
switch_mode(0)
end
function ch2up()
printf(" * usb pulse = ch2up")
update_zoom(100)
end
function ch2mid()
printf(" * usb pulse = ch2mid")
if ( zoom_setpoint ~= nil ) then update_zoom(zoom_setpoint) else update_zoom(50) end
end
function ch2down()
printf(" * usb pulse = ch2down")
update_zoom(0)
end
function pwm_mode(pulse_width)
if pulse_width > 0 then
if pulse_width < 5 then ch1up()
elseif pulse_width < 8 then ch1mid()
elseif pulse_width < 11 then ch1down()
elseif pulse_width < 14 then ch2up()
elseif pulse_width < 17 then ch2mid()
elseif pulse_width < 20 then ch2down()
else printf(" * usb pulse width error") end
end
end
-- Basic exposure calculation using shutter speed and ISO only
-- called for Tv-only and ND-only cameras (cameras without an iris)
function basic_tv_calc()
tv96setpoint = tv96target
av96setpoint = nil
local min_av = get_prop(props.MIN_AV)
-- calculate required ISO setting
sv96setpoint = tv96setpoint + min_av - bv96meter
-- low ambient light ?
if (sv96setpoint > sv96max2 ) then -- check if required ISO setting is too high
sv96setpoint = sv96max2 -- clamp at max2 ISO if so
tv96setpoint = math.max(bv96meter+sv96setpoint-min_av,tv96min) -- recalculate required shutter speed down to Tv min
-- high ambient light ?
elseif (sv96setpoint < sv96min ) then -- check if required ISO setting is too low
sv96setpoint = sv96min -- clamp at minimum ISO setting if so
tv96setpoint = bv96meter + sv96setpoint - min_av -- recalculate required shutter speed and hope for the best
end
end
-- Basic exposure calculation using shutter speed, iris and ISO
-- called for iris-only and "both" cameras (cameras with an iris & ND filter)
function basic_iris_calc()
tv96setpoint = tv96target
av96setpoint = av96target
-- calculate required ISO setting
sv96setpoint = tv96setpoint + av96setpoint - bv96meter
-- low ambient light ?
if (sv96setpoint > sv96max1 ) then -- check if required ISO setting is too high
sv96setpoint = sv96max1 -- clamp at first ISO limit
av96setpoint = bv96meter + sv96setpoint - tv96setpoint -- calculate new aperture setting
if ( av96setpoint < av96min ) then -- check if new setting is goes below lowest f-stop
av96setpoint = av96min -- clamp at lowest f-stop
sv96setpoint = tv96setpoint + av96setpoint - bv96meter -- recalculate ISO setting
if (sv96setpoint > sv96max2 ) then -- check if the result is above max2 ISO
sv96setpoint = sv96max2 -- clamp at highest ISO setting if so
tv96setpoint = math.max(bv96meter+sv96setpoint-av96setpoint,tv96min) -- recalculate required shutter speed down to tv minimum
end
end
-- high ambient light ?
elseif (sv96setpoint < sv96min ) then -- check if required ISO setting is too low
sv96setpoint = sv96min -- clamp at minimum ISO setting if so
tv96setpoint = bv96meter + sv96setpoint - av96setpoint -- recalculate required shutter speed
if (tv96setpoint > tv96max ) then -- check if shutter speed now too fast
tv96setpoint = tv96max -- clamp at maximum shutter speed if so
av96setpoint = bv96meter + sv96setpoint - tv96setpoint -- calculate new aperture setting
if ( av96setpoint > av96max ) then -- check if new setting is goes above highest f-stop
av96setpoint = av96max -- clamp at highest f-stop
tv96setpoint = bv96meter + sv96setpoint - av96setpoint -- recalculate shutter speed needed and hope for the best
end
end
end
end
-- calculate exposure for cams without adjustable iris or ND filter
function exposure_Tv_only()
insert_ND_filter = nil
basic_tv_calc()
end
-- calculate exposure for cams with ND filter only
function exposure_NDfilter()
insert_ND_filter = false
basic_tv_calc()
if (tv96setpoint > tv96max ) then -- check if shutter speed now too fast
insert_ND_filter = true -- flag the ND filter to be inserted
bv96meter = bv96meter - nd96offset -- adjust meter for ND offset
basic_tv_calc() -- start over, but with new meter value
bv96meter = bv96meter + nd96offset -- restore meter for later logging
end
end
-- calculate exposure for cams with adjustable iris only
function exposure_iris()
insert_ND_filter = nil
basic_iris_calc()
end
-- calculate exposure for cams with both adjustable iris and ND filter
function exposure_both()
insert_ND_filter = false -- NOTE : assume ND filter never used automatically by Canon firmware
basic_iris_calc()
if (tv96setpoint > tv96max ) then -- check if shutter speed now too fast
insert_ND_filter = true -- flag the ND filter to be inserted
bv96meter = bv96meter - nd96offset -- adjust meter for ND offset
basic_iris_calc() -- start over, but with new meter value
bv96meter = bv96meter + nd96offset -- restore meter for later logging
end
end
-- ========================== Main Program =================================
set_console_layout(1 ,1, 45, 14 )
--printf("KAP 3.1 started - press MENU to exit")
printf("3DR EAI 1.0 Canon SX260 - Lets Map!")
printf("Based On KAP 3.1")
printf("Press the shutter button to pause")
bi=get_buildinfo()
printf("%s %s-%s %s %s %s", bi.version, bi.build_number, bi.build_revision, bi.platform, bi.platsub, bi.build_date)
chdk_version= tonumber(string.sub(bi.build_number,1,1))*100 + tonumber(string.sub(bi.build_number,3,3))*10 + tonumber(string.sub(bi.build_number,5,5))
if ( tonumber(bi.build_revision) > 0 ) then
build = tonumber(bi.build_revision)
else
build = tonumber(string.match(bi.build_number,'-(%d+)$'))
end
if ((chdk_version<120) or ((chdk_version==120)and(build<3276)) or ((chdk_version==130)and(build<3383))) then
printf("CHDK 1.2.0 build 3276 or higher required")
else
if( props.CONTINUOUS_AF == nil ) then caf=-999 else caf = get_prop(props.CONTINUOUS_AF) end
if( props.SERVO_AF == nil ) then saf=-999 else saf = get_prop(props.SERVO_AF) end
cmode = capmode.get_name()
printf("Mode:%s,Continuous_AF:%d,Servo_AF:%d", cmode,caf,saf)
printf(" Tv:"..print_tv(tv96target).." max:"..print_tv(tv96max).." min:"..print_tv(tv96min).." ecomp:"..(ec96adjust/96).."."..(math.abs(ec96adjust*10/96)%10) )
printf(" Av:"..print_av(av96target).." minAv:"..print_av(av96minimum).." maxAv:"..print_av(av96max) )
printf(" ISOmin:"..print_sv(sv96min).." ISO1:"..print_sv(sv96max1).." ISO2:"..print_sv(sv96max2) )
printf(" MF mode:"..focus_mode.." Video:"..video_mode.." USB:"..usb_mode)
printf(" AvM:"..Av_mode.." int:"..(interval/1000).." Shts:"..max_shots.." Dly:"..start_delay.." B/L:"..backlight)
sleep(500)
if (start_delay > 0 ) then
printf("entering start delay of ".. start_delay.." seconds")
sleep( start_delay*1000 )
end
-- CAMERA CONFIGURATION -
-- FIND config table here http://subversion.assembla.com/svn/chdk/trunk/core/conf.c
set_config_value(2,0) --Save raw: off
if (gps==1) then
set_config_value(282,1) --turn GPS on
--set_config_value(278,1) --show GPS symbol
set_config_value(261,1) --wait for signal time
set_config_value(266,5) --battery shutdown percentage
end
-- enable USB remote in USB remote moded
if (usb_mode > 0 ) then
set_config_value(121,1) -- make sure USB remote is enabled
if (get_usb_power(1) == 0) then -- can we start ?
printf("waiting on USB signal")
repeat wait_click(20) until ((get_usb_power(1) == 1) or ( is_key("menu")))
--changed sleep from 1000 to 500
else sleep(500) end
printf("USB signal received")
end
-- switch to shooting mode
switch_mode(1)
-- set zoom position
update_zoom(zoom_setpoint)
-- lock focus at infinity
lock_focus()
-- disable flash and AF assist lamp
set_prop(props.FLASH_MODE, 2) -- flash off
set_prop(props.AF_ASSIST_BEAM,0) -- AF assist off if supported for this camera
set_config_value( 297, 60) -- set console timeout to 60 seconds
if (usb_mode > 2 ) then repeat until (get_usb_power(2) == 0 ) end -- flush pulse buffer
next_shot_time = get_tick_count()
script_exit = false
if( get_video_button() == 1) then video_button = true else video_button = false end
set_console_layout(2 ,0, 45, 4 )
repeat
--BB: Set get_usb_power(2) > 7 for a 70/100s pulse
--BB: Could consider a max threshold to prevent erroneous trigger events
--eg. get_usb_power(2) > 7 && get_usb_power(2) < 13
if( ( (usb_mode < 2 ) and ( next_shot_time <= get_tick_count() ) )
or ( (usb_mode == 2 ) and (get_usb_power(2) > 7 ) )
or ( (usb_mode == 3 ) and (shot_request == true ) ) ) then
-- time to insert a video sequence ?
if( check_video(shot_count) == true) then next_shot_time = get_tick_count() end
-- intervalometer timing
next_shot_time = next_shot_time + interval
-- set focus at infinity ? (maybe redundant for AFL & MF mode but makes sure its set right)
if (focus_mode > 0) then
set_focus(infx)
sleep(100)
end
-- check exposure
local count = 0
local timeout = false
press("shoot_half")
repeat
sleep(50)
count = count + 1
if (count > 40 ) then timeout = true end
until (get_shooting() == true ) or (timeout == true)
-- shoot in auto mode if meter reading invalid, else calculate new desired exposure
if ( timeout == true ) then
release("shoot_half")
repeat sleep(50) until get_shooting() == false
shoot() -- shoot in Canon auto mode if we don't have a valid meter reading
shot_count = shot_count + 1
printf(string.format('IMG_%04d.JPG',get_exp_count()).." : shot in auto mode, meter reading invalid")
else
-- get meter reading values (and add in exposure compensation)
bv96raw=get_bv96()
bv96meter=bv96raw-ec96adjust
tv96meter=get_tv96()
av96meter=get_av96()
sv96meter=get_sv96()
-- set minimum Av to larger of user input or current min for zoom setting
av96min= math.max(av96minimum,get_prop(props.MIN_AV))
if (av96target < av96min) then av96target = av96min end
-- calculate required setting for current ambient light conditions
if (Av_mode == 1) then exposure_iris()
elseif (Av_mode == 2) then exposure_NDfilter()
elseif (Av_mode == 3) then exposure_both()
else exposure_Tv_only()
end
-- set up all exposure overrides
set_tv96_direct(tv96setpoint)
set_sv96(sv96setpoint)
if( av96setpoint ~= nil) then set_av96_direct(av96setpoint) end
if(Av_mode > 1) and (insert_ND_filter == true) then -- ND filter available and needed?
set_nd_filter(1) -- activate the ND filter
nd_string="NDin"
else
set_nd_filter(2) -- make sure the ND filter does not activate
nd_string="NDout"
end
-- and finally shoot the image
press("shoot_full_only")
sleep(100)
release("shoot_full")
repeat sleep(50) until get_shooting() == false
shot_count = shot_count + 1
-- update shooting statistic and log as required
shot_focus=get_focus()
if(shot_focus ~= -1) and (shot_focus < 20000) then
focus_string=" foc:"..(shot_focus/1000).."."..(((shot_focus%1000)+50)/100).."m"
if(focus_mode>0) then
error_string=" **WARNING : focus not at infinity**"
end
else
focus_string=" foc:infinity"
error_string=nil
end
printf(string.format('%d) IMG_%04d.JPG',shot_count,get_exp_count()))
printf(" meter : Tv:".. print_tv(tv96meter) .." Av:".. print_av(av96meter) .." Sv:"..print_sv(sv96meter).." "..bv96raw ..":"..bv96meter)
printf(" actual: Tv:".. print_tv(tv96setpoint).." Av:".. print_av(av96setpoint).." Sv:"..print_sv(sv96setpoint))
printf(" AvMin:".. print_av(av96min).." NDF:"..nd_string..focus_string )
if ((max_shots>0) and (shot_count >= max_shots)) then script_exit = true end
shot_request = false -- reset shot request flag
end
collectgarbage()
end
-- check if USB remote enabled in intervalometer mode and USB power is off -> pause if so
if ((usb_mode == 1 ) and (get_usb_power(1) == 0)) then
printf("waiting on USB signal")
unlock_focus()
switch_mode(0)
repeat wait_click(20) until ((get_usb_power(1) == 1) or ( is_key("menu")))
switch_mode(1)
lock_focus()
if ( is_key("menu")) then script_exit = true end
printf("USB wait finished")
sleep(100)
end
if (usb_mode == 3 ) then pwm_mode(get_usb_power(2)) end
if (blite_timer > 0) then
blite_timer = blite_timer-1
if ((blite_timer==0) and (backlight==1)) then set_lcd_display(0) end
end
if( error_string ~= nil) then
draw_string( 16, 144, string.sub(error_string.." ",0,42), 258, 259)
end
wait_click(100)
if( not( is_key("no_key"))) then
if ((blite_timer==0) and (backlight==1)) then set_lcd_display(1) end
blite_timer=300
if ( is_key("menu") ) then script_exit = true end
end
until (script_exit==true)
printf("script halt requested")
restore()
end
--[[ end of file ]]--
| gpl-3.0 |
dageq/Dage-Aliraqi | plugins/arabic_lock.lua | 234 | 1405 | antiarabic = {}-- An empty table for solving multiple kicking problem
do
local function run(msg, matches)
if is_momod(msg) then -- Ignore mods,owner,admins
return
end
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)]['settings']['lock_arabic'] then
if data[tostring(msg.to.id)]['settings']['lock_arabic'] == 'yes' then
if is_whitelisted(msg.from.id) then
return
end
if antiarabic[msg.from.id] == true then
return
end
if msg.to.type == 'chat' then
local receiver = get_receiver(msg)
local username = msg.from.username
local name = msg.from.first_name
if username and is_super_group(msg) then
send_large_msg(receiver , "Arabic/Persian is not allowed here\n@"..username.."["..msg.from.id.."]\nStatus: User kicked/msg deleted")
else
send_large_msg(receiver , "Arabic/Persian is not allowed here\nName: "..name.."["..msg.from.id.."]\nStatus: User kicked/msg deleted")
end
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] kicked (arabic was locked) ")
local chat_id = msg.to.id
local user_id = msg.from.id
kick_user(user_id, chat_id)
end
antiarabic[msg.from.id] = true
end
end
return
end
local function cron()
antiarabic = {} -- Clear antiarabic table
end
return {
patterns = {
"([\216-\219][\128-\191])"
},
run = run,
cron = cron
}
end
| gpl-2.0 |
amirhacker135/mmkingtm1 | plugins/broadcast.lua | 12 | 2746 | local function run(msg, matches)
if matches[1] == 'bc' and is_admin(msg) then
local response = matches[3]
send_large_msg("chat#id"..matches[2], response)
end
if matches[1] == 'broadcast' then
if is_sudo(msg) then -- Only sudo !
local data = load_data(_config.moderation.data)
local groups = 'groups'
local response = matches[2]
for k,v in pairs(data[tostring(groups)]) do
chat_id = v
local receiver = 'chat#id'..chat_id
send_large_msg(receiver, response)
end
end
end
end
return {
usage ={
"broadcast: Send A Message To All Groups.",
"bc [id]: Send A Message To Target Group.",
},
patterns = {
"^[!/](broadcast) +(.+)$",
"^[!/](bc) (%d+) (.*)$"
},
run = run
}
-- -_-_-_-_-_-_-_-_-_- ||-_-_-_-_-_ || ||-_-_-_-_-_
-- || || || ||
-- || || || ||
-- || || || ||
-- || ||-_-_-_-_-_ || ||-_-_-_-_-_
-- || || || ||
-- || || || ||
-- || || || ||
-- || ||-_-_-_-_-_ ||-_-_-_-_-_ ||-_-_-_-_-_
--
--
-- /\ /\ /-_-_-_-_-_ ||-_-_-_-_-_ ||-_-_-_-_-_
-- ||\\ //|| //\\ || //|| //\\ // || || //
-- || \\ // || // \\ || // || // \\ // || || //
-- || \\ // || // \\ || // || // \\ || || || //
-- || \\ // || //______\\ || // || //______\\ || -_-_-_- ||-_-_-_-_-_ || //
-- || \\ // || // \\ || // || // \\ || || || || \\
-- || \\ // || // \\ || // || // \\ \\ || || || \\
-- || \\// || // \\ ||// || // \\ \\-_-_-_-_-|| ||-_-_-_-_-_ || \\
--
--
-- ||-_-_-_- || || || //-_-_-_-_-_-
-- || || || || || //
-- ||_-_-_|| || || || //
-- || || || || \\
-- || || \\ // \\
-- || || \\ // //
-- || ||-_-_-_-_ \\-_-_-_-// -_-_-_-_-_-//
--
--By @ali_ghoghnoos
--@telemanager_ch
| gpl-2.0 |
nasomi/darkstar | scripts/globals/weaponskills/blade_teki.lua | 30 | 1242 | -----------------------------------
-- Blade Teki
-- Katana weapon skill
-- Skill Level: 70
-- Decription: Deals water elemental damage. Damage varies with TP.
-- Aligned with the Aqua Gorget.
-- Aligned with the Aqua Belt.
-- Element: Water
-- Modifiers: STR:20% ; INT:20%
-- 100%TP 200%TP 300%TP
-- 0.50 0.75 1.00
-----------------------------------
require("scripts/globals/magic");
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
-----------------------------------
function onUseWeaponSkill(player, target, wsID)
local params = {};
params.ftp100 = 0.5; params.ftp200 = 0.75; params.ftp300 = 1;
params.str_wsc = 0.2; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.2; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
params.ele = ELE_WATER;
params.skill = SKILL_KAT;
params.includemab = true;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.str_wsc = 0.3; params.int_wsc = 0.3;
end
local damage, criticalHit, tpHits, extraHits = doMagicWeaponskill(player, target, params);
damage = damage * WEAPON_SKILL_POWER
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
dmccuskey/dmc-states-mixin | dmc_corona_boot.lua | 47 | 15406 | --====================================================================--
-- dmc_corona_boot.lua
--
-- utility to read in configuration file for dmc-corona-library
--
-- Documentation:
--====================================================================--
--[[
The MIT License (MIT)
Copyright (C) 2013-2015 David McCuskey. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
--]]
--====================================================================--
--== DMC Corona Library : DMC Corona Boot
--====================================================================--
-- Semantic Versioning Specification: http://semver.org/
local VERSION = "1.5.2"
--====================================================================--
--== Imports
local has_json, json = pcall( require, 'json' )
if not has_json then json = nil end
--====================================================================--
--== Setup, Constants
local sfind = string.find
local sgmatch = string.gmatch
local sgsub = string.gsub
local tconcat = table.concat
local tinsert = table.insert
local tremove = table.remove
--====================================================================--
--== Setup Support
--====================================================================--
local Utils = {} -- make copying from dmc_utils easier
function Utils.extend( fromTable, toTable )
function _extend( fT, tT )
for k,v in pairs( fT ) do
if type( fT[ k ] ) == "table" and
type( tT[ k ] ) == "table" then
tT[ k ] = _extend( fT[ k ], tT[ k ] )
elseif type( fT[ k ] ) == "table" then
tT[ k ] = _extend( fT[ k ], {} )
else
tT[ k ] = v
end
end
return tT
end
return _extend( fromTable, toTable )
end
-- split string up in parts, using separator
-- returns array of pieces
function Utils.split( str, sep )
if sep == nil then
sep = "%s"
end
local t, i = {}, 1
for str in string.gmatch( str, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
function Utils.propertyIn( list, property )
for i = 1, #list do
if list[i] == property then return true end
end
return false
end
function Utils.guessPathPlatform( path )
-- print( "Utils.guessPathPlatform", path )
local win, ios = 0, 0
for match in sgmatch( path, '\\' ) do
win=win+1
end
for match in sgmatch( path, '/' ) do
ios=ios+1
end
if win>ios then
return '\\'
else
return '/'
end
end
-- takes System Path to Lua module dot
-- eg, lib.dmc_lua.lua_object >> lib/dmc_lua/lua_object
--
function Utils.sysPathToRequirePath( sys_path )
-- print( "sysPathToRequirePath", sys_path )
local sys_tbl = Utils.split( sys_path, Utils.guessPathPlatform( sys_path ) )
-- clean off any dots
for i=#sys_tbl, 1, -1 do
if sys_tbl[i]=='.' then
tremove( sys_tbl, i )
end
end
return tconcat( sys_tbl, '.' )
end
--== Start lua_files copies ==--
-- version 0.2.0
local File = {}
--======================================================--
-- fileExists()
function File.fileExists( file_path )
-- print( "File.fileExists", file_path )
local has_file, _ = pcall( function()
local result = assert( io.open( file_path, 'r' ) )
io.close( result )
end)
return has_file
end
--====================================================================--
--== readFile() ==--
function File._openCloseFile( file_path, read_f, options )
-- print( "File.readFile", file_path )
assert( type(file_path)=='string', "file path is not string" )
assert( type(read_f)=='function', "read function is not function" )
--==--
local fh = assert( io.open(file_path, 'r') )
local contents = read_f( fh )
io.close( fh )
return contents
end
function File._readLines( fh )
local contents = {}
for line in fh:lines() do
tinsert( contents, line )
end
return contents
end
function File.readFileLines( file_path, options )
return File._openCloseFile( file_path, File._readLines, options )
end
function File._readContents( fh )
return fh:read( '*all' )
end
function File.readFileContents( file_path, options )
return File._openCloseFile( file_path, File._readContents, options )
end
function File.readFile( file_path, options )
options = options or {}
options.lines = options.lines == nil and true or options.lines
--==--
if options.lines == true then
return File.readFileLines( file_path, options )
else
return File.readFileContents( file_path, options )
end
end
--====================================================================--
--== read/write JSONFile() ==--
function File.convertJsonToLua( json_str )
assert( json ~= nil, 'JSON library not loaded' )
assert( type(json_str)=='string' )
assert( #json_str > 0 )
--==--
local data = json.decode( json_str )
assert( data~=nil, "Error reading JSON file, probably malformed data" )
return data
end
--====================================================================--
--== readConfigFile() ==--
-- types of possible keys for a line
local KEY_TYPES = { 'boolean', 'bool', 'file', 'integer', 'int', 'json', 'path', 'string', 'str' }
function File.getLineType( line )
-- print( "File.getLineType", #line, line )
assert( type(line)=='string' )
--==--
local is_section, is_key = false, false
if #line > 0 then
is_section = ( string.find( line, '%[%u', 1, false ) == 1 )
is_key = ( string.find( line, '%u', 1, false ) == 1 )
end
return is_section, is_key
end
function File.processSectionLine( line )
-- print( "File.processSectionLine", line )
assert( type(line)=='string', "expected string as parameter" )
assert( #line > 0 )
--==--
local key = line:match( "%[([%u_]+)%]" )
assert( type(key) ~= 'nil', "key not found in line: "..tostring(line) )
return string.lower( key ) -- use only lowercase inside of module
end
function File.processKeyLine( line )
-- print( "File.processKeyLine", line )
assert( type(line)=='string', "expected string as parameter" )
assert( #line > 0 )
--==--
-- split up line into key/value
local raw_key, raw_val = line:match( "([%u_:]+)%s*=%s*(.-)%s*$" )
-- split up key parts
local keys = {}
for k in string.gmatch( raw_key, "([^:]+)") do
tinsert( keys, #keys+1, k )
end
-- trim off quotes, make sure balanced
local q1, q2, trim
q1, trim, q2 = raw_val:match( "^(['\"]?)(.-)(['\"]?)$" )
assert( q1 == q2, "quotes must match" )
-- process key and value
local key_name, key_type = unpack( keys )
key_name = File.processKeyName( key_name )
key_type = File.processKeyType( key_type )
-- get final value
local key_value
if key_type and Utils.propertyIn( KEY_TYPES, key_type ) then
local method = 'castTo_'..key_type
key_value = File[method]( trim )
else
key_value = File.castTo_string( trim )
end
return key_name, key_value
end
function File.processKeyName( name )
-- print( "File.processKeyName", name )
assert( type(name)=='string', "expected string as parameter" )
assert( #name > 0, "no length for name" )
--==--
return string.lower( name ) -- use only lowercase inside of module
end
-- allows nil to be passed in
function File.processKeyType( name )
-- print( "File.processKeyType", name )
--==--
if type(name)=='string' then
name = string.lower( name ) -- use only lowercase inside of module
end
return name
end
function File.castTo_boolean( value )
assert( type(value)=='string' )
--==--
if value == 'true' then return true
else return false end
end
File.castTo_bool = File.castTo_boolean
function File.castTo_file( value )
return File.castTo_string( value )
end
function File.castTo_integer( value )
assert( type(value)=='string' )
--==--
local num = tonumber( value )
assert( type(num) == 'number' )
return num
end
File.castTo_int = File.castTo_integer
function File.castTo_json( value )
assert( type(value)=='string' )
--==--
return File.convertJsonToLua( value )
end
function File.castTo_path( value )
assert( type(value)=='string' )
--==--
return string.gsub( value, '[/\\]', "." )
end
function File.castTo_string( value )
assert( type(value)~='nil' and type(value)~='table' )
return tostring( value )
end
File.castTo_str = File.castTo_string
function File.parseFileLines( lines, options )
-- print( "parseFileLines", #lines )
assert( options, "options parameter expected" )
assert( options.default_section, "options table requires 'default_section' entry" )
--==--
local curr_section = options.default_section
local config_data = {}
config_data[ curr_section ]={}
for _, line in ipairs( lines ) do
local is_section, is_key = File.getLineType( line )
-- print( line, is_section, is_key )
if is_section then
curr_section = File.processSectionLine( line )
if not config_data[ curr_section ] then
config_data[ curr_section ]={}
end
elseif is_key then
local key, val = File.processKeyLine( line )
config_data[ curr_section ][key] = val
end
end
return config_data
end
-- @param file_path string full path to file
--
function File.readConfigFile( file_path, options )
-- print( "File.readConfigFile", file_path )
options = options or {}
options.default_section = options.default_section or File.DEFAULT_CONFIG_SECTION
--==--
return File.parseFileLines( File.readFileLines( file_path ), options )
end
--== End lua_files copies ==--
--====================================================================--
--== Setup DMC Corona Library Config
--====================================================================--
--[[
This is standard code to bootstrap the dmc-corona-library
it looks for a configuration file to read
--]]
local DMC_CORONA_CONFIG_FILE = 'dmc_corona.cfg'
local DMC_CORONA_DEFAULT_SECTION = 'dmc_corona'
-- locations of third party libs used by dmc_corona
local THIRD_LIBS = {}
--- add 'lib/dmc' location
tinsert( THIRD_LIBS, tconcat( {'lib','dmc_lua'}, '.' ) )
local REQ_STACK = {}
local function pushStack( value )
-- print( "pre stack (pre):", #REQ_STACK)
tinsert( REQ_STACK, value )
end
local function popStack()
-- print( "pop stack (pre):", #REQ_STACK)
if REQ_STACK == 0 then
-- print( "nothing ins stack")
error( "!!!! nothing in stack" )
end
return tremove( REQ_STACK )
end
local wrapError, unwrapError, processError
wrapError = function( stack, message, level )
-- we package or unpackage
local package = { stack, message, level }
return processError( stack, package )
end
unwrapError = function( package )
return unpack( package )
end
processError = function( stack, package )
if stack==0 then
local stack, message, level = unwrapError( package )
return message, level
else
return package
end
end
local function newRequireFunction( module_name )
-- print( "dmc_require: ", module_name )
assert( type(module_name)=='string', "dmc_require: expected string module name" )
--==--
local _paths = _G.__dmc_require.paths
local _require = _G.__dmc_require.require
local lua_paths = Utils.extend( _paths, {} )
tinsert( lua_paths, 1, '' ) -- add search at root-level
local err_tbl = {}
local library, err = nil, nil
local idx = 1
pushStack( module_name )
repeat
local mod_path = lua_paths[idx]
local path = ( mod_path=='' and mod_path or mod_path..'.' ) .. module_name
local has_module, result = pcall( _require, path )
if has_module then
library = result
elseif type( result )=='table' then
-- this is a packaged error from the call-stack
-- now we're just trying to show it
-- so we have to unwind the call-stack
err = result
else
-- we just got error from Lua, so we need to handle it
if sfind( result, "module '.+' not found" ) then
-- "module not found"
-- pass on this because we could have more places to check
elseif sfind( result, "error loading module" ) then
-- "error loading module"
-- we can't proceed with this error, so
-- package up to travel back up call-stack
result="\n\n"..result
err = wrapError( #REQ_STACK, result, 2 )
else
-- we have some unknown error
err = wrapError( #REQ_STACK, result, 3 )
end
end
idx=idx+1
until err or library or idx > #lua_paths
popStack()
if err then
error( processError( #REQ_STACK, err ) )
elseif not library then
-- print("not found")
local emsg = string.format( "\nThe module '%s' not found in archive:", tostring( module_name) )
error( wrapError( #REQ_STACK, debug.traceback( emsg ), 3 ))
end
return library
end
-- read in the config file for dmc-corona
local function readDMCConfiguration()
-- print( "readDMCConfiguration" )
-- check if a module has tried to read config
if _G.__dmc_corona ~= nil then return end
local file_path, config_data
local dmc_lib_data
file_path = system.pathForFile( DMC_CORONA_CONFIG_FILE, system.ResourceDirectory )
if file_path ~= nil then
config_data = File.readConfigFile( file_path, { default_section=DMC_CORONA_DEFAULT_SECTION } )
end
-- make sure we have defaults for data areas
_G.__dmc_corona = config_data or {}
dmc_lib_data = _G.__dmc_corona
dmc_lib_data.dmc_corona = dmc_lib_data.dmc_corona or {}
end
local function setupDMCRequireStruct()
-- print( "setupDMCRequireStruct" )
if _G.__dmc_require ~= nil then return end
_G.__dmc_require = {
paths={},
require=_G.require, -- orig require method
pkg_path = package.path -- orig package path
}
end
local function setupRequireLoading()
-- print( "setupRequireLoading" )
if _G.__dmc_require ~= nil then return end
setupDMCRequireStruct()
local dmc_corona_info = _G.__dmc_corona.dmc_corona
local req_paths = _G.__dmc_require.paths
local sys2reqPath = Utils.sysPathToRequirePath
local path_info = dmc_corona_info.lua_path or {}
-- modify the search paths, also adding 3rd party lib locations
for i=1,#path_info do
local mod_path, third_path
mod_path = sys2reqPath( path_info[i] )
-- print( ">s1", mod_path )
tinsert( req_paths, mod_path )
for i=1,#THIRD_LIBS do
third_path = THIRD_LIBS[i]
-- print( ">s2", mod_path..'.'..third_path )
tinsert( req_paths, mod_path..'.'..third_path )
end
end
end
-- useRequireLoading()
-- setup alternate require() method
--
local function useRequireLoading()
-- print( "useRequireLoading" )
setupRequireLoading() -- must be first
_G.require=newRequireFunction
end
-- setupModuleLoadingMethod()
--
local function setupModuleLoadingMethod( )
-- print( "setupModuleLoadingMethod" )
setupRequireLoading() -- must be first
_G.require=newRequireFunction
end
readDMCConfiguration()
setupModuleLoadingMethod()
| mit |
icplus/OP-SDK | package/ramips/ui/luci-mtk/src/modules/admin-full/luasrc/model/cbi/admin_network/wifi_add.lua | 35 | 5096 | --[[
LuCI - Lua Configuration Interface
Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
]]--
local fs = require "nixio.fs"
local nw = require "luci.model.network"
local fw = require "luci.model.firewall"
local uci = require "luci.model.uci".cursor()
local http = require "luci.http"
local iw = luci.sys.wifi.getiwinfo(http.formvalue("device"))
local has_firewall = fs.access("/etc/config/firewall")
if not iw then
luci.http.redirect(luci.dispatcher.build_url("admin/network/wireless"))
return
end
m = SimpleForm("network", translate("Join Network: Settings"))
m.cancel = translate("Back to scan results")
m.reset = false
function m.on_cancel()
local dev = http.formvalue("device")
http.redirect(luci.dispatcher.build_url(
dev and "admin/network/wireless_join?device=" .. dev
or "admin/network/wireless"
))
end
nw.init(uci)
fw.init(uci)
m.hidden = {
device = http.formvalue("device"),
join = http.formvalue("join"),
channel = http.formvalue("channel"),
mode = http.formvalue("mode"),
bssid = http.formvalue("bssid"),
wep = http.formvalue("wep"),
wpa_suites = http.formvalue("wpa_suites"),
wpa_version = http.formvalue("wpa_version")
}
if iw and iw.mbssid_support then
replace = m:field(Flag, "replace", translate("Replace wireless configuration"),
translate("An additional network will be created if you leave this unchecked."))
function replace.cfgvalue() return "1" end
else
replace = m:field(DummyValue, "replace", translate("Replace wireless configuration"))
replace.default = translate("The hardware is not multi-SSID capable and the existing " ..
"configuration will be replaced if you proceed.")
function replace.formvalue() return "1" end
end
if http.formvalue("wep") == "1" then
key = m:field(Value, "key", translate("WEP passphrase"),
translate("Specify the secret encryption key here."))
key.password = true
key.datatype = "wepkey"
elseif (tonumber(m.hidden.wpa_version) or 0) > 0 and
(m.hidden.wpa_suites == "PSK" or m.hidden.wpa_suites == "PSK2")
then
key = m:field(Value, "key", translate("WPA passphrase"),
translate("Specify the secret encryption key here."))
key.password = true
key.datatype = "wpakey"
--m.hidden.wpa_suite = (tonumber(http.formvalue("wpa_version")) or 0) >= 2 and "psk2" or "psk"
end
newnet = m:field(Value, "_netname_new", translate("Name of the new network"),
translate("The allowed characters are: <code>A-Z</code>, <code>a-z</code>, " ..
"<code>0-9</code> and <code>_</code>"
))
newnet.default = m.hidden.mode == "Ad-Hoc" and "mesh" or "wwan"
newnet.datatype = "uciname"
if has_firewall then
fwzone = m:field(Value, "_fwzone",
translate("Create / Assign firewall-zone"),
translate("Choose the firewall zone you want to assign to this interface. Select <em>unspecified</em> to remove the interface from the associated zone or fill out the <em>create</em> field to define a new zone and attach the interface to it."))
fwzone.template = "cbi/firewall_zonelist"
fwzone.default = m.hidden.mode == "Ad-Hoc" and "mesh" or "wan"
end
function newnet.parse(self, section)
local net, zone
if has_firewall then
local zval = fwzone:formvalue(section)
zone = fw:get_zone(zval)
if not zone and zval == '-' then
zval = m:formvalue(fwzone:cbid(section) .. ".newzone")
if zval and #zval > 0 then
zone = fw:add_zone(zval)
end
end
end
local wdev = nw:get_wifidev(m.hidden.device)
wdev:set("disabled", false)
wdev:set("channel", m.hidden.channel)
if replace:formvalue(section) then
local n
for _, n in ipairs(wdev:get_wifinets()) do
wdev:del_wifinet(n)
end
end
local wconf = {
device = m.hidden.device,
ssid = m.hidden.join,
mode = (m.hidden.mode == "Ad-Hoc" and "adhoc" or "sta")
}
if m.hidden.wep == "1" then
wconf.encryption = "wep-open"
wconf.key = "1"
wconf.key1 = key and key:formvalue(section) or ""
elseif (tonumber(m.hidden.wpa_version) or 0) > 0 then
wconf.encryption = (tonumber(m.hidden.wpa_version) or 0) >= 2 and "psk2" or "psk"
wconf.key = key and key:formvalue(section) or ""
else
wconf.encryption = "none"
end
if wconf.mode == "adhoc" or wconf.mode == "sta" then
wconf.bssid = m.hidden.bssid
end
local value = self:formvalue(section)
net = nw:add_network(value, { proto = "dhcp" })
if not net then
self.error = { [section] = "missing" }
else
wconf.network = net:name()
local wnet = wdev:add_wifinet(wconf)
if wnet then
if zone then
fw:del_network(net:name())
zone:add_network(net:name())
end
uci:save("wireless")
uci:save("network")
uci:save("firewall")
luci.http.redirect(wnet:adminlink())
end
end
end
if has_firewall then
function fwzone.cfgvalue(self, section)
self.iface = section
local z = fw:get_zone_by_network(section)
return z and z:name()
end
end
return m
| gpl-2.0 |
nasomi/darkstar | scripts/globals/items/cup_of_choco-delight.lua | 35 | 1167 | -----------------------------------------
-- ID: 4283
-- Item: cup_of_choco-delight
-- Food Effect: 240Min, All Races
-----------------------------------------
-- Magic Regen While Healing 5
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,14400,4283);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_MPHEAL, 5);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_MPHEAL, 5);
end;
| gpl-3.0 |
nasomi/darkstar | scripts/zones/Selbina/npcs/Explorer_Moogle.lua | 17 | 1768 | -----------------------------------
-- Area: Selbina
-- NPC: Explorer Moogle
-----------------------------------
package.loaded["scripts/zones/Selbina/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Selbina/TextIDs");
require("scripts/globals/settings");
require("scripts/globals/teleports");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
accept = 0;
event = 0x046f;
if (player:getGil() < 300) then
accept = 1;
end
if (player:getMainLvl() < EXPLORER_MOOGLE_LEVELCAP) then
event = event + 1;
end
player:startEvent(event,player:getZoneID(),0,accept);
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 price = 300;
if (csid == 0x046f) then
if (option == 1 and player:delGil(price)) then
toExplorerMoogle(player,231);
elseif (option == 2 and player:delGil(price)) then
toExplorerMoogle(player,234);
elseif (option == 3 and player:delGil(price)) then
toExplorerMoogle(player,240);
elseif (option == 4 and player:delGil(price)) then
toExplorerMoogle(player,248);
elseif (option == 5 and player:delGil(price)) then
toExplorerMoogle(player,249);
end
end
end; | gpl-3.0 |
codeacula/achaea-neko | Services/gmcp.lua | 1 | 1070 | -- GMCP service
local GmcpService = {}
Neko.gmcp = GmcpService
GmcpService.handlers = {}
function GmcpService.handle(msg, data)
if not GmcpService.handlers[msg] then return end
for _, func in ipairs(GmcpService.handlers[msg]) do
func(data)
end
end
function GmcpService.printHandles()
-- The end of the things
local ends = "+"
for i = 1, 98 do ends = ends.."-" end
ends = ends.."+\n"
local commandFormat = " %-25s"
local descriptionFormat = " %-70s"
Text.display(Text.colors.green, " GMCP Events Handled\n")
Text.display(Text.colors.white, ends)
local msgName = {}
for msg, _ in pairs(GmcpService.handlers) do
table.insert(msgName, msg)
end
table.sort(msgName)
Text.display(Text.colors.nekoLMessageText, table.concat(msgName, "\n").."\n")
return false
end
function GmcpService.register(msg, callback)
if not GmcpService.handlers[msg] then
GmcpService.handlers[msg] = {}
end
table.insert(GmcpService.handlers[msg], callback)
end
Neko.aliases.register("^`gmcp$", GmcpService.printHandles, "Displays a list of handled GMCP messages") | mit |
nasomi/darkstar | scripts/globals/effects/aftermath.lua | 18 | 2588 | -----------------------------------
--
-- EFFECT_AFTERMATH
--
-----------------------------------
require("scripts/globals/status");
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
local power = effect:getPower();
if (effect:getSubPower() == 1) then
target:addMod(MOD_SUBTLE_BLOW,power);
elseif (effect:getSubPower() == 2) then
target:addMod(MOD_CRITHITRATE,power)
elseif (effect:getSubPower() == 3) then
target:addMod(MOD_REGEN,power)
elseif (effect:getSubPower() == 4) then
target:addMod(MOD_ATTP,power)
elseif (effect:getSubPower() == 5) then
target:addMod(MOD_DMG,power)
elseif (effect:getSubPower() == 6) then
target:addMod(MOD_HASTE_GEAR,power)
elseif (effect:getSubPower() == 7) then
target:addMod(MOD_SPIKES,5)
target:addMod(MOD_SPIKES_DMG,power)
elseif (effect:getSubPower() == 8) then
target:addMod(MOD_STORETP,power)
elseif (effect:getSubPower() == 9) then
target:addMod(MOD_ACC,power)
elseif (effect:getSubPower() == 10) then
target:addMod(MOD_REFRESH,power)
elseif (effect:getSubPower() == 11) then
target:addMod(MOD_ENMITY,power)
elseif (effect:getSubPower() == 12) then
target:addMod(MOD_RACC,power)
end
end;
-----------------------------------
-- onEffectTick Action
-----------------------------------
function onEffectTick(target,effect)
end;
-----------------------------------
-- onEffectLose Action
-----------------------------------
function onEffectLose(target,effect)
local power = effect:getPower();
if (effect:getSubPower() == 1) then
target:delMod(MOD_SUBTLE_BLOW,power);
elseif (effect:getSubPower() == 2) then
target:delMod(MOD_CRITHITRATE,power)
elseif (effect:getSubPower() == 3) then
target:delMod(MOD_REGEN,power)
elseif (effect:getSubPower() == 4) then
target:delMod(MOD_ATTP,power)
elseif (effect:getSubPower() == 5) then
target:delMod(MOD_DMG,power)
elseif (effect:getSubPower() == 6) then
target:delMod(MOD_HASTE_GEAR,power)
elseif (effect:getSubPower() == 7) then
target:delMod(MOD_SPIKES,5);
target:delMod(MOD_SPIKES_DMG,power)
elseif (effect:getSubPower() == 8) then
target:delMod(MOD_STORETP,power)
elseif (effect:getSubPower() == 9) then
target:delMod(MOD_ACC,power)
elseif (effect:getSubPower() == 10) then
target:delMod(MOD_REFRESH,power)
elseif (effect:getSubPower() == 11) then
target:delMod(MOD_ENMITY,power)
elseif (effect:getSubPower() == 12) then
target:delMod(MOD_RACC,power)
end
end; | gpl-3.0 |
nasomi/darkstar | scripts/zones/Dynamis-Bastok/Zone.lua | 28 | 2474 | -----------------------------------
--
-- Zone: Dynamis-Bastok
--
-----------------------------------
package.loaded["scripts/zones/Dynamis-Bastok/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/status");
require("scripts/zones/Dynamis-Bastok/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onConquestUpdate
-----------------------------------
function onConquestUpdate(zone, updatetype)
local players = zone:getPlayers();
for name, player in pairs(players) do
conquestUpdate(zone, player, updatetype, CONQUEST_BASE);
end
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
local realDay = os.time();
local dynaWaitxDay = player:getVar("dynaWaitxDay");
if ((dynaWaitxDay + (BETWEEN_2DYNA_WAIT_TIME * 24 * 60 * 60)) < realDay or player:getVar("DynamisID") == GetServerVariable("[DynaBastok]UniqueID")) then
if (player:isBcnmsFull() == 1) then
if (player:hasStatusEffect(EFFECT_DYNAMIS, 0) == false) then
inst = player:addPlayerToDynamis(1280);
if (inst == 1) then
player:bcnmEnter(1280);
else
cs = 0;
end
else
player:bcnmEnter(1280);
end
else
inst = player:bcnmRegister(1280);
if (inst == 1) then
player:bcnmEnter(1280);
else
cs = 0;
end
end
else
cs = 0;
end
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0) then
player:setPos(112.000,0.994,-72.000,127,0xEA);
end
end; | gpl-3.0 |
nasomi/darkstar | scripts/zones/Inner_Horutoto_Ruins/npcs/_5cr.lua | 17 | 2440 | -----------------------------------
-- Area: Inner Horutoto Ruins
-- NPC: _5cr (Magical Gizmo) #3
-- Involved In Mission: The Horutoto Ruins Experiment
-----------------------------------
package.loaded["scripts/zones/Inner_Horutoto_Ruins/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/missions");
require("scripts/zones/Inner_Horutoto_Ruins/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
-- The Magical Gizmo Number, this number will be compared to the random
-- value created by the mission The Horutoto Ruins Experiment, when you
-- reach the Gizmo Door and have the cutscene
local magical_gizmo_no = 3; -- of the 6
-- Check if we are on Windurst Mission 1-1
if (player:getCurrentMission(WINDURST) == THE_HORUTOTO_RUINS_EXPERIMENT and player:getVar("MissionStatus") == 2) then
-- Check if we found the correct Magical Gizmo or not
if (player:getVar("MissionStatus_rv") == magical_gizmo_no) then
player:startEvent(0x0034);
else
if (player:getVar("MissionStatus_op3") == 2) then
-- We've already examined this
player:messageSpecial(EXAMINED_RECEPTACLE);
else
-- Opened the wrong one
player:startEvent(0x0035);
end
end
end
return 1;
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 we just finished the cutscene for Windurst Mission 1-1
-- The cutscene that we opened the correct Magical Gizmo
if (csid == 0x0034) then
player:setVar("MissionStatus",3);
player:setVar("MissionStatus_rv", 0);
player:addKeyItem(CRACKED_MANA_ORBS);
player:messageSpecial(KEYITEM_OBTAINED,CRACKED_MANA_ORBS);
elseif (csid == 0x0035) then
-- Opened the wrong one
player:setVar("MissionStatus_op3", 2);
-- Give the message that thsi orb is not broken
player:messageSpecial(NOT_BROKEN_ORB);
end
end; | gpl-3.0 |
ngeiswei/ardour | share/scripts/mixer_settings_store.lua | 2 | 10434 | ardour {
["type"] = "EditorAction",
name = "Store Mixer Settings",
author = "Mixbus Team",
description = [[
Stores the current Mixer state as a file
that can be read and recalled arbitrarily
by its companion script, Recall Mixer Settings.
Supports: processor settings, grouping,
mute, solo, gain, trim, pan and processor ordering,
plus re-adding certain deleted plugins.
]]
}
function factory (params)
return function ()
local user_cfg = ARDOUR.user_config_directory(-1)
local folder_path = ARDOUR.LuaAPI.build_filename(Session:path(), 'mixer_settings')
local p = params or {}
local args = p[1] or ""
if args=="global_path" then
folder_path = ARDOUR.LuaAPI.build_filename(user_cfg, 'mixer_settings')
end
function exists(file)
local ok, err, code = os.rename(file, file)
if not ok then
if code == 13 then -- Permission denied, but it exists
return true
end
end return ok, err
end
function whoami()
if not pcall(function() local first_check = Session:get_mixbus(0) end) then
return "Ardour"
else
local second_check = Session:get_mixbus(11)
if second_check:isnil() then
return "Mixbus"
else
return "32C"
end
end
end
function isdir(path)
return exists(path.."/")
end
function setup_paths()
local local_ok = false
if not(isdir(folder_path)) then
local_ok, _, _ = os.execute('mkdir '.. folder_path)
if local_ok == 0 then
local_ok = true
end
else
local_ok = true
end
return local_ok
end
function get_processor_by_name(track, name)
local i = 0
local proc = track:nth_processor(i)
repeat
if(proc:display_name() == name) then
return proc
else
i = i + 1
end
proc = track:nth_processor(i)
until proc:isnil()
end
function group_by_id(id)
local id = tonumber(id)
for g in Session:route_groups():iter() do
local group_id = tonumber(g:to_stateful():id():to_s())
if group_id == id then return g end
end
end
function group_by_name(name)
for g in Session:route_groups():iter() do
if g:name() == name then return g end
end
end
function route_groupid_interrogate(t)
local group = false
for g in Session:route_groups():iter() do
for r in g:route_list():iter() do
if r:name() == t:name() then group = g:to_stateful():id():to_s() end
end
end return group
end
function route_group_interrogate(t)
for g in Session:route_groups():iter() do
for r in g:route_list():iter() do
if r:name() == t:name() then return g end
end
end
end
function empty_last_store(path) --empty current file from last run
local file = io.open(path, "w")
--file:write(string.format("instance = { whoami = '%s' }", whoami())
file:write("")
file:close()
end
function mark_tracks(selected, path)
empty_last_store(path)
local route_string = [[instance = {
route_id = %d,
route_name = '%s',
gain_control = %s,
trim_control = %s,
pan_control = %s,
sends = {%s},
muted = %s,
soloed = %s,
order = {%s},
cache = {%s},
group = %s,
group_name = '%s',
pi_order = %d
}]]
local group_string = [[instance = {
group_id = %s,
name = '%s',
routes = {%s},
}]]
local processor_string = [[instance = {
plugin_id = %d,
type = %d,
display_name = '%s',
owned_by_route_name = '%s',
owned_by_route_id = %d,
parameters = {%s},
active = %s,
}]]
local group_route_string = " [%d] = %s,"
local proc_order_string = " [%d] = %d,"
local proc_cache_string = " [%d] = {'%s', %d},"
local params_string = " [%d] = %s,"
--ensure easy-to-read formatting doesn't make it through
local route_string = string.gsub(route_string, "[\n\t%s]", "")
local group_string = string.gsub(group_string, "[\n\t%s]", "")
local processor_string = string.gsub(processor_string, "[\n\t%s]", "")
local sel = Editor:get_selection ()
local groups_to_write = {}
local i = 0
local tracks = Session:get_stripables()
if selected then tracks = sel.tracks:routelist() end
for r in tracks:iter() do
local group = route_group_interrogate(r)
if group then
local already_there = false
for _, v in pairs(groups_to_write) do
if group == v then
already_there = true
end
end
if not(already_there) then
groups_to_write[#groups_to_write + 1] = group
end
end
end
for _, g in pairs(groups_to_write) do
local tmp_str = ""
for t in g:route_list():iter() do
tmp_str = tmp_str .. string.format(group_route_string, i, t:to_stateful():id():to_s())
i = i + 1
end
local group_str = string.format(
group_string,
g:to_stateful():id():to_s(),
g:name(),
tmp_str
)
file = io.open(path, "a")
file:write(group_str, "\r\n")
file:close()
end
for r in tracks:iter() do
if r:is_monitor () or r:is_auditioner () or not(r:to_vca():isnil()) then goto nextroute end -- skip special routes
r = r:to_route()
if r:isnil() then goto nextroute end
local order = ARDOUR.ProcessorList()
local x = 0
repeat
local proc = r:nth_processor(x)
if not proc:isnil() then
order:push_back(proc)
end
x = x + 1
until proc:isnil()
local route_group = route_group_interrogate(r)
if route_group then route_group = route_group:name() else route_group = "" end
local rid = r:to_stateful():id():to_s()
local pan = r:pan_azimuth_control()
if pan:isnil() then pan = false else pan = pan:get_value() end --sometimes a route doesn't have pan, like the master.
-- Get send information, if any.
local send_string = ""
local i = 0
repeat
local fmt = "{%s, %s, %s, %s}"
string.gsub(fmt, "[\n\t]", "")
local values = {}
for j, ctrl in pairs({
r:send_level_controllable(i),
r:send_enable_controllable(i),
r:send_pan_azimuth_controllable(i),
r:send_pan_azimuth_enable_controllable(i),
}) do
if not(ctrl:isnil()) then
values[#values + 1] = ctrl:get_value()
else
values[#values + 1] = "nil"
end
end
send_string = send_string .. string.format(fmt, table.unpack(values))
send_string = send_string .. ","
i = i + 1
until r:send_enable_controllable(i):isnil()
print(send_string)
local order_nmbr = 0
local tmp_order_str, tmp_cache_str = "", ""
for p in order:iter() do
local ptype
if not(p:to_insert():isnil()) then
ptype = p:to_insert():plugin(0):get_info().type
else
ptype = 99
end
local pid = p:to_stateful():id():to_s()
if not(string.find(p:display_name(), "latcomp")) then
tmp_order_str = tmp_order_str .. string.format(proc_order_string, order_nmbr, pid)
tmp_cache_str = tmp_cache_str .. string.format(proc_cache_string, pid, p:display_name(), ptype)
end
order_nmbr = order_nmbr + 1
end
local route_str = string.format(
route_string,
rid,
r:name(),
ARDOUR.LuaAPI.ascii_dtostr(r:gain_control():get_value()),
ARDOUR.LuaAPI.ascii_dtostr(r:trim_control():get_value()),
tostring(pan),
send_string,
r:muted(),
r:soloed(),
tmp_order_str,
tmp_cache_str,
route_groupid_interrogate(r),
route_group,
r:presentation_info_ptr():order()
)
file = io.open(path, "a")
file:write(route_str, "\n")
file:close()
local i = 0
while true do
local params = {}
local proc = r:nth_plugin (i)
if proc:isnil () then break end
local active = proc:active()
local id = proc:to_stateful():id():to_s()
local plug = proc:to_insert ():plugin (0)
local ptype = proc:to_insert():plugin(0):get_info().type
local n = 0
for j = 0, plug:parameter_count() - 1 do -- Iterate over all plugin parameters
if plug:parameter_is_control(j) then
local label = plug:parameter_label(j)
if plug:parameter_is_input(j) and label ~= "hidden" and label:sub(1,1) ~= "#" then
local _, _, pd = ARDOUR.LuaAPI.plugin_automation(proc, n)
local val = ARDOUR.LuaAPI.get_processor_param(proc, n, true)
-- Clamp values at plugin max and min
if val < pd.lower then
val = pd.lower
end
if val > pd.upper then
val = pd.upper
end
print(r:name(), "->", proc:display_name(), "(#".. n ..")", label, val)
params[n] = val
end
n = n + 1
end
end
i = i + 1
local tmp_params_str = ""
for k, v in pairs(params) do
tmp_params_str = tmp_params_str .. string.format(params_string, k, ARDOUR.LuaAPI.ascii_dtostr(v))
end
local proc_str = string.format(
processor_string,
id,
ptype,
proc:display_name(),
r:name(),
r:to_stateful():id():to_s(),
tmp_params_str,
active
)
file = io.open(path, "a")
file:write(proc_str, "\n")
file:close()
end
::nextroute::
end
end
local store_options = {
{ type = "label", col=0, colspan=1, align="right", title = "Name:" },
{ type = "entry", col=1, colspan=1, align="left" , key = "filename", default = Session:name(), title=""},
{ type = "hseparator", title="", col=0, colspan = 3},
{ type = "label", col=0, colspan=1, align="right", title = "Selected Tracks Only:" },
{ type = "checkbox", col=1, colspan=1, align="left", key = "selected", default = false, title = ""},
--{ type = "label", col=0, colspan=2, align="left", title = ''},
--{ type = "label", col=0, colspan=2, align="left", title = "Global Path: " .. global_path},
--{ type = "label", col=0, colspan=2, align="left", title = "Local Path: " .. folder_path},
}
local snap_num = 0
for test = 0, 12, 1 do
if string.find(args, string.format("Scene_%d", test)) then
snap_num = test
end
end
local paths_ok = setup_paths()
local filename = "Scene_" .. snap_num
local selected = false --we store 'all' routes and let the user pick what to recall later
if paths_ok then
if (snap_num==0) then
local rv = LuaDialog.Dialog("Store Mixer Settings:", store_options):run()
if not(rv) then return end
filename = rv['filename']
selected = rv['selected']
end
local store_path = ARDOUR.LuaAPI.build_filename(folder_path, string.format("%s-%s.lua", filename, whoami()))
mark_tracks(selected, store_path)
if (snap_num ~= 0) then
LuaDialog.Message ("Mixer Scenes: Store", "Stored mixer settings to: " .. store_path,
LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run()
end
end
end end
| gpl-2.0 |
nasomi/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/HomePoint#2.lua | 19 | 1220 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: HomePoint#2
-- @pos -130 0.001 -16 50
-----------------------------------
package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil;
require("scripts/globals/settings");
require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs");
require("scripts/globals/homepoint");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
homepointMenu( player, 0x21fd, 106);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x21fd) then
if (option == 1) then
player:setHomePoint();
player:messageSpecial(HOMEPOINT_SET);
else
hpTeleport( player, option);
end
end
end; | gpl-3.0 |
Gamerbude/Wasteland | mods/bucket/init.lua | 2 | 5955 | -- Minetest 0.4 mod: bucket
-- See README.txt for licensing and other information.
local LIQUID_MAX = 8 --The number of water levels when liquid_finite is enabled
minetest.register_alias("bucket", "bucket:bucket_empty")
minetest.register_alias("bucket_water", "bucket:bucket_water")
minetest.register_alias("bucket_lava", "bucket:bucket_lava")
minetest.register_craft({
output = 'bucket:bucket_empty 1',
recipe = {
{'default:steel_ingot', '', 'default:steel_ingot'},
{'', 'default:steel_ingot', ''},
}
})
bucket = {}
bucket.liquids = {}
-- Register a new liquid
-- source = name of the source node
-- flowing = name of the flowing node
-- itemname = name of the new bucket item (or nil if liquid is not takeable)
-- inventory_image = texture of the new bucket item (ignored if itemname == nil)
-- This function can be called from any mod (that depends on bucket).
function bucket.register_liquid(source, flowing, itemname, inventory_image, name)
bucket.liquids[source] = {
source = source,
flowing = flowing,
itemname = itemname,
}
bucket.liquids[flowing] = bucket.liquids[source]
if itemname ~= nil then
minetest.register_craftitem(itemname, {
description = name,
inventory_image = inventory_image,
stack_max = 1,
liquids_pointable = true,
groups = {not_in_creative_inventory=1},
on_place = function(itemstack, user, pointed_thing)
-- Must be pointing to node
if pointed_thing.type ~= "node" then
return
end
-- Call on_rightclick if the pointed node defines it
if user and not user:get_player_control().sneak then
local n = minetest.get_node(pointed_thing.under)
local nn = n.name
if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].on_rightclick then
return minetest.registered_nodes[nn].on_rightclick(pointed_thing.under, n, user, itemstack) or itemstack
end
end
local place_liquid = function(pos, node, source, flowing, fullness)
if math.floor(fullness/128) == 1 or (not minetest.setting_getbool("liquid_finite")) then
minetest.add_node(pos, {name=source, param2=fullness})
return
elseif node.name == flowing then
fullness = fullness + node.param2
elseif node.name == source then
fullness = LIQUID_MAX
end
if fullness >= LIQUID_MAX then
minetest.add_node(pos, {name=source, param2=LIQUID_MAX})
else
minetest.add_node(pos, {name=flowing, param2=fullness})
end
end
-- Check if pointing to a buildable node
local node = minetest.get_node(pointed_thing.under)
local fullness = tonumber(itemstack:get_metadata())
if not fullness then fullness = LIQUID_MAX end
if minetest.registered_nodes[node.name].buildable_to then
-- buildable; replace the node
place_liquid(pointed_thing.under, node, source, flowing, fullness)
else
-- not buildable to; place the liquid above
-- check if the node above can be replaced
local node = minetest.get_node(pointed_thing.above)
if minetest.registered_nodes[node.name].buildable_to then
place_liquid(pointed_thing.above, node, source, flowing, fullness)
else
-- do not remove the bucket with the liquid
return
end
end
return {name="bucket:bucket_empty"}
end
})
end
end
minetest.register_craftitem("bucket:bucket_empty", {
description = "Empty Bucket",
inventory_image = "bucket.png",
stack_max = 99,
liquids_pointable = true,
on_use = function(itemstack, user, pointed_thing)
-- Must be pointing to node
if pointed_thing.type ~= "node" then
return
end
-- Check if pointing to a liquid source
node = minetest.get_node(pointed_thing.under)
liquiddef = bucket.liquids[node.name]
if liquiddef ~= nil and liquiddef.itemname ~= nil and (node.name == liquiddef.source or
(node.name == liquiddef.flowing and minetest.setting_getbool("liquid_finite"))) then
minetest.add_node(pointed_thing.under, {name="air"})
if node.name == liquiddef.source then node.param2 = LIQUID_MAX end
return ItemStack({name = liquiddef.itemname, metadata = tostring(node.param2)})
end
end,
})
bucket.register_liquid(
"default:water_source",
"default:water_flowing",
"bucket:bucket_water",
"bucket_water.png",
"Water Bucket"
)
bucket.register_liquid(
"default:lava_source",
"default:lava_flowing",
"bucket:bucket_lava",
"bucket_lava.png",
"Lava Bucket"
)
minetest.register_craft({
type = "fuel",
recipe = "bucket:bucket_lava",
burntime = 60,
replacements = {{"bucket:bucket_lava", "bucket:bucket_empty"}},
})
minetest.register_craftitem("bucket:bucket_snow", {
description = "Bucket with Snow",
inventory_image = "bucket_snow.png",
groups = {not_in_creative_inventory=1},
stack_max = 1,
liquids_pointable = false,
on_use = function(itemstack, user, pointed_thing)
-- Must be pointing to node
if pointed_thing.type ~= "node" then
return
end
-- Check if is buildable to
local p = pointed_thing.above
node = minetest.get_node(p)
local def = minetest.registered_items[node.name]
if def ~= nil and def.buildable_to then
local cnt = 0
for iz = -1,1,1 do
for ix = -1,1,1 do
local np = {x=p.x+ix,y=p.y,z=p.z+iz}
local n = minetest.get_node(np)
local n_def = minetest.registered_items[n.name]
if n_def ~= nil and n_def.buildable_to and cnt < 8 then
minetest.set_node(np, {name="default:snow"})
cnt = cnt+1
nodeupdate(np)
end
end
end
return {name = "bucket:bucket_empty"}
end
end,
})
minetest.register_craft({
output = 'bucket:bucket_snow',
recipe = {
{'default:snow', 'default:snow', 'default:snow'},
{'default:snow', 'bucket:bucket_empty', 'default:snow'},
{'default:snow', 'default:snow', 'default:snow'},
}
})
minetest.register_craft({
type = "cooking",
output = "bucket:bucket_water",
recipe = "bucket:bucket_snow",
})
| gpl-3.0 |
Hello23-Ygopro/ygopro-ds | expansions/script/c27003221.lua | 1 | 1346 | --TB1-062 Teleporting Jimeze
local ds=require "expansions.utility_dbscg"
local scard,sid=ds.GetID()
function scard.initial_effect(c)
ds.EnableBattleAttribute(c)
ds.AddSetcode(c,SPECIAL_TRAIT_ALIEN,SPECIAL_TRAIT_UNIVERSE_2,SPECIAL_TRAIT_INCLUDES_UNIVERSE)
ds.AddPlayProcedure(c,COLOR_GREEN,2,1)
--energy cost down
ds.AddPermanentUpdateEnergyCost(c,-2,nil,DS_LOCATION_BATTLE,LOCATION_HAND,0,scard.ectg)
--to warp
ds.AddActivateMainSkill(c,0,DS_LOCATION_BATTLE,scard.twop,scard.twcost)
end
scard.dragon_ball_super_card=true
scard.combo_cost=0
--energy cost down
scard.ectg=aux.TargetBoolFunction(Card.IsSpecialTrait,SPECIAL_TRAIT_MAIDEN_SQUADRON)
--to warp
scard.twcost=ds.SendtoDropCost(nil,LOCATION_HAND,0,1)
function scard.twop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
Duel.SendtoWarp(c,DS_REASON_SKILL)
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(sid,1))
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_PHASE+PHASE_DRAW)
e1:SetRange(DS_LOCATION_WARP)
e1:SetCountLimit(1)
e1:SetCondition(ds.turnpcon(tp))
e1:SetOperation(scard.plop)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_DRAW+RESET_SELF_TURN)
c:RegisterEffect(e1)
end
function scard.plop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_CARD,0,sid)
Duel.Play(e:GetHandler(),0,tp,tp,false,false,DS_POS_FACEUP_ACTIVE)
end
| gpl-3.0 |
nasomi/darkstar | scripts/zones/Horlais_Peak/bcnms/double_dragonian.lua | 17 | 1772 | -----------------------------------
-- Area: Horlias peak
-- Name: double_dragonian
-- KSNM30
-----------------------------------
package.loaded["scripts/zones/Horlais_Peak/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/titles");
require("scripts/globals/quests");
require("scripts/zones/Horlais_Peak/TextIDs");
-----------------------------------
-- EXAMPLE SCRIPT
--
-- What should go here:
-- giving key items, playing ENDING cutscenes
--
-- What should NOT go here:
-- Handling of "battlefield" status, spawning of monsters,
-- putting loot into treasure pool,
-- enforcing ANY rules (SJ/number of people/etc), moving
-- chars around, playing entrance CSes (entrance CSes go in bcnm.lua)
-- 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
player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,1,0);
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);
end;
| gpl-3.0 |
shangjiyu/luci-with-extra | applications/luci-app-diag-devinfo/luasrc/controller/luci_diag/smap_common.lua | 61 | 3184 | -- Copyright 2009 Daniel Dickinson
-- Licensed to the public under the Apache License 2.0.
module("luci.controller.luci_diag.smap_common", package.seeall)
require("luci.i18n")
require("luci.util")
require("luci.sys")
require("luci.cbi")
require("luci.model.uci")
local translate = luci.i18n.translate
local DummyValue = luci.cbi.DummyValue
local SimpleSection = luci.cbi.SimpleSection
function index()
return -- no-op
end
function get_params()
local smapnets_uci = luci.model.uci.cursor()
smapnets_uci:load("luci_devinfo")
local nettable = smapnets_uci:get_all("luci_devinfo")
local i
local subnet
local smapout
local outnets = {}
i = next(nettable, nil)
while (i) do
if (smapnets_uci:get("luci_devinfo", i) == "smap_scannet") then
local scannet = smapnets_uci:get_all("luci_devinfo", i)
if scannet["subnet"] and (scannet["subnet"] ~= "") and scannet["enable"] and ( scannet["enable"] == "1") then
local output = ""
local outrow = {}
outrow["subnet"] = scannet["subnet"]
ports = "5060"
if scannet["ports"] and ( scannet["ports"] ~= "" ) then
ports = scannet["ports"]
end
outrow["timeout"] = 10
local timeout = tonumber(scannet["timeout"])
if timeout and ( timeout > 0 ) then
outrow["timeout"] = scannet["timeout"]
end
outrow["repeat_count"] = 1
local repcount = tonumber(scannet["repeat_count"])
if repcount and ( repcount > 0 ) then
outrow["repeat_count"] = scannet["repeat_count"]
end
outrow["sleepreq"] = 100
local repcount = tonumber(scannet["sleepreq"])
if repcount and ( repcount > 0 ) then
outrow["sleepreq"] = scannet["sleepreq"]
end
if scannet["interface"] and ( scannet["interface"] ~= "" ) then
outrow["interface"] = scannet["interface"]
else
outrow["interface"] = ""
end
outrow["ports"] = ports
outrow["output"] = output
outnets[i] = outrow
end
end
i = next(nettable, i)
end
return outnets
end
function command_function(outnets, i)
local interface = luci.controller.luci_diag.devinfo_common.get_network_device(outnets[i]["interface"])
return "/usr/bin/netsmap-to-devinfo -r " .. outnets[i]["subnet"] .. " -t " .. outnets[i]["timeout"] .. " -i " .. interface .. " -x -p " .. outnets[i]["ports"] .. " -c " .. outnets[i]["repeat_count"] .. " -s " .. outnets[i]["sleepreq"] .. " </dev/null"
end
function action_links(smapmap, mini)
s = smapmap:section(SimpleSection, "", translate("Actions"))
b = s:option(DummyValue, "_config", translate("Configure Scans"))
b.value = ""
if (mini) then
b.titleref = luci.dispatcher.build_url("mini", "voice", "phones", "phone_scan_config")
else
b.titleref = luci.dispatcher.build_url("admin", "network", "diag_config", "smap_devinfo_config")
end
b = s:option(DummyValue, "_scans", translate("Repeat Scans (this can take a few minutes)"))
b.value = ""
if (mini) then
b.titleref = luci.dispatcher.build_url("mini", "diag", "phone_scan")
else
b.titleref = luci.dispatcher.build_url("admin", "status", "smap_devinfo")
end
end
| apache-2.0 |
nasomi/darkstar | scripts/globals/items/serving_of_bavarois.lua | 35 | 1213 | -----------------------------------------
-- ID: 5729
-- Item: serving_of_bavarois
-- Food Effect: 3Hrs, All Races
-----------------------------------------
-- HP 20
-- Intelligence 3
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,10800,5729);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 20);
target:addMod(MOD_INT, 3);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 20);
target:delMod(MOD_INT, 3);
end;
| gpl-3.0 |
nasomi/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/Prillaure.lua | 38 | 1040 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Prillaure
-- Type: Event Scene Replayer
-- @pos -143.000 0.999 9.000 50
-----------------------------------
package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x01f7);
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 |
nasomi/darkstar | scripts/globals/spells/aspir_ii.lua | 21 | 1315 | -----------------------------------------
-- Spell: Aspir
-- Drain functions only on skill level!!
-----------------------------------------
require("scripts/globals/magic");
require("scripts/globals/status");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
local dmg = 10 + 0.575 * (caster:getSkillLevel(DARK_MAGIC_SKILL) + caster:getMod(79 + DARK_MAGIC_SKILL));
--get resist multiplier (1x if no resist)
local resist = applyResistance(caster,spell,target,caster:getStat(MOD_INT)-target:getStat(MOD_INT),DARK_MAGIC_SKILL,1.0);
--get the resisted damage
dmg = dmg*resist;
--add on bonuses (staff/day/weather/jas/mab/etc all go in this function)
dmg = addBonuses(caster,spell,target,dmg);
--add in target adjustment
dmg = adjustForTarget(target,dmg,spell:getElement());
--add in final adjustments
if (target:isUndead()) then
spell:setMsg(75); -- No effect
return dmg;
end
if (target:getMP() > dmg) then
caster:addMP(dmg);
target:delMP(dmg);
else
dmg = target:getMP();
caster:addMP(dmg);
target:delMP(dmg);
end
return dmg;
end; | gpl-3.0 |
nasomi/darkstar | scripts/globals/mobskills/Panzerfaust.lua | 25 | 1285 | ---------------------------------------------
-- Panzerfaust
--
-- Description: Strikes a target twice with an armored fist. Additional effect: Knockback
-- Type: Physical
-- Utsusemi/Blink absorb: 2 shadows
-- Range: Melee
-- Notes:
---------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------
-- onMobSkillCheck
---------------------------------------------
function onMobSkillCheck(target,mob,skill)
return 0;
end;
---------------------------------------------
-- onMobWeaponSkill
---------------------------------------------
function onMobWeaponSkill(target, mob, skill)
local numhits = 2;
local accmod = 1;
local dmgmod = 1.5;
local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,TP_NO_EFFECT);
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_PHYSICAL,MOBPARAM_BLUNT,info.hitslanded);
target:delHP(dmg);
if (mob:getName() == "Despot") then
if (mob:actionQueueAbility() == false) then
local rand = math.random(1,4); -- Panzerfaust 3-6 times
for i = 0,rand do
mob:useMobAbility(280);
end
end
end
return dmg;
end;
| gpl-3.0 |
nasomi/darkstar | scripts/globals/items/plate_of_ratatouille.lua | 35 | 1408 | -----------------------------------------
-- ID: 5731
-- Item: plate_of_ratatouille
-- Food Effect: 3Hrs, All Races
-----------------------------------------
-- Agility 5
-- Evasion 5
-- HP recovered while healing 2
-- Undead Killer 5
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,10800,5731);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_AGI, 5);
target:addMod(MOD_EVA, 5);
target:addMod(MOD_HPHEAL, 2);
target:addMod(MOD_UNDEAD_KILLER, 5);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_AGI, 5);
target:delMod(MOD_EVA, 5);
target:delMod(MOD_HPHEAL, 2);
target:delMod(MOD_UNDEAD_KILLER, 5);
end;
| gpl-3.0 |
aqasaeed/hesamjun | plugins/inrealm.lua | 287 | 25005 | -- data saved to moderation.json
-- check moderation plugin
do
local function create_group(msg)
-- superuser and admins only (because sudo are always has privilege)
if is_sudo(msg) or is_realm(msg) and is_admin(msg) then
local group_creator = msg.from.print_name
create_group_chat (group_creator, group_name, ok_cb, false)
return 'Group [ '..string.gsub(group_name, '_', ' ')..' ] has been created.'
end
end
local function create_realm(msg)
-- superuser and admins only (because sudo are always has privilege)
if is_sudo(msg) or is_realm(msg) and is_admin(msg) then
local group_creator = msg.from.print_name
create_group_chat (group_creator, group_name, ok_cb, false)
return 'Realm [ '..string.gsub(group_name, '_', ' ')..' ] has been created.'
end
end
local function killchat(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function killrealm(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function get_group_type(msg)
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
if not data[tostring(msg.to.id)]['group_type'] then
return 'No group type available.'
end
local group_type = data[tostring(msg.to.id)]['group_type']
return group_type
else
return 'Chat type not found.'
end
end
local function callbackres(extra, success, result)
--vardump(result)
local user = result.id
local name = string.gsub(result.print_name, "_", " ")
local chat = 'chat#id'..extra.chatid
send_large_msg(chat, user..'\n'..name)
return user
end
local function set_description(msg, data, target, about)
if not is_admin(msg) then
return "For admins only!"
end
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 set_rules(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local data_cat = 'rules'
data[tostring(target)][data_cat] = rules
save_data(_config.moderation.data, data)
return 'Set group rules to:\n'..rules
end
-- lock/unlock group name. bot automatically change group name when locked
local function lock_group_name(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
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_name(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
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
--lock/unlock group member. bot automatically kick new added user when locked
local function lock_group_member(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
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_member(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
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
--lock/unlock group photo. bot automatically keep group photo when locked
local function lock_group_photo(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'yes' then
return 'Group photo is already locked'
else
data[tostring(target)]['settings']['set_photo'] = 'waiting'
save_data(_config.moderation.data, data)
end
return 'Please send me the group photo now'
end
local function unlock_group_photo(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
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 lock_group_flood(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
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_flood(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
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
-- show group settings
local function show_group_settings(msg, data, target)
local data = load_data(_config.moderation.data, data)
if not is_admin(msg) then
return "For admins only!"
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
return text
end
local function returnids(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..''
for k,v in pairs(result.members) do
local username = ""
text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n"
end
send_large_msg(receiver, text)
local file = io.open("./groups/lists/"..result.id.."memberlist.txt", "w")
file:write(text)
file:flush()
file:close()
end
local function returnidsfile(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..''
for k,v in pairs(result.members) do
local username = ""
text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n"
end
local file = io.open("./groups/lists/"..result.id.."memberlist.txt", "w")
file:write(text)
file:flush()
file:close()
send_document("chat#id"..result.id,"./groups/lists/"..result.id.."memberlist.txt", ok_cb, false)
end
local function admin_promote(msg, admin_id)
if not is_sudo(msg) then
return "Access denied!"
end
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
if data[tostring(admins)][tostring(admin_id)] then
return admin_name..' is already an admin.'
end
data[tostring(admins)][tostring(admin_id)] = admin_id
save_data(_config.moderation.data, data)
return admin_id..' has been promoted as admin.'
end
local function admin_demote(msg, admin_id)
if not is_sudo(msg) then
return "Access denied!"
end
local data = load_data(_config.moderation.data)
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
if not data[tostring(admins)][tostring(admin_id)] then
return admin_id..' is not an admin.'
end
data[tostring(admins)][tostring(admin_id)] = nil
save_data(_config.moderation.data, data)
return admin_id..' has been demoted from admin.'
end
local function admin_list(msg)
local data = load_data(_config.moderation.data)
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
local message = 'List for Realm admins:\n'
for k,v in pairs(data[tostring(admins)]) do
message = message .. '- (at)' .. v .. ' [' .. k .. '] ' ..'\n'
end
return message
end
local function groups_list(msg)
local data = load_data(_config.moderation.data)
local groups = 'groups'
if not data[tostring(groups)] then
return 'No groups at the moment'
end
local message = 'List of groups:\n'
for k,v in pairs(data[tostring(groups)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairs(settings) do
if m == 'set_name' then
name = n
end
end
local group_owner = "No owner"
if data[tostring(v)]['set_owner'] then
group_owner = tostring(data[tostring(v)]['set_owner'])
end
local group_link = "No link"
if data[tostring(v)]['settings']['set_link'] then
group_link = data[tostring(v)]['settings']['set_link']
end
message = message .. '- '.. name .. ' (' .. v .. ') ['..group_owner..'] \n {'..group_link.."}\n"
end
local file = io.open("./groups/lists/groups.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function realms_list(msg)
local data = load_data(_config.moderation.data)
local realms = 'realms'
if not data[tostring(realms)] then
return 'No Realms at the moment'
end
local message = 'List of Realms:\n'
for k,v in pairs(data[tostring(realms)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairs(settings) do
if m == 'set_name' then
name = n
end
end
local group_owner = "No owner"
if data[tostring(v)]['admins_in'] then
group_owner = tostring(data[tostring(v)]['admins_in'])
end
local group_link = "No link"
if data[tostring(v)]['settings']['set_link'] then
group_link = data[tostring(v)]['settings']['set_link']
end
message = message .. '- '.. name .. ' (' .. v .. ') ['..group_owner..'] \n {'..group_link.."}\n"
end
local file = io.open("./groups/lists/realms.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function admin_user_promote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
if not data['admins'] then
data['admins'] = {}
save_data(_config.moderation.data, data)
end
if data['admins'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is already as admin.')
end
data['admins'][tostring(member_id)] = member_username
save_data(_config.moderation.data, data)
return send_large_msg(receiver, '@'..member_username..' has been promoted as admin.')
end
local function admin_user_demote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
if not data['admins'] then
data['admins'] = {}
save_data(_config.moderation.data, data)
end
if not data['admins'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is not an admin.')
end
data['admins'][tostring(member_id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Admin '..member_username..' has been demoted.')
end
local function username_id(cb_extra, success, result)
local mod_cmd = cb_extra.mod_cmd
local receiver = cb_extra.receiver
local member = cb_extra.member
local text = 'No user @'..member..' in this group.'
for k,v in pairs(result.members) do
vusername = v.username
if vusername == member then
member_username = member
member_id = v.id
if mod_cmd == 'addadmin' then
return admin_user_promote(receiver, member_username, member_id)
elseif mod_cmd == 'removeadmin' then
return admin_user_demote(receiver, member_username, member_id)
end
end
end
send_large_msg(receiver, text)
end
local function set_log_group(msg)
if not is_admin(msg) then
return
end
local log_group = data[tostring(groups)][tostring(msg.to.id)]['log_group']
if log_group == 'yes' then
return 'Log group is already set'
else
data[tostring(groups)][tostring(msg.to.id)]['log_group'] = 'yes'
save_data(_config.moderation.data, data)
return 'Log group has been set'
end
end
local function unset_log_group(msg)
if not is_admin(msg) then
return
end
local log_group = data[tostring(groups)][tostring(msg.to.id)]['log_group']
if log_group == 'no' then
return 'Log group is already disabled'
else
data[tostring(groups)][tostring(msg.to.id)]['log_group'] = 'no'
save_data(_config.moderation.data, data)
return 'log group has been disabled'
end
end
local function help()
local help_text = tostring(_config.help_text_realm)
return help_text
end
function run(msg, matches)
--vardump(msg)
local name_log = user_print_name(msg.from)
if matches[1] == 'log' and is_owner(msg) then
savelog(msg.to.id, "log file created by owner")
send_document("chat#id"..msg.to.id,"./groups/"..msg.to.id.."log.txt", ok_cb, false)
end
if matches[1] == 'who' and is_momod(msg) then
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list ")
local receiver = get_receiver(msg)
chat_info(receiver, returnidsfile, {receiver=receiver})
end
if matches[1] == 'wholist' and is_momod(msg) then
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list in a file")
local receiver = get_receiver(msg)
chat_info(receiver, returnids, {receiver=receiver})
end
if matches[1] == 'creategroup' and matches[2] then
group_name = matches[2]
group_type = 'group'
return create_group(msg)
end
if not is_sudo(msg) or not is_admin(msg) and not is_realm(msg) then
return --Do nothing
end
if matches[1] == 'createrealm' and matches[2] then
group_name = matches[2]
group_type = 'realm'
return create_realm(msg)
end
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
if matches[2] then if data[tostring(matches[2])] then
local settings = data[tostring(matches[2])]['settings']
if matches[1] == 'setabout' and matches[2] then
local target = matches[2]
local about = matches[3]
return set_description(msg, data, target, about)
end
if matches[1] == 'setrules' then
rules = matches[3]
local target = matches[2]
return set_rules(msg, data, target)
end
if matches[1] == 'lock' then --group lock *
local target = matches[2]
if matches[3] == 'name' then
return lock_group_name(msg, data, target)
end
if matches[3] == 'member' then
return lock_group_member(msg, data, target)
end
if matches[3] == 'photo' then
return lock_group_photo(msg, data, target)
end
if matches[3] == 'flood' then
return lock_group_flood(msg, data, target)
end
end
if matches[1] == 'unlock' then --group unlock *
local target = matches[2]
if matches[3] == 'name' then
return unlock_group_name(msg, data, target)
end
if matches[3] == 'member' then
return unlock_group_member(msg, data, target)
end
if matches[3] == 'photo' then
return unlock_group_photo(msg, data, target)
end
if matches[3] == 'flood' then
return unlock_group_flood(msg, data, target)
end
end
if matches[1] == 'settings' and data[tostring(matches[2])]['settings'] then
local target = matches[2]
return show_group_settings(msg, data, target)
end
if matches[1] == 'setname' and is_realm(msg) then
local new_name = string.gsub(matches[2], '_', ' ')
data[tostring(msg.to.id)]['settings']['set_name'] = new_name
save_data(_config.moderation.data, data)
local group_name_set = data[tostring(msg.to.id)]['settings']['set_name']
local to_rename = 'chat#id'..msg.to.id
rename_chat(to_rename, group_name_set, ok_cb, false)
savelog(msg.to.id, "Realm { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]")
end
if matches[1] == 'setgpname' and is_admin(msg) 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]
rename_chat(to_rename, group_name_set, ok_cb, false)
savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]")
end
end
end
if matches[1] == 'help' and is_realm(msg) then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help")
return help()
end
if matches[1] == 'set' then
if matches[2] == 'loggroup' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set as log group")
return set_log_group(msg)
end
end
if matches[1] == 'kill' and matches[2] == 'chat' then
if not is_admin(msg) then
return nil
end
if is_realm(msg) then
local receiver = 'chat#id'..matches[3]
return modrem(msg),
print("Closing Group: "..receiver),
chat_info(receiver, killchat, {receiver=receiver})
else
return 'Error: Group '..matches[3]..' not found'
end
end
if matches[1] == 'kill' and matches[2] == 'realm' then
if not is_admin(msg) then
return nil
end
if is_realm(msg) then
local receiver = 'chat#id'..matches[3]
return realmrem(msg),
print("Closing realm: "..receiver),
chat_info(receiver, killrealm, {receiver=receiver})
else
return 'Error: Realm '..matches[3]..' not found'
end
end
if matches[1] == 'chat_add_user' then
if not msg.service then
return "Are you trying to troll me?"
end
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
if not is_admin(msg) then
chat_del_user(chat, user, ok_cb, true)
end
end
if matches[1] == 'addadmin' then
if string.match(matches[2], '^%d+$') then
local admin_id = matches[2]
print("user "..admin_id.." has been promoted as admin")
return admin_promote(msg, admin_id)
else
local member = string.gsub(matches[2], "@", "")
local mod_cmd = "addadmin"
chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member})
end
end
if matches[1] == 'removeadmin' then
if string.match(matches[2], '^%d+$') then
local admin_id = matches[2]
print("user "..admin_id.." has been demoted")
return admin_demote(msg, admin_id)
else
local member = string.gsub(matches[2], "@", "")
local mod_cmd = "removeadmin"
chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member})
end
end
if matches[1] == 'type'then
local group_type = get_group_type(msg)
return group_type
end
if matches[1] == 'list' and matches[2] == 'admins' then
return admin_list(msg)
end
if matches[1] == 'list' and matches[2] == 'groups' then
if msg.to.type == 'chat' then
groups_list(msg)
send_document("chat#id"..msg.to.id, "./groups/lists/groups.txt", ok_cb, false)
return "Group list created" --group_list(msg)
elseif msg.to.type == 'user' then
groups_list(msg)
send_document("user#id"..msg.from.id, "./groups/lists/groups.txt", ok_cb, false)
return "Group list created" --group_list(msg)
end
end
if matches[1] == 'list' and matches[2] == 'realms' then
if msg.to.type == 'chat' then
realms_list(msg)
send_document("chat#id"..msg.to.id, "./groups/lists/realms.txt", ok_cb, false)
return "Realms list created" --realms_list(msg)
elseif msg.to.type == 'user' then
realms_list(msg)
send_document("user#id"..msg.from.id, "./groups/lists/realms.txt", ok_cb, false)
return "Realms list created" --realms_list(msg)
end
end
if matches[1] == 'res' and is_momod(msg) then
local cbres_extra = {
chatid = msg.to.id
}
local username = matches[2]
local username = username:gsub("@","")
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username)
return res_user(username, callbackres, cbres_extra)
end
end
return {
patterns = {
"^[!/](creategroup) (.*)$",
"^[!/](createrealm) (.*)$",
"^[!/](setabout) (%d+) (.*)$",
"^[!/](setrules) (%d+) (.*)$",
"^[!/](setname) (.*)$",
"^[!/](setgpname) (%d+) (.*)$",
"^[!/](setname) (%d+) (.*)$",
"^[!/](lock) (%d+) (.*)$",
"^[!/](unlock) (%d+) (.*)$",
"^[!/](setting) (%d+)$",
"^[!/](wholist)$",
"^[!/](who)$",
"^[!/](type)$",
"^[!/](kill) (chat) (%d+)$",
"^[!/](kill) (realm) (%d+)$",
"^[!/](addadmin) (.*)$", -- sudoers only
"^[!/](removeadmin) (.*)$", -- sudoers only
"^[!/](list) (.*)$",
"^[!/](log)$",
"^[!/](help)$",
"^!!tgservice (.+)$",
},
run = run
}
end
| gpl-2.0 |
nasomi/darkstar | scripts/globals/items/galkan_sausage_+1.lua | 35 | 1364 | -----------------------------------------
-- ID: 5859
-- Item: galkan_sausage_+1
-- Food Effect: 30Min, All Races
-----------------------------------------
-- Strength 4
-- Intelligence -5
-- Attack 10
-- Ranged Attack 10
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,1800,5859);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_STR, 4);
target:addMod(MOD_INT, -5);
target:addMod(MOD_ATT, 10);
target:addMod(MOD_RATT, 10);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_STR, 4);
target:delMod(MOD_INT, -5);
target:delMod(MOD_ATT, 10);
target:delMod(MOD_RATT, 10);
end;
| gpl-3.0 |
appaquet/torch-android | src/3rdparty/nnx/SpatialNormalization.lua | 6 | 9748 | local SpatialNormalization, parent = torch.class('nn.SpatialNormalization','nn.Module')
local help_desc =
[[a spatial (2D) contrast normalizer
? computes the local mean and local std deviation
across all input features, using the given 2D kernel
? the local mean is then removed from all maps, and the std dev
used to divide the inputs, with a threshold
? if no threshold is given, the global std dev is used
? weight replication is used to preserve sizes (this is
better than zero-padding, but more costly to compute, use
nn.ContrastNormalization to use zero-padding)
? two 1D kernels can be used instead of a single 2D kernel. This
is beneficial to integrate information over large neiborhoods.
]]
local help_example =
[[EX:
-- create a spatial normalizer, with a 9x9 gaussian kernel
-- works on 8 input feature maps, therefore the mean+dev will
-- be estimated on 8x9x9 cubes
stimulus = torch.randn(8,500,500)
gaussian = image.gaussian(9)
mod = nn.SpatialNormalization(gaussian, 8)
result = mod:forward(stimulus)]]
function SpatialNormalization:__init(...) -- kernel for weighted mean | nb of features
parent.__init(self)
print('<SpatialNormalization> WARNING: this module has been deprecated,')
print(' please use SpatialContrastiveNormalization instead')
-- get args
local args, nf, ker, thres
= xlua.unpack(
{...},
'nn.SpatialNormalization',
help_desc .. '\n' .. help_example,
{arg='nInputPlane', type='number', help='number of input maps', req=true},
{arg='kernel', type='torch.Tensor | table', help='a KxK filtering kernel or two {1xK, Kx1} 1D kernels'},
{arg='threshold', type='number', help='threshold, for division [default = adaptive]'}
)
-- check args
if not ker then
xerror('please provide kernel(s)', 'nn.SpatialNormalization', args.usage)
end
self.kernel = ker
local ker2
if type(ker) == 'table' then
ker2 = ker[2]
ker = ker[1]
end
self.nfeatures = nf
self.fixedThres = thres
-- padding values
self.padW = math.floor(ker:size(2)/2)
self.padH = math.floor(ker:size(1)/2)
self.kerWisPair = 0
self.kerHisPair = 0
-- padding values for 2nd kernel
if ker2 then
self.pad2W = math.floor(ker2:size(2)/2)
self.pad2H = math.floor(ker2:size(1)/2)
else
self.pad2W = 0
self.pad2H = 0
end
self.ker2WisPair = 0
self.ker2HisPair = 0
-- normalize kernel
ker:div(ker:sum())
if ker2 then ker2:div(ker2:sum()) end
-- manage the case where ker is even size (for padding issue)
if (ker:size(2)/2 == math.floor(ker:size(2)/2)) then
print ('Warning, kernel width is even -> not symetric padding')
self.kerWisPair = 1
end
if (ker:size(1)/2 == math.floor(ker:size(1)/2)) then
print ('Warning, kernel height is even -> not symetric padding')
self.kerHisPair = 1
end
if (ker2 and ker2:size(2)/2 == math.floor(ker2:size(2)/2)) then
print ('Warning, kernel width is even -> not symetric padding')
self.ker2WisPair = 1
end
if (ker2 and ker2:size(1)/2 == math.floor(ker2:size(1)/2)) then
print ('Warning, kernel height is even -> not symetric padding')
self.ker2HisPair = 1
end
-- create convolution for computing the mean
local convo1 = nn.Sequential()
convo1:add(nn.SpatialPadding(self.padW,self.padW-self.kerWisPair,
self.padH,self.padH-self.kerHisPair))
local ctable = nn.tables.oneToOne(nf)
convo1:add(nn.SpatialConvolutionMap(ctable,ker:size(2),ker:size(1)))
convo1:add(nn.Sum(1))
convo1:add(nn.Replicate(nf))
-- set kernel
local fb = convo1.modules[2].weight
for i=1,fb:size(1) do fb[i]:copy(ker) end
-- set bias to 0
convo1.modules[2].bias:zero()
-- 2nd ker ?
if ker2 then
local convo2 = nn.Sequential()
convo2:add(nn.SpatialPadding(self.pad2W,self.pad2W-self.ker2WisPair,
self.pad2H,self.pad2H-self.ker2HisPair))
local ctable = nn.tables.oneToOne(nf)
convo2:add(nn.SpatialConvolutionMap(ctable,ker2:size(2),ker2:size(1)))
convo2:add(nn.Sum(1))
convo2:add(nn.Replicate(nf))
-- set kernel
local fb = convo2.modules[2].weight
for i=1,fb:size(1) do fb[i]:copy(ker2) end
-- set bias to 0
convo2.modules[2].bias:zero()
-- convo is a double convo now:
local convopack = nn.Sequential()
convopack:add(convo1)
convopack:add(convo2)
self.convo = convopack
else
self.convo = convo1
end
-- create convolution for computing the meanstd
local convostd1 = nn.Sequential()
convostd1:add(nn.SpatialPadding(self.padW,self.padW-self.kerWisPair,
self.padH,self.padH-self.kerHisPair))
convostd1:add(nn.SpatialConvolutionMap(ctable,ker:size(2),ker:size(1)))
convostd1:add(nn.Sum(1))
convostd1:add(nn.Replicate(nf))
-- set kernel
local fb = convostd1.modules[2].weight
for i=1,fb:size(1) do fb[i]:copy(ker) end
-- set bias to 0
convostd1.modules[2].bias:zero()
-- 2nd ker ?
if ker2 then
local convostd2 = nn.Sequential()
convostd2:add(nn.SpatialPadding(self.pad2W,self.pad2W-self.ker2WisPair,
self.pad2H,self.pad2H-self.ker2HisPair))
convostd2:add(nn.SpatialConvolutionMap(ctable,ker2:size(2),ker2:size(1)))
convostd2:add(nn.Sum(1))
convostd2:add(nn.Replicate(nf))
-- set kernel
local fb = convostd2.modules[2].weight
for i=1,fb:size(1) do fb[i]:copy(ker2) end
-- set bias to 0
convostd2.modules[2].bias:zero()
-- convo is a double convo now:
local convopack = nn.Sequential()
convopack:add(convostd1)
convopack:add(convostd2)
self.convostd = convopack
else
self.convostd = convostd1
end
-- other operation
self.squareMod = nn.Square()
self.sqrtMod = nn.Sqrt()
self.subtractMod = nn.CSubTable()
self.meanDiviseMod = nn.CDivTable()
self.stdDiviseMod = nn.CDivTable()
self.diviseMod = nn.CDivTable()
self.thresMod = nn.Threshold()
-- some tempo states
self.coef = torch.Tensor(1,1)
self.inConvo = torch.Tensor()
self.inMean = torch.Tensor()
self.inputZeroMean = torch.Tensor()
self.inputZeroMeanSq = torch.Tensor()
self.inConvoVar = torch.Tensor()
self.inVar = torch.Tensor()
self.inStdDev = torch.Tensor()
self.thstd = torch.Tensor()
end
function SpatialNormalization:updateOutput(input)
-- auto switch to 3-channel
self.input = input
if (input:nDimension() == 2) then
self.input = input:clone():resize(1,input:size(1),input:size(2))
end
-- recompute coef only if necessary
if (self.input:size(3) ~= self.coef:size(2)) or (self.input:size(2) ~= self.coef:size(1)) then
local intVals = self.input.new(self.nfeatures,self.input:size(2),self.input:size(3)):fill(1)
self.coef = self.convo:updateOutput(intVals)
self.coef = self.coef:clone()
end
-- compute mean
self.inConvo = self.convo:updateOutput(self.input)
self.inMean = self.meanDiviseMod:updateOutput{self.inConvo,self.coef}
self.inputZeroMean = self.subtractMod:updateOutput{self.input,self.inMean}
-- compute std dev
self.inputZeroMeanSq = self.squareMod:updateOutput(self.inputZeroMean)
self.inConvoVar = self.convostd:updateOutput(self.inputZeroMeanSq)
self.inStdDevNotUnit = self.sqrtMod:updateOutput(self.inConvoVar)
self.inStdDev = self.stdDiviseMod:updateOutput({self.inStdDevNotUnit,self.coef})
local meanstd = self.inStdDev:mean()
self.thresMod.threshold = self.fixedThres or math.max(meanstd,1e-3)
self.thresMod.val = self.fixedThres or math.max(meanstd,1e-3)
self.stdDev = self.thresMod:updateOutput(self.inStdDev)
--remove std dev
self.diviseMod:updateOutput{self.inputZeroMean,self.stdDev}
self.output = self.diviseMod.output
return self.output
end
function SpatialNormalization:updateGradInput(input, gradOutput)
-- auto switch to 3-channel
self.input = input
if (input:nDimension() == 2) then
self.input = input:clone():resize(1,input:size(1),input:size(2))
end
self.gradInput:resizeAs(self.input):zero()
-- backprop all
local gradDiv = self.diviseMod:updateGradInput({self.inputZeroMean,self.stdDev},gradOutput)
local gradThres = gradDiv[2]
local gradZeroMean = gradDiv[1]
local gradinStdDev = self.thresMod:updateGradInput(self.inStdDev,gradThres)
local gradstdDiv = self.stdDiviseMod:updateGradInput({self.inStdDevNotUnit,self.coef},gradinStdDev)
local gradinStdDevNotUnit = gradstdDiv[1]
local gradinConvoVar = self.sqrtMod:updateGradInput(self.inConvoVar,gradinStdDevNotUnit)
local gradinputZeroMeanSq = self.convostd:updateGradInput(self.inputZeroMeanSq,gradinConvoVar)
gradZeroMean:add(self.squareMod:updateGradInput(self.inputZeroMean,gradinputZeroMeanSq))
local gradDiff = self.subtractMod:updateGradInput({self.input,self.inMean},gradZeroMean)
local gradinMean = gradDiff[2]
local gradinConvoNotUnit = self.meanDiviseMod:updateGradInput({self.inConvo,self.coef},gradinMean)
local gradinConvo = gradinConvoNotUnit[1]
-- first part of the gradInput
self.gradInput:add(gradDiff[1])
-- second part of the gradInput
self.gradInput:add(self.convo:updateGradInput(self.input,gradinConvo))
return self.gradInput
end
function SpatialNormalization:type(type)
parent.type(self,type)
self.convo:type(type)
self.meanDiviseMod:type(type)
self.subtractMod:type(type)
self.squareMod:type(type)
self.convostd:type(type)
self.sqrtMod:type(type)
self.stdDiviseMod:type(type)
self.thresMod:type(type)
self.diviseMod:type(type)
return self
end
| bsd-3-clause |
nasomi/darkstar | scripts/globals/weaponskills/shoulder_tackle.lua | 18 | 1562 | -----------------------------------
-- Shoulder Tackle
-- Hand-to-Hand weapon skill
-- Skill Level: 40
-- Stuns target. Chance of stunning varies with TP.
-- Will stack with Sneak Attack.
-- Aligned with the Aqua Gorget & Thunder Gorget.
-- Aligned with the Aqua Belt & Thunder Belt.
-- Element: None
-- Modifiers: VIT:100%
-- 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.0; params.dex_wsc = 0.0; params.vit_wsc = 0.3; 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;
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, params);
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.vit_wsc = 1.0;
end
if damage > 0 then
local tp = player:getTP();
local duration = (tp/50);
if (target:hasStatusEffect(EFFECT_STUN) == false) then
target:addStatusEffect(EFFECT_STUN, 1, 0, duration);
end
end
damage = damage * WEAPON_SKILL_POWER
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
C60Project/C60-PRODUCT | plugins/private.lua | 1 | 3077 | local function do_keybaord_credits()
local keyboard = {}
keyboard.inline_keyboard = {
{
{text = 'Channel', url = 'https://telegram.me/'..config.channel:gsub('@', '')},
{text = 'GitHub', url = 'https://github.com/RememberTheAir/GroupButler'},
{text = 'Rate me!', url = 'https://telegram.me/storebot?start='..bot.username},
}
}
return keyboard
end
local action = function(msg, blocks, ln)
if not(msg.chat.type == 'private') then return end
if blocks[1] == 'ping' then
api.sendMessage(msg.from.id, '*Pong!*', true)
end
if blocks[1] == 'strings' then
if not blocks[2] then
local file_id = db:get('trfile:EN')
if not file_id then return end
api.sendDocumentId(msg.chat.id, file_id, msg.message_id)
else
local l_code = blocks[2]
local exists = is_lang_supported(l_code)
if exists then
local file_id = db:get('trfile:'..l_code:upper())
if not file_id then return end
api.sendDocumentId(msg.chat.id, file_id, msg.message_id)
else
api.sendReply(msg, lang[ln].setlang.error, true)
end
end
end
if blocks[1] == 'echo' then
local res, code = api.sendMessage(msg.chat.id, blocks[2], true)
if not res then
if code == 118 then
api.sendMessage(msg.chat.id, lang[ln].bonus.too_long)
else
api.sendMessage(msg.chat.id, lang[ln].breaks_markdown, true)
end
end
end
if blocks[1] == 'c' then
if msg.chat.type ~= 'private' then
return
end
local text = 'This command *has been replaced!*\n\nNow you can start your message with an ! to communicate with the bot owner. Example:\n_!hello, how are you?_'
if config.help_group and config.help_group ~= '' then
text = text..'\n\nYou can also join the discussion group to ask your question/report a bug. You can join with [this link]('..config.help_group..')'
end
api.sendMessage(msg.chat.id, text, true)
end
if blocks[1] == '!' then
if msg.chat.type ~= 'private' then
return
end
local input = blocks[2]
local receiver = msg.from.id
--allert if not feedback
if not input and not msg.reply then
api.sendMessage(msg.from.id, lang[ln].report.no_input)
return
end
if msg.reply then
msg = msg.reply
end
api.forwardMessage (config.admin.owner, msg.from.id, msg.message_id)
api.sendMessage(receiver, lang[ln].report.sent)
end
if blocks[1] == 'info' then
local keyboard = {}
keyboard = do_keybaord_credits()
api.sendKeyboard(msg.chat.id, '`v'..config.version..'`\n'..lang[ln].credits, keyboard, true)
end
if blocks[1] == 'resolve' then
local id = res_user_group(blocks[2], msg.chat.id)
if not id then
message = lang[ln].bonus.no_user
else
message = '*'..id..'*'
end
api.sendMessage(msg.chat.id, message, true)
end
end
return {
action = action,
triggers = {
'^/(ping)$',
'^/(strings)$',
'^/(strings) (%a%a)$',
'^/(echo) (.*)$',
'^/(c)%s?',
'^(!)$',
'^(!)(.+)',
'^/(info)$',
'^/(resolve) (@[%w_]+)$',
}
} | gpl-2.0 |
jonathf/awesome | keybinds.lua | 1 | 5662 | local awful = require("awful")
awful.rules = require("awful.rules")
require("awful.autofocus")
modkey = "Mod4"
config_path = awful.util.getdir("config")
globalkeys = awful.util.table.join(
-- command keys
awful.key({modkey}, "Return", function() awful.spawn(terminal) end),
awful.key({modkey}, "v", function() awful.spawn("firefox") end),
awful.key({modkey}, "r", function() awful.spawn("rofi -show combi") end),
awful.key({modkey, "Control"}, "r", awesome.restart),
awful.key({modkey, "Control"}, "q", awesome.quit),
awful.key({modkey,}, "Escape", awful.tag.history.restore),
-- the 'j' key
awful.key({modkey}, "j",
function()
awful.client.focus.byidx(1)
if client.focus then client.focus:raise() end
end),
awful.key({modkey, "Shift"}, "j",
function() awful.client.swap.byidx(1) end),
awful.key({modkey, "Control"}, "j",
function() awful.screen.focus_relative( 1) end),
awful.key({modkey, "Control", "Shift"}, "j",
function() awful.tag.incncol(1) end),
-- the 'k' key
awful.key({modkey}, "k",
function()
awful.client.focus.byidx(-1)
if client.focus then client.focus:raise() end
end),
awful.key({modkey, "Shift"}, "k",
function() awful.client.swap.byidx(-1) end),
awful.key({modkey, "Control"}, "k",
function() awful.screen.focus_relative(-1) end),
awful.key({modkey, "Control", "Shift"}, "k",
function() awful.tag.incncol(-1) end),
-- the 'h' key
awful.key({modkey,}, "h", awful.tag.viewprev),
awful.key({modkey, "Control"}, "h",
function() awful.tag.incmwfact(-0.05) end),
awful.key({modkey, "Control", "Shift"}, "h",
function() awful.tag.incnmaster(1) end),
awful.key({modkey, "Shift"}, "h",
function()
if client.focus then
local idx = awful.tag.getidx()-1
if idx == 0 then idx = 9 end
client.focus:move_to_tag(awful.screen.focused().tags[idx])
end
awful.tag.viewprev()
end),
-- the 'l' key
awful.key({modkey}, "l", awful.tag.viewnext),
awful.key({modkey, "Control"}, "l",
function() awful.tag.incmwfact( 0.05) end),
awful.key({modkey, "Control", "Shift"}, "l",
function() awful.tag.incnmaster(-1) end),
awful.key({modkey, "Shift"}, "l",
function()
if client.focus then
local idx = awful.tag.getidx()+1
if idx == 10 then idx = 1 end
client.focus:move_to_tag(awful.screen.focused().tags[idx])
end
awful.tag.viewnext()
end),
-- the 'o' key
awful.key({modkey,}, "o", function() awful.screen.focus_relative(1) end),
awful.key({modkey, "Shift"}, "o", awful.client.movetoscreen),
-- volume, brightness and print
awful.key({}, "XF86AudioRaiseVolume", function()
awful.util.spawn("amixer -D pulse sset Master 10%+ unmute") end),
awful.key({}, "XF86AudioLowerVolume", function()
awful.util.spawn("amixer -D pulse sset Master 10%- unmute") end),
awful.key({}, "XF86AudioMute", function()
awful.util.spawn("amixer -D pulse sset Master toggle") end),
awful.key({}, "XF86MonBrightnessDown", function()
awful.spawn.with_shell(config_path .. 'xbacklight_sqrt -dec 2') end),
awful.key({}, "XF86MonBrightnessUp", function()
awful.spawn.with_shell(config_path .. 'xbacklight_sqrt -inc 3') end),
awful.key({}, "Print", function()
awful.util.spawn("scrot -e 'mv $f ~/tmp/screenshots/ 2>/dev/null'") end),
-- the 'space' key
awful.key({modkey}, "space", function()
awful.layout.inc(1, awful.screen.focused(),
awful.layout.layouts) end)
)
-- number keys:
for i = 1, 9 do
globalkeys = awful.util.table.join(globalkeys,
awful.key({modkey}, "#" .. i + 9, function()
local screen = awful.screen.focused()
local tag = screen.tags[i]
if tag then tag:view_only() end
end),
awful.key({ modkey, "Control" }, "#" .. i + 9, function()
local screen = awful.screen.focused()
local tag = screen.tags[i]
if tag then awful.tag.viewtoggle(tag) end
end),
awful.key({ modkey, "Shift" }, "#" .. i + 9, function()
if client.focus then
local tag = client.focus.screen.tags[i]
if tag then client.focus:move_to_tag(tag) end
end
local screen = awful.screen.focused()
local tag = screen.tags[i]
if tag then tag:view_only() end
end),
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, function ()
if client.focus then
local tag = client.focus.screen.tags[i]
if tag then
client.focus:toggle_tag(tag)
end
end
end)
)
end
root.keys(globalkeys)
root.buttons(
awful.util.table.join(
awful.button({}, 1, function(c) client.focus = c end)
)
)
clientkeys = awful.util.table.join(
awful.key({modkey}, "m", function(c)
c.maximized = not c.maximized
c:raise()
end,
{description = "maximize", group = "client"}),
awful.key({modkey,}, "f", function(c) c.fullscreen = not c.fullscreen end),
awful.key({modkey, "Control"}, "c", function(c) c:kill() end),
awful.key({modkey, "Shift"}, "o", function(c) c.move_to_screen() end)
)
clientbuttons = awful.util.table.join(
awful.button({}, 1, function(c) client.focus = c end)
)
| bsd-2-clause |
OrenjiAkira/lua-html | lib/lux/path.lua | 1 | 2964 | --[[
--
-- Copyright (c) 2013-2016 Wilson Kazuo Mizutani
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--
--]]
--- A module for managing Lua's paths.
-- @module lux.path
local path = {}
local paths
local index
local set_path
local function update_path ()
set_path(path.get())
end
--- Gets the current path.
-- @treturn string The current path
function path.get ()
local result = ""
for _,p in ipairs(paths) do
result = result .. ";" .. p.path
end
return result
end
--- Searches for a lua module in the current path.
-- @tparam string mod The module to be searched
-- @treturn string
-- The path to the Lua file if it is found, or else `nil` plus the the
-- sequence of files it checked.
function path.search (mod)
local checks = {}
local file = mod:gsub('%.', '/')
for _,entry in pairs(paths) do
local filename = entry.path:gsub('%?', file)
local file = io.open(filename, 'r')
if file then
file:close()
return filename
end
table.insert(checks, filename)
end
return nil, checks
end
--- Clears all registered paths and set path handler
-- @tparam function default_path
-- The default path
-- @tparam function set
-- A function that sets the current path
function path.clear (default_path, set)
paths = {}
index = {}
set_path = set
local id = 1
for p in default_path:gmatch "([^;]+)" do
path.add(id, p)
id = id + 1
end
update_path()
end
--- Adds a path.
-- @tparam string id
-- An identifier for the path
-- @tparam string path
-- The path added
-- @see path.remove
function path.add (id, path)
assert(not index[id], "ID already in use")
table.insert(paths, { id = id, path = path })
index[id] = #paths
update_path()
end
--- Removes the path assigned to the given identifier.
-- @tparam string id
-- The identifier for the to-be-removed path
-- @see path.add
function path.remove (id)
local i = index[id]
table.remove(paths, i)
index[id] = nil
for j = i,#paths do
index[paths[j].id] = j
end
update_path()
end
path.clear(package.path, function (p) package.path = p end)
return path
| mit |
Ingenious-Gaming/Starfall | lua/starfall/permissions/core.lua | 5 | 5523 | ---------------------------------------------------------------------
-- SF Permissions management
---------------------------------------------------------------------
-- TODO: Client version
--- Permission format
-- @name Permission
-- @class table
-- @field name The name of the permission
-- @field desc The description of the permission.
-- @field level The abusability of the permission. 0 = low (print to console),
-- 1 = normal (modify entities), 2 = high (run arbitrary lua)
-- @field value Boolean. True to allow, false to deny
SF.Permissions = {}
local P = SF.Permissions
P.__index = P
P.privileges = {}
if SERVER then
util.AddNetworkString( "starfall_permissions_privileges" )
else
P.serverPrivileges = {}
end
do
local lockmeta = {
__newindex = function ( table, key, value )
error( "attempting to assign to a read-only table", 2 )
end,
__metatable = "constant"
}
local result_vals = {
DENY = setmetatable( {}, lockmeta ),
ALLOW = setmetatable( {}, lockmeta ),
NEUTRAL = setmetatable( {}, lockmeta )
}
P.Result = setmetatable( {}, {
__index = result_vals,
__newindex = lockmeta.__newindex,
__metatable = "enum"
} )
end
local DENY = P.Result.DENY
local ALLOW = P.Result.ALLOW
local NEUTRAL = P.Result.NEUTRAL
local providers = {}
local have_owner = false
--- Adds a provider implementation to the set used by this library.
-- Providers must implement the {@link SF.Permissions.Provider} interface.
-- @param provider the provider to be registered
function P.registerProvider ( provider )
if type( provider ) ~= "table"
or type( provider.supportsOwner ) ~= "function"
or type( provider.isOwner ) ~= "function"
or type( provider.check ) ~= "function" then
error( "given object does not implement the provider interface", 2 )
end
providers[ provider ] = provider
if provider:supportsOwner() then
have_owner = true
end
end
--- Checks whether a player may perform an action.
-- @param principal the player performing the action to be authorized
-- @param target the object on which the action is being performed
-- @param key a string identifying the action being performed
-- @return boolean whether the action is permitted
function P.check ( principal, target, key )
if not P.privileges[ key ] then print( "WARNING: Starfall privilege " .. key .. " was not registered!" ) end
-- server owners can do whatever they want
if have_owner then
-- this can't be merged into the check loop below because that
for _, provider in pairs( providers ) do
if provider:isOwner( principal ) then return true end
end
elseif principal:IsSuperAdmin() then
return true
end
local allow = false
for _, provider in pairs( providers ) do
local result = provider:check( principal, target, key )
if DENY == result then
-- a single deny overrides any allows, just deny it now
return false
elseif ALLOW == result then
-- an allow can be overridden by a deny, so remember and keep going
allow = true
end
-- otherwise, this provider has no opinion, just go on to the next one
end
return allow
end
--- Registers a privilege
-- @param id unique identifier of the privilege being registered
-- @param name Human readable name of the privilege
-- @param description a short description of the privilege
function P.registerPrivilege ( id, name, description )
P.privileges[ id ] = { name = name, description = description }
-- The second check is not really necessary, but since it will resolve to false most of the time, we can save some time
if SERVER and #player.GetAll() > 0 then
net.Start( "starfall_permissions_privileges" )
net.WriteInt( #P.privileges, 16 )
for k, v in pairs( P.privileges ) do
net.WriteString( k )
net.WriteString( v.name )
net.WriteString( v.description )
end
net.Broadcast()
end
end
-- Find and include all provider files.
do
local function IncludeClientFile ( file )
if SERVER then
AddCSLuaFile( file )
else
include( file )
end
end
if SERVER then
include( "starfall/permissions/provider.lua" )
end
IncludeClientFile( "starfall/permissions/provider.lua" )
if SERVER then
local files = file.Find( "starfall/permissions/providers_sv/*.lua", "LUA" )
for _, file in pairs( files ) do
include( "starfall/permissions/providers_sv/" .. file )
end
end
local sh_files = file.Find( "starfall/permissions/providers_sh/*.lua", "LUA" )
for _, file in pairs( sh_files ) do
if SERVER then
AddCSLuaFile( "starfall/permissions/providers_sh/" .. file )
end
include( "starfall/permissions/providers_sh/" .. file )
end
local cl_files = file.Find( "starfall/permissions/providers_cl/*.lua", "LUA" )
for _, file in pairs( cl_files ) do
IncludeClientFile( "starfall/permissions/providers_cl/" .. file )
end
end
-- Send serverside privileges to client
if SERVER then
local function sendPrivileges ( ply )
net.Start( "starfall_permissions_privileges" )
net.WriteInt( #P.privileges, 16 )
for k, v in pairs( P.privileges ) do
net.WriteString( k )
net.WriteString( v.name )
net.WriteString( v.description )
end
if ply then
net.Send( ply )
else
net.Broadcast()
end
end
sendPrivileges()
hook.Add( "PlayerInitialSpawn", "starfall_permissions", sendPrivileges )
else
net.Receive( "starfall_permissions_privileges", function ()
local len = net.ReadInt( 16 )
for i = 1, len do
P.serverPrivileges[ net.ReadString() ] = { name = net.ReadString(), description = net.ReadString() }
end
end )
end
| bsd-3-clause |
nasomi/darkstar | scripts/zones/Port_Jeuno/npcs/Chaka_Skitimah.lua | 17 | 1281 | -----------------------------------
-- Area: Port Jeuno
-- NPC: Chaka Skitimah
-- Standard Info NPC
-----------------------------------
package.loaded["scripts/zones/Port_Jeuno/TextIDs"] = nil;
require("scripts/zones/Port_Jeuno/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local vHour = VanadielHour();
local vMin = VanadielMinute();
while vHour >= 4 do
vHour = vHour - 6;
end
if ( vHour == -2) then vHour = 4;
elseif ( vHour == -1) then vHour = 5;
end
local seconds = math.floor(2.4 * ((vHour * 60) + vMin));
player:startEvent( 0x0003, seconds, 0, 0, 0, 0, 0, 0, 0);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
nasomi/darkstar | scripts/zones/Northern_San_dOria/npcs/Ailbeche.lua | 17 | 7385 | -----------------------------------
-- Area: Northern San d'Oria
-- NPC: Ailbeche
-- Starts and Finishes Quest: Father and Son, Sharpening the Sword, A Boy's Dream (start)
-- @zone 231
-- @pos 4 -1 24
-----------------------------------
package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/shop");
require("scripts/globals/quests");
require("scripts/zones/Northern_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
-- "Flyers for Regine" conditional script
FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE);
if (player:getQuestStatus(SANDORIA, FATHER_AND_SON) == QUEST_COMPLETED and player:getVar("returnedAilbecheRod") ~= 1) then
if (trade:hasItemQty(17391,1) == true and trade:getItemCount() == 1) then
player:startEvent(0x003d); -- Finish Quest "Father and Son" (part2) (trading fishing rod)
end
end
if (player:getVar("aBoysDreamCS") >= 3) then
if (trade:hasItemQty(17001,1) == true and trade:getItemCount() == 1 and player:hasItem(4562) == false) then
player:startEvent(0x000f); -- During Quest "A Boy's Dream" (trading bug) madame ?
elseif (trade:hasItemQty(4562,1) == true and trade:getItemCount() == 1) then
player:startEvent(0x002f); -- During Quest "A Boy's Dream" (trading odontotyrannus)
end
end
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)
fatherAndSon = player:getQuestStatus(SANDORIA, FATHER_AND_SON);
sharpeningTheSword = player:getQuestStatus(SANDORIA, SHARPENING_THE_SWORD);
aBoysDream = player:getQuestStatus(SANDORIA, A_BOY_S_DREAM);
-- Checking levels and jobs for af quest
mLvl = player:getMainLvl();
mJob = player:getMainJob();
-- Check if they have key item "Ordelle whetStone"
OrdelleWhetstone = player:hasKeyItem(ORDELLE_WHETSTONE);
sharpeningTheSwordCS = player:getVar("sharpeningTheSwordCS");
aBoysDreamCS = player:getVar("aBoysDreamCS");
-- "Father and Son" Event Dialogs
if (fatherAndSon == QUEST_AVAILABLE) then
player:startEvent(0x01fc); -- Start Quest "Father and Son"
elseif (fatherAndSon == QUEST_ACCEPTED and player:getVar("QuestfatherAndSonVar") == 1) then
player:startEvent(0x01fd); -- Finish Quest "Father and Son" (part1)
elseif (sharpeningTheSword == QUEST_AVAILABLE and player:getVar("returnedAilbecheRod") == 1) then
if (mJob == 7 and mLvl < 40 or mJob ~= 7) then
player:startEvent(0x000c); -- Dialog after "Father and Son" (part2)
-- "Sharpening the Sword" Quest Dialogs
elseif (mJob == 7 and mLvl >= 40 and sharpeningTheSwordCS == 0) then
player:startEvent(0x002d); -- Start Quest "Sharpening the Sword" with thank you for the rod
elseif (mJob == 7 and mLvl >= 40 and sharpeningTheSwordCS == 1) then
player:startEvent(0x002b); -- Start Quest "Sharpening the Sword"
end
elseif (sharpeningTheSword == QUEST_ACCEPTED and OrdelleWhetstone == false) then
player:startEvent(0x002a); -- During Quest "Sharpening the Sword"
elseif (sharpeningTheSword == QUEST_ACCEPTED and OrdelleWhetstone == true) then
player:startEvent(0x002c); -- Finish Quest "Sharpening the Sword"
-- "A Boy's Dream" Quest Dialogs
elseif (aBoysDream == QUEST_AVAILABLE and mJob == 7 and mLvl >= 50) then
if (aBoysDreamCS == 0) then
player:startEvent(0x0029); -- Start Quest "A Boy's Dream" (long cs)
else
player:startEvent(0x0028); -- Start Quest "A Boy's Dream" (shot cs)
end
elseif (aBoysDreamCS == 2) then
player:startEvent(0x002e); -- During Quest "A Boy's Dream"
elseif (aBoysDreamCS == 3) then
player:startEvent(0x0027); -- During Quest "A Boy's Dream" (after exoroche cs)
elseif (aBoysDreamCS == 4) then
player:startEvent(0x003c); -- During Quest "A Boy's Dream" (after trading bug) madame ?
elseif (aBoysDreamCS == 5) then
player:startEvent(0x002f); -- During Quest "A Boy's Dream" (after trading odontotyrannus)
elseif (aBoysDreamCS >= 6) then
player:startEvent(0x0019); -- During Quest "A Boy's Dream" (after Zaldon CS)
elseif (player:hasKeyItem(KNIGHTS_CONFESSION) and player:getVar("UnderOathCS") == 6) then
player:startEvent(0x003B); -- During Quest "Under Oath" (he's going fishing in Jugner)
elseif (player:getVar("UnderOathCS") == 8) then
player:startEvent(0x000D); -- During Quest "Under Oath" (After jugner CS)
else
player:startEvent(0x0364); -- Standard dialog
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
-- "Father and Son"
if (csid == 0x01fc) then
player:addQuest(SANDORIA,FATHER_AND_SON);
elseif (csid == 0x01fd) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,17391);
else
player:addItem(17391);
player:messageSpecial(ITEM_OBTAINED, 17391); -- Willow Fishing Rod
player:addTitle(LOST_CHILD_OFFICER);
player:setVar("QuestfatherAndSonVar",0);
player:addFame(SANDORIA,SAN_FAME*30);
player:completeQuest(SANDORIA,FATHER_AND_SON);
end
elseif (csid == 0x003d) then
player:setVar("returnedAilbecheRod",1);
player:addTitle(FAMILY_COUNSELOR);
player:tradeComplete();
-- "Sharpening the Sword"
elseif ((csid == 0x002d or csid == 0x002b) and option == 1) then
player:addQuest(SANDORIA,SHARPENING_THE_SWORD);
player:setVar("sharpeningTheSwordCS",2);
player:setVar("returnedAilbecheRod",0);
elseif (csid == 0x002d and option == 0) then
player:setVar("sharpeningTheSwordCS",1);
elseif (csid == 0x002c) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,17643);
else
player:delKeyItem(ORDELLE_WHETSTONE);
player:addItem(17643);
player:messageSpecial(ITEM_OBTAINED, 17643); -- Honor Sword
player:setVar("sharpeningTheSwordCS",0);
player:addFame(SANDORIA,SAN_FAME*30);
player:completeQuest(SANDORIA,SHARPENING_THE_SWORD);
end
-- "A Boy's Dream"
elseif ((csid == 0x0029 or csid == 0x0028) and option == 1) then
player:addQuest(SANDORIA,A_BOY_S_DREAM);
player:setVar("aBoysDreamCS",2);
elseif (csid == 0x0029 and option == 0) then
player:setVar("aBoysDreamCS",1);
elseif (csid == 0x000f and player:getVar("aBoysDreamCS") == 3) then
player:setVar("aBoysDreamCS",4);
elseif (csid == 0x002f and player:getVar("aBoysDreamCS") == 4) then
player:setVar("aBoysDreamCS",5);
elseif (csid == 0x0019 and player:getVar("aBoysDreamCS") == 6) then
player:setVar("aBoysDreamCS",7);
elseif (csid == 0x003B) then
player:setVar("UnderOathCS", 7);
end
end; | gpl-3.0 |
nasomi/darkstar | scripts/zones/Outer_Horutoto_Ruins/npcs/_5ee.lua | 17 | 3321 | -----------------------------------
-- Area: Inner Horutoto Ruins
-- NPC: Ancient Magical Gizmo #1 (E out of E, F, G, H, I, J)
-- Involved In Mission: The Heart of the Matter
-----------------------------------
package.loaded["scripts/zones/Outer_Horutoto_Ruins/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/globals/missions");
require("scripts/zones/Outer_Horutoto_Ruins/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
-- Check if we are on Windurst Mission 1-2
if (player:getCurrentMission(WINDURST) == THE_HEART_OF_THE_MATTER) then
MissionStatus = player:getVar("MissionStatus");
if (MissionStatus == 2) then
-- Entered a Dark Orb
if (player:getVar("MissionStatus_orb1") == 1) then
player:startEvent(0x002e);
else
player:messageSpecial(ORB_ALREADY_PLACED);
end
elseif (MissionStatus == 4) then
-- Took out a Glowing Orb
if (player:getVar("MissionStatus_orb1") == 2) then
player:startEvent(0x002e);
else
player:messageSpecial(G_ORB_ALREADY_GOTTEN);
end
else
player:messageSpecial(DARK_MANA_ORB_RECHARGER);
end
else
player:messageSpecial(DARK_MANA_ORB_RECHARGER);
end
return 1;
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 == 0x002e) then
orb_value = player:getVar("MissionStatus_orb1");
if (orb_value == 1) then
player:setVar("MissionStatus_orb1",2);
-- Push the text that the player has placed the orb
player:messageSpecial(FIRST_DARK_ORB_IN_PLACE);
--Delete the key item
player:delKeyItem(FIRST_DARK_MANA_ORB);
-- Check if all orbs have been placed or not
if (player:getVar("MissionStatus_orb2") == 2 and
player:getVar("MissionStatus_orb3") == 2 and
player:getVar("MissionStatus_orb4") == 2 and
player:getVar("MissionStatus_orb5") == 2 and
player:getVar("MissionStatus_orb6") == 2) then
player:messageSpecial(ALL_DARK_MANA_ORBS_SET);
player:setVar("MissionStatus",3);
end
elseif (orb_value == 2) then
player:setVar("MissionStatus_orb1",3);
-- Time to get the glowing orb out
player:addKeyItem(FIRST_GLOWING_MANA_ORB);
player:messageSpecial(KEYITEM_OBTAINED,FIRST_GLOWING_MANA_ORB);
-- Check if all orbs have been placed or not
if (player:getVar("MissionStatus_orb2") == 3 and
player:getVar("MissionStatus_orb3") == 3 and
player:getVar("MissionStatus_orb4") == 3 and
player:getVar("MissionStatus_orb5") == 3 and
player:getVar("MissionStatus_orb6") == 3) then
player:messageSpecial(RETRIEVED_ALL_G_ORBS);
player:setVar("MissionStatus",5);
end
end
end
end; | gpl-3.0 |
nicholas-leonard/nn | SparseLinear.lua | 12 | 7194 | local THNN = require 'nn.THNN'
local SparseLinear, parent = torch.class('nn.SparseLinear', 'nn.Module')
local NO_LAST_INPUT = 0
local ONE_LAST_INPUT = 1
local ACC_MULTIPLE_TIMES = 2
function SparseLinear:__init(inputSize, outputSize, doGradInput)
parent.__init(self)
self.weightDecay = 0
self.doGradInput = doGradInput or false
self.weight = torch.Tensor(outputSize, inputSize):zero()
self.bias = torch.Tensor(outputSize):zero()
self.gradWeight = torch.Tensor(outputSize, inputSize):zero()
self.gradBias = torch.Tensor(outputSize):zero()
assert(type(self.doGradInput) == type(true))
self.lastInput = nil
self.sparseUpdate = NO_LAST_INPUT
self.formatted_input = nil
-- state
self.gradInput = {}
self.output:resize(outputSize)
self:reset()
end
function SparseLinear:reset(stdv)
if stdv then
stdv = stdv * math.sqrt(3)
else
stdv = 1./math.sqrt(self.weight:size(2))
end
self.weight:uniform(-stdv, stdv)
self.bias:uniform(-stdv, stdv):mul(0.000001)
end
function SparseLinear:reshapeInput(input)
if type(input) == 'table' then
return input, true, false
else
if input:dim() == 2 then
return {input}, false, false
else
return input, true, true
end
end
end
function SparseLinear:updateOutput(input)
if self.sparseUpdate == ONE_LAST_INPUT then
self.sparseUpdate = ACC_MULTIPLE_TIMES
end
local input, batchMode, legacyMode = self:reshapeInput(input)
self.legacyMode = legacyMode
if legacyMode then
input.THNN.SparseLinear_legacyUpdateOutput(
input:cdata(),
self.output:cdata(),
self.weight:cdata(),
self.bias:cdata()
)
else
local nbatches = #input
if nbatches == 0 then
self.output:copy(self.bias)
return self.output
end
local size = 0
local marker = 1
self.formatted_input = self.formatted_input or input[1].new()
for i,v in ipairs(input) do size = size + input[i]:size(1) end
self.formatted_input:resize(size, 3)
for i,v in ipairs(input) do
local buf = self.formatted_input:narrow(1, marker, input[i]:size(1))
buf:narrow(2,2,2):copy(input[i])
buf:select(2,1):fill(i)
marker = marker + input[i]:size(1)
end
self.output:resize(nbatches, self.weight:size(1))
input[1].THNN.SparseLinear_updateOutput(
self.formatted_input:cdata(),
self.output:cdata(),
self.weight:cdata(),
self.bias:cdata()
)
-- fix output size for batchSize = 1
if not batchMode then
self.output = self.output[1]
end
end
return self.output
end
function SparseLinear:accGradParameters(input, gradOutput, scale)
local input, batchMode, legacyMode = self:reshapeInput(input)
self.legacyMode = legacyMode
self.lastInput = self.lastInput or gradOutput.new()
if self.sparseUpdate == NO_LAST_INPUT then
local v = self.formatted_input
if self.legacyMode then v = input end
self.lastInput:resizeAs(v):copy(v)
self.sparseUpdate = ONE_LAST_INPUT
elseif self.sparseUpdate == ONE_LAST_INPUT then
self.sparseUpdate = ACC_MULTIPLE_TIMES
end
if legacyMode then
input.THNN.SparseLinear_legacyAccGradParameters(
input:cdata(),
gradOutput:cdata(),
self.gradWeight:cdata(),
self.gradBias:cdata(),
self.weight:cdata(),
self.bias:cdata(),
self.weightDecay or 0,
scale or 1
)
else
if not batchMode then
gradOutput:resize(1, gradOutput:size(1))
end
local rows = self.formatted_input:select(2, 1)
local cols = self.formatted_input:select(2, 2)
local sortinds = cols * gradOutput:size(1) + rows
local _, inds = sortinds:sort(1, false)
local newinput = self.formatted_input:index(1, inds)
input[1].THNN.SparseLinear_accGradParameters(
newinput:cdata(),
gradOutput:cdata(),
self.gradWeight:cdata(),
self.gradBias:cdata(),
self.weight:cdata(),
self.bias:cdata(),
self.weightDecay or 0,
scale or 1
)
end
end
function SparseLinear:updateGradInput(input, gradOutput)
if self.legacyMode then
if type(self.gradInput) ~= type(gradOutput) then self.gradInput = gradOutput.new() end
self.gradInput:resizeAs(input)
else
self.gradInput = {}
end
if self.doGradInput then
-- GradInput should be dense anyway
local gi
local batchMode = true
if gradOutput:dim() == 1 then
gi = self.weight:t()*gradOutput
batchMode = false
elseif gradOutput:dim() == 2 then
gi = gradOutput*self.weight
end
local ini = self.weight:size(2)
if self.legacyMode then
local batches = self.gradInput:size(1)
self.gradInput:resize(batches, ini, 2)
self.gradInput:select(3,1):copy(torch.repeatTensor(torch.range(1, ini), batches, 1))
self.gradInput:select(3,2):copy(gi)
else
local indicies = torch.range(1, ini)
if not batchMode then gi:resize(1, ini) end
for i = 1,gi:size(1) do
self.gradInput[i] = gradOutput.new(ini, 2)
self.gradInput[i]:select(2, 2):copy(gi[i])
self.gradInput[i]:select(2, 1):range(1, ini)
end
end
end
return self.gradInput
end
-- These functions do sparse updates / zeros. However, if we accumulated
-- gradients multiple times, we can't depend on the last input to do sparse
-- updates.
function SparseLinear:updateParameters(learningRate)
if self.lastInput and self.sparseUpdate == ONE_LAST_INPUT then
if self.legacyMode then
self.lastInput.THNN.SparseLinear_legacyUpdateParameters(
self.weight:cdata(),
self.bias:cdata(),
self.gradWeight:cdata(),
self.gradBias:cdata(),
self.lastInput:cdata(),
learningRate
)
else
self.lastInput.THNN.SparseLinear_updateParameters(
self.weight:cdata(),
self.bias:cdata(),
self.gradWeight:cdata(),
self.gradBias:cdata(),
self.lastInput:cdata(),
learningRate
)
end
else
parent.updateParameters(self, learningRate)
end
end
function SparseLinear:zeroGradParameters()
if self.lastInput and self.sparseUpdate == ONE_LAST_INPUT then
if self.legacyMode then
self.lastInput.THNN.SparseLinear_legacyZeroGradParameters(
self.gradWeight:cdata(),
self.gradBias:cdata(),
self.lastInput:cdata()
)
else
self.lastInput.THNN.SparseLinear_zeroGradParameters(
self.gradWeight:cdata(),
self.gradBias:cdata(),
self.lastInput:cdata()
)
end
else
parent.zeroGradParameters(self)
end
self.sparseUpdate = NO_LAST_INPUT
end
function SparseLinear:clearState()
if self.lastInput then self.lastInput:set() end
input.THNN.SparseLinear_cudaClearState()
return parent.clearState(self)
end
| bsd-3-clause |
Nathan22Miles/sile-0.9.1 | core/cairo-output.lua | 2 | 2874 | local lgi = require("lgi");
local cairo = lgi.cairo
local pango = lgi.Pango
local fm = lgi.PangoCairo.FontMap.get_default()
local pango_context = lgi.Pango.FontMap.create_context(fm)
if (not SILE.outputters) then SILE.outputters = {} end
local cr
local move -- See https://github.com/pavouk/lgi/issues/48
local sgs
SILE.outputters.cairo = {
init = function()
local surface = cairo.PdfSurface.create(SILE.outputFilename, SILE.documentState.paperSize[1], SILE.documentState.paperSize[2])
cr = cairo.Context.create(surface)
move = cr.move_to
sgs = cr.show_glyph_string
end,
newPage = function()
cr:show_page();
end,
finish = function()
end,
setColor = function (self, color)
cr:set_source_rgb(color.r, color.g, color.b)
end,
outputHbox = function (value)
if not value then return end
if value.pgs then
sgs(cr, value.font, value.pgs)
elseif value.text then
cr:show_text(value.text)
end
end,
setFont = function (options)
cr:select_font_face(options.font, options.style == "italic" and 1 or 0, options.weight > 100 and 0 or 1)
cr:set_font_size(options.size)
end,
drawImage = function (src, x,y,w,h)
local image = cairo.ImageSurface.create_from_png(src)
if not image then SU.error("Could not load image "..src) end
local src_width = image:get_width()
local src_height = image:get_height()
if not (src_width > 0) then SU.error("Something went wrong loading image "..src) end
cr:save()
cr:set_source_surface(image, 0,0)
local p = cr:get_source()
local matrix, sx, sy
if w or h then
if w > 0 then sx = src_width / w end
if h > 0 then sy = src_height / h end
matrix = cairo.Matrix.create_scale(sx or sy, sy or sx)
else
matrix = cairo.Matrix.create_identity()
end
matrix:translate(-x,-y)
p:set_matrix(matrix)
cr:paint()
cr:restore()
end,
moveTo = function (x,y)
move(cr, x,y)
end,
rule = function (x,y,w,d)
cr:rectangle(x,y,w,d)
cr:fill()
end,
debugFrame = function (self,f)
cr:set_source_rgb(0.8,0,0)
cr:set_line_width(0.5);
cr:rectangle(f:left(), f:top(), f:width(), f:height());
cr:stroke();
cr:move_to(f:left() - 10, f:top() -2);
cr:show_text(f.id);
cr:set_source_rgb(0,0,0);
end,
debugHbox = function(typesetter, hbox, scaledWidth)
cr:set_source_rgb(0.9,0.9,0.9);
cr:set_line_width(0.5);
cr:rectangle(typesetter.frame.state.cursorX, typesetter.frame.state.cursorY-(hbox.height), scaledWidth, hbox.height+hbox.depth);
if (hbox.depth) then cr:rectangle(typesetter.frame.state.cursorX, typesetter.frame.state.cursorY-(hbox.height), scaledWidth, hbox.height); end
cr:stroke();
cr:set_source_rgb(0,0,0);
cr:move_to(typesetter.frame.state.cursorX, typesetter.frame.state.cursorY);
end
}
SILE.outputter = SILE.outputters.cairo | mit |
nasomi/darkstar | scripts/zones/Palborough_Mines/TextIDs.lua | 9 | 1671 | -- Variable TextID Description text
-- General Texts
ITEM_CANNOT_BE_OBTAINED = 6379; -- You cannot obtain the item <item>. Come back after sorting your inventory.
ITEM_OBTAINED = 6384; -- Obtained: <item>.
GIL_OBTAINED = 6385; -- Obtained <number> gil.
KEYITEM_OBTAINED = 6387; -- Obtained key item: <keyitem>.
FISHING_MESSAGE_OFFSET = 7202; -- You can't fish here.
HOMEPOINT_SET = 7428; -- Home point set!
-- Other dialog
NOTHING_OUT_OF_ORDINARY = 6398; -- There is nothing out of the ordinary here.
SENSE_OF_FOREBODING = 6399; -- You are suddenly overcome with a sense of foreboding...
-- Refiner Dialog
SOMETHING_FALLS_OUT_OF_THE_MACHINE = 7360; -- Something falls out of the machine!
THE_MACHINE_SEEMS_TO_BE_WORKING = 7357; -- The machine seems to be working, but you cannot discern its purpose.
YOU_CANT_CARRY_ANY_MORE_ITEMS = 7363; -- There seems to be more left in the machine, but you can't carry any more items.
-- Mining
MINING_IS_POSSIBLE_HERE = 7384; -- Mining is possible here if you have
-- Treasure Coffer/Chest Dialog
CHEST_UNLOCKED = 7398; -- You unlock the chest!
CHEST_FAIL = 7399; -- Fails to open the chest.
CHEST_TRAP = 7400; -- The chest was trapped!
CHEST_WEAK = 7401; -- You cannot open the chest when you are in a weakened state.
CHEST_MIMIC = 7402; -- The chest was a mimic!
CHEST_MOOGLE = 7403; -- You cannot open the chest while participating in the moogle event.
CHEST_ILLUSION = 7404; -- The chest was but an illusion...
CHEST_LOCKED = 7405; -- The chest appears to be locked.
-- conquest Base
CONQUEST_BASE = 7043; -- Tallying conquest results...
| gpl-3.0 |
nasomi/darkstar | scripts/globals/mobskills/Bomb_Toss_Suicide.lua | 2 | 1150 | require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------------
function onMobSkillCheck(target,mob,skill)
-- notorious monsters shouldn't explode, nor dynamis
if (mob:isMobType(MOBTYPE_NOTORIOUS) or mob:isInDynamis()) then
return 1;
end
if (mob:getMainJob() ~= JOB_THF and math.random() < 0.5) then
return 1;
end
return 0;
end;
function onMobWeaponSkill(target, mob, skill)
local dmgmod = 1;
local BOMB_TOSS_HPP = mob:getHP()/mob:getMaxHP();
local job = mob:getMainJob();
local power = math.random(10,15);
-- did I drop it in my face?
if (math.random() < 0.2) then
power = 7;
end
-- thfs drop bombs like crazy
if (job == JOB_THF) then
power = power + 4;
end
local info = MobMagicalMove(mob,target,skill,mob:getWeaponDmg()*power*BOMB_TOSS_HPP,ELE_FIRE,dmgmod,TP_MAB_BONUS,1);
local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_MAGICAL,MOBPARAM_FIRE,MOBPARAM_IGNORE_SHADOWS);
mob:setHP(0);
target:delHP(dmg);
return dmg;
end;
| gpl-3.0 |
kerr-huang/SL4A | lua/json4lua/examples/tests.lua | 20 | 5532 | --[[
Some basic tests for JSON4Lua.
]]--
--- Compares two tables for being data-identical.
function compareData(a,b)
if (type(a)=='string' or type(a)=='number' or type(a)=='boolean' or type(a)=='nil') then return a==b end
-- After basic data types, we're only interested in tables
if (type(a)~='table') then return true end
-- Check that a has everything b has
for k,v in pairs(b) do
if (not compareData( a[k], v ) ) then return false end
end
for k,v in pairs(a) do
if (not compareData( v, b[k] ) ) then return false end
end
return true
end
---
-- Checks that our compareData function works properly
function testCompareData()
s = "name"
r = "name"
assert(compareData(s,r))
assert(not compareData('fred',s))
assert(not compareData(nil, s))
assert(not compareData("123",123))
assert(not compareData(false, nil))
assert(compareData(true, true))
assert(compareData({1,2,3},{1,2,3}))
assert(compareData({'one',2,'three'},{'one',2,'three'}))
assert(not compareData({'one',2,4},{4,2,'one'}))
assert(compareData({one='ichi',two='nichi',three='san'}, {three='san',two='nichi',one='ichi'}))
s = { one={1,2,3}, two={one='hitotsu',two='futatsu',three='mitsu'} }
assert(compareData(s,s))
t = { one={1,2,3}, two={one='een',two='twee',three='drie'} }
assert(not compareData(s,t))
end
testCompareData()
--
--
-- Performs some perfunctory tests on JSON module
function testJSON4Lua()
json = require('json')
if nil then
-- Test encodeString
s = [["\"
]]
r = json._encodeString(s)
assert(r=='\\"\\\\\\"\\n')
s = [["""\\\"]]
r = json._encodeString(s)
assert(r==[[\"\"\"\\\\\\\"]])
end
-- Test encode for basic strings (complicated strings)
s = [[Hello, Lua!]]
r = json.encode(s)
assert(r=='"Hello, Lua!"')
s = [["\"
]]
r = json.encode(s)
assert(r=='\"\\"\\\\\\"\\n\"')
s = [["""\\\"]]
r = json.encode(s)
assert(r==[["\"\"\"\\\\\\\""]])
-- Test encode for numeric values
s = 23
r = json.encode(s)
assert(r=='23')
s=48.123
r = json.encode(s)
assert(r=='48.123')
-- Test encode for boolean values
assert(json.encode(true)=='true')
assert(json.encode(false)=='false')
assert(json.encode(nil)=='null')
-- Test encode for arrays
s = {1,2,3}
r = json.encode(s)
assert(r=="[1,2,3]")
s = {9,9,9}
r = json.encode(s)
assert(r=="[9,9,9]")
-- Complex array test
s = { 2, 'joe', false, nil, 'hi' }
r = json.encode(s)
assert(r=='[2,"joe",false,null,"hi"]')
-- Test encode for tables
s = {Name='Craig',email='craig@lateral.co.za',age=35}
r = json.encode(s)
-- NB: This test can fail because of order: need to test further once
-- decoding is supported.
assert(r==[[{"age":35,"Name":"Craig","email":"craig@lateral.co.za"}]])
-- Test decode_scanWhitespace
if nil then
s = " \n \r \t "
e = json._decode_scanWhitespace(s,1)
assert(e==string.len(s)+1)
s = " \n\r\t4"
assert(json._decode_scanWhitespace(s,1)==5)
-- Test decode_scanString
s = [["Test"]]
r,e = json._decode_scanString(s,1)
assert(r=='Test' and e==7)
s = [["This\nis a \"test"]]
r = json._decode_scanString(s,1)
assert(r=="This\nis a \"test")
-- Test decode_scanNumber
s = [[354]]
r,e = json._decode_scanNumber(s,1)
assert(r==354 and e==4)
s = [[ 4565.23 AND OTHER THINGS ]]
r,e = json._decode_scanNumber(s,2)
assert(r==4565.23 and e==9)
s = [[ -23.22 and ]]
r,e = json._decode_scanNumber(s,2)
assert(r==-23.22 and e==8)
-- Test decode_scanConstant
s = "true"
r,e = json._decode_scanConstant(s,1)
assert(r==true and e==5)
s = " false "
r,e = json._decode_scanConstant(s,3)
assert(r==false and e==8)
s = "1null6"
r,e = json._decode_scanConstant(s,2)
assert(r==nil and e==6)
-- Test decode_scanArray
s = "[1,2,3]"
r,e = json._decode_scanArray(s,1)
assert(compareData(r,{1,2,3}))
s = [[[ 1 , 3 ,5 , "Fred" , true, false, null, -23 ] ]]
r,e = json._decode_scanArray(s,1)
assert(compareData(r, {1,3,5,'Fred',true,false,nil,-23} ) )
s = "[3,5,null,7,9]"
r,e = json._decode_scanArray(s,1)
assert(compareData(r, {3,5,nil,7,9}))
s = "[3,5,null,7,9,null,null]"
r,e = json._decode_scanArray(s,1)
assert(compareData(r, {3,5,nil,7,9,nil,nil}))
end
-- Test decode_scanObject
s = [[ {"one":1, "two":2, "three":"three", "four":true} ]]
r,e = json.decode(s)
assert(compareData(r,{one=1,two=2,three='three',four=true}))
s = [[ { "one" : { "first":1,"second":2,"third":3}, "two":2, "three":false } ]]
r,e = json.decode(s)
assert(compareData(r, {one={first=1,second=2,third=3},two=2,three=false}))
s = [[ { "primes" : [2,3,5,7,9], "user":{"name":"craig","age":35,"programs_lua":true},
"lua_is_great":true } ]]
r,e = json.decode(s)
assert(compareData(r, {primes={2,3,5,7,9},user={name='craig',age=35,programs_lua=true},lua_is_great=true}))
-- Test json.null management
t = { 1,2,json.null,4 }
assert( json.encode(t)=="[1,2,null,4]" )
t = {x=json.null }
r = json.encode(t)
assert( json.encode(t) == '{"x":null}' )
-- Test comment decoding
s = [[ /* A comment
that spans
a few lines
*/
"test"
]]
r,e = json.decode(s)
assert(r=='test',"Comment decoding failed")
end
testJSON4Lua()
print("JSON4Lua tests completed successfully") | apache-2.0 |
nasomi/darkstar | scripts/zones/Northern_San_dOria/npcs/Daveille.lua | 36 | 1427 | -----------------------------------
-- Area: Northern San d'Oria
-- NPC: Daveille
-- Standard Info NPC
-----------------------------------
package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/zones/Northern_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)
player:startEvent(0x0248);
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 |
nasomi/darkstar | scripts/zones/Windurst_Waters_[S]/npcs/Mikhe_Aryohcha.lua | 38 | 1124 | -----------------------------------
-- Area: Windurst Waters (S)
-- NPC: Mikhe Aryohcha
-- Type: Standard NPC
-- @zone: 94
-- @pos -56.645 -4.5 13.014
--
-- Auto-Script: Requires Verification (Verified by Brawndo)
-----------------------------------
package.loaded["scripts/zones/Windurst_Waters_[S]/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Windurst_Waters_[S]/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc, MIKHE_ARYOHCHA_DIALOG);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
aqasaeed/zeus | plugins/invite.lua | 33 | 2849 | --[[
Invite user into the chat group.
Type !invite by replying to a message to invite replied user.
Usefull when you want to reinviting kicked user. Most reliable.
Use !invite 1234567890 (where 1234567890 is id_number) to invite a user by id_number.
This is a very reliable method, and if failed, will failed silently.
Use !invite @username to invite a user by @username.
Less reliable. Some users don't have @username.
Use !invite print_name to invite a user by print_name.
Unreliable. Avoid if possible. Maybe need an initial communication with the user.
If print_name is not exist, it will failed silently.
--]]
do
local function invite_user(chat_id, user_id)
if is_super_banned(user_id) or is_banned(user_id, chat_id) then
return send_large_msg('chat#id'..chat_id, 'Invitation canceled.\n'
..'ID'..user_id..' is (super)banned.')
end
chat_add_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, false)
end
local function resolve_username(extra, success, result)
if success == 1 then
invite_user(extra.msg.to.id, result.id)
else
return send_large_msg('chat#id'..extra.msg.to.id, 'Failed to invite '
..string.gsub(extra.msg.text, '!invite ', '')
..' into this group.\nPlease check if username is correct.')
end
end
local function action_by_reply(extra, success, result)
invite_user(result.to.id, result.from.id)
end
local function run(msg, matches)
if is_chat_msg(msg) and is_mod(msg.from.id, msg.to.id) then
if msg.reply_id and msg.text == "!invite" then
msgr = get_message(msg.reply_id, action_by_reply, {msg=msg})
end
if string.match(matches[1], '^%d+$') then
invite_user(msg.to.id, matches[1])
elseif string.match(matches[1], '^@.+$') then
msgr = res_user(string.gsub(matches[1], '@', ''), resolve_username, {msg=msg})
elseif string.match(matches[1], '.*$') then
-- This one is tricky. Big chance are, you need an initial interaction with <print_name>.
chat_add_user('chat#id'..msg.to.id, string.gsub(matches[1], ' ', '_'), ok_cb, false)
end
else
return 'This is not a chat group!'
end
end
return {
description = 'Invite other user to the chat group.',
usage = {
moderator = {
-- Need space in front of this, so bot won't consider it as a command
' !invite : If type by replying, bot will then inviting the replied user.',
' !invite <user_id> : Invite by their user_id.',
' !invite @<user_name> : Invite by their @<user_name>.',
' !invite <print_name> : Invite by their print_name.'
},
},
patterns = {
'^!invite$',
'^!invite (.*)$',
'^!invite (%d+)$'
},
run = run,
privileged = true
}
end
| gpl-2.0 |
nasomi/darkstar | scripts/zones/Norg/npcs/Louartain.lua | 34 | 1420 | -----------------------------------
-- Area: Norg
-- NPC: Louartain
-- Standard Info NPC
-----------------------------------
require("scripts/globals/pathfind");
local path = {
41.878349, -6.282223, 10.820915,
42.088036, -6.282223, 11.867051,
42.096603, -6.282223, 12.939011,
42.104187, -6.282223, 17.270992,
42.126625, -6.282223, 14.951096,
42.097260, -6.282223, 10.187170,
42.104218, -6.282223, 17.303179,
42.128235, -6.282223, 14.767291,
42.097534, -6.282223, 10.223410
};
function onSpawn(npc)
npc:initNpcAi();
npc:setPos(pathfind.first(path));
-- onPath(npc);
end;
function onPath(npc)
pathfind.patrol(npc, path);
end;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x0054);
npc:wait(-1);
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);
npc:wait(0);
end;
| gpl-3.0 |
nasomi/darkstar | scripts/globals/spells/foe_lullaby.lua | 10 | 1208 | -----------------------------------------
-- Spell: Foe Lullaby
-----------------------------------------
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
local duration = 30;
local pCHR = caster:getStat(MOD_CHR);
local mCHR = target:getStat(MOD_CHR);
local dCHR = (pCHR - mCHR);
local resm = applyResistanceEffect(caster,spell,target,dCHR,SKILL_SNG,0,EFFECT_LULLABY);
if (resm < 0.5) then
spell:setMsg(85);--resist message
return EFFECT_LULLABY;
end
if (target:hasImmunity(1) or 100 * math.random() < target:getMod(MOD_SLEEPRES)) then
--No effect
spell:setMsg(75);
else
local iBoost = caster:getMod(MOD_LULLABY_EFFECT) + caster:getMod(MOD_ALL_SONGS_EFFECT);
duration = duration * ((iBoost * 0.1) + (caster:getMod(MOD_SONG_DURATION_BONUS)/100) + 1);
if (target:addStatusEffect(EFFECT_LULLABY,1,0,duration)) then
spell:setMsg(237);
else
spell:setMsg(75);
end
end
return EFFECT_LULLABY;
end;
| gpl-3.0 |
nasomi/darkstar | scripts/zones/Port_Windurst/npcs/Chipmy-Popmy.lua | 17 | 1295 | -----------------------------------
-- Area: Port Windurst
-- NPC: Chipmy-Popmy
-- Working 100%
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/missions");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local currentday = tonumber(os.date("%j"));
if (player:getCurrentMission(COP) == DAWN and player:getVar("PromathiaStatus")==3 and player:getVar("Promathia_kill_day") ~= currentday and player:getVar("COP_3-taru_story")== 0 ) then
player:startEvent(0x026B);
else
player:startEvent(0xca);
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 == 0x026B) then
player:setVar("COP_3-taru_story",1);
end
end;
| gpl-3.0 |
nicholas-leonard/nn | SpatialUpSamplingNearest.lua | 9 | 1836 | local SpatialUpSamplingNearest, parent = torch.class('nn.SpatialUpSamplingNearest', 'nn.Module')
--[[
Applies a 2D up-sampling over an input image composed of several input planes.
The upsampling is done using the simple nearest neighbor technique.
The Y and X dimensions are assumed to be the last 2 tensor dimensions. For
instance, if the tensor is 4D, then dim 3 is the y dimension and dim 4 is the x.
owidth = width*scale_factor
oheight = height*scale_factor
--]]
function SpatialUpSamplingNearest:__init(scale)
parent.__init(self)
self.scale_factor = scale
if self.scale_factor < 1 then
error('scale_factor must be greater than 1')
end
if math.floor(self.scale_factor) ~= self.scale_factor then
error('scale_factor must be integer')
end
self.inputSize = torch.LongStorage(4)
self.outputSize = torch.LongStorage(4)
end
function SpatialUpSamplingNearest:updateOutput(input)
if input:dim() ~= 4 and input:dim() ~= 3 then
error('SpatialUpSamplingNearest only support 3D or 4D tensors')
end
-- Copy the input size
local xdim = input:dim()
local ydim = input:dim() - 1
for i = 1, input:dim() do
self.inputSize[i] = input:size(i)
self.outputSize[i] = input:size(i)
end
self.outputSize[ydim] = self.outputSize[ydim] * self.scale_factor
self.outputSize[xdim] = self.outputSize[xdim] * self.scale_factor
input.THNN.SpatialUpSamplingNearest_updateOutput(
input:cdata(),
self.output:cdata(),
self.scale_factor
)
return self.output
end
function SpatialUpSamplingNearest:updateGradInput(input, gradOutput)
self.gradInput:resizeAs(input)
input.THNN.SpatialUpSamplingNearest_updateGradInput(
input:cdata(),
gradOutput:cdata(),
self.gradInput:cdata(),
self.scale_factor
)
return self.gradInput
end
| bsd-3-clause |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.