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 |
|---|---|---|---|---|---|
dickeyf/darkstar | scripts/zones/Dynamis-Xarcabard/mobs/Marquis_Nebiros.lua | 5 | 1303 | -----------------------------------
-- Area: Dynamis Xarcabard
-- MOB: Marquis Decarabia
-----------------------------------
require("scripts/globals/dynamis");
require("scripts/zones/Dynamis-Xarcabard/TextIDs");
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
end;
-----------------------------------
-- onMobFight Action
-----------------------------------
function onMobFight(mob,target)
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob,killer,ally)
local Animate_Trigger = GetServerVariable("[DynaXarcabard]Boss_Trigger");
if (mob:isInBattlefieldList() == false) then
mob:addInBattlefieldList();
Animate_Trigger = Animate_Trigger + 16384;
SetServerVariable("[DynaXarcabard]Boss_Trigger",Animate_Trigger);
if (Animate_Trigger == 32767) then
SpawnMob(17330911); -- 142
SpawnMob(17330912); -- 143
SpawnMob(17330183); -- 177
SpawnMob(17330184); -- 178
activateAnimatedWeapon(); -- Change subanim of all animated weapon
end
end
if (Animate_Trigger == 32767) then
ally:messageSpecial(PRISON_OF_SOULS_HAS_SET_FREE);
end
end; | gpl-3.0 |
dickeyf/darkstar | scripts/globals/items/dish_of_spaghetti_nero_di_seppia_+1.lua | 18 | 1800 | -----------------------------------------
-- ID: 5202
-- Item: Dish of Spaghetti Nero Di Seppia +1
-- Food Effect: 60 Mins, All Races
-----------------------------------------
-- HP % 17 (cap 140)
-- Dexterity 3
-- Vitality 2
-- Agility -1
-- Mind -2
-- Charisma -1
-- Double Attack 1
-- Store TP 6
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
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,3600,5202);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_FOOD_HPP, 17);
target:addMod(MOD_FOOD_HP_CAP, 140);
target:addMod(MOD_DEX, 3);
target:addMod(MOD_VIT, 2);
target:addMod(MOD_AGI, -1);
target:addMod(MOD_MND, -2);
target:addMod(MOD_CHR, -1);
target:addMod(MOD_DOUBLE_ATTACK, 1);
target:addMod(MOD_STORETP, 6);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_FOOD_HPP, 17);
target:delMod(MOD_FOOD_HP_CAP, 140);
target:delMod(MOD_DEX, 3);
target:delMod(MOD_VIT, 2);
target:delMod(MOD_AGI, -1);
target:delMod(MOD_MND, -2);
target:delMod(MOD_CHR, -1);
target:delMod(MOD_DOUBLE_ATTACK, 1);
target:delMod(MOD_STORETP, 6);
end;
| gpl-3.0 |
Andrey2470T/Advanced-Trains-Optinal-Additional- | advtrains_train_japan/init.lua | 2 | 2972 | local S
if minetest.get_modpath("intllib") then
S = intllib.Getter()
else
S = function(s,a,...)a={a,...}return s:gsub("@(%d+)",function(n)return a[tonumber(n)]end)end
end
advtrains.register_wagon("engine_japan", {
mesh="advtrains_engine_japan.b3d",
textures = {"advtrains_engine_japan.png"},
drives_on={default=true},
max_speed=20,
seats = {
{
name=S("Driver stand"),
attach_offset={x=0, y=8, z=13},
view_offset={x=0, y=0, z=0},
driving_ctrl_access=true,
group="dstand",
},
{
name="1",
attach_offset={x=-4, y=8, z=0},
view_offset={x=0, y=0, z=0},
group="pass",
},
{
name="2",
attach_offset={x=4, y=8, z=0},
view_offset={x=0, y=0, z=0},
group="pass",
},
{
name="3",
attach_offset={x=-4, y=8, z=-8},
view_offset={x=0, y=0, z=0},
group="pass",
},
{
name="4",
attach_offset={x=4, y=8, z=-8},
view_offset={x=0, y=0, z=0},
group="pass",
},
},
seat_groups = {
dstand={
name = "Driver Stand",
access_to = {"pass"},
require_doors_open=true,
},
pass={
name = "Passenger area",
access_to = {"dstand"},
require_doors_open=true,
},
},
assign_to_seat_group = {"dstand", "pass"},
doors={
open={
[-1]={frames={x=0, y=20}, time=1},
[1]={frames={x=40, y=60}, time=1}
},
close={
[-1]={frames={x=20, y=40}, time=1},
[1]={frames={x=60, y=80}, time=1}
}
},
door_entry={-1},
visual_size = {x=1, y=1},
wagon_span=2.5,
is_locomotive=true,
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
drops={"default:steelblock 4"},
}, S("Japanese Train Engine"), "advtrains_engine_japan_inv.png")
advtrains.register_wagon("wagon_japan", {
mesh="advtrains_wagon_japan.b3d",
textures = {"advtrains_wagon_japan.png"},
drives_on={default=true},
max_speed=20,
seats = {
{
name="1",
attach_offset={x=-4, y=8, z=8},
view_offset={x=0, y=0, z=0},
group="pass",
},
{
name="2",
attach_offset={x=4, y=8, z=8},
view_offset={x=0, y=0, z=0},
group="pass",
},
{
name="1a",
attach_offset={x=-4, y=8, z=0},
view_offset={x=0, y=0, z=0},
group="pass",
},
{
name="2a",
attach_offset={x=4, y=8, z=0},
view_offset={x=0, y=0, z=0},
group="pass",
},
{
name="3",
attach_offset={x=-4, y=8, z=-8},
view_offset={x=0, y=0, z=0},
group="pass",
},
{
name="4",
attach_offset={x=4, y=8, z=-8},
view_offset={x=0, y=0, z=0},
group="pass",
},
},
seat_groups = {
pass={
name = "Passenger area",
access_to = {},
require_doors_open=true,
},
},
assign_to_seat_group = {"pass"},
doors={
open={
[-1]={frames={x=0, y=20}, time=1},
[1]={frames={x=40, y=60}, time=1}
},
close={
[-1]={frames={x=20, y=40}, time=1},
[1]={frames={x=60, y=80}, time=1}
}
},
door_entry={-1, 1},
visual_size = {x=1, y=1},
wagon_span=2.3,
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},
drops={"default:steelblock 4"},
}, S("Japanese Train Wagon"), "advtrains_wagon_japan_inv.png")
| lgpl-2.1 |
Turttle/darkstar | scripts/zones/East_Ronfaure_[S]/Zone.lua | 12 | 1804 | -----------------------------------
--
-- Zone: East_Ronfaure_[S] (81)
--
-----------------------------------
package.loaded["scripts/zones/East_Ronfaure_[S]/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/East_Ronfaure_[S]/TextIDs");
require("scripts/globals/quests");
require("scripts/globals/missions");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then
player:setPos(86.131,-65.817,273.861,25);
end
if (prevZone == 80) then
if (player:getCurrentMission(WOTG) == WHILE_THE_CAT_IS_AWAY) then
cs = 0x0007;
end
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 == 0x0007) then
player:completeMission(WOTG, WHILE_THE_CAT_IS_AWAY);
player:addMission(WOTG, A_TIMESWEPT_BUTTERFLY);
end
end; | gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c1281505.lua | 2 | 2208 | --ヴァイロン・テトラ
function c1281505.initial_effect(c)
--equip
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(1281505,0))
e1:SetCategory(CATEGORY_EQUIP)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e1:SetCode(EVENT_TO_GRAVE)
e1:SetCondition(c1281505.eqcon)
e1:SetCost(c1281505.eqcost)
e1:SetTarget(c1281505.eqtg)
e1:SetOperation(c1281505.eqop)
c:RegisterEffect(e1)
--destroy sub
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_EQUIP+EFFECT_TYPE_CONTINUOUS)
e3:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e3:SetCode(EFFECT_DESTROY_REPLACE)
e3:SetTarget(c1281505.reptg)
e3:SetOperation(c1281505.repop)
c:RegisterEffect(e3)
end
function c1281505.eqcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:GetPreviousLocation()==LOCATION_MZONE
end
function c1281505.eqcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckLPCost(tp,500) end
Duel.PayLPCost(tp,500)
end
function c1281505.eqtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and chkc:IsFaceup() end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0
and Duel.IsExistingTarget(Card.IsFaceup,tp,LOCATION_MZONE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
Duel.SelectTarget(tp,Card.IsFaceup,tp,LOCATION_MZONE,0,1,1,nil)
end
function c1281505.eqop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if c:IsRelateToEffect(e) and tc:IsFaceup() and tc:IsRelateToEffect(e) then
Duel.Equip(tp,c,tc)
--equip limit
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_EQUIP_LIMIT)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetValue(c1281505.eqlimit)
e1:SetReset(RESET_EVENT+0x1fe0000)
c:RegisterEffect(e1)
end
end
function c1281505.eqlimit(e,c)
local tp=e:GetHandlerPlayer()
return c:IsControler(tp)
end
function c1281505.reptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
return Duel.SelectYesNo(tp,aux.Stringid(1281505,1))
end
function c1281505.repop(e,tp,eg,ep,ev,re,r,rp)
Duel.Destroy(e:GetHandler(),REASON_EFFECT+REASON_REPLACE)
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c50608164.lua | 5 | 2436 | --M・HERO 光牙
function c50608164.initial_effect(c)
c:EnableReviveLimit()
--spsummon condition
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetCode(EFFECT_SPSUMMON_CONDITION)
c:RegisterEffect(e1)
--atkup
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetRange(LOCATION_MZONE)
e2:SetCode(EFFECT_UPDATE_ATTACK)
e2:SetValue(c50608164.val)
c:RegisterEffect(e2)
--atkdown
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(50608164,0))
e3:SetType(EFFECT_TYPE_QUICK_O)
e3:SetCode(EVENT_FREE_CHAIN)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP)
e3:SetRange(LOCATION_MZONE)
e3:SetHintTiming(TIMING_DAMAGE_STEP)
e3:SetCountLimit(1)
e3:SetCondition(c50608164.condition)
e3:SetCost(c50608164.cost)
e3:SetTarget(c50608164.target)
e3:SetOperation(c50608164.operation)
c:RegisterEffect(e3)
end
function c50608164.val(e,c)
return Duel.GetFieldGroupCount(c:GetControler(),0,LOCATION_MZONE)*500
end
function c50608164.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCurrentPhase()~=PHASE_DAMAGE or not Duel.IsDamageCalculated()
end
function c50608164.cfilter(c)
return c:IsSetCard(0x8) and c:IsType(TYPE_MONSTER) and c:IsAbleToRemoveAsCost()
end
function c50608164.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c50608164.cfilter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g=Duel.SelectMatchingCard(tp,c50608164.cfilter,tp,LOCATION_GRAVE,0,1,1,nil)
e:SetLabel(g:GetFirst():GetAttack())
Duel.Remove(g,POS_FACEUP,REASON_COST)
end
function c50608164.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsFaceup() end
if chk==0 then return Duel.IsExistingTarget(Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
Duel.SelectTarget(tp,Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
end
function c50608164.operation(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsFaceup() and tc:IsRelateToEffect(e) then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(-e:GetLabel())
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
tc:RegisterEffect(e1)
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c511000821.lua | 2 | 1914 | --王家の神殿
function c511000821.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e1)
--Trap activate in set turn
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_TRAP_ACT_IN_SET_TURN)
e2:SetProperty(EFFECT_FLAG_SET_AVAILABLE)
e2:SetRange(LOCATION_SZONE)
e2:SetTargetRange(LOCATION_SZONE,0)
c:RegisterEffect(e2)
--spsummon
local e3=Effect.CreateEffect(c)
e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
e3:SetDescription(aux.Stringid(511000821,0))
e3:SetType(EFFECT_TYPE_IGNITION)
e3:SetRange(LOCATION_SZONE)
e3:SetCost(c511000821.cost)
e3:SetTarget(c511000821.target)
e3:SetOperation(c511000821.operation)
c:RegisterEffect(e3)
end
function c511000821.cfilter(c)
return c:IsFaceup() and c:IsCode(89194033) and c:IsAbleToGraveAsCost()
end
function c511000821.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToGraveAsCost()
and Duel.IsExistingMatchingCard(c511000821.cfilter,tp,LOCATION_ONFIELD,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,c511000821.cfilter,tp,LOCATION_ONFIELD,0,1,1,nil)
g:AddCard(e:GetHandler())
Duel.SendtoGrave(g,REASON_COST)
end
function c511000821.filter(c,e,tp)
return c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c511000821.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c511000821.filter,tp,0x43,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,0x32)
end
function c511000821.operation(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,c511000821.filter,tp,0x43,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 |
SalvationDevelopment/Salvation-Scripts-TCG | c511000025.lua | 2 | 1549 | --Tuning Collapse
function c511000025.initial_effect(c)
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_DECKDES)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_PLAYER_TARGET)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_DESTROYED)
e1:SetCondition(c511000025.condition)
e1:SetTarget(c511000025.target)
e1:SetOperation(c511000025.operation)
c:RegisterEffect(e1)
end
function c511000025.cfilter(c,tp)
return c:IsType(TYPE_SYNCHRO) and c:IsPreviousLocation(LOCATION_ONFIELD) and c:IsPreviousPosition(POS_FACEUP) and c:IsControler(1-tp)
and c:IsLocation(LOCATION_GRAVE)
end
function c511000025.condition(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(c511000025.cfilter,1,nil,tp)
end
function c511000025.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(1-tp) and c511000025.cfilter(chkc) end
if chk==0 then return true end
local g=eg:Filter(c511000025.cfilter,nil,tp)
local tc=g:GetFirst()
if g:GetCount()>1 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET)
tc=g:Select(tp,1,1,nil):GetFirst()
end
Duel.SetTargetCard(tc)
local desc=tc:GetLevel()
local desp=1-tp
Duel.SetTargetPlayer(desp)
Duel.SetTargetParam(desc)
Duel.SetOperationInfo(0,CATEGORY_DECKDES,nil,0,desp,desc)
end
function c511000025.operation(e,tp,eg,ep,ev,re,r,rp)
local p=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER)
local tc=Duel.GetFirstTarget()
local lv=tc:GetLevel()
if tc:IsRelateToEffect(e) and lv>0 then
Duel.DiscardDeck(p,lv,REASON_EFFECT)
end
end | gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c80168720.lua | 2 | 1324 | --闇の訪れ
function c80168720.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_POSITION)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCost(c80168720.cost)
e1:SetTarget(c80168720.target)
e1:SetOperation(c80168720.activate)
c:RegisterEffect(e1)
end
function c80168720.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsDiscardable,tp,LOCATION_HAND,0,2,e:GetHandler()) end
Duel.DiscardHand(tp,Card.IsDiscardable,2,2,REASON_COST+REASON_DISCARD)
end
function c80168720.filter(c)
return c:IsFaceup() and c:IsCanTurnSet()
end
function c80168720.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and c80168720.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c80168720.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
local g=Duel.SelectTarget(tp,c80168720.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_POSITION,g,1,0,0)
end
function c80168720.activate(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and tc:IsFaceup() then
Duel.ChangePosition(tc,POS_FACEDOWN_ATTACK,0,POS_FACEDOWN_DEFENSE,0)
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c73616671.lua | 3 | 1340 | --イリュージョン・マジック
function c73616671.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,73616671+EFFECT_COUNT_CODE_OATH)
e1:SetCost(c73616671.cost)
e1:SetTarget(c73616671.target)
e1:SetOperation(c73616671.activate)
c:RegisterEffect(e1)
end
c73616671.card_code_list={46986414}
function c73616671.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckReleaseGroup(tp,Card.IsRace,1,nil,RACE_SPELLCASTER) end
local g=Duel.SelectReleaseGroup(tp,Card.IsRace,1,1,nil,RACE_SPELLCASTER)
Duel.Release(g,REASON_COST)
end
function c73616671.filter(c)
return c:IsCode(46986414) and c:IsAbleToHand()
end
function c73616671.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c73616671.filter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK+LOCATION_GRAVE)
end
function c73616671.activate(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(c73616671.filter),tp,LOCATION_DECK+LOCATION_GRAVE,0,1,2,nil)
if g:GetCount()>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c17189532.lua | 9 | 1252 | --ファントム・バウンサー
function c17189532.initial_effect(c)
--search
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(17189532,0))
e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP)
e1:SetCode(EVENT_TO_GRAVE)
e1:SetCondition(c17189532.condition)
e1:SetTarget(c17189532.target)
e1:SetOperation(c17189532.operation)
c:RegisterEffect(e1)
end
function c17189532.condition(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD) and e:GetHandler():IsReason(REASON_DESTROY)
end
function c17189532.filter(c)
return c:IsSetCard(0x6b) and c:IsAbleToHand()
end
function c17189532.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c17189532.filter,tp,LOCATION_DECK,0,2,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,2,tp,LOCATION_DECK)
end
function c17189532.operation(e,tp,eg,ep,ev,re,r,rp)
local sg=Duel.GetMatchingGroup(c17189532.filter,tp,LOCATION_DECK,0,nil)
if sg:GetCount()<2 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=sg:Select(tp,2,2,nil)
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
| gpl-2.0 |
dickeyf/darkstar | scripts/zones/Outer_Horutoto_Ruins/npcs/_ne4.lua | 13 | 2994 | -----------------------------------
-- Area: Outer Horutoto Ruins
-- NPC: Strange Apparatus
-- @pos: -574 0 739 194
-----------------------------------
package.loaded["scripts/zones/Outer_Horutoto_Ruins/TextIDs"] = nil;
require("scripts/zones/Outer_Horutoto_Ruins/TextIDs");
require("scripts/globals/strangeapparatus");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
local trade = tradeToStrApp(player, trade);
if (trade ~= nil) then
if ( trade == 1) then -- good trade
local drop = player:getLocalVar("strAppDrop");
local dropQty = player:getLocalVar("strAppDropQty");
local docStatus = 0; -- Assistant
if (hasStrAppDocStatus(player)) then
docStatus = 1; -- Doctor
end
player:startEvent(0x0042, drop, dropQty, INFINITY_CORE, 0, 0, 0, docStatus, 0);
else -- wrong chip, spawn elemental nm
spawnElementalNM(player);
delStrAppDocStatus(player);
player:messageSpecial(SYS_OVERLOAD);
player:messageSpecial(YOU_LOST_THE, trade);
end
else -- Invalid trade, lose doctor status
delStrAppDocStatus(player);
player:messageSpecial(DEVICE_NOT_WORKING);
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local docStatus = 0; -- Assistant
if (hasStrAppDocStatus(player)) then
docStatus = 1; -- Doctor
else
player:setLocalVar( "strAppPass", 1);
end
player:startEvent(0x0040, docStatus, 0, INFINITY_CORE, 0, 0, 0, 0, player:getZoneID());
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u", option);
if (csid == 0x0040) then
if (hasStrAppDocStatus(player) == false) then
local docStatus = 1; -- Assistant
if ( option == strAppPass(player)) then -- Good password
docStatus = 0; -- Doctor
giveStrAppDocStatus(player);
end
player:updateEvent(docStatus, 0, INFINITY_CORE, 0, 0, 0, 0, 0);
end
end
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 0x0042) then
local drop = player:getLocalVar("strAppDrop");
local dropQty = player:getLocalVar("strAppDropQty");
if (drop ~= 0) then
if ( dropQty == 0) then
dropQty = 1;
end
player:addItem(drop, dropQty);
player:setLocalVar("strAppDrop", 0);
player:setLocalVar("strAppDropQty", 0);
end
end
end; | gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c63477921.lua | 7 | 1220 | --サイバー・サモン・ブラスター
function c63477921.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e1)
--damage
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(63477921,0))
e2:SetCategory(CATEGORY_DAMAGE)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e2:SetRange(LOCATION_SZONE)
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
e2:SetCondition(c63477921.damcon)
e2:SetTarget(c63477921.damtg)
e2:SetOperation(c63477921.damop)
c:RegisterEffect(e2)
end
function c63477921.filter(c)
return c:IsFaceup() and c:IsRace(RACE_MACHINE)
end
function c63477921.damcon(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(c63477921.filter,1,nil)
end
function c63477921.damtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetTargetPlayer(1-tp)
Duel.SetTargetParam(300)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,300)
end
function c63477921.damop(e,tp,eg,ep,ev,re,r,rp)
if not e:GetHandler():IsRelateToEffect(e) then return end
local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
Duel.Damage(p,d,REASON_EFFECT)
end
| gpl-2.0 |
Turttle/darkstar | scripts/zones/The_Boyahda_Tree/npcs/HomePoint#1.lua | 19 | 1204 | -----------------------------------
-- Area: The Boyahda Tree
-- NPC: HomePoint#1
-- @pos 88 -15 -217 153
-----------------------------------
package.loaded["scripts/zones/The_Boyahda_Tree/TextIDs"] = nil;
require("scripts/globals/settings");
require("scripts/zones/The_Boyahda_Tree/TextIDs");
require("scripts/globals/homepoint");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
homepointMenu( player, 0x21fc, 92);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x21fc) then
if (option == 1) then
player:setHomePoint();
player:messageSpecial(HOMEPOINT_SET);
else
hpTeleport( player, option);
end
end
end; | gpl-3.0 |
Turttle/darkstar | scripts/zones/Ifrits_Cauldron/npcs/qm4.lua | 16 | 1477 | -----------------------------------
-- Area: Ifrit's Cauldron
-- NPC: ???
-- Involved in Mission: Bastok 6-2
-- @pos 171 0 -25 205
-----------------------------------
package.loaded["scripts/zones/Ifrits_Cauldron/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/missions");
require("scripts/zones/Ifrits_Cauldron/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getCurrentMission(BASTOK) == THE_PIRATE_S_COVE and player:getVar("MissionStatus") == 2) then
if (GetMobAction(17616897) == 0 and GetMobAction(17616898) == 0 and trade:hasItemQty(646,1) and trade:getItemCount() == 1) then
player:tradeComplete();
SpawnMob(17616897):updateClaim(player);
SpawnMob(17616898):updateClaim(player);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:messageSpecial(NOTHING_OUT_OF_ORDINARY);
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 |
eugeneia/snabb | src/apps/snmp/iftable.lua | 2 | 1377 | -- Use of this source code is governed by the Apache 2.0 license; see COPYING.
module(..., package.seeall)
local shm = require("core.shm")
local ifmib = require("lib.ipc.shmem.iftable_mib")
local ifmib_dir = '/ifmib'
local function create_ifmib(stats, ifname, ifalias, log_date)
-- stats can be nil in case this process is not the master
-- of the device
if not stats then return end
if not shm.exists(ifmib_dir) then
shm.mkdir(ifmib_dir)
end
ifmib.init_snmp( { ifDescr = ifname,
ifName = ifname,
ifAlias = ifalias or "NetFlow input", },
ifname:gsub('/', '-'), stats,
shm.root..ifmib_dir, 5, log_date)
end
MIB = {
config = {
target_app = {required=true},
ifname = {required=true},
ifalias = {default="NetFlow input"},
log_date = {default=false},
stats = {default='shm'}
}
}
function MIB:new (conf)
local self = {
initialized = false,
conf = conf
}
return setmetatable(self, {__index=MIB})
end
function MIB:tick ()
if self.initialized then
return
end
local target_app = engine.app_table[self.conf.target_app]
local stats = target_app and target_app[self.conf.stats]
create_ifmib(stats, self.conf.ifname, self.conf.ifalias, self.conf.log_date)
self.initialized = true
end | apache-2.0 |
dickeyf/darkstar | scripts/globals/items/carp_sushi.lua | 18 | 1386 | -----------------------------------------
-- ID: 4407
-- Item: carp_sushi
-- Food Effect: 30Min, All Races
-----------------------------------------
-- Dexterity 1
-- Accuracy % 10
-- HP Recovered While Healing 2
-----------------------------------------
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,4407);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_DEX, 1);
target:addMod(MOD_FOOD_ACCP, 10);
target:addMod(MOD_FOOD_ACC_CAP, 999);
target:addMod(MOD_HPHEAL, 2);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_DEX, 1);
target:delMod(MOD_FOOD_ACCP, 10);
target:delMod(MOD_FOOD_ACC_CAP, 999);
target:delMod(MOD_HPHEAL, 2);
end;
| gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c11109820.lua | 2 | 3138 | --エクシーズ・ユニバース
function c11109820.initial_effect(c)
--special summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(11109820,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_TOGRAVE)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetTarget(c11109820.target)
e1:SetOperation(c11109820.operation)
c:RegisterEffect(e1)
end
function c11109820.filter1(c,e,tp,ft)
if c:IsControler(tp) then ft=ft+1 end
return c:IsFaceup() and c:IsType(TYPE_XYZ)
and Duel.IsExistingTarget(c11109820.filter2,tp,LOCATION_MZONE,LOCATION_MZONE,1,c,e,tp,c:GetRank(),ft)
end
function c11109820.filter2(c,e,tp,rk,ft)
if c:IsControler(tp) then ft=ft+1 end
return c:IsFaceup() and c:IsType(TYPE_XYZ)
and ft>0 and Duel.IsExistingMatchingCard(c11109820.spfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,rk+c:GetRank())
end
function c11109820.spfilter(c,e,tp,rk)
local crk=c:GetRank()
return (crk==rk or crk==rk-1) and not c:IsSetCard(0x48) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c11109820.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return false end
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
if chk==0 then return e:IsHasType(EFFECT_TYPE_ACTIVATE)
and Duel.IsExistingTarget(c11109820.filter1,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil,e,tp,ft) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g1=Duel.SelectTarget(tp,c11109820.filter1,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil,e,tp,ft)
local tc=g1:GetFirst()
if tc:IsControler(tp) then ft=ft+1 end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g2=Duel.SelectTarget(tp,c11109820.filter2,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,tc,e,tp,tc:GetRank(),ft)
g1:Merge(g2)
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,g1,2,0,0)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function c11109820.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
--change damage
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CHANGE_DAMAGE)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetTargetRange(0,1)
e1:SetValue(0)
e1:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e1,tp)
local e2=e1:Clone()
e2:SetCode(EFFECT_NO_EFFECT_DAMAGE)
e2:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e2,tp)
--sp_summon
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
local tc1=g:GetFirst()
local tc2=g:GetNext()
if not tc1:IsRelateToEffect(e) or not tc2:IsRelateToEffect(e) then return end
Duel.SendtoGrave(g,REASON_EFFECT)
local og=Duel.GetOperatedGroup()
if og:FilterCount(Card.IsLocation,nil,LOCATION_GRAVE)<2 or Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
local sg=Duel.GetMatchingGroup(c11109820.spfilter,tp,LOCATION_EXTRA,0,nil,e,tp,tc1:GetRank()+tc2:GetRank())
if sg:GetCount()==0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local ssg=sg:Select(tp,1,1,nil)
local sc=ssg:GetFirst()
if sc then
Duel.SpecialSummon(sc,0,tp,tp,false,false,POS_FACEUP)
if c:IsRelateToEffect(e) then
c:CancelToGrave()
Duel.Overlay(sc,Group.FromCards(c))
end
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c74094021.lua | 4 | 1785 | --真六武衆-ミズホ
function c74094021.initial_effect(c)
--special summon
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
e1:SetRange(LOCATION_HAND)
e1:SetCondition(c74094021.spcon)
c:RegisterEffect(e1)
--destroy
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(74094021,0))
e2:SetCategory(CATEGORY_DESTROY)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetCountLimit(1)
e2:SetRange(LOCATION_MZONE)
e2:SetCost(c74094021.cost)
e2:SetTarget(c74094021.target)
e2:SetOperation(c74094021.operation)
c:RegisterEffect(e2)
end
function c74094021.spfilter(c)
return c:IsFaceup() and c:IsCode(48505422)
end
function c74094021.spcon(e,c)
if c==nil then return true end
return Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>0 and
Duel.IsExistingMatchingCard(c74094021.spfilter,c:GetControler(),LOCATION_ONFIELD,0,1,nil)
end
function c74094021.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckReleaseGroup(tp,Card.IsSetCard,1,e:GetHandler(),0x3d) end
local sg=Duel.SelectReleaseGroup(tp,Card.IsSetCard,1,1,e:GetHandler(),0x3d)
Duel.Release(sg,REASON_COST)
end
function c74094021.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsOnField() end
if chk==0 then return Duel.IsExistingTarget(aux.TRUE,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,aux.TRUE,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)
end
function c74094021.operation(e,tp,eg,ep,ev,re,r,rp,chk)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.Destroy(tc,REASON_EFFECT)
end
end
| gpl-2.0 |
Turttle/darkstar | scripts/globals/items/chunk_of_homemade_cheese.lua | 35 | 1208 | -----------------------------------------
-- ID: 5225
-- Item: chunk_of_homemade_cheese
-- Food Effect: 30Min, All Races
-----------------------------------------
-- Health 10
-- Defense 40
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,1800,5225);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 10);
target:addMod(MOD_DEF, 40);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 10);
target:delMod(MOD_DEF, 40);
end;
| gpl-3.0 |
Turttle/darkstar | scripts/globals/weaponskills/camlanns_torment.lua | 30 | 1377 | -----------------------------------
-- Camlann's Torment
-- Polearm weapon skill
-- Skill Level: EMPYREAN
-- Delivers a triple damage attack. DEF ignored varies with TP.
-- Will stack with Sneak Attack.
-- Element: None
-- Modifiers: VIT:60%
-- 100%TP 200%TP 300%TP
-- 3.00 3 3
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
-----------------------------------
function onUseWeaponSkill(player, target, wsID)
local params = {};
params.numHits = 1;
params.ftp100 = 3; params.ftp200 = 3; params.ftp300 = 3;
params.str_wsc = 0.0; params.dex_wsc = 0.0; params.vit_wsc = 0.6; 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;
params.ignoresDef = true;
params.ignored100 = 0.15;
params.ignored200 = 0.35;
params.ignored300 = 0.5;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.str_wsc = 0.6;
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, params);
damage = damage * WEAPON_SKILL_POWER
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
fgenesis/Aquaria_experimental | game_scripts/scripts/maps/node_sunwormcavebrain.lua | 1 | 1916 | -- Copyright (C) 2007, 2010 - Bit-Blot
--
-- This file is part of Aquaria.
--
-- Aquaria is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License
-- as published by the Free Software Foundation; either version 2
-- of the License, or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--
-- See the GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
if not v then v = {} end
if not AQUARIA_VERSION then dofile("scripts/entities/entityinclude.lua") end
v.h1 = 0
v.h2 = 0
v.past = 0
v.timer = 0
v.levelAt = 1
v.pastDefault = false
v.n = 0
function init(me)
v.h1 = getNode("WATERLEVEL_HIGH")
v.h2 = getNode("WATERLEVEL_LOW")
v.past = getNode("RAISE_WATERLEVEL")
v.bossRoom = getNode("NAIJA_ENTER")
v.n = getNaija()
loadSound("waterlevelchange")
end
function activate(me)
end
function update(me, dt)
if not isFlag(FLAG_BOSS_SUNWORM, 0) then
setWaterLevel(node_y(getNode("ENDWATERLEVEL")))
return
end
if entity_x(v.n) > node_x(v.past) then
if not v.pastDefault then
if not AQUARIA_VERSION then dofile("scripts/entities/entityinclude.lua") end
setWaterLevel(node_y(v.h1), 2)
v.pastDefault = true
end
else
v.pastDefault = false
v.timer = v.timer + dt
if v.timer > 7 then
playSfx("waterlevelchange")
if v.levelAt == 1 then
v.levelAt = 2
else
v.levelAt = 1
end
if v.levelAt == 1 then
setWaterLevel(node_y(v.h1), 2)
elseif v.levelAt == 2 then
setWaterLevel(node_y(v.h2), 2)
end
v.timer = 0
end
end
end
| gpl-2.0 |
Turttle/darkstar | scripts/zones/Metalworks/npcs/HomePoint#2.lua | 19 | 1185 | -----------------------------------
-- Area: Metalworks
-- NPC: HomePoint#2
-- @pos: -78 2 2 237
-----------------------------------
package.loaded["scripts/zones/Metalworks/TextIDs"] = nil;
require("scripts/globals/settings");
require("scripts/zones/Metalworks/TextIDs");
require("scripts/globals/homepoint");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
homepointMenu( player, 0x21fd, 102);
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 |
SalvationDevelopment/Salvation-Scripts-TCG | c110000107.lua | 2 | 3057 | --Jet Gauntlet
function c110000107.initial_effect(c)
--destroy
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(110000107,0))
e1:SetCategory(CATEGORY_DESTROY)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_BATTLE_START)
e1:SetTarget(c110000107.target)
e1:SetOperation(c110000107.operation)
c:RegisterEffect(e1)
--Restrict Attack
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_ATTACK_ANNOUNCE)
e2:SetCondition(c110000107.racon)
e2:SetOperation(c110000107.raop)
c:RegisterEffect(e2)
--Attack Redirection
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
e3:SetCode(EVENT_BE_BATTLE_TARGET)
e3:SetCondition(c110000107.arcon)
e3:SetTarget(c110000107.artar)
e3:SetOperation(c110000107.arop)
c:RegisterEffect(e3)
end
function c110000107.target(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return Duel.GetAttackTarget()==c or (Duel.GetAttacker()==c and Duel.GetAttackTarget()~=nil) end
local g=Group.FromCards(Duel.GetAttacker(),Duel.GetAttackTarget())
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0)
end
function c110000107.operation(e,tp,eg,ep,ev,re,r,rp)
local g=Group.CreateGroup()
local c=Duel.GetAttacker()
if c:IsRelateToBattle() then g:AddCard(c) end
c=Duel.GetAttackTarget()
if c~=nil and c:IsRelateToBattle() then g:AddCard(c) end
if g:GetCount()>0 then
Duel.Destroy(g, nil, REASON_EFFECT)
end
end
function c110000107.cboperation(e,tp,eg,ep,ev,re,r,rp)
Duel.ChangeAttackTarget(e:GetHandler())
end
function c110000107.afilter(c)
return c:IsSetCard(0x3A2E) and c:IsFaceup()
end
function c110000107.atkfilter(e,c)
return c:IsSetCard(0x3A2E)
end
function c110000107.arcon(e,tp,eg,ep,ev,re,r,rp)
return r~=REASON_REPLACE and Duel.GetAttackTarget()==e:GetHandler()
and Duel.GetAttacker():IsControler(1-tp) and e:GetHandler():GetBattlePosition()~=POS_FACEDOWN_DEFENSE
end
function c110000107.artar(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) end
if chk==0 then return Duel.IsExistingMatchingCard(c110000107.afilter,tp,LOCATION_MZONE,0,1,e:GetHandler()) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET)
Duel.SelectTarget(tp,c110000107.afilter,tp,LOCATION_MZONE,0,1,1,Duel.GetAttackTarget())
end
function c110000107.arop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc and tc:IsRelateToEffect(e) then
Duel.ChangeAttackTarget(tc)
end
end
function c110000107.racon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler()==Duel.GetAttacker()
end
function c110000107.raop(e,tp,eg,ep,ev,re,r,rp)
local j=e:GetHandler()
local e9=Effect.CreateEffect(e:GetHandler())
e9:SetType(EFFECT_TYPE_FIELD)
e9:SetRange(LOCATION_MZONE)
e9:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE)
e9:SetTargetRange(LOCATION_MZONE,0)
e9:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
e9:SetTarget(c110000107.atkfilter)
j:RegisterEffect(e9)
end | gpl-2.0 |
Turttle/darkstar | scripts/zones/Castle_Oztroja/npcs/_m73.lua | 16 | 2232 | -----------------------------------
-- Area: Castle Oztroja
-- NPC: _m73 (Torch Stand)
-- Notes: Opens door _477 when _m72 to _m75 are lit
-- @pos -140.146 -72.058 -137.145 151
-----------------------------------
package.loaded["scripts/zones/Castle_Oztroja/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Castle_Oztroja/TextIDs");
require("scripts/globals/settings");
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
DoorID = npc:getID() - 3;
Torch1 = npc:getID() - 1 ;
Torch2 = npc:getID();
Torch3 = npc:getID() + 1;
Torch4 = npc:getID() + 2;
DoorA = GetNPCByID(DoorID):getAnimation();
TorchStand1A = GetNPCByID(Torch1):getAnimation();
TorchStand2A = npc:getAnimation();
TorchStand3A = GetNPCByID(Torch3):getAnimation();
TorchStand4A = GetNPCByID(Torch4):getAnimation();
if (DoorA == 9 and TorchStand2A == 9) then
player:startEvent(0x000a);
else
player:messageSpecial(TORCH_LIT);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (option == 1) then
GetNPCByID(Torch2):openDoor(55);
if ((DoorA == 9) and (TorchStand1A == 8) and (TorchStand3A == 8) and (TorchStand4A == 8)) then
GetNPCByID(DoorID):openDoor(35);
-- The lamps shouldn't go off here, but I couldn't get the torches to update animation times without turning them off first
-- They need to be reset to the door open time(35s) + 4s (39 seconds)
GetNPCByID(Torch1):setAnimation(9);
GetNPCByID(Torch2):setAnimation(9);
GetNPCByID(Torch3):setAnimation(9);
GetNPCByID(Torch4):setAnimation(9);
GetNPCByID(Torch1):openDoor(39);
GetNPCByID(Torch2):openDoor(39);
GetNPCByID(Torch3):openDoor(39);
GetNPCByID(Torch4):openDoor(39);
end
end
end;
| gpl-3.0 |
dickeyf/darkstar | scripts/zones/Open_sea_route_to_Mhaura/Zone.lua | 13 | 1464 | -----------------------------------
--
-- Zone: Open_sea_route_to_Mhaura (47)
--
-----------------------------------
package.loaded["scripts/zones/Open_sea_route_to_Mhaura/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Open_sea_route_to_Mhaura/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then
local position = math.random(-2,2) + 0.150;
player:setPos(position,-2.100,3.250,64);
end
return cs;
end;
-----------------------------------
-- onTransportEvent
-----------------------------------
function onTransportEvent(player,transport)
player:startEvent(0x0404);
player:messageSpecial(DOCKING_IN_MHAURA);
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 == 0x0404) then
player:setPos(0,0,0,0,249);
end
end; | gpl-3.0 |
eugeneia/snabb | lib/pflua/src/pf/regalloc.lua | 4 | 16429 | -- Implements register allocation for pflua's native backend
--
-- Follows the algorithm described in:
-- "Linear scan register allocation"
-- Poletto and Sarkar
-- https://dl.acm.org/citation.cfm?id=330250
--
-- The result of register allocation is a table that describes
-- the register allocated for the given virtual registers, e.g.:
--
-- { v1 = 1, -- %rcx
-- v2 = 2, -- %rdx
-- r3 = 0, -- %rax
-- len = 6, -- %rsi
-- callee_saves = {},
-- spills = { v3 = 0, v4 = 1 },
-- spill_registers = { 3, 4 }
-- }
--
-- The callee_saves field lists the callee-save registers that are
-- used in the allocation. This lets the code generation pass easily
-- generate any push/pops that are needed.
--
-- Register numbers are based on DynASM's Rq() register mapping.
--
-- The following registers are reserved and not allocated:
-- * %rdi to store the packet pointer argument
--
-- The allocator should first prioritize using caller-save registers
-- * %rax, %rcx, %rdx, %r8-%r11
--
-- before using callee-save registers
-- * %rbx, %r12-%r15
--
-- The spills and spill_registers fields are used for spilling registers
-- to memory if that becomes necessary. When the first register is spilled,
-- two additional registers are spilled (and put into spill_registers) so
-- that they can be used to move data from/to memory and registers.
--
-- The spills field keeps track of the stack slots (numbered from 0)
-- that are used for spilled registers. Variables should only be mapped
-- in one of the main allocation table or in the spills table.
module(...,package.seeall)
local utils = require('pf.utils')
local verbose = os.getenv("PF_VERBOSE");
-- returns the registers that a given instruction reads
local function reads_from(instr)
local itype = instr[1]
local function maybe_reg(reg)
if type(reg) == "number" then
return nil
else
return reg
end
end
if itype == "mov" or itype == "mov64" then
return { maybe_reg(instr[3]) }
elseif itype == "ntohs" or itype == "ntohl" or itype == "uint32" then
return { instr[2] }
elseif itype == "cjmp" or itype == "jmp" or itype == "ret-true" or
itype == "ret-false" or itype == "nop" or itype == "label" then
return {}
else
-- instructions don't have immediates in the first arg
return { instr[2], maybe_reg(instr[3]) }
end
end
-- Update the ends of intervals based on variable occurrences in
-- the "control" ast
local function find_live_in_control(label, control, intervals)
-- the head of an ast is always an operation name, so skip
for i = 2, #control do
local ast_type = type(control[i])
if ast_type == "string" then
for _, interval in ipairs(intervals) do
if control[i] == interval.name then
interval.finish = label
end
end
elseif ast_type == "table" then
find_live_in_control(label, control[i], intervals)
end
end
end
-- The lack of loops and unique register names for each load
-- in the instruction IR makes finding live intervals easy.
--
-- A live interval is a table
-- { name = String, start = number, finish = number }
--
-- The start and finish fields are indices into the instruction
-- array
--
local function live_intervals(instrs)
local len = { name = "len", start = 1, finish = 1 }
local order = { len }
local intervals = { len = len }
for idx, instr in ipairs(instrs) do
local itype = instr[1]
-- movs and loads are the only instructions that result in
-- new live intervals
if itype == "load" or itype == "mov" or itype == "mov64" then
local name = instr[2]
local interval = { name = name,
start = idx,
finish = idx }
intervals[name] = interval
table.insert(order, interval)
end
for _, reg in ipairs(reads_from(instr)) do
intervals[reg].finish = idx
end
end
-- we need the resulting allocations to be ordered by starting
-- point, so we emit the ordered sequence rather than the map
return order
end
-- Check if a register is free in the freelist
local function is_free(seq, reg)
for _, val in ipairs(seq) do
if val == reg then
return true
end
end
return false
end
-- Remove the given register from the freelist
local function remove_free(freelist, reg)
for idx, reg2 in ipairs(freelist) do
if reg2 == reg then
table.remove(freelist, idx)
return
end
end
end
-- Insert an interval sorted by increasing finish
local function insert_active(active, interval)
local finish = interval.finish
for idx, interval2 in ipairs(active) do
if interval2.finish > finish then
table.insert(active, idx, interval)
return
end
end
table.insert(active, interval)
end
-- Optimize movs from a register to the same one
local function delete_useless_movs(ir, alloc)
for idx, instr in ipairs(ir) do
if instr[1] == "mov" then
if alloc[instr[2]] == alloc[instr[3]] then
-- It's faster just to convert these to
-- nops than to re-number the table
ir[idx] = { "nop" }
end
end
end
end
-- All available registers, tied to unix x64 ABI
x86_regs = {
caller_regs = {11, 10, 9, 8, 6, 2, 1, 0},
callee_regs = {15, 14, 13, 12, 3},
len = 6 -- %rsi
}
-- Do register allocation with the given IR
-- Returns a register allocation and potentially mutates
-- the ir for optimizations
function allocate(ir, regs)
regs = regs or x86_regs
local intervals = live_intervals(ir)
local active = {}
local next_spill = 0
-- caller-save registers, use these first
local free_caller = utils.dup(regs.caller_regs)
-- callee-save registers, if we have to
local free_callee = utils.dup(regs.callee_regs)
local allocation = { len = regs.len,
callee_saves = {},
spills = {} }
remove_free(free_caller, allocation.len)
local function expire_old(interval)
local to_expire = {}
for idx, active_interval in ipairs(active) do
if active_interval.finish > interval.start then
break
else
local name = active_interval.name
local reg = allocation[name]
table.insert(to_expire, idx)
-- figure out which free list this register is supposed to be on
if is_free(regs.caller_regs, reg) then
table.insert(free_caller, reg)
elseif is_free(regs.callee_regs, reg) then
table.insert(free_callee, reg)
else
error("unknown register")
end
end
end
for i=1, #to_expire do
table.remove(active, to_expire[#to_expire - i + 1])
end
end
local function spill_at(interval)
-- when there's a first spill, pick two additional variables
-- to spill to the stack and reserve their registers for accessing
-- spilled variables via movs
if next_spill == 0 then
local i1, i2 = active[#active], active[#active-1]
local reg1 = allocation[i1.name]
local reg2 = allocation[i2.name]
table.remove(active); table.remove(active)
allocation[i1.name] = nil
allocation[i2.name] = nil
allocation.spills[i1.name] = 0
allocation.spills[i2.name] = 1
allocation.spill_registers = { reg1, reg2 }
next_spill = next_spill + 2
end
local to_spill = active[#active]
if to_spill.finish > interval.finish then
allocation[interval.name] = allocation[to_spill.name]
allocation[to_spill.name] = nil
allocation.spills[to_spill.name] = next_spill
table.remove(active)
insert_active(active, interval)
else
allocation.spills[interval.name] = next_spill
end
next_spill = next_spill + 1
end
for _, interval in pairs(intervals) do
local name = interval.name
expire_old(interval)
-- because we prefill some registers, check first if
-- we need to allocate for this interval
if not allocation[name] then
if #free_caller == 0 and #free_callee == 0 then
spill_at(interval)
-- newly freed registers are put at the end, so allocating from
-- the end will tend to produce better results since we want to
-- try eliminate movs with the same destination/source register
elseif #free_caller ~= 0 then
allocation[name] = free_caller[#free_caller]
table.remove(free_caller)
insert_active(active, interval)
else
local idx = #free_callee
allocation[name] = free_callee[idx]
allocation.callee_saves[free_callee[idx]] = true
table.remove(free_callee)
insert_active(active, interval)
end
else
insert_active(active, interval)
end
end
delete_useless_movs(ir, allocation)
if verbose then
utils.pp({ "register_allocation", allocation })
end
return allocation
end
function selftest()
local function test(instrs, expected)
utils.assert_equals(expected, live_intervals(instrs))
end
-- part of `tcp`, see pf.selection
local example_1 =
{ { "label", 0 },
{ "cmp", "len", 34 },
{ "cjmp", "<", 4 },
{ "label", 3 },
{ "load", "v1", 12, 2 },
{ "cmp", "v1", 8 },
{ "cjmp", "!=", 6 },
{ "label", 5 },
{ "load", "r1", 23, 1 },
{ "cmp", "r1", 6 },
{ "cjmp", "=", "true-label" },
{ "ret-false" },
{ "label", 6 },
{ "cmp", "len", 54 },
{ "cjmp", "<", 8 },
{ "label", 7 },
{ "cmp", "v1", 56710 },
{ "cjmp", "!=", 10 },
{ "label", 9 },
{ "load", "v2", 20, 1 },
{ "cmp", "v2", 6 },
{ "cjmp", "!=", 12 } }
local example_2 =
{ { "label", 1 },
{ "load", "r1", 12, 2 },
{ "load", "r2", 14, 2 },
{ "mov", "r3", "r1" },
{ "mul", "r3", "r2" },
{ "cmp", "r3", 1 },
{ "cjmp", "!=", 4 },
{ "cmp", "len", 1 } }
-- this example isn't from real code, but tests what happens when
-- there is higher register pressure
local example_3 =
{ { "label", 1 },
{ "load", "r1", 12, 2 },
{ "load", "r2", 14, 2 },
{ "load", "r3", 15, 2 },
{ "load", "r4", 16, 2 },
{ "load", "r5", 17, 2 },
{ "load", "r6", 18, 2 },
{ "load", "r7", 19, 2 },
{ "load", "r8", 20, 2 },
{ "load", "r9", 21, 2 },
{ "cmp", "r1", 1 },
{ "cmp", "r2", 1 },
{ "cmp", "r3", 1 },
{ "cmp", "r4", 1 },
{ "cmp", "r5", 1 },
{ "cmp", "r6", 1 },
{ "cmp", "r7", 1 },
{ "cmp", "r8", 1 },
{ "cmp", "r9", 1 } }
-- test that tries to make movs use same dst/src
local example_4 =
{ { "label", 1 },
{ "load", "v1", 12, 2 },
{ "cmp", "v1", 1 },
{ "load", "r1", 12, 2 },
{ "mov", "r2", "r1" },
{ "cmp", "r2", 1 },
{ "cmp", "len", 1 } }
-- full `tcp` example from more recent instruction selection
local example_5 =
{ { "label", 0 },
{ "cmp", "len", 34 },
{ "cjmp", "<", 4 },
{ "label", 3 },
{ "load", "r1", 12, 2 },
{ "mov", "v1", "r1" },
{ "cmp", "v1", 8 },
{ "cjmp", "!=", 6 },
{ "label", 5 },
{ "load", "r2", 23, 1 },
{ "cmp", "r2", 6 },
{ "cjmp", "=", "true-label" },
{ "ret-false" },
{ "label", 6 },
{ "cmp", "len", 54 },
{ "cjmp", "<", 8 },
{ "label", 7 },
{ "cmp", "v1", 56710 },
{ "cjmp", "!=", 10 },
{ "label", 9 },
{ "load", "r3", 20, 1 },
{ "mov", "v2", "r3" },
{ "cmp", "v2", 6 },
{ "cjmp", "!=", 12 },
{ "label", 11 },
{ "ret-true" },
{ "label", 12 },
{ "cmp", "len", 55 },
{ "cjmp", "<", 14 },
{ "label", 13 },
{ "cmp", "v2", 44 },
{ "cjmp", "!=", 16 },
{ "label", 15 },
{ "load", "r4", 54, 1 },
{ "cmp", "r4", 6 },
{ "cjmp", "=", "true-label" },
{ "ret-false" },
{ "label", 16 },
{ "ret-false" },
{ "label", 14 },
{ "ret-false" },
{ "label", 10 },
{ "ret-false" },
{ "label", 8 },
{ "ret-false" },
{ "label", 4 },
{ "ret-false" } }
-- test that variables in load offsets are properly accounted for
local example_6 =
{ { "label", 0 },
{ "mov", "r1", 5 },
{ "load", "v2", 12, 2 },
{ "load", "v1", "r1", 2 },
{ "cmp", "v1", 1 },
{ "cmp", "v2", 2 } }
-- another test with high register pressure, should be high enough
-- to require spilling
local example_7 =
{ { "label", 1 },
{ "load", "r1", 12, 2 },
{ "load", "r2", 14, 2 },
{ "load", "r3", 15, 2 },
{ "load", "r4", 16, 2 },
{ "load", "r5", 17, 2 },
{ "load", "r6", 18, 2 },
{ "load", "r7", 19, 2 },
{ "load", "r8", 20, 2 },
{ "load", "r9", 21, 2 },
{ "load", "r10", 22, 2 },
{ "load", "r11", 23, 2 },
{ "load", "r12", 24, 2 },
{ "load", "r13", 25, 2 },
{ "load", "r14", 26, 2 },
{ "cmp", "r1", 1 },
{ "cmp", "r2", 1 },
{ "cmp", "r3", 1 },
{ "cmp", "r4", 1 },
{ "cmp", "r5", 1 },
{ "cmp", "r6", 1 },
{ "cmp", "r7", 1 },
{ "cmp", "r8", 1 },
{ "cmp", "r9", 1 },
{ "cmp", "r10", 1 },
{ "cmp", "r11", 1 },
{ "cmp", "r12", 1 },
{ "cmp", "r13", 1 },
{ "cmp", "r14", 1 } }
test(example_1,
{ { name = "len", start = 1, finish = 14 },
{ name = "v1", start = 5, finish = 17 },
{ name = "r1", start = 9, finish = 10 },
{ name = "v2", start = 20, finish = 21 } })
test(example_2,
{ { name = "len", start = 1, finish = 8 },
{ name = "r1", start = 2, finish = 4 },
{ name = "r2", start = 3, finish = 5 },
{ name = "r3", start = 4, finish = 6 } })
test(example_5,
{ { name = "len", start = 1, finish = 28 },
{ name = "r1", start = 5, finish = 6 },
{ name = "v1", start = 6, finish = 18 },
{ name = "r2", start = 10, finish = 11 },
{ name = "r3", start = 21, finish = 22 },
{ name = "v2", start = 22, finish = 31 },
{ name = "r4", start = 34, finish = 35 } })
test(example_6,
{ { name = "len", start = 1, finish = 1 },
{ name = "r1", start = 2, finish = 4 },
{ name = "v2", start = 3, finish = 6 },
{ name = "v1", start = 4, finish = 5 } })
local function test(instrs, expected)
utils.assert_equals(expected, allocate(instrs))
end
test(example_1,
{ v1 = 0, r1 = 1, len = 6, v2 = 0,
callee_saves = {}, spills = {} })
-- mutates example_2
test(example_2,
{ r1 = 0, r2 = 1, r3 = 0, len = 6,
callee_saves = {}, spills = {} })
utils.assert_equals(example_2,
{ { "label", 1 },
{ "load", "r1", 12, 2 },
{ "load", "r2", 14, 2 },
{ "nop" },
{ "mul", "r3", "r2" },
{ "cmp", "r3", 1 },
{ "cjmp", "!=", 4 },
{ "cmp", "len", 1 } })
test(example_3,
{ r1 = 6, r2 = 0, r3 = 1, r4 = 2, r5 = 8, r6 = 9,
r7 = 10, r8 = 11, r9 = 3, len = 6,
callee_saves = utils.set(3), spills = {} })
test(example_4,
{ v1 = 0, r1 = 0, len = 6, r2 = 0, callee_saves = {},
spills = {} })
test(example_5,
{ len = 6, r1 = 0, v1 = 0, r2 = 1, r3 = 0,
v2 = 0, r4 = 0, callee_saves = {},
spills = {} })
test(example_7,
{ r1 = 6, r2 = 0, r3 = 1, r4 = 2, r5 = 8, r6 = 9,
r7 = 10, r8 = 11, r9 = 3, r10 = 12, r11 = 13,
spills = { r12 = 1, r13 = 0, r14 = 2 },
len = 6, callee_saves = utils.set(3, 12, 13, 14, 15),
spill_registers = { 15, 14 } })
end
| apache-2.0 |
Turttle/darkstar | scripts/zones/Windurst_Waters/npcs/Amagusa-Chigurusa.lua | 38 | 1418 | -----------------------------------
-- Area: Windurst Waters
-- NPC: Amagusa-Chigurusa
-- Type: Standard NPC
-- @pos -28.746 -4.5 61.954 238
-----------------------------------
package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/zones/Windurst_Waters/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local WildcatWindurst = player:getVar("WildcatWindurst");
if (player:getQuestStatus(WINDURST,LURE_OF_THE_WILDCAT_WINDURST) == QUEST_ACCEPTED and player:getMaskBit(WildcatWindurst,12) == false) then
player:startEvent(0x03a9);
else
player:startEvent(0x0232);
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 == 0x03a9) then
player:setMaskBit(player:getVar("WildcatWindurst"),"WildcatWindurst",12,true);
end
end;
| gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c98287529.lua | 2 | 2209 | --虚竜魔王アモルファクターP
function c98287529.initial_effect(c)
c:EnableReviveLimit()
--skip
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_SPSUMMON_SUCCESS)
e1:SetCondition(c98287529.skipcon)
e1:SetOperation(c98287529.skipop)
c:RegisterEffect(e1)
--disable
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetRange(LOCATION_MZONE)
e2:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e2:SetCode(EFFECT_DISABLE)
e2:SetTarget(c98287529.distg)
c:RegisterEffect(e2)
--search
local e3=Effect.CreateEffect(c)
e3:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY)
e3:SetCode(EVENT_TO_GRAVE)
e3:SetCondition(c98287529.condition)
e3:SetTarget(c98287529.target)
e3:SetOperation(c98287529.operation)
c:RegisterEffect(e3)
end
function c98287529.skipcon(e,tp,eg,ep,ev,re,r,rp)
return bit.band(e:GetHandler():GetSummonType(),SUMMON_TYPE_RITUAL)==SUMMON_TYPE_RITUAL
end
function c98287529.skipop(e,tp,eg,ep,ev,re,r,rp)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetTargetRange(0,1)
e1:SetCode(EFFECT_SKIP_M1)
e1:SetReset(RESET_PHASE+PHASE_END+RESET_OPPO_TURN)
Duel.RegisterEffect(e1,tp)
end
function c98287529.distg(e,c)
return c:IsType(TYPE_FUSION+TYPE_SYNCHRO+TYPE_XYZ)
end
function c98287529.condition(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD)
end
function c98287529.filter(c)
return c:IsSetCard(0xda) and not c:IsCode(98287529) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
end
function c98287529.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c98287529.filter,tp,LOCATION_DECK,0,1,nil) end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c98287529.operation(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,c98287529.filter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
| gpl-2.0 |
Turttle/darkstar | scripts/zones/Newton_Movalpolos/npcs/HomePoint#1.lua | 17 | 1210 | -----------------------------------
-- Area: Newton Movalpolos
-- NPC: HomePoint#1
-- @pos -415 -63.2 409 265
-----------------------------------
package.loaded["scripts/zones/Newton_Movalpolos/TextIDs"] = nil;
require("scripts/globals/settings");
require("scripts/zones/Newton_Movalpolos/TextIDs");
require("scripts/globals/homepoint");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
homepointMenu( player, 0x21fc, 83);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x21fc) then
if (option == 1) then
player:setHomePoint();
player:messageSpecial(HOMEPOINT_SET);
else
hpTeleport( player, option);
end
end
end; | gpl-3.0 |
dickeyf/darkstar | scripts/zones/Windurst_Woods/Zone.lua | 26 | 2352 | -----------------------------------
--
-- Zone: Windurst_Woods (241)
--
-----------------------------------
package.loaded["scripts/zones/Windurst_Woods/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/events/harvest_festivals");
require("scripts/globals/zone");
require("scripts/globals/settings");
require("scripts/zones/Windurst_Woods/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
applyHalloweenNpcCostumes(zone:getID())
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
-- FIRST LOGIN (START CS)
if (player:getPlaytime(false) == 0) then
if (OPENING_CUTSCENE_ENABLE == 1) then
cs = 0x016F;
end
player:setPos(0,0,-50,0);
player:setHomePoint();
end
-- MOG HOUSE EXIT
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
position = math.random(1,5) + 37;
player:setPos(-138,-10,position,0);
if (player:getMainJob() ~= player:getVar("PlayerMainJob")) then
cs = 0x7534;
end
player:setVar("PlayerMainJob",0);
end
return cs;
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;
-----------------------------------
-- 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 == 0x016F) then
player:messageSpecial(ITEM_OBTAINED,0x218);
elseif (csid == 0x7534 and option == 0) then
player:setHomePoint();
player:messageSpecial(HOMEPOINT_SET);
end
end; | gpl-3.0 |
mimetic/DIG-corona-library | examples/slideviewer+textrender+accordion/scripts/dmc/dmc_corona/lib/dmc_lua/lua_megaphone.lua | 4 | 3712 | --====================================================================--
-- dmc_lua/lua_megaphone.lua
--
-- Documentation: http://docs.davidmccuskey.com/
--====================================================================--
--[[
The MIT License (MIT)
Copyright (c) 2013-2015 David McCuskey
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 Lua Library : Lua Megaphone
--====================================================================--
-- Semantic Versioning Specification: http://semver.org/
local VERSION = "1.1.0"
--====================================================================--
--== Imports
local Objects = require 'lua_objects'
local LuaEventsMixin = require 'lua_events_mix'
--====================================================================--
--== Setup, Constants
-- setup some aliases to make code cleaner
local newClass = Objects.newClass
local Class = Objects.Class
local EventsMix = LuaEventsMixin.EventsMix
local singleton = nil
--====================================================================--
--== Megaphone Class
--====================================================================--
local Megaphone = newClass( { Class, EventsMix }, { name="Lua Megaphone" } )
--== Event Constants ==--
Megaphone.EVENT = 'megaphone_event'
--======================================================--
-- Start: Setup Lua Objects
function Megaphone:__new__( ... )
-- print( "Megaphone:__new__" )
EventsMix.__init__( self, ... )
end
--[[
function Megaphone:__destroy__( ... )
-- print( "Megaphone:__destroy__" )
EventsMix.__undoInit__( self )
end
--]]
-- END: Setup Lua Objects
--======================================================--
--====================================================================--
--== Public Methods
function Megaphone:say( message, data, params )
-- print( "Megaphone:say ", message )
params = params or {}
assert( type(message)=='string', "Megaphone:say, arg 'message' must be a string" )
assert( params==nil or type(params)=='table', "Megaphone:say, arg 'params' must be a table" )
--==--
self:dispatchEvent( message, data, params )
end
function Megaphone:listen( listener )
-- print( "Megaphone:listen " )
assert( type(listener)=='function', "Megaphone:listen, arg 'listener' must be a function" )
--==--
self:addEventListener( Megaphone.EVENT, listener )
end
function Megaphone:ignore( listener )
-- print( "Megaphone:ignore " )
assert( type(listener)=='function', "Megaphone:ignore, arg 'listener' must be a function" )
--==--
self:removeEventListener( Megaphone.EVENT, listener )
end
singleton = Megaphone:new()
return singleton
| mit |
SalvationDevelopment/Salvation-Scripts-TCG | c3659803.lua | 2 | 3085 | --オーバーロード・フュージョン
function c3659803.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:SetTarget(c3659803.target)
e1:SetOperation(c3659803.activate)
c:RegisterEffect(e1)
end
function c3659803.filter0(c)
return c:IsOnField() and c:IsAbleToRemove()
end
function c3659803.filter1(c,e)
return c:IsOnField() and c:IsAbleToRemove() and not c:IsImmuneToEffect(e)
end
function c3659803.filter2(c,e,tp,m,f,chkf)
return c:IsType(TYPE_FUSION) and c:IsAttribute(ATTRIBUTE_DARK) and c:IsRace(RACE_MACHINE) and (not f or f(c))
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf)
end
function c3659803.filter3(c)
return c:IsType(TYPE_MONSTER) and c:IsCanBeFusionMaterial() and c:IsAbleToRemove()
end
function c3659803.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local chkf=Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and PLAYER_NONE or tp
local mg1=Duel.GetFusionMaterial(tp):Filter(c3659803.filter0,nil)
local mg2=Duel.GetMatchingGroup(c3659803.filter3,tp,LOCATION_GRAVE,0,nil)
mg1:Merge(mg2)
local res=Duel.IsExistingMatchingCard(c3659803.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 mg3=fgroup(ce,e,tp)
local mf=ce:GetValue()
res=Duel.IsExistingMatchingCard(c3659803.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg3,mf,chkf)
end
end
return res
end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function c3659803.activate(e,tp,eg,ep,ev,re,r,rp)
local chkf=Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and PLAYER_NONE or tp
local mg1=Duel.GetFusionMaterial(tp):Filter(c3659803.filter1,nil,e)
local mg2=Duel.GetMatchingGroup(c3659803.filter3,tp,LOCATION_GRAVE,0,nil)
mg1:Merge(mg2)
local sg1=Duel.GetMatchingGroup(c3659803.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf)
local mg3=nil
local sg2=nil
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
mg3=fgroup(ce,e,tp)
local mf=ce:GetValue()
sg2=Duel.GetMatchingGroup(c3659803.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg3,mf,chkf)
end
if sg1:GetCount()>0 or (sg2~=nil and sg2:GetCount()>0) then
local sg=sg1:Clone()
if sg2 then sg:Merge(sg2) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local tg=sg:Select(tp,1,1,nil)
local tc=tg:GetFirst()
if sg1:IsContains(tc) and (sg2==nil or not sg2:IsContains(tc) or not Duel.SelectYesNo(tp,ce:GetDescription())) then
local mat1=Duel.SelectFusionMaterial(tp,tc,mg1,nil,chkf)
tc:SetMaterial(mat1)
Duel.Remove(mat1,POS_FACEUP,REASON_EFFECT+REASON_MATERIAL+REASON_FUSION)
Duel.BreakEffect()
Duel.SpecialSummon(tc,SUMMON_TYPE_FUSION,tp,tp,false,false,POS_FACEUP)
else
local mat2=Duel.SelectFusionMaterial(tp,tc,mg3,nil,chkf)
local fop=ce:GetOperation()
fop(ce,e,tp,tc,mat2)
end
tc:CompleteProcedure()
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c44394295.lua | 2 | 3204 | --影依融合
function c44394295.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_FUSION_SUMMON+CATEGORY_DECKDES)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetCountLimit(1,44394295+EFFECT_COUNT_CODE_OATH)
e1:SetTarget(c44394295.target)
e1:SetOperation(c44394295.activate)
c:RegisterEffect(e1)
end
function c44394295.filter0(c)
return c:IsType(TYPE_MONSTER) and c:IsCanBeFusionMaterial() and c:IsAbleToGrave()
end
function c44394295.filter1(c,e)
return not c:IsImmuneToEffect(e)
end
function c44394295.filter2(c,e,tp,m,f,chkf)
return c:IsType(TYPE_FUSION) and c:IsSetCard(0x9d) and (not f or f(c))
and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,tp,false,false) and c:CheckFusionMaterial(m,nil,chkf)
end
function c44394295.cfilter(c)
return c:GetSummonLocation()==LOCATION_EXTRA
end
function c44394295.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local chkf=Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and PLAYER_NONE or tp
local mg1=Duel.GetFusionMaterial(tp)
if Duel.IsExistingMatchingCard(c44394295.cfilter,tp,0,LOCATION_MZONE,1,nil) then
local mg2=Duel.GetMatchingGroup(c44394295.filter0,tp,LOCATION_DECK,0,nil)
mg1:Merge(mg2)
end
local res=Duel.IsExistingMatchingCard(c44394295.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 mg3=fgroup(ce,e,tp)
local mf=ce:GetValue()
res=Duel.IsExistingMatchingCard(c44394295.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg3,mf,chkf)
end
end
return res
end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function c44394295.activate(e,tp,eg,ep,ev,re,r,rp)
local chkf=Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and PLAYER_NONE or tp
local mg1=Duel.GetFusionMaterial(tp):Filter(c44394295.filter1,nil,e)
if Duel.IsExistingMatchingCard(c44394295.cfilter,tp,0,LOCATION_MZONE,1,nil) then
local mg2=Duel.GetMatchingGroup(c44394295.filter0,tp,LOCATION_DECK,0,nil)
mg1:Merge(mg2)
end
local sg1=Duel.GetMatchingGroup(c44394295.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg1,nil,chkf)
local mg3=nil
local sg2=nil
local ce=Duel.GetChainMaterial(tp)
if ce~=nil then
local fgroup=ce:GetTarget()
mg3=fgroup(ce,e,tp)
local mf=ce:GetValue()
sg2=Duel.GetMatchingGroup(c44394295.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg3,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,mg3,nil,chkf)
local fop=ce:GetOperation()
fop(ce,e,tp,tc,mat2)
end
tc:CompleteProcedure()
end
end
| gpl-2.0 |
Metastruct/pac3 | lua/pac3/editor/client/translations/korean.lua | 3 | 17427 | return {
["sprite path"] = "스프라이트 이미지",
["right upperarm"] = "오른쪽 팔 위쪽",
["neck"] = "목",
["size y"] = "y축 크기",
["draw shadow"] = "그림자 활성화",
["copy"] = "복사",
["start size"] = "시작 크기",
["clip"] = "자르기",
["size"] = "크기",
["reset view"] = "시야 재설정",
["right calf"] = "오른쪽 종아리",
["effect"] = "이펙트",
["max"] = "최대",
["angles"] = "각도",
["left foot"] = "왼발",
["font"] = "글꼴",
["wear"] = "착용",
["load"] = "불러오기",
["bodygroup state"] = "바디그룹 상태",
["size x"] = "크기 x축",
["relative bones"] = "상대적 뼈",
["scale"] = "규모",
["follow"] = "따라가기",
["outline color"] = "테두리 색상",
["left thigh"] = "왼쪽 허벅지",
["bone"] = "뼈",
["invert"] = "뒤집기",
["double face"] = "두 얼굴",
["clear"] = "지우기",
["right forearm"] = "오른쪽 팔",
["left hand"] = "왼손",
["left upperarm"] = "왼쪽 팔 위쪽",
["false"] = "비활성화",
["alpha"] = "투명도",
["use lua"] = "루아 사용",
["sprite"] = "스프라이트",
["my outfit"] = "내 의상",
["right hand"] = "오른손",
["angle velocity"] = "각도 회전",
["right clavicle"] = "오른쪽 쇄골",
["outline"] = "윤곽선",
["string"] = "문자열",
["left clavicle"] = "왼쪽 쇄골",
["color"] = "색상",
["save"] = "저장",
["parent name"] = "상위 이름",
["toggle t pose"] = "t포즈 고정",
["outline alpha"] = "윤곽선 투명도",
["remove"] = "지우기",
["spine 4"] = "등 4",
["skin"] = "스킨",
["command"] = "명령어",
["material"] = "재질",
["sound"] = "소리",
["fullb??right"] = "최대밝기",
["true"] = "활성화",
["spine 2"] = "등 2",
["bone merge"] = "관절 병합",
["animation"] = "애니메이션",
["spine 1"] = "등 1",
["text"] = "텍스트",
["rate"] = "속도",
["operator"] = "연산자",
["spine"] = "등",
["loop"] = "반복",
["clone"] = "복제",
["position"] = "위치",
["model"] = "모델",
["left toe"] = "왼쪽 발가락",
["pelvis"] = "골반",
["pitch"] = "간격",
["right toe"] = "오른쪽 발가락",
["right finger 2"] = "오른쪽 손가락 2",
["add parts to me!"] = "나에게 파트를 추가하세요!",
["group"] = "그룹",
["right foot"] = "오른발",
["aim part name"] = "에임 파트",
["left calf"] = "왼쪽 종아리",
["rotate origin"] = "회전 원점",
["trail path"] = "트레일 경로",
["reset eye angles"] = "눈 각도 재설정",
["volume"] = "볼륨",
["entity"] = "엔티티",
["modify"] = "수정",
["draw weapon"] = "무기 보기",
["hide"] = "숨김",
["length"] = "길이",
["offset"] = "오프셋",
["owner name"] = "소유자 이름",
["head"] = "머리",
["bodygroup"] = "바디그룹",
["brightness"] = "밝기",
["eye angles"] = "눈의 각도",
["event"] = "이벤트",
["trail"] = "트레일",
["arguments"] = "인수",
["name"] = "이름",
["right thigh"] = "오른쪽 허벅지",
["ping pong loop"] = "핑 퐁 루프",
["min"] = "최소",
["left forearm"] = "왼쪽 팔",
["light"] = "빛",
["bone merge alternative"] = "대체관절 병합",
["origin fix"] = "프롭 고치기",
["owner entity"] = "엔티티 소유자",
["overall size"] = "전체관절 두깨",
["fullbright"] = "최대광원",
["follow part name"] = "따르는 파트 이름",
["hide entity"] = "엔티티 숨기기",
["save parts"] = "파트를 저장",
["load parts"] = "파트를 불러오기",
["toggle breathing"] = "호홉동작 고정",
["parts"] = "파트를",
["modified"] = "저장 날짜",
["jiggle"] = "피직스파트 설정",
["start color"] = "시작 색상",
["end color"] = "끝나는 색상",
["stretch"] = "늘리기",
["spacing"] = "간격",
["end size"] = "끝나는 크기",
["min pitch"] = "최소 빠르기",
["max pitch"] = "최대 빠르기",
["show editor"] = "에디터 보이기",
["wear on server"] = "착용 ",
["clear"] = "지우기",
["convert active pac2 outfit pac2"] = "의상 컨버팅",
["draw distance"] = "의상 활성화 거리",
["wear parts"] = "파트를 착용",
["clear parts"] = "파트를 초기화",
["toggle focus"] = "포커스 토글",
["language"] = "언어 설정",
["help"] = "도움말",
["draw order"] = "렌더 순서",
["root owner"] = "루트 오너",
["halo"] = "빛나는 테두리",
["particles"] = "파티클",
["sunbeams"] = "햇살",
["woohoo"] = "모자이크",
["start alpha"] = "처음 알파값",
["end alpha"] = "끝 알파값",
["multiplier"] = "효과 배율",
["darken"] = "어두움",
["function"] = "함수",
["input"] = "입력",
["weapon hold type"] = "무기 잡는 방식",
["variable name"] = "변수 이름",
["input multiplier"] = "효과 배율",
["expression"] = "수식",
["cell shade"] = "만화 테두리",
["axis"] = "축",
["additive"] = "첨가",
["input divider"] = "인풋 분산",
-- momo
--poseparameter
["poseparameter"] = "자세한도",
["pose parameter"] = "자세 한도",
["range"] = "범위",
-- Animation
["sequence name"] = "장면 이름",
["owner cycle"] = "사용자에게 직접적용",
["physgun"] = "게리건",
["zombie"] = "좀비",
["angry"] = "화남",
["camera"] = "카메라",
["crossbow"] = "크로스 보우",
["duel"] = "듀얼 건",
["fist"] = "주먹",
["grenade"] = "폭탄",
["knife"] = "나이프",
["magic"] = "마법",
["melee"] = "검1",
["melee2"] = "검2",
["meleeangry"] = "검 화남",
["normal"] = "노멀",
["passive"] = "패시브",
["pistol"] = "피스톨",
["revolver"] = "리볼버",
["rpg"] = "RPG",
["scared"] = "두려움",
["shotgut"] = "샷건",
["slam"] = "슬램",
["suitcase"] = "슈트 케이스",
["smg"] = "SMG",
-- Ogg
["ogg"] = "노래 불러오기",
["echo"] = "에코",
["echo feedback"] = "에코 피드백",
["echo delay"] = "에코 지연 속도",
["play on footstep"] = "발소리로 변경",
["play count"] = "재생 횟수",
["filter type"] = "필터 종류",
["filter fraction"] = "필터 부분",
["doppler"] = "도플러 효과",
["stop on hide"] = "멈추기",
["pause on hide"] = "정지 시키기",
["overlapping"] = "중복",
-- Proxy
["proxy"] = "프록시",
["pow"] = "pow값",
["zero eye pitch"] = "제로 눈 피치",
["reset velocities on hide"] = "숨김 속도 리셋",
["velocity roughness"] = "거칠기 속도",
-- jiggle
["constrain x"] = "X값 제한",
["constrain y"] = "Y값 제한",
["constrain z"] = "Z값 제한",
["strain"] = "압력",
["constant velocity"] = "정수 속도",
["local velocity"] = "로컬 속도",
["jiggle angle"] = "각도가 움직임",
["jiggle position"] = "위치가 움직임",
["stop radius"] = "정지반경",
["ground"] = "땅바닥",
["reset on hide"] = "숨김 리셋",
["constrain pitch"] = "Pitch값 조정",
["constrain yaw"] = "Yaw값 조정",
["constrain roll"] = "Roll값 조정",
-- Physics
["physics"] = "물리",
["constrain sphere"] = "제한 영역",
["radius"] = "반경",
["box"] = "상자",
["self collision"] = "자가 충돌",
["collisions"] = "충돌",
["mass"] = "질량",
["seconds to arrive"] = "도착 시간",
["max speed"] = "최대 속도",
["max angular"] = "최대 각도",
["max speed damp"] = "최대 제동속도",
["max angular damp"] = "최대 제동각도",
["damp factor"] = "제동 팩터",
-- Shake
["shake"] = "흔들기",
["frequency"] = "진동 빈도",
["amplitude"] = "진폭",
["duration"] = "지속 시간",
-- Beam
["beam"] = "줄",
["end point name"] = "끝 지점",
["bend"] = "휘어짐",
["resolution"] = "해상도",
["width"] = "폭",
["width bend"] = "폭 휘어짐",
["width bend size"] = "폭 휘어짐 크기",
["texture stretch"] = "텍스쳐 늘리기",
["texture scroll"] = "텍스쳐 돌리기",
-- Fog
["fog"] = "안개",
["start"] = "시작",
["end"] = "끝",
["height"] = "높이",
-- Particle
["velocity"] = "거리",
["die time"] = "사라지는 시간",
["fire delay"] = "발사 지연시간",
["spread"] = "확산",
["start length"] = "시작 길이",
["end length"] = "끝 길이",
["bounce"] = "튕김",
["gravity"] = "중력",
["random colour"] = "랜덤 색깔",
["color1"] = "색1",
["color2"] = "색2",
["collide"] = "충돌",
["lighting"] = "명암",
["sliding"] = "슬라이딩",
["number particles"] = "파티클 갯수",
["air resistance"] = "기압 저항력",
["3 d"] = "3D",
["random roll speed"] = "랜덤 구르기 속도",
["roll delta"] = "델타 구르기",
["align to surface"] = "표면 조정",
["stick to surface"] = "표면 붙이기",
["double sided"] = "두개의 면을가진",
["particle angle velocity"] = "파티클 각도 거리",
["stick lifetime"] = "스틱 생명시간",
["stick start size"] = "스틱 시작 크기",
["stick end size"] = "스틱 끝 크기",
["stick start alpha"] = "스틱 시작 알파",
["stick end alpha"] = "스틱 끝 알파",
["owner velocity multiplier"] = "사용자 거리 제곱",
["draw manual"] = "수동 그리기",
-- born
["scale children"] = "하위목록 크기도 조정",
["alternative bones"] = "대채 관절",
["move children to origin"] = "하위목록 원점으로 이동",
["follow angles only"] = "각도만 따라가기",
["chest"] = "가슴",
["eyes"] = "눈",
["mouth"] = "입",
["forward"] = "",
["right trapezius"] = "오른쪽 승모근",
["right shoulder"] = "오른쪽 어꺠",
["right bicep"] = "오른쪽 상완이두근",
["right elbow"] = "오른쪽 팔꿈치",
["right ulna"] = "오른쪽 자뼈",
["right wrist"] = "오른쪽 손목",
["left trapezius"] = "왼쪽 승모근",
["left shoulder"] = "왼쪽 어꺠",
["left bicep"] = "왼쪽 상완이두근",
["left elbow"] = "왼쪽 팔꿈치",
["left ulna"] = "왼쪽 자뼈",
["left wrist"] = "왼쪽 손목",
-- projectile
["projectile"] = "발사체",
["damping"] = "감쇠",
["sphere"] = "영역",
["life time"] = "생명 시간",
["aim dir"] = "에임 감독",
["sticky"] = "달라붙음",
["delay"] = "딜레이",
["outfit part name"] = "내 의상 파트",
["physical"] = "물리",
["collide with owner"] = "사용자에 부딪힘",
-- entity
["player angles"] = "플레이어 각도",
["translucent"] = "반투명",
["inverse kinematics"] = "역 운동학",
["weapon"] = "무기",
["mute footsteps"] = "발소리 끄기",
["mute sounds"] = "소리 끄기",
["allow ogg when muted"] = "소리 껐을때 ogg 불러오기",
["hide bullets"] = "총알 숨기기",
["draw player on death"] = "죽었을때 플레이어 표시",
["use legacy scale"] = "오래된 크기조정 사용",
["sprint speed"] = "전력질주 속도",
["run speed"] = "달리기 속도",
["walk speed"] = "걷기 속도",
["crouch speed"] = "앉아서 이동 속도",
["full apart on death"] = "사망시 전부착용",
["death ragdollize parent"] = "사망시 전부 레그돌화",
["hide ragdoll on death"] = "사망시 레그돌 숨기기",
["animation rate"] = "애니메이션 속도",
-- Model
["position offset"] = "위치 기준변환",
["angle offset"] = "각도 기준변환",
["light blend"] = "밝기",
["alternative scaling"] = "비율 조정",
["texture filter"] = "텍스쳐 필터",
["tint color"] = "염색",
["angle part name"] = "앵글 파트이름",
["angle part multiplier"] = "앵글 파트승수",
["blur length"] = "블러 길이",
["blur spacing"] = "블러 공간",
["use player color"] = "플레이어색 사용",
["use weapon color"] = "무기색 사용",
-- Event
["affect children only"] = "하위목록에만 영향",
["target part name"] = "목표 부위 이름",
["is voice chatting"] = "음성 채팅사용중일때",
["has weapon"] = "무기를 들고있을때",
["timer"] = "타이머",
["model name"] = "모델 이름",
["is under water"] = "잠수중일때",
["ammo"] = "탄약",
["weapon class"] = "무기 종류",
["vehicle class"] = "탑승물 종류",
["owner health"] = "사용자의 체력",
["gravitygun punt"] = "중력건을 사용",
["say"] = "채팅중일때",
["is crouching"] = "주저앉아있을때",
["speed"] = "속도",
["is flashlight on"] = "손전등 사용중일때",
["is in noclip"] = "노클립 사용중일때",
["is on ground"] = "지상일때",
["owner armor"] = "사용자의 아머",
["is client"] = "오직 클라이언트만",
["equal"] = "같을때",
["not equal"] = "같지 않을때",
["above"] = "초과일때",
["equal or above"] = "이상일때",
["below"] = "미만일때",
["equal or below"] = "이하일때",
["maybe"] = "혹시나(Maybe)",
["time"] = "시간",
["advanced timer"] = "진보된 타이머",
["animation event"] = "애니메이션 이벤트",
["health lost"] = "HP 감소량",
["holdtype"] = "무기잡는 방식",
["fov"] = "시야",
["entity class"] = "엔티티 클래스",
["client spawned"] = "클라이언트 스폰",
["owner velocity forward"] = "사용자 전진속도",
["owner velocity length"] = "사용자 길이속도",
["owner velocity right"] = "사용자 우향속도",
["owner velocity up"] = "사용자 상승속도",
["parent velocity forward"] = "상위 전진속도",
["parent velocity length"] = "상위 길이속도",
["parent velocity right"] = "상위 우향속도",
["parent velocity up"] = "상위 상승속도",
-- holdtype
["walk"] = "걷기",
["crouch walk"] = "앉아서 걷기",
["reload stand"] = "서서 재장전",
["jump"] = "점프",
["attack stand primaryfire"] = "서서 주사격무기 공격",
["swim"] = "수영중",
["attack crouch primaryfire"] = "앉아서 주사격무기 공격",
["swim idle"] = "수영 자세",
["reload crouch"] = "앉아서 재장전",
["act range attack1"] = "어택1 범위",
["crouch idle"] = "앉은 자세",
["act land"] = "착륙",
["stand idle"] = "서있는 자세",
["run"] = "달리기",
["fallback"] = "대비책",
["noclip"] = "노클립",
["air"] = "공중",
["sitting"] = "(의자에)앉음",
["alternative rate"] = "대안 속도",
-- outline
["blur x"] = "x 블러",
["blur y"] = "y 블러",
["passes"] = "통과",
["amount"] = "총량",
["ignore z"] = "z각 무시",
["spherical size"] = "구 크기",
["shape"] = "날카로움",
["affect children"] = "하위목록에 영향",
--material
["alpha test"] = "알파 테스트",
["translucent x"] = "X값 반투명",
["blend tint by base alpha"] = "기존 알파값에의한 염색",
["distance alpha"] = "거리에따른 알파값",
["vertex alpha"] = "꼭지 알파값",
--webaudio
["minimum radius"] = "최소 반경",
["maximum radius"] = "최대 반경",
["inner angle"] = "안쪽 앵글",
["outer angle"] = "바깥쪽 앵글",
["outer volume"] = "바깥쪽 볼륨",
["random pitch"] = "랜덤 피치",
--body group
["body group name"] = "바디 그룹 이름",
["model index"] = "모델 인덱스",
--effects
["use particle tracer"] = "파티클 트레이서 사용",
["point a name"] = "포인트 A 이름",
["point b name"] = "포인트 B 이름",
["point c name"] = "포인트 C 이름",
["point d name"] = "포인트 D 이름",
--flex
["flex"] = "전선",
-- Pac3 menu
["new file"] = "새 파일",
["load from url"] = "URL에서 불러오기",
["ok"] = "확인",
["hide editor"] = "에디터 숨기기",
["reset view position"] = "시점 초기화",
["advanced mode"] = "고급 옵션 표기",
["show only with active weapon"] = "사용중인 무기표시",
["hide weapon"] = "무기 숨기기",
["show weapon"] = "무기 보이기",
["view"] = "보기",
["options"] = "옵션",
["player"] = "플레이어",
["tools"] = "도구",
["exit"] = "나가기",
["toggle basic mode"] = "기본 모드 켜기",
["disable input"] = "마우스 끄기",
["toggle camera follow"] = "카메라를 따라오게",
["camera follow"] = "카메라를 따라오게",
["show deprecated features"] = "쓸모없는 옵션 표기",
["rendering"] = "렌더링",
["draw in reflections"] = "반사광 그리기",
["t pose"] = "T 포즈",
["modifiers"] = "모델 수정",
["spawn as props"] = "프롭 소환하기",
["scale this and children"] = "크기 키우기",
["clear names"] = "이름 지우기",
["position grid size"] = "위치 그리드 크기",
["angles grid size"] = "각도 그리드 크기",
["duplicate"] = "복사하기",
["sound level"] = "사운드 레벨",
["style"] = "스타일",
["examples"] = "예제",
["help i have ocd (rounding numbers)"] = "OCD를 가지게하기 (라운딩 넘버)",
["copy global id"] = "글로벌 id 카피",
["paste"] = "붙여넣기",
["auto load (your spawn outfit)"] = "이 PAC를 스폰시 불러오기",
["advanced"] = "전문기능",
["effects"] = "이펙트",
["webaudio"] = "웹오디오",
["put parts in submenu"] = "부메뉴에 파트 넣기",
["automatic property size"] = "자동으로 크기맞추기",
["fix origin"] = "원점 수정",
["replace ogg with webaudio"] = "ogg를 웹오디오로 교체",
["free children from part"] = "자유로운 하위목록",
["square model scales..."] = "모델 비율조정",
["import editor tool from file..."] = "파일로부터 에디터 도구 가져오기",
["import editor tool from url..."] = "url로부터 에디터 도구 가져오기",
["round numbers"] = "라운드 넘버",
["record surrounding props to pac"] = "pac에 주변프롭들 기록",
["populate with bones"] = "뼈로 이동",
["populate with dummy bones"] = "더미 뼈로 이동",
["print part info"] = "파트 정보 출력",
["dump player submaterials"] = "플레이어 부재질 덤핑",
["stop all custom animations"] = "모든 커스텀애니메이션 정지",
["copy from faceposer tool"] = "얼굴조정 툴에서 복사해오기",
["script"] = "스크립트",
["custom_animation"] = "커스텀 애니메이션",
["about"] = "크레딧",
["find"] = "값",
["Getting Started"] = "시작 튜토리얼(영어)",
}
| gpl-3.0 |
mrbangi/telegram | 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 |
Turttle/darkstar | scripts/zones/North_Gustaberg/npcs/Kuuwari-Aori_WW.lua | 30 | 3063 | -----------------------------------
-- Area: North Gustaberg
-- NPC: Kuuwari-Aori, W.W.
-- Type: Outpost Conquest Guards
-- @pos -584.687 39.107 54.281 106
-----------------------------------
package.loaded["scripts/zones/North_Gustaberg/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/conquest");
require("scripts/zones/North_Gustaberg/TextIDs");
local guardnation = WINDURST; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno
local guardtype = 3; -- 1: city, 2: foreign, 3: outpost, 4: border
local region = GUSTABERG;
local csid = 0x7ff7;
-----------------------------------
-- 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 |
SalvationDevelopment/Salvation-Scripts-TCG | c20358953.lua | 2 | 1612 | --シャーク・ザ・クルー
function c20358953.initial_effect(c)
--special summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(20358953,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP)
e1:SetCode(EVENT_LEAVE_FIELD)
e1:SetCondition(c20358953.spcon)
e1:SetTarget(c20358953.sptg)
e1:SetOperation(c20358953.spop)
c:RegisterEffect(e1)
end
function c20358953.spcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:IsReason(REASON_DESTROY) and c:IsReason(REASON_EFFECT) and not c:IsLocation(LOCATION_DECK)
and c:GetPreviousControler()==tp and c:IsPreviousPosition(POS_FACEUP) and c:GetReasonPlayer()==1-tp
end
function c20358953.filter(c,e,tp)
return c:IsLevelBelow(4) and c:IsAttribute(ATTRIBUTE_WATER) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c20358953.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c20358953.filter,tp,LOCATION_DECK,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,2,tp,LOCATION_DECK)
end
function c20358953.spop(e,tp,eg,ep,ev,re,r,rp)
local ft=Duel.GetLocationCount(tp,LOCATION_MZONE)
if ft<=0 then return end
if Duel.IsPlayerAffectedByEffect(tp,59822133) then ft=1 end
if ft>2 then ft=2 end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c20358953.filter,tp,LOCATION_DECK,0,1,ft,nil,e,tp)
if g:GetCount()~=0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
end
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c100000538.lua | 2 | 1233 | --ワルキューレ・ブリュンヒルデ
function c100000538.initial_effect(c)
--atk
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e1:SetRange(LOCATION_MZONE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(c100000538.val)
c:RegisterEffect(e1)
--Destroy replace
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_DESTROY_REPLACE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetRange(LOCATION_MZONE)
e2:SetTarget(c100000538.desreptg)
c:RegisterEffect(e2)
end
function c100000538.filter(c)
return c:IsRace(RACE_DRAGON) or c:IsRace(RACE_WARRIOR)
end
function c100000538.val(e,c)
return Duel.GetMatchingGroupCount(c100000538.filter,c:GetControler(),LOCATION_MZONE,LOCATION_MZONE,nil)*300
end
function c100000538.desreptg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return c:IsReason(REASON_BATTLE) and c:IsFaceup() and c:GetDefense()>=1000 end
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_COPY_INHERIT)
e2:SetReset(RESET_EVENT+0x1ff0000)
e2:SetCode(EFFECT_UPDATE_DEFENSE)
e2:SetValue(-1000)
c:RegisterEffect(e2)
return true
end
| gpl-2.0 |
Turttle/darkstar | scripts/zones/Lower_Jeuno/npcs/Chenokih.lua | 37 | 1438 | -----------------------------------
-- Area: Lower Jeuno
-- NPC: Chenokih
-- Standard Merchant NPC
-----------------------------------
require("scripts/globals/shop");
package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil;
require("scripts/zones/Lower_Jeuno/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,CHENOKIH_SHOP_DIALOG);
stock = {0x3232,24500, -- Hose
0x3242,22632, -- Linen Slacks
0x3233,57600, -- Wool Hose
0x323A,14756, -- Wool Slops
0x3241,6348, -- Black Slacks
0x32B2,16000, -- Socks
0x32C2,14352, -- Shoes
0x32B3,35200, -- Wool Socks
0x32BA,9180, -- Chestnut Sabots
0x32C1,4128, -- Sandals
0x3509,11088, -- Black Cape
0x3500,1250} -- Scarlet Ribbon
showShop(player, STATIC, stock);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
piXelicidio/locas-ants | code/qlist.lua | 1 | 4340 | --- TQuickList; quick adding and removing collection.
local TQuickList = {}
--class functions
--- Returns a new node, usable for any TQuickList, not tied to this instance.
-- This actually can be created anywhere as long as the table has the required fields.
-- Why this? Becasue we don't want to create a new node everytime we add an obj to the list,
-- we can reuse the same node to jump from list to list (this will be very useful in the grid map later)
-- @param refObj the data you want to store in the node
function TQuickList.newNode( refObj )
local node =
{ refList = nil,
idx = 0,
obj = refObj
}
-- each node has the de capability to remove itself from the current list owner (refList)
function node.selfRemove()
-- TODO: think if we can remove this condition.
--if node.refList ~= nil then
node.refList.remove( node )
--end
end
return node
end
function TQuickList.create()
local qList = {
---Public properties (for quick access) that you should "THINK" are read-only, so... behave.
array = {}, -- store the list items, avoid using qList.array[index], some items may be nil
emptyItems = {}, -- store the index of the removed items on array
count = 0 -- keeps the item count updated
}
-- private fields
local fIter = nil
--public funcitons
--- Adds a node to the list
-- reuse empty items in the array if present
-- Warning: no validations, if you add the same node twice it gets duplicated
-- this not creates a new node, we are resuing node table from another qlist.
function qList.add( node )
local idx=0
if #qList.emptyItems~=0 then
-- reuse last removed position
idx = table.remove(qList.emptyItems)
qList.array[idx] = node
else
-- if no emptyItems (no arry[n]===nil ) to reuse then insert directly
idx = #qList.array + 1 --index is the last one
qList.array[idx] = node
end
node.idx = idx
node.refList = qList
qList.count = qList.count + 1
end
--- Creates a new node and adds it to the list, combines both .add and newNode, returns node
function qList.addNew( refObj )
local node = TQuickList.newNode( refObj )
qList.add( node )
return node
end
--- remove node quickly just setting it to nil, and saving the idex for reuse
-- no validations for optimization:
-- but be careful is node.refList~=qList or node.idx==0 ploff!!
-- TODO: think how to make it less prone to problems... or not?
function qList.remove( node )
qList.array[node.idx] = nil
node.refList = nil --TODO: unnecesary?
-- save array spot for reuse (not the node, the node is free to move to other list, or forget)
--table.insert( qList.emptyItems, node.idx )
qList.emptyItems[ #qList.emptyItems + 1] = node.idx
qList.count = qList.count - 1
end
--- pass each element to doFunc,
-- do it yourself with pairs(qList.array) to avoid this call
-- do not use iparis or for loop with qList.array[i],
-- will not work well because of nil values present
function qList.forEachObj( doFunc )
for _,item in pairs(qList.array) do
doFunc(item.obj)
end
end
--- pass each element to doFunc acting on Nodes version,
-- do it yourself with pairs(qList.array) to avoid this call
-- do not use iparis or for loop with qList.array[i],
-- will not work well because of nil values present
function qList.forEachNode( doFunc )
for _,item in pairs(qList.array) do
doFunc(item)
end
end
--- empty the list
function qList.clear()
--TODO
qList.array = {}
qList.emptyItems = {}
qList.count = 0
end
--- Set iterator to index = 0
function qList.iterReset()
fIter = nil
end
--- Return next item, move to next.
-- if reach end return nil
function qList.iterNext()
local idx, node = next( qList.array, fIter )
if idx then fIter = idx end
return node
end
--- TODO: repacks arrays removing nil items.
-- (Slowly) Optimize the array removing nil items, use wisely.
function qList.repack()
-- goes to every idx=emtpyItems[i]
-- remove array[idx]
-- update all the nodes after idx decreasing node.idx
-- repeat
end
return qList
end
return TQuickList
| mit |
SalvationDevelopment/Salvation-Scripts-TCG | c44920699.lua | 2 | 1734 | --炎舞-「天璇」
function c44920699.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_ATKCHANGE)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(TIMING_DAMAGE_STEP)
e1:SetCondition(c44920699.condition)
e1:SetTarget(c44920699.target)
e1:SetOperation(c44920699.activate)
c:RegisterEffect(e1)
--
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetRange(LOCATION_SZONE)
e3:SetTargetRange(LOCATION_MZONE,0)
e3:SetCode(EFFECT_UPDATE_ATTACK)
e3:SetTarget(aux.TargetBoolFunction(Card.IsRace,RACE_BEASTWARRIOR))
e3:SetValue(300)
c:RegisterEffect(e3)
end
function c44920699.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCurrentPhase()~=PHASE_DAMAGE or not Duel.IsDamageCalculated()
end
function c44920699.filter(c)
return c:IsFaceup() and c:IsRace(RACE_BEASTWARRIOR)
end
function c44920699.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c44920699.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c44920699.filter,tp,LOCATION_MZONE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
Duel.SelectTarget(tp,c44920699.filter,tp,LOCATION_MZONE,0,1,1,nil)
end
function c44920699.activate(e,tp,eg,ep,ev,re,r,rp)
if not e:GetHandler():IsRelateToEffect(e) then return end
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and tc:IsFaceup() then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
e1:SetValue(700)
tc:RegisterEffect(e1)
end
end
| gpl-2.0 |
Turttle/darkstar | scripts/globals/mobskills/Pyric_Blast.lua | 7 | 1063 | ---------------------------------------------
-- Pyric Blast
--
-- Description: Deals Fire damage to enemies within a fan-shaped area. Additional effect: Plague
-- Type: Breath
-- Ignores Shadows
-- Range: Unknown Cone
---------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------
function onMobSkillCheck(target,mob,skill)
if(mob:getFamily() == 316) then
local mobSkin = mob:getModelId();
if (mobSkin == 1796) then
return 0;
else
return 1;
end
end
if (mob:AnimationSub() == 0) then
return 0;
else
return 1;
end
end;
function onMobWeaponSkill(target, mob, skill)
local dmgmod = MobBreathMove(mob, target, 0.01, 0.1, ELE_FIRE, 200);
local dmg = MobFinalAdjustments(dmgmod,mob,skill,target,MOBSKILL_BREATH,MOBPARAM_FIRE,MOBPARAM_IGNORE_SHADOWS);
MobStatusEffectMove(mob, target, EFFECT_PLAGUE, 5, 3, 60);
target:delHP(dmg);
return dmg;
end;
| gpl-3.0 |
Turttle/darkstar | scripts/globals/items/lik_kabob.lua | 35 | 1264 | -----------------------------------------
-- ID: 5647
-- Item: Lik Kabob
-- Food Effect: 30 Min, All Races
-----------------------------------------
-- Dexterity 3
-- Attack 7
-- Mind -2
-----------------------------------------
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,5647);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_DEX, 3);
target:addMod(MOD_ATT, 7);
target:addMod(MOD_MND, -2);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_DEX, 3);
target:delMod(MOD_ATT, 7);
target:delMod(MOD_MND, -2);
end;
| gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c48049769.lua | 5 | 1882 | --サンダー・シーホース
function c48049769.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(48049769,0))
e1:SetCategory(CATEGORY_SEARCH)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_HAND)
e1:SetCountLimit(1,48049769)
e1:SetCost(c48049769.cost)
e1:SetTarget(c48049769.target)
e1:SetOperation(c48049769.operation)
c:RegisterEffect(e1)
end
function c48049769.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetActivityCount(tp,ACTIVITY_SPSUMMON)==0 and e:GetHandler():IsDiscardable() end
Duel.SendtoGrave(e:GetHandler(),REASON_COST+REASON_DISCARD)
--oath effects
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:SetReset(RESET_PHASE+PHASE_END)
e1:SetTargetRange(1,0)
Duel.RegisterEffect(e1,tp)
end
function c48049769.filter(c)
return c:IsRace(RACE_THUNDER) and c:IsAttribute(ATTRIBUTE_LIGHT) and c:GetLevel()==4 and c:IsAttackBelow(1600) and c:IsAbleToHand()
end
function c48049769.filter1(c,g)
return g:IsExists(Card.IsCode,1,c,c:GetCode())
end
function c48049769.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local g=Duel.GetMatchingGroup(c48049769.filter,tp,LOCATION_DECK,0,nil)
return g:IsExists(c48049769.filter1,1,nil,g)
end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,2,tp,LOCATION_DECK)
end
function c48049769.operation(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(c48049769.filter,tp,LOCATION_DECK,0,nil)
local sg=g:Filter(c48049769.filter1,nil,g)
if sg:GetCount()==0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local hg=sg:Select(tp,1,1,nil)
local hc=sg:Filter(Card.IsCode,hg:GetFirst(),hg:GetFirst():GetCode()):GetFirst()
hg:AddCard(hc)
Duel.SendtoHand(hg,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,hg)
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c62242678.lua | 2 | 8272 | --琰魔竜王 レッド・デーモン・カラミティ
function c62242678.initial_effect(c)
--synchro summon
c:EnableReviveLimit()
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetRange(LOCATION_EXTRA)
e1:SetCondition(c62242678.syncon)
e1:SetOperation(c62242678.synop)
e1:SetValue(SUMMON_TYPE_SYNCHRO)
c:RegisterEffect(e1)
--act limit
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(62242678,0))
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
e2:SetCondition(c62242678.limcon)
e2:SetTarget(c62242678.limtg)
e2:SetOperation(c62242678.limop)
c:RegisterEffect(e2)
--damage
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(62242678,1))
e3:SetCategory(CATEGORY_DAMAGE)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e3:SetCode(EVENT_BATTLE_DESTROYING)
e3:SetCondition(aux.bdcon)
e3:SetTarget(c62242678.damtg)
e3:SetOperation(c62242678.damop)
c:RegisterEffect(e3)
--spsummon
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(62242678,2))
e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e4:SetCode(EVENT_DESTROYED)
e4:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY)
e4:SetCondition(c62242678.spcon)
e4:SetTarget(c62242678.sptg)
e4:SetOperation(c62242678.spop)
c:RegisterEffect(e4)
--double tuner
local e5=Effect.CreateEffect(c)
e5:SetType(EFFECT_TYPE_SINGLE)
e5:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e5:SetCode(21142671)
c:RegisterEffect(e5)
end
function c62242678.matfilter1(c,syncard)
return c:IsType(TYPE_TUNER) and (c:IsLocation(LOCATION_HAND) or c:IsFaceup()) and c:IsCanBeSynchroMaterial(syncard)
end
function c62242678.matfilter2(c,syncard)
return c:IsNotTuner() and c:IsFaceup() and c:IsRace(RACE_DRAGON) and c:IsAttribute(ATTRIBUTE_DARK) and c:IsType(TYPE_SYNCHRO) and c:IsCanBeSynchroMaterial(syncard)
end
function c62242678.synfilter1(c,syncard,lv,g1,g2,g3)
local f1=c.tuner_filter
if c:IsHasEffect(EFFECT_HAND_SYNCHRO) then
return g3:IsExists(c62242678.synfilter2,1,c,syncard,lv,g2,f1,c)
else
return g1:IsExists(c62242678.synfilter2,1,c,syncard,lv,g2,f1,c)
end
end
function c62242678.synfilter2(c,syncard,lv,g2,f1,tuner1)
local f2=c.tuner_filter
if f1 and not f1(c) then return false end
if f2 and not f2(tuner1) then return false end
local mg=g2:Filter(c62242678.synfilter3,nil,f1,f2)
Duel.SetSelectedCard(Group.FromCards(c,tuner1))
return mg:CheckWithSumEqual(Card.GetSynchroLevel,lv,1,1,syncard)
end
function c62242678.synfilter3(c,f1,f2)
return (not f1 or f1(c)) and (not f2 or f2(c))
end
function c62242678.syncon(e,c,tuner,mg)
if c==nil then return true end
local tp=c:GetControler()
if Duel.GetLocationCount(tp,LOCATION_MZONE)<-2 then return false end
local g1=nil
local g2=nil
local g3=nil
if mg then
g1=mg:Filter(c62242678.matfilter1,nil,c)
g2=mg:Filter(c62242678.matfilter2,nil,c)
g3=g1:Clone()
else
g1=Duel.GetMatchingGroup(c62242678.matfilter1,tp,LOCATION_MZONE,LOCATION_MZONE,nil,c)
g2=Duel.GetMatchingGroup(c62242678.matfilter2,tp,LOCATION_MZONE,LOCATION_MZONE,nil,c)
g3=Duel.GetMatchingGroup(c62242678.matfilter1,tp,LOCATION_MZONE+LOCATION_HAND,LOCATION_MZONE,nil,c)
end
local pe=Duel.IsPlayerAffectedByEffect(tp,EFFECT_MUST_BE_SMATERIAL)
local lv=c:GetLevel()
if tuner then
local f1=tuner.tuner_filter
if not pe then
return g1:IsExists(c62242678.synfilter2,1,tuner,c,lv,g2,f1,tuner)
else
return c62242678.synfilter2(pe:GetOwner(),c,lv,g2,f1,tuner)
end
end
if not pe then
return g1:IsExists(c62242678.synfilter1,1,nil,c,lv,g1,g2,g3)
else
return c62242678.synfilter1(pe:GetOwner(),c,lv,g1,g2,g3)
end
end
function c62242678.synop(e,tp,eg,ep,ev,re,r,rp,c,tuner,mg)
local g=Group.CreateGroup()
local g1=nil
local g2=nil
local g3=nil
if mg then
g1=mg:Filter(c62242678.matfilter1,nil,c)
g2=mg:Filter(c62242678.matfilter2,nil,c)
g3=g1:Clone()
else
g1=Duel.GetMatchingGroup(c62242678.matfilter1,tp,LOCATION_MZONE,LOCATION_MZONE,nil,c)
g2=Duel.GetMatchingGroup(c62242678.matfilter2,tp,LOCATION_MZONE,LOCATION_MZONE,nil,c)
g3=Duel.GetMatchingGroup(c62242678.matfilter1,tp,LOCATION_MZONE+LOCATION_HAND,LOCATION_MZONE,nil,c)
end
local pe=Duel.IsPlayerAffectedByEffect(tp,EFFECT_MUST_BE_SMATERIAL)
local lv=c:GetLevel()
if tuner then
g:AddCard(tuner)
local f1=tuner.tuner_filter
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SMATERIAL)
local tuner2=nil
if not pe then
local t2=g1:FilterSelect(tp,c62242678.synfilter2,1,1,tuner,c,lv,g2,f1,tuner)
tuner2=t2:GetFirst()
else
tuner2=pe:GetOwner()
Group.FromCards(tuner2):Select(tp,1,1,nil)
end
g:AddCard(tuner2)
local f2=tuner2.tuner_filter
local mg2=g2:Filter(c62242678.synfilter3,nil,f1,f2)
Duel.SetSelectedCard(g)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SMATERIAL)
local m3=mg2:SelectWithSumEqual(tp,Card.GetSynchroLevel,lv,1,1,c)
g:Merge(m3)
else
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SMATERIAL)
local tuner1=nil
if not pe then
local t1=g1:FilterSelect(tp,c62242678.synfilter1,1,1,nil,c,lv,g1,g2,g3)
tuner1=t1:GetFirst()
else
tuner1=pe:GetOwner()
Group.FromCards(tuner1):Select(tp,1,1,nil)
end
g:AddCard(tuner1)
local f1=tuner1.tuner_filter
local t2=nil
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SMATERIAL)
if tuner1:IsHasEffect(EFFECT_HAND_SYNCHRO) then
t2=g3:FilterSelect(tp,c62242678.synfilter2,1,1,tuner1,c,lv,g2,f1,tuner1)
else
t2=g1:FilterSelect(tp,c62242678.synfilter2,1,1,tuner1,c,lv,g2,f1,tuner1)
end
local tuner2=t2:GetFirst()
g:AddCard(tuner2)
local f2=tuner2.tuner_filter
local mg2=g2:Filter(c62242678.synfilter3,nil,f1,f2)
Duel.SetSelectedCard(g)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SMATERIAL)
local m3=mg2:SelectWithSumEqual(tp,Card.GetSynchroLevel,lv,1,1,c)
g:Merge(m3)
end
c:SetMaterial(g)
Duel.SendtoGrave(g,REASON_MATERIAL+REASON_SYNCHRO)
end
function c62242678.limcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():GetSummonType()==SUMMON_TYPE_SYNCHRO
end
function c62242678.limtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetChainLimit(c62242678.chainlm)
end
function c62242678.chainlm(e,rp,tp)
return tp==rp
end
function c62242678.limop(e,tp,eg,ep,ev,re,r,rp)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CANNOT_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetTargetRange(0,1)
e1:SetValue(c62242678.aclimit)
e1:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e1,tp)
end
function c62242678.aclimit(e,re,tp)
return re:GetHandler():IsOnField() or re:IsHasType(EFFECT_TYPE_ACTIVATE)
end
function c62242678.damtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
local dam=e:GetHandler():GetBattleTarget():GetBaseAttack()
if dam<0 then dam=0 end
Duel.SetTargetPlayer(1-tp)
Duel.SetTargetParam(dam)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,dam)
end
function c62242678.damop(e,tp,eg,ep,ev,re,r,rp)
local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
Duel.Damage(p,d,REASON_EFFECT)
end
function c62242678.spcon(e,tp,eg,ep,ev,re,r,rp)
return rp~=tp and e:GetHandler():GetPreviousControler()==tp
end
function c62242678.spfilter(c,e,tp)
return c:IsLevelBelow(8) and c:IsRace(RACE_DRAGON) and c:IsAttribute(ATTRIBUTE_DARK)
and c:IsType(TYPE_SYNCHRO) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c62242678.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c62242678.spfilter(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(c62242678.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c62242678.spfilter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c62242678.spop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
end
end
| gpl-2.0 |
mohammadclash/STAR | plugins/media.lua | 376 | 1679 | do
local function run(msg, matches)
local receiver = get_receiver(msg)
local url = matches[1]
local ext = matches[2]
local file = download_to_file(url)
local cb_extra = {file_path=file}
local mime_type = mimetype.get_content_type_no_sub(ext)
if ext == 'gif' then
print('send_file')
send_document(receiver, file, rmtmp_cb, cb_extra)
elseif mime_type == 'text' then
print('send_document')
send_document(receiver, file, rmtmp_cb, cb_extra)
elseif mime_type == 'image' then
print('send_photo')
send_photo(receiver, file, rmtmp_cb, cb_extra)
elseif mime_type == 'audio' then
print('send_audio')
send_audio(receiver, file, rmtmp_cb, cb_extra)
elseif mime_type == 'video' then
print('send_video')
send_video(receiver, file, rmtmp_cb, cb_extra)
else
print('send_file')
send_file(receiver, file, rmtmp_cb, cb_extra)
end
end
return {
description = "When user sends media URL (ends with gif, mp4, pdf, etc.) download and send it to origin.",
usage = "When user sends media URL (ends with gif, mp4, pdf, etc.) download and send it to origin.",
patterns = {
"(https?://[%w-_%.%?%.:/%+=&]+%.(gif))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(mp4))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(pdf))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(ogg))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(zip))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(mp3))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(rar))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(wmv))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(doc))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(avi))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(webp))$"
},
run = run
}
end
| gpl-2.0 |
mamaddeveloper/hhw | plugins/media.lua | 376 | 1679 | do
local function run(msg, matches)
local receiver = get_receiver(msg)
local url = matches[1]
local ext = matches[2]
local file = download_to_file(url)
local cb_extra = {file_path=file}
local mime_type = mimetype.get_content_type_no_sub(ext)
if ext == 'gif' then
print('send_file')
send_document(receiver, file, rmtmp_cb, cb_extra)
elseif mime_type == 'text' then
print('send_document')
send_document(receiver, file, rmtmp_cb, cb_extra)
elseif mime_type == 'image' then
print('send_photo')
send_photo(receiver, file, rmtmp_cb, cb_extra)
elseif mime_type == 'audio' then
print('send_audio')
send_audio(receiver, file, rmtmp_cb, cb_extra)
elseif mime_type == 'video' then
print('send_video')
send_video(receiver, file, rmtmp_cb, cb_extra)
else
print('send_file')
send_file(receiver, file, rmtmp_cb, cb_extra)
end
end
return {
description = "When user sends media URL (ends with gif, mp4, pdf, etc.) download and send it to origin.",
usage = "When user sends media URL (ends with gif, mp4, pdf, etc.) download and send it to origin.",
patterns = {
"(https?://[%w-_%.%?%.:/%+=&]+%.(gif))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(mp4))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(pdf))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(ogg))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(zip))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(mp3))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(rar))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(wmv))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(doc))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(avi))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(webp))$"
},
run = run
}
end
| gpl-2.0 |
Shayan123456/botttttt6 | plugins/media.lua | 376 | 1679 | do
local function run(msg, matches)
local receiver = get_receiver(msg)
local url = matches[1]
local ext = matches[2]
local file = download_to_file(url)
local cb_extra = {file_path=file}
local mime_type = mimetype.get_content_type_no_sub(ext)
if ext == 'gif' then
print('send_file')
send_document(receiver, file, rmtmp_cb, cb_extra)
elseif mime_type == 'text' then
print('send_document')
send_document(receiver, file, rmtmp_cb, cb_extra)
elseif mime_type == 'image' then
print('send_photo')
send_photo(receiver, file, rmtmp_cb, cb_extra)
elseif mime_type == 'audio' then
print('send_audio')
send_audio(receiver, file, rmtmp_cb, cb_extra)
elseif mime_type == 'video' then
print('send_video')
send_video(receiver, file, rmtmp_cb, cb_extra)
else
print('send_file')
send_file(receiver, file, rmtmp_cb, cb_extra)
end
end
return {
description = "When user sends media URL (ends with gif, mp4, pdf, etc.) download and send it to origin.",
usage = "When user sends media URL (ends with gif, mp4, pdf, etc.) download and send it to origin.",
patterns = {
"(https?://[%w-_%.%?%.:/%+=&]+%.(gif))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(mp4))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(pdf))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(ogg))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(zip))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(mp3))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(rar))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(wmv))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(doc))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(avi))$",
"(https?://[%w-_%.%?%.:/%+=&]+%.(webp))$"
},
run = run
}
end
| gpl-2.0 |
fgenesis/Aquaria_experimental | game_scripts/scripts/entities/energygodspirit.lua | 2 | 5617 | -- Copyright (C) 2007, 2010 - Bit-Blot
--
-- This file is part of Aquaria.
--
-- Aquaria is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License
-- as published by the Free Software Foundation; either version 2
-- of the License, or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--
-- See the GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
if not v then v = {} end
if not AQUARIA_VERSION then dofile("scripts/entities/entityinclude.lua") end
v.n = 0
v.curNote = -1
v.noteTimer = 0
v.delayTime = 2
v.delay = v.delayTime
v.attackDelay = 0
v.noteQuad = 0
v.maxHits = 6
v.hits = v.maxHits
local STATE_HURT = 1000
local STATE_SING = 1001
function init(me)
setupEntity(me)
entity_setEntityType(me, ET_ENEMY)
entity_setTexture(me, "particles/lines")
entity_setAllDamageTargets(me, false)
entity_rotate(me, 360, 1, -1)
entity_scale(me, 1.5, 1.5, 2, -1, 1, 1)
entity_setCollideRadius(me, 32)
entity_setState(me, STATE_IDLE)
entity_setBlendType(me, BLEND_ADD)
for i=0,7 do
loadSound(getNoteName(i, "low-"))
end
entity_addVel(me, randVector(500))
entity_setMaxSpeed(me, 300)
entity_alpha(me, 0)
loadSound("energyboss-die")
end
function postInit(me)
v.n = getNaija()
entity_setTarget(me, v.n)
playSfx("spirit-enter")
entity_alpha(me, 1, 1.5)
playMusic("ancienttest")
end
function update(me, dt)
entity_updateMovement(me, dt)
entity_doCollisionAvoidance(me, dt, 10, 0.2)
if entity_isState(me, STATE_IDLE) then
v.delay = v.delay - dt
if v.delay < 0 then
v.delay = v.delayTime
entity_setState(me, STATE_SING)
end
end
if entity_isState(me, STATE_SING) then
if v.holdingNote then
v.noteTimer = v.noteTimer + dt
if v.noteTimer > 1 then
-- hit it!
v.holdingNote = false
entity_setState(me, STATE_HURT)
end
end
if v.noteQuad ~= 0 then
quad_setPosition(v.noteQuad, entity_x(me), entity_y(me))
end
end
if entity_isState(me, STATE_ATTACK) then
entity_doEntityAvoidance(me, dt, 128, 0.2)
v.attackDelay = v.attackDelay + (dt * (1.0-(v.hits/v.maxHits))*3)
if v.attackDelay > 1 then
local s = createShot("energygodspirit", me, v.n, entity_x(me), entity_y(me))
v.attackDelay = 0
end
end
end
function enterState(me)
if entity_isState(me, STATE_IDLE) then
entity_animate(me, "idle", -1)
elseif entity_isState(me, STATE_HURT) then
entity_setMaxSpeedLerp(me, 4)
entity_setMaxSpeedLerp(me, 1, 5)
entity_addVel(me, randVector(500))
playSfx("secret")
playSfx("energyorbcharge")
entity_setStateTime(me, 3)
if v.hits == 1 then
entity_setStateTime(me, 0.5)
end
v.curNote = -1
spawnParticleEffect("energygodspirithit", entity_x(me), entity_y(me))
entity_heal(v.n, 0.5)
setSceneColor(0.5, 0.5, 1, 0.5)
entity_setMaxSpeed(me, entity_getMaxSpeed(me)+50)
elseif entity_isState(me, STATE_SING) then
entity_setStateTime(me, 5)
v.curNote = getRandNote()
local r, g, b = getNoteColor(v.curNote)
entity_color(me, r*0.9 + 0.1, g*0.9 + 0.1, b*0.9 + 0.1, 1)
playSfx(getNoteName(v.curNote, "low-"))
local t = 6
v.noteQuad = createQuad(string.format("Song/NoteSymbol%d", v.curNote), 6)
quad_alphaMod(v.noteQuad, 0.2)
quad_scale(v.noteQuad, 1, 1)
quad_scale(v.noteQuad, 3, 3, t, 0, 0, 1)
quad_setPosition(v.noteQuad, entity_x(me), entity_y(me))
quad_setBlendType(v.noteQuad, BLEND_ADD)
quad_delete(v.noteQuad, t)
setSceneColor(r*0.5 + 0.5, g*0.5 + 0.5, b*0.5 + 0.5, 1)
shakeCamera(4, 3)
elseif entity_isState(me, STATE_ATTACK) then
entity_setMaxSpeedLerp(me, 4)
entity_addVel(me, randVector(800))
--entity_moveTowardsTarget(me, 800, 1)
entity_setMaxSpeedLerp(me, 1, 5)
entity_setStateTime(me, 4)
setSceneColor(1, 0.5, 0.5, 1)
v.attackDelay = 0
elseif entity_isState(me, STATE_DEATHSCENE) then
end
end
function exitState(me)
if entity_isState(me, STATE_SING) then
entity_color(me, 1, 1, 1, 1)
--voice("laugh1")
entity_setState(me, STATE_ATTACK)
if v.noteQuad ~= 0 then
quad_delete(v.noteQuad, 1)
v.noteQuad = 0
end
elseif entity_isState(me, STATE_ATTACK) then
entity_setState(me, STATE_IDLE)
elseif entity_isState(me, STATE_HURT) then
v.hits = v.hits - 1
if v.hits <= 0 then
setFlag(FLAG_ENERGYGODENCOUNTER, 2)
entity_damage(me, v.n, 10000)
setSceneColor(1, 1, 1, 5)
fadeOutMusic(6)
shakeCamera(10, 4)
cam_toEntity(me)
shakeCamera(10, 4)
watch(4)
spawnParticleEffect("energygodspirithit", entity_x(me), entity_y(me))
playSfx("energyboss-die")
shakeCamera(15, 2)
watch(2)
playSfx("spirit-enter")
shakeCamera(20, 2)
watch(2)
cam_toEntity(getNaija())
local node = entity_getNearestNode(me, "energygodencounter")
if node ~= 0 then
node_activate(node)
end
else
entity_setState(me, STATE_ATTACK)
end
end
end
function damage(me, attacker, bone, damageType, dmg)
return true
end
function animationKey(me, key)
end
function hitSurface(me)
end
function songNote(me, note)
if v.curNote == note then
v.holdingNote = true
v.noteTimer = 0
end
end
function songNoteDone(me, note)
v.holdingNote = false
end
function song(me, song)
end
function activate(me)
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c18239909.lua | 2 | 3155 | --爆竜剣士イグニスターP
function c18239909.initial_effect(c)
--synchro summon
aux.AddSynchroProcedure(c,nil,aux.NonTuner(Card.IsType,TYPE_PENDULUM),1)
c:EnableReviveLimit()
--destroy
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(18239909,0))
e1:SetCategory(CATEGORY_DESTROY+CATEGORY_TODECK)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetRange(LOCATION_MZONE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCountLimit(1)
e1:SetTarget(c18239909.destg)
e1:SetOperation(c18239909.desop)
c:RegisterEffect(e1)
--spsummon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(18239909,1))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1)
e2:SetTarget(c18239909.sptg)
e2:SetOperation(c18239909.spop)
c:RegisterEffect(e2)
end
function c18239909.tgfilter(c)
if c:IsLocation(LOCATION_MZONE) then
return c:IsFaceup() and c:IsType(TYPE_PENDULUM)
else
return c:GetSequence()==6 or c:GetSequence()==7
end
end
function c18239909.desfilter(c)
return c18239909.tgfilter(c)
and Duel.IsExistingMatchingCard(Card.IsAbleToDeck,0,LOCATION_ONFIELD,LOCATION_ONFIELD,1,c)
end
function c18239909.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsOnField() and c18239909.desfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c18239909.desfilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil) end
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
local g=Duel.SelectTarget(tp,c18239909.desfilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_TODECK,nil,1,0,LOCATION_ONFIELD)
end
function c18239909.desop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and Duel.Destroy(tc,REASON_EFFECT)~=0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
local g=Duel.SelectMatchingCard(tp,Card.IsAbleToDeck,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,nil)
if g:GetCount()>0 then
Duel.HintSelection(g)
Duel.SendtoDeck(g,nil,2,REASON_EFFECT)
end
end
end
function c18239909.spfilter(c,e,tp)
return c:IsSetCard(0xc7) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c18239909.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c18239909.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) end
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
end
function c18239909.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,c18239909.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp)
local tc=g:GetFirst()
if tc then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP_DEFENSE)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CANNOT_BE_SYNCHRO_MATERIAL)
e1:SetReset(RESET_EVENT+0x1fe0000)
e1:SetValue(1)
tc:RegisterEffect(e1)
end
end
| gpl-2.0 |
longsion/OpenBird | Resources/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 |
dickeyf/darkstar | scripts/zones/Windurst_Waters/npcs/Cochal-Monchal.lua | 13 | 1597 | -----------------------------------
-- Area: Windurst Waters
-- NPC: Cochal-Monchal
-- Involved in Quest: Dark Legacy
-- @zone 238
-- @pos -52 -6 110
-----------------------------------
package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/zones/Windurst_Waters/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getVar("darkLegacyCS") == 2) then
player:startEvent(0x02b9,0,DARKSTEEL_FORMULA);
elseif (player:getVar("darkLegacyCS") == 3) then
player:startEvent(0x02ba,0,DARKSTEEL_FORMULA);
elseif (player:hasKeyItem(DARKSTEEL_FORMULA)) then
player:startEvent(0x02bb,0,DARKSTEEL_FORMULA);
else
player:startEvent(0x2b8);
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 == 0x02b9) then
player:setVar("darkLegacyCS",3);
player:delKeyItem(LETTER_FROM_THE_DARKSTEEL_FORGE);
end
end; | gpl-3.0 |
lionsoul2014/ip2region | binding/lua_c/bench_test.lua | 1 | 4913 | -- Copyright 2022 The Ip2Region Authors. All rights reserved.
-- Use of this source code is governed by a Apache2.0-style
-- license that can be found in the LICENSE file.
--
-- ---
-- @Author Lion <chenxin619315@gmail.com>
-- @Date 2022/06/30
-- set the package to load the current xdb_searcher.so
package.path = "./?.lua" .. package.path
package.cpath = "./?.so" .. package.cpath
local xdb = require("xdb_searcher")
function printHelp()
print("lua bench_test.lua [command options]")
print("options: ")
print(" --db string ip2region binary xdb file path")
print(" --src string source ip text file path")
print(" --cache-policy string cache policy: file/vectorIndex/content")
end
if #arg < 2 then
printHelp(arg)
return
end
-- parser the command line args
local dbFile, srcFile = "", ""
local cachePolicy = "vectorIndex"
for _, r in ipairs(arg) do
if string.len(r) < 5 then
goto continue
end
if string.sub(r, 1, 2) ~= "--" then
goto continue
end
for k, v in string.gmatch(string.sub(r, 3), "([^=]+)=([^%s]+)") do
if k == "db" then
dbFile = v
elseif k == "src" then
srcFile = v
elseif k == "cache-policy" then
cachePolicy = v
else
print(string.format("undefined option `%s`", r))
return
end
-- break the match iterate
break
end
-- continue this loop
::continue::
end
-- print(string.format("dbFile=%s, srcFile=%s, cachePolicy=%s", dbFile, srcFile, cachePolicy))
if string.len(dbFile) < 2 or string.len(srcFile) < 2 then
printHelp()
return
end
-- create the searcher based on the cache-policy
local searcher, v_index, content
if cachePolicy == "file" then
searcher, err = xdb.new_with_file_only(dbFile)
if err ~= nil then
print(string.format("failed to create searcher: %s", err))
return
end
elseif cachePolicy == "vectorIndex" then
v_index, err = xdb.load_vector_index(dbFile)
if err ~= nil then
print(string.format("failed to load vector index: %s", err))
return
end
searcher, err = xdb.new_with_vector_index(dbFile, v_index)
if err ~= nil then
print(string.format("failed to create vector index searcher: %s", err))
return
end
elseif cachePolicy == "content" then
content, err = xdb.load_content(dbFile)
if err ~= nil then
print(string.format("failed to load xdb content from '%s'", dbFile))
return
end
searcher, err = xdb.new_with_buffer(content)
if err ~= nil then
print(string.format("failed to create content buffer searcher: %s", err))
return
end
else
print(string.format("undefined cache-policy `%s`", cachePolicy))
return
end
-- do the bench test
local handle = io.open(srcFile, "r")
if handle == nil then
print(string.format("failed to open src text file `%s`", handle))
return
end
local lines = handle:lines()
local sip_str, eip_str, s_region, region = "", "", "", ""
local sip, mip, eip, err = 0, 0, 0, 0
local count, t_time, c_time = 0, 0, 0
local s_time = xdb.now()
for l in lines do
if string.len(l) < 1 then
goto continue
end
for v1, v2, v3 in string.gmatch(l, "([%d%.]+)|([%d%.]+)|([^\n]+)") do
-- print(sip_str, eip_str, region)
sip_str = v1
eip_str = v2
s_region = v3
break
end
sip, err = xdb.check_ip(sip_str)
if err ~= nil then
print(string.format("invalid start ip `%s`", sip_str))
return
end
eip, err = xdb.check_ip(eip_str)
if err ~= nil then
print(string.format("invalid end ip `%s`", sip_str))
return
end
if sip > eip then
print(string.format("start ip(%s) should not be greater than end ip(%s)\n", sip_str, eip_str))
return
end
mip = (sip + eip) >> 1
for _, ip in ipairs({sip, (sip + mip) >> 1, mip, (mip + eip) >> 1, eip}) do
t_time = xdb.now()
region, err = searcher:search(ip)
c_time = c_time + xdb.now() - t_time
if err ~= nil then
print(string.format("failed to search ip `%s`", xdb.long2ip(ip)))
return
end
-- check the region
if region ~= s_region then
printf(string.format("failed search(%s) with (%s != %s)\n", xdb.long2ip(ip), region, s_region))
return
end
count = count + 1
end
::continue::
end
-- resource cleanup
searcher:close()
if v_index ~= nil then
v_index:close()
end
if content ~= nil then
content:close()
end
-- print the stats
local avg_costs = 0
if count > 0 then
avg_costs = c_time / count
end
print(string.format("Bench finished, {cachePolicy: %s, total: %d, took: %.3f s, cost: %.3f μs/op}",
cachePolicy, count, (xdb.now() - s_time)/1e6, c_time / count)) | apache-2.0 |
dickeyf/darkstar | scripts/globals/spells/bluemagic/warm-up.lua | 27 | 1924 | -----------------------------------------
-- Spell: Warm-Up
-- Enhances accuracy and evasion
-- Spell cost: 59 MP
-- Monster Type: Beastmen
-- Spell Type: Magical (Earth)
-- Blue Magic Points: 4
-- Stat Bonus: VIT+1
-- Level: 68
-- Casting Time: 7 seconds
-- Recast Time: 120 seconds
-- Duration: 180 seconds
--
-- Combos: Clear Mind
-----------------------------------------
require("scripts/globals/status");
require("scripts/globals/magic");
require("scripts/globals/bluemagic");
-----------------------------------------
-- OnMagicCastingCheck
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onSpellCast(caster,target,spell)
local typeEffectOne = EFFECT_ACCURACY_BOOST
local typeEffectTwo = EFFECT_EVASION_BOOST
local power = 10;
local duration = 180;
local returnEffect = typeEffectOne;
if (caster:hasStatusEffect(EFFECT_DIFFUSION)) then
local diffMerit = caster:getMerit(MERIT_DIFFUSION);
if (diffMerit > 0) then
duration = duration + (duration/100)* diffMerit;
end;
caster:delStatusEffect(EFFECT_DIFFUSION);
end;
if (target:addStatusEffect(typeEffectOne,power,0,duration) == false and target:addStatusEffect(typeEffectTwo,power,0,duration) == false) then -- both statuses fail to apply
spell:setMsg(75);
elseif (target:addStatusEffect(typeEffectOne,power,0,duration) == false) then -- the first status fails to apply
target:addStatusEffect(typeEffectTwo,power,0,duration)
spell:setMsg(230);
returnEffect = typeEffectTwo;
else
target:addStatusEffect(typeEffectOne,power,0,duration)
target:addStatusEffect(typeEffectTwo,power,0,duration)
spell:setMsg(230);
end;
return returnEffect;
end; | gpl-3.0 |
TelegramDev/test | 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 |
SalvationDevelopment/Salvation-Scripts-TCG | c65591858.lua | 5 | 1981 | --先史遺産ウィングス・スフィンクス
function c65591858.initial_effect(c)
--summon success
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(65591858,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_SUMMON_SUCCESS)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCost(c65591858.spcost)
e1:SetTarget(c65591858.sptg)
e1:SetOperation(c65591858.spop)
c:RegisterEffect(e1)
Duel.AddCustomActivityCounter(65591858,ACTIVITY_SPSUMMON,c65591858.counterfilter)
end
function c65591858.counterfilter(c)
return c:IsSetCard(0x70)
end
function c65591858.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetCustomActivityCount(65591858,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:SetReset(RESET_PHASE+PHASE_END)
e1:SetTargetRange(1,0)
e1:SetTarget(c65591858.splimit)
Duel.RegisterEffect(e1,tp)
end
function c65591858.splimit(e,c,sump,sumtype,sumpos,targetp,se)
return not c:IsSetCard(0x70)
end
function c65591858.filter(c,e,tp)
return c:GetLevel()==5 and c:IsSetCard(0x70) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c65591858.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c65591858.filter(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(c65591858.filter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c65591858.filter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0)
end
function c65591858.spop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)
end
end
| gpl-2.0 |
Turttle/darkstar | scripts/zones/Southern_San_dOria/npcs/Rouva.lua | 17 | 1713 | -----------------------------------
-- Area: Southern San d'Oria
-- NPC: Rouva
-- Involved in Quest: Lure of the Wildcat (San d'Oria)
-- @pos -17 2 10 230
-------------------------------------
package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/zones/Southern_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE) == QUEST_ACCEPTED) then
if (trade:hasItemQty(532,1) and trade:getItemCount() == 1) then -- Trade Magicmart_flyer
player:messageSpecial(FLYER_REFUSED);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local WildcatSandy = player:getVar("WildcatSandy");
if (player:getQuestStatus(SANDORIA,LURE_OF_THE_WILDCAT_SAN_D_ORIA) == QUEST_ACCEPTED and player:getMaskBit(WildcatSandy,2) == false) then
player:startEvent(0x0328);
else
player:startEvent(0x0298);
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 == 0x0328) then
player:setMaskBit(player:getVar("WildcatSandy"),"WildcatSandy",2,true);
end
end; | gpl-3.0 |
hfjgjfg/avast50 | plugins/stats.lua | 1 | 3981 | do
-- Returns a table with `name` and `msgs`
local function get_msgs_user_chat(user_id, chat_id)
local user_info = {}
local uhash = 'user:'..user_id
local user = redis:hgetall(uhash)
local um_hash = 'msgs:'..user_id..':'..chat_id
user_info.msgs = tonumber(redis:get(um_hash) or 0)
user_info.name = user_print_name(user)..' ['..user_id..']'
return user_info
end
local function chat_stats(chat_id)
-- Users on chat
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
local users_info = {}
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = get_msgs_user_chat(user_id, chat_id)
table.insert(users_info, user_info)
end
-- Sort users by msgs number
table.sort(users_info, function(a, b)
if a.msgs and b.msgs then
return a.msgs > b.msgs
end
end)
local text = 'users in this chat \n'
for k,user in pairs(users_info) do
text = text..user.name..' = '..user.msgs..'\n'
end
local file = io.open("./groups/lists/"..chat_id.."stats.txt", "w")
file:write(text)
file:flush()
file:close()
send_document("chat#id"..chat_id,"./groups/lists/"..chat_id.."stats.txt", ok_cb, false)
return --text
end
local function chat_stats2(chat_id)
-- Users on chat
local hash = 'chat:'..chat_id..':users'
local users = redis:smembers(hash)
local users_info = {}
-- Get user info
for i = 1, #users do
local user_id = users[i]
local user_info = get_msgs_user_chat(user_id, chat_id)
table.insert(users_info, user_info)
end
-- Sort users by msgs number
table.sort(users_info, function(a, b)
if a.msgs and b.msgs then
return a.msgs > b.msgs
end
end)
local text = 'users in this chat \n'
for k,user in pairs(users_info) do
text = text..user.name..' = '..user.msgs..'\n'
end
return text
end
-- Save stats, ban user
local function bot_stats()
local redis_scan = [[
local cursor = '0'
local count = 0
repeat
local r = redis.call("SCAN", cursor, "MATCH", KEYS[1])
cursor = r[1]
count = count + #r[2]
until cursor == '0'
return count]]
-- Users
local hash = 'msgs:*:'..our_id
local r = redis:eval(redis_scan, 1, hash)
local text = 'Users: '..r
hash = 'chat:*:users'
r = redis:eval(redis_scan, 1, hash)
text = text..'\nGroups: '..r
return text
end
local function run(msg, matches)
if matches[1]:lower() == 'nod32' then -- Put everything you like :)
local about = _config.about_text
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] used /nod32 ")
return about
end
if matches[1]:lower() == "statslist" then
if not is_momod(msg) then
return "For mods only !"
end
local chat_id = msg.to.id
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested group stats ")
return chat_stats2(chat_id)
end
if matches[1]:lower() == "stats" then
if not matches[2] then
if not is_momod(msg) then
return "For mods only !"
end
if msg.to.type == 'chat' then
local chat_id = msg.to.id
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested group stats ")
return chat_stats(chat_id)
else
return
end
end
if matches[2] == "nod32" then -- Put everything you like :)
if not is_admin(msg) then
return "For admins only !"
else
return bot_stats()
end
end
if matches[2] == "group" then
if not is_admin(msg) then
return "For admins only !"
else
return chat_stats(matches[3])
end
end
end
end
return {
patterns = {
"^[!/]([Ss]tats)$",
"^[!/]([Ss]tatslist)$",
"^[!/]([Ss]tats) (group) (%d+)",
"^[!/]([Ss]tats) (gp)",-- Put everything you like :)
"^[!/]([Rr]sm)"-- Put everything you like :)
},
run = run
}
end
| gpl-2.0 |
Turttle/darkstar | scripts/zones/Inner_Horutoto_Ruins/npcs/_5cg.lua | 34 | 1075 | -----------------------------------
-- Area: Inner Horutoto Ruins
-- NPC: _5cg (Gate of Fire)
-- @pos -332 0 99 192
-----------------------------------
package.loaded["scripts/zones/Inner_Horutoto_Ruins/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Inner_Horutoto_Ruins/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:messageSpecial(DOOR_FIRMLY_CLOSED);
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);
end; | gpl-3.0 |
Turttle/darkstar | scripts/zones/The_Shrine_of_RuAvitau/npcs/qm2.lua | 24 | 1639 | -----------------------------------
-- Area: The Shrine of Ru'Avitau
-- NPC: ??? (Spawn Kirin)
-- @pos -81 32 2 178
-----------------------------------
package.loaded["scripts/zones/The_Shrine_of_RuAvitau/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/The_Shrine_of_RuAvitau/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
-- Ensure Kirin is not alive..
if (GetMobAction( 17506670 ) == 0) then
-- Validate traded items are all needed seals..
if (trade:hasItemQty( 1404, 1 ) and trade:hasItemQty( 1405, 1 ) and trade:hasItemQty( 1406, 1 ) and trade:hasItemQty( 1407, 1 ) and trade:getItemCount() == 4) then
-- Complete the trade..
player:tradeComplete();
-- Spawn Kirin..
local mob = SpawnMob( 17506670, 180 );
player:showText( npc, KIRIN_OFFSET );
mob:updateClaim( player );
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x0064);
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 |
trex2000/WifiBot | ESP8266/Web_Page/http_server.lua | 3 | 2335 | sendFileContents = function(conn, filename)
if file.open(filename, "r") then
--conn:send(responseHeader("200 OK","text/html"));
repeat
local line=file.readline()
if line then
conn:send(line);
end
until not line
file.close();
print("File sent");
else
print("File not found");
conn:send(responseHeader("404 Not Found","text/html"));
conn:send("Page not found");
end
end
responseHeader = function(code, type)
return "HTTP/1.1 " .. code .. "\r\nConnection: close\r\nServer: nunu-Luaweb\r\nContent-Type: " .. type .. "\r\n\r\n";
end
httpserver = function ()
print("HTTP Server function is started");
srv=net.createServer(net.TCP,60)
print("HTTP Server is created");
srv:listen(80,function(conn)
conn:on("receive",function(conn,request)
print("Request received");
conn:send(responseHeader("200 OK","text/html"));
if string.find(request,"gpio=0") then
print("onDown Up");
gpio.write(7, gpio.HIGH); --13 UP
elseif string.find(request,"gpio=1") then
print("onUp Up");
gpio.write(7, gpio.LOW); --13 UP
elseif string.find(request,"gpio=2") then
print("onDown Down");
gpio.write(6, gpio.HIGH); --12 DOWN
elseif string.find(request,"gpio=3") then
print("onUp Down");
gpio.write(6, gpio.LOW); --12 DOWN
elseif string.find(request,"gpio=4") then
print("onDown Left");
gpio.write(2, gpio.HIGH); --4 LEFT
elseif string.find(request,"gpio=5") then
print("onUp Left");
gpio.write(2, gpio.LOW); --4 LEFT
elseif string.find(request,"gpio=6") then
print("onDown Right");
gpio.write(1, gpio.HIGH); --5 RIGHT
elseif string.find(request,"gpio=7") then
print("onUp Right");
gpio.write(1, gpio.LOW); --5 RIGHT
else
sendFileContents(conn,"header.htm");
end
end)
print(request);
conn:on("sent",function(conn)
conn:close();
print("Connection closed");
conn = nil;
end)
end)
end
| gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c14745409.lua | 5 | 3748 | --聖剣ガラティーン
function c14745409.initial_effect(c)
c:SetUniqueOnField(1,0,14745409)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_EQUIP)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetTarget(c14745409.target)
e1:SetOperation(c14745409.operation)
c:RegisterEffect(e1)
--Atk up
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_EQUIP)
e2:SetCode(EFFECT_UPDATE_ATTACK)
e2:SetValue(1000)
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(c14745409.eqlimit)
c:RegisterEffect(e3)
--atkdown
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e4:SetCode(EVENT_PHASE+PHASE_STANDBY)
e4:SetRange(LOCATION_SZONE)
e4:SetCountLimit(1)
e4:SetCondition(c14745409.atkcon)
e4:SetOperation(c14745409.atkop)
c:RegisterEffect(e4)
--equip
local e5=Effect.CreateEffect(c)
e5:SetDescription(aux.Stringid(14745409,0))
e5:SetCategory(CATEGORY_EQUIP)
e5:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY)
e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e5:SetCode(EVENT_TO_GRAVE)
e5:SetCountLimit(1,14745409)
e5:SetCondition(c14745409.eqcon)
e5:SetTarget(c14745409.eqtg)
e5:SetOperation(c14745409.operation)
c:RegisterEffect(e5)
end
function c14745409.eqlimit(e,c)
return c:IsRace(RACE_WARRIOR)
end
function c14745409.eqfilter1(c)
return c:IsFaceup() and c:IsRace(RACE_WARRIOR)
end
function c14745409.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and c14745409.eqfilter1(chkc) end
if chk==0 then return Duel.IsExistingTarget(c14745409.eqfilter1,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
Duel.SelectTarget(tp,c14745409.eqfilter1,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0)
end
function c14745409.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if c:IsRelateToEffect(e) and tc and tc:IsRelateToEffect(e) and tc:IsFaceup() and c:CheckUniqueOnField(tp) then
Duel.Equip(tp,c,tc)
end
end
function c14745409.atkcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()==tp
end
function c14745409.atkop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:GetFlagEffect(14745409)==0 then
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_EQUIP)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(-200)
e1:SetReset(RESET_EVENT+0x1fe0000)
c:RegisterEffect(e1)
c:RegisterFlagEffect(14745409,RESET_EVENT+0x1fe0000,0,0)
e:SetLabelObject(e1)
e:SetLabel(2)
else
local pe=e:GetLabelObject()
local ct=e:GetLabel()
e:SetLabel(ct+1)
pe:SetValue(ct*-200)
end
end
function c14745409.eqcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:IsPreviousLocation(LOCATION_ONFIELD) and c:IsPreviousPosition(POS_FACEUP) and c:IsReason(REASON_DESTROY) and c:CheckUniqueOnField(tp)
end
function c14745409.eqfilter2(c)
return c:IsFaceup() and c:IsSetCard(0x107a) and c:IsRace(RACE_WARRIOR)
end
function c14745409.eqtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c14745409.eqfilter2(chkc) end
if chk==0 then return e:GetHandler():IsRelateToEffect(e) and Duel.GetLocationCount(tp,LOCATION_SZONE)>0
and Duel.IsExistingTarget(c14745409.eqfilter2,tp,LOCATION_MZONE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
Duel.SelectTarget(tp,c14745409.eqfilter2,tp,LOCATION_MZONE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0)
end
| gpl-2.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c4904633.lua | 2 | 2462 | --影依の原核
function c4904633.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(0,TIMING_END_PHASE)
e1:SetTarget(c4904633.target)
e1:SetOperation(c4904633.activate)
c:RegisterEffect(e1)
--tohand
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(4904633,0))
e2:SetCategory(CATEGORY_TOHAND)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_TO_GRAVE)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e2:SetCondition(c4904633.thcon)
e2:SetTarget(c4904633.thtg)
e2:SetOperation(c4904633.thop)
c:RegisterEffect(e2)
end
function c4904633.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,4904633,0,0x21,1450,1950,9,RACE_SPELLCASTER,ATTRIBUTE_DARK) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
end
function c4904633.activate(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToEffect(e) then return end
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0
or not Duel.IsPlayerCanSpecialSummonMonster(tp,4904633,0,0x21,1450,1950,9,RACE_SPELLCASTER,ATTRIBUTE_DARK) then return end
c:AddMonsterAttribute(TYPE_EFFECT+TYPE_TRAP)
Duel.SpecialSummonStep(c,0,tp,tp,true,false,POS_FACEUP)
c:AddMonsterAttributeComplete()
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(4904633)
e1:SetReset(RESET_EVENT+0x1fe0000)
c:RegisterEffect(e1,true)
Duel.SpecialSummonComplete()
end
function c4904633.thcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsReason(REASON_EFFECT)
end
function c4904633.thfilter(c)
return c:IsSetCard(0x9d) and c:IsType(TYPE_SPELL+TYPE_TRAP) and not c:IsCode(4904633) and c:IsAbleToHand()
end
function c4904633.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c4904633.thfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c4904633.thfilter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectTarget(tp,c4904633.thfilter,tp,LOCATION_GRAVE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
end
function c4904633.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 |
Turttle/darkstar | scripts/zones/Lower_Jeuno/npcs/HomePoint#1.lua | 17 | 1254 | -----------------------------------
-- Area: Lower Jeuno
-- NPC: HomePoint#1
-- @pos -98.588 0.001 -183.416 245
-----------------------------------
package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil;
require("scripts/globals/settings");
require("scripts/zones/Lower_Jeuno/TextIDs");
require("scripts/globals/homepoint");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
homepointMenu( player, 0x21fc, 35);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x21fc) then
if (option == 1) then
player:setHomePoint();
player:messageSpecial(HOMEPOINT_SET);
else
hpTeleport( player, option);
end
end
end; | gpl-3.0 |
dickeyf/darkstar | scripts/zones/Spire_of_Dem/npcs/_0j1.lua | 39 | 1330 | -----------------------------------
-- Area: Spire_of_Dem
-- NPC: web of regret
-----------------------------------
package.loaded["scripts/zones/Spire_of_Dem/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/bcnm");
require("scripts/zones/Spire_of_Dem/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (TradeBCNM(player,player:getZoneID(),trade,npc)) then
return;
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (EventTriggerBCNM(player,npc)) then
return 1;
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("onUpdate CSID: %u",csid);
--printf("onUpdate RESULT: %u",option);
if (EventUpdateBCNM(player,csid,option)) then
return;
end
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
--printf("onFinish CSID: %u",csid);
--printf("onFinish RESULT: %u",option);
if (EventFinishBCNM(player,csid,option)) then
return;
end
end; | gpl-3.0 |
SalvationDevelopment/Salvation-Scripts-TCG | c72563071.lua | 5 | 1656 | --サイコ・ショックウェーブ
function c72563071.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_CHAINING)
e1:SetCondition(c72563071.condition)
e1:SetCost(c72563071.cost)
e1:SetTarget(c72563071.target)
e1:SetOperation(c72563071.activate)
c:RegisterEffect(e1)
end
function c72563071.condition(e,tp,eg,ep,ev,re,r,rp)
return ep~=tp and re:IsActiveType(TYPE_TRAP) and re:IsHasType(EFFECT_TYPE_ACTIVATE)
end
function c72563071.cfilter(c)
return c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsDiscardable()
end
function c72563071.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c72563071.cfilter,tp,LOCATION_HAND,0,1,e:GetHandler()) end
Duel.DiscardHand(tp,c72563071.cfilter,1,1,REASON_COST+REASON_DISCARD)
end
function c72563071.spfilter(c,e,tp)
return c:GetLevel()==6 and c:IsAttribute(ATTRIBUTE_DARK) and c:IsRace(RACE_MACHINE)
and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c72563071.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c72563071.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
end
function c72563071.activate(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c72563071.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp)
if g:GetCount()~=0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
end
end
| gpl-2.0 |
jokersso3/joker | plugins/Groups.lua | 22 | 2731 | local function chat_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 your bot Groups:\n\n '
for k,v in pairs(data[tostring(groups)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairsByKeys(settings) do
if m == 'set_name' then
name = n
end
end
message = message .. '️ '.. name .. ' (ID: ' .. v .. ')\n\n '
end
local file = io.open("./system/chats/lists/listed_groups.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function run(msg, matches)
if msg.to.type ~= 'chat' or is_sudo(msg) and is_realm(msg) then
local data = load_data(_config.moderation.data)
if is_sudo(msg) or is_vip(msg) then
if matches[1] == 'link' and data[tostring(matches[2])] then
if is_banned(msg.from.id, matches[2]) then
return 'You are in ban'
end
if is_gbanned(msg.from.id) then
return 'You are in Globalban or Superban'
end
if data[tostring(matches[2])]['settings']['lock_member'] == 'yes' and not is_owner2(msg.from.id, matches[2]) then
return 'Group is private.'
end
local chat_id = "chat#id"..matches[2]
local user_id = "user#id"..msg.from.id
chat_add_user(chat_id, user_id, ok_cb, false)
local group_link = data[tostring(matches[2])]['settings']['set_link']
local group_name = data[tostring(matches[2])]['settings']['set_name']
return "Group Link is:\n"..group_link.."\n\n (Group name:"..group_name..")\n"
elseif matches[1] == 'link' and not data[tostring(matches[2])] then
return "Group not found"
end
end
end
if matches[1] == 'groups' or matches[1] == 'chats' then
if is_sudo(msg) and msg.to.type == 'chat' then
return chat_list(msg)
elseif msg.to.type ~= 'chat' then
return chat_list(msg)
end
end
if matches[1] == 'help' and msg.to.type == 'user' then
text = "Welcome to my bot!\n\nTo get a list of bot groups use /chats or /groups for list of chats.\n\n"
return text
end
end
return {
description = "See link of a group and groups list",
usage = "!link ID && !groups",
advan = {
"Created by: @janlou",
"Powered by: @AdvanTM",
"CopyRight all right reserved",
},
patterns = {
"^[!#/]([Ll]ink) (.*)$",
"^[!#/]([Gg]roups)$",
"^[!#/]([Cc]hats)$",
"^[!#/]([Hh]elp)$",
},
run = run
}
| gpl-2.0 |
ehrenbrav/FCEUX_Learning_Environment | output/luaScripts/SMB-CompetitionRecorder.lua | 9 | 3932 | -- Super Mario Bros. script by ugetab.
-- 2010, April 20th.
-- Competition Recorder:
-- Start the script, then make a recording from Start.
-- Play until you get a score you'd like to keep, then end the movie.
-- A record of your best scores, and the filename you got it in, will be saved.
-- You can easily find your best score, because it will be sorted highest to lowest.
-- The last entry is always erased, but is also always the lowest score.
-- The best score for your current movie file will be displayed above the coin counter.
-- The reason this is good for competition is that you can't get away with cheating,
-- unless the game allows it. A movie file is a collection of button presses which
-- can be played back. If it doesn't play back the same for someone else, then there's
-- probably a problem with the game file, or with what the person recording did.
function text(x,y,str)
if (x > 0 and x < 255 and y > 0 and y < 240) then
gui.text(x,y,str);
end;
end;
function bubbleSort(table)
--http://www.dreamincode.net/code/snippet3406.htm
--check to make sure the table has some items in it
if #table < 2 then
--print("Table does not have enough data in it")
return;
end;
for i = 0, (#table / 2) -1 do --> array start to end. Arrays start at 1, not 0.
for j = 1, (#table / 2) -1 do
if tonumber(table[(j*2)+1]) > tonumber(table[(j*2)-1]) then -->switch
temp1 = table[(j*2) - 1];
temp2 = table[(j*2)];
table[(j*2) - 1] = table[(j*2) + 1];
table[(j*2)] = table[(j*2) + 2];
table[(j*2) + 1] = temp1;
table[(j*2) + 2] = temp2;
end;
end;
end;
return;
end;
filesizefile = io.open("MaxScore_LUA.txt","r");
if filesizefile == nil then
filewritefile = io.open("MaxScore_LUA.txt","w");
filewritefile:close();
filesizefile = io.open("MaxScore_LUA.txt","r");
end;
filesize = filesizefile:seek("end");
filesizefile:close();
scores = {"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"};
if filesize == nil then
filesize = 0;
end;
if filesize < 20 then
fileinit = io.open("MaxScore_LUA.txt","w+")
for i = 1, #scores do
fileinit:write(scores[i]..'\n');
end;
fileinit:close();
end;
activescoring = false;
moviename = "";
maxscoresave = -9999999;
text(83,8,"-Inactive-");
while (true) do
if (movie.mode() == "record") then
if movie.ispoweron() then
maxscoretest = memory.readbyte(0x07d7)..memory.readbyte(0x07d8)..memory.readbyte(0x07d9)..memory.readbyte(0x07da)..memory.readbyte(0x07db)..memory.readbyte(0x07dc).."0";
activescoring = true;
--if (tonumber(maxscoretest) >= tonumber(maxscoresave)) then
if (tonumber(maxscoretest) <= 9999990) then
maxscoresave = maxscoretest;
moviename = movie.getname();
end;
--end;
text(83,8,maxscoresave);
end;
end;
if (movie.mode() == nil) then
if (activescoring == true) then
activescoring = false;
text(83,8,"-Inactive-");
readfile = io.open("MaxScore_LUA.txt","r");
linecount = 1
for line in readfile:lines() do
if linecount <= 20 then
scores[linecount] = line;
end;
linecount = linecount + 1;
end;
readfile:close ();
--if tonumber(maxscoresave) > tonumber(scores[19]) then
scores[19] = maxscoresave;
scores[20] = moviename;
bubbleSort(scores);
savefile = io.open("MaxScore_LUA.txt","w+")
for i = 1, #scores do
savefile:write(tostring(scores[i]));
savefile:write('\n');
end;
savefile:close();
--end;
end;
end;
FCEU.frameadvance();
end;
| gpl-2.0 |
eugenesan/openwrt-luci | applications/luci-freifunk-policyrouting/luasrc/model/cbi/freifunk/policyrouting.lua | 76 | 1905 | --[[
LuCI - Lua Configuration Interface
Copyright 2011 Manuel Munz <freifunk at somakoma de>
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
]]--
local uci = require "luci.model.uci".cursor()
m = Map("freifunk-policyrouting", translate("Policy Routing"), translate("These pages can be used to setup policy routing for certain firewall zones. "..
"This is useful if you need to use your own internet connection for yourself but you don't want to share it with others (thats why it can also be "..
"called 'Ego Mode'). Your own traffic is then sent via your internet connection while traffic originating from the mesh will use another gateway in the mesh. "))
m:chain("network")
c = m:section(NamedSection, "pr", "settings", "")
local pr = c:option(Flag, "enable", translate("Enable Policy Routing"))
pr.rmempty = false
local strict = c:option(Flag, "strict", translate("Strict Filtering"), translate("If no default route is received from the mesh network then traffic which belongs to "..
"the selected firewall zones is routed via your internet connection as a fallback. If you do not want this and instead block that traffic then you should "..
"select this option."))
strict.rmempty = false
local fallback = c:option(Flag, "fallback", translate("Fallback to mesh"),
translate("If your own gateway is not available then fallback to the mesh default gateway."))
strict.rmempty = false
local zones = c:option(MultiValue, "zones", translate("Firewall zones"), translate("All traffic from interfaces belonging to these zones will be sent via "..
"a gateway in the mesh network."))
uci:foreach("firewall", "zone", function(section)
local name = section.name
if not (name == "wan") then
zones:value(name)
end
end)
return m
| apache-2.0 |
Ninjistix/darkstar | scripts/zones/Southern_San_dOria/npcs/Machielle.lua | 5 | 1517 | -----------------------------------
-- Area: Southern San d'Oria
-- NPC: Machielle
-- Only sells when Bastok controls Norvallen Region
-----------------------------------
package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Southern_San_dOria/TextIDs");
require("scripts/globals/settings");
require("scripts/globals/quests");
-----------------------------------
function onTrade(player,npc,trade)
-- "Flyers for Regine" conditional script
if (player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE) == 1) then
if (trade:hasItemQty(532,1) == true and trade:getItemCount() == 1) then
player:messageSpecial(FLYER_REFUSED);
end
else
onHalloweenTrade(player,trade,npc);
end
end;
function onTrigger(player,npc)
local RegionOwner = GetRegionOwner(NORVALLEN);
if (RegionOwner ~= NATION_SANDORIA) then
player:showText(npc,MACHIELLE_CLOSED_DIALOG);
else
player:showText(npc,MACHIELLE_OPEN_DIALOG);
local stock =
{
688, 18, -- Arrowwood Log
621, 25, -- Crying Mustard
618, 25, -- Blue Peas
698, 88 -- Ash Log
}
showShop(player,SANDORIA,stock);
end
end;
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
dinodeck/ninety_nine_days_of_dev | 006_magic_menu/code/Actions.lua | 6 | 9228 | Actions =
{
-- Teleport an entity from the current position to the given position
Teleport = function(map, tileX, tileY, layer)
layer = layer or 1
return function(trigger, entity, tX, tY, tLayer)
entity:SetTilePos(tileX, tileY, layer, map)
end
end,
AddNPC = function(map, npc)
print("npcid", tostring(npc.id))
assert(npc.id ~= "hero")
return function(trigger, entity, tX, tY, tLayer)
local charDef = gCharacters[npc.def]
assert(charDef) -- Character should always exist!
local char = Character:Create(charDef, map)
-- Use npc def location by default
-- Drop back to entities locations if missing
local x = npc.x or char.mEntity.mTileX
local y = npc.y or char.mEntity.mTileY
local layer = npc.layer or char.mEntity.mLayer
char.mEntity:SetTilePos(x, y, layer, map)
table.insert(map.mNPCs, char)
assert(map.mNPCbyId[npc.id] == nil)
char.mId = npc.id
map.mNPCbyId[npc.id] = char
end
end,
RemoveNPC = function(map, npcId)
return function(trigger, entity, tX, tY, tLayer)
local char = map.mNPCbyId[npcId]
local x = char.mEntity.mTileX
local y = char.mEntity.mTileY
local layer = char.mEntity.mLayer
map:RemoveNPC(x, y, layer)
end
end,
AddSavePoint = function(map, x, y, layer)
return function(trigger, entity, tX, tY, tLayer)
local entityDef = gEntities["save_point"]
local savePoint = Entity:Create(entityDef)
savePoint:SetTilePos(x, y, layer, map)
local function AskCallback(index)
if index == 2 then
return
end
Save:Save()
gGame.Stack:PushFit(gRenderer, 0, 0, "Saved!")
end
local trigger = Trigger:Create(
{
OnUse = function()
gGame.World.mParty:Rest()
local askMsg = "Save progress?"
gGame.Stack:PushFit(gRenderer, 0, 0, askMsg, false,
{
choices =
{
options = {"Yes", "No"},
OnSelection = AskCallback
},
})
end
})
map:AddFullTrigger(trigger, x, y, layer)
end
end,
AddChest = function(map, entityId, loot, x, y, layer)
layer = layer or 1
map.mContainerCount = map.mContainerCount or 0
map.mContainerCount = map.mContainerCount + 1
local containerId = map.mContainerCount
local mapId = map.mMapDef.id
local state = gGame.World.mGameState.maps[mapId]
local isLooted = state.chests_looted[containerId] or false
return function(trigger, entity, tX, tY, tLayer)
local entityDef = gEntities[entityId]
assert(entityDef ~= nil)
local chest = Entity:Create(entityDef)
-- Put the chest entity on the map
chest:SetTilePos(x, y, layer, map)
if isLooted then
-- Open chest and return before
-- setting trigger.
chest:SetFrame(entityDef.openFrame)
return
end
-- Define open chest function
local OnOpenChest = function()
if loot == nil or #loot == 0 then
gGame.Stack:PushFit(gRenderer, 0, 0, "The chest is empty!", 300)
else
gGame.World:AddLoot(loot)
for _, item in ipairs(loot) do
local count = item.count or 1
local name = ItemDB[item.id].name
local message = string.format("Got %s", name)
if count > 1 then
message = message .. string.format(" x%d", count)
end
gGame.Stack:PushFit(gRenderer, 0, 0, message, 300)
end
end
-- Remove the trigger
map:RemoveTrigger(chest.mTileX, chest.mTileY, chest.mLayer)
chest:SetFrame(entityDef.openFrame)
print(string.format("Chest: %d set to looted.", containerId))
state.chests_looted[containerId] = true
end
local trigger = Trigger:Create( { OnUse = OnOpenChest } )
map:AddFullTrigger(trigger,
chest.mTileX, chest.mTileY, chest.mLayer)
end
end,
RunScript = function(map, Func)
return function(trigger, entity, tX, tY, tLayer)
Func(map, trigger, entity, tX, tY, tLayer)
end
end,
OpenShop = function(map, def)
return function(trigger, entity, tX, tY, tLayer)
gGame.Stack:Push(ShopState:Create(gGame.Stack, gGame.World, def))
end
end,
OpenInn = function(map, def)
def = def or {}
local cost = def.cost or 5
local lackGPMsg = "You need %d gp to stay at the Inn."
local askMsg = "Stay at the inn for %d gp?"
local resultMsg = "HP/MP Restored!"
askMsg = string.format(askMsg, cost)
lackGPMsg = string.format(lackGPMsg, cost)
local OnSelection = function(index, item)
print("selection! callback", index, item)
if index == 2 then
return
end
gGame.World.mGold = gGame.World.mGold - cost
gGame.World.mParty:Rest()
--gGame.Stack:PushFit(gRenderer, 0, 0, lackGPMsg)
gGame.Stack:PushFit(gRenderer, 0, 0, resultMsg)
end
return function(trigger, entity, tX, tY, tLayer)
local gp = gGame.World.mGold
if gp >= cost then
gGame.Stack:PushFit(gRenderer, 0, 0, askMsg, false,
{
choices =
{
options = {"Yes", "No"},
OnSelection = OnSelection
},
})
else
gGame.Stack:PushFit(gRenderer, 0, 0, lackGPMsg)
end
end
end,
ShortText = function(map, text)
return function(trigger, entity, tX, tY, tLayer)
tY = tY - 4
local x, y = map:TileToScreen(tX, tY)
gGame.Stack:PushFix(gRenderer, x, y, 9*32, 2.5*32, text)
end
end,
ChangeMap = function(map, destinationId, dX, dY)
local storyboard =
{
SOP.BlackScreen("blackscreen", 0),
SOP.FadeInScreen("blackscreen", 0.5),
SOP.ReplaceScene(
"handin",
{
map = destinationId,
focusX = dX,
focusY = dY,
hideHero = false
}),
SOP.FadeOutScreen("blackscreen", 0.5),
SOP.Function(function()
gGame.World:UnlockInput()
end),
SOP.HandOff(destinationId),
}
return function(trigger, entity, tX, tY, tLayer)
gGame.World:LockInput()
local storyboard = Storyboard:Create(gGame.Stack, storyboard, true)
gGame.Stack:Push(storyboard)
end
end,
Combat = function(map, def)
return function(trigger, entity, tX, tY, tLayer)
def.background = def.background or "combat_bg_field.png"
def.enemy = def.enemy or { "grunt" }
-- Convert id's to enemy actors
local enemyList = {}
for k, v in ipairs(def.enemy) do
print(v, tostring(gEnemyDefs[v]))
local enemyDef = gEnemyDefs[v]
enemyList[k] = Actor:Create(enemyDef)
end
local combatState = CombatState:Create(gGame.Stack,
{
background = def.background,
actors =
{
party = gGame.World.mParty:ToArray(),
enemy = enemyList,
},
canFlee = def.canFlee,
OnWin = def.OnWin,
OnDie = def.OnDie
})
local storyboard =
{
SOP.BlackScreen("blackscreen", 0),
SOP.FadeInScreen("blackscreen", 0.5),
SOP.Function(
function()
gGame.Stack:Push(combatState)
end)
}
local storyboard = Storyboard:Create(gGame.Stack, storyboard)
gGame.Stack:Push(storyboard)
end
end
} | mit |
codedash64/Urho3D | bin/Data/LuaScripts/06_SkeletalAnimation.lua | 17 | 10180 | -- Skeletal animation example.
-- This sample demonstrates:
-- - Populating a 3D scene with skeletally animated AnimatedModel components
-- - Moving the animated models and advancing their animation using a script object
-- - Enabling a cascaded shadow map on a directional light, which allows high-quality shadows
-- over a large area (typically used in outdoor scenes for shadows cast by sunlight)
-- - Displaying renderer debug geometry
require "LuaScripts/Utilities/Sample"
function Start()
-- Execute the common startup for samples
SampleStart()
-- Create the scene content
CreateScene()
-- Create the UI content
CreateInstructions()
-- Setup the viewport for displaying the scene
SetupViewport()
-- Set the mouse mode to use in the sample
SampleInitMouseMode(MM_RELATIVE)
-- Hook up to the frame update and render post-update events
SubscribeToEvents()
end
function CreateScene()
scene_ = Scene()
-- Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
-- Also create a DebugRenderer component so that we can draw debug geometry
scene_:CreateComponent("Octree")
scene_:CreateComponent("DebugRenderer")
-- Create scene node & StaticModel component for showing a static plane
local planeNode = scene_:CreateChild("Plane")
planeNode.scale = Vector3(50.0, 1.0, 50.0)
local planeObject = planeNode:CreateComponent("StaticModel")
planeObject.model = cache:GetResource("Model", "Models/Plane.mdl")
planeObject.material = cache:GetResource("Material", "Materials/StoneTiled.xml")
-- Create a Zone component for ambient lighting & fog control
local zoneNode = scene_:CreateChild("Zone")
local zone = zoneNode:CreateComponent("Zone")
zone.boundingBox = BoundingBox(-1000.0, 1000.0)
zone.ambientColor = Color(0.5, 0.5, 0.5)
zone.fogColor = Color(0.4, 0.5, 0.8)
zone.fogStart = 100.0
zone.fogEnd = 300.0
-- Create a directional light to the world. Enable cascaded shadows on it
local lightNode = scene_:CreateChild("DirectionalLight")
lightNode.direction = Vector3(0.6, -1.0, 0.8)
local light = lightNode:CreateComponent("Light")
light.lightType = LIGHT_DIRECTIONAL
light.castShadows = true
light.color = Color(0.5, 0.5, 0.5)
light.shadowBias = BiasParameters(0.00025, 0.5)
-- Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
light.shadowCascade = CascadeParameters(10.0, 50.0, 200.0, 0.0, 0.8)
-- Create animated models
local uint NUM_MODELS = 30
local MODEL_MOVE_SPEED = 2.0
local MODEL_ROTATE_SPEED = 100.0
local bounds = BoundingBox(Vector3(-20.0, 0.0, -20.0), Vector3(20.0, 0.0, 20.0))
for i = 1, NUM_MODELS do
local modelNode = scene_:CreateChild("Jill")
modelNode.position = Vector3(Random(40.0) - 20.0, 0.0, Random(40.0) - 20.0)
modelNode.rotation = Quaternion(0.0, Random(360.0), 0.0)
local modelObject = modelNode:CreateComponent("AnimatedModel")
modelObject.model = cache:GetResource("Model", "Models/Kachujin/Kachujin.mdl")
modelObject.material = cache:GetResource("Material", "Models/Kachujin/Materials/Kachujin.xml")
modelObject.castShadows = true
-- Create an AnimationState for a walk animation. Its time position will need to be manually updated to advance the
-- animation, The alternative would be to use an AnimationController component which updates the animation automatically,
-- but we need to update the model's position manually in any case
local walkAnimation = cache:GetResource("Animation", "Models/Kachujin/Kachujin_Walk.ani")
local state = modelObject:AddAnimationState(walkAnimation)
-- Enable full blending weight and looping
state.weight = 1.0
state.looped = true
state.time = Random(walkAnimation.length)
-- Create our Mover script object that will move & animate the model during each frame's update.
local object = modelNode:CreateScriptObject("Mover")
object:SetParameters(MODEL_MOVE_SPEED, MODEL_ROTATE_SPEED, bounds)
end
-- Create the camera. Limit far clip distance to match the fog
cameraNode = scene_:CreateChild("Camera")
local camera = cameraNode:CreateComponent("Camera")
camera.farClip = 300.0
-- Set an initial position for the camera scene node above the plane
cameraNode.position = Vector3(0.0, 5.0, 0.0)
end
function CreateInstructions()
-- Construct new Text object, set string to display and font to use
local instructionText = ui.root:CreateChild("Text")
instructionText:SetText("Use WASD keys and mouse to move\n"..
"Space to toggle debug geometry")
instructionText:SetFont(cache:GetResource("Font", "Fonts/Anonymous Pro.ttf"), 15)
-- The text has multiple rows. Center them in relation to each other
instructionText.textAlignment = HA_CENTER
-- Position the text relative to the screen center
instructionText.horizontalAlignment = HA_CENTER
instructionText.verticalAlignment = VA_CENTER
instructionText:SetPosition(0, ui.root.height / 4)
end
function SetupViewport()
-- Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
local viewport = Viewport:new(scene_, cameraNode:GetComponent("Camera"))
renderer:SetViewport(0, viewport)
end
function SubscribeToEvents()
-- Subscribe HandleUpdate() function for processing update events
SubscribeToEvent("Update", "HandleUpdate")
-- Subscribe HandlePostRenderUpdate() function for processing the post-render update event, sent after Renderer subsystem is
-- done with defining the draw calls for the viewports (but before actually executing them.) We will request debug geometry
-- rendering during that event
SubscribeToEvent("PostRenderUpdate", "HandlePostRenderUpdate")
end
function MoveCamera(timeStep)
-- Do not move if the UI has a focused element (the console)
if ui.focusElement ~= nil then
return
end
-- Movement speed as world units per second
local MOVE_SPEED = 20.0
-- Mouse sensitivity as degrees per pixel
local MOUSE_SENSITIVITY = 0.1
-- Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
local mouseMove = input.mouseMove
yaw = yaw + MOUSE_SENSITIVITY * mouseMove.x
pitch = pitch + MOUSE_SENSITIVITY * mouseMove.y
pitch = Clamp(pitch, -90.0, 90.0)
-- Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
cameraNode.rotation = Quaternion(pitch, yaw, 0.0)
-- Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
if input:GetKeyDown(KEY_W) then
cameraNode:Translate(Vector3(0.0, 0.0, 1.0) * MOVE_SPEED * timeStep)
end
if input:GetKeyDown(KEY_S) then
cameraNode:Translate(Vector3(0.0, 0.0, -1.0) * MOVE_SPEED * timeStep)
end
if input:GetKeyDown(KEY_A) then
cameraNode:Translate(Vector3(-1.0, 0.0, 0.0) * MOVE_SPEED * timeStep)
end
if input:GetKeyDown(KEY_D) then
cameraNode:Translate(Vector3(1.0, 0.0, 0.0) * MOVE_SPEED * timeStep)
end
-- Toggle debug geometry with space
if input:GetKeyPress(KEY_SPACE) then
drawDebug = not drawDebug
end
end
function HandleUpdate(eventType, eventData)
-- Take the frame time step, which is stored as a float
local timeStep = eventData["TimeStep"]:GetFloat()
-- Move the camera, scale movement with time step
MoveCamera(timeStep)
end
function HandlePostRenderUpdate(eventType, eventData)
-- If draw debug mode is enabled, draw viewport debug geometry, which will show eg. drawable bounding boxes and skeleton
-- bones. Note that debug geometry has to be separately requested each frame. Disable depth test so that we can see the
-- bones properly
if drawDebug then
renderer:DrawDebugGeometry(false)
end
end
-- Mover script object class
Mover = ScriptObject()
function Mover:Start()
self.moveSpeed = 0.0
self.rotationSpeed = 0.0
self.bounds = BoundingBox()
end
function Mover:SetParameters(moveSpeed, rotationSpeed, bounds)
self.moveSpeed = moveSpeed
self.rotationSpeed = rotationSpeed
self.bounds = bounds
end
function Mover:Update(timeStep)
local node = self.node
node:Translate(Vector3(0.0, 0.0, 1.0) * self.moveSpeed * timeStep)
-- If in risk of going outside the plane, rotate the model right
local pos = node.position
local bounds = self.bounds
if pos.x < bounds.min.x or pos.x > bounds.max.x or pos.z < bounds.min.z or pos.z > bounds.max.z then
node:Yaw(self.rotationSpeed * timeStep)
end
-- Get the model's first (only) animation state and advance its time
local model = node:GetComponent("AnimatedModel", true)
local state = model:GetAnimationState(0)
if state ~= nil then
state:AddTime(timeStep)
end
end
-- Create XML patch instructions for screen joystick layout specific to this sample app
function GetScreenJoystickPatchString()
return
"<patch>"..
" <remove sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/attribute[@name='Is Visible']\" />"..
" <replace sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/element[./attribute[@name='Name' and @value='Label']]/attribute[@name='Text']/@value\">Debug</replace>"..
" <add sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]\">"..
" <element type=\"Text\">"..
" <attribute name=\"Name\" value=\"KeyBinding\" />"..
" <attribute name=\"Text\" value=\"SPACE\" />"..
" </element>"..
" </add>"..
"</patch>"
end
| mit |
timstclair/kube-contrib | ingress/controllers/nginx/lua/vendor/lua-resty-http/lib/resty/http.lua | 45 | 21496 | local http_headers = require "resty.http_headers"
local ngx_socket_tcp = ngx.socket.tcp
local ngx_req = ngx.req
local ngx_req_socket = ngx_req.socket
local ngx_req_get_headers = ngx_req.get_headers
local ngx_req_get_method = ngx_req.get_method
local str_gmatch = string.gmatch
local str_lower = string.lower
local str_upper = string.upper
local str_find = string.find
local str_sub = string.sub
local str_gsub = string.gsub
local tbl_concat = table.concat
local tbl_insert = table.insert
local ngx_encode_args = ngx.encode_args
local ngx_re_match = ngx.re.match
local ngx_re_gsub = ngx.re.gsub
local ngx_log = ngx.log
local ngx_DEBUG = ngx.DEBUG
local ngx_ERR = ngx.ERR
local ngx_NOTICE = ngx.NOTICE
local ngx_var = ngx.var
local co_yield = coroutine.yield
local co_create = coroutine.create
local co_status = coroutine.status
local co_resume = coroutine.resume
-- http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.5.1
local HOP_BY_HOP_HEADERS = {
["connection"] = true,
["keep-alive"] = true,
["proxy-authenticate"] = true,
["proxy-authorization"] = true,
["te"] = true,
["trailers"] = true,
["transfer-encoding"] = true,
["upgrade"] = true,
["content-length"] = true, -- Not strictly hop-by-hop, but Nginx will deal
-- with this (may send chunked for example).
}
-- Reimplemented coroutine.wrap, returning "nil, err" if the coroutine cannot
-- be resumed. This protects user code from inifite loops when doing things like
-- repeat
-- local chunk, err = res.body_reader()
-- if chunk then -- <-- This could be a string msg in the core wrap function.
-- ...
-- end
-- until not chunk
local co_wrap = function(func)
local co = co_create(func)
if not co then
return nil, "could not create coroutine"
else
return function(...)
if co_status(co) == "suspended" then
return select(2, co_resume(co, ...))
else
return nil, "can't resume a " .. co_status(co) .. " coroutine"
end
end
end
end
local _M = {
_VERSION = '0.07',
}
_M._USER_AGENT = "lua-resty-http/" .. _M._VERSION .. " (Lua) ngx_lua/" .. ngx.config.ngx_lua_version
local mt = { __index = _M }
local HTTP = {
[1.0] = " HTTP/1.0\r\n",
[1.1] = " HTTP/1.1\r\n",
}
local DEFAULT_PARAMS = {
method = "GET",
path = "/",
version = 1.1,
}
function _M.new(self)
local sock, err = ngx_socket_tcp()
if not sock then
return nil, err
end
return setmetatable({ sock = sock, keepalive = true }, mt)
end
function _M.set_timeout(self, timeout)
local sock = self.sock
if not sock then
return nil, "not initialized"
end
return sock:settimeout(timeout)
end
function _M.ssl_handshake(self, ...)
local sock = self.sock
if not sock then
return nil, "not initialized"
end
return sock:sslhandshake(...)
end
function _M.connect(self, ...)
local sock = self.sock
if not sock then
return nil, "not initialized"
end
self.host = select(1, ...)
self.keepalive = true
return sock:connect(...)
end
function _M.set_keepalive(self, ...)
local sock = self.sock
if not sock then
return nil, "not initialized"
end
if self.keepalive == true then
return sock:setkeepalive(...)
else
-- The server said we must close the connection, so we cannot setkeepalive.
-- If close() succeeds we return 2 instead of 1, to differentiate between
-- a normal setkeepalive() failure and an intentional close().
local res, err = sock:close()
if res then
return 2, "connection must be closed"
else
return res, err
end
end
end
function _M.get_reused_times(self)
local sock = self.sock
if not sock then
return nil, "not initialized"
end
return sock:getreusedtimes()
end
function _M.close(self)
local sock = self.sock
if not sock then
return nil, "not initialized"
end
return sock:close()
end
local function _should_receive_body(method, code)
if method == "HEAD" then return nil end
if code == 204 or code == 304 then return nil end
if code >= 100 and code < 200 then return nil end
return true
end
function _M.parse_uri(self, uri)
local m, err = ngx_re_match(uri, [[^(http[s]*)://([^:/]+)(?::(\d+))?(.*)]],
"jo")
if not m then
if err then
return nil, "failed to match the uri: " .. err
end
return nil, "bad uri"
else
if not m[3] then
if m[1] == "https" then
m[3] = 443
else
m[3] = 80
end
end
if not m[4] or "" == m[4] then m[4] = "/" end
return m, nil
end
end
local function _format_request(params)
local version = params.version
local headers = params.headers or {}
local query = params.query or ""
if query then
if type(query) == "table" then
query = "?" .. ngx_encode_args(query)
end
end
-- Initialize request
local req = {
str_upper(params.method),
" ",
params.path,
query,
HTTP[version],
-- Pre-allocate slots for minimum headers and carriage return.
true,
true,
true,
}
local c = 6 -- req table index it's faster to do this inline vs table.insert
-- Append headers
for key, values in pairs(headers) do
if type(values) ~= "table" then
values = {values}
end
key = tostring(key)
for _, value in pairs(values) do
req[c] = key .. ": " .. tostring(value) .. "\r\n"
c = c + 1
end
end
-- Close headers
req[c] = "\r\n"
return tbl_concat(req)
end
local function _receive_status(sock)
local line, err = sock:receive("*l")
if not line then
return nil, nil, err
end
return tonumber(str_sub(line, 10, 12)), tonumber(str_sub(line, 6, 8))
end
local function _receive_headers(sock)
local headers = http_headers.new()
repeat
local line, err = sock:receive("*l")
if not line then
return nil, err
end
for key, val in str_gmatch(line, "([^:%s]+):%s*(.+)") do
if headers[key] then
if type(headers[key]) ~= "table" then
headers[key] = { headers[key] }
end
tbl_insert(headers[key], tostring(val))
else
headers[key] = tostring(val)
end
end
until str_find(line, "^%s*$")
return headers, nil
end
local function _chunked_body_reader(sock, default_chunk_size)
return co_wrap(function(max_chunk_size)
local max_chunk_size = max_chunk_size or default_chunk_size
local remaining = 0
local length
repeat
-- If we still have data on this chunk
if max_chunk_size and remaining > 0 then
if remaining > max_chunk_size then
-- Consume up to max_chunk_size
length = max_chunk_size
remaining = remaining - max_chunk_size
else
-- Consume all remaining
length = remaining
remaining = 0
end
else -- This is a fresh chunk
-- Receive the chunk size
local str, err = sock:receive("*l")
if not str then
co_yield(nil, err)
end
length = tonumber(str, 16)
if not length then
co_yield(nil, "unable to read chunksize")
end
if max_chunk_size and length > max_chunk_size then
-- Consume up to max_chunk_size
remaining = length - max_chunk_size
length = max_chunk_size
end
end
if length > 0 then
local str, err = sock:receive(length)
if not str then
co_yield(nil, err)
end
max_chunk_size = co_yield(str) or default_chunk_size
-- If we're finished with this chunk, read the carriage return.
if remaining == 0 then
sock:receive(2) -- read \r\n
end
else
-- Read the last (zero length) chunk's carriage return
sock:receive(2) -- read \r\n
end
until length == 0
end)
end
local function _body_reader(sock, content_length, default_chunk_size)
return co_wrap(function(max_chunk_size)
local max_chunk_size = max_chunk_size or default_chunk_size
if not content_length and max_chunk_size then
-- We have no length, but wish to stream.
-- HTTP 1.0 with no length will close connection, so read chunks to the end.
repeat
local str, err, partial = sock:receive(max_chunk_size)
if not str and err == "closed" then
max_chunk_size = tonumber(co_yield(partial, err) or default_chunk_size)
end
max_chunk_size = tonumber(co_yield(str) or default_chunk_size)
if max_chunk_size and max_chunk_size < 0 then max_chunk_size = nil end
if not max_chunk_size then
ngx_log(ngx_ERR, "Buffer size not specified, bailing")
break
end
until not str
elseif not content_length then
-- We have no length but don't wish to stream.
-- HTTP 1.0 with no length will close connection, so read to the end.
co_yield(sock:receive("*a"))
elseif not max_chunk_size then
-- We have a length and potentially keep-alive, but want everything.
co_yield(sock:receive(content_length))
else
-- We have a length and potentially a keep-alive, and wish to stream
-- the response.
local received = 0
repeat
local length = max_chunk_size
if received + length > content_length then
length = content_length - received
end
if length > 0 then
local str, err = sock:receive(length)
if not str then
max_chunk_size = tonumber(co_yield(nil, err) or default_chunk_size)
end
received = received + length
max_chunk_size = tonumber(co_yield(str) or default_chunk_size)
if max_chunk_size and max_chunk_size < 0 then max_chunk_size = nil end
if not max_chunk_size then
ngx_log(ngx_ERR, "Buffer size not specified, bailing")
break
end
end
until length == 0
end
end)
end
local function _no_body_reader()
return nil
end
local function _read_body(res)
local reader = res.body_reader
if not reader then
-- Most likely HEAD or 304 etc.
return nil, "no body to be read"
end
local chunks = {}
local c = 1
local chunk, err
repeat
chunk, err = reader()
if err then
return nil, err, tbl_concat(chunks) -- Return any data so far.
end
if chunk then
chunks[c] = chunk
c = c + 1
end
until not chunk
return tbl_concat(chunks)
end
local function _trailer_reader(sock)
return co_wrap(function()
co_yield(_receive_headers(sock))
end)
end
local function _read_trailers(res)
local reader = res.trailer_reader
if not reader then
return nil, "no trailers"
end
local trailers = reader()
setmetatable(res.headers, { __index = trailers })
end
local function _send_body(sock, body)
if type(body) == 'function' then
repeat
local chunk, err, partial = body()
if chunk then
local ok,err = sock:send(chunk)
if not ok then
return nil, err
end
elseif err ~= nil then
return nil, err, partial
end
until chunk == nil
elseif body ~= nil then
local bytes, err = sock:send(body)
if not bytes then
return nil, err
end
end
return true, nil
end
local function _handle_continue(sock, body)
local status, version, err = _receive_status(sock)
if not status then
return nil, err
end
-- Only send body if we receive a 100 Continue
if status == 100 then
local ok, err = sock:receive("*l") -- Read carriage return
if not ok then
return nil, err
end
_send_body(sock, body)
end
return status, version, err
end
function _M.send_request(self, params)
-- Apply defaults
setmetatable(params, { __index = DEFAULT_PARAMS })
local sock = self.sock
local body = params.body
local headers = http_headers.new()
local params_headers = params.headers
if params_headers then
-- We assign one by one so that the metatable can handle case insensitivity
-- for us. You can blame the spec for this inefficiency.
for k,v in pairs(params_headers) do
headers[k] = v
end
end
-- Ensure minimal headers are set
if type(body) == 'string' and not headers["Content-Length"] then
headers["Content-Length"] = #body
end
if not headers["Host"] then
headers["Host"] = self.host
end
if not headers["User-Agent"] then
headers["User-Agent"] = _M._USER_AGENT
end
if params.version == 1.0 and not headers["Connection"] then
headers["Connection"] = "Keep-Alive"
end
params.headers = headers
-- Format and send request
local req = _format_request(params)
ngx_log(ngx_DEBUG, "\n", req)
local bytes, err = sock:send(req)
if not bytes then
return nil, err
end
-- Send the request body, unless we expect: continue, in which case
-- we handle this as part of reading the response.
if headers["Expect"] ~= "100-continue" then
local ok, err, partial = _send_body(sock, body)
if not ok then
return nil, err, partial
end
end
return true
end
function _M.read_response(self, params)
local sock = self.sock
local status, version, err
-- If we expect: continue, we need to handle this, sending the body if allowed.
-- If we don't get 100 back, then status is the actual status.
if params.headers["Expect"] == "100-continue" then
local _status, _version, _err = _handle_continue(sock, params.body)
if not _status then
return nil, _err
elseif _status ~= 100 then
status, version, err = _status, _version, _err
end
end
-- Just read the status as normal.
if not status then
status, version, err = _receive_status(sock)
if not status then
return nil, err
end
end
local res_headers, err = _receive_headers(sock)
if not res_headers then
return nil, err
end
-- Determine if we should keepalive or not.
local ok, connection = pcall(str_lower, res_headers["Connection"])
if ok then
if (version == 1.1 and connection == "close") or
(version == 1.0 and connection ~= "keep-alive") then
self.keepalive = false
end
end
local body_reader = _no_body_reader
local trailer_reader, err = nil, nil
local has_body = false
-- Receive the body_reader
if _should_receive_body(params.method, status) then
local ok, encoding = pcall(str_lower, res_headers["Transfer-Encoding"])
if ok and version == 1.1 and encoding == "chunked" then
body_reader, err = _chunked_body_reader(sock)
has_body = true
else
local ok, length = pcall(tonumber, res_headers["Content-Length"])
if ok then
body_reader, err = _body_reader(sock, length)
has_body = true
end
end
end
if res_headers["Trailer"] then
trailer_reader, err = _trailer_reader(sock)
end
if err then
return nil, err
else
return {
status = status,
headers = res_headers,
has_body = has_body,
body_reader = body_reader,
read_body = _read_body,
trailer_reader = trailer_reader,
read_trailers = _read_trailers,
}
end
end
function _M.request(self, params)
local res, err = self:send_request(params)
if not res then
return res, err
else
return self:read_response(params)
end
end
function _M.request_pipeline(self, requests)
for i, params in ipairs(requests) do
if params.headers and params.headers["Expect"] == "100-continue" then
return nil, "Cannot pipeline request specifying Expect: 100-continue"
end
local res, err = self:send_request(params)
if not res then
return res, err
end
end
local responses = {}
for i, params in ipairs(requests) do
responses[i] = setmetatable({
params = params,
response_read = false,
}, {
-- Read each actual response lazily, at the point the user tries
-- to access any of the fields.
__index = function(t, k)
local res, err
if t.response_read == false then
res, err = _M.read_response(self, t.params)
t.response_read = true
if not res then
ngx_log(ngx_ERR, err)
else
for rk, rv in pairs(res) do
t[rk] = rv
end
end
end
return rawget(t, k)
end,
})
end
return responses
end
function _M.request_uri(self, uri, params)
if not params then params = {} end
local parsed_uri, err = self:parse_uri(uri)
if not parsed_uri then
return nil, err
end
local scheme, host, port, path = unpack(parsed_uri)
if not params.path then params.path = path end
local c, err = self:connect(host, port)
if not c then
return nil, err
end
if scheme == "https" then
local verify = true
if params.ssl_verify == false then
verify = false
end
local ok, err = self:ssl_handshake(nil, host, verify)
if not ok then
return nil, err
end
end
local res, err = self:request(params)
if not res then
return nil, err
end
local body, err = res:read_body()
if not body then
return nil, err
end
res.body = body
local ok, err = self:set_keepalive()
if not ok then
ngx_log(ngx_ERR, err)
end
return res, nil
end
function _M.get_client_body_reader(self, chunksize, sock)
local chunksize = chunksize or 65536
if not sock then
local ok, err
ok, sock, err = pcall(ngx_req_socket)
if not ok then
return nil, sock -- pcall err
end
if not sock then
if err == "no body" then
return nil
else
return nil, err
end
end
end
local headers = ngx_req_get_headers()
local length = headers.content_length
local encoding = headers.transfer_encoding
if length then
return _body_reader(sock, tonumber(length), chunksize)
elseif encoding and str_lower(encoding) == 'chunked' then
-- Not yet supported by ngx_lua but should just work...
return _chunked_body_reader(sock, chunksize)
else
return nil
end
end
function _M.proxy_request(self, chunksize)
return self:request{
method = ngx_req_get_method(),
path = ngx_re_gsub(ngx_var.uri, "\\s", "%20", "jo") .. ngx_var.is_args .. (ngx_var.query_string or ""),
body = self:get_client_body_reader(chunksize),
headers = ngx_req_get_headers(),
}
end
function _M.proxy_response(self, response, chunksize)
if not response then
ngx_log(ngx_ERR, "no response provided")
return
end
ngx.status = response.status
-- Filter out hop-by-hop headeres
for k,v in pairs(response.headers) do
if not HOP_BY_HOP_HEADERS[str_lower(k)] then
ngx.header[k] = v
end
end
local reader = response.body_reader
repeat
local chunk, err = reader(chunksize)
if err then
ngx_log(ngx_ERR, err)
break
end
if chunk then
local res, err = ngx.print(chunk)
if not res then
ngx_log(ngx_ERR, err)
break
end
end
until not chunk
end
return _M
| apache-2.0 |
bogdanm/luaelf | lib/elfrelsect.lua | 1 | 2485 | -- ELF relocation section object
module( ..., package.seeall )
local cl = require "classes"
local ct = require "elfct"
local rel = require "elfrel"
local rela = require "elfrela"
local sf = string.format
local elfutils = require "elfutils"
local _relsect = cl.new_class( "elfrelsect", "elfsect", "ELF REL/RELA section handler" )
new = function( stream, offset, elfobj )
local self = cl.new_instance( "elfrelsect" )
getmetatable( self ).__index = function( table, key )
if type( key ) == "number" then
assert( key >= 0 and key < #self.relocs, sf( "invalid index '%d'", key ) )
return self.relocs[ key + 1 ]
else
return _relsect[ key ]
end
end
_relsect.base.init( self, stream, offset )
self.relocs = {}
self.elfobj = elfobj
return self
end
_relsect.get_num_relocations = function( self )
return #self.relocs
end
_relsect.get_relocation_at = function( self, idx )
assert( idx >= 0 and idx < #self.relocs, sf( "invalid index '%d'", idx ) )
return self.relocs[ idx + 1 ]
end
_relsect.load = function( self )
local s = self.stream
_relsect.base.load( self )
assert( self:get_type() == ct.SHT_REL or self:get_type() == ct.SHT_RELA )
if self:get_size() == 0 then return self end
self.data = s:read_off( self:get_size(), self:get_offset() )
local relsize = self:get_entry_size()
local numrels = self:get_size() / relsize
for i = 1, numrels do
if self:get_type() == ct.SHT_REL then
self.relocs[ i ] = rel.new( s, self:get_offset() + ( i - 1 ) * relsize, self.elfobj, self:get_link() ):load()
else
self.relocs[ i ] = rela.new( s, self:get_offset() + ( i - 1 ) * relsize, self.elfobj, self:get_link() ):load()
end
end
return self
end
_relsect.filter = function( self, filter, negate )
if not filter.type then return self.relocs end
local allowed_types = elfutils.to_table( filter.type )
local filtered = {}
for idx, s in ipairs( self.relocs ) do
filtered[ idx ] = elfutils.has_value( allowed_types, s:get_rel_type() )
if negate then filtered[ idx ] = not filtered[ idx ] end
end
local rels = {}
for idx = 1, #filtered do
if filtered[ idx ] then rels[ #rels + 1 ] = self.relocs[ idx ] end
end
return rels
end
_relsect.iterator = function( self, stype, negate )
local fiter = function( rels, n )
n = n + 1
if n <= #rels then return n, rels[ n ] end
end
local rels = stype and self:filter( stype, negate ) or self.relocs
return fiter, rels, 0
end
| mit |
jagu-sayan/42Premake | src/_manifest.lua | 6 | 1838 | --
-- _manifest.lua
-- Manage the list of built-in Premake scripts.
-- Copyright (c) 2002-2010 Jason Perkins and the Premake project
--
-- The master list of built-in scripts. Order is important! If you want to
-- build a new script into Premake, add it to this list.
return
{
-- core files
"base/os.lua",
"base/path.lua",
"base/string.lua",
"base/table.lua",
"base/io.lua",
"base/globals.lua",
"base/action.lua",
"base/option.lua",
"base/tree.lua",
"base/solution.lua",
"base/project.lua",
"base/configs.lua",
"base/api.lua",
"base/cmdline.lua",
"tools/dotnet.lua",
"tools/gcc.lua",
"tools/msc.lua",
"tools/ow.lua",
"base/validate.lua",
"base/help.lua",
"base/premake.lua",
-- CodeBlocks action
"actions/codeblocks/_codeblocks.lua",
"actions/codeblocks/codeblocks_workspace.lua",
"actions/codeblocks/codeblocks_cbp.lua",
-- CodeLite action
"actions/codelite/_codelite.lua",
"actions/codelite/codelite_workspace.lua",
"actions/codelite/codelite_project.lua",
-- GNU make action
"actions/make/_make.lua",
"actions/make/make_solution.lua",
"actions/make/make_cpp.lua",
"actions/make/make_csharp.lua",
-- Visual Studio actions
"actions/vstudio/_vstudio.lua",
"actions/vstudio/vs2002_solution.lua",
"actions/vstudio/vs2002_csproj.lua",
"actions/vstudio/vs2002_csproj_user.lua",
"actions/vstudio/vs200x_vcproj.lua",
"actions/vstudio/vs2003_solution.lua",
"actions/vstudio/vs2005_solution.lua",
"actions/vstudio/vs2005_csproj.lua",
"actions/vstudio/vs2005_csproj_user.lua",
"actions/vstudio/vs_generic_solution.lua",
"actions/vstudio/vs2010_vcxproxj.lua",
-- Xcode action
"actions/xcode/_xcode.lua",
"actions/xcode/xcode_common.lua",
"actions/xcode/xcode_project.lua",
-- Clean action
"actions/clean/_clean.lua",
}
| bsd-3-clause |
syj2010syj/All-Star-Battle-2 | YDWE/share/script/compile/template.lua | 1 | 4806 |
local select=select
local load=load
local string=string
local table=table
local function result(...)
return select("#",...), select(1,...)
end
local function precompile(code, output_func, lua_codes)
if lua_codes == nil then
lua_codes = {''}
end
local start_tag = '<?'
local end_tag = '?>'
local start1, end1 = string.find(code, start_tag, 1, true)
local start2 = nil
local end2 = 0
local cEqual = string.byte('=', 1)
while start1 ~= nil do
if start1 > end2 + 1 then
table.insert(lua_codes, output_func..'('..string.format("%q", string.sub(code, end2 + 1, start1 - 1))..')')
end
start2, end2 = string.find(code, end_tag, end1 + 1, true)
if start2 ~= nil then
if string.byte(code, end1 + 1) ~= cEqual then
table.insert(lua_codes, string.sub(code, end1 + 1, start2 - 1))
else
table.insert(lua_codes, output_func..'('..string.sub(code, end1 + 2, start2 - 1)..')')
end
start1, end1 = string.find(code, start_tag, end2 + 1, true)
else
-- end tag not found
end2 = end1
start1 = nil
-- we could error it, but we ignore it here
end
end
table.insert(lua_codes, output_func..'('..string.format("%q", string.sub(code, end2 + 1))..')')
return
end
local function map_file_import(path_in_archive)
return function (buf, is_path)
if is_path then
__map_handle__:import(path_in_archive, __map_path__:parent_path() / buf)
return
else
local temp_file_path = fs.ydwe_path() / "logs" / "import" / path_in_archive
fs.create_directories(temp_file_path:parent_path())
if not io.save(temp_file_path, buf) then
log.error("failed: save " .. temp_file_path:string())
return
end
__map_handle__:import(path_in_archive, temp_file_path)
return
end
end
end
local function string_hash(str)
return string.format('0x%08X', ar.storm.string_hash(str))
end
template = {}
function template:do_compile(op)
local code, err = io.load(op.input)
if not code then
log.error("Template read " .. op.input:string() .. ". Error: " .. err)
return false, err
end
local lua_codes = {''}
table.insert(lua_codes, [[
stormlib = ar.stormlib
storm = ar.storm
local file_path = fs.ydwe_path() / "logs" / "mu.out"
local update_j = {}
local clock_lines = {}
local function update(file_name, tag, func)
if file_name == 'war3map.j' then
table.insert(update_j, {tag, func})
else
if __map_handle__:has(file_name) and
__map_handle__:extract(file_name, file_path)
then
local clock = os.clock()
local content = func(io.load(file_path))
clock_lines[#clock_lines+1] = ('[%s]:%.3f'):format(tag, os.clock() - clock)
if content then
io.save(file_path, content)
__map_handle__:import(file_name, file_path)
end
end
end
end
local function do_update_j(content)
for _, data in ipairs(update_j) do
local tag, func = data[1], data[2]
local clock = os.clock()
content = func(content) or content
clock_lines[#clock_lines+1] = ('[%s]:%.3f'):format(tag, os.clock() - clock)
end
return content
end
]])
table.insert(lua_codes, "local __jass_result__ = {''}")
table.insert(lua_codes, "local function __jass_output__(str) table.insert(__jass_result__, str) end")
local r, err = pcall(precompile, code, '__jass_output__', lua_codes)
if not r then
return r, err
end
package.loaded['slk'] = nil
__map_handle__ = op.map_handle
__map_path__ = op.map_path
local env = setmetatable({import = map_file_import, StringHash = string_hash}, {__index = _G})
table.insert(lua_codes, [[
local buf = do_update_j(table.concat(__jass_result__))
io.save(fs.ydwe_path() / "logs" / "clock.txt", table.concat(clock_lines, '\n'))
return buf
]])
io.save(fs.ydwe_path() / "logs" / "调用lua插件前最后看一眼脚本.lua", table.concat(lua_codes, '\n'))
local f, err = load(table.concat(lua_codes, '\n'), nil, 't', env)
if not f then
return f, err
end
return pcall(f)
end
function template:compile(op)
log.trace("Template compilation start.")
op.output = fs.ydwe_path() / "logs" / "lua_processed.j"
local time_1 = os.clock()
local success, content = self:do_compile(op)
local time_2 = os.clock()
if not success then
if content then
gui.message_dialog(nil, content, _("Error"), gui.MB_ICONERROR | gui.MB_OK)
else
gui.message_dialog(nil, _("Unknown"), _("Error"), gui.MB_ICONERROR | gui.MB_OK)
end
log.error("Template error processing: " .. tostring(content))
return false
end
io.save(fs.ydwe_path() / "logs" / "自定义lua耗时.txt", tostring(time_2 - time_1))
local result, err = io.save(op.output, content)
if not result then
log.error("Template write " .. op.output:string() .. ". Error: " .. err)
return false
end
log.debug("Template compilation succeeded.")
return true
end
| gpl-3.0 |
neofob/sile | lua-libraries/std/table.lua | 6 | 4034 | --[[--
Extensions to the table module.
@module std.table
]]
local base = require "std.base"
local func = require "std.functional"
--- Make a shallow copy of a table, including any metatable.
--
-- To make deep copies, use @{std.tree.clone}.
-- @function clone
-- @tparam table t source table
-- @tparam boolean nometa if non-nil don't copy metatable
-- @return copy of *table*
local clone = base.clone
--- Clone a table, renaming some keys.
-- @function clone_rename
-- @tparam table t source table
-- @tparam table map table `{old_key=new_key, ...}`
-- @return copy of *table*
local clone_rename = base.clone_rename
--- Destructively merge another table's fields into *table*.
-- @function merge
-- @tparam table t destination table
-- @tparam table u table with fields to merge
-- @return table `t` with fields from `u` merged in
local merge = base.merge
-- Preserve core table sort function.
local _sort = table.sort
--- Make table.sort return its result.
-- @tparam table t unsorted table
-- @tparam function c comparator function
-- @return `t` with keys sorted accordind to `c`
local function sort (t, c)
_sort (t, c)
return t
end
--- Return whether table is empty.
-- @tparam table t any table
-- @return `true` if `t` is empty, otherwise `false`
local function empty (t)
return not next (t)
end
--- Turn a tuple into a list.
-- @param ... tuple
-- @return list
local function pack (...)
return {...}
end
--- Find the number of elements in a table.
-- @tparam table t any table
-- @return number of non-nil values in `t`
local function size (t)
local n = 0
for _ in pairs (t) do
n = n + 1
end
return n
end
--- Make the list of keys in table.
-- @tparam table t any table
-- @treturn table list of keys
local function keys (t)
local l = {}
for k, _ in pairs (t) do
table.insert (l, k)
end
return l
end
--- Make the list of values of a table.
-- @tparam table t any table
-- @treturn table list of values
local function values (t)
local l = {}
for _, v in pairs (t) do
table.insert (l, v)
end
return l
end
--- Invert a table.
-- @tparam table t a table with `{k=v, ...}`
-- @treturn table inverted table `{v=k, ...}`
local function invert (t)
local i = {}
for k, v in pairs (t) do
i[v] = k
end
return i
end
--- An iterator like ipairs, but in reverse.
-- @tparam table t any table
-- @treturn function iterator function
-- @treturn table the table, `t`
-- @treturn number `#t + 1`
local function ripairs (t)
return function (t, n)
n = n - 1
if n > 0 then
return n, t[n]
end
end,
t, #t + 1
end
--- Turn an object into a table according to __totable metamethod.
-- @tparam std.object x object to turn into a table
-- @treturn table resulting table or `nil`
local function totable (x)
local m = func.metamethod (x, "__totable")
if m then
return m (x)
elseif type (x) == "table" then
return x
elseif type (x) == "string" then
local t = {}
x:gsub (".", function (c) t[#t + 1] = c end)
return t
else
return nil
end
end
--- Make a table with a default value for unset keys.
-- @param x default entry value (default: `nil`)
-- @tparam table t initial table (default: `{}`)
-- @treturn table table whose unset elements are x
local function new (x, t)
return setmetatable (t or {},
{__index = function (t, i)
return x
end})
end
--- @export
local Table = {
clone = clone,
clone_rename = clone_rename,
empty = empty,
invert = invert,
keys = keys,
merge = merge,
new = new,
pack = pack,
ripairs = ripairs,
size = size,
sort = sort,
totable = totable,
values = values,
-- Core Lua table.sort function
_sort = _sort,
}
for k, v in pairs (table) do
Table[k] = Table[k] or v
end
return Table
| mit |
dafei2015/hugular_cstolua | Client/Assets/Lua/core/Plane.lua | 4 | 1309 | Plane =
{
normal = nil,
distance = 0,
}
local mt = {}
mt.__index = Plane
function Plane.New(normal, d)
local plane= {}
setmetatable(plane, mt)
plane.normal = normal:Normalize()
plane.distance = d
return plane
end
function Plane:Raycast(ray)
local a = Vector3.Dot(ray.direction, self.normal)
local num2 = -Vector3.Dot(ray.origin, self.normal) - self.distance
if math.Approximately(a, 0) then
return false, 0
end
local enter = num2 / a
return enter > 0, enter
end
function Plane:SetNormalAndPosition(inNormal, inPoint)
self.normal = inNormal:Normalize()
self.distance = -Vector3.Dot(inNormal, inPoint)
end
function Plane:Set3Points(a, b, c)
self.normal = Vector3.Normalize(Vector3.Cross(b - a, c - a))
self.distance = -Vector3.Dot(self.normal, a)
end
function Plane:GetDistanceToPoint(inPt)
return Vector3.Dot(self.normal, inPt) + self.distance
end
function Plane:GetSide(inPt)
return ((Vector3.Dot(self.normal, inPt) + self.distance) > 0)
end
function Plane:SameSide(inPt0, inPt1)
local distanceToPoint = self:GetDistanceToPoint(inPt0)
local num2 = self:GetDistanceToPoint(inPt1)
return (((distanceToPoint > 0) and (num2 > 0)) or ((distanceToPoint <= 0) and (num2 <= 0)))
end
| mit |
karrots/nodemcu-firmware | lua_modules/si7021/si7021.lua | 83 | 2184 | -- ***************************************************************************
-- SI7021 module for ESP8266 with nodeMCU
-- Si7021 compatible tested 2015-1-22
--
-- Written by VIP6
--
-- MIT license, http://opensource.org/licenses/MIT
-- ***************************************************************************
local moduleName = ...
local M = {}
_G[moduleName] = M
--I2C slave address of Si70xx
local Si7021_ADDR = 0x40
--Commands
local CMD_MEASURE_HUMIDITY_HOLD = 0xE5
local CMD_MEASURE_HUMIDITY_NO_HOLD = 0xF5
local CMD_MEASURE_TEMPERATURE_HOLD = 0xE3
local CMD_MEASURE_TEMPERATURE_NO_HOLD = 0xF3
-- temperature and pressure
local t,h
local init = false
-- i2c interface ID
local id = 0
-- 16-bit two's complement
-- value: 16-bit integer
local function twoCompl(value)
if value > 32767 then value = -(65535 - value + 1)
end
return value
end
-- read data from si7021
-- ADDR: slave address
-- commands: Commands of si7021
-- length: bytes to read
local function read_data(ADDR, commands, length)
i2c.start(id)
i2c.address(id, ADDR, i2c.TRANSMITTER)
i2c.write(id, commands)
i2c.stop(id)
i2c.start(id)
i2c.address(id, ADDR,i2c.RECEIVER)
tmr.delay(20000)
c = i2c.read(id, length)
i2c.stop(id)
return c
end
-- initialize module
-- sda: SDA pin
-- scl SCL pin
function M.init(sda, scl)
i2c.setup(id, sda, scl, i2c.SLOW)
--print("i2c ok..")
init = true
end
-- read humidity from si7021
local function read_humi()
dataH = read_data(Si7021_ADDR, CMD_MEASURE_HUMIDITY_HOLD, 2)
UH = string.byte(dataH, 1) * 256 + string.byte(dataH, 2)
h = ((UH*12500+65536/2)/65536 - 600)
return(h)
end
-- read temperature from si7021
local function read_temp()
dataT = read_data(Si7021_ADDR, CMD_MEASURE_TEMPERATURE_HOLD, 2)
UT = string.byte(dataT, 1) * 256 + string.byte(dataT, 2)
t = ((UT*17572+65536/2)/65536 - 4685)
return(t)
end
-- read temperature and humidity from si7021
function M.read()
if (not init) then
print("init() must be called before read.")
else
read_humi()
read_temp()
end
end;
-- get humidity
function M.getHumidity()
return h
end
-- get temperature
function M.getTemperature()
return t
end
return M
| mit |
Ninjistix/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/Tehf_Kimasnahya.lua | 5 | 2711 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Tehf Kimasnahya
-- Type: Standard NPC
-- !pos -89.897 -1 6.199 50
-----------------------------------
package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs");
-----------------------------------
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
local gotitall = player:getQuestStatus(AHT_URHGAN,GOT_IT_ALL);
local gotItAllProg = player:getVar("gotitallCS");
local threeMenProg = player:getVar("threemenandaclosetCS");
if (gotitall == QUEST_AVAILABLE) then
player:startEvent(520);
elseif (gotItAllProg == 4) then
player:startEvent(525);
elseif (gotItAllProg == 6) then
player:startEvent(527);
elseif (gotItAllProg >= 7 and player:getVar("Wait1DayForgotitallCS_date") < os.time() and player:needToZone() == false) then
player:startEvent(528);
elseif (gotItAllProg >= 7) then
player:startEvent(539);
elseif (gotItAllProg >= 1 and gotItAllProg <= 3) then
player:startEvent(521);
elseif (threeMenProg == 5) then
player:startEvent(843);
elseif (threeMenProg == 6) then
player:startEvent(844);
else
player:startEvent(529);
end
end;
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 520) then
player:addQuest(AHT_URHGAN,GOT_IT_ALL);
player:setVar("gotitallCS",1);
elseif (csid == 525 and option == 0) then
player:setVar("gotitallCS",5);
player:delKeyItem(VIAL_OF_LUMINOUS_WATER);
elseif (csid == 527) then
player:setVar("gotitallCS",7);
player:setVar("Wait1DayForgotitallCS_date", getMidnight());
player:needToZone(true);
elseif (csid == 539) then
player:setVar("gotitallCS",8);
elseif (csid == 528) then
if (player:getFreeSlotsCount() == 0) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,18257);
else
player:setVar("Wait1DayForgotitallCS_date",0);
player:setVar("gotitallCS",0);
player:addItem(18257); -- Bibiki Seashell
player:messageSpecial(ITEM_OBTAINED,18257);
player:completeQuest(AHT_URHGAN,GOT_IT_ALL);
end
elseif (csid == 843 and option == 1) then
player:setVar("threemenandaclosetCS",6);
end
end;
| gpl-3.0 |
arca1n/cocos2d-x_nextpeer_integration | external/lua/luajit/src/dynasm/dasm_mips.lua | 74 | 28080 | ------------------------------------------------------------------------------
-- DynASM MIPS module.
--
-- Copyright (C) 2005-2013 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------
-- Module information:
local _info = {
arch = "mips",
description = "DynASM MIPS module",
version = "1.3.0",
vernum = 10300,
release = "2012-01-23",
author = "Mike Pall",
license = "MIT",
}
-- Exported glue functions for the arch-specific module.
local _M = { _info = _info }
-- Cache library functions.
local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs
local assert, setmetatable = assert, setmetatable
local _s = string
local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char
local match, gmatch = _s.match, _s.gmatch
local concat, sort = table.concat, table.sort
local bit = bit or require("bit")
local band, shl, sar, tohex = bit.band, bit.lshift, bit.arshift, bit.tohex
-- Inherited tables and callbacks.
local g_opt, g_arch
local wline, werror, wfatal, wwarn
-- Action name list.
-- CHECK: Keep this in sync with the C code!
local action_names = {
"STOP", "SECTION", "ESC", "REL_EXT",
"ALIGN", "REL_LG", "LABEL_LG",
"REL_PC", "LABEL_PC", "IMM",
}
-- Maximum number of section buffer positions for dasm_put().
-- CHECK: Keep this in sync with the C code!
local maxsecpos = 25 -- Keep this low, to avoid excessively long C lines.
-- Action name -> action number.
local map_action = {}
for n,name in ipairs(action_names) do
map_action[name] = n-1
end
-- Action list buffer.
local actlist = {}
-- Argument list for next dasm_put(). Start with offset 0 into action list.
local actargs = { 0 }
-- Current number of section buffer positions for dasm_put().
local secpos = 1
------------------------------------------------------------------------------
-- Dump action names and numbers.
local function dumpactions(out)
out:write("DynASM encoding engine action codes:\n")
for n,name in ipairs(action_names) do
local num = map_action[name]
out:write(format(" %-10s %02X %d\n", name, num, num))
end
out:write("\n")
end
-- Write action list buffer as a huge static C array.
local function writeactions(out, name)
local nn = #actlist
if nn == 0 then nn = 1; actlist[0] = map_action.STOP end
out:write("static const unsigned int ", name, "[", nn, "] = {\n")
for i = 1,nn-1 do
assert(out:write("0x", tohex(actlist[i]), ",\n"))
end
assert(out:write("0x", tohex(actlist[nn]), "\n};\n\n"))
end
------------------------------------------------------------------------------
-- Add word to action list.
local function wputxw(n)
assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range")
actlist[#actlist+1] = n
end
-- Add action to list with optional arg. Advance buffer pos, too.
local function waction(action, val, a, num)
local w = assert(map_action[action], "bad action name `"..action.."'")
wputxw(0xff000000 + w * 0x10000 + (val or 0))
if a then actargs[#actargs+1] = a end
if a or num then secpos = secpos + (num or 1) end
end
-- Flush action list (intervening C code or buffer pos overflow).
local function wflush(term)
if #actlist == actargs[1] then return end -- Nothing to flush.
if not term then waction("STOP") end -- Terminate action list.
wline(format("dasm_put(Dst, %s);", concat(actargs, ", ")), true)
actargs = { #actlist } -- Actionlist offset is 1st arg to next dasm_put().
secpos = 1 -- The actionlist offset occupies a buffer position, too.
end
-- Put escaped word.
local function wputw(n)
if n >= 0xff000000 then waction("ESC") end
wputxw(n)
end
-- Reserve position for word.
local function wpos()
local pos = #actlist+1
actlist[pos] = ""
return pos
end
-- Store word to reserved position.
local function wputpos(pos, n)
assert(n >= 0 and n <= 0xffffffff and n % 1 == 0, "word out of range")
actlist[pos] = n
end
------------------------------------------------------------------------------
-- Global label name -> global label number. With auto assignment on 1st use.
local next_global = 20
local map_global = setmetatable({}, { __index = function(t, name)
if not match(name, "^[%a_][%w_]*$") then werror("bad global label") end
local n = next_global
if n > 2047 then werror("too many global labels") end
next_global = n + 1
t[name] = n
return n
end})
-- Dump global labels.
local function dumpglobals(out, lvl)
local t = {}
for name, n in pairs(map_global) do t[n] = name end
out:write("Global labels:\n")
for i=20,next_global-1 do
out:write(format(" %s\n", t[i]))
end
out:write("\n")
end
-- Write global label enum.
local function writeglobals(out, prefix)
local t = {}
for name, n in pairs(map_global) do t[n] = name end
out:write("enum {\n")
for i=20,next_global-1 do
out:write(" ", prefix, t[i], ",\n")
end
out:write(" ", prefix, "_MAX\n};\n")
end
-- Write global label names.
local function writeglobalnames(out, name)
local t = {}
for name, n in pairs(map_global) do t[n] = name end
out:write("static const char *const ", name, "[] = {\n")
for i=20,next_global-1 do
out:write(" \"", t[i], "\",\n")
end
out:write(" (const char *)0\n};\n")
end
------------------------------------------------------------------------------
-- Extern label name -> extern label number. With auto assignment on 1st use.
local next_extern = 0
local map_extern_ = {}
local map_extern = setmetatable({}, { __index = function(t, name)
-- No restrictions on the name for now.
local n = next_extern
if n > 2047 then werror("too many extern labels") end
next_extern = n + 1
t[name] = n
map_extern_[n] = name
return n
end})
-- Dump extern labels.
local function dumpexterns(out, lvl)
out:write("Extern labels:\n")
for i=0,next_extern-1 do
out:write(format(" %s\n", map_extern_[i]))
end
out:write("\n")
end
-- Write extern label names.
local function writeexternnames(out, name)
out:write("static const char *const ", name, "[] = {\n")
for i=0,next_extern-1 do
out:write(" \"", map_extern_[i], "\",\n")
end
out:write(" (const char *)0\n};\n")
end
------------------------------------------------------------------------------
-- Arch-specific maps.
local map_archdef = { sp="r29", ra="r31" } -- Ext. register name -> int. name.
local map_type = {} -- Type name -> { ctype, reg }
local ctypenum = 0 -- Type number (for Dt... macros).
-- Reverse defines for registers.
function _M.revdef(s)
if s == "r29" then return "sp"
elseif s == "r31" then return "ra" end
return s
end
------------------------------------------------------------------------------
-- Template strings for MIPS instructions.
local map_op = {
-- First-level opcodes.
j_1 = "08000000J",
jal_1 = "0c000000J",
b_1 = "10000000B",
beqz_2 = "10000000SB",
beq_3 = "10000000STB",
bnez_2 = "14000000SB",
bne_3 = "14000000STB",
blez_2 = "18000000SB",
bgtz_2 = "1c000000SB",
addi_3 = "20000000TSI",
li_2 = "24000000TI",
addiu_3 = "24000000TSI",
slti_3 = "28000000TSI",
sltiu_3 = "2c000000TSI",
andi_3 = "30000000TSU",
lu_2 = "34000000TU",
ori_3 = "34000000TSU",
xori_3 = "38000000TSU",
lui_2 = "3c000000TU",
beqzl_2 = "50000000SB",
beql_3 = "50000000STB",
bnezl_2 = "54000000SB",
bnel_3 = "54000000STB",
blezl_2 = "58000000SB",
bgtzl_2 = "5c000000SB",
lb_2 = "80000000TO",
lh_2 = "84000000TO",
lwl_2 = "88000000TO",
lw_2 = "8c000000TO",
lbu_2 = "90000000TO",
lhu_2 = "94000000TO",
lwr_2 = "98000000TO",
sb_2 = "a0000000TO",
sh_2 = "a4000000TO",
swl_2 = "a8000000TO",
sw_2 = "ac000000TO",
swr_2 = "b8000000TO",
cache_2 = "bc000000NO",
ll_2 = "c0000000TO",
lwc1_2 = "c4000000HO",
pref_2 = "cc000000NO",
ldc1_2 = "d4000000HO",
sc_2 = "e0000000TO",
swc1_2 = "e4000000HO",
sdc1_2 = "f4000000HO",
-- Opcode SPECIAL.
nop_0 = "00000000",
sll_3 = "00000000DTA",
movf_2 = "00000001DS",
movf_3 = "00000001DSC",
movt_2 = "00010001DS",
movt_3 = "00010001DSC",
srl_3 = "00000002DTA",
rotr_3 = "00200002DTA",
sra_3 = "00000003DTA",
sllv_3 = "00000004DTS",
srlv_3 = "00000006DTS",
rotrv_3 = "00000046DTS",
srav_3 = "00000007DTS",
jr_1 = "00000008S",
jalr_1 = "0000f809S",
jalr_2 = "00000009DS",
movz_3 = "0000000aDST",
movn_3 = "0000000bDST",
syscall_0 = "0000000c",
syscall_1 = "0000000cY",
break_0 = "0000000d",
break_1 = "0000000dY",
sync_0 = "0000000f",
mfhi_1 = "00000010D",
mthi_1 = "00000011S",
mflo_1 = "00000012D",
mtlo_1 = "00000013S",
mult_2 = "00000018ST",
multu_2 = "00000019ST",
div_2 = "0000001aST",
divu_2 = "0000001bST",
add_3 = "00000020DST",
move_2 = "00000021DS",
addu_3 = "00000021DST",
sub_3 = "00000022DST",
negu_2 = "00000023DT",
subu_3 = "00000023DST",
and_3 = "00000024DST",
or_3 = "00000025DST",
xor_3 = "00000026DST",
not_2 = "00000027DS",
nor_3 = "00000027DST",
slt_3 = "0000002aDST",
sltu_3 = "0000002bDST",
tge_2 = "00000030ST",
tge_3 = "00000030STZ",
tgeu_2 = "00000031ST",
tgeu_3 = "00000031STZ",
tlt_2 = "00000032ST",
tlt_3 = "00000032STZ",
tltu_2 = "00000033ST",
tltu_3 = "00000033STZ",
teq_2 = "00000034ST",
teq_3 = "00000034STZ",
tne_2 = "00000036ST",
tne_3 = "00000036STZ",
-- Opcode REGIMM.
bltz_2 = "04000000SB",
bgez_2 = "04010000SB",
bltzl_2 = "04020000SB",
bgezl_2 = "04030000SB",
tgei_2 = "04080000SI",
tgeiu_2 = "04090000SI",
tlti_2 = "040a0000SI",
tltiu_2 = "040b0000SI",
teqi_2 = "040c0000SI",
tnei_2 = "040e0000SI",
bltzal_2 = "04100000SB",
bal_1 = "04110000B",
bgezal_2 = "04110000SB",
bltzall_2 = "04120000SB",
bgezall_2 = "04130000SB",
synci_1 = "041f0000O",
-- Opcode SPECIAL2.
madd_2 = "70000000ST",
maddu_2 = "70000001ST",
mul_3 = "70000002DST",
msub_2 = "70000004ST",
msubu_2 = "70000005ST",
clz_2 = "70000020DS=",
clo_2 = "70000021DS=",
sdbbp_0 = "7000003f",
sdbbp_1 = "7000003fY",
-- Opcode SPECIAL3.
ext_4 = "7c000000TSAM", -- Note: last arg is msbd = size-1
ins_4 = "7c000004TSAM", -- Note: last arg is msb = pos+size-1
wsbh_2 = "7c0000a0DT",
seb_2 = "7c000420DT",
seh_2 = "7c000620DT",
rdhwr_2 = "7c00003bTD",
-- Opcode COP0.
mfc0_2 = "40000000TD",
mfc0_3 = "40000000TDW",
mtc0_2 = "40800000TD",
mtc0_3 = "40800000TDW",
rdpgpr_2 = "41400000DT",
di_0 = "41606000",
di_1 = "41606000T",
ei_0 = "41606020",
ei_1 = "41606020T",
wrpgpr_2 = "41c00000DT",
tlbr_0 = "42000001",
tlbwi_0 = "42000002",
tlbwr_0 = "42000006",
tlbp_0 = "42000008",
eret_0 = "42000018",
deret_0 = "4200001f",
wait_0 = "42000020",
-- Opcode COP1.
mfc1_2 = "44000000TG",
cfc1_2 = "44400000TG",
mfhc1_2 = "44600000TG",
mtc1_2 = "44800000TG",
ctc1_2 = "44c00000TG",
mthc1_2 = "44e00000TG",
bc1f_1 = "45000000B",
bc1f_2 = "45000000CB",
bc1t_1 = "45010000B",
bc1t_2 = "45010000CB",
bc1fl_1 = "45020000B",
bc1fl_2 = "45020000CB",
bc1tl_1 = "45030000B",
bc1tl_2 = "45030000CB",
["add.s_3"] = "46000000FGH",
["sub.s_3"] = "46000001FGH",
["mul.s_3"] = "46000002FGH",
["div.s_3"] = "46000003FGH",
["sqrt.s_2"] = "46000004FG",
["abs.s_2"] = "46000005FG",
["mov.s_2"] = "46000006FG",
["neg.s_2"] = "46000007FG",
["round.l.s_2"] = "46000008FG",
["trunc.l.s_2"] = "46000009FG",
["ceil.l.s_2"] = "4600000aFG",
["floor.l.s_2"] = "4600000bFG",
["round.w.s_2"] = "4600000cFG",
["trunc.w.s_2"] = "4600000dFG",
["ceil.w.s_2"] = "4600000eFG",
["floor.w.s_2"] = "4600000fFG",
["movf.s_2"] = "46000011FG",
["movf.s_3"] = "46000011FGC",
["movt.s_2"] = "46010011FG",
["movt.s_3"] = "46010011FGC",
["movz.s_3"] = "46000012FGT",
["movn.s_3"] = "46000013FGT",
["recip.s_2"] = "46000015FG",
["rsqrt.s_2"] = "46000016FG",
["cvt.d.s_2"] = "46000021FG",
["cvt.w.s_2"] = "46000024FG",
["cvt.l.s_2"] = "46000025FG",
["cvt.ps.s_3"] = "46000026FGH",
["c.f.s_2"] = "46000030GH",
["c.f.s_3"] = "46000030VGH",
["c.un.s_2"] = "46000031GH",
["c.un.s_3"] = "46000031VGH",
["c.eq.s_2"] = "46000032GH",
["c.eq.s_3"] = "46000032VGH",
["c.ueq.s_2"] = "46000033GH",
["c.ueq.s_3"] = "46000033VGH",
["c.olt.s_2"] = "46000034GH",
["c.olt.s_3"] = "46000034VGH",
["c.ult.s_2"] = "46000035GH",
["c.ult.s_3"] = "46000035VGH",
["c.ole.s_2"] = "46000036GH",
["c.ole.s_3"] = "46000036VGH",
["c.ule.s_2"] = "46000037GH",
["c.ule.s_3"] = "46000037VGH",
["c.sf.s_2"] = "46000038GH",
["c.sf.s_3"] = "46000038VGH",
["c.ngle.s_2"] = "46000039GH",
["c.ngle.s_3"] = "46000039VGH",
["c.seq.s_2"] = "4600003aGH",
["c.seq.s_3"] = "4600003aVGH",
["c.ngl.s_2"] = "4600003bGH",
["c.ngl.s_3"] = "4600003bVGH",
["c.lt.s_2"] = "4600003cGH",
["c.lt.s_3"] = "4600003cVGH",
["c.nge.s_2"] = "4600003dGH",
["c.nge.s_3"] = "4600003dVGH",
["c.le.s_2"] = "4600003eGH",
["c.le.s_3"] = "4600003eVGH",
["c.ngt.s_2"] = "4600003fGH",
["c.ngt.s_3"] = "4600003fVGH",
["add.d_3"] = "46200000FGH",
["sub.d_3"] = "46200001FGH",
["mul.d_3"] = "46200002FGH",
["div.d_3"] = "46200003FGH",
["sqrt.d_2"] = "46200004FG",
["abs.d_2"] = "46200005FG",
["mov.d_2"] = "46200006FG",
["neg.d_2"] = "46200007FG",
["round.l.d_2"] = "46200008FG",
["trunc.l.d_2"] = "46200009FG",
["ceil.l.d_2"] = "4620000aFG",
["floor.l.d_2"] = "4620000bFG",
["round.w.d_2"] = "4620000cFG",
["trunc.w.d_2"] = "4620000dFG",
["ceil.w.d_2"] = "4620000eFG",
["floor.w.d_2"] = "4620000fFG",
["movf.d_2"] = "46200011FG",
["movf.d_3"] = "46200011FGC",
["movt.d_2"] = "46210011FG",
["movt.d_3"] = "46210011FGC",
["movz.d_3"] = "46200012FGT",
["movn.d_3"] = "46200013FGT",
["recip.d_2"] = "46200015FG",
["rsqrt.d_2"] = "46200016FG",
["cvt.s.d_2"] = "46200020FG",
["cvt.w.d_2"] = "46200024FG",
["cvt.l.d_2"] = "46200025FG",
["c.f.d_2"] = "46200030GH",
["c.f.d_3"] = "46200030VGH",
["c.un.d_2"] = "46200031GH",
["c.un.d_3"] = "46200031VGH",
["c.eq.d_2"] = "46200032GH",
["c.eq.d_3"] = "46200032VGH",
["c.ueq.d_2"] = "46200033GH",
["c.ueq.d_3"] = "46200033VGH",
["c.olt.d_2"] = "46200034GH",
["c.olt.d_3"] = "46200034VGH",
["c.ult.d_2"] = "46200035GH",
["c.ult.d_3"] = "46200035VGH",
["c.ole.d_2"] = "46200036GH",
["c.ole.d_3"] = "46200036VGH",
["c.ule.d_2"] = "46200037GH",
["c.ule.d_3"] = "46200037VGH",
["c.sf.d_2"] = "46200038GH",
["c.sf.d_3"] = "46200038VGH",
["c.ngle.d_2"] = "46200039GH",
["c.ngle.d_3"] = "46200039VGH",
["c.seq.d_2"] = "4620003aGH",
["c.seq.d_3"] = "4620003aVGH",
["c.ngl.d_2"] = "4620003bGH",
["c.ngl.d_3"] = "4620003bVGH",
["c.lt.d_2"] = "4620003cGH",
["c.lt.d_3"] = "4620003cVGH",
["c.nge.d_2"] = "4620003dGH",
["c.nge.d_3"] = "4620003dVGH",
["c.le.d_2"] = "4620003eGH",
["c.le.d_3"] = "4620003eVGH",
["c.ngt.d_2"] = "4620003fGH",
["c.ngt.d_3"] = "4620003fVGH",
["add.ps_3"] = "46c00000FGH",
["sub.ps_3"] = "46c00001FGH",
["mul.ps_3"] = "46c00002FGH",
["abs.ps_2"] = "46c00005FG",
["mov.ps_2"] = "46c00006FG",
["neg.ps_2"] = "46c00007FG",
["movf.ps_2"] = "46c00011FG",
["movf.ps_3"] = "46c00011FGC",
["movt.ps_2"] = "46c10011FG",
["movt.ps_3"] = "46c10011FGC",
["movz.ps_3"] = "46c00012FGT",
["movn.ps_3"] = "46c00013FGT",
["cvt.s.pu_2"] = "46c00020FG",
["cvt.s.pl_2"] = "46c00028FG",
["pll.ps_3"] = "46c0002cFGH",
["plu.ps_3"] = "46c0002dFGH",
["pul.ps_3"] = "46c0002eFGH",
["puu.ps_3"] = "46c0002fFGH",
["c.f.ps_2"] = "46c00030GH",
["c.f.ps_3"] = "46c00030VGH",
["c.un.ps_2"] = "46c00031GH",
["c.un.ps_3"] = "46c00031VGH",
["c.eq.ps_2"] = "46c00032GH",
["c.eq.ps_3"] = "46c00032VGH",
["c.ueq.ps_2"] = "46c00033GH",
["c.ueq.ps_3"] = "46c00033VGH",
["c.olt.ps_2"] = "46c00034GH",
["c.olt.ps_3"] = "46c00034VGH",
["c.ult.ps_2"] = "46c00035GH",
["c.ult.ps_3"] = "46c00035VGH",
["c.ole.ps_2"] = "46c00036GH",
["c.ole.ps_3"] = "46c00036VGH",
["c.ule.ps_2"] = "46c00037GH",
["c.ule.ps_3"] = "46c00037VGH",
["c.sf.ps_2"] = "46c00038GH",
["c.sf.ps_3"] = "46c00038VGH",
["c.ngle.ps_2"] = "46c00039GH",
["c.ngle.ps_3"] = "46c00039VGH",
["c.seq.ps_2"] = "46c0003aGH",
["c.seq.ps_3"] = "46c0003aVGH",
["c.ngl.ps_2"] = "46c0003bGH",
["c.ngl.ps_3"] = "46c0003bVGH",
["c.lt.ps_2"] = "46c0003cGH",
["c.lt.ps_3"] = "46c0003cVGH",
["c.nge.ps_2"] = "46c0003dGH",
["c.nge.ps_3"] = "46c0003dVGH",
["c.le.ps_2"] = "46c0003eGH",
["c.le.ps_3"] = "46c0003eVGH",
["c.ngt.ps_2"] = "46c0003fGH",
["c.ngt.ps_3"] = "46c0003fVGH",
["cvt.s.w_2"] = "46800020FG",
["cvt.d.w_2"] = "46800021FG",
["cvt.s.l_2"] = "46a00020FG",
["cvt.d.l_2"] = "46a00021FG",
-- Opcode COP1X.
lwxc1_2 = "4c000000FX",
ldxc1_2 = "4c000001FX",
luxc1_2 = "4c000005FX",
swxc1_2 = "4c000008FX",
sdxc1_2 = "4c000009FX",
suxc1_2 = "4c00000dFX",
prefx_2 = "4c00000fMX",
["alnv.ps_4"] = "4c00001eFGHS",
["madd.s_4"] = "4c000020FRGH",
["madd.d_4"] = "4c000021FRGH",
["madd.ps_4"] = "4c000026FRGH",
["msub.s_4"] = "4c000028FRGH",
["msub.d_4"] = "4c000029FRGH",
["msub.ps_4"] = "4c00002eFRGH",
["nmadd.s_4"] = "4c000030FRGH",
["nmadd.d_4"] = "4c000031FRGH",
["nmadd.ps_4"] = "4c000036FRGH",
["nmsub.s_4"] = "4c000038FRGH",
["nmsub.d_4"] = "4c000039FRGH",
["nmsub.ps_4"] = "4c00003eFRGH",
}
------------------------------------------------------------------------------
local function parse_gpr(expr)
local tname, ovreg = match(expr, "^([%w_]+):(r[1-3]?[0-9])$")
local tp = map_type[tname or expr]
if tp then
local reg = ovreg or tp.reg
if not reg then
werror("type `"..(tname or expr).."' needs a register override")
end
expr = reg
end
local r = match(expr, "^r([1-3]?[0-9])$")
if r then
r = tonumber(r)
if r <= 31 then return r, tp end
end
werror("bad register name `"..expr.."'")
end
local function parse_fpr(expr)
local r = match(expr, "^f([1-3]?[0-9])$")
if r then
r = tonumber(r)
if r <= 31 then return r end
end
werror("bad register name `"..expr.."'")
end
local function parse_imm(imm, bits, shift, scale, signed)
local n = tonumber(imm)
if n then
local m = sar(n, scale)
if shl(m, scale) == n then
if signed then
local s = sar(m, bits-1)
if s == 0 then return shl(m, shift)
elseif s == -1 then return shl(m + shl(1, bits), shift) end
else
if sar(m, bits) == 0 then return shl(m, shift) end
end
end
werror("out of range immediate `"..imm.."'")
elseif match(imm, "^[rf]([1-3]?[0-9])$") or
match(imm, "^([%w_]+):([rf][1-3]?[0-9])$") then
werror("expected immediate operand, got register")
else
waction("IMM", (signed and 32768 or 0)+scale*1024+bits*32+shift, imm)
return 0
end
end
local function parse_disp(disp)
local imm, reg = match(disp, "^(.*)%(([%w_:]+)%)$")
if imm then
local r = shl(parse_gpr(reg), 21)
local extname = match(imm, "^extern%s+(%S+)$")
if extname then
waction("REL_EXT", map_extern[extname], nil, 1)
return r
else
return r + parse_imm(imm, 16, 0, 0, true)
end
end
local reg, tailr = match(disp, "^([%w_:]+)%s*(.*)$")
if reg and tailr ~= "" then
local r, tp = parse_gpr(reg)
if tp then
waction("IMM", 32768+16*32, format(tp.ctypefmt, tailr))
return shl(r, 21)
end
end
werror("bad displacement `"..disp.."'")
end
local function parse_index(idx)
local rt, rs = match(idx, "^(.*)%(([%w_:]+)%)$")
if rt then
rt = parse_gpr(rt)
rs = parse_gpr(rs)
return shl(rt, 16) + shl(rs, 21)
end
werror("bad index `"..idx.."'")
end
local function parse_label(label, def)
local prefix = sub(label, 1, 2)
-- =>label (pc label reference)
if prefix == "=>" then
return "PC", 0, sub(label, 3)
end
-- ->name (global label reference)
if prefix == "->" then
return "LG", map_global[sub(label, 3)]
end
if def then
-- [1-9] (local label definition)
if match(label, "^[1-9]$") then
return "LG", 10+tonumber(label)
end
else
-- [<>][1-9] (local label reference)
local dir, lnum = match(label, "^([<>])([1-9])$")
if dir then -- Fwd: 1-9, Bkwd: 11-19.
return "LG", lnum + (dir == ">" and 0 or 10)
end
-- extern label (extern label reference)
local extname = match(label, "^extern%s+(%S+)$")
if extname then
return "EXT", map_extern[extname]
end
end
werror("bad label `"..label.."'")
end
------------------------------------------------------------------------------
-- Handle opcodes defined with template strings.
map_op[".template__"] = function(params, template, nparams)
if not params then return sub(template, 9) end
local op = tonumber(sub(template, 1, 8), 16)
local n = 1
-- Limit number of section buffer positions used by a single dasm_put().
-- A single opcode needs a maximum of 2 positions (ins/ext).
if secpos+2 > maxsecpos then wflush() end
local pos = wpos()
-- Process each character.
for p in gmatch(sub(template, 9), ".") do
if p == "D" then
op = op + shl(parse_gpr(params[n]), 11); n = n + 1
elseif p == "T" then
op = op + shl(parse_gpr(params[n]), 16); n = n + 1
elseif p == "S" then
op = op + shl(parse_gpr(params[n]), 21); n = n + 1
elseif p == "F" then
op = op + shl(parse_fpr(params[n]), 6); n = n + 1
elseif p == "G" then
op = op + shl(parse_fpr(params[n]), 11); n = n + 1
elseif p == "H" then
op = op + shl(parse_fpr(params[n]), 16); n = n + 1
elseif p == "R" then
op = op + shl(parse_fpr(params[n]), 21); n = n + 1
elseif p == "I" then
op = op + parse_imm(params[n], 16, 0, 0, true); n = n + 1
elseif p == "U" then
op = op + parse_imm(params[n], 16, 0, 0, false); n = n + 1
elseif p == "O" then
op = op + parse_disp(params[n]); n = n + 1
elseif p == "X" then
op = op + parse_index(params[n]); n = n + 1
elseif p == "B" or p == "J" then
local mode, n, s = parse_label(params[n], false)
if p == "B" then n = n + 2048 end
waction("REL_"..mode, n, s, 1)
n = n + 1
elseif p == "A" then
op = op + parse_imm(params[n], 5, 6, 0, false); n = n + 1
elseif p == "M" then
op = op + parse_imm(params[n], 5, 11, 0, false); n = n + 1
elseif p == "N" then
op = op + parse_imm(params[n], 5, 16, 0, false); n = n + 1
elseif p == "C" then
op = op + parse_imm(params[n], 3, 18, 0, false); n = n + 1
elseif p == "V" then
op = op + parse_imm(params[n], 3, 8, 0, false); n = n + 1
elseif p == "W" then
op = op + parse_imm(params[n], 3, 0, 0, false); n = n + 1
elseif p == "Y" then
op = op + parse_imm(params[n], 20, 6, 0, false); n = n + 1
elseif p == "Z" then
op = op + parse_imm(params[n], 10, 6, 0, false); n = n + 1
elseif p == "=" then
op = op + shl(band(op, 0xf800), 5) -- Copy D to T for clz, clo.
else
assert(false)
end
end
wputpos(pos, op)
end
------------------------------------------------------------------------------
-- Pseudo-opcode to mark the position where the action list is to be emitted.
map_op[".actionlist_1"] = function(params)
if not params then return "cvar" end
local name = params[1] -- No syntax check. You get to keep the pieces.
wline(function(out) writeactions(out, name) end)
end
-- Pseudo-opcode to mark the position where the global enum is to be emitted.
map_op[".globals_1"] = function(params)
if not params then return "prefix" end
local prefix = params[1] -- No syntax check. You get to keep the pieces.
wline(function(out) writeglobals(out, prefix) end)
end
-- Pseudo-opcode to mark the position where the global names are to be emitted.
map_op[".globalnames_1"] = function(params)
if not params then return "cvar" end
local name = params[1] -- No syntax check. You get to keep the pieces.
wline(function(out) writeglobalnames(out, name) end)
end
-- Pseudo-opcode to mark the position where the extern names are to be emitted.
map_op[".externnames_1"] = function(params)
if not params then return "cvar" end
local name = params[1] -- No syntax check. You get to keep the pieces.
wline(function(out) writeexternnames(out, name) end)
end
------------------------------------------------------------------------------
-- Label pseudo-opcode (converted from trailing colon form).
map_op[".label_1"] = function(params)
if not params then return "[1-9] | ->global | =>pcexpr" end
if secpos+1 > maxsecpos then wflush() end
local mode, n, s = parse_label(params[1], true)
if mode == "EXT" then werror("bad label definition") end
waction("LABEL_"..mode, n, s, 1)
end
------------------------------------------------------------------------------
-- Pseudo-opcodes for data storage.
map_op[".long_*"] = function(params)
if not params then return "imm..." end
for _,p in ipairs(params) do
local n = tonumber(p)
if not n then werror("bad immediate `"..p.."'") end
if n < 0 then n = n + 2^32 end
wputw(n)
if secpos+2 > maxsecpos then wflush() end
end
end
-- Alignment pseudo-opcode.
map_op[".align_1"] = function(params)
if not params then return "numpow2" end
if secpos+1 > maxsecpos then wflush() end
local align = tonumber(params[1])
if align then
local x = align
-- Must be a power of 2 in the range (2 ... 256).
for i=1,8 do
x = x / 2
if x == 1 then
waction("ALIGN", align-1, nil, 1) -- Action byte is 2**n-1.
return
end
end
end
werror("bad alignment")
end
------------------------------------------------------------------------------
-- Pseudo-opcode for (primitive) type definitions (map to C types).
map_op[".type_3"] = function(params, nparams)
if not params then
return nparams == 2 and "name, ctype" or "name, ctype, reg"
end
local name, ctype, reg = params[1], params[2], params[3]
if not match(name, "^[%a_][%w_]*$") then
werror("bad type name `"..name.."'")
end
local tp = map_type[name]
if tp then
werror("duplicate type `"..name.."'")
end
-- Add #type to defines. A bit unclean to put it in map_archdef.
map_archdef["#"..name] = "sizeof("..ctype..")"
-- Add new type and emit shortcut define.
local num = ctypenum + 1
map_type[name] = {
ctype = ctype,
ctypefmt = format("Dt%X(%%s)", num),
reg = reg,
}
wline(format("#define Dt%X(_V) (int)(ptrdiff_t)&(((%s *)0)_V)", num, ctype))
ctypenum = num
end
map_op[".type_2"] = map_op[".type_3"]
-- Dump type definitions.
local function dumptypes(out, lvl)
local t = {}
for name in pairs(map_type) do t[#t+1] = name end
sort(t)
out:write("Type definitions:\n")
for _,name in ipairs(t) do
local tp = map_type[name]
local reg = tp.reg or ""
out:write(format(" %-20s %-20s %s\n", name, tp.ctype, reg))
end
out:write("\n")
end
------------------------------------------------------------------------------
-- Set the current section.
function _M.section(num)
waction("SECTION", num)
wflush(true) -- SECTION is a terminal action.
end
------------------------------------------------------------------------------
-- Dump architecture description.
function _M.dumparch(out)
out:write(format("DynASM %s version %s, released %s\n\n",
_info.arch, _info.version, _info.release))
dumpactions(out)
end
-- Dump all user defined elements.
function _M.dumpdef(out, lvl)
dumptypes(out, lvl)
dumpglobals(out, lvl)
dumpexterns(out, lvl)
end
------------------------------------------------------------------------------
-- Pass callbacks from/to the DynASM core.
function _M.passcb(wl, we, wf, ww)
wline, werror, wfatal, wwarn = wl, we, wf, ww
return wflush
end
-- Setup the arch-specific module.
function _M.setup(arch, opt)
g_arch, g_opt = arch, opt
end
-- Merge the core maps and the arch-specific maps.
function _M.mergemaps(map_coreop, map_def)
setmetatable(map_op, { __index = map_coreop })
setmetatable(map_def, { __index = map_archdef })
return map_op, map_def
end
return _M
------------------------------------------------------------------------------
| mit |
jamiepg1/MCServer | MCServer/Plugins/APIDump/Hooks/OnTakeDamage.lua | 44 | 1214 | return
{
HOOK_TAKE_DAMAGE =
{
CalledWhen = "An {{cEntity|entity}} is taking any kind of damage",
DefaultFnName = "OnTakeDamage", -- also used as pagename
Desc = [[
This hook is called when any {{cEntity}} descendant, such as a {{cPlayer|player}} or a
{{cMonster|mob}}, takes any kind of damage. The plugins may modify the amount of damage or effects
with this hook by editting the {{TakeDamageInfo}} object passed.</p>
<p>
This hook is called after the final damage is calculated, including all the possible weapon
{{cEnchantments|enchantments}}, armor protection and potion effects.
]],
Params =
{
{ Name = "Receiver", Type = "{{cEntity}} descendant", Notes = "The entity taking damage" },
{ Name = "TDI", Type = "{{TakeDamageInfo}}", Notes = "The damage type, cause and effects. Plugins may modify this object to alter the final damage applied." },
},
Returns = [[
If the function returns false or no value, other plugins' callbacks are called and then the server
applies the final values from the TDI object to Receiver. If the function returns true, no other
callbacks are called, and no damage nor effects are applied.
]],
}, -- HOOK_TAKE_DAMAGE
}
| apache-2.0 |
Ninjistix/darkstar | scripts/zones/Windurst_Woods/npcs/Nokkhi_Jinjahl.lua | 7 | 5182 | -----------------------------------
-- Area: Windurst Woods
-- NPC: Nokkhi Jinjahl
-- Type: Travelling Merchant NPC / NPC Quiver Maker / Windurst 1st Place
-- !pos 4 1 -43 241
-----------------------------------
package.loaded["scripts/zones/Windurst_Woods/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Windurst_Woods/TextIDs");
-----------------------------------
function onTrade(player,npc,trade)
local ammoList =
{
{21307, 6199}, -- arrow, achiyalabopa
{21306, 6200}, -- arrow, adlivun
{19195, 5819}, -- arrow, antlion
{18154, 4221}, -- arrow, beetle
{21309, 6137}, -- arrow, chapuli
{18159, 4224}, -- arrow, demon
{21302, 6269}, -- arrow, eminent
{19800, 5912}, -- arrow, gargouille
{18156, 4222}, -- arrow, horn
{17320, 4225}, -- arrow, iron
{17325, 5332}, -- arrow, kabura
{21308, 6138}, -- arrow, mantid
{21303, 6280}, -- arrow, ra'kaznar
{21304, 6202}, -- arrow, raaz
{19182, 5871}, -- arrow, ruszor
{18155, 4223}, -- arrow, scorpion
{17321, 4226}, -- arrow, silver
{18158, 5333}, -- arrow, sleep
{17330, 4219}, -- arrow, stone
{21305, 6201}, -- arrow, tulfaire
{21314, 6278}, -- bolt, abrasion
{21321, 6203}, -- bolt, achiyalabopa
{18148, 5335}, -- bolt, acid
{19801, 5913}, -- bolt, adaman
{21320, 6204}, -- bolt, adlivun
{21318, 6206}, -- bolt, bismuth
{18150, 5334}, -- bolt, blind
{18151, 5339}, -- bolt, bloody
{21322, 6140}, -- bolt, damascus
{19183, 5872}, -- bolt, dark adaman
{19196, 5820}, -- bolt, darkling
{17338, 4229}, -- bolt, darksteel
{21316, 6270}, -- bolt, eminent
{19197, 5821}, -- bolt, fusion
{21313, 6310}, -- bolt, gashing
{18153, 5336}, -- bolt, holy
{21324, 6139}, -- bolt, midrium
{17337, 4228}, -- bolt, mythril
{21323, 6141}, -- bolt, oxidant
{21317, 6281}, -- bolt, ra'kaznar
{21315, 6279}, -- bolt, righteous
{18149, 5337}, -- bolt, sleep
{21319, 6205}, -- bolt, titanium
{18152, 5338}, -- bolt, venom
{19803, 5915}, -- bullet, adaman
{21336, 6208}, -- bullet, adlivun
{21337, 6207}, -- bullet, achiyalabopa
{17340, 5363}, -- bullet
{21333, 6210}, -- bullet, bismuth
{17343, 5359}, -- bullet, bronze
{21338, 6143}, -- bullet, damascus
{19184, 5873}, -- bullet, dark adaman
{21330, 6311}, -- bullet, decimating
{21328, 6437}, -- bullet, divine
{19198, 5822}, -- bullet, dweomer
{21331, 6271}, -- bullet, eminent
{17312, 5353}, -- bullet, iron
{19802, 5914}, -- bullet, orichalcum
{19199, 5823}, -- bullet, oberon's
{21332, 6282}, -- bullet, ra'kaznar
{17341, 5340}, -- bullet, silver
{18723, 5416}, -- bullet, steel
{18160, 5341}, -- bullet, spartan
{21335, 6209}, -- bullet, titanium
{2176, 5402}, -- card, fire
{2177, 5403}, -- card, ice
{2178, 5404}, -- card, wind
{2179, 5405}, -- card, earth
{2180, 5406}, -- card, thunder
{2181, 5407}, -- card, water
{2182, 5408}, -- card, light
{2183, 5409}, -- card, dark
};
local carnationsNeeded = 0;
local giveToPlayer = {};
-- check for invalid items
for i = 0,8,1 do
local itemId = trade:getItemId(i);
if (itemId > 0 and itemId ~= 948) then
local validSlot = false;
for k, v in pairs(ammoList) do
if (v[1] == itemId) then
local itemQty = trade:getSlotQty(i);
if (itemQty % 99 ~= 0) then
player:messageSpecial(NOKKHI_BAD_COUNT);
return;
end;
local stacks = itemQty / 99;
carnationsNeeded = carnationsNeeded + stacks;
giveToPlayer[#giveToPlayer+1] = {v[2], stacks};
validSlot = true;
break;
end
end
if (not validSlot) then
player:messageSpecial(NOKKHI_BAD_ITEM);
return;
end
end
end
-- check for correct number of carnations
if (carnationsNeeded == 0 or trade:getItemQty(948) ~= carnationsNeeded) then
player:messageSpecial(NOKKHI_BAD_COUNT);
return;
end
-- check for enough inventory space
if (player:getFreeSlotsCount() < carnationsNeeded) then
player:messageSpecial(ITEM_CANNOT_BE_OBTAINED, giveToPlayer[1][1]);
return;
end
-- make the trade
player:messageSpecial(NOKKHI_GOOD_TRADE);
for k, v in pairs(giveToPlayer) do
player:addItem(v[1], v[2]);
player:messageSpecial(ITEM_OBTAINED,v[1]);
end
player:tradeComplete();
end;
function onTrigger(player,npc)
player:startEvent(667,npc:getID());
end;
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
end
| gpl-3.0 |
dinodeck/ninety_nine_days_of_dev | 003_combat_numbers/code/ActorXPSummary.lua | 1 | 3668 |
ActorXPSummary = {}
ActorXPSummary.__index = ActorXPSummary
function ActorXPSummary:Create(actor, layout, layoutId)
local this =
{
mActor = actor,
mLayout = layout,
mId = layoutId,
mXPBar = ProgressBar:Create
{
value = actor.mXP,
maximum = actor.mNextLevelXP,
background = Texture.Find("xpbackground.png"),
foreground = Texture.Find("xpforeground.png"),
},
mPopUpList = {},
mPopUpDisplayTime = 1, -- secs
}
this.mAvatar = Sprite.Create()
this.mAvatar:SetTexture(this.mActor.mPortraitTexture)
local avatarScale = 0.8
this.mAvatar:SetScale(avatarScale, avatarScale)
this.mActorWidth = actor.mPortraitTexture:GetWidth() * avatarScale
setmetatable(this, self)
return this
end
function ActorXPSummary:Update(dt)
local popup = self.mPopUpList[1]
if popup == nil then
--print("popup at 1 is nil")
return
end
if popup:IsFinished() then
print("Removed")
table.remove(self.mPopUpList, 1)
return
end
popup:Update(dt)
if popup.mDisplayTime > self.mPopUpDisplayTime
and #self.mPopUpList > 1 then
popup:TurnOff()
end
end
function ActorXPSummary:Render(renderer)
local font = gGame.Font.default
renderer:ScaleText(1.25, 1.25)
-- Potrait
local left = self.mLayout:Left(self.mId)
local midY = self.mLayout:MidY(self.mId)
local avatarLeft = left + self.mActorWidth/2 + 6
self.mAvatar:SetPosition(avatarLeft , midY)
renderer:DrawSprite(self.mAvatar)
-- Name
local nameX = left + self.mActorWidth + 84
local nameY = self.mLayout:Top(self.mId) - 12
renderer:AlignText("right", "top")
renderer:DrawText2d(nameX, nameY, self.mActor.mName)
-- Level
local strLevelLabel = "Level:"
local strLevelValue = string.format("%d", self.mActor.mLevel)
local levelY = nameY - 42
renderer:DrawText2d(nameX, levelY, strLevelLabel)
font:AlignText("left", "top")
font:DrawText2d(renderer, nameX + 12, levelY - 3, strLevelValue)
-- XP
renderer:AlignText("right", "top")
local strXPLabel = "EXP:"
local strXPValue = string.format("%d", self.mActor.mXP)
local right = self.mLayout:Right(self.mId) - 18
local rightLabel = right - 96
renderer:DrawText2d(rightLabel, nameY, strXPLabel)
font:AlignText("right", "top")
font:DrawText2d(renderer, right, nameY - 3, strXPValue)
local barX = right - self.mXPBar.mHalfWidth
self.mXPBar:SetPosition(barX, nameY - 24)
self.mXPBar:SetValue(self.mActor.mXP, self.mActor.mNextLevelXP)
self.mXPBar:Render(renderer)
local strNextLevelLabel = "Next Level:"
local strNextLevelValue = string.format("%d", self.mActor.mNextLevelXP)
renderer:DrawText2d(rightLabel, levelY, strNextLevelLabel)
font:DrawText2d(renderer, right, levelY - 3, strNextLevelValue)
local popup = self.mPopUpList[1]
if popup == nil then
return
end
popup:Render(renderer)
end
function ActorXPSummary:SetPosition(x, y)
self.mX = x
self.mY = y
end
function ActorXPSummary:AddPopUp(text, color)
local x = self.mLayout:MidX(self.mId)
local y = self.mLayout:MidY(self.mId)
local popup = XPPopUp:Create(text, x, y, color)
table.insert(self.mPopUpList, popup)
popup:TurnOn()
Apply(self.mPopUpList, print)
end
function ActorXPSummary:PopUpCount()
return #self.mPopUpList
end
function ActorXPSummary:CancelPopUp()
local popup = self.mPopUpList[1]
if popup == nil or popup:IsTurningOff() then
return
end
popup:TurnOff()
end | mit |
Ninjistix/darkstar | scripts/zones/Lower_Jeuno/npcs/Ruslan.lua | 5 | 1735 | -----------------------------------
-- Area: Lower Jeuno
-- NPC: Ruslan
-- Involved In Quest: Wondering Minstrel
-- !pos -19 -1 -58 245
-----------------------------------
package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Lower_Jeuno/TextIDs");
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/globals/titles");
-----------------------------------
function onTrade(player,npc,trade)
end;
function onTrigger(player,npc)
wonderingstatus = player:getQuestStatus(WINDURST,WONDERING_MINSTREL);
if (wonderingstatus == QUEST_ACCEPTED) then
prog = player:getVar("QuestWonderingMin_var")
if (prog == 0) then -- WONDERING_MINSTREL + Rosewood Lumber: During Quest / Progression
player:startEvent(10009,0,718);
player:setVar("QuestWonderingMin_var",1);
elseif (prog == 1) then -- WONDERING_MINSTREL + Rosewood Lumber: Quest Objective Reminder
player:startEvent(10010,0,718);
end
elseif (wonderingstatus == QUEST_COMPLETED) then
rand = math.random(3);
if (rand == 1) then
player:startEvent(10011); -- WONDERING_MINSTREL: After Quest
else
player:startEvent(10008); -- Standard Conversation
end
else
player:startEvent(10008); -- Standard Conversation
end
end;
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
Ninjistix/darkstar | scripts/zones/Lufaise_Meadows/npcs/Teldo-Moroldo_WW.lua | 3 | 2977 | -----------------------------------
-- Area: Lufaise Meadows
-- NPC: Teldo-Moroldo, W.W.
-- Outpost Conquest Guards
-- !pos -542.418 -7.124 -53.521 24
-----------------------------------
package.loaded["scripts/zones/Lufaise_Meadows/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/conquest");
require("scripts/zones/Lufaise_Meadows/TextIDs");
local guardnation = NATION_WINDURST; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno
local guardtype = 3; -- 1: city, 2: foreign, 3: outpost, 4: border
local region = TAVNAZIANARCH;
local csid = 0x7ff7;
function onTrade(player,npc,trade)
tradeConquestGuard(player,npc,trade,guardnation,guardtype);
end;
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;
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("OPTION: %u",option);
end;
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 |
backburn/Probably | external/AceGUI-3.0/widgets/AceGUIContainer-ScrollFrame.lua | 37 | 6549 | --[[-----------------------------------------------------------------------------
ScrollFrame Container
Plain container that scrolls its content and doesn't grow in height.
-------------------------------------------------------------------------------]]
local Type, Version = "ScrollFrame", 23
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local pairs, assert, type = pairs, assert, type
local min, max, floor, abs = math.min, math.max, math.floor, math.abs
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
--[[-----------------------------------------------------------------------------
Support functions
-------------------------------------------------------------------------------]]
local function FixScrollOnUpdate(frame)
frame:SetScript("OnUpdate", nil)
frame.obj:FixScroll()
end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function ScrollFrame_OnMouseWheel(frame, value)
frame.obj:MoveScroll(value)
end
local function ScrollFrame_OnSizeChanged(frame)
frame:SetScript("OnUpdate", FixScrollOnUpdate)
end
local function ScrollBar_OnScrollValueChanged(frame, value)
frame.obj:SetScroll(value)
end
--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
["OnAcquire"] = function(self)
self:SetScroll(0)
self.scrollframe:SetScript("OnUpdate", FixScrollOnUpdate)
end,
["OnRelease"] = function(self)
self.status = nil
for k in pairs(self.localstatus) do
self.localstatus[k] = nil
end
self.scrollframe:SetPoint("BOTTOMRIGHT")
self.scrollbar:Hide()
self.scrollBarShown = nil
self.content.height, self.content.width = nil, nil
end,
["SetScroll"] = function(self, value)
local status = self.status or self.localstatus
local viewheight = self.scrollframe:GetHeight()
local height = self.content:GetHeight()
local offset
if viewheight > height then
offset = 0
else
offset = floor((height - viewheight) / 1000.0 * value)
end
self.content:ClearAllPoints()
self.content:SetPoint("TOPLEFT", 0, offset)
self.content:SetPoint("TOPRIGHT", 0, offset)
status.offset = offset
status.scrollvalue = value
end,
["MoveScroll"] = function(self, value)
local status = self.status or self.localstatus
local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight()
if self.scrollBarShown then
local diff = height - viewheight
local delta = 1
if value < 0 then
delta = -1
end
self.scrollbar:SetValue(min(max(status.scrollvalue + delta*(1000/(diff/45)),0), 1000))
end
end,
["FixScroll"] = function(self)
if self.updateLock then return end
self.updateLock = true
local status = self.status or self.localstatus
local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight()
local offset = status.offset or 0
local curvalue = self.scrollbar:GetValue()
-- Give us a margin of error of 2 pixels to stop some conditions that i would blame on floating point inaccuracys
-- No-one is going to miss 2 pixels at the bottom of the frame, anyhow!
if viewheight < height + 2 then
if self.scrollBarShown then
self.scrollBarShown = nil
self.scrollbar:Hide()
self.scrollbar:SetValue(0)
self.scrollframe:SetPoint("BOTTOMRIGHT")
self:DoLayout()
end
else
if not self.scrollBarShown then
self.scrollBarShown = true
self.scrollbar:Show()
self.scrollframe:SetPoint("BOTTOMRIGHT", -20, 0)
self:DoLayout()
end
local value = (offset / (viewheight - height) * 1000)
if value > 1000 then value = 1000 end
self.scrollbar:SetValue(value)
self:SetScroll(value)
if value < 1000 then
self.content:ClearAllPoints()
self.content:SetPoint("TOPLEFT", 0, offset)
self.content:SetPoint("TOPRIGHT", 0, offset)
status.offset = offset
end
end
self.updateLock = nil
end,
["LayoutFinished"] = function(self, width, height)
self.content:SetHeight(height or 0 + 20)
self.scrollframe:SetScript("OnUpdate", FixScrollOnUpdate)
end,
["SetStatusTable"] = function(self, status)
assert(type(status) == "table")
self.status = status
if not status.scrollvalue then
status.scrollvalue = 0
end
end,
["OnWidthSet"] = function(self, width)
local content = self.content
content.width = width
end,
["OnHeightSet"] = function(self, height)
local content = self.content
content.height = height
end
}
--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
local frame = CreateFrame("Frame", nil, UIParent)
local num = AceGUI:GetNextWidgetNum(Type)
local scrollframe = CreateFrame("ScrollFrame", nil, frame)
scrollframe:SetPoint("TOPLEFT")
scrollframe:SetPoint("BOTTOMRIGHT")
scrollframe:EnableMouseWheel(true)
scrollframe:SetScript("OnMouseWheel", ScrollFrame_OnMouseWheel)
scrollframe:SetScript("OnSizeChanged", ScrollFrame_OnSizeChanged)
local scrollbar = CreateFrame("Slider", ("AceConfigDialogScrollFrame%dScrollBar"):format(num), scrollframe, "UIPanelScrollBarTemplate")
scrollbar:SetPoint("TOPLEFT", scrollframe, "TOPRIGHT", 4, -16)
scrollbar:SetPoint("BOTTOMLEFT", scrollframe, "BOTTOMRIGHT", 4, 16)
scrollbar:SetMinMaxValues(0, 1000)
scrollbar:SetValueStep(1)
scrollbar:SetValue(0)
scrollbar:SetWidth(16)
scrollbar:Hide()
-- set the script as the last step, so it doesn't fire yet
scrollbar:SetScript("OnValueChanged", ScrollBar_OnScrollValueChanged)
local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND")
scrollbg:SetAllPoints(scrollbar)
scrollbg:SetTexture(0, 0, 0, 0.4)
--Container Support
local content = CreateFrame("Frame", nil, scrollframe)
content:SetPoint("TOPLEFT")
content:SetPoint("TOPRIGHT")
content:SetHeight(400)
scrollframe:SetScrollChild(content)
local widget = {
localstatus = { scrollvalue = 0 },
scrollframe = scrollframe,
scrollbar = scrollbar,
content = content,
frame = frame,
type = Type
}
for method, func in pairs(methods) do
widget[method] = func
end
scrollframe.obj, scrollbar.obj = widget, widget
return AceGUI:RegisterAsContainer(widget)
end
AceGUI:RegisterWidgetType(Type, Constructor, Version)
| bsd-3-clause |
Ninjistix/darkstar | scripts/globals/items/mammut.lua | 7 | 1024 | -----------------------------------------
-- ID: 18503
-- Item: Mammut
-- Additional Effect: Ice Damage
-----------------------------------------
require("scripts/globals/status");
require("scripts/globals/magic");
require("scripts/globals/msg");
-----------------------------------
function onAdditionalEffect(player,target,damage)
local chance = 10;
if (math.random(0,99) >= chance) then
return 0,0,0;
else
local dmg = math.random(4,15);
local params = {};
params.bonusmab = 0;
params.includemab = false;
dmg = addBonusesAbility(player, ELE_ICE, target, dmg, params);
dmg = dmg * applyResistanceAddEffect(player,target,ELE_ICE,0);
dmg = adjustForTarget(target,dmg,ELE_ICE);
dmg = finalMagicNonSpellAdjustments(player,target,ELE_ICE,dmg);
local message = msgBasic.ADD_EFFECT_DMG;
if (dmg < 0) then
message = msgBasic.ADD_EFFECT_HEAL;
end
return SUBEFFECT_ICE_DAMAGE,message,dmg;
end
end; | gpl-3.0 |
premake/premake-4.x | tests/base/test_config_bug.lua | 12 | 3876 | T.config_bug_report = { }
local config_bug = T.config_bug_report
local vs10_helpers = premake.vstudio.vs10_helpers
local sln, prjA,prjB,prjC,prjD
function config_bug.teardown()
sln = nil
prjA = nil
prjB = nil
prjC = nil
prjD = nil
end
function config_bug.setup()
end
local config_bug_updated = function ()
local setCommonLibraryConfig = function()
configuration "Debug or Release"
kind "StaticLib"
configuration "DebugDLL or ReleaseDLL"
kind "SharedLib"
end
sln = solution "Test"
configurations { "Debug", "Release", "DebugDLL", "ReleaseDLL" }
language "C++"
prjA = project "A"
files { "a.cpp" }
setCommonLibraryConfig()
prjB = project "B"
files { "b.cpp" }
setCommonLibraryConfig()
configuration "SharedLib"
links { "A" }
prjC = project "C"
files { "c.cpp" }
setCommonLibraryConfig()
configuration "SharedLib"
links { "A", "B" }
prjD = project "Executable"
kind "WindowedApp"
links { "A", "B", "C" }
end
local kindSetOnConfiguration_and_linkSetOnSharedLibProjB = function (config_kind)
sln = solution "DontCare"
configurations { "DebugDLL"}
configuration "DebugDLL"
kind(config_kind)
prjA = project "A"
prjB = project "B"
configuration { config_kind }
links { "A" }
end
local sharedLibKindSetOnProject_and_linkSetOnSharedLibProjB = function ()
sln = solution "DontCare"
configurations { "DebugDLL" }
project "A"
prjB = project "B"
configuration "DebugDLL"
kind "SharedLib"
configuration "SharedLib"
links { "A" }
defines {"defineSet"}
end
function kind_set_on_project_config_block()
sln = solution "DontCare"
configurations { "DebugDLL" }
local A = project "A"
configuration "DebugDLL"
kind "SharedLib"
defines {"defineSet"}
return A
end
function config_bug.bugUpdated_prjBLinksContainsA()
config_bug_updated()
premake.bake.buildconfigs()
local conf = premake.getconfig(prjB,"DebugDLL","Native")
test.isnotnil(conf.links.A)
end
function config_bug.kindSetOnProjectConfigBlock_projKindEqualsSharedLib()
local proj = kind_set_on_project_config_block()
premake.bake.buildconfigs()
local conf = premake.getconfig(proj,"DebugDLL","Native")
test.isequal("SharedLib",conf.kind)
end
function config_bug.defineSetOnProjectConfigBlock_projDefineSetIsNotNil()
local proj = kind_set_on_project_config_block()
premake.bake.buildconfigs()
local conf = premake.getconfig(proj,"DebugDLL","Native")
test.isnotnil(conf.defines.defineSet)
end
function config_bug.defineSetInBlockInsideProject ()
sharedLibKindSetOnProject_and_linkSetOnSharedLibProjB()
premake.bake.buildconfigs()
local conf = premake.getconfig(prjB,"DebugDLL","Native")
test.isnotnil(conf.defines.defineSet)
end
function config_bug.whenKindSetOnProject_PrjBLinksContainsA()
sharedLibKindSetOnProject_and_linkSetOnSharedLibProjB()
premake.bake.buildconfigs()
local conf = premake.getconfig(prjB,"DebugDLL","Native")
test.isnotnil(conf.links.A)
end
function config_bug.whenKindSetOnConfiguration_prjBLinksContainsA_StaticLib()
-- sharedLibKindSetOnConfiguration_and_linkSetOnSharedLibProjB()
kindSetOnConfiguration_and_linkSetOnSharedLibProjB("StaticLib")
premake.bake.buildconfigs()
local config = premake.getconfig(prjB,"DebugDLL","Native")
test.isnotnil(config.links.A)
end
function config_bug.whenKindSetOnConfiguration_prjBLinksContainsA()
-- sharedLibKindSetOnConfiguration_and_linkSetOnSharedLibProjB()
kindSetOnConfiguration_and_linkSetOnSharedLibProjB("SharedLib")
premake.bake.buildconfigs()
local config = premake.getconfig(prjB,"DebugDLL","Native")
test.isnotnil(config.links.A)
end
| bsd-3-clause |
Ninjistix/darkstar | scripts/zones/Port_Bastok/npcs/Gudav.lua | 5 | 1636 | -----------------------------------
-- Area: Port Bastok
-- NPC: Gudav
-- Starts Quests: A Foreman's Best Friend
-----------------------------------
package.loaded["scripts/zones/Port_Bastok/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/zones/Port_Bastok/TextIDs");
-----------------------------------
function onTrade(player,npc,trade)
if (trade:hasItemQty(13096,1) and trade:getItemCount() == 1) then
if (player:getQuestStatus(BASTOK,A_FOREMAN_S_BEST_FRIEND) == QUEST_ACCEPTED) then
player:tradeComplete();
player:startEvent(112);
end
end
end;
function onTrigger(player,npc)
if (player:getMainLvl() >= 7 and player:getQuestStatus(BASTOK,A_FOREMAN_S_BEST_FRIEND) == QUEST_AVAILABLE) then
player:startEvent(110);
else
player:startEvent(31);
end
end;
function onEventUpdate(player,csid,option)
-- printf("CSID2: %u",csid);
-- printf("RESULT2: %u",option);
end;
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
if (csid == 110) then
player:addQuest(BASTOK,A_FOREMAN_S_BEST_FRIEND);
elseif (csid == 112) then
if (player:hasKeyItem(MAP_OF_THE_GUSGEN_MINES) == false) then
player:addKeyItem(MAP_OF_THE_GUSGEN_MINES);
player:messageSpecial(KEYITEM_OBTAINED,MAP_OF_THE_GUSGEN_MINES);
end
player:addFame(BASTOK,60);
player:completeQuest(BASTOK,A_FOREMAN_S_BEST_FRIEND);
end
end; | gpl-3.0 |
backburn/Probably | interface/commands/core.lua | 1 | 3434 | -- ProbablyEngine Rotations - https://probablyengine.com/
-- Released under modified BSD, see attached LICENSE.
ProbablyEngine.command.help = {
}
ProbablyEngine.command.register_help = function(key, help)
ProbablyEngine.command.help[key] = help
end
ProbablyEngine.command.register_handler({'version', 'ver', 'v'}, function()
ProbablyEngine.command.print('|cff' .. ProbablyEngine.addonColor .. 'ProbablyEngine |r' .. ProbablyEngine.version)
end)
ProbablyEngine.command.register_help('version', pelg('help_version'))
ProbablyEngine.command.register_handler({'help', '?', 'wat'}, function()
ProbablyEngine.command.print('|cff' .. ProbablyEngine.addonColor .. 'ProbablyEngine |r' .. ProbablyEngine.version)
for command, help in pairs(ProbablyEngine.command.help) do
ProbablyEngine.command.print('|cff' .. ProbablyEngine.addonColor .. '/pe ' ..command .. '|r ' .. help)
end
end)
ProbablyEngine.command.register_help('help', pelg('help_help'))
ProbablyEngine.command.register_handler({'cycle', 'pew', 'run'}, function()
ProbablyEngine.cycle(true)
end)
ProbablyEngine.command.register_help('cycle', pelg('help_cycle'))
ProbablyEngine.command.register_handler({'toggle'}, function()
ProbablyEngine.buttons.toggle('MasterToggle')
end)
ProbablyEngine.command.register_handler({'enable'}, function()
ProbablyEngine.buttons.setActive('MasterToggle')
end)
ProbablyEngine.command.register_handler({'disable'}, function()
ProbablyEngine.buttons.setInactive('MasterToggle')
end)
ProbablyEngine.command.register_help('toggle', pelg('help_toggle'))
ProbablyEngine.command.register_handler({'cd', 'cooldown', 'cooldowns'}, function()
ProbablyEngine.buttons.toggle('cooldowns')
end)
ProbablyEngine.command.register_help('cd', pelg('cooldowns_tooltip'))
ProbablyEngine.command.register_handler({'kick', 'interrupts', 'interrupt', 'silence'}, function()
ProbablyEngine.buttons.toggle('interrupt')
end)
ProbablyEngine.command.register_help('kick', pelg('interrupt_tooltip'))
ProbablyEngine.command.register_handler({'aoe', 'multitarget'}, function()
ProbablyEngine.buttons.toggle('multitarget')
end)
ProbablyEngine.command.register_help('aoe', pelg('multitarget_tooltip'))
ProbablyEngine.command.register_handler({'ct', 'combattracker', 'ut', 'unittracker', 'tracker'}, function()
UnitTracker.toggle()
end)
ProbablyEngine.command.register_help('ct', pelg('help_ct'))
ProbablyEngine.command.register_handler({'al', 'log', 'actionlog'}, function()
PE_ActionLog:Show()
end)
ProbablyEngine.command.register_help('al', pelg('help_al'))
ProbablyEngine.command.register_handler({'lag', 'cycletime'}, function()
PE_CycleLag:Show()
end)
ProbablyEngine.command.register_handler({'turbo', 'godmode'}, function()
local state = ProbablyEngine.config.toggle('pe_turbo')
if state then
ProbablyEngine.print(pelg('turbo_enable'))
SetCVar('maxSpellStartRecoveryOffset', 1)
SetCVar('reducedLagTolerance', 10)
ProbablyEngine.cycleTime = 10
else
ProbablyEngine.print(pelg('turbo_disable'))
SetCVar('maxSpellStartRecoveryOffset', 1)
SetCVar('reducedLagTolerance', 100)
ProbablyEngine.cycleTime = 100
end
end)
ProbablyEngine.command.register_help('turbo', pelg('help_turbo'))
ProbablyEngine.command.register_handler({'bvt'}, function()
local state = ProbablyEngine.config.toggle('buttonVisualText')
ProbablyEngine.buttons.resetButtons()
ProbablyEngine.rotation.add_buttons()
end)
| bsd-3-clause |
SHIELDTM/shieldbot | libs/mimetype.lua | 3662 | 2922 | -- Thanks to https://github.com/catwell/lua-toolbox/blob/master/mime.types
do
local mimetype = {}
-- TODO: Add more?
local types = {
["text/html"] = "html",
["text/css"] = "css",
["text/xml"] = "xml",
["image/gif"] = "gif",
["image/jpeg"] = "jpg",
["application/x-javascript"] = "js",
["application/atom+xml"] = "atom",
["application/rss+xml"] = "rss",
["text/mathml"] = "mml",
["text/plain"] = "txt",
["text/vnd.sun.j2me.app-descriptor"] = "jad",
["text/vnd.wap.wml"] = "wml",
["text/x-component"] = "htc",
["image/png"] = "png",
["image/tiff"] = "tiff",
["image/vnd.wap.wbmp"] = "wbmp",
["image/x-icon"] = "ico",
["image/x-jng"] = "jng",
["image/x-ms-bmp"] = "bmp",
["image/svg+xml"] = "svg",
["image/webp"] = "webp",
["application/java-archive"] = "jar",
["application/mac-binhex40"] = "hqx",
["application/msword"] = "doc",
["application/pdf"] = "pdf",
["application/postscript"] = "ps",
["application/rtf"] = "rtf",
["application/vnd.ms-excel"] = "xls",
["application/vnd.ms-powerpoint"] = "ppt",
["application/vnd.wap.wmlc"] = "wmlc",
["application/vnd.google-earth.kml+xml"] = "kml",
["application/vnd.google-earth.kmz"] = "kmz",
["application/x-7z-compressed"] = "7z",
["application/x-cocoa"] = "cco",
["application/x-java-archive-diff"] = "jardiff",
["application/x-java-jnlp-file"] = "jnlp",
["application/x-makeself"] = "run",
["application/x-perl"] = "pl",
["application/x-pilot"] = "prc",
["application/x-rar-compressed"] = "rar",
["application/x-redhat-package-manager"] = "rpm",
["application/x-sea"] = "sea",
["application/x-shockwave-flash"] = "swf",
["application/x-stuffit"] = "sit",
["application/x-tcl"] = "tcl",
["application/x-x509-ca-cert"] = "crt",
["application/x-xpinstall"] = "xpi",
["application/xhtml+xml"] = "xhtml",
["application/zip"] = "zip",
["application/octet-stream"] = "bin",
["audio/midi"] = "mid",
["audio/mpeg"] = "mp3",
["audio/ogg"] = "ogg",
["audio/x-m4a"] = "m4a",
["audio/x-realaudio"] = "ra",
["video/3gpp"] = "3gpp",
["video/mp4"] = "mp4",
["video/mpeg"] = "mpeg",
["video/quicktime"] = "mov",
["video/webm"] = "webm",
["video/x-flv"] = "flv",
["video/x-m4v"] = "m4v",
["video/x-mng"] = "mng",
["video/x-ms-asf"] = "asf",
["video/x-ms-wmv"] = "wmv",
["video/x-msvideo"] = "avi"
}
-- Returns the common file extension from a content-type
function mimetype.get_mime_extension(content_type)
return types[content_type]
end
-- Returns the mimetype and subtype
function mimetype.get_content_type(extension)
for k,v in pairs(types) do
if v == extension then
return k
end
end
end
-- Returns the mimetype without the subtype
function mimetype.get_content_type_no_sub(extension)
for k,v in pairs(types) do
if v == extension then
-- Before /
return k:match('([%w-]+)/')
end
end
end
return mimetype
end | gpl-2.0 |
wounds1/zaza2 | libs/mimetype.lua | 3662 | 2922 | -- Thanks to https://github.com/catwell/lua-toolbox/blob/master/mime.types
do
local mimetype = {}
-- TODO: Add more?
local types = {
["text/html"] = "html",
["text/css"] = "css",
["text/xml"] = "xml",
["image/gif"] = "gif",
["image/jpeg"] = "jpg",
["application/x-javascript"] = "js",
["application/atom+xml"] = "atom",
["application/rss+xml"] = "rss",
["text/mathml"] = "mml",
["text/plain"] = "txt",
["text/vnd.sun.j2me.app-descriptor"] = "jad",
["text/vnd.wap.wml"] = "wml",
["text/x-component"] = "htc",
["image/png"] = "png",
["image/tiff"] = "tiff",
["image/vnd.wap.wbmp"] = "wbmp",
["image/x-icon"] = "ico",
["image/x-jng"] = "jng",
["image/x-ms-bmp"] = "bmp",
["image/svg+xml"] = "svg",
["image/webp"] = "webp",
["application/java-archive"] = "jar",
["application/mac-binhex40"] = "hqx",
["application/msword"] = "doc",
["application/pdf"] = "pdf",
["application/postscript"] = "ps",
["application/rtf"] = "rtf",
["application/vnd.ms-excel"] = "xls",
["application/vnd.ms-powerpoint"] = "ppt",
["application/vnd.wap.wmlc"] = "wmlc",
["application/vnd.google-earth.kml+xml"] = "kml",
["application/vnd.google-earth.kmz"] = "kmz",
["application/x-7z-compressed"] = "7z",
["application/x-cocoa"] = "cco",
["application/x-java-archive-diff"] = "jardiff",
["application/x-java-jnlp-file"] = "jnlp",
["application/x-makeself"] = "run",
["application/x-perl"] = "pl",
["application/x-pilot"] = "prc",
["application/x-rar-compressed"] = "rar",
["application/x-redhat-package-manager"] = "rpm",
["application/x-sea"] = "sea",
["application/x-shockwave-flash"] = "swf",
["application/x-stuffit"] = "sit",
["application/x-tcl"] = "tcl",
["application/x-x509-ca-cert"] = "crt",
["application/x-xpinstall"] = "xpi",
["application/xhtml+xml"] = "xhtml",
["application/zip"] = "zip",
["application/octet-stream"] = "bin",
["audio/midi"] = "mid",
["audio/mpeg"] = "mp3",
["audio/ogg"] = "ogg",
["audio/x-m4a"] = "m4a",
["audio/x-realaudio"] = "ra",
["video/3gpp"] = "3gpp",
["video/mp4"] = "mp4",
["video/mpeg"] = "mpeg",
["video/quicktime"] = "mov",
["video/webm"] = "webm",
["video/x-flv"] = "flv",
["video/x-m4v"] = "m4v",
["video/x-mng"] = "mng",
["video/x-ms-asf"] = "asf",
["video/x-ms-wmv"] = "wmv",
["video/x-msvideo"] = "avi"
}
-- Returns the common file extension from a content-type
function mimetype.get_mime_extension(content_type)
return types[content_type]
end
-- Returns the mimetype and subtype
function mimetype.get_content_type(extension)
for k,v in pairs(types) do
if v == extension then
return k
end
end
end
-- Returns the mimetype without the subtype
function mimetype.get_content_type_no_sub(extension)
for k,v in pairs(types) do
if v == extension then
-- Before /
return k:match('([%w-]+)/')
end
end
end
return mimetype
end | gpl-2.0 |
hfjgjfg/hhh | libs/mimetype.lua | 3662 | 2922 | -- Thanks to https://github.com/catwell/lua-toolbox/blob/master/mime.types
do
local mimetype = {}
-- TODO: Add more?
local types = {
["text/html"] = "html",
["text/css"] = "css",
["text/xml"] = "xml",
["image/gif"] = "gif",
["image/jpeg"] = "jpg",
["application/x-javascript"] = "js",
["application/atom+xml"] = "atom",
["application/rss+xml"] = "rss",
["text/mathml"] = "mml",
["text/plain"] = "txt",
["text/vnd.sun.j2me.app-descriptor"] = "jad",
["text/vnd.wap.wml"] = "wml",
["text/x-component"] = "htc",
["image/png"] = "png",
["image/tiff"] = "tiff",
["image/vnd.wap.wbmp"] = "wbmp",
["image/x-icon"] = "ico",
["image/x-jng"] = "jng",
["image/x-ms-bmp"] = "bmp",
["image/svg+xml"] = "svg",
["image/webp"] = "webp",
["application/java-archive"] = "jar",
["application/mac-binhex40"] = "hqx",
["application/msword"] = "doc",
["application/pdf"] = "pdf",
["application/postscript"] = "ps",
["application/rtf"] = "rtf",
["application/vnd.ms-excel"] = "xls",
["application/vnd.ms-powerpoint"] = "ppt",
["application/vnd.wap.wmlc"] = "wmlc",
["application/vnd.google-earth.kml+xml"] = "kml",
["application/vnd.google-earth.kmz"] = "kmz",
["application/x-7z-compressed"] = "7z",
["application/x-cocoa"] = "cco",
["application/x-java-archive-diff"] = "jardiff",
["application/x-java-jnlp-file"] = "jnlp",
["application/x-makeself"] = "run",
["application/x-perl"] = "pl",
["application/x-pilot"] = "prc",
["application/x-rar-compressed"] = "rar",
["application/x-redhat-package-manager"] = "rpm",
["application/x-sea"] = "sea",
["application/x-shockwave-flash"] = "swf",
["application/x-stuffit"] = "sit",
["application/x-tcl"] = "tcl",
["application/x-x509-ca-cert"] = "crt",
["application/x-xpinstall"] = "xpi",
["application/xhtml+xml"] = "xhtml",
["application/zip"] = "zip",
["application/octet-stream"] = "bin",
["audio/midi"] = "mid",
["audio/mpeg"] = "mp3",
["audio/ogg"] = "ogg",
["audio/x-m4a"] = "m4a",
["audio/x-realaudio"] = "ra",
["video/3gpp"] = "3gpp",
["video/mp4"] = "mp4",
["video/mpeg"] = "mpeg",
["video/quicktime"] = "mov",
["video/webm"] = "webm",
["video/x-flv"] = "flv",
["video/x-m4v"] = "m4v",
["video/x-mng"] = "mng",
["video/x-ms-asf"] = "asf",
["video/x-ms-wmv"] = "wmv",
["video/x-msvideo"] = "avi"
}
-- Returns the common file extension from a content-type
function mimetype.get_mime_extension(content_type)
return types[content_type]
end
-- Returns the mimetype and subtype
function mimetype.get_content_type(extension)
for k,v in pairs(types) do
if v == extension then
return k
end
end
end
-- Returns the mimetype without the subtype
function mimetype.get_content_type_no_sub(extension)
for k,v in pairs(types) do
if v == extension then
-- Before /
return k:match('([%w-]+)/')
end
end
end
return mimetype
end | gpl-2.0 |
spam999/teleanony | libs/mimetype.lua | 3662 | 2922 | -- Thanks to https://github.com/catwell/lua-toolbox/blob/master/mime.types
do
local mimetype = {}
-- TODO: Add more?
local types = {
["text/html"] = "html",
["text/css"] = "css",
["text/xml"] = "xml",
["image/gif"] = "gif",
["image/jpeg"] = "jpg",
["application/x-javascript"] = "js",
["application/atom+xml"] = "atom",
["application/rss+xml"] = "rss",
["text/mathml"] = "mml",
["text/plain"] = "txt",
["text/vnd.sun.j2me.app-descriptor"] = "jad",
["text/vnd.wap.wml"] = "wml",
["text/x-component"] = "htc",
["image/png"] = "png",
["image/tiff"] = "tiff",
["image/vnd.wap.wbmp"] = "wbmp",
["image/x-icon"] = "ico",
["image/x-jng"] = "jng",
["image/x-ms-bmp"] = "bmp",
["image/svg+xml"] = "svg",
["image/webp"] = "webp",
["application/java-archive"] = "jar",
["application/mac-binhex40"] = "hqx",
["application/msword"] = "doc",
["application/pdf"] = "pdf",
["application/postscript"] = "ps",
["application/rtf"] = "rtf",
["application/vnd.ms-excel"] = "xls",
["application/vnd.ms-powerpoint"] = "ppt",
["application/vnd.wap.wmlc"] = "wmlc",
["application/vnd.google-earth.kml+xml"] = "kml",
["application/vnd.google-earth.kmz"] = "kmz",
["application/x-7z-compressed"] = "7z",
["application/x-cocoa"] = "cco",
["application/x-java-archive-diff"] = "jardiff",
["application/x-java-jnlp-file"] = "jnlp",
["application/x-makeself"] = "run",
["application/x-perl"] = "pl",
["application/x-pilot"] = "prc",
["application/x-rar-compressed"] = "rar",
["application/x-redhat-package-manager"] = "rpm",
["application/x-sea"] = "sea",
["application/x-shockwave-flash"] = "swf",
["application/x-stuffit"] = "sit",
["application/x-tcl"] = "tcl",
["application/x-x509-ca-cert"] = "crt",
["application/x-xpinstall"] = "xpi",
["application/xhtml+xml"] = "xhtml",
["application/zip"] = "zip",
["application/octet-stream"] = "bin",
["audio/midi"] = "mid",
["audio/mpeg"] = "mp3",
["audio/ogg"] = "ogg",
["audio/x-m4a"] = "m4a",
["audio/x-realaudio"] = "ra",
["video/3gpp"] = "3gpp",
["video/mp4"] = "mp4",
["video/mpeg"] = "mpeg",
["video/quicktime"] = "mov",
["video/webm"] = "webm",
["video/x-flv"] = "flv",
["video/x-m4v"] = "m4v",
["video/x-mng"] = "mng",
["video/x-ms-asf"] = "asf",
["video/x-ms-wmv"] = "wmv",
["video/x-msvideo"] = "avi"
}
-- Returns the common file extension from a content-type
function mimetype.get_mime_extension(content_type)
return types[content_type]
end
-- Returns the mimetype and subtype
function mimetype.get_content_type(extension)
for k,v in pairs(types) do
if v == extension then
return k
end
end
end
-- Returns the mimetype without the subtype
function mimetype.get_content_type_no_sub(extension)
for k,v in pairs(types) do
if v == extension then
-- Before /
return k:match('([%w-]+)/')
end
end
end
return mimetype
end | gpl-2.0 |
mamad-majhol/TeleSecret | libs/mimetype.lua | 3662 | 2922 | -- Thanks to https://github.com/catwell/lua-toolbox/blob/master/mime.types
do
local mimetype = {}
-- TODO: Add more?
local types = {
["text/html"] = "html",
["text/css"] = "css",
["text/xml"] = "xml",
["image/gif"] = "gif",
["image/jpeg"] = "jpg",
["application/x-javascript"] = "js",
["application/atom+xml"] = "atom",
["application/rss+xml"] = "rss",
["text/mathml"] = "mml",
["text/plain"] = "txt",
["text/vnd.sun.j2me.app-descriptor"] = "jad",
["text/vnd.wap.wml"] = "wml",
["text/x-component"] = "htc",
["image/png"] = "png",
["image/tiff"] = "tiff",
["image/vnd.wap.wbmp"] = "wbmp",
["image/x-icon"] = "ico",
["image/x-jng"] = "jng",
["image/x-ms-bmp"] = "bmp",
["image/svg+xml"] = "svg",
["image/webp"] = "webp",
["application/java-archive"] = "jar",
["application/mac-binhex40"] = "hqx",
["application/msword"] = "doc",
["application/pdf"] = "pdf",
["application/postscript"] = "ps",
["application/rtf"] = "rtf",
["application/vnd.ms-excel"] = "xls",
["application/vnd.ms-powerpoint"] = "ppt",
["application/vnd.wap.wmlc"] = "wmlc",
["application/vnd.google-earth.kml+xml"] = "kml",
["application/vnd.google-earth.kmz"] = "kmz",
["application/x-7z-compressed"] = "7z",
["application/x-cocoa"] = "cco",
["application/x-java-archive-diff"] = "jardiff",
["application/x-java-jnlp-file"] = "jnlp",
["application/x-makeself"] = "run",
["application/x-perl"] = "pl",
["application/x-pilot"] = "prc",
["application/x-rar-compressed"] = "rar",
["application/x-redhat-package-manager"] = "rpm",
["application/x-sea"] = "sea",
["application/x-shockwave-flash"] = "swf",
["application/x-stuffit"] = "sit",
["application/x-tcl"] = "tcl",
["application/x-x509-ca-cert"] = "crt",
["application/x-xpinstall"] = "xpi",
["application/xhtml+xml"] = "xhtml",
["application/zip"] = "zip",
["application/octet-stream"] = "bin",
["audio/midi"] = "mid",
["audio/mpeg"] = "mp3",
["audio/ogg"] = "ogg",
["audio/x-m4a"] = "m4a",
["audio/x-realaudio"] = "ra",
["video/3gpp"] = "3gpp",
["video/mp4"] = "mp4",
["video/mpeg"] = "mpeg",
["video/quicktime"] = "mov",
["video/webm"] = "webm",
["video/x-flv"] = "flv",
["video/x-m4v"] = "m4v",
["video/x-mng"] = "mng",
["video/x-ms-asf"] = "asf",
["video/x-ms-wmv"] = "wmv",
["video/x-msvideo"] = "avi"
}
-- Returns the common file extension from a content-type
function mimetype.get_mime_extension(content_type)
return types[content_type]
end
-- Returns the mimetype and subtype
function mimetype.get_content_type(extension)
for k,v in pairs(types) do
if v == extension then
return k
end
end
end
-- Returns the mimetype without the subtype
function mimetype.get_content_type_no_sub(extension)
for k,v in pairs(types) do
if v == extension then
-- Before /
return k:match('([%w-]+)/')
end
end
end
return mimetype
end | gpl-2.0 |
Xamla/torch-ros | demo/publish_lena_image.lua | 1 | 1483 | --[[
Publish an uncompressed image via torch-ros.
This sample uses the torch image package as source for the Lena test image.
To show the result simply start rviz and click 'Add' and select 'By topic'.
In the treeview under topic 'lena_image' select 'Image'. A blinking Lena image
will be displayed. The image is inverted at each time step to create a
clearly visible change between consecutive frames.
]]
ros = require 'ros'
image = require 'image'
ros.init('lena_image_source')
nh = ros.NodeHandle()
spinner = ros.AsyncSpinner()
spinner:start()
-- convert into byte rgb and publish
local lena = image.lena()
lena = lena:mul(255):permute(2,3,1):byte()
publisher = nh:advertise("lena_image", 'sensor_msgs/Image', 10)
local msg = ros.Message('sensor_msgs/Image')
--[[
Message Definition of 'the sensor_msgs/Image'
(for details see: http://docs.ros.org/api/sensor_msgs/html/msg/Image.html)
std_msgs/Header header
uint32 height
uint32 width
string encoding
uint8 is_bigendian
uint32 step
uint8[] data
]]
msg.height = lena:size(1)
msg.width = lena:size(2)
msg.encoding = "rgb8"
msg.is_bigendian = false
msg.step = lena:stride(1)
msg.data = lena:reshape(msg.height * msg.width * 3)
print('press ctrl+c to exit')
while ros.ok() do
if publisher:getNumSubscribers() > 0 then
lena = -lena -- invert image to get some blinking effect
msg.data = lena:reshape(msg.height * msg.width * 3)
publisher:publish(msg)
end
sys.sleep(0.1)
ros.spinOnce()
end
ros.shutdown()
| bsd-3-clause |
arca1n/cocos2d-x_nextpeer_integration | samples/Lua/TestLua/Resources/luaScript/AssetsManagerTest/AssetsManagerTest.lua | 3 | 4480 | local targetPlatform = cc.Application:getInstance():getTargetPlatform()
local lineSpace = 40
local itemTagBasic = 1000
local menuItemNames =
{
"enter",
"reset",
"update",
}
local winSize = cc.Director:getInstance():getWinSize()
local function updateLayer()
local layer = cc.Layer:create()
local support = false
if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform)
or (cc.PLATFORM_OS_WINDOWS == targetPlatform) or (cc.PLATFORM_OS_ANDROID == targetPlatform)
or (cc.PLATFORM_OS_MAC == targetPlatform) then
support = true
end
if not support then
print("Platform is not supported!")
return layer
end
local isUpdateItemClicked = false
local assetsManager = nil
local pathToSave = ""
local menu = cc.Menu:create()
menu:setPosition(cc.p(0, 0))
cc.MenuItemFont:setFontName("Arial")
cc.MenuItemFont:setFontSize(24)
local progressLable = cc.LabelTTF:create("","Arial",30)
progressLable:setPosition(cc.p(140,50))
layer:addChild(progressLable)
pathToSave = createDownloadDir()
local function onError(errorCode)
if errorCode == cc.ASSETSMANAGER_NO_NEW_VERSION then
progressLable:setString("no new version")
elseif errorCode == cc.ASSETSMANAGER_NETWORK then
progressLable:setString("network error")
end
end
local function onProgress( percent )
local progress = string.format("downloading %d%%",percent)
progressLable:setString(progress)
end
local function onSuccess()
progressLable:setString("downloading ok")
end
local function getAssetsManager()
if nil == assetsManager then
assetsManager = cc.AssetsManager:new("https://raw.github.com/samuele3hu/AssetsManagerTest/master/package.zip",
"https://raw.github.com/samuele3hu/AssetsManagerTest/master/version",
pathToSave)
assetsManager:retain()
assetsManager:setDelegate(onError, cc.ASSETSMANAGER_PROTOCOL_ERROR )
assetsManager:setDelegate(onProgress, cc.ASSETSMANAGER_PROTOCOL_PROGRESS)
assetsManager:setDelegate(onSuccess, cc.ASSETSMANAGER_PROTOCOL_SUCCESS )
assetsManager:setConnectionTimeout(3)
end
return assetsManager
end
local function update(sender)
progressLable:setString("")
getAssetsManager():update()
end
local function reset(sender)
progressLable:setString("")
deleteDownloadDir(pathToSave)
getAssetsManager():deleteVersion()
createDownloadDir()
end
local function reloadModule( moduleName )
package.loaded[moduleName] = nil
return require(moduleName)
end
local function enter(sender)
if not isUpdateItemClicked then
addSearchPath(pathToSave,true)
end
assetsManagerModule = reloadModule("luaScript/AssetsManagerTest/AssetsManagerModule")
assetsManagerModule.newScene(AssetsManagerTestMain)
end
local callbackFuncs =
{
enter,
reset,
update,
}
local function menuCallback(tag, menuItem)
local scene = nil
local nIdx = menuItem:getZOrder() - itemTagBasic
local ExtensionsTestScene = CreateExtensionsTestScene(nIdx)
if nil ~= ExtensionsTestScene then
cc.Director:getInstance():replaceScene(ExtensionsTestScene)
end
end
for i = 1, table.getn(menuItemNames) do
local item = cc.MenuItemFont:create(menuItemNames[i])
item:registerScriptTapHandler(callbackFuncs[i])
item:setPosition(winSize.width / 2, winSize.height - i * lineSpace)
if not support then
item:setEnabled(false)
end
menu:addChild(item, itemTagBasic + i)
end
local function onNodeEvent(msgName)
if nil ~= assetsManager then
assetsManager:release()
assetsManager = nil
end
end
layer:registerScriptHandler(onNodeEvent)
layer:addChild(menu)
return layer
end
-------------------------------------
-- AssetsManager Test
-------------------------------------
function AssetsManagerTestMain()
local scene = cc.Scene:create()
scene:addChild(updateLayer())
scene:addChild(CreateBackMenuItem())
return scene
end
| mit |
Xagul/forgottenserver | data/movements/scripts/tiles.lua | 13 | 1866 | local increasing = {[416] = 417, [426] = 425, [446] = 447, [3216] = 3217, [3202] = 3215, [11062] = 11063}
local decreasing = {[417] = 416, [425] = 426, [447] = 446, [3217] = 3216, [3215] = 3202, [11063] = 11062}
function onStepIn(creature, item, position, fromPosition)
if not increasing[item.itemid] then
return true
end
local player = creature:getPlayer()
if player == nil or player:isInGhostMode() then
return true
end
item:transform(increasing[item.itemid])
if item.actionid >= 1000 then
if player:getLevel() < item.actionid - 1000 then
player:teleportTo(fromPosition, false)
position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
player:sendTextMessage(MESSAGE_INFO_DESCR, "The tile seems to be protected against unwanted intruders.")
end
return true
end
if Tile(position):hasFlag(TILESTATE_PROTECTIONZONE) then
local lookPosition = player:getPosition()
lookPosition:getNextPosition(player:getDirection())
local depotItem = Tile(lookPosition):getItemByType(ITEM_TYPE_DEPOT)
if depotItem ~= nil then
local depotItems = player:getDepotChest(getDepotId(depotItem:getUniqueId()), true):getItemHoldingCount()
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "Your depot contains " .. depotItems .. " item" .. (depotItems > 1 and "s." or "."))
return true
end
end
if item.actionid ~= 0 and player:getStorageValue(item.actionid) <= 0 then
player:teleportTo(fromPosition, false)
position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
player:sendTextMessage(MESSAGE_INFO_DESCR, "The tile seems to be protected against unwanted intruders.")
return true
end
return true
end
function onStepOut(creature, item, position, fromPosition)
if not decreasing[item.itemid] then
return true
end
if creature:isPlayer() and creature:isInGhostMode() then
return true
end
item:transform(decreasing[item.itemid])
return true
end
| gpl-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.