repo_name stringlengths 6 78 | path stringlengths 4 206 | copies stringclasses 281
values | size stringlengths 4 7 | content stringlengths 625 1.05M | license stringclasses 15
values |
|---|---|---|---|---|---|
nesstea/darkstar | scripts/zones/Southern_San_dOria/npcs/Amaura.lua | 13 | 3049 | -----------------------------------
-- Area: Southern San d'Oria
-- NPC: Amaura
-- Involved in Quest: The Medicine Woman, To Cure a Cough
-- @zone 230
-- @pos -85 -6 89
-----------------------------------
package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/titles");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/zones/Southern_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:hasKeyItem(AMAURAS_FORMULA) == true) then
if (trade:hasItemQty(920,1) == true and trade:hasItemQty(642,1) == true and trade:hasItemQty(846,1) == true and trade:getItemCount() == 3) then
player:startEvent(0x027D);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
medicineWoman = player:getQuestStatus(SANDORIA,THE_MEDICINE_WOMAN);
toCureaCough = player:getQuestStatus(SANDORIA,TO_CURE_A_COUGH);
if (medicineWoman == QUEST_ACCEPTED) then
amaurasFormulaKI = player:hasKeyItem(AMAURAS_FORMULA);
coldMedicine = player:hasKeyItem(COLD_MEDICINE);
if (amaurasFormulaKI == false and coldMedicine == false) then
player:startEvent(0x027C);
else
player:startEvent(0x0282);
end
elseif (player:getVar("DiaryPage") == 3 or toCureaCough == QUEST_ACCEPTED) then
if (player:hasKeyItem(THYME_MOSS) == false and player:hasKeyItem(COUGH_MEDICINE) == false) then
player:startEvent(0x0285); -- need thyme moss for cough med
elseif (player:hasKeyItem(THYME_MOSS) == true) then
player:startEvent(0x0286); -- receive cough med for Nenne
end
else
player:startEvent(0x0282);
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 == 0x027C and option == 0) then
player:addKeyItem(AMAURAS_FORMULA);
player:messageSpecial(KEYITEM_OBTAINED,AMAURAS_FORMULA);
elseif (csid == 0x027D) then
player:tradeComplete();
player:delKeyItem(AMAURAS_FORMULA);
player:addKeyItem(COLD_MEDICINE);
player:messageSpecial(KEYITEM_OBTAINED,COLD_MEDICINE);
elseif (csid == 0x0285) then
player:addQuest(SANDORIA,TO_CURE_A_COUGH);
elseif (csid == 0x0286) then
player:delKeyItem(THYME_MOSS);
player:addKeyItem(COUGH_MEDICINE);
player:messageSpecial(KEYITEM_OBTAINED,COUGH_MEDICINE);
end
end; | gpl-3.0 |
UnfortunateFruit/darkstar | scripts/zones/Selbina/npcs/Vobo.lua | 17 | 1505 | -----------------------------------
-- Area: Selbina
-- NPC: Vobo
-- Involved in Quest: Riding on the Clouds
-- @pos 37 -14 81 248
-----------------------------------
package.loaded["scripts/zones/Selbina/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Selbina/TextIDs");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if(player:getQuestStatus(JEUNO,RIDING_ON_THE_CLOUDS) == QUEST_ACCEPTED and player:getVar("ridingOnTheClouds_3") == 2) then
if(trade:hasItemQty(1127,1) and trade:getItemCount() == 1) then -- Trade Kindred seal
player:setVar("ridingOnTheClouds_3",0);
player:tradeComplete();
player:addKeyItem(SOMBER_STONE);
player:messageSpecial(KEYITEM_OBTAINED,SOMBER_STONE);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x02C6);
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 |
nesstea/darkstar | scripts/zones/The_Garden_of_RuHmet/npcs/_0zt.lua | 13 | 1351 | -----------------------------------
-- Area: The_Garden_of_RuHmet
-- NPC: Luminus convergence
-----------------------------------
package.loaded["scripts/zones/The_Garden_of_RuHmet/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/The_Garden_of_RuHmet/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getCurrentMission(COP) == WHEN_ANGELS_FALL and player:getVar("PromathiaStatus")==5) then
player:startEvent(0x00CC);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("onUpdate CSID: %u",csid);
--printf("onUpdate RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
--printf("onFinish CSID: %u",csid);
--printf("onFinish RESULT: %u",option);
if (csid==0x00CC) then
player:completeMission(COP,WHEN_ANGELS_FALL);
player:addMission(COP,DAWN);
player:setVar("PromathiaStatus",0);
end
end; | gpl-3.0 |
UnfortunateFruit/darkstar | scripts/zones/Cape_Teriggan/TextIDs.lua | 2 | 1454 | -- Variable TextID Description text
-- General Texts
ITEM_CANNOT_BE_OBTAINED = 6379; -- You cannot obtain the item <item> come back again after sorting your inventory.
FULL_INVENTORY_AFTER_TRADE = 6381; -- You cannot obtain the #. Try trading again after sorting your inventory.
ITEM_OBTAINED = 6382; -- Obtained: <item>.
GIL_OBTAINED = 6383; -- Obtained <number> gil.
KEYITEM_OBTAINED = 6385; -- Obtained key item: <keyitem>.
ITEMS_OBTAINED = 6391; -- You obtain
BEASTMEN_BANNER = 7117; -- There is a beastmen's banner.
FISHING_MESSAGE_OFFSET = 7537; -- You can't fish here.
HOMEPOINT_SET = 11226; -- Home point set!
-- Other dialog
NOTHING_OUT_OF_ORDINARY = 6396; -- There is nothing out of the ordinary here.
-- Conquest
CONQUEST = 7204; -- You've earned conquest points!
-- ZM4 Dialog
CANNOT_REMOVE_FRAG = 7647; -- It is an oddly shaped stone monument. A shining stone is embedded in it, but cannot be removed...
ALREADY_OBTAINED_FRAG = 7648; -- You have already obtained this monument's . Try searching for another.
FOUND_ALL_FRAGS = 7649; -- You have obtained all of the fragments. You must hurry to the ruins of the ancient shrine!
ZILART_MONUMENT = 7651; -- It is an ancient Zilart monument.
-- Other
NOTHING_HAPPENS = 119; -- Nothing happens...?Possible Special Code: 00?
-- conquest Base
CONQUEST_BASE = 7036; -- Tallying conquest results...
| gpl-3.0 |
malortie/gmod-addons | th_weapons/lua/autorun/server/hl1/grenade_util.lua | 1 | 6709 | -- Only enable this addon if HL:S is mounted.
if !IsHL1Mounted() then return end
local grenade_contact_damage = GetConVar( 'sk_hl1_plr_dmg_grenade' ) or CreateConVar( 'sk_hl1_plr_dmg_grenade', '100' )
-- Blast radius scale factor
local grenade_radius_factor = GetConVar( 'sk_hl1_grenade_radius_factor' ) or CreateConVar( 'sk_hl1_grenade_radius_factor', '2.5' )
local GrenadeContactModel = 'models/grenade.mdl'
local GrenadeTimedModel = 'models/w_grenade.mdl'
local GrenadeSatchelModel = 'models/w_satchel.mdl'
local GrenadeTNTModel = 'models/th/w_tnt/w_tnt.mdl'
local GrenadeContactClassName = 'ent_th_handgrenade'
local GrenadeTimedClassName = 'ent_th_handgrenade'
local GrenadeSatchelClassName = 'ent_th_satchel'
local GrenadeTNTClassName = 'ent_th_handgrenade'
local SatchelCode = { SATCHEL_DETONATE = 0, SATCHEL_RELEASE = 1 }
local CGrenade = {}
GrenadeUtils = CGrenade
debug.getregistry().CGrenade = CGrenade
function CGrenade.ShootContact( owner, vecStart, vecVelocity )
local grenade = ents.Create( GrenadeContactClassName )
grenade:Spawn()
grenade:Activate()
-- contact grenades arc lower
grenade:SetGravity( 0.5 ) -- lower gravity since grenade is aerodynamic and engine doesn't know it.
grenade:SetPos( vecStart )
grenade:SetVelocity( vecVelocity )
grenade:SetAngles( vecVelocity:Angle() )
grenade:SetOwner( owner )
--
-- New
grenade:SetModelScale( grenade:GetModelScale() * 0.5, 0 )
--
-- make monsters afaid of it while in the air
grenade.m_pfnThink = grenade.DangerSoundThink
grenade:NextThink( CurTime() )
-- Tumble in air
local angvel = grenade:GetLocalAngularVelocity()
angvel.p = RandomFloat( -100, -500 )
grenade:SetLocalAngularVelocity( angvel )
-- Explode on contact
grenade.m_pfnTouch = grenade.ExplodeTouch
grenade:SetBlastDamage( grenade_contact_damage:GetFloat() )
grenade:SetBlastRadius( grenade:GetBlastDamage() * grenade_radius_factor:GetFloat() )
return grenade
end
function CGrenade.ShootTimed( owner, vecStart, vecVelocity, time )
local grenade = ents.Create( GrenadeTimedClassName )
grenade:Spawn()
grenade:Activate()
grenade:SetPos( vecStart )
grenade:SetVelocity( vecVelocity )
grenade:SetAngles( vecVelocity:Angle() )
grenade:SetOwner( owner )
--grenade.m_pfnTouch = grenade.BounceTouch -- Bounce if touched
--[[
Take one second off of the desired detonation time and set the think to PreDetonate. PreDetonate
will insert a DANGER sound into the world sound list and delay detonation for one second so that
the grenade explodes after the exact amount of time specified in the call to ShootTimed().
--]]
grenade:SetDetonateTime( CurTime() + time )
grenade.m_pfnThink = grenade.TumbleThink
grenade:NextThink( CurTime() + 0.1 )
if time < 0.1 then
grenade:NextThink( CurTime() )
grenade:SetVelocity( vector_origin )
end
grenade:SetSequence( RandomInt( 3, 6 ) )
grenade:SetPlaybackRate( 1.0 )
-- Tumble through the air
-- pGrenade->pev->avelocity.x = -400;
--
-- NEW
--
grenade:SetGravity( 0.5 )
grenade:SetFriction( 0.8 )
grenade:SetModel( GrenadeTimedModel )
grenade:SetBlastDamage( 100 )
grenade:SetBlastRadius( grenade:GetBlastDamage() * grenade_radius_factor:GetFloat() )
-- New
grenade:SetModelScale( grenade:GetModelScale() * 0.95, 0 )
-- Set up solidity and movetype
grenade:SetMoveType( MOVETYPE_VPHYSICS )
grenade:SetSolid( SOLID_VPHYSICS )
grenade:PhysicsInit( SOLID_VPHYSICS )
grenade:PhysWake()
if util.IsValidPhysicsObject( grenade, 0 ) then
grenade:GetPhysicsObject():SetVelocityInstantaneous( vecVelocity )
end
--
return grenade
end
function CGrenade.ShootTimedTNT( owner, vecStart, vecVelocity, time )
local grenade = ents.Create( GrenadeTimedClassName )
grenade:Spawn()
grenade:Activate()
grenade:SetPos( vecStart )
grenade:SetVelocity( vecVelocity )
grenade:SetAngles( vecVelocity:Angle() )
grenade:SetOwner( owner )
--[[
Take one second off of the desired detonation time and set the think to PreDetonate. PreDetonate
will insert a DANGER sound into the world sound list and delay detonation for one second so that
the grenade explodes after the exact amount of time specified in the call to ShootTimed().
--]]
grenade:SetDetonateTime( CurTime() + time )
grenade.m_pfnThink = grenade.TumbleThink
grenade:NextThink( CurTime() + 0.1 )
if time < 0.1 then
grenade:NextThink( CurTime() )
grenade:SetVelocity( vector_origin )
end
grenade:SetSequence( RandomInt( 3, 6 ) )
grenade:SetPlaybackRate( 1.0 )
-- Tumble through the air
-- pGrenade->pev->avelocity.x = -400;
--
-- NEW
--
grenade:SetGravity( 0.5 )
grenade:SetFriction( 0.8 )
grenade:SetModel( GrenadeTNTModel )
grenade:SetBlastDamage( 100 )
grenade:SetBlastRadius( grenade:GetBlastDamage() * grenade_radius_factor:GetFloat() )
-- New
grenade:SetModelScale( grenade:GetModelScale() * 0.95, 0 )
-- Set up solidity and movetype
grenade:SetMoveType( MOVETYPE_VPHYSICS )
grenade:SetSolid( SOLID_VPHYSICS )
grenade:PhysicsInit( SOLID_VPHYSICS )
grenade:PhysWake()
if util.IsValidPhysicsObject( grenade, 0 ) then
grenade:GetPhysicsObject():SetVelocityInstantaneous( vecVelocity )
end
--
return grenade
end
function CGrenade.ShootSatchelCharge( owner, vecStart, vecVelocity )
local grenade = ents.Create( GrenadeSatchelClassName )
grenade:SetMoveType( MOVETYPE_FLYGRAVITY )
grenade:SetSolid( SOLID_BBOX )
grenade:SetModel( GrenadeSatchelModel )
grenade:SetCollisionBounds( vector_origin, vector_origin )
--grenade:SetBlastDamage( 200 )
grenade:SetPos( vecStart )
grenade:SetVelocity( vecVelocity )
grenade:SetAngles( angle_zero )
grenade:SetOwner( owner )
--
grenade:Spawn()
grenade:Activate()
grenade:SetBlastRadius( grenade:GetBlastDamage() * grenade_radius_factor:GetFloat() )
--
-- Detonate in "time" seconds
--pGrenade->SetThink( &CGrenade::SUB_DoNothing );
grenade.m_pfnUse = grenade.DetonateUse
grenade.m_pfnTouch = grenade.SlideTouch
grenade:SetKeyValue( 'spawnflags', SF_DETONATE )
grenade:SetFriction( 0.9 )
return grenade
end
function CGrenade.UseSatchelCharges( owner, code )
if !IsValid( owner ) then return end
for _, v in pairs( ents.FindByClass( 'th_grenade_satchel' ) ) do
if v:HasSpawnFlags( SF_DETONATE ) && v:GetOwner() == owner then
if code == SatchelCode.SATCHEL_DETONATE then
v:Use( owner, owner, USE_ON, 0 )
else -- SATCHEL_RELEASE
v:SetOwner( nil )
end
end
end
end
--[[
function SUB_UseTargets( self, activator, useType, value )
local kv = self:GetKeyValues()
if kv then
local target = kv[ 'target' ]
if target then
ents.FireTargets( target, activator, self, useType, value )
end
end
end
--]] | gpl-3.0 |
DaemonSnake/vlc | share/lua/playlist/lelombrik.lua | 108 | 1985 | --[[
French humor site: http://lelombrik.net
$Id$
Copyright © 2007 the VideoLAN team
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
--]]
-- Probe function.
function probe()
return vlc.access == "http"
and string.match( vlc.path, "lelombrik.net/videos" )
end
-- Parse function.
function parse()
while true do
line = vlc.readline()
if not line then
vlc.msg.err("Couldn't extract the video URL from lelombrik")
return { }
end
if string.match( line, "id=\"nom_fichier\">" ) then
title = string.gsub( line, ".*\"nom_fichier\">([^<]*).*", "%1" )
if title then
title = vlc.strings.from_charset( "ISO_8859-1", title )
end
elseif string.match( line, "'file'" ) then
_,_,path = string.find( line, "'file', *'([^']*)")
elseif string.match( line, "flashvars=" ) then
path = string.gsub( line, "flashvars=.*&file=([^&]*).*", "%1" )
arturl = string.gsub( line, "flashvars=.*&image=([^&]*).*", "%1" )
elseif string.match( line, "'image'" ) then
_,_,arturl = string.find( line, "'image', *'([^']*)")
end
if path and arturl and title then
return { { path = path; arturl = arturl; title = title } }
end
end
end
| gpl-2.0 |
milkmanjack/lama | data/command/test.lua | 1 | 1276 | --[[
lama is a MUD server made in Lua.
Copyright (C) 2013 Curtis Erickson
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
]]
--- Command for listing usable commands.
-- @author milkmanjack
local Command = require("obj.Command")
--- Test command.
-- @class table
-- @name Test
local Test = Command:clone()
Test.keyword = "test"
--- Tests stuff.
function Test:parse(player, mob, input)
local cmd, _ = string.getWord(input)
local a, _ = string.getWord(_)
local b, _ = string.getWord(_)
self:execute(player, mob, a, b)
end
function Test:execute(player, mob, a, b)
mob:sendMessage(matchKeywords(a, b) or "not matched", MessageMode.COMMAND)
end
return Test
| gpl-3.0 |
nesstea/darkstar | scripts/zones/Lower_Jeuno/npcs/Navisse.lua | 13 | 4725 | -----------------------------------
-- Area: Lower Jeuno
-- NPC: Navisse
-- Standard Info NPC
-----------------------------------
package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil;
require("scripts/zones/Lower_Jeuno/TextIDs");
require("scripts/globals/pathfind");
local path = {
-- -59.562683, 6.000051, -90.890404,
-58.791367, 6.000050, -91.663391,
-58.021465, 6.000049, -92.432144,
-58.729881, 6.000051, -91.577568,
-60.351879, 6.000053, -89.835815,
-61.099354, 6.000054, -89.034248,
-61.841427, 5.999946, -88.238564,
-62.769325, 5.999948, -87.244301,
-61.750378, 5.999948, -87.684868,
-60.796600, 5.999947, -88.208214,
-55.475166, 5.999943, -91.271210,
-56.590668, 5.999943, -91.245201,
-57.651192, 6.000052, -91.002350,
-64.134392, 6.000052, -89.460915,
-63.261021, 6.000051, -90.107605,
-62.330879, 6.000051, -90.679604,
-61.395359, 6.000050, -91.235107,
-56.591644, 6.000047, -94.066406,
-57.208908, 6.000048, -93.245895,
-57.934330, 6.000049, -92.435081,
-59.788624, 6.000052, -90.439583,
-61.832211, 5.999946, -88.248795,
-62.574249, 5.999948, -87.453148,
-61.832058, 5.999946, -88.248627,
-61.089920, 6.000054, -89.044273,
-60.348049, 6.000053, -89.840111,
-59.043877, 6.000051, -91.238251,
-58.301846, 6.000050, -92.033958,
-57.467026, 6.000048, -92.929070,
-56.536987, 6.000047, -93.926826,
-57.528469, 6.000047, -93.482582,
-58.476944, 6.000048, -92.949654,
-59.416409, 6.000049, -92.400879,
-64.235306, 6.000051, -89.563835,
-64.000816, 6.000054, -88.482338,
-63.516331, 5.999947, -87.539917,
-62.444843, 5.999948, -87.352570,
-61.468765, 5.999947, -87.831436,
-60.520329, 5.999947, -88.364532,
-55.100037, 5.999943, -91.488144,
-56.063160, 5.999944, -90.932312,
-62.719467, 5.999948, -87.093468,
-62.064899, 5.999947, -87.960884,
-61.338562, 5.999946, -88.770836,
-59.579746, 6.000052, -90.663826,
-58.177391, 6.000050, -92.167343,
-57.435341, 6.000048, -92.963005,
-56.734436, 6.000047, -93.714989,
-57.492855, 6.000049, -92.901787,
-58.251190, 6.000050, -92.088486,
-59.364170, 6.000051, -90.894829,
-61.039413, 6.000054, -89.098907,
-61.784184, 5.999946, -88.300293,
-62.804745, 5.999948, -87.206451,
-60.463631, 6.000053, -89.715942,
-59.721657, 6.000052, -90.511711,
-58.974190, 6.000051, -91.313248,
-58.232239, 6.000050, -92.109024,
-56.840717, 6.000047, -93.600716,
-57.914623, 6.000048, -93.276276,
-58.855755, 6.000048, -92.730408,
-64.140175, 6.000051, -89.619812,
-63.025597, 6.000052, -89.751106,
-61.954758, 6.000052, -89.984474,
-60.887684, 6.000052, -90.234573,
-55.190853, 5.999943, -91.590721,
-55.368877, 6.000050, -92.667923,
-55.841885, 6.000048, -93.664970,
-56.916370, 6.000048, -93.400879,
-57.705578, 6.000049, -92.652748,
-58.456089, 6.000050, -91.865067,
-60.405739, 6.000053, -89.778008,
-61.147854, 6.000054, -88.982376,
-61.889904, 5.999946, -88.186691,
-62.637497, 5.999948, -87.385239,
-63.643429, 6.000055, -87.880524,
-64.248825, 6.000053, -88.784004,
-63.455921, 6.000052, -89.526733,
-62.418514, 6.000052, -89.852493,
-61.363335, 6.000052, -90.117607,
-55.142048, 5.999943, -91.602325,
-55.358624, 6.000050, -92.679016,
-55.842934, 6.000048, -93.675148,
-56.919590, 6.000048, -93.408241,
-57.710354, 6.000049, -92.649918,
-58.459896, 6.000050, -91.861336,
-60.409424, 6.000053, -89.774185,
-61.151508, 6.000054, -88.978500,
-62.848709, 5.999948, -87.159264,
-61.829231, 5.999948, -87.629791,
-60.951675, 5.999947, -88.117493,
-55.395309, 5.999943, -91.317513,
-56.522537, 5.999943, -91.263893,
-57.586517, 6.000052, -91.018196,
-64.081299, 6.000052, -89.473526,
-63.209583, 6.000051, -90.135269,
-62.270042, 6.000050, -90.714821,
-61.334797, 6.000050, -91.270729,
-56.586208, 6.000047, -94.069595,
-64.130554, 6.000051, -89.625450,
-56.496498, 6.000047, -94.122322,
-57.173595, 6.000048, -93.271568,
-57.904095, 6.000049, -92.465279,
-59.571453, 6.000052, -90.672951,
};
function onSpawn(npc)
npc:initNpcAi();
npc:setPos(pathfind.first(path));
onPath(npc);
end;
function onPath(npc)
pathfind.patrol(npc, path);
end;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x0099);
npc:wait(-1);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option,npc)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
npc:wait(0);
end;
| gpl-3.0 |
nesstea/darkstar | scripts/globals/abilities/pets/thunderspark.lua | 28 | 1520 | ---------------------------------------------------
-- Thunderspark M=whatever
---------------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/summon");
require("scripts/globals/magic");
require("scripts/globals/monstertpmoves");
---------------------------------------------------
function onAbilityCheck(player, target, ability)
return 0,0;
end;
function onPetAbility(target, pet, skill)
local numhits = 1;
local accmod = 1;
local dmgmod = 2;
local dmgmodsubsequent = 1; -- ??
local totaldamage = 0;
local damage = AvatarPhysicalMove(pet,target,skill,numhits,accmod,dmgmod,dmgmodsubsequent,TP_NO_EFFECT,1,2,3);
--get resist multiplier (1x if no resist)
local resist = applyPlayerResistance(pet,-1,target,pet:getStat(MOD_INT)-target:getStat(MOD_INT),ELEMENTAL_MAGIC_SKILL, ELE_THUNDER);
--get the resisted damage
damage.dmg = damage.dmg*resist;
--add on bonuses (staff/day/weather/jas/mab/etc all go in this function)
damage.dmg = mobAddBonuses(pet,spell,target,damage.dmg,1);
local tp = skill:getTP();
if tp < 1000 then
tp = 1000;
end
damage.dmg = damage.dmg * tp / 1000;
totaldamage = AvatarFinalAdjustments(damage.dmg,pet,skill,target,MOBSKILL_PHYSICAL,MOBPARAM_BLUNT,numhits);
target:addStatusEffect(EFFECT_PARALYSIS, 15, 0, 60);
target:delHP(totaldamage);
target:updateEnmityFromDamage(pet,totaldamage);
return totaldamage;
end | gpl-3.0 |
nesstea/darkstar | scripts/zones/Bastok_Markets/npcs/Ardea.lua | 13 | 2029 | -----------------------------------
-- Area: Bastok Markets
-- NPC: Ardea
-- @zone 235
-- @pos -198 -6 -69
-- Involved in quests: Chasing Quotas, Rock Racketeer
-- Standard Info NPC
-----------------------------------
package.loaded["scripts/zones/Bastok_Markets/TextIDs"] = nil;
require("scripts/zones/Bastok_Markets/TextIDs");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local RockRacketeer = player:getQuestStatus(WINDURST,ROCK_RACKETTER);
local Quotas_Status = player:getVar("ChasingQuotas_Progress");
-- Rock Racketeer
if (RockRacketeer == QUEST_ACCEPTED and player:hasKeyItem(SHARP_GRAY_STONE)) then
player:startEvent(0x0105);
elseif (Quotas_Status == 3) then
player:startEvent(264); -- Someone was just asking about that earring.
elseif (Quotas_Status == 4) then
player:startEvent(265); -- They'll be happy if you return it.
-- Standard dialog
else
player:startEvent(0x104);
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);
-- Rock Racketeer
if (csid == 0x0105 and option ~= 1) then
player:delKeyItem(SHARP_GRAY_STONE);
player:addGil(GIL_RATE*10);
player:setVar("rockracketeer_sold",1);
elseif (csid == 0x0105 and option ~= 2) then
player:setVar("rockracketeer_sold",2);
elseif (csid == 264) then
player:setVar("ChasingQuotas_Progress",4);
end
end;
| gpl-3.0 |
akdor1154/awesome | lib/awful/widget/layoutbox.lua | 1 | 2224 | ---------------------------------------------------------------------------
--- Layoutbox widget.
--
-- @author Julien Danjou <julien@danjou.info>
-- @copyright 2009 Julien Danjou
-- @release @AWESOME_VERSION@
-- @classmod awful.widget.layoutbox
---------------------------------------------------------------------------
local setmetatable = setmetatable
local capi = { screen = screen }
local layout = require("awful.layout")
local tooltip = require("awful.tooltip")
local tag = require("awful.tag")
local beautiful = require("beautiful")
local imagebox = require("wibox.widget.imagebox")
local function get_screen(s)
return s and capi.screen[s]
end
local layoutbox = { mt = {} }
local boxes = nil
local function update(w, screen)
screen = get_screen(screen)
local name = layout.getname(layout.get(screen))
w._layoutbox_tooltip:set_text(name or "[no name]")
w:set_image(name and beautiful["layout_" .. name])
end
local function update_from_tag(t)
local screen = get_screen(tag.getscreen(t))
local w = boxes[screen]
if w then
update(w, screen)
end
end
--- Create a layoutbox widget. It draws a picture with the current layout
-- symbol of the current tag.
-- @param screen The screen number that the layout will be represented for.
-- @return An imagebox widget configured as a layoutbox.
function layoutbox.new(screen)
screen = get_screen(screen or 1)
-- Do we already have the update callbacks registered?
if boxes == nil then
boxes = setmetatable({}, { __mode = "v" })
tag.attached_connect_signal(nil, "property::selected", update_from_tag)
tag.attached_connect_signal(nil, "property::layout", update_from_tag)
layoutbox.boxes = boxes
end
-- Do we already have a layoutbox for this screen?
local w = boxes[screen]
if not w then
w = imagebox()
w._layoutbox_tooltip = tooltip({ objects = {w}, delay_show = 1 })
update(w, screen)
boxes[screen] = w
end
return w
end
function layoutbox.mt:__call(...)
return layoutbox.new(...)
end
return setmetatable(layoutbox, layoutbox.mt)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
| gpl-2.0 |
UnfortunateFruit/darkstar | scripts/zones/Misareaux_Coast/npcs/Spatial_Displacement.lua | 19 | 1721 | -----------------------------------
-- Area: Misareaux Coast
-- NPC: Spacial Displacement
-- Entrance to Riverne Site #A01 and #B01
-----------------------------------
package.loaded["scripts/zones/Misareaux_Coast/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/missions");
require("scripts/zones/Misareaux_Coast/TextIDs");
-----------------------------------
-- onTrade
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger
-----------------------------------
function onTrigger(player,npc)
if(player:hasCompletedMission(COP,SHELTERING_DOUBT))then
player:startEvent(0x0227); -- Access to Sites A & B
elseif(player:getCurrentMission(COP) == ANCIENT_VOWS and player:getVar("PromathiaStatus") == 1)then
player:startEvent(0x0008);
else
player:startEvent(0x0226); -- Access to Site A Only
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 == 0x0008)then
player:setVar("PromathiaStatus",2);
player:setPos(732.55,-32.5,-506.544,90,30); -- Go to Riverne #A01 {R}
elseif((csid == 0x0227 or csid == 0x0226) and option == 1) then
player:setPos(732.55,-32.5,-506.544,90,30); -- Go to Riverne #A01 {R}
elseif(csid == 0x0227 and option == 2) then
player:setPos(729.749,-20.319,407.153,90,29); -- Go to Riverne #B01 {R}
end;
end; | gpl-3.0 |
nesstea/darkstar | scripts/globals/weaponskills/full_swing.lua | 11 | 1251 | -----------------------------------
-- Full Swing
-- Staff weapon skill
-- Skill Level: 200
-- Delivers a single-hit attack. Damage varies with TP.
-- Will stack with Sneak Attack.
-- Aligned with the Flame Gorget & Thunder Gorget.
-- Aligned with the Flame Belt & Thunder Belt.
-- Element: None
-- Modifiers: STR:50%
-- 100%TP 200%TP 300%TP
-- 1.00 3.00 5.00
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
-----------------------------------
function onUseWeaponSkill(player, target, wsID, tp, primary)
local params = {};
params.numHits = 1;
params.ftp100 = 1; params.ftp200 = 3; params.ftp300 = 5;
params.str_wsc = 0.5; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0;
params.canCrit = false;
params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0;
params.atkmulti = 1;
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, primary);
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
UnfortunateFruit/darkstar | scripts/zones/Dynamis-Xarcabard/mobs/Prince_Seere.lua | 19 | 1250 | -----------------------------------
-- Area: Dynamis Xarcabard
-- NPC: Prince Seere
-----------------------------------
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)
local Animate_Trigger = GetServerVariable("[DynaXarcabard]Boss_Trigger");
if(mob:isInBattlefieldList() == false) then
mob:addInBattlefieldList();
Animate_Trigger = Animate_Trigger + 8;
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
killer:messageSpecial(PRISON_OF_SOULS_HAS_SET_FREE);
end
end; | gpl-3.0 |
UnfortunateFruit/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/Wahnid.lua | 19 | 1179 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Wahnid
-- Type: Guild Merchant: Fishing Guild
-- @pos -31.720 -6.000 -94.919 50
-----------------------------------
package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/shop");
require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if(player:sendGuild(60426,1,18,6)) then
player:showText(npc,WAHNID_SHOP_DIALOG);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
nesstea/darkstar | scripts/zones/Lower_Delkfutts_Tower/mobs/Disaster_Idol.lua | 8 | 1179 | -----------------------------------
-- Area: Lower_Delkfutts_tower
-- Mob: Disaster_Idol
-----------------------------------
require("scripts/globals/missions");
-----------------------------------
-- onMobEngaged Action
-----------------------------------
function onMobEngaged(mob,target)
local DayofWeek = VanadielDayElement();
mob:setSpellList(118 + DayofWeek);
mob:setLocalVar("Element", DayofWeek+1);
end;
-----------------------------------
-- onMobFight Action
-----------------------------------
function onMobFight(mob,target)
-- TODO: Has level mimic of person who spawned it. Minimum level 65. HP should scale accordingly.
local DayofWeek = VanadielDayElement();
local Element = mob:getLocalVar("Element");
if (DayofWeek + 1 ~= Element) then
mob:setSpellList(118 + DayofWeek);
mob:setLocalVar("Element", DayofWeek+1);
end
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, killer, ally)
if (ally:getCurrentMission(COP) == THREE_PATHS and ally:getVar("COP_Tenzen_s_Path") == 6) then
ally:setVar("COP_Tenzen_s_Path",7);
end
end; | gpl-3.0 |
nesstea/darkstar | scripts/zones/Dynamis-Beaucedine/mobs/Goblin_Statue.lua | 7 | 1815 | -----------------------------------
-- Area: Dynamis Beaucedine
-- MOB: Goblin Statue
-- Map Position: http://images1.wikia.nocookie.net/__cb20090312005233/ffxi/images/thumb/b/b6/Bea.jpg/375px-Bea.jpg
-----------------------------------
package.loaded["scripts/zones/Dynamis-Beaucedine/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/dynamis");
require("scripts/zones/Dynamis-Beaucedine/TextIDs");
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
mob:setMobMod(MOBMOD_SUPERLINK, mob:getShortID());
end;
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
dynamis.spawnGroup(mob, beaucedineGoblinList, 2);
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob,killer,ally)
local mobID = mob:getID();
-- Time Bonus: 031 046
if (mobID == 17326860 and mob:isInBattlefieldList() == false) then
ally:addTimeToDynamis(15);
mob:addInBattlefieldList();
elseif (mobID == 17326875 and mob:isInBattlefieldList() == false) then
ally:addTimeToDynamis(15);
mob:addInBattlefieldList();
-- HP Bonus: 037 041 044 051 053
elseif (mobID == 17326866 or mobID == 17326870 or mobID == 17326873 or mobID == 17326880 or mobID == 17326882) then
ally:restoreHP(2000);
ally:messageBasic(024,(ally:getMaxHP()-ally:getHP()));
-- MP Bonus: 038 040 045 049 052 104
elseif (mobID == 17326867 or mobID == 17326869 or mobID == 17326874 or mobID == 17326878 or mobID == 17326881 or mobID == 17326933) then
ally:restoreMP(2000);
ally:messageBasic(025,(ally:getMaxMP()-ally:getMP()));
end
end;
| gpl-3.0 |
drazisil/npcblocker | localization.core.lua | 1 | 1187 | -- Copyright (C) 2014 Joseph W Becher
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
local npcBlocker, L = ...; -- Let's use the private table passed to every .lua file to store our locale
local function defaultFunc(L, key)
-- If this function was called, we have no localization for this key.
-- We could complain loudly to allow localizers to see the error of their ways,
-- but, for now, just return the key as its own localization. This allows you to—avoid writing the default localization out explicitly.
return key;
end
setmetatable(L, { __index = defaultFunc });
| gpl-3.0 |
nesstea/darkstar | scripts/globals/spells/bluemagic/geist_wall.lua | 26 | 1298 | -----------------------------------------
-- Spell: Geist Wall
-- Removes one beneficial magic effect from enemies within range
-- Spell cost: 35 MP
-- Monster Type: Lizards
-- Spell Type: Magical (Dark)
-- Blue Magic Points: 3
-- Stat Bonus: HP-5, MP+10
-- Level: 46
-- Casting Time: 3 seconds
-- Recast Time: 30 seconds
-- Magic Bursts on: Compression, Gravitation, Darkness
-- Combos: None
-----------------------------------------
require("scripts/globals/magic");
require("scripts/globals/status");
require("scripts/globals/bluemagic");
-----------------------------------------
-- OnMagicCastingCheck
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onSpellCast(caster,target,spell)
local dINT = (caster:getStat(MOD_INT) - target:getStat(MOD_INT));
local resist = applyResistance(caster,spell,target,dINT,BLUE_SKILL);
local effect = EFFECT_NONE;
if (resist > 0.0625) then
spell:setMsg(341);
effect = target:dispelStatusEffect();
if (effect == EFFECT_NONE) then
spell:setMsg(75);
end
else
spell:setMsg(85);
end
return effect;
end; | gpl-3.0 |
UnfortunateFruit/darkstar | scripts/zones/Mount_Zhayolm/Zone.lua | 29 | 1631 | -----------------------------------
--
-- Zone: Mount_Zhayolm (61)
--
-----------------------------------
package.loaded["scripts/zones/Mount_Zhayolm/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/Mount_Zhayolm/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then
player:setPos(-521.016,-6.191,60.013,126);
end
if (prevZone == 63) then
player:setPos(681.950,-24.00,369.936,40);
end
return cs;
end;
-----------------------------------
-- afterZoneIn
-----------------------------------
function afterZoneIn(player)
player:entityVisualPacket("1pb1");
player:entityVisualPacket("2pb1");
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
dpino/snabbswitch | lib/ljsyscall/syscall/linux/cgroup.lua | 24 | 1246 | -- Linux cgroup API
-- this is all file system operations packaged up to be easier to use
local require, error, assert, tonumber, tostring,
setmetatable, pairs, ipairs, unpack, rawget, rawset,
pcall, type, table, string =
require, error, assert, tonumber, tostring,
setmetatable, pairs, ipairs, unpack, rawget, rawset,
pcall, type, table, string
local function init(S)
local h = require "syscall.helpers"
local split = h.split
local abi, types, c = S.abi, S.types, S.c
local t, pt, s = types.t, types.pt, types.s
local util = S.util
local cgroup = {}
local function mkgroup(name)
-- append default location, should be tmpfs mount
if name:sub(1, 1) ~= "/" then return "/sys/fs/cgroup" .. name else return name end
end
function cgroup.mount(tab)
tab.source = tab.source or "cgroup"
tab.type = "cgroup"
tab.target = mkgroup(tab.target)
return S.mount(tab)
end
function cgroup.cgroups(ps)
ps = tostring(ps or "self")
local cgf = util.readfile("/proc/" .. ps .. "/cgroup")
local lines = split("\n", cgf)
local cgroups = {}
for i = 1, #lines - 1 do
local parts = split( ":", lines[i])
cgroups[parts[1]] = {name = parts[2], path = parts[3]}
end
return cgroups
end
return cgroup
end
return {init = init}
| apache-2.0 |
nesstea/darkstar | scripts/zones/Windurst_Waters_[S]/npcs/Upital-Lupital.lua | 13 | 1071 | -----------------------------------
-- Area: Windurst Waters (S)
-- NPC: Upital-Lupital
-- Type: Standard NPC
-- @zone: 94
-- @pos -57.809 -13.339 122.753
--
-- Auto-Script: Requires Verification (Verified by Brawndo)
-----------------------------------
package.loaded["scripts/zones/Windurst_Waters_[S]/TextIDs"] = nil;
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x01b7);
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 |
nesstea/darkstar | scripts/zones/East_Ronfaure/npcs/Stone_Monument.lua | 13 | 1269 | -----------------------------------
-- Area: East Ronfaure
-- NPC: Stone Monument
-- Involved in quest "An Explorer's Footsteps"
-- @pos 77.277 -2.894 -517.376 101
-----------------------------------
package.loaded["scripts/zones/East_Ronfaure/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/East_Ronfaure/TextIDs");
-----------------------------------
-- onTrigger
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x0384);
end;
-----------------------------------
-- onTrade
-----------------------------------
function onTrade(player,npc,trade)
if (trade:getItemCount() == 1 and trade:hasItemQty(571,1)) then
player:tradeComplete();
player:addItem(570);
player:messageSpecial(ITEM_OBTAINED,570);
player:setVar("anExplorer-CurrentTablet",0x00002);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end; | gpl-3.0 |
UnfortunateFruit/darkstar | scripts/zones/The_Eldieme_Necropolis/npcs/_5fh.lua | 34 | 1106 | -----------------------------------
-- Area: The Eldieme Necropolis
-- NPC: Shiva's Gate
-- @pos 110 -34 100 195
-----------------------------------
package.loaded["scripts/zones/The_Eldieme_Necropolis/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/The_Eldieme_Necropolis/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (npc:getAnimation() == 9) then
player:messageSpecial(SOLID_STONE);
end
return 0;
end;
--
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end; | gpl-3.0 |
UnfortunateFruit/darkstar | scripts/globals/spells/bluemagic/infrasonics.lua | 4 | 1467 | -----------------------------------------
-- Spell: Infrasonics
-- Lowers the evasion of enemies within a fan-shaped area originating from the caster
-- Spell cost: 42 MP
-- Monster Type: Lizards
-- Spell Type: Magical (Ice)
-- Blue Magic Points: 4
-- Stat Bonus: INT+1
-- Level: 65
-- Casting Time: 5 seconds
-- Recast Time: 120 seconds
-- Magic Bursts on: Induration, Distortion, Darkness
-- Combos: None
-----------------------------------------
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 duration = 60;
local dINT = caster:getStat(MOD_MND) - target:getStat(MOD_MND);
local resist = applyResistance(caster,spell,target,dINT,BLUE_SKILL);
if(resist > 0.0625) then
-- resisted!
spell:setMsg(85);
return 0;
end
if(target:hasStatusEffect(EFFECT_EVASION_DOWN) == true) then
-- no effect
spell:setMsg(75);
else
target:addStatusEffect(EFFECT_EVASION_DOWN,20,0,duration);
spell:setMsg(236);
end
return EFFECT_EVASION_DOWN;
end;
| gpl-3.0 |
nesstea/darkstar | scripts/globals/items/homemade_steak.lua | 18 | 1100 | -----------------------------------------
-- ID: 5226
-- Item: homemade_steak
-- Food Effect: 30Min, All Races
-----------------------------------------
-- Strength 1
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,1800,5226);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_STR, 1);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_STR, 1);
end;
| gpl-3.0 |
UnfortunateFruit/darkstar | scripts/globals/items/serving_of_bavarois.lua | 35 | 1213 | -----------------------------------------
-- ID: 5729
-- Item: serving_of_bavarois
-- Food Effect: 3Hrs, All Races
-----------------------------------------
-- HP 20
-- Intelligence 3
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,10800,5729);
end;
-----------------------------------------
-- onEffectGain Action
-----------------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_HP, 20);
target:addMod(MOD_INT, 3);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_HP, 20);
target:delMod(MOD_INT, 3);
end;
| gpl-3.0 |
UnfortunateFruit/darkstar | scripts/zones/San_dOria-Jeuno_Airship/npcs/qm1.lua | 18 | 1501 | -----------------------------------
-- Area: San d'Oria-Jeuno Airship
-- NPC: ???
-- Involved In Quest: The Stars Of Ifrit
-- @zone 223
-- @pos 77 -9 -5 -13
-----------------------------------
package.loaded["scripts/zones/San_dOria-Jeuno_Airship/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/globals/keyitems");
require("scripts/globals/weather");
require("scripts/zones/San_dOria-Jeuno_Airship/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local TOTD = VanadielTOTD();
local TheStarsOfIfrit = player:getQuestStatus(BASTOK,THE_STARS_OF_IFRIT);
if (TOTD == TIME_NIGHT and IsMoonFull()) then
if(TheStarsOfIfrit == QUEST_ACCEPTED and player:hasKeyItem(CARRIER_PIGEON_LETTER) == false) then
player:addKeyItem(CARRIER_PIGEON_LETTER);
player:messageSpecial(KEYITEM_OBTAINED,CARRIER_PIGEON_LETTER);
end
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end; | gpl-3.0 |
UnfortunateFruit/darkstar | scripts/zones/Gusgen_Mines/TextIDs.lua | 5 | 1706 | -- Variable TextID Description text
-- General Texts
ITEM_CANNOT_BE_OBTAINED = 6379; -- You cannot obtain the item <item>. Come back after sorting your inventory.
ITEM_OBTAINED = 6382; -- Obtained: <item>.
GIL_OBTAINED = 6383; -- Obtained <number> gil.
KEYITEM_OBTAINED = 6385; -- Obtained key item: <keyitem>.
FISHING_MESSAGE_OFFSET = 7195; -- You can't fish here.
-- Mining
MINING_IS_POSSIBLE_HERE = 7341; -- Mining is possible here if you have
-- Treasure Coffer/Chest Dialog
CHEST_UNLOCKED = 7355; -- You unlock the chest!
CHEST_FAIL = 7356; -- Fails to open the chest.
CHEST_TRAP = 7357; -- The chest was trapped!
CHEST_WEAK = 7358; -- You cannot open the chest when you are in a weakened state.
CHEST_MIMIC = 7359; -- The chest was a mimic!
CHEST_MOOGLE = 7360; -- You cannot open the chest while participating in the moogle event.
CHEST_ILLUSION = 7361; -- The chest was but an illusion...
CHEST_LOCKED = 7362; -- The chest appears to be locked.
-- Dialog Texts
LETTERS_IS_WRITTEN_HERE = 7363; -- Something resembling letters is written here.
FOUND_LOCATION_SEAL = 7364; -- You have found the location of the seal. You placeon it.
IS_ON_THIS_SEAL = 7365; -- is on this seal.
NOTHING_OUT_OF_ORDINARY = 7382; -- There is nothing out of the ordinary here.
-- Other
LOCK_OTHER_DEVICE = 7321; -- This entrance's lock is connected to some other device.
-- conquest Base
CONQUEST_BASE = 7036; -- Tallying conquest results...
-- Strange Apparatus
DEVICE_NOT_WORKING = 7304; -- The device is not working.
SYS_OVERLOAD = 7313; -- arning! Sys...verload! Enterin...fety mode. ID eras...d
YOU_LOST_THE = 7318; -- You lost the #.
| gpl-3.0 |
brisberg/TameTallbirds | mod/scripts/lang/zh-TM.lua | 1 | 1150 | return {
-- Display name of the tame birds
TAMETALLBIRD_NAME = "高腳鳥",
TAMETALLBIRD_DESCRIBE = {
-- Birds are friendly when well fed
FULL = "鳥肚子飽, 忠誠友好",
-- Generic inspect string for the bird
GENERIC = "腳很高, 忠誠度也高",
-- Bird is hungry and needs food
HUNGRY = "該餵這傢伙了",
-- Bird is hungry and might attack the player
STARVING = "小心! 別被牠吃了",
-- Bird is asleep
SLEEPING = "異常的溫馴",
},
STAY_ACTION = {
-- Display name for Right-Click "Stay" action
NAME = "別動",
-- Spoken command to a pet to "Stay here"
ANNOUNCE = "在這等我!",
},
FOLLOW_ACTION = {
-- Display name for Right-Click "Follow" action
NAME = "追隨",
-- Spoken command to a pet to "Follow Me"
ANNOUNCE = "來吧大傢伙!",
},
RETREAT_ACTION = {
-- Display name for Right-Click "Retreat" action
NAME = "撤退",
-- Spoken command to a pet to "Retreat from combat"
ANNOUNCE = "回到這裡!",
},
}
| mit |
UnfortunateFruit/darkstar | scripts/globals/mobskills/Spirit_Tap.lua | 7 | 1405 | ---------------------------------------------------
-- Spirit Tap
-- Attempts to absorb one buff from a single target, or otherwise steals HP.
-- Type: Magical
-- Utsusemi/Blink absorb: Ignores Shadows
-- Range: Melee
-- Notes: Can be any (positive) buff, including food. Will drain about 100HP if it can't take any buffs
---------------------------------------------------
require("scripts/globals/settings");
require("scripts/globals/status");
require("scripts/globals/monstertpmoves");
---------------------------------------------------
function onMobSkillCheck(target,mob,skill)
if(mob:isMobType(MOBTYPE_NOTORIOUS)) then
return 1;
end
return 0;
end;
function onMobWeaponSkill(target, mob, skill)
-- try to drain buff
local effect = target:stealStatusEffect();
local dmg = 0;
if(effect ~= nil) then
-- add to myself
mob:addStatusEffect(effect:getType(), effect:getPower(), effect:getTickCount(), effect:getDuration());
-- add buff to myself
skill:setMsg(MSG_EFFECT_DRAINED);
return 1;
else
-- time to drain HP. 50-100
local power = math.random(0, 51) + 50;
dmg = MobFinalAdjustments(power,mob,skill,target,MOBSKILL_MAGICAL,MOBPARAM_DARK,MOBPARAM_IGNORE_SHADOWS);
target:delHP(dmg);
mob:addHP(dmg);
skill:setMsg(MSG_DRAIN_HP);
end
return dmg;
end;
| gpl-3.0 |
vonflynee/opencomputersserver | world/opencomputers/a3abb948-eba5-4c6b-9388-1bb1f150ed2b/lib/shell.lua | 15 | 5213 | local fs = require("filesystem")
local text = require("text")
local unicode = require("unicode")
local shell = {}
local aliases = {}
-- Cache loaded shells for command execution. This puts the requirement on
-- shells that they do not keep a global state, since they may be called
-- multiple times, but reduces memory usage a lot.
local shells = setmetatable({}, {__mode="v"})
local function getShell()
local shellPath = os.getenv("SHELL") or "/bin/sh"
local shellName, reason = shell.resolve(shellPath, "lua")
if not shellName then
return nil, "cannot resolve shell `" .. shellPath .. "': " .. reason
end
if shells[shellName] then
return shells[shellName]
end
local sh, reason = loadfile(shellName, "t", env)
if sh then
shells[shellName] = sh
end
return sh, reason
end
local function findFile(name, ext)
checkArg(1, name, "string")
local function findIn(dir)
if dir:sub(1, 1) ~= "/" then
dir = shell.resolve(dir)
end
dir = fs.concat(fs.concat(dir, name), "..")
local name = fs.name(name)
local list = fs.list(dir)
if list then
local files = {}
for file in list do
files[file] = true
end
if ext and unicode.sub(name, -(1 + unicode.len(ext))) == "." .. ext then
-- Name already contains extension, prioritize.
if files[name] then
return true, fs.concat(dir, name)
end
elseif files[name] then
-- Check exact name.
return true, fs.concat(dir, name)
elseif ext then
-- Check name with automatially added extension.
local name = name .. "." .. ext
if files[name] then
return true, fs.concat(dir, name)
end
end
end
return false
end
if unicode.sub(name, 1, 1) == "/" then
local found, where = findIn("/")
if found then return where end
elseif unicode.sub(name, 1, 2) == "./" then
local found, where = findIn(shell.getWorkingDirectory())
if found then return where end
else
for path in string.gmatch(shell.getPath(), "[^:]+") do
local found, where = findIn(path)
if found then return where end
end
end
return false
end
-------------------------------------------------------------------------------
function shell.getAlias(alias)
return aliases[alias]
end
function shell.setAlias(alias, value)
checkArg(1, alias, "string")
checkArg(2, value, "string", "nil")
aliases[alias] = value
end
function shell.aliases()
return pairs(aliases)
end
function shell.resolveAlias(command, args)
checkArg(1, command, "string")
checkArg(2, args, "table", "nil")
args = args or {}
local program, lastProgram = command, nil
while true do
local tokens = text.tokenize(shell.getAlias(program) or program)
program = tokens[1]
if program == lastProgram then
break
end
lastProgram = program
for i = #tokens, 2, -1 do
table.insert(args, 1, tokens[i])
end
end
return program, args
end
function shell.getWorkingDirectory()
return os.getenv("PWD")
end
function shell.setWorkingDirectory(dir)
checkArg(1, dir, "string")
dir = fs.canonical(dir) .. "/"
if dir == "//" then dir = "/" end
if fs.isDirectory(dir) then
os.setenv("PWD", dir)
return true
else
return nil, "not a directory"
end
end
function shell.getPath()
return os.getenv("PATH")
end
function shell.setPath(value)
os.setenv("PATH", value)
end
function shell.resolve(path, ext)
if ext then
checkArg(2, ext, "string")
local where = findFile(path, ext)
if where then
return where
else
return nil, "file not found"
end
else
if unicode.sub(path, 1, 1) == "/" then
return fs.canonical(path)
else
return fs.concat(shell.getWorkingDirectory(), path)
end
end
end
function shell.execute(command, env, ...)
local sh, reason = getShell()
if not sh then
return false, reason
end
local result = table.pack(pcall(sh, env, command, ...))
if not result[1] and type(result[2]) == "table" and result[2].reason == "terminated" then
if result[2].code then
return true
else
return false, "terminated"
end
end
return table.unpack(result, 1, result.n)
end
function shell.parse(...)
local params = table.pack(...)
local args = {}
local options = {}
local doneWithOptions = false
for i = 1, params.n do
local param = params[i]
if not doneWithOptions and type(param) == "string" then
if param == "--" then
doneWithOptions = true -- stop processing options at `--`
elseif unicode.sub(param, 1, 2) == "--" then
if param:match("%-%-(.-)=") ~= nil then
options[param:match("%-%-(.-)=")] = param:match("=(.*)")
else
options[unicode.sub(param, 3)] = true
end
elseif unicode.sub(param, 1, 1) == "-" and param ~= "-" then
for j = 2, unicode.len(param) do
options[unicode.sub(param, j, j)] = true
end
else
table.insert(args, param)
end
else
table.insert(args, param)
end
end
return args, options
end
-------------------------------------------------------------------------------
return shell
| mit |
nesstea/darkstar | scripts/zones/Metalworks/npcs/Fariel.lua | 13 | 2130 | -----------------------------------
-- Area: Metalworks
-- NPC: Fariel
-- Type: Standard Info NPC
-----------------------------------
package.loaded["scripts/zones/Metalworks/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Metalworks/TextIDs");
require("scripts/globals/pathfind");
local path = {
53.551208, -14.000000, -7.162227,
54.111534, -14.000000, -6.227105,
54.075279, -14.000000, -5.139729,
53.565350, -14.000000, 6.000605,
52.636345, -14.000000, 6.521872,
51.561535, -14.000000, 6.710593,
50.436523, -14.000000, 6.835652,
41.754219, -14.000000, 7.686310,
41.409531, -14.000000, 6.635177,
41.351002, -14.000000, 5.549131,
41.341057, -14.000000, 4.461191,
41.338020, -14.000000, -9.138797,
42.356136, -14.000000, -9.449953,
43.442558, -14.000000, -9.409095,
44.524868, -14.000000, -9.298069,
53.718494, -14.000000, -8.260445,
54.082706, -14.000000, -7.257769,
54.110283, -14.000000, -6.170790,
54.073116, -14.000000, -5.083439,
53.556625, -14.000000, 6.192736,
52.545383, -14.000000, 6.570893,
51.441212, -14.000000, 6.730487,
50.430820, -14.000000, 6.836911,
41.680725, -14.000000, 7.693455,
41.396103, -14.000000, 6.599321,
41.349224, -14.000000, 5.512603,
41.340771, -14.000000, 4.424644
};
function onSpawn(npc)
npc:initNpcAi();
npc:setPos(pathfind.first(path));
onPath(npc);
end;
function onPath(npc)
pathfind.patrol(npc, path);
end;
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x02C2);
npc:wait(-1);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option,npc)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
npc:wait(0);
end;
| gpl-3.0 |
UnfortunateFruit/darkstar | scripts/zones/Davoi/npcs/!.lua | 19 | 2440 | -----------------------------------
-- Area: Davoi
-- NPC: !
-- Involved in Mission: The Davoi Report
-- @pos 164 0.1 -21 149
-----------------------------------
package.loaded["scripts/zones/Davoi/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/missions");
require("scripts/globals/keyitems");
require("scripts/zones/Davoi/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local CurrentMission = player:getCurrentMission(SANDORIA)
if(CurrentMission == THE_DAVOI_REPORT and player:getVar("MissionStatus") == 1) then
player:setVar("MissionStatus",2);
player:addKeyItem(LOST_DOCUMENT);
player:messageSpecial(KEYITEM_OBTAINED,LOST_DOCUMENT);
elseif(CurrentMission == INFILTRATE_DAVOI and player:getVar("MissionStatus") >= 6 and player:getVar("MissionStatus") <= 9) then
local X = npc:getXPos();
local Z = npc:getZPos();
if(X >= 292 and X <= 296 and Z >= -30 and Z <= -26 and player:hasKeyItem(EAST_BLOCK_CODE) == false) then
player:setVar("MissionStatus",player:getVar("MissionStatus") + 1);
player:addKeyItem(EAST_BLOCK_CODE);
player:messageSpecial(KEYITEM_OBTAINED,EAST_BLOCK_CODE);
elseif(X >= 333 and X <= 337 and Z >= -138 and Z <= -134 and player:hasKeyItem(SOUTH_BLOCK_CODE) == false) then
player:setVar("MissionStatus",player:getVar("MissionStatus") + 1);
player:addKeyItem(SOUTH_BLOCK_CODE);
player:messageSpecial(KEYITEM_OBTAINED,SOUTH_BLOCK_CODE);
elseif(X >= 161 and X <= 165 and Z >= -20 and Z <= -16 and player:hasKeyItem(NORTH_BLOCK_CODE) == false) then
player:setVar("MissionStatus",player:getVar("MissionStatus") + 1);
player:addKeyItem(NORTH_BLOCK_CODE);
player:messageSpecial(KEYITEM_OBTAINED,NORTH_BLOCK_CODE);
else
player:messageSpecial(YOU_SEE_NOTHING);
end
else
player:messageSpecial(YOU_SEE_NOTHING);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end; | gpl-3.0 |
nesstea/darkstar | scripts/globals/items/dish_of_hydra_kofte.lua | 18 | 1873 | -----------------------------------------
-- ID: 5602
-- Item: dish_of_hydra_kofte
-- Food Effect: 180Min, All Races
-----------------------------------------
-- Strength 7
-- Intelligence -3
-- Attack % 20
-- Attack Cap 150
-- Defense % 25
-- Defense Cap 70
-- Ranged ATT % 20
-- Ranged ATT Cap 150
-- Poison Resist 5
-----------------------------------------
require("scripts/globals/status");
-----------------------------------------
-- OnItemCheck
-----------------------------------------
function onItemCheck(target)
local result = 0;
if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then
result = 246;
end
return result;
end;
-----------------------------------------
-- OnItemUse
-----------------------------------------
function onItemUse(target)
target:addStatusEffect(EFFECT_FOOD,0,0,10800,5602);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_STR, 7);
target:addMod(MOD_INT, -3);
target:addMod(MOD_FOOD_ATTP, 20);
target:addMod(MOD_FOOD_ATT_CAP, 150);
target:addMod(MOD_FOOD_DEFP, 25);
target:addMod(MOD_FOOD_DEF_CAP, 70);
target:addMod(MOD_FOOD_RATTP, 20);
target:addMod(MOD_FOOD_RATT_CAP, 150);
target:addMod(MOD_POISONRES, 5);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_STR, 7);
target:delMod(MOD_INT, -3);
target:delMod(MOD_FOOD_ATTP, 20);
target:delMod(MOD_FOOD_ATT_CAP, 150);
target:delMod(MOD_FOOD_DEFP, 25);
target:delMod(MOD_FOOD_DEF_CAP, 70);
target:delMod(MOD_FOOD_RATTP, 20);
target:delMod(MOD_FOOD_RATT_CAP, 150);
target:delMod(MOD_POISONRES, 5);
end;
| gpl-3.0 |
nesstea/darkstar | scripts/zones/Sea_Serpent_Grotto/npcs/Hurr_the_Betrayer.lua | 13 | 3621 | -----------------------------------
-- Area: Sea Serpent Grotto
-- NPC: Hurr the Betrayer
-- Type: Involved in the "Sahagin Key Quest"
-- @zone: 176
-- @pos 305.882 26.768 234.279
--
-----------------------------------
package.loaded["scripts/zones/Sea_Serpent_Grotto/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/Sea_Serpent_Grotto/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:getVar("SahaginKeyItems") == 1) then --If player was told to use 3 Mythril Beastcoins
if (trade:hasItemQty(749,3) and trade:hasItemQty(1135,1)) then
player:startEvent(0x006b);
end
elseif (player:getVar("SahaginKeyItems") == 2) then --If player was told to use a Gold Beastcoin
if (trade:hasItemQty(748,1) and trade:hasItemQty(1135,1) and trade:getItemCount() == 2) then
player:startEvent(0x006b);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:getVar("SahaginKeyProgress") == 2 and player:hasItem(1197) == false) then --If player has never before finished the quest
player:startEvent(0x0069);
player:setVar("SahaginKeyItems",1);
elseif (player:getVar("SahaginKeyProgress") == 3 and player:getVar("SahaginKeyItems") == 0 and player:hasItem(1197) == false) then
rand = math.random(2); --Setup random variable to determine which item will be required.
if (rand == 1) then
player:startEvent(0x0069); --Requires 3 Mythril Beastcoins and a Norg Shell
player:setVar("SahaginKeyItems",1);
elseif (rand == 2) then
player:startEvent(0x006a); --Requires Gold Beastcoin and a Norg Shell
player:setVar("SahaginKeyItems",2);
end
elseif (player:getVar("SahaginKeyProgress") == 3 and player:getVar("SahaginKeyItems") == 1) then
player:startEvent(0x0069); --If player was told to use 3 Mythril Beastcoins
elseif (player:getVar("SahaginKeyProgress") == 3 and player:getVar("SahaginKeyItems") == 2) then
player:startEvent(0x006a); --If player was told to use a Gold Beastcoin
elseif (player:getVar("SahaginKeyProgress") == 2 and player:hasItem(1197) == true) then
player:startEvent(0x0068); --Doesn't offer the key again if the player has one
else
player:startEvent(0x0068); --Doesn't offer the key if the player hasn't spoken to the first 2 NPCs
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 == 0x006b and player:getVar("SahaginKeyProgress") == 2) then
player:tradeComplete();
player:setVar("SahaginKeyProgress",3); --Mark the quest progress
player:setVar("SahaginKeyItems",0);
player:addItem(1197); -- Sahagin Key
player:messageSpecial(ITEM_OBTAINED, 1197);
elseif (csid == 0x006b and player:getVar("SahaginKeyProgress") == 3) then
player:tradeComplete();
player:setVar("SahaginKeyItems",0);
player:addItem(1197); -- Sahagin Key
player:messageSpecial(ITEM_OBTAINED, 1197);
end
end;
| gpl-3.0 |
nesstea/darkstar | scripts/zones/Windurst_Waters/npcs/Jourille.lua | 16 | 1510 | -----------------------------------
-- Area: Windurst Waters
-- NPC: Jourille
-- Only sells when Windurst controlls Ronfaure Region
-- Confirmed shop stock, August 2013
-----------------------------------
require("scripts/globals/shop");
require("scripts/globals/conquest");
package.loaded["scripts/zones/Windurst_Waters/TextIDs"] = nil;
require("scripts/zones/Windurst_Waters/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
RegionOwner = GetRegionOwner(RONFAURE);
if (RegionOwner ~= WINDURST) then
player:showText(npc,JOURILLE_CLOSED_DIALOG);
else
player:showText(npc,JOURILLE_OPEN_DIALOG);
stock = {
0x027F, 110, --Chestnut
0x1125, 29, --San d'Orian Carrot
0x0262, 55, --San d'Orian Flour
0x114F, 69, --San d'Orian Grape
}
showShop(player,WINDURST,stock);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
nesstea/darkstar | scripts/globals/bcnm.lua | 11 | 42652 | require("scripts/globals/status");
require("scripts/globals/keyitems");
require("scripts/globals/missions");
require("scripts/globals/quests");
-- NEW SYSTEM BCNM NOTES
-- The "core" functions TradeBCNM EventUpdateBCNM EventTriggerBCNM EventFinishBCNM all return TRUE if the action performed is covered by the function.
-- This means all the old code will still be executed if the new functions don't support it. This means that there is effectively 'backwards compatibility' with the old system.
-- array to map (for each zone) the item id of the valid trade item with the bcnmid in the database
-- e.g. zone, {itemid, bcnmid, itemid, bcnmid, itemid, bcnmid}
-- DO NOT INCLUDE MAAT FIGHTS
itemid_bcnmid_map = {6, {0, 0}, -- Bearclaw_Pinnacle
8, {0, 0}, -- Boneyard_Gully
10, {0, 0}, -- The_Shrouded_Maw
13, {0, 0}, -- Mine_Shaft_2716
17, {0, 0}, -- Spire of Holla
19, {0, 0}, -- Spire of Dem
21, {0, 0}, -- Spire of Mea
23, {0, 0}, -- Spire of Vahzl
29, {0, 0}, -- Riverne Site #B01
31, {0, 0}, -- Monarch Linn
32, {0, 0}, -- Sealion's Den
35, {0, 0}, -- The Garden of RuHmet
36, {0, 0}, -- Empyreal Paradox
139, {1177, 4, 1552, 10, 1553, 11, 1131, 12, 1175, 15, 1180, 17}, -- Horlais Peak
140, {1551, 34, 1552, 35, 1552, 36}, -- Ghelsba Outpost
144, {1166, 68, 1178, 81, 1553, 76, 1180, 82, 1130, 79, 1552, 73}, -- Waughroon Shrine
146, {1553, 107, 1551, 105, 1177, 100}, -- Balgas Dias
163, {1130, 129}, -- Sacrificial Chamber
168, {0, 0}, -- Chamber of Oracles
170, {0, 0}, -- Full Moon Fountain
180, {1550, 293}, -- LaLoff Amphitheater
181, {0, 0}, -- The Celestial Nexus
201, {1546, 418, 1174, 417}, -- Cloister of Gales
202, {1548, 450, 1172, 449}, -- Cloister of Storms
203, {1545, 482, 1171, 481}, -- Cloister of Frost
206, {0, 0}, -- Qu'Bia Arena
207, {1544, 545}, -- Cloister of Flames
209, {1547, 578, 1169, 577}, -- Cloister of Tremors
211, {1549, 609}}; -- Cloister of Tides
-- array to map (for each zone) the BCNM ID to the Event Parameter corresponding to this ID.
-- DO NOT INCLUDE MAAT FIGHTS (only included one for testing!)
-- bcnmid, paramid, bcnmid, paramid, etc
-- The BCNMID is found via the database.
-- The paramid is a bitmask which you need to find out. Being a bitmask, it will be one of:
-- 0, 1, 2, 3, 4, 5, ...
bcnmid_param_map = {6, {640, 0},
8, {672, 0, 673, 1},
10, {704, 0, 706, 2},
13, {736, 0},
17, {768, 0},
19, {800, 0},
21, {832, 0},
23, {864, 0},
29, {896, 0},
31, {960, 0, 961, 1},
32, {992, 0, 993, 1},
35, {1024, 0},
36, {1056, 0},
139, {0, 0, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 10, 10, 11, 11, 12, 12, 15, 15, 17, 17},
140, {32, 0, 33, 1, 34, 2, 35, 3, 36, 4},
144, {65, 1, 73, 9, 64, 0, 67, 3, 68, 4, 70, 6, 71, 7, 72, 8, 81, 17, 76, 12, 82, 18, 79, 15},
146, {99, 3, 96, 0, 101, 5, 102, 6, 103, 7, 107, 11, 105, 9},
163, {128, 0, 129, 1},
165, {160, 0, 161, 1},
168, {192, 0, 194, 2, 195, 3, 196, 4},
170, {224, 0, 225, 1},
179, {256, 0},
180, {293, 5, 288, 0, 289, 1, 290, 2, 291, 3, 292, 4},
181, {320, 0},
201, {416, 0, 417, 1, 418, 2, 420, 4},
202, {448, 0, 449, 1, 450, 2, 452, 4},
203, {480, 0, 481, 1, 482, 2, 484, 4},
206, {512, 0, 516, 4, 517, 5, 518, 6, 519, 7, 532, 20},
207, {544, 0, 545, 1, 547, 3},
209, {576, 0, 577, 1, 578, 2, 580, 4},
211, {608, 0, 609, 1, 611, 3}};
-- Call this onTrade for burning circles
function TradeBCNM(player, zone, trade, npc)
-- return false;
if (player:hasStatusEffect(EFFECT_BATTLEFIELD)) then -- cant start a new bc
player:messageBasic(94, 0, 0);
return false;
elseif (player:hasWornItem(trade:getItem())) then -- If already used orb or testimony
player:messageBasic(56, 0, 0); -- i need correct dialog
return false;
end
if (CheckMaatFights(player, zone, trade, npc)) then -- This function returns true for maat fights
return true;
end
-- the following is for orb battles, etc
local id = ItemToBCNMID(player, zone, trade);
if (id == -1) then -- no valid BCNMs with this item
-- todo: display message based on zone text offset
player:setVar("trade_bcnmid", 0);
player:setVar("trade_itemid", 0);
return false;
else -- a valid BCNM with this item, start it.
mask = GetBattleBitmask(id, zone, 1);
if (mask == -1) then -- Cannot resolve this BCNMID to an event number, edit bcnmid_param_map!
print("Item is for a valid BCNM but cannot find the event parameter to display to client.");
player:setVar("trade_bcnmid", 0);
player:setVar("trade_itemid", 0);
return false;
end
if (player:isBcnmsFull() == 1) then -- temp measure, this will precheck the instances
print("all bcnm instances are currently occupied.");
npc:messageBasic(246, 0, 0); -- this wont look right in other languages!
return true;
end
player:startEvent(0x7d00, 0, 0, 0, mask, 0, 0, 0, 0);
return true;
end
end;
function EventTriggerBCNM(player, npc)
player:setVar("trade_bcnmid", 0);
player:setVar("trade_itemid", 0);
if (player:hasStatusEffect(EFFECT_BATTLEFIELD)) then
if (player:isInBcnm() == 1) then
player:startEvent(0x7d03); -- Run Away or Stay menu
else -- You're not in the BCNM but you have the Battlefield effect. Think: non-trader in a party
status = player:getStatusEffect(EFFECT_BATTLEFIELD);
playerbcnmid = status:getPower();
playermask = GetBattleBitmask(playerbcnmid, player:getZoneID(), 1);
if (playermask~=-1) then
-- This gives players who did not trade to go in the option of entering the fight
player:startEvent(0x7d00, 0, 0, 0, playermask, 0, 0, 0, 0);
else
player:messageBasic(94, 0, 0);
end
end
return true;
else
if (checkNonTradeBCNM(player, npc)) then
return true;
end
end
return false;
end;
function EventUpdateBCNM(player, csid, option, entrance)
-- return false;
local id = player:getVar("trade_bcnmid"); -- this is 0 if the bcnm isnt handled by new functions
local skip = CutsceneSkip(player, npc);
print("UPDATE csid "..csid.." option "..option);
-- seen: option 2, 3, 0 in that order
if (csid == 0x7d03 and option == 2) then -- leaving a BCNM the player is currently in.
player:bcnmLeave(1);
return true;
end
if (option == 255 and csid == 0x7d00) then -- Clicked yes, try to register bcnmid
if (player:hasStatusEffect(EFFECT_BATTLEFIELD)) then
-- You're entering a bcnm but you already had the battlefield effect, so you want to go to the
-- instance that your battlefield effect represents.
player:setVar("bcnm_instanceid_tick", 0);
player:setVar("bcnm_instanceid", player:getBattlefieldID()); -- returns 255 if non-existent.
return true;
end
inst = player:bcnmRegister(id);
if (inst > 0) then
player:setVar("bcnm_instanceid", inst);
player:setVar("bcnm_instanceid_tick", 0);
player:updateEvent(0, 3, 0, 0, 1, 0);
if (entrance ~= nil and player:getBattlefield() ~= nil) then
player:getBattlefield():setEntrance(entrance);
end
-- player:tradeComplete();
else
-- no free battlefields at the moment!
print("no free instances");
player:setVar("bcnm_instanceid", 255);
player:setVar("bcnm_instanceid_tick", 0);
end
elseif (option == 0 and csid == 0x7d00) then -- Requesting an Instance
-- Increment the instance ticker.
-- The client will send a total of THREE EventUpdate packets for each one of the free instances.
-- If the first instance is free, it should respond to the first packet
-- If the second instance is free, it should respond to the second packet, etc
local instance = player:getVar("bcnm_instanceid_tick");
instance = instance + 1;
player:setVar("bcnm_instanceid_tick", instance);
if (instance == player:getVar("bcnm_instanceid")) then
-- respond to this packet
local mask = GetBattleBitmask(id, player:getZoneID(), 2);
local status = player:getStatusEffect(EFFECT_BATTLEFIELD);
local playerbcnmid = status:getPower();
if (mask < playerbcnmid) then
mask = GetBattleBitmask(playerbcnmid, player:getZoneID(), 2);
player:updateEvent(2, mask, 0, 1, 1, skip); -- Add mask number for the correct entering CS
player:bcnmEnter(id);
player:setVar("bcnm_instanceid_tick", 0);
-- print("mask is "..mask)
-- print("playerbcnmid is "..playerbcnmid);
elseif (mask >= playerbcnmid) then
mask = GetBattleBitmask(id, player:getZoneID(), 2);
player:updateEvent(2, mask, 0, 1, 1, skip); -- Add mask number for the correct entering CS
player:bcnmEnter(id);
player:setVar("bcnm_instanceid_tick", 0);
-- print("mask2 is "..mask)
-- print("playerbcnmid2 is "..playerbcnmid);
end
if (entrance ~= nil and player:getBattlefield() ~= nil) then
player:getBattlefield():setEntrance(entrance);
end
elseif (player:getVar("bcnm_instanceid") == 255) then -- none free
-- print("nfa");
-- player:updateEvent(2, 5, 0, 0, 1, 0); -- @cs 32000 0 0 0 0 0 0 0 2
-- param1
-- 2=generic enter cs
-- 3=spam increment instance requests
-- 4=cleared to enter but cant while ppl engaged
-- 5=dont meet req, access denied.
-- 6=room max cap
-- param2 alters the eventfinish option (offset)
-- param7/8 = does nothing??
end
-- @pos -517 159 -209
-- @pos -316 112 -103
-- player:updateEvent(msgid, bcnmFight, 0, record, numadventurers, skip); skip=1 to skip anim
-- msgid 1=wait a little longer, 2=enters
end
return true;
end;
function EventFinishBCNM(player, csid, option)
print("FINISH csid "..csid.." option "..option);
if (player:hasStatusEffect(EFFECT_BATTLEFIELD) == false) then -- Temp condition for normal bcnm (started with onTrigger)
return false;
else
local id = player:getVar("trade_bcnmid");
local item = player:getVar("trade_itemid");
if (id == 68 or id == 418 or id == 450 or id == 482 or id == 545 or id == 578 or id == 609 or id == 293) then
player:tradeComplete(); -- Removes the item
elseif ((item >= 1426 and item <= 1440) or item == 1130 or item == 1131 or item == 1175 or item == 1177 or item == 1180 or item == 1178 or item == 1551 or item == 1552 or item == 1553) then -- Orb and Testimony (one time item)
player:createWornItem(item);
end
return true;
end
end;
-- Returns TRUE if you're trying to do a maat fight, regardless of outcome e.g. if you trade testimony on wrong job, this will return true in order to prevent further execution of TradeBCNM. Returns FALSE if you're not doing a maat fight (in other words, not trading a testimony!!)
function CheckMaatFights(player, zone, trade, npc)
player:setVar("trade_bcnmid", 0);
player:setVar("trade_itemid", 0);
-- check for maat fights (one maat fight per zone in the db, but >1 mask entries depending on job, so we
-- need to choose the right one depending on the players job, and make sure the right testimony is traded,
-- and make sure the level is right!
local itemid = trade:getItem();
local job = player:getMainJob();
local lvl = player:getMainLvl();
if (itemid >= 1426 and itemid <= 1440) then -- The traded item IS A TESTIMONY
if (lvl < 66) then
return true;
end
if (player:isBcnmsFull() == 1) then -- temp measure, this will precheck the instances
print("all bcnm instances are currently occupied.");
npc:messageBasic(246, 0, 0);
return true;
end
-- Zone, {item, job, menu, bcnmid, ...}
maatList = {139, {1426, 1, 32, 5, 1429, 4, 64, 6, 1436, 11, 128, 7}, -- Horlais Peak [WAR BLM RNG]
144, {1430, 5, 64, 70, 1431, 6, 128, 71, 1434, 9, 256, 72}, -- Waughroon Shrine [RDM THF BST]
146, {1427, 2, 32, 101, 1428, 3, 64, 102, 1440, 15, 128, 103}, -- Balga's Dais [MNK WHM SMN]
168, {1437, 12, 4, 194, 1438, 13, 8, 195, 1439, 14, 16, 196}, -- Chamber of Oracles [SAM NIN DRG]
206, {1432, 7, 32, 517, 1433, 8, 64, 518, 1435, 10, 128, 519} };-- Qu'Bia Arena [PLD DRK BRD]
for nb = 1, table.getn(maatList), 2 do
if (maatList[nb] == zone) then
for nbi = 1, table.getn(maatList[nb + 1]), 4 do
if (itemid == maatList[nb + 1][nbi] and job == maatList[nb + 1][nbi + 1]) then
player:startEvent(0x7d00, 0, 0, 0, maatList[nb + 1][nbi + 2], 0, 0, 0, 0);
player:setVar("trade_bcnmid", maatList[nb + 1][nbi + 3]);
player:setVar("trade_itemid", maatList[nb + 1][nbi]);
break;
end
end
end
end
return true;
end
-- if it got this far then its not a testimony
return false;
end;
function GetBattleBitmask(id, zone, mode)
-- normal sweep for NON MAAT FIGHTS
local ret = -1;
local mask = 0;
for zoneindex = 1, table.getn(bcnmid_param_map), 2 do
if (zone==bcnmid_param_map[zoneindex]) then -- matched zone
for bcnmindex = 1, table.getn(bcnmid_param_map[zoneindex + 1]), 2 do -- loop bcnms in this zone
if (id==bcnmid_param_map[zoneindex+1][bcnmindex]) then -- found bcnmid
if (mode == 1) then
ret = mask + (2^bcnmid_param_map[zoneindex+1][bcnmindex+1]); -- for trigger (mode 1): 1, 2, 4, 8, 16, 32, ...
else
ret = mask + bcnmid_param_map[zoneindex+1][bcnmindex+1]; -- for update (mode 2): 0, 1, 2, 3, 4, 5, 6, ...
end
end
end
end
end
return ret;
end;
function ItemToBCNMID(player, zone, trade)
for zoneindex = 1, table.getn(itemid_bcnmid_map), 2 do
if (zone==itemid_bcnmid_map[zoneindex]) then -- matched zone
for bcnmindex = 1, table.getn(itemid_bcnmid_map[zoneindex + 1]), 2 do -- loop bcnms in this zone
if (trade:getItem()==itemid_bcnmid_map[zoneindex+1][bcnmindex]) then
local item = trade:getItem();
local questTimelineOK = 0;
-- Job/lvl condition for smn battle lvl20
if (item >= 1544 and item <= 1549 and player:getMainJob() == 15 and player:getMainLvl() >= 20) then
questTimelineOK = 1;
elseif (item == 1166 and player:getVar("aThiefinNorgCS") == 6) then -- AF3 SAM condition
questTimelineOK = 1;
elseif (item == 1551) then -- BCNM20
questTimelineOK = 1;
elseif (item == 1552) then -- BCNM30
questTimelineOK = 1;
elseif (item == 1131) then -- BCNM40
questTimelineOK = 1;
elseif (item == 1177) then -- BCNM50
questTimelineOK = 1;
elseif (item == 1130) then -- BCNM60
questTimelineOK = 1;
elseif (item == 1175) then -- KSNM30
questTimelineOK = 1;
elseif (item == 1178) then -- KSNM30
questTimelineOK = 1;
elseif (item == 1180) then -- KSNM30
questTimelineOK = 1;
elseif (item == 1553) then -- KSNM99
questTimelineOK = 1;
elseif (item == 1550 and (player:getQuestStatus(OUTLANDS, DIVINE_MIGHT) == QUEST_ACCEPTED or player:getQuestStatus(OUTLANDS, DIVINE_MIGHT_REPEAT) == QUEST_ACCEPTED)) then -- Divine Might
questTimelineOK = 1;
elseif (item == 1169 and player:getVar("ThePuppetMasterProgress") == 2) then -- The Puppet Master
questTimelineOK = 1;
elseif (item == 1171 and player:getVar("ClassReunionProgress") == 5) then -- Class Reunion
questTimelineOK = 1;
elseif (item == 1172 and player:getVar("CarbuncleDebacleProgress") == 3) then -- Carbuncle Debacle (Gremlims)
questTimelineOK = 1;
elseif (item == 1174 and player:getVar("CarbuncleDebacleProgress") == 6) then -- Carbuncle Debacle (Ogmios)
questTimelineOK = 1;
end
if (questTimelineOK == 1) then
player:setVar("trade_bcnmid", itemid_bcnmid_map[zoneindex+1][bcnmindex+1]);
player:setVar("trade_itemid", itemid_bcnmid_map[zoneindex+1][bcnmindex]);
return itemid_bcnmid_map[zoneindex+1][bcnmindex+1];
end
end
end
end
end
return -1;
end;
-- E.g. mission checks go here, you must know the right bcnmid for the mission you want to code.
-- You also need to know the bitmask (event param) which should be put in bcnmid_param_map
function checkNonTradeBCNM(player, npc)
local mask = 0;
local Zone = player:getZoneID();
if (Zone == 6) then -- Bearclaw_Pinnacle
if (player:getCurrentMission(COP) == THREE_PATHS and player:getVar("COP_Ulmia_s_Path") == 6) then -- flames_for_the_dead
mask = GetBattleBitmask(640, Zone, 1);
player:setVar("trade_bcnmid", 640);
end
elseif (Zone == 8) then -- Boneyard_Gully
if (player:getCurrentMission(COP) == THREE_PATHS and player:getVar("COP_Ulmia_s_Path") == 5) then -- head_wind
mask = GetBattleBitmask(672, Zone, 1);
player:setVar("trade_bcnmid", 672);
elseif (player:hasKeyItem(MIASMA_FILTER)==true) then
mask = GetBattleBitmask(673, Zone, 1);
player:setVar("trade_bcnmid", 673);
else
end
elseif (Zone == 10) then -- The_Shrouded_Maw
if (player:getCurrentMission(COP) == DARKNESS_NAMED and player:getVar("PromathiaStatus") == 2) then-- DARKNESS_NAMED
mask = GetBattleBitmask(704, Zone, 1);
player:setVar("trade_bcnmid", 704);
elseif (player:hasKeyItem(VIAL_OF_DREAM_INCENSE)==true) then -- waking_dreams (diabolos avatar quest)
mask = GetBattleBitmask(706, Zone, 1);
player:setVar("trade_bcnmid", 706);
end
elseif (Zone == 13) then -- Mine_Shaft_2716
if (player:getCurrentMission(COP) == THREE_PATHS and player:getVar("COP_Louverance_s_Path") == 5) then -- century_of_hardship
mask = GetBattleBitmask(736, Zone, 1);
player:setVar("trade_bcnmid", 736);
end
elseif (Zone == 17) then -- Spire of Holla
if (player:getCurrentMission(COP) == BELOW_THE_ARKS and player:getVar("PromathiaStatus") ==1 ) then
mask = GetBattleBitmask(768, Zone, 1);
player:setVar("trade_bcnmid", 768);
elseif (player:getCurrentMission(COP) == THE_MOTHERCRYSTALS and player:hasKeyItem(LIGHT_OF_HOLLA) == false) then -- light of holla
mask = GetBattleBitmask(768, Zone, 1);
player:setVar("trade_bcnmid", 768);
end
elseif (Zone == 19) then -- Spire of Dem
if (player:getCurrentMission(COP) == BELOW_THE_ARKS and player:getVar("PromathiaStatus") ==1 ) then
mask = GetBattleBitmask(800, Zone, 1);
player:setVar("trade_bcnmid", 800);
elseif (player:getCurrentMission(COP) == THE_MOTHERCRYSTALS and player:hasKeyItem(LIGHT_OF_DEM) == false) then -- light of dem
mask = GetBattleBitmask(800, Zone, 1);
player:setVar("trade_bcnmid", 800);
end
elseif (Zone == 21) then -- Spire of Mea
if (player:getCurrentMission(COP) == BELOW_THE_ARKS and player:getVar("PromathiaStatus") ==1 ) then
mask = GetBattleBitmask(832, Zone, 1);
player:setVar("trade_bcnmid", 832);
elseif (player:getCurrentMission(COP) == THE_MOTHERCRYSTALS and player:hasKeyItem(LIGHT_OF_MEA) == false) then -- light of mea
mask = GetBattleBitmask(832, Zone, 1);
player:setVar("trade_bcnmid", 832);
end
elseif (Zone == 23) then -- Spire of vahzl
if (player:getCurrentMission(COP) == DESIRES_OF_EMPTINESS and player:getVar("PromathiaStatus")==8) then -- desires of emptiness
mask = GetBattleBitmask(864, Zone, 1);
player:setVar("trade_bcnmid", 864);
end
elseif (Zone == 29) then -- Riverne Site #B01
if (player:getQuestStatus(JEUNO,STORMS_OF_FATE) == QUEST_ACCEPTED and player:getVar('StormsOfFate') == 2) then -- Storms of Fate BCNM
mask = GetBattleBitmask(896, Zone, 1);
player:setVar("trade_bcnmid", 896);
end
elseif (Zone == 31) then -- Monarch Linn
if (player:getCurrentMission(COP) == ANCIENT_VOWS and player:getVar("PromathiaStatus") == 2) then -- Ancient Vows bcnm
mask = GetBattleBitmask(960, Zone, 1);
player:setVar("trade_bcnmid", 960);
elseif (player:getCurrentMission(COP) == THE_SAVAGE and player:getVar("PromathiaStatus") == 1) then
mask = GetBattleBitmask(961, Zone, 1);
player:setVar("trade_bcnmid", 961);
end
elseif (Zone == 32) then -- Sealion's Den
if (player:getCurrentMission(COP) == ONE_TO_BE_FEARED and player:getVar("PromathiaStatus")==2) then -- one_to_be_feared
mask = GetBattleBitmask(992, Zone, 1);
player:setVar("trade_bcnmid", 992);
elseif (player:getCurrentMission(COP) == THE_WARRIOR_S_PATH) then -- warriors_path
mask = GetBattleBitmask(993, Zone, 1);
player:setVar("trade_bcnmid", 993);
end
elseif (Zone == 35) then -- The Garden of RuHmet
if (player:getCurrentMission(COP) == WHEN_ANGELS_FALL and player:getVar("PromathiaStatus")==4) then -- when_angels_fall
mask = GetBattleBitmask(1024, Zone, 1);
player:setVar("trade_bcnmid", 1024);
end
elseif (Zone == 36) then -- Empyreal Paradox
if (player:getCurrentMission(COP) == DAWN and player:getVar("PromathiaStatus")==2) then -- dawn
mask = GetBattleBitmask(1056, Zone, 1);
player:setVar("trade_bcnmid", 1056);
end
elseif (Zone == 139) then -- Horlais Peak
if ((player:getCurrentMission(BASTOK) == THE_EMISSARY_SANDORIA2 or
player:getCurrentMission(WINDURST) == THE_THREE_KINGDOMS_SANDORIA2) and player:getVar("MissionStatus") == 9) then -- Mission 2-3
mask = GetBattleBitmask(0, Zone, 1);
player:setVar("trade_bcnmid", 0);
elseif (player:getCurrentMission(SANDORIA) == THE_SECRET_WEAPON and player:getVar("SecretWeaponStatus") == 2) then
mask = GetBattleBitmask(3, Zone, 1)
player:setVar("trade_bcnmid", 3);
end
elseif (Zone == 140) then -- Ghelsba Outpost
local MissionStatus = player:getVar("MissionStatus");
local sTcCompleted = player:hasCompletedMission(SANDORIA, SAVE_THE_CHILDREN)
if (player:getCurrentMission(SANDORIA) == SAVE_THE_CHILDREN and (sTcCompleted and MissionStatus <= 2 or sTcCompleted == false and MissionStatus == 2)) then -- Sandy Mission 1-3
mask = GetBattleBitmask(32, Zone, 1);
player:setVar("trade_bcnmid", 32);
elseif (player:hasKeyItem(DRAGON_CURSE_REMEDY)) then -- DRG Flag Quest
mask = GetBattleBitmask(33, Zone, 1);
player:setVar("trade_bcnmid", 33);
end
elseif (Zone == 144) then -- Waughroon Shrine
if ((player:getCurrentMission(SANDORIA) == JOURNEY_TO_BASTOK2 or
player:getCurrentMission(WINDURST) == THE_THREE_KINGDOMS_BASTOK2) and player:getVar("MissionStatus") == 10) then -- Mission 2-3
mask = GetBattleBitmask(64, Zone, 1);
player:setVar("trade_bcnmid", 64);
elseif ((player:getCurrentMission(BASTOK) == ON_MY_WAY) and (player:getVar("MissionStatus") == 2)) then
mask = GetBattleBitmask(67, Zone, 1);
player:setVar("trade_bcnmid", 67);
end
elseif (Zone == 146) then -- Balga's Dais
if (player:hasKeyItem(DARK_KEY)) then -- Mission 2-3
mask = GetBattleBitmask(96, Zone, 1);
player:setVar("trade_bcnmid", 96);
elseif ((player:getCurrentMission(WINDURST) == SAINTLY_INVITATION) and (player:getVar("MissionStatus") == 1)) then -- Mission 6-2
mask = GetBattleBitmask(99, Zone, 1);
player:setVar("trade_bcnmid", 99);
end
elseif (Zone == 163) then -- Sacrificial Chamber
if (player:getCurrentMission(ZILART) == THE_TEMPLE_OF_UGGALEPIH) then -- Zilart Mission 4
mask = GetBattleBitmask(128, Zone, 1);
player:setVar("trade_bcnmid", 128);
end
elseif (Zone == 165) then -- Throne Room
if (player:getCurrentMission(player:getNation()) == 15 and player:getVar("MissionStatus") == 3) then -- Mission 5-2
mask = GetBattleBitmask(160, Zone, 1);
player:setVar("trade_bcnmid", 160);
elseif (player:getCurrentMission(BASTOK) == WHERE_TWO_PATHS_CONVERGE and player:getVar("BASTOK92") == 1) then -- bastok 9-2
mask = GetBattleBitmask(161, Zone, 1);
player:setVar("trade_bcnmid", 161);
end
elseif (Zone == 168) then -- Chamber of Oracles
if (player:getCurrentMission(ZILART) == THROUGH_THE_QUICKSAND_CAVES or player:getCurrentMission(ZILART) == THE_CHAMBER_OF_ORACLES) then -- Zilart Mission 6
mask = GetBattleBitmask(192, Zone, 1);
player:setVar("trade_bcnmid", 192);
end
elseif (Zone == 170) then -- Full Moon Fountain
if (player:hasKeyItem(MOON_BAUBLE)) then -- The Moonlit Path
mask = GetBattleBitmask(224, Zone, 1);
player:setVar("trade_bcnmid", 224);
elseif ((player:getCurrentMission(WINDURST) == MOON_READING) and player:getVar("WINDURST92") == 2) then -- Moon reading
mask = GetBattleBitmask(225, Zone, 1);
player:setVar("trade_bcnmid", 225);
end
elseif (Zone == 179) then -- Stellar Fulcrum
if (player:getCurrentMission(ZILART) == RETURN_TO_DELKFUTTS_TOWER and player:getVar("ZilartStatus") == 3) then -- Zilart Mission 8
mask = GetBattleBitmask(256, Zone, 1);
player:setVar("trade_bcnmid", 256);
end
elseif (Zone == 180) then -- La'Loff Amphitheater
if (player:getCurrentMission(ZILART) == ARK_ANGELS and player:getVar("ZilartStatus") == 1) then
local qmid = npc:getID();
if (qmid == 17514791 and player:hasKeyItem(SHARD_OF_APATHY) == false) then -- Hume, Ark Angels 1
mask = GetBattleBitmask(288, Zone, 1);
player:setVar("trade_bcnmid", 288);
elseif (qmid == 17514792 and player:hasKeyItem(SHARD_OF_COWARDICE) == false) then -- Tarutaru, Ark Angels 2
mask = GetBattleBitmask(289, Zone, 1);
player:setVar("trade_bcnmid", 289);
elseif (qmid == 17514793 and player:hasKeyItem(SHARD_OF_ENVY) == false) then -- Mithra, Ark Angels 3
mask = GetBattleBitmask(290, Zone, 1);
player:setVar("trade_bcnmid", 290);
elseif (qmid == 17514794 and player:hasKeyItem(SHARD_OF_ARROGANCE) == false) then -- Elvaan, Ark Angels 4
mask = GetBattleBitmask(291, Zone, 1);
player:setVar("trade_bcnmid", 291);
elseif (qmid == 17514795 and player:hasKeyItem(SHARD_OF_RAGE) == false) then -- Galka, Ark Angels 5
mask = GetBattleBitmask(292, Zone, 1);
player:setVar("trade_bcnmid", 292);
end
end
elseif (Zone == 181) then -- The Celestial Nexus
if (player:getCurrentMission(ZILART) == THE_CELESTIAL_NEXUS) then -- Zilart Mission 16
mask = GetBattleBitmask(320, Zone, 1);
player:setVar("trade_bcnmid", 320);
end
elseif (Zone == 201) then -- Cloister of Gales
if (player:hasKeyItem(TUNING_FORK_OF_WIND)) then -- Trial by Wind
mask = GetBattleBitmask(416, Zone, 1);
player:setVar("trade_bcnmid", 416);
elseif (player:getCurrentMission(ASA) == SUGAR_COATED_DIRECTIVE and player:hasKeyItem(DOMINAS_EMERALD_SEAL)) then
mask = GetBattleBitmask(420, Zone, 1);
player:setVar("trade_bcnmid", 420);
end
elseif (Zone == 202) then -- Cloister of Storms
if (player:hasKeyItem(TUNING_FORK_OF_LIGHTNING)) then -- Trial by Lightning
mask = GetBattleBitmask(448, Zone, 1);
player:setVar("trade_bcnmid", 448);
elseif (player:getCurrentMission(ASA) == SUGAR_COATED_DIRECTIVE and player:hasKeyItem(DOMINAS_VIOLET_SEAL)) then
mask = GetBattleBitmask(452, Zone, 1);
player:setVar("trade_bcnmid", 452);
end
elseif (Zone == 203) then -- Cloister of Frost
if (player:hasKeyItem(TUNING_FORK_OF_ICE)) then -- Trial by Ice
mask = GetBattleBitmask(480, Zone, 1);
player:setVar("trade_bcnmid", 480);
elseif (player:getCurrentMission(ASA) == SUGAR_COATED_DIRECTIVE and player:hasKeyItem(DOMINAS_AZURE_SEAL)) then
mask = GetBattleBitmask(484, Zone, 1);
player:setVar("trade_bcnmid", 484);
end
elseif (Zone == 206) then -- Qu'Bia Arena
if (player:getCurrentMission(player:getNation()) == 14 and player:getVar("MissionStatus") == 11) then -- Mission 5-1
mask = GetBattleBitmask(512, Zone, 1);
player:setVar("trade_bcnmid", 512);
elseif (player:getCurrentMission(SANDORIA) == THE_HEIR_TO_THE_LIGHT and player:getVar("MissionStatus") == 3) then -- sando 9-2
mask = GetBattleBitmask(516, Zone, 1);
player:setVar("trade_bcnmid", 516);
-- Temp disabled pending BCNM mob fixes
-- elseif (player:getCurrentMission(ACP) >= THOSE_WHO_LURK_IN_SHADOWS_III and player:hasKeyItem(MARK_OF_SEED)) then -- ACP Mission 7
-- mask = GetBattleBitmask(532, Zone, 1);
-- player:setVar("trade_bcnmid", 532);
end
elseif (Zone == 207) then -- Cloister of Flames
if (player:hasKeyItem(TUNING_FORK_OF_FIRE)) then -- Trial by Fire
mask = GetBattleBitmask(544, Zone, 1);
player:setVar("trade_bcnmid", 544);
elseif (player:getCurrentMission(ASA) == SUGAR_COATED_DIRECTIVE and player:hasKeyItem(DOMINAS_SCARLET_SEAL)) then
mask = GetBattleBitmask(547, Zone, 1);
player:setVar("trade_bcnmid", 547);
end
elseif (Zone == 209) then -- Cloister of Tremors
if (player:hasKeyItem(TUNING_FORK_OF_EARTH)) then -- Trial by Earth
mask = GetBattleBitmask(576, Zone, 1);
player:setVar("trade_bcnmid", 576);
elseif (player:getCurrentMission(ASA) == SUGAR_COATED_DIRECTIVE and player:hasKeyItem(DOMINAS_AMBER_SEAL)) then
mask = GetBattleBitmask(580, Zone, 1);
player:setVar("trade_bcnmid", 580);
end
elseif (Zone == 211) then -- Cloister of Tides
if (player:hasKeyItem(TUNING_FORK_OF_WATER)) then -- Trial by Water
mask = GetBattleBitmask(608, Zone, 1);
player:setVar("trade_bcnmid", 608);
elseif (player:getCurrentMission(ASA) == SUGAR_COATED_DIRECTIVE and player:hasKeyItem(DOMINAS_CERULEAN_SEAL)) then
mask = GetBattleBitmask(611, Zone, 1);
player:setVar("trade_bcnmid", 611);
end
end
if (mask == -1) then
print("BCNMID/Mask pair not found"); -- something went wrong
return true;
elseif (mask ~= 0) then
player:startEvent(0x7d00, 0, 0, 0, mask, 0, 0, 0, 0);
print("BCNMID found with mask "..mask);
return true;
else
return false;
end
end;
function CutsceneSkip(player, npc)
local skip = 0;
local Zone = player:getZoneID();
if (Zone == 6) then -- Bearclaw Pinnacle
if ((player:hasCompletedMission(COP, THREE_PATHS)) or (player:getCurrentMission(COP) == THREE_PATHS and player:getVar("COP_Ulmia_s_Path") > 6)) then -- flames_for_the_dead
skip = 1;
end
elseif (Zone == 8) then -- Boneyard Gully
if ((player:hasCompletedMission(COP, THREE_PATHS)) or (player:getCurrentMission(COP) == THREE_PATHS and player:getVar("COP_Ulmia_s_Path") > 5)) then -- head_wind
skip = 1;
end
elseif (Zone == 10) then -- The_Shrouded_Maw
if ((player:hasCompletedMission(COP, DARKNESS_NAMED)) or (player:getCurrentMission(COP) == DARKNESS_NAMED and player:getVar("PromathiaStatus") > 2)) then -- DARKNESS_NAMED
skip = 1;
elseif ((player:hasCompleteQuest(WINDURST, WAKING_DREAMS)) or (player:hasKeyItem(WHISPER_OF_DREAMS))) then -- waking_dreams (diabolos avatar quest)
skip = 1;
end
elseif (Zone == 13) then -- Mine Shaft 2716
if ((player:hasCompletedMission(COP, THREE_PATHS)) or (player:getCurrentMission(COP) == THREE_PATHS and player:getVar("COP_Louverance_s_Path") > 5)) then -- century_of_hardship
skip = 1;
end
elseif (Zone == 17) then -- Spire of Holla
if ((player:hasCompletedMission(COP, THE_MOTHERCRYSTALS)) or (player:hasKeyItem(LIGHT_OF_HOLLA))) then -- light of holla
skip = 1;
end
elseif (Zone == 19) then -- Spire of Dem
if ((player:hasCompletedMission(COP, THE_MOTHERCRYSTALS)) or (player:hasKeyItem(LIGHT_OF_DEM))) then -- light of dem
skip = 1;
end
elseif (Zone == 21) then -- Spire of Mea
if ((player:hasCompletedMission(COP, THE_MOTHERCRYSTALS)) or (player:hasKeyItem(LIGHT_OF_MEA))) then -- light of mea
skip = 1;
end
elseif (Zone == 23) then -- Spire of Vahzl
if ((player:hasCompletedMission(COP, DESIRES_OF_EMPTINESS)) or (player:getCurrentMission(COP) == DESIRES_OF_EMPTINESS and player:getVar("PromathiaStatus") > 8)) then -- desires of emptiness
skip = 1;
end
elseif (Zone == 29) then -- Riverne Site #B01
if ((player:getQuestStatus(JEUNO,STORMS_OF_FATE) == QUEST_COMPLETED) or (player:getQuestStatus(JEUNO,STORMS_OF_FATE) == QUEST_ACCEPTED and player:getVar("StormsOfFate") > 2)) then -- Storms of Fate
skip = 1;
end
elseif (Zone == 31) then -- Monarch Linn
if (player:hasCompletedMission(COP, ANCIENT_VOWS)) then -- Ancient Vows
skip = 1;
elseif ((player:hasCompletedMission(COP, THE_SAVAGE)) or (player:getCurrentMission(COP) == THE_SAVAGE and player:getVar("PromathiaStatus") > 1)) then
skip = 1;
end
elseif (Zone == 32) then -- Sealion's Den
if (player:hasCompletedMission(COP, ONE_TO_BE_FEARED)) then -- one_to_be_feared
skip = 1;
elseif (player:hasCompletedMission(COP, THE_WARRIOR_S_PATH)) then -- warriors_path
skip = 1;
end
elseif (Zone == 35) then -- The Garden of RuHmet
if ((player:hasCompletedMission(COP, WHEN_ANGELS_FALL)) or (player:getCurrentMission(COP) == WHEN_ANGELS_FALL and player:getVar("PromathiaStatus") > 4)) then -- when_angels_fall
skip = 1;
end
elseif (Zone == 36) then -- Empyreal Paradox
if ((player:hasCompletedMission(COP, DAWN)) or (player:getCurrentMission(COP) == DAWN and player:getVar("PromathiaStatus") > 2)) then -- dawn
skip = 1;
end
elseif (Zone == 139) then -- Horlais Peak
if ((player:hasCompletedMission(BASTOK, THE_EMISSARY_SANDORIA2) or player:hasCompletedMission(WINDURST, THE_THREE_KINGDOMS_SANDORIA2)) or
((player:getCurrentMission(BASTOK) == THE_EMISSARY_SANDORIA2 or player:getCurrentMission(WINDURST) == THE_THREE_KINGDOMS_SANDORIA2) and player:getVar("MissionStatus") > 9)) then -- Mission 2-3
skip = 1;
elseif ((player:hasCompletedMission(SANDORIA, THE_SECRET_WEAPON)) or (player:getCurrentMission(SANDORIA) == THE_SECRET_WEAPON and player:getVar("SecretWeaponStatus") > 2)) then
skip = 1;
end
elseif (Zone == 140) then -- Ghelsba Outpost
if ((player:hasCompletedMission(SANDORIA, SAVE_THE_CHILDREN)) or (player:getCurrentMission(SANDORIA) == SAVE_THE_CHILDREN and player:getVar("MissionStatus") > 2)) then -- Sandy Mission 1-3
skip = 1;
elseif (player:hasCompleteQuest(SANDORIA, THE_HOLY_CREST)) then -- DRG Flag Quest
skip = 1;
end
elseif (Zone == 144) then -- Waughroon Shrine
if ((player:hasCompletedMission(SANDORIA, JOURNEY_TO_BASTOK2) or player:hasCompletedMission(WINDURST, THE_THREE_KINGDOMS_BASTOK2)) or
((player:getCurrentMission(SANDORIA) == JOURNEY_TO_BASTOK2 or player:getCurrentMission(WINDURST) == THE_THREE_KINGDOMS_BASTOK2) and player:getVar("MissionStatus") > 10)) then -- Mission 2-3
skip = 1;
elseif ((player:hasCompletedMission(BASTOK, ON_MY_WAY)) or (player:getCurrentMission(BASTOK) == ON_MY_WAY and player:getVar("MissionStatus") > 2)) then
skip = 1;
end
elseif (Zone == 146) then -- Balga's Dais
if ((player:hasCompletedMission(SANDORIA, JOURNEY_TO_WINDURST2) or player:hasCompletedMission(BASTOK, THE_EMISSARY_WINDURST2)) or
((player:getCurrentMission(SANDORIA) == JOURNEY_TO_WINDURST2 or player:getCurrentMission(BASTOK) == THE_EMISSARY_WINDURST2) and player:getVar("MissionStatus") > 8)) then -- Mission 2-3
skip = 1;
elseif ((player:hasCompletedMission(WINDURST, SAINTLY_INVITATION)) or (player:getCurrentMission(WINDURST) == SAINTLY_INVITATION and player:getVar("MissionStatus") > 1)) then -- Mission 6-2
skip = 1;
end
elseif (Zone == 165) then -- Throne Room
if ((player:hasCompletedMission(player:getNation(), 15)) or (player:getCurrentMission(player:getNation()) == 15 and player:getVar("MissionStatus") > 3)) then -- Mission 5-2
skip = 1;
end
elseif (Zone == 168) then -- Chamber of Oracles
if (player:hasCompletedMission(ZILART, THROUGH_THE_QUICKSAND_CAVES)) then -- Zilart Mission 6
skip = 1;
end
elseif (Zone == 170) then -- Full Moon Fountain
if ((player:hasCompleteQuest(WINDURST, THE_MOONLIT_PATH)) or (player:hasKeyItem(WHISPER_OF_THE_MOON))) then -- The Moonlit Path
skip = 1;
end
elseif (Zone == 179) then -- Stellar Fulcrum
if (player:hasCompletedMission(ZILART, RETURN_TO_DELKFUTTS_TOWER)) then -- Zilart Mission 8
skip = 1;
end
elseif (Zone == 180) then -- La'Loff Amphitheater
if (player:hasCompletedMission(ZILART, ARK_ANGELS)) then
skip = 1;
end
elseif (Zone == 181) then -- The Celestial Nexus
if (player:hasCompletedMission(ZILART, THE_CELESTIAL_NEXUS)) then -- Zilart Mission 16
skip = 1;
end
elseif (Zone == 201) then -- Cloister of Gales
if ((player:hasCompleteQuest(OUTLANDS, TRIAL_BY_WIND)) or (player:hasKeyItem(WHISPER_OF_GALES))) then -- Trial by Wind
skip = 1;
end
elseif (Zone == 202) then -- Cloister of Storms
if ((player:hasCompleteQuest(OTHER_AREAS, TRIAL_BY_LIGHTNING)) or (player:hasKeyItem(WHISPER_OF_STORMS))) then -- Trial by Lightning
skip = 1;
end
elseif (Zone == 203) then -- Cloister of Frost
if ((player:hasCompleteQuest(SANDORIA, TRIAL_BY_ICE)) or (player:hasKeyItem(WHISPER_OF_FROST))) then -- Trial by Ice
skip = 1;
end
elseif (Zone == 206) then -- Qu'Bia Arena
if ((player:hasCompletedMission(player:getNation(), 14)) or (player:getCurrentMission(player:getNation()) == 14 and player:getVar("MissionStatus") > 11)) then -- Mission 5-1
skip = 1;
elseif ((player:hasCompletedMission(player:getNation(), 23)) or (player:getCurrentMission(player:getNation()) == 23 and player:getVar("MissionStatus") > 4)) then -- Mission 9-2
skip = 1;
end
elseif (Zone == 207) then -- Cloister of Flames
if ((player:hasCompleteQuest(OUTLANDS, TRIAL_BY_FIRE)) or (player:hasKeyItem(WHISPER_OF_FLAMES))) then -- Trial by Fire
skip = 1;
end
elseif (Zone == 209) then -- Cloister of Tremors
if ((player:hasCompleteQuest(BASTOK, TRIAL_BY_EARTH)) or (player:hasKeyItem(WHISPER_OF_TREMORS))) then -- Trial by Earth
skip = 1;
end
elseif (Zone == 211) then -- Cloister of Tides
if ((player:hasCompleteQuest(OUTLANDS, TRIAL_BY_WATER)) or (player:hasKeyItem(WHISPER_OF_TIDES))) then -- Trial by Water
skip = 1;
end
end
return skip;
end;
| gpl-3.0 |
mramir8274/deltabot | plugins/inrealm.lua | 287 | 25005 | -- data saved to moderation.json
-- check moderation plugin
do
local function create_group(msg)
-- superuser and admins only (because sudo are always has privilege)
if is_sudo(msg) or is_realm(msg) and is_admin(msg) then
local group_creator = msg.from.print_name
create_group_chat (group_creator, group_name, ok_cb, false)
return 'Group [ '..string.gsub(group_name, '_', ' ')..' ] has been created.'
end
end
local function create_realm(msg)
-- superuser and admins only (because sudo are always has privilege)
if is_sudo(msg) or is_realm(msg) and is_admin(msg) then
local group_creator = msg.from.print_name
create_group_chat (group_creator, group_name, ok_cb, false)
return 'Realm [ '..string.gsub(group_name, '_', ' ')..' ] has been created.'
end
end
local function killchat(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function killrealm(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function get_group_type(msg)
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
if not data[tostring(msg.to.id)]['group_type'] then
return 'No group type available.'
end
local group_type = data[tostring(msg.to.id)]['group_type']
return group_type
else
return 'Chat type not found.'
end
end
local function callbackres(extra, success, result)
--vardump(result)
local user = result.id
local name = string.gsub(result.print_name, "_", " ")
local chat = 'chat#id'..extra.chatid
send_large_msg(chat, user..'\n'..name)
return user
end
local function set_description(msg, data, target, about)
if not is_admin(msg) then
return "For admins only!"
end
local data_cat = 'description'
data[tostring(target)][data_cat] = about
save_data(_config.moderation.data, data)
return 'Set group description to:\n'..about
end
local function set_rules(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local data_cat = 'rules'
data[tostring(target)][data_cat] = rules
save_data(_config.moderation.data, data)
return 'Set group rules to:\n'..rules
end
-- lock/unlock group name. bot automatically change group name when locked
local function lock_group_name(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'yes' then
return 'Group name is already locked'
else
data[tostring(target)]['settings']['lock_name'] = 'yes'
save_data(_config.moderation.data, data)
rename_chat('chat#id'..target, group_name_set, ok_cb, false)
return 'Group name has been locked'
end
end
local function unlock_group_name(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'no' then
return 'Group name is already unlocked'
else
data[tostring(target)]['settings']['lock_name'] = 'no'
save_data(_config.moderation.data, data)
return 'Group name has been unlocked'
end
end
--lock/unlock group member. bot automatically kick new added user when locked
local function lock_group_member(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'yes' then
return 'Group members are already locked'
else
data[tostring(target)]['settings']['lock_member'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Group members has been locked'
end
local function unlock_group_member(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'no' then
return 'Group members are not locked'
else
data[tostring(target)]['settings']['lock_member'] = 'no'
save_data(_config.moderation.data, data)
return 'Group members has been unlocked'
end
end
--lock/unlock group photo. bot automatically keep group photo when locked
local function lock_group_photo(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'yes' then
return 'Group photo is already locked'
else
data[tostring(target)]['settings']['set_photo'] = 'waiting'
save_data(_config.moderation.data, data)
end
return 'Please send me the group photo now'
end
local function unlock_group_photo(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'no' then
return 'Group photo is not locked'
else
data[tostring(target)]['settings']['lock_photo'] = 'no'
save_data(_config.moderation.data, data)
return 'Group photo has been unlocked'
end
end
local function lock_group_flood(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'yes' then
return 'Group flood is locked'
else
data[tostring(target)]['settings']['flood'] = 'yes'
save_data(_config.moderation.data, data)
return 'Group flood has been locked'
end
end
local function unlock_group_flood(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'no' then
return 'Group flood is not locked'
else
data[tostring(target)]['settings']['flood'] = 'no'
save_data(_config.moderation.data, data)
return 'Group flood has been unlocked'
end
end
-- show group settings
local function show_group_settings(msg, data, target)
local data = load_data(_config.moderation.data, data)
if not is_admin(msg) then
return "For admins only!"
end
local settings = data[tostring(target)]['settings']
local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member
return text
end
local function returnids(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..''
for k,v in pairs(result.members) do
local username = ""
text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n"
end
send_large_msg(receiver, text)
local file = io.open("./groups/lists/"..result.id.."memberlist.txt", "w")
file:write(text)
file:flush()
file:close()
end
local function returnidsfile(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..''
for k,v in pairs(result.members) do
local username = ""
text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n"
end
local file = io.open("./groups/lists/"..result.id.."memberlist.txt", "w")
file:write(text)
file:flush()
file:close()
send_document("chat#id"..result.id,"./groups/lists/"..result.id.."memberlist.txt", ok_cb, false)
end
local function admin_promote(msg, admin_id)
if not is_sudo(msg) then
return "Access denied!"
end
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
if data[tostring(admins)][tostring(admin_id)] then
return admin_name..' is already an admin.'
end
data[tostring(admins)][tostring(admin_id)] = admin_id
save_data(_config.moderation.data, data)
return admin_id..' has been promoted as admin.'
end
local function admin_demote(msg, admin_id)
if not is_sudo(msg) then
return "Access denied!"
end
local data = load_data(_config.moderation.data)
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
if not data[tostring(admins)][tostring(admin_id)] then
return admin_id..' is not an admin.'
end
data[tostring(admins)][tostring(admin_id)] = nil
save_data(_config.moderation.data, data)
return admin_id..' has been demoted from admin.'
end
local function admin_list(msg)
local data = load_data(_config.moderation.data)
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
local message = 'List for Realm admins:\n'
for k,v in pairs(data[tostring(admins)]) do
message = message .. '- (at)' .. v .. ' [' .. k .. '] ' ..'\n'
end
return message
end
local function groups_list(msg)
local data = load_data(_config.moderation.data)
local groups = 'groups'
if not data[tostring(groups)] then
return 'No groups at the moment'
end
local message = 'List of groups:\n'
for k,v in pairs(data[tostring(groups)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairs(settings) do
if m == 'set_name' then
name = n
end
end
local group_owner = "No owner"
if data[tostring(v)]['set_owner'] then
group_owner = tostring(data[tostring(v)]['set_owner'])
end
local group_link = "No link"
if data[tostring(v)]['settings']['set_link'] then
group_link = data[tostring(v)]['settings']['set_link']
end
message = message .. '- '.. name .. ' (' .. v .. ') ['..group_owner..'] \n {'..group_link.."}\n"
end
local file = io.open("./groups/lists/groups.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function realms_list(msg)
local data = load_data(_config.moderation.data)
local realms = 'realms'
if not data[tostring(realms)] then
return 'No Realms at the moment'
end
local message = 'List of Realms:\n'
for k,v in pairs(data[tostring(realms)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairs(settings) do
if m == 'set_name' then
name = n
end
end
local group_owner = "No owner"
if data[tostring(v)]['admins_in'] then
group_owner = tostring(data[tostring(v)]['admins_in'])
end
local group_link = "No link"
if data[tostring(v)]['settings']['set_link'] then
group_link = data[tostring(v)]['settings']['set_link']
end
message = message .. '- '.. name .. ' (' .. v .. ') ['..group_owner..'] \n {'..group_link.."}\n"
end
local file = io.open("./groups/lists/realms.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function admin_user_promote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
if not data['admins'] then
data['admins'] = {}
save_data(_config.moderation.data, data)
end
if data['admins'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is already as admin.')
end
data['admins'][tostring(member_id)] = member_username
save_data(_config.moderation.data, data)
return send_large_msg(receiver, '@'..member_username..' has been promoted as admin.')
end
local function admin_user_demote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
if not data['admins'] then
data['admins'] = {}
save_data(_config.moderation.data, data)
end
if not data['admins'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is not an admin.')
end
data['admins'][tostring(member_id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Admin '..member_username..' has been demoted.')
end
local function username_id(cb_extra, success, result)
local mod_cmd = cb_extra.mod_cmd
local receiver = cb_extra.receiver
local member = cb_extra.member
local text = 'No user @'..member..' in this group.'
for k,v in pairs(result.members) do
vusername = v.username
if vusername == member then
member_username = member
member_id = v.id
if mod_cmd == 'addadmin' then
return admin_user_promote(receiver, member_username, member_id)
elseif mod_cmd == 'removeadmin' then
return admin_user_demote(receiver, member_username, member_id)
end
end
end
send_large_msg(receiver, text)
end
local function set_log_group(msg)
if not is_admin(msg) then
return
end
local log_group = data[tostring(groups)][tostring(msg.to.id)]['log_group']
if log_group == 'yes' then
return 'Log group is already set'
else
data[tostring(groups)][tostring(msg.to.id)]['log_group'] = 'yes'
save_data(_config.moderation.data, data)
return 'Log group has been set'
end
end
local function unset_log_group(msg)
if not is_admin(msg) then
return
end
local log_group = data[tostring(groups)][tostring(msg.to.id)]['log_group']
if log_group == 'no' then
return 'Log group is already disabled'
else
data[tostring(groups)][tostring(msg.to.id)]['log_group'] = 'no'
save_data(_config.moderation.data, data)
return 'log group has been disabled'
end
end
local function help()
local help_text = tostring(_config.help_text_realm)
return help_text
end
function run(msg, matches)
--vardump(msg)
local name_log = user_print_name(msg.from)
if matches[1] == 'log' and is_owner(msg) then
savelog(msg.to.id, "log file created by owner")
send_document("chat#id"..msg.to.id,"./groups/"..msg.to.id.."log.txt", ok_cb, false)
end
if matches[1] == 'who' and is_momod(msg) then
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list ")
local receiver = get_receiver(msg)
chat_info(receiver, returnidsfile, {receiver=receiver})
end
if matches[1] == 'wholist' and is_momod(msg) then
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list in a file")
local receiver = get_receiver(msg)
chat_info(receiver, returnids, {receiver=receiver})
end
if matches[1] == 'creategroup' and matches[2] then
group_name = matches[2]
group_type = 'group'
return create_group(msg)
end
if not is_sudo(msg) or not is_admin(msg) and not is_realm(msg) then
return --Do nothing
end
if matches[1] == 'createrealm' and matches[2] then
group_name = matches[2]
group_type = 'realm'
return create_realm(msg)
end
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
if matches[2] then if data[tostring(matches[2])] then
local settings = data[tostring(matches[2])]['settings']
if matches[1] == 'setabout' and matches[2] then
local target = matches[2]
local about = matches[3]
return set_description(msg, data, target, about)
end
if matches[1] == 'setrules' then
rules = matches[3]
local target = matches[2]
return set_rules(msg, data, target)
end
if matches[1] == 'lock' then --group lock *
local target = matches[2]
if matches[3] == 'name' then
return lock_group_name(msg, data, target)
end
if matches[3] == 'member' then
return lock_group_member(msg, data, target)
end
if matches[3] == 'photo' then
return lock_group_photo(msg, data, target)
end
if matches[3] == 'flood' then
return lock_group_flood(msg, data, target)
end
end
if matches[1] == 'unlock' then --group unlock *
local target = matches[2]
if matches[3] == 'name' then
return unlock_group_name(msg, data, target)
end
if matches[3] == 'member' then
return unlock_group_member(msg, data, target)
end
if matches[3] == 'photo' then
return unlock_group_photo(msg, data, target)
end
if matches[3] == 'flood' then
return unlock_group_flood(msg, data, target)
end
end
if matches[1] == 'settings' and data[tostring(matches[2])]['settings'] then
local target = matches[2]
return show_group_settings(msg, data, target)
end
if matches[1] == 'setname' and is_realm(msg) then
local new_name = string.gsub(matches[2], '_', ' ')
data[tostring(msg.to.id)]['settings']['set_name'] = new_name
save_data(_config.moderation.data, data)
local group_name_set = data[tostring(msg.to.id)]['settings']['set_name']
local to_rename = 'chat#id'..msg.to.id
rename_chat(to_rename, group_name_set, ok_cb, false)
savelog(msg.to.id, "Realm { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]")
end
if matches[1] == 'setgpname' and is_admin(msg) then
local new_name = string.gsub(matches[3], '_', ' ')
data[tostring(matches[2])]['settings']['set_name'] = new_name
save_data(_config.moderation.data, data)
local group_name_set = data[tostring(matches[2])]['settings']['set_name']
local to_rename = 'chat#id'..matches[2]
rename_chat(to_rename, group_name_set, ok_cb, false)
savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]")
end
end
end
if matches[1] == 'help' and is_realm(msg) then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help")
return help()
end
if matches[1] == 'set' then
if matches[2] == 'loggroup' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set as log group")
return set_log_group(msg)
end
end
if matches[1] == 'kill' and matches[2] == 'chat' then
if not is_admin(msg) then
return nil
end
if is_realm(msg) then
local receiver = 'chat#id'..matches[3]
return modrem(msg),
print("Closing Group: "..receiver),
chat_info(receiver, killchat, {receiver=receiver})
else
return 'Error: Group '..matches[3]..' not found'
end
end
if matches[1] == 'kill' and matches[2] == 'realm' then
if not is_admin(msg) then
return nil
end
if is_realm(msg) then
local receiver = 'chat#id'..matches[3]
return realmrem(msg),
print("Closing realm: "..receiver),
chat_info(receiver, killrealm, {receiver=receiver})
else
return 'Error: Realm '..matches[3]..' not found'
end
end
if matches[1] == 'chat_add_user' then
if not msg.service then
return "Are you trying to troll me?"
end
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
if not is_admin(msg) then
chat_del_user(chat, user, ok_cb, true)
end
end
if matches[1] == 'addadmin' then
if string.match(matches[2], '^%d+$') then
local admin_id = matches[2]
print("user "..admin_id.." has been promoted as admin")
return admin_promote(msg, admin_id)
else
local member = string.gsub(matches[2], "@", "")
local mod_cmd = "addadmin"
chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member})
end
end
if matches[1] == 'removeadmin' then
if string.match(matches[2], '^%d+$') then
local admin_id = matches[2]
print("user "..admin_id.." has been demoted")
return admin_demote(msg, admin_id)
else
local member = string.gsub(matches[2], "@", "")
local mod_cmd = "removeadmin"
chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member})
end
end
if matches[1] == 'type'then
local group_type = get_group_type(msg)
return group_type
end
if matches[1] == 'list' and matches[2] == 'admins' then
return admin_list(msg)
end
if matches[1] == 'list' and matches[2] == 'groups' then
if msg.to.type == 'chat' then
groups_list(msg)
send_document("chat#id"..msg.to.id, "./groups/lists/groups.txt", ok_cb, false)
return "Group list created" --group_list(msg)
elseif msg.to.type == 'user' then
groups_list(msg)
send_document("user#id"..msg.from.id, "./groups/lists/groups.txt", ok_cb, false)
return "Group list created" --group_list(msg)
end
end
if matches[1] == 'list' and matches[2] == 'realms' then
if msg.to.type == 'chat' then
realms_list(msg)
send_document("chat#id"..msg.to.id, "./groups/lists/realms.txt", ok_cb, false)
return "Realms list created" --realms_list(msg)
elseif msg.to.type == 'user' then
realms_list(msg)
send_document("user#id"..msg.from.id, "./groups/lists/realms.txt", ok_cb, false)
return "Realms list created" --realms_list(msg)
end
end
if matches[1] == 'res' and is_momod(msg) then
local cbres_extra = {
chatid = msg.to.id
}
local username = matches[2]
local username = username:gsub("@","")
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username)
return res_user(username, callbackres, cbres_extra)
end
end
return {
patterns = {
"^[!/](creategroup) (.*)$",
"^[!/](createrealm) (.*)$",
"^[!/](setabout) (%d+) (.*)$",
"^[!/](setrules) (%d+) (.*)$",
"^[!/](setname) (.*)$",
"^[!/](setgpname) (%d+) (.*)$",
"^[!/](setname) (%d+) (.*)$",
"^[!/](lock) (%d+) (.*)$",
"^[!/](unlock) (%d+) (.*)$",
"^[!/](setting) (%d+)$",
"^[!/](wholist)$",
"^[!/](who)$",
"^[!/](type)$",
"^[!/](kill) (chat) (%d+)$",
"^[!/](kill) (realm) (%d+)$",
"^[!/](addadmin) (.*)$", -- sudoers only
"^[!/](removeadmin) (.*)$", -- sudoers only
"^[!/](list) (.*)$",
"^[!/](log)$",
"^[!/](help)$",
"^!!tgservice (.+)$",
},
run = run
}
end
| gpl-2.0 |
milkmanjack/lama | src/global/DatabaseManager.lua | 1 | 7693 | --[[
lama is a MUD server made in Lua.
Copyright (C) 2013 Curtis Erickson
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
]]
--- Singleton that provides database management utilities.
-- @author milkmanjack
local md5 = require("md5")
local Mob = require("obj.Mob")
--- Singleton that provides database management utilities.
-- @class table
-- @name DatabaseManager
-- @field charDirectory Where character saves are stored.
-- @field extension File extension for saves.
DatabaseManager = {}
-- templates for savefiles
DatabaseManager.charTemplate= [[
-- Character file generated %s
return {
password = "%s",
name = "%s",
description = "%s",
race = "%s",
class = "%s",
level = %d,
experience = %d,
health = %d,
mana = %d,
moves = %d,
location = {x=%d,y=%d,z=%d}
}
]]
-- file information
DatabaseManager.dataDirectory = "data"
DatabaseManager.raceDirectory = "race"
DatabaseManager.classDirectory = "class"
DatabaseManager.charDirectory = "character"
DatabaseManager.cmdDirectory = "command"
DatabaseManager.extension = "lua"
-- runtime data
DatabaseManager.commands = {}
DatabaseManager.races = {}
DatabaseManager.classes = {}
--- Get the legalized name form of the given string.
-- @param name Name to be legalized.
-- @return The legalized name, or nil followed by an error message.
function DatabaseManager.legalizeName(name)
name = string.lower(name) -- lowercase please
-- names with 1 hyphen are legal
-- "Billy-Bob", "Al-thud"
local hFirst, hLast= string.match(name, "([a-z]+)%-([a-z]+)")
if hFirst and hLast then
return string.format("%s%s-%s%s",
string.upper(string.sub(hFirst, 1, 1)),
string.sub(hFirst, 2),
string.sub(hLast, 1, 1),
string.sub(hLast, 2)
)
end
--- names with one apostrophe are legal
-- "Al'thud", "Tal'ic"
hFirst, hLast= string.match(name, "([a-z]+)'([a-z]+)")
if hFirst and hLast then
return string.format("%s%s'%s%s",
string.upper(string.sub(hFirst, 1, 1)),
string.sub(hFirst, 2),
string.sub(hLast, 1, 1),
string.sub(hLast, 2)
)
end
-- standard name made of only alphanumeric characters, beginning with a capital letter.
-- "Garret", "Judas"
name = string.match(name, "([a-z]+)")
if name then
return string.format("%s%s",
string.upper(string.sub(name, 1, 1)),
string.sub(name, 2)
)
end
return nil, "invalid name"
end
--- Format a string so it's safe for saving.
-- @param s String to format.
-- @return The formatted string.
function DatabaseManager.safeString(s)
s = string.gsub(s, "\r", "\\r")
s = string.gsub(s, "\n", "\\n")
return s
end
--- Get the character filename for a given name.
-- @param name Name of the character to generate a filename for.
-- @return Properly formatted filename for character based on its name.
function DatabaseManager.getCharacterFileFromName(name)
name = string.lower(DatabaseManager.legalizeName(name)) -- legalize it.
name = string.gsub(name, "[^a-zA-Z]", "") -- remove non-alpha characters.
return string.format("%s/%s/%s.%s", DatabaseManager.dataDirectory, DatabaseManager.charDirectory, name, DatabaseManager.extension)
end
--- Check if a character name is in use.
-- @param name Name to check.
-- @return true if name is taken.<br/>false otherwise.
function DatabaseManager.characterNameTaken(name)
local filename = DatabaseManager.getCharacterFileFromName(name)
local file = io.open(filename, "r")
if not file then
return false
end
file:close()
return true
end
--- Get the XML format of a character.
-- @param mob Mob of the character to generate data of.
-- @return The XML format of the character.
function DatabaseManager.generateCharacterData(mob)
local template = DatabaseManager.charTemplate
return string.format(template,
os.date(),
mob.characterData.password,
mob.name,
DatabaseManager.safeString(mob.description),
mob.race:getName(),
mob.class:getName(),
mob.level,
mob.experience,
mob.health,
mob.mana,
mob.moves,
mob:getLoc():getX(),
mob:getLoc():getY(),
mob:getLoc():getZ()
)
end
--- Save a mob as a character.
-- @param mob Mob of the character to save.
function DatabaseManager.saveCharacter(mob)
local filename = DatabaseManager.getCharacterFileFromName(mob:getName())
local file = io.open(filename, "w+")
file:write(DatabaseManager.generateCharacterData(mob))
file:close()
end
--- Load a character into a mob.
-- @param name Name of the character to be loaded.
-- @param mob The mob for character data to be read into.<br/>if nil, a new mob will be generated and returned.
-- @return The mob that data was read into.
function DatabaseManager.loadCharacter(name)
local filename = DatabaseManager.getCharacterFileFromName(name)
local data = dofile(filename)
local location = Game.map:getTile(data.location.x, data.location.y, data.location.z)
local mob = Mob:new()
mob:setPassword(data.password)
mob:setKeywords(name)
mob:setName(data.name)
mob:setDescription(data.description)
mob.race = DatabaseManager.getRaceByName(data.race)
mob.class = DatabaseManager.getClassByName(data.class)
mob.level = data.level
mob.experience = data.experience
mob.health = data.health
mob.mana = data.mana
mob.moves = data.moves
return mob, location
end
function DatabaseManager.getRaceByName(name)
for i,race in ipairs(DatabaseManager.races) do
if string.find(race:getName(), name) == 1 then
return race
end
end
end
--- Load races.
function DatabaseManager.loadRaces()
local directory = string.format("%s/%s", DatabaseManager.dataDirectory, DatabaseManager.raceDirectory)
for i in lfs.dir(directory) do
if i ~= "." and i ~= ".." then
if string.match(i, ".+%.lua") then -- it's an lua file!
local race = dofile(directory .. "/" .. i)
Game.info("Loading race '" .. race:getName() .. "'")
table.insert(DatabaseManager.races, race)
end
end
end
end
function DatabaseManager.getClassByName(name)
for i,class in ipairs(DatabaseManager.classes) do
if string.find(class:getName(), name) == 1 then
return class
end
end
end
--- Load classes.
function DatabaseManager.loadClasses()
local directory = string.format("%s/%s", DatabaseManager.dataDirectory, DatabaseManager.classDirectory)
for i in lfs.dir(directory) do
if i ~= "." and i ~= ".." then
if string.match(i, ".+%.lua") then -- it's an lua file!
local class = dofile(directory .. "/" .. i)
Game.info("Loading class '" .. class:getName() .. "'")
table.insert(DatabaseManager.classes, class)
end
end
end
end
--- Load commands.
function DatabaseManager.loadCommands()
local directory = string.format("%s/%s", DatabaseManager.dataDirectory, DatabaseManager.cmdDirectory)
for i in lfs.dir(directory) do
if i ~= "." and i ~= ".." and i ~= "movement.lua" then
if string.match(i, ".+%.lua") then -- it's an lua file!
local command = dofile(directory .. "/" .. i)
Game.info("Loading command '" .. command:getKeyword() .. "'")
table.insert(DatabaseManager.commands, command)
end
end
end
end
_G.DatabaseManager = DatabaseManager
return DatabaseManager
| gpl-3.0 |
plajjan/snabbswitch | lib/ljsyscall/syscall/util.lua | 15 | 9655 | -- generic utils not specific to any OS
-- these are generally equivalent to things that are in man(1) or man(3)
-- these can be made more modular as number increases
local require, error, assert, tonumber, tostring,
setmetatable, pairs, ipairs, unpack, rawget, rawset,
pcall, type, table, string =
require, error, assert, tonumber, tostring,
setmetatable, pairs, ipairs, unpack, rawget, rawset,
pcall, type, table, string
local function init(S)
local h = require "syscall.helpers"
local htonl = h.htonl
local ffi = require "ffi"
local bit = require "syscall.bit"
local abi, types, c = S.abi, S.types, S.c
local t, pt, s = types.t, types.pt, types.s
local mt, meth = {}, {}
local util = require("syscall." .. abi.os .. ".util").init(S)
mt.dir = {
__tostring = function(t)
if #t == 0 then return "" end
table.sort(t)
return table.concat(t, "\n") .. "\n"
end
}
function util.dirtable(name, nodots) -- return table of directory entries, remove . and .. if nodots true
local d = {}
local size = 4096
local buf = t.buffer(size)
local iter, err = util.ls(name, buf, size)
if not iter then return nil, err end
for f in iter do
if not (nodots and (f == "." or f == "..")) then d[#d + 1] = f end
end
return setmetatable(d, mt.dir)
end
-- this returns an iterator over multiple calls to getdents TODO add nodots?
-- note how errors work, getdents will throw as called multiple times, but normally should not fail if open succeeds
-- getdents can fail eg on nfs though.
function util.ls(name, buf, size)
size = size or 4096
buf = buf or t.buffer(size)
if not name then name = "." end
local fd, err = S.open(name, "directory, rdonly")
if err then return nil, err end
local di
return function()
local d, first
repeat
if not di then
local err
di, err = fd:getdents(buf, size)
if not di then
fd:close()
error(err)
end
first = true
end
d = di()
if not d then di = nil end
if not d and first then return nil end
until d
return d.name, d
end
end
-- recursive rm TODO use ls iterator, which also returns type
local function rmhelper(file, prefix)
local name
if prefix then name = prefix .. "/" .. file else name = file end
local st, err = S.lstat(name)
if not st then return nil, err end
if st.isdir then
local files, err = util.dirtable(name, true)
if not files then return nil, err end
for _, f in pairs(files) do
local ok, err = rmhelper(f, name)
if not ok then return nil, err end
end
local ok, err = S.rmdir(name)
if not ok then return nil, err end
else
local ok, err = S.unlink(name)
if not ok then return nil, err end
end
return true
end
function util.rm(...)
for _, f in ipairs{...} do
local ok, err = rmhelper(f)
if not ok then return nil, err end
end
return true
end
-- TODO warning broken
function util.cp(source, dest, mode) -- TODO make much more functional, less broken, esp fix mode! and size issue!!
local contents, err = util.readfile(source)
if not contents then return nil, err end
local ok, err = util.writefile(dest, contents, mode)
if not ok then return nil, err end
return true
end
function util.touch(file)
local fd, err = S.open(file, "wronly,creat,noctty,nonblock", "0666")
if not fd then return nil, err end
local fd2, err = S.dup(fd)
if not fd2 then
fd2:close()
return nil, err
end
fd:close()
local ok, err = S.futimes(fd2)
fd2:close()
if not ok then return nil, err end
return true
end
function util.createfile(file) -- touch without timestamp adjustment
local fd, err = S.open(file, "wronly,creat,noctty,nonblock", "0666")
if not fd then return nil, err end
local ok, err = fd:close()
if not ok then return nil, err end
return true
end
function util.mapfile(name) -- generally better to use, but no good for sysfs etc
local fd, err = S.open(name, "rdonly")
if not fd then return nil, err end
local st, err = S.fstat(fd)
if not st then return nil, err end
local size = st.size
local m, err = S.mmap(nil, size, "read", "shared", fd, 0)
if not m then return nil, err end
local str = ffi.string(m, size)
local ok, err = S.munmap(m, size)
if not ok then return nil, err end
local ok, err = fd:close()
if not ok then return nil, err end
return str
end
-- TODO fix short reads, but mainly used for sysfs, proc
function util.readfile(name, buffer, length)
local fd, err = S.open(name, "rdonly")
if not fd then return nil, err end
local r, err = S.read(fd, buffer, length or 4096)
if not r then return nil, err end
local ok, err = fd:close()
if not ok then return nil, err end
return r
end
-- write string to named file; silently ignore short writes TODO fix
function util.writefile(name, str, mode, flags)
local fd, err
if mode then fd, err = S.creat(name, mode) else fd, err = S.open(name, flags or "wronly") end
if not fd then return nil, err end
local n, err = S.write(fd, str)
if not n then return nil, err end
local ok, err = fd:close()
if not ok then return nil, err end
return true
end
mt.ps = {
__tostring = function(ps)
local s = {}
for i = 1, #ps do
s[#s + 1] = tostring(ps[i])
end
return table.concat(s, '\n')
end
}
-- note that Linux and NetBSD have /proc but FreeBSD does not usually have it mounted, although it is an option
function util.ps()
local ls, err = util.dirtable("/proc")
if not ls then return nil, err end
local ps = {}
for i = 1, #ls do
if not string.match(ls[i], '[^%d]') then
local p = util.proc(tonumber(ls[i]))
if p then ps[#ps + 1] = p end
end
end
table.sort(ps, function(a, b) return a.pid < b.pid end)
return setmetatable(ps, mt.ps)
end
mt.proc = {
__index = function(p, k)
local name = p.dir .. k
local st, err = S.lstat(name)
if not st then return nil, err end
if st.isreg then
local fd, err = S.open(p.dir .. k, "rdonly")
if not fd then return nil, err end
local ret, err = S.read(fd) -- read defaults to 4k, sufficient?
if not ret then return nil, err end
S.close(fd)
return ret -- TODO many could usefully do with some parsing
end
if st.islnk then
local ret, err = S.readlink(name)
if not ret then return nil, err end
return ret
end
-- TODO directories
end,
__tostring = function(p) -- TODO decide what to print
local c = p.cmdline
if c then
if #c == 0 then
local comm = p.comm
if comm and #comm > 0 then
c = '[' .. comm:sub(1, -2) .. ']'
end
end
return p.pid .. ' ' .. c
end
end
}
function util.proc(pid)
if not pid then pid = S.getpid() end
return setmetatable({pid = pid, dir = "/proc/" .. pid .. "/"}, mt.proc)
end
-- receive cmsg, extended helper on recvmsg, fairly incomplete at present
function util.recvcmsg(fd, msg, flags)
if not msg then
local buf1 = t.buffer(1) -- assume user wants to receive single byte to get cmsg
local io = t.iovecs{{buf1, 1}}
local bufsize = 1024 -- sane default, build your own structure otherwise
local buf = t.buffer(bufsize)
msg = t.msghdr{iov = io, msg_control = buf, msg_controllen = bufsize}
end
local count, err = S.recvmsg(fd, msg, flags)
if not count then return nil, err end
local ret = {count = count, iovec = msg.msg_iov} -- thats the basic return value, and the iovec
for mc, cmsg in msg:cmsgs() do
local pid, uid, gid = cmsg:credentials()
if pid then
ret.pid = pid
ret.uid = uid
ret.gid = gid
end
local fd_array = {}
for fd in cmsg:fds() do
fd_array[#fd_array + 1] = fd
end
ret.fd = fd_array
end
return ret
end
function util.sendfds(fd, ...)
local buf1 = t.buffer(1) -- need to send one byte
local io = t.iovecs{{buf1, 1}}
local cmsg = t.cmsghdr("socket", "rights", {...})
local msg = t.msghdr{iov = io, control = cmsg}
return S.sendmsg(fd, msg, 0)
end
-- generic inet name to ip, also with netmask support
-- TODO convert to a type? either way should not really be in util, probably helpers
-- better as a type that returns inet, mask
function util.inet_name(src, netmask)
local addr
if not netmask then
local a, b = src:find("/", 1, true)
if a then
netmask = tonumber(src:sub(b + 1))
src = src:sub(1, a - 1)
end
end
if src:find(":", 1, true) then -- ipv6
addr = t.in6_addr(src)
if not addr then return nil end
if not netmask then netmask = 128 end
else
addr = t.in_addr(src)
if not addr then return nil end
if not netmask then netmask = 32 end
end
return addr, netmask
end
local function lastslash(name)
local ls
local i = 0
while true do
i = string.find(name, "/", i + 1)
if not i then return ls end
ls = i
end
end
local function deltrailslash(name)
while name:sub(#name) == "/" do
name = string.sub(name, 1, #name - 1)
end
return name
end
function util.basename(name)
if name == "" then return "." end
name = deltrailslash(name)
if name == "" then return "/" end -- was / or // etc
local ls = lastslash(name)
if not ls then return name end
return string.sub(name, ls + 1)
end
function util.dirname(name)
if name == "" then return "." end
name = deltrailslash(name)
if name == "" then return "/" end -- was / or // etc
local ls = lastslash(name)
if not ls then return "." end
name = string.sub(name, 1, ls - 1)
name = deltrailslash(name)
if name == "" then return "/" end -- was / or // etc
return name
end
return util
end
return {init = init}
| apache-2.0 |
trilastiko/keys | VSCOKeys.lrdevplugin/DevelopSettings.lua | 11 | 8424 | --[[----------------------------------------------------------------------------
VSCO Keys for Adobe Lightroom
Copyright (C) 2015 Visual Supply Company
Licensed under GNU GPLv2 (or any later version).
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
------------------------------------------------------------------------------]]
local set = {}
set.WhiteBalance = {name = "White Balance"}
set.Exposure2012 = {name = "Exposure", min = -5, max = 5}
set.Exposure = {name = "Exposure", maxVersion = 3, min = -4, max = 4}
set.IncrementalTemperature = {name = "Temperature", min = -100, max = 100} -- Settings for jpgs
set.IncrementalTint = {name = "Tint", min = -100, max = 100} -- Settings for jpgs
set.Temperature = {name = "Temperature", min = 2000, max = 50000} -- Settings for raw
set.Tint = {name = "Tint", min = -150, max = 150} -- Settings for raw
set.Shadows2012 = {name = "Shadows", min = -100, max = 100}
set.FillLight = {name = "Fill Light", maxVersion = 3, min = 0, max = 100}
set.Highlights2012 = {name = "Highlights", min = -100, max = 100}
set.HighlightRecovery = {name = "Highlight Recovery", maxVersion = 3, min = 0, max = 100}
set.Contrast2012 = {name = "Contrast", min = -100, max = 100}
set.Contrast = {name = "Contrast", maxVersion = 3, min = -50, max = 100}
set.Saturation = {name = "Saturation", min = -100, max = 100}
set.Blacks2012 = {name = "Blacks", min = -100, max = 100}
set.Shadows = {name = "Black Clipping", maxVersion = 3, min = 0, max = 100}
set.Whites2012 = {name = "Whites", min = -100, max = 100}
set.Brightness = {name = "Brightness", maxVersion = 3, min = 0, max = 100}
set.Vibrance = {name = "Vibrance", min = -100, max = 100}
set.Clarity2012 = {name = "Clarity", min = -100, max = 100}
set.Clarity = {name = "Clarity", maxVersion = 3, min = -100, max = 100}
set.Sharpness = {name = "Sharpness", min = 0, max = 150}
set.SharpenRadius = {name = "SharpenRadius", min = 0.5, max = 3.0}
set.SharpenDetail = {name = "SharpenDetail", min = 0, max = 100}
set.SharpenEdgeMasking = {name = "SharpenEdgeMasking", min = 0, max = 100}
set.LuminanceSmoothing = {name = "LuminanceSmoothing", min = 0, max = 100}
set.LuminanceNoiseReductionDetail = {name = "LuminanceNoiseReductionDetail", min = 0, max = 100}
set.LuminanceNoiseReductionContrast = {name = "LuminanceNoiseReductionContrast", min = 0, max = 100}
set.ColorNoiseReduction = {name = "ColorNoiseReduction", min = 0, max = 100}
set.ColorNoiseReductionDetail = {name = "ColorNoiseReductionDetail", min = 0, max = 100}
set.ParametricDarks = {name = "Dark Tones", min = -100, max = 100}
set.ParametricLights = {name = "Light Tones", min = -100, max = 100}
set.ParametricShadows = {name = "Shadow Tones", min = -100, max = 100}
set.ParametricHighlights = {name = "Highlight Tones", min = -100, max = 100}
set.ParametricHighlightSplit = {name = "Highlight Split", min = 30, max = 90}
set.ParametricMidtoneSplit = {name = "Midtone Split", min = 20, max = 80}
set.ParametricShadowSplit = {name = "Shadow Split", min = 10, max = 70}
set.HueAdjustmentRed = {name = "Red Hue Shift", min = -100, max = 100}
set.HueAdjustmentOrange = {name = "Orange Hue Shift", min = -100, max = 100}
set.HueAdjustmentYellow = {name = "Yellow Hue Shift", min = -100, max = 100}
set.HueAdjustmentGreen = {name = "Green Hue Shift", min = -100, max = 100}
set.HueAdjustmentAqua = {name = "Aqua Hue Shift", min = -100, max = 100}
set.HueAdjustmentBlue = {name = "Blue Hue Shift", min = -100, max = 100}
set.HueAdjustmentPurple = {name = "Purple Hue Shift", min = -100, max = 100}
set.HueAdjustmentMagenta = {name = "Magenta Hue Shift", min = -100, max = 100}
set.SaturationAdjustmentRed = {name = "Red Saturation Shift", min = -100, max = 100}
set.SaturationAdjustmentOrange = {name = "Orange Saturation Shift", min = -100, max = 100}
set.SaturationAdjustmentYellow = {name = "Yellow Saturation Shift", min = -100, max = 100}
set.SaturationAdjustmentGreen = {name = "Green Saturation Shift", min = -100, max = 100}
set.SaturationAdjustmentAqua = {name = "Aqua Saturation Shift", min = -100, max = 100}
set.SaturationAdjustmentBlue = {name = "Blue Saturation Shift", min = -100, max = 100}
set.SaturationAdjustmentPurple = {name = "Purple Saturation Shift", min = -100, max = 100}
set.SaturationAdjustmentMagenta = {name = "Magenta Saturation Shift", min = -100, max = 100}
set.LuminanceAdjustmentRed = {name = "Red Luminance Shift", min = -100, max = 100}
set.LuminanceAdjustmentOrange = {name = "Orange Luminance Shift", min = -100, max = 100}
set.LuminanceAdjustmentYellow = {name = "Yellow Luminance Shift", min = -100, max = 100}
set.LuminanceAdjustmentGreen = {name = "Green Luminance Shift", min = -100, max = 100}
set.LuminanceAdjustmentAqua = {name = "Aqua Luminance Shift", min = -100, max = 100}
set.LuminanceAdjustmentBlue = {name = "Blue Luminance Shift", min = -100, max = 100}
set.LuminanceAdjustmentPurple = {name = "Purple Luminance Shift", min = -100, max = 100}
set.LuminanceAdjustmentMagenta = {name = "Magenta Luminance Shift", min = -100, max = 100}
set.GrainAmount = {name = "Grain Amount", min = 0, max = 100}
set.GrainSize = {name = "Grain Size", min = 0, max = 100}
set.GrainFrequency = {name = "Grain Roughness", min = 0, max = 100}
set.PostCropVignetteAmount = {name = "P-C Vignette Amount", min = -100, max = 100}
set.PostCropVignetteMidpoint = {name = "P-C Vignette Midpoint", min = 0, max = 100}
set.PostCropVignetteRoundness = {name = "P-C Vignette Roundness", min = -100, max = 100}
set.PostCropVignetteFeather = {name = "P-C Vignette Feather", min = 0, max = 100}
set.PostCropVignetteHighlightContrast = {name = "P-C Vignette Highlights", min = 0, max = 100}
set.SplitToningBalance = {name = "Split Toning Balance", min = -100, max = 100}
set.SplitToningHighlightHue = {name = "Highlight Hue", min = 0, max = 360}
set.SplitToningHighlightSaturation = {name = "Highlight Saturation", min = 0, max = 100}
set.SplitToningShadowHue = {name = "Shadow Hue", min = 0, max = 360}
set.SplitToningShadowSaturation = {name = "Shadow Saturation", min = 0, max = 100}
set.ShadowTint = {name = "Calibration Shadow Tint", min = -100, max = 100}
set.RedHue = {name = "Calibration Red Hue", min = -100, max = 100}
set.RedSaturation = {name = "Calibration Red Sat", min = -100, max = 100}
set.GreenHue = {name = "Calibration Green Hue", min = -100, max = 100}
set.GreenSaturation = {name = "Calibration Green Sat", min = -100, max = 100}
set.BlueHue = {name = "Calibration Blue Hue", min = -100, max = 100}
set.BlueSaturation = {name = "Calibration Blue Sat", min = -100, max = 100}
set.LensManualDistortionAmount = {name = "Distortion Amount", min = -100, max = 100}
set.PerspectiveVertical = {name = "Vertical Perspective", min = -100, max = 100}
set.PerspectiveHorizontal = {name = "Horizontal Perspective", min = -100, max = 100}
set.PerspectiveRotate = {name = "Perspective Rotate", min = -10, max = 10}
set.PerspectiveScale = {name = "Perspective Rotate", min = 50, max = 150}
set.VignetteAmount = {name = "Vignette Amount", min = -100, max = 100}
set.VignetteMidpoint = {name = "Vignette Midpoint", min = 0, max = 100}
set.DefringePurpleAmount = {name = "Purple Defringe Amount", min = 0, max = 20}
set.DefringePurpleHueLo = {name = "Purple Defringe Hue Lo", min = 0, max = 100}
set.DefringePurpleHueHi = {name = "Purple Defringe Hue Hi", min = 0, max = 100}
set.DefringeGreenAmount = {name = "Green Defringe Amount", min = 0, max = 20}
set.DefringeGreenHueLo = {name = "Green Defringe Hue Lo", min = 0, max = 100}
set.DefringeGreenHueHi = {name = "Green Defringe Hue Hi", min = 0, max = 100}
set.ChromaticAberrationB = {name = "Blue Chromatic Aberration", maxVersion = 3, min = -100, max = 100}
set.ChromaticAberrationR = {name = "Red Chromatic Aberration", maxVersion = 3, min = -100, max = 100}
return set | gpl-2.0 |
nesstea/darkstar | scripts/globals/abilities/pets/inferno.lua | 34 | 1111 | ---------------------------------------------------
-- Inferno
---------------------------------------------------
require("/scripts/globals/settings");
require("/scripts/globals/status");
require("/scripts/globals/monstertpmoves");
require("/scripts/globals/magic");
---------------------------------------------------
function onAbilityCheck(player, target, ability)
local level = player:getMainLvl() * 2;
if(player:getMP()<level) then
return 87,0;
end
return 0,0;
end;
function onPetAbility(target, pet, skill, master)
local dINT = math.floor(pet:getStat(MOD_INT) - target:getStat(MOD_INT));
local level = pet:getMainLvl()
local damage = 48 + (level * 8);
damage = damage + (dINT * 1.5);
damage = MobMagicalMove(pet,target,skill,damage,ELE_FIRE,1,TP_NO_EFFECT,0);
damage = mobAddBonuses(pet, nil, target, damage.dmg, ELE_FIRE);
damage = AvatarFinalAdjustments(damage,pet,skill,target,MOBSKILL_MAGICAL,MOBPARAM_NONE,1);
master:setMP(0);
target:delHP(damage);
target:updateEnmityFromDamage(pet,damage);
return damage;
end | gpl-3.0 |
heyuqi/wxFormBuilder | build/premake/utilities.lua | 4 | 2219 | -----------------------------------------------------------------------------
-- Name: utilities.lua
-- Purpose: Directories creation for local builds, Linux install script.
-- Based on original Premake 3 script
-- Author: Andrea Zanellato
-- Modified by:
-- Created:
-- Copyright: (c) wxFormBuilder Team
-- Licence: GNU General Public License Version 2
-----------------------------------------------------------------------------
function CreateShareReadme( filename )
local text =
"This directory and the symlink it contains were created automatically by premake\n" ..
"to facilitate execution of wxFormBuilder prior to installation on Unix platforms.\n" ..
"On Unix, wxFormBuilder expects to be executed from a directory named \"output\",\n" ..
"which is next to a directory named \"share\". The \"share\" directory should have a\n" ..
"subdirectory named \"wxformbuilder\", which contains the configuration files."
if ( not os.isfile( filename ) ) then
local fo = io.open( filename, "w" )
fo:write( text )
fo:close()
end
end
function CreateSymlink( pathToLink, symLink )
os.execute( "ln -s -f -n " .. pathToLink .. " " .. symLink )
end
if ( not os.is("windows") ) then
newoption {
trigger = "skip-symlink",
description = "Do not create the symlink output/share/wxformbuilder"
}
if ( not _OPTIONS["skip-symlink"] ) then
print( "Running pre-build file creation steps..." )
-- Create a 'share' directory.
-- HACK: make sure the warning isn't shown on the console.
os.execute( "mkdir ../../output/share >/dev/null 2>/dev/null" )
CreateShareReadme( "../../output/share/README.txt" )
CreateSymlink( "../../output", "../../output/share/wxformbuilder" )
end
end
if ( os.is("linux") ) then
newoption {
trigger = "install",
description = "Copy the application to the specified path"
}
function doinstall(cmd, arg)
if ( not arg ) then
error("You must specify an install location")
end
os.execute( "../../install/linux/wxfb_export.sh " .. arg )
end
end
| gpl-2.0 |
FailcoderAddons/supervillain-ui | SVUI_UnitFrames/libs/Plugins/oUF_CombatFader/oUF_CombatFader.lua | 3 | 4341 | --GLOBAL NAMESPACE
local _G = _G;
--LUA
local unpack = _G.unpack;
local select = _G.select;
local assert = _G.assert;
local error = _G.error;
local print = _G.print;
local pairs = _G.pairs;
local next = _G.next;
local tostring = _G.tostring;
local type = _G.type;
--BLIZZARD API
local InCombatLockdown = _G.InCombatLockdown;
local UnitHealth = _G.UnitHealth;
local UnitExists = _G.UnitExists;
local UnitHealthMax = _G.UnitHealthMax;
local UnitCastingInfo = _G.UnitCastingInfo;
local UnitChannelInfo = _G.UnitChannelInfo;
local parent, ns = ...
local oUF = ns.oUF
local frames, allFrames = {}, {}
local showStatus
local CheckForReset = function()
for frame, unit in pairs(allFrames) do
if frame.___fadereset then
frame:SetAlpha(1)
frame.___fadereset = nil
end
end
end
local FadeFramesInOut = function(fade, unit)
for frame, unit in pairs(frames) do
if not UnitExists(unit) then return end
if fade then
if(frame:GetAlpha() ~= 1 or (frame.___fadeset and frame.___fadeset[2] == 0)) then
frame:FadeIn(0.15)
end
else
if frame:GetAlpha() ~= 0 then
frame:FadeOut(0.15)
frame:FadeCallback(CheckForReset)
else
showStatus = false;
return
end
end
end
if unit == 'player' then
showStatus = fade
end
end
local Update = function(self, arg1, arg2)
if arg1 == "UNIT_HEALTH" and self and self.unit ~= arg2 then return end
if type(arg1) == 'boolean' and not frames[self] then return end
if(not frames[self]) then
self:FadeIn(0.15)
self.___fadereset = true
return
end
local combat = InCombatLockdown()
local cur, max = UnitHealth("player"), UnitHealthMax("player")
local cast, channel = UnitCastingInfo("player"), UnitChannelInfo("player")
local target, focus = UnitExists("target"), UnitExists("focus")
if (cast or channel) and showStatus ~= true then
FadeFramesInOut(true, frames[self])
elseif cur ~= max and showStatus ~= true then
FadeFramesInOut(true, frames[self])
elseif (target or focus) and showStatus ~= true then
FadeFramesInOut(true, frames[self])
elseif arg1 == true and showStatus ~= true then
FadeFramesInOut(true, frames[self])
else
if combat and showStatus ~= true then
FadeFramesInOut(true, frames[self])
elseif not target and not combat and not focus and (cur == max) and not (cast or channel) then
FadeFramesInOut(false, frames[self])
end
end
end
local Enable = function(self, unit)
if(self.CombatFade) then
frames[self] = self.unit
allFrames[self] = self.unit
if unit == 'player' then
showStatus = false;
end
self:RegisterEvent("PLAYER_ENTERING_WORLD", Update)
self:RegisterEvent("PLAYER_REGEN_ENABLED", Update)
self:RegisterEvent("PLAYER_REGEN_DISABLED", Update)
self:RegisterEvent("PLAYER_TARGET_CHANGED", Update)
self:RegisterEvent("PLAYER_FOCUS_CHANGED", Update)
self:RegisterEvent("UNIT_HEALTH", Update)
self:RegisterEvent("UNIT_SPELLCAST_START", Update)
self:RegisterEvent("UNIT_SPELLCAST_STOP", Update)
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START", Update)
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP", Update)
self:RegisterEvent("UNIT_PORTRAIT_UPDATE", Update)
self:RegisterEvent("UNIT_MODEL_CHANGED", Update)
if not self.CombatFadeHooked then
self:HookScript("OnEnter", function(self) Update(self, true) end)
self:HookScript("OnLeave", function(self) Update(self, false) end)
self.CombatFadeHooked = true
end
return true
end
end
local Disable = function(self)
if(self.CombatFade) then
frames[self] = nil
Update(self)
self:UnregisterEvent("PLAYER_ENTERING_WORLD", Update)
self:UnregisterEvent("PLAYER_REGEN_ENABLED", Update)
self:UnregisterEvent("PLAYER_REGEN_DISABLED", Update)
self:UnregisterEvent("PLAYER_TARGET_CHANGED", Update)
self:UnregisterEvent("PLAYER_FOCUS_CHANGED", Update)
self:UnregisterEvent("UNIT_HEALTH", Update)
self:UnregisterEvent("UNIT_SPELLCAST_START", Update)
self:UnregisterEvent("UNIT_SPELLCAST_STOP", Update)
self:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_START", Update)
self:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_STOP", Update)
self:UnregisterEvent("UNIT_PORTRAIT_UPDATE", Update)
self:UnregisterEvent("UNIT_MODEL_CHANGED", Update)
end
end
oUF:AddElement('CombatFade', Update, Enable, Disable) | mit |
Shopify/goluago | tst/encoding/json/json_test.lua | 1 | 2367 | local json = require "goluago/encoding/json"
equals("unmarshal: can decode empty object", {}, json.unmarshal("{}"))
equals("unmarshal: can decode empty array", array({}), json.unmarshal("[]"))
equals("unmarshal: can decode null", nil, json.unmarshal("null"))
equals("unmarshal: can decode array with null", array({ nil }), json.unmarshal("[null]"))
equals("marshal: can encode empty object", "{}", json.marshal({}))
equals("marshal: can encode null", "null", json.marshal(nil))
equals("marshal: can encode floats", "{\"foo\":1.01}", json.marshal({ foo = 1.01 }))
-- Valid case
local payload = [=[
{
"key1":1,
"key2":"val2",
"key3":["arrKey", 2, true, false, {}, []],
"key4": {
"subkey1":1,
"subkey2":"val2",
"subkey3":["arrKey", 2, true, false, {}, []],
"subkey4": {
"subsubkey1":1,
"subsubkey2":"val2",
"subsubkey3":["arrKey", 2, true, false, {}, []]
}
},
"key5": null,
"key6": [1, null, 2, null],
"key7": true
}
]=]
local want = {}
want["key1"]=1
want["key2"]="val2"
want["key3"]=array({"arrKey", 2, true, false, {}, array({})})
want["key4"]={}
want["key4"]["subkey1"]=1
want["key4"]["subkey2"]="val2"
want["key4"]["subkey3"]=array({"arrKey", 2, true, false, {}, array({})})
want["key4"]["subkey4"]={}
want["key4"]["subkey4"]["subsubkey1"]=1
want["key4"]["subkey4"]["subsubkey2"]="val2"
want["key4"]["subkey4"]["subsubkey3"]=array({"arrKey", 2, true, false, {}, array({})})
want["key5"]=nil
want["key6"]=array({1, nil, 2, nil})
want["key7"]=true
equals("unmarshal: can decode sample JSON", want, json.unmarshal(payload))
-- Real use case
local payload = [=[{
"stuff":"name='updates[1234]'",
"targetURL":"http://127.0.0.1:7070/targeturl",
"complete":true
}]=]
local want = {stuff="name='updates[1234]'", targetURL="http://127.0.0.1:7070/targeturl", complete=true}
local got = json.unmarshal(payload)
equals("unmarshal: can decode real use case JSON", want, got)
istrue("unmarshal: true values should be true", got.complete)
equals("marshal: can roundtrip real use case JSON", want, json.unmarshal(json.marshal(got)))
-- Error case
local trailingComma = [=[
{
"i have": "i trailing comma",
}
]=]
local got, gotErr = pcall(function ()
return json.unmarshal(trailingComma)
end)
istrue("unmarshal: invalid JSON throws an error", gotErr)
isfalse("unmarshal: invalid JSON decodes a nil value", got)
| mit |
nesstea/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/Mushayra.lua | 13 | 1049 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Mushayra
-- Type: Standard NPC
-- @pos -111.551 -6.999 -61.720 50
-----------------------------------
package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x0207);
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 |
Cyumus/NutScript | gamemode/core/derma/cl_contextmenu.lua | 5 | 6394 |
local PANEL = {}
AccessorFunc( PANEL, "m_bHangOpen", "HangOpen" )
function PANEL:Init()
--
-- This makes it so that when you're hovering over this panel
-- you can `click` on the world. Your viewmodel will aim etc.
--
self:SetWorldClicker( true )
self.Canvas = vgui.Create( "DCategoryList", self )
self.m_bHangOpen = false
--self.Canvas:EnableVerticalScrollbar( true )
--self.Canvas:SetSpacing( 0 )
--self.Canvas:SetPadding( 5 )
--self.Canvas:SetDrawBackground( false )
end
function PANEL:Open()
self:SetHangOpen( false )
-- If the spawn menu is open, try to close it..
if ( g_SpawnMenu:IsVisible() ) then
g_SpawnMenu:Close( true )
end
if ( self:IsVisible() ) then return end
CloseDermaMenus()
self:MakePopup()
self:SetVisible( true )
self:SetKeyboardInputEnabled( false )
self:SetMouseInputEnabled( true )
RestoreCursorPosition()
local bShouldShow = true;
-- TODO: Any situation in which we shouldn't show the tool menu on the context menu?
-- Set up the active panel..
if ( bShouldShow && IsValid( spawnmenu.ActiveControlPanel() ) ) then
self.OldParent = spawnmenu.ActiveControlPanel():GetParent()
self.OldPosX, self.OldPosY = spawnmenu.ActiveControlPanel():GetPos()
spawnmenu.ActiveControlPanel():SetParent( self )
self.Canvas:Clear()
self.Canvas:AddItem( spawnmenu.ActiveControlPanel() )
self.Canvas:Rebuild()
self.Canvas:SetVisible( true )
else
self.Canvas:SetVisible( false )
end
self:InvalidateLayout( true )
end
function PANEL:Close( bSkipAnim )
if ( self:GetHangOpen() ) then
self:SetHangOpen( false )
return
end
RememberCursorPosition()
CloseDermaMenus()
self:SetKeyboardInputEnabled( false )
self:SetMouseInputEnabled( false )
self:SetAlpha( 255 )
self:SetVisible( false )
self:RestoreControlPanel()
end
function PANEL:PerformLayout()
self:SetPos( 0, -32 )
self:SetSize( ScrW(), ScrH() )
self.Canvas:SetWide( 311 )
self.Canvas:SetPos( ScrW() - self.Canvas:GetWide() - 50, self.y )
if ( IsValid( spawnmenu.ActiveControlPanel() ) ) then
spawnmenu.ActiveControlPanel():InvalidateLayout( true )
local Tall = spawnmenu.ActiveControlPanel():GetTall() + 10
local MaxTall = ScrH() * 0.8
if ( Tall > MaxTall ) then Tall = MaxTall end
self.Canvas:SetTall( Tall )
self.Canvas.y = ScrH() - 50 - Tall
end
self.Canvas:InvalidateLayout( true )
end
function PANEL:StartKeyFocus( pPanel )
self:SetKeyboardInputEnabled( true )
self:SetHangOpen( true )
end
function PANEL:EndKeyFocus( pPanel )
self:SetKeyboardInputEnabled( false )
end
function PANEL:RestoreControlPanel()
-- Restore the active panel
if ( !spawnmenu.ActiveControlPanel() ) then return end
if ( !self.OldParent ) then return end
spawnmenu.ActiveControlPanel():SetParent( self.OldParent )
spawnmenu.ActiveControlPanel():SetPos( self.OldPosX, self.OldPosY )
self.OldParent = nil
end
--
-- Note here: EditablePanel is important! Child panels won't be able to get
-- keyboard input if it's a DPanel or a Panel. You need to either have an EditablePanel
-- or a DFrame (which is derived from EditablePanel) as your first panel attached to the system.
--
vgui.Register( "ContextMenu", PANEL, "EditablePanel" )
function CreateContextMenu()
if ( IsValid( g_ContextMenu ) ) then
g_ContextMenu:Remove()
g_ContextMenu = nil
end
g_ContextMenu = vgui.Create( "ContextMenu" )
g_ContextMenu:SetVisible( false )
--
-- We're blocking clicks to the world - but we don't want to
-- so feed clicks to the proper functions..
--
g_ContextMenu.OnMousePressed = function( p, code )
hook.Run( "GUIMousePressed", code, gui.ScreenToVector( gui.MousePos() ) )
end
g_ContextMenu.OnMouseReleased = function( p, code )
hook.Run( "GUIMouseReleased", code, gui.ScreenToVector( gui.MousePos() ) )
end
hook.Run( "ContextMenuCreated", g_ContextMenu )
local IconLayout = g_ContextMenu:Add( "DIconLayout" )
IconLayout:Dock( LEFT )
IconLayout:SetWorldClicker( true )
IconLayout:SetBorder( 8 )
IconLayout:SetSpaceX( 8 )
IconLayout:SetSpaceY( 8 )
IconLayout:SetWide( 200 )
IconLayout:SetLayoutDir( LEFT )
for k, v in pairs( list.Get( "DesktopWindows" ) ) do
local icon = IconLayout:Add( "DButton" )
icon:SetText( "" )
icon:SetSize( 80, 82 )
icon.Paint = function()end
local label = icon:Add( "DLabel" )
label:Dock( BOTTOM )
label:SetText( v.title )
label:SetContentAlignment( 5 )
label:SetTextColor( Color( 255, 255, 255, 255 ) )
label:SetExpensiveShadow( 1, Color( 0, 0, 0, 200 ) )
local image = icon:Add( "DImage" )
image:SetImage( v.icon )
image:SetSize( 64, 64 )
image:Dock( TOP )
image:DockMargin( 8, 0, 8, 0 )
icon.DoClick = function()
--
-- v might have changed using autorefresh so grab it again
--
local newv = list.Get( "DesktopWindows" )[ k ]
if ( v.onewindow ) then
if ( IsValid( icon.Window ) ) then icon.Window:Center() return end
end
-- Make the window
icon.Window = g_ContextMenu:Add( "DFrame" )
icon.Window:SetSize( newv.width, newv.height )
icon.Window:SetTitle( newv.title )
icon.Window:Center()
newv.init( icon, icon.Window )
end
end
end
function GM:OnContextMenuOpen()
-- Let the gamemode decide whether we should open or not..
if ( !hook.Call( "ContextMenuOpen", GAMEMODE ) ) then return end
if ( IsValid( g_ContextMenu ) && !g_ContextMenu:IsVisible() ) then
g_ContextMenu:Open()
vgui.Create("nutQuick")
menubar.ParentTo( g_ContextMenu )
end
end
function GM:OnContextMenuClose()
if ( IsValid( g_ContextMenu ) ) then
g_ContextMenu:Close()
end
if (IsValid(nut.gui.quick)) then
nut.gui.quick:Remove()
end
end
DMenuBar.AddMenu = function( self, label )
local m = DermaMenu()
m:SetDeleteSelf( false )
m:SetDrawColumn( true )
m:Hide()
self.Menus[ label ] = m
local b = self:Add( "DButton" )
b:SetText( label )
b:Dock( LEFT )
b:SetTextColor(color_black)
b:DockMargin( 5, 0, 0, 0 )
b:SetIsMenu( true )
b:SetDrawBackground( false )
b:SizeToContentsX( 16 )
b.DoClick = function()
if ( m:IsVisible() ) then
m:Hide()
return
end
local x, y = b:LocalToScreen( 0, 0 )
m:Open( x, y + b:GetTall(), false, b )
end
b.OnCursorEntered = function()
local opened = self:GetOpenMenu()
if ( !IsValid( opened ) || opened == m ) then return end
opened:Hide()
b:DoClick()
end
return m
end | mit |
nesstea/darkstar | scripts/globals/spells/blind_ii.lua | 21 | 1748 | -----------------------------------------
-- Spell: Blind II
-- caster:getMerit() returns a value which is equal to the number of merit points TIMES the value of each point
-- Blind II value per point is '1' This is a constant set in the table 'merits'
-----------------------------------------
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
local merits = caster:getMerit(MERIT_BLIND_II);
-- Pull base stats.
local dINT = (caster:getStat(MOD_INT) - target:getStat(MOD_MND)); --blind uses caster INT vs target MND
-- Base power. May need more research.
local power = math.floor((dINT + 100) / 4);
if (power < 15) then
power = 15;
end
if (power > 30) then
power = 30;
end
if (caster:hasStatusEffect(EFFECT_SABOTEUR)) then
power = power * 2;
end
power = power + merits; --similar to Slow II, merit potency bonus is added after the cap
-- Duration, including resistance. Unconfirmed.
local duration = 180 * applyResistanceEffect(caster,spell,target,dINT,35,merits*2,EFFECT_BLINDNESS);
if (duration >= 90) then --Do it!
if (caster:hasStatusEffect(EFFECT_SABOTEUR)) then
duration = duration * 2;
end
caster:delStatusEffect(EFFECT_SABOTEUR);
if (target:addStatusEffect(EFFECT_BLINDNESS,power,0,duration)) then
spell:setMsg(236);
else
spell:setMsg(75);
end
else
spell:setMsg(85);
end
return EFFECT_BLINDNESS;
end;
| gpl-3.0 |
Mashape/kong | spec/03-plugins/21-bot-detection/02-invalidations_spec.lua | 2 | 3413 | local helpers = require "spec.helpers"
for _, strategy in helpers.each_strategy() do
describe("Plugin: bot-detection (hooks) [#" .. strategy .. "]", function()
local plugin
local proxy_client
local admin_client
lazy_setup(function()
local bp = helpers.get_db_utils(strategy, {
"routes",
"services",
"plugins",
})
local route = bp.routes:insert {
hosts = { "bot.com" },
}
plugin = bp.plugins:insert {
route = { id = route.id },
name = "bot-detection",
config = {},
}
assert(helpers.start_kong({
database = strategy,
nginx_conf = "spec/fixtures/custom_nginx.template",
}))
end)
lazy_teardown(function()
helpers.stop_kong()
end)
before_each(function()
proxy_client = helpers.proxy_client()
admin_client = helpers.admin_client()
end)
after_each(function()
if proxy_client then
proxy_client:close()
end
if admin_client then
admin_client:close()
end
end)
it("blocks a newly entered user-agent", function()
local res = assert( proxy_client:send {
method = "GET",
path = "/request",
headers = {
host = "bot.com",
["user-agent"] = "helloworld"
}
})
assert.response(res).has.status(200)
-- Update the plugin
res = assert(admin_client:send {
method = "PATCH",
path = "/plugins/" .. plugin.id,
body = {
config = { blacklist = { "helloworld" } },
},
headers = {
["content-type"] = "application/json"
}
})
assert.response(res).has.status(200)
local check_status = function()
local res = assert(proxy_client:send {
mehod = "GET",
path = "/request",
headers = {
host = "bot.com",
["user-agent"] = "helloworld",
},
})
res:read_body() -- must call read_body to complete call, otherwise next iteration fails
return res.status == 403
end
helpers.wait_until(check_status, 10)
end)
it("allows a newly entered user-agent", function()
local res = assert(proxy_client:send {
method = "GET",
path = "/request",
headers = {
host = "bot.com",
["user-agent"] = "facebookexternalhit/1.1"
}
})
assert.response(res).has.status(403)
-- Update the plugin
res = assert(admin_client:send {
method = "PATCH",
path = "/plugins/" .. plugin.id,
body = {
config = { whitelist = { "facebookexternalhit/1.1" } },
},
headers = {
["content-type"] = "application/json",
}
})
assert.response(res).has.status(200)
local check_status = function()
local res = assert(proxy_client:send {
mehod = "GET",
path = "/request",
headers = {
host = "bot.com",
["user-agent"] = "facebookexternalhit/1.1"
}
})
res:read_body() -- must call read_body to complete call, otherwise next iteration fails
return res.status == 200
end
helpers.wait_until(check_status, 10)
end)
end)
end
| apache-2.0 |
nesstea/darkstar | scripts/zones/Selbina/npcs/Falgima.lua | 13 | 1220 | -----------------------------------
-- Area: Selbina
-- NPC: Falgima
-- Standard Merchant NPC
-----------------------------------
package.loaded["scripts/zones/Selbina/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Selbina/TextIDs");
require("scripts/globals/shop");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,FALGIMA_SHOP_DIALOG);
stock = {0x1288,5351, -- Scroll of Invisible
0x1289,2325, -- Scroll of Sneak
0x128A,1204, -- Scroll of Deodorize
0x13F0,30360} -- Scroll of Flurry
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 |
FailcoderAddons/supervillain-ui | SVUI_Skins/components/blizzard/transmog.lua | 2 | 3186 | --[[
##############################################################################
S V U I By: Failcoder
##############################################################################
--]]
--[[ GLOBALS ]]--
local _G = _G;
local unpack = _G.unpack;
local select = _G.select;
local ipairs = _G.ipairs;
local pairs = _G.pairs;
local type = _G.type;
--[[ ADDON ]]--
local SV = _G['SVUI'];
local L = SV.L;
local MOD = SV.Skins;
local Schema = MOD.Schema;
--[[
##########################################################
HELPERS
##########################################################
]]--
local TransmogFrameList = {
"TransmogrifyModelFrameLines",
"TransmogrifyModelFrameMarbleBg",
"TransmogrifyFrameButtonFrameButtonBorder",
"TransmogrifyFrameButtonFrameButtonBottomBorder",
"TransmogrifyFrameButtonFrameMoneyLeft",
"TransmogrifyFrameButtonFrameMoneyRight",
"TransmogrifyFrameButtonFrameMoneyMiddle"
};
local TransmogSlotList = {
"Head",
"Shoulder",
"Chest",
"Waist",
"Legs",
"Feet",
"Wrist",
"Hands",
"Back",
"MainHand",
"SecondaryHand"
};
--[[
##########################################################
TRANSMOG MODR
##########################################################
]]--
local function TransmogStyle()
if SV.db.Skins.blizzard.enable ~= true or SV.db.Skins.blizzard.transmogrify ~= true then return end
TransmogrifyFrame:SetSize(500, 600)
SV.API:Set("Window", TransmogrifyFrame, true)
for p, texture in pairs(TransmogFrameList)do
_G[texture]:Die()
end
select(2, TransmogrifyModelFrame:GetRegions()):Die()
TransmogrifyModelFrame:ClearAllPoints()
TransmogrifyModelFrame:SetPoint("TOPLEFT", TransmogrifyFrame, "TOPLEFT", 12, -22)
TransmogrifyModelFrame:SetPoint("BOTTOMRIGHT", TransmogrifyFrame, "BOTTOMRIGHT", -12, 36)
TransmogrifyModelFrame:SetStyle("!_Frame", "Model")
TransmogrifyFrameButtonFrame:GetRegions():Die()
TransmogrifyApplyButton:RemoveTextures()
TransmogrifyApplyButton:SetStyle("Button")
TransmogrifyApplyButton:SetPoint("BOTTOMRIGHT", TransmogrifyFrame, "BOTTOMRIGHT", -4, 4)
SV.API:Set("CloseButton", TransmogrifyArtFrameCloseButton)
TransmogrifyArtFrame:RemoveTextures()
for p, a9 in pairs(TransmogSlotList) do
local icon = _G["TransmogrifyFrame"..a9 .."SlotIconTexture"]
local a9 = _G["TransmogrifyFrame"..a9 .."Slot"]
if a9 then
a9:RemoveTextures()
a9:SetStyle("ActionSlot")
a9:SetFrameLevel(a9:GetFrameLevel()+2)
a9.Panel:SetAllPoints()
icon:SetTexCoord(unpack(_G.SVUI_ICON_COORDS))
icon:ClearAllPoints()
icon:InsetPoints()
end
end
TransmogrifyConfirmationPopup:SetParent(UIParent)
TransmogrifyConfirmationPopup:RemoveTextures()
TransmogrifyConfirmationPopup:SetStyle("Frame", "Pattern")
TransmogrifyConfirmationPopup.Button1:SetStyle("Button")
TransmogrifyConfirmationPopup.Button2:SetStyle("Button")
SV.API:Set("!_ItemButton", TransmogrifyConfirmationPopupItemFrame1)
SV.API:Set("!_ItemButton", TransmogrifyConfirmationPopupItemFrame2)
end
--[[
##########################################################
MOD LOADING
##########################################################
]]--
MOD:SaveBlizzardStyle("Blizzard_ItemAlterationUI", TransmogStyle) | mit |
mynameiscraziu/thisismilad | plugins/inrealm.lua | 228 | 16974 | -- 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 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)
if not is_admin(msg) then
return "For admins only!"
end
local settings = data[tostring(target)]['settings']
local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member
return text
end
local function returnids(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..''
for k,v in pairs(result.members) do
local username = ""
text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n"
end
send_large_msg(receiver, text)
local file = io.open("./groups/"..result.id.."memberlist.txt", "w")
file:write(text)
file:flush()
file:close()
end
local function returnidsfile(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..''
for k,v in pairs(result.members) do
local username = ""
text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n"
end
local file = io.open("./groups/"..result.id.."memberlist.txt", "w")
file:write(text)
file:flush()
file:close()
send_document("chat#id"..result.id,"./groups/"..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 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 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 group_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.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
function run(msg, matches)
--vardump(msg)
if matches[1] == 'creategroup' and matches[2] then
group_name = matches[2]
return create_group(msg)
end
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 not is_realm(msg) then
return
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] == 'setting' 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_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)
end
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] == 'list' and matches[2] == 'admins' then
return admin_list(msg)
end
if matches[1] == 'list' and matches[2] == 'groups' then
group_list(msg)
send_document("chat#id"..msg.to.id, "groups.txt", ok_cb, false)
return " Group list created" --group_list(msg)
end
end
return {
patterns = {
"^[!/](creategroup) (.*)$",
"^[!/](setabout) (%d+) (.*)$",
"^[!/](setrules) (%d+) (.*)$",
"^[!/](setname) (%d+) (.*)$",
"^[!/](lock) (%d+) (.*)$",
"^[!/](unlock) (%d+) (.*)$",
"^[!/](setting) (%d+)$",
"^[!/](wholist)$",
"^[!/](who)$",
"^[!/](addadmin) (.*)$", -- sudoers only
"^[!/](removeadmin) (.*)$", -- sudoers only
"^[!/](list) (.*)$",
"^[!/](log)$",
"^!!tgservice (.+)$",
},
run = run
}
end
| gpl-2.0 |
nesstea/darkstar | scripts/globals/spells/bluemagic/ram_charge.lua | 35 | 1707 | -----------------------------------------
-- Spell: Ram Charge
-- Damage varies with TP
-- Spell cost: 79 MP
-- Monster Type: Beasts
-- Spell Type: Physical (Blunt)
-- Blue Magic Points: 4
-- Stat Bonus: HP+5
-- Level: 73
-- Casting Time: 0.5 seconds
-- Recast Time: 34.75 seconds
-- Skillchain Element(s): Fragmentation (can open/close Light with Fusion WSs and spells)
-- Combos: Lizard Killer
-----------------------------------------
require("scripts/globals/magic");
require("scripts/globals/status");
require("scripts/globals/bluemagic");
-----------------------------------------
-- OnMagicCastingCheck
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onSpellCast(caster,target,spell)
local params = {};
-- This data should match information on http://wiki.ffxiclopedia.org/wiki/Calculating_Blue_Magic_Damage
params.tpmod = TPMOD_DAMAGE;
params.dmgtype = DMGTYPE_BLUNT;
params.scattr = SC_FRAGMENTATION;
params.numhits = 1;
params.multiplier = 1.0;
params.tp150 = 1.375;
params.tp300 = 1.75;
params.azuretp = 1.875;
params.duppercap = 75;
params.str_wsc = 0.3;
params.dex_wsc = 0.0;
params.vit_wsc = 0.0;
params.agi_wsc = 0.0;
params.int_wsc = 0.0;
params.mnd_wsc = 0.5;
params.chr_wsc = 0.0;
damage = BluePhysicalSpell(caster, target, spell, params);
damage = BlueFinalAdjustments(caster, target, spell, damage, params);
-- Missing KNOCKBACK effect
return damage;
end; | gpl-3.0 |
malortie/gmod-addons | th_weapons/lua/entities/ent_weapon_th_mp5/init.lua | 1 | 1174 | -- Only enable this addon if HL:S is mounted.
if !IsHL1Mounted() then return end
-------------------------------------
-- Weapon MP5 spawning.
-------------------------------------
AddCSLuaFile('cl_init.lua')
AddCSLuaFile('shared.lua')
include('shared.lua')
-- Define a global variable to ease calling base class methods.
DEFINE_BASECLASS( 'base_point' )
--[[---------------------------------------------------------
Called to spawn this entity.
@param ply The player spawner.
@param tr The trace result from player's eye to the spawn point.
@param ClassName The entity's class name.
@return true on success.
@return false on failure.
-----------------------------------------------------------]]
function ENT:SpawnFunction( ply, tr, ClassName )
-- Do not spawn at an invalid position.
if ( !tr.Hit ) then return end
-- Spawn the entity at the hit position,
-- facing toward the player.
local SpawnPos = tr.HitPos + tr.HitNormal
local SpawnAng = ply:EyeAngles()
SpawnAng.p = 0
SpawnAng.y = SpawnAng.y + 180
local ent = ents.Create( 'weapon_th_mp5' )
ent:SetPos( SpawnPos )
ent:SetAngles( SpawnAng )
ent:Spawn()
ent:Activate()
return ent
end
| gpl-3.0 |
nesstea/darkstar | scripts/globals/spells/sage_etude.lua | 27 | 1613 | -----------------------------------------
-- Spell: Sage Etude
-- Static INT Boost, BRD 66
-----------------------------------------
require("scripts/globals/status");
require("scripts/globals/magic");
-----------------------------------------
-- OnSpellCast
-----------------------------------------
function onMagicCastingCheck(caster,target,spell)
return 0;
end;
function onSpellCast(caster,target,spell)
local sLvl = caster:getSkillLevel(SKILL_SNG); -- Gets skill level of Singing
local iLvl = caster:getWeaponSkillLevel(SLOT_RANGED);
local power = 0;
if (sLvl+iLvl <= 416) then
power = 12;
elseif ((sLvl+iLvl >= 417) and (sLvl+iLvl <= 445)) then
power = 13;
elseif ((sLvl+iLvl >= 446) and (sLvl+iLvl <= 474)) then
power = 14;
elseif (sLvl+iLvl >= 475) then
power = 15;
end
local iBoost = caster:getMod(MOD_ETUDE_EFFECT) + caster:getMod(MOD_ALL_SONGS_EFFECT);
power = power + iBoost;
if (caster:hasStatusEffect(EFFECT_SOUL_VOICE)) then
power = power * 2;
elseif (caster:hasStatusEffect(EFFECT_MARCATO)) then
power = power * 1.5;
end
caster:delStatusEffect(EFFECT_MARCATO);
local duration = 120;
duration = duration * ((iBoost * 0.1) + (caster:getMod(MOD_SONG_DURATION_BONUS)/100) + 1);
if (caster:hasStatusEffect(EFFECT_TROUBADOUR)) then
duration = duration * 2;
end
if not (target:addBardSong(caster,EFFECT_ETUDE,power,10,duration,caster:getID(), MOD_INT, 2)) then
spell:setMsg(75);
end
return EFFECT_ETUDE;
end; | gpl-3.0 |
LuaDist2/rake | rake.lua | 2 | 3474 | -- A Lua implementation of the Rapid Automatic Keyword Extraction
-- Released under the MIT License
local _M = {}
local function load_words(stop_words_path)
local file = io.open(stop_words_path)
if not file then error('could not open file '..stop_words_path) end
local words = {}
for line in file:lines() do
if line:sub(1, 1) ~= '#' then
for word in line:gmatch('%S+') do
words[word:lower()] = true
end
end
end
return words
end
local function generate_candidate_keywords(sentences, stop_words)
local keywords = {}
for s in sentences do
local kw = {}
for word in s:gmatch('%S+') do
if stop_words[word] then
if #kw > 0 then table.insert(keywords, table.concat(kw, ' ')) end
kw = {}
else
table.insert(kw, word)
end
end
if #kw > 0 then table.insert(keywords, table.concat(kw, ' ')) end
end
return keywords
end
local function calculate_word_scores(keywords)
local frequency = {}
local degree = {}
local score = {}
for _, kw in ipairs(keywords) do
local words = {}
for w in kw:gmatch('[^%s%d]+') do table.insert(words, w) end
local word_degree = #words - 1
for _, word in ipairs(words) do
frequency[word] = (frequency[word] or 0) + 1
degree[word] = (degree[word] or 0) + word_degree
end
end
for word, f in pairs(frequency) do score[word] = (degree[word] + f) / f end
return score
end
local function generate_candidate_keyword_scores(keywords, word_scores)
local scores = {}
for _, kw in ipairs(keywords) do
if not scores[kw] then
local kw_score = 0
for w in kw:gmatch('[^%s%d]+') do
kw_score = kw_score + word_scores[w]
end
scores[kw] = kw_score
end
end
return scores
end
--- Create a rake object
-- @param stop_words Set of stop words (i.e. a table with the words as keys), or
-- path to a file from where to load them.
-- @usage rake = require 'rake'
-- r = rake.new('SmartStoplist.txt')
-- result = r:run(text) -- returns a table mapping keywords to scores
function _M.new(stop_words)
local rake = {}
if type(stop_words) == 'string' then
stop_words = load_words(stop_words)
elseif type(stop_words) ~= 'table' then
error('stop_words must be a path to a file or a set')
end
rake.stop_words = stop_words
--- Run the RAKE algorithm
-- @param text Text to extract keywords from
-- @param return_intermediate Optional, also return intermediate results:
-- sentences (a generator), keywords, and word scores (tables)
-- @return Keyword scores as a table
function rake:run(text, return_intermediate)
if type(text) ~= 'string' then error('text must be a string') end
text = text:lower()
local sentences = text:gmatch('[^%p]+')
local keywords = generate_candidate_keywords(sentences, self.stop_words)
local word_scores = calculate_word_scores(keywords)
local keyword_scores = generate_candidate_keyword_scores(keywords, word_scores)
if return_intermediate then
return sentences, keywords, word_scores, keyword_scores
end
return keyword_scores
end
return rake
end
return _M | mit |
UnfortunateFruit/darkstar | scripts/commands/capskill.lua | 27 | 3148 | ---------------------------------------------------------------------------------------------------
-- func: capskill
-- desc: Caps a specific skill.
---------------------------------------------------------------------------------------------------
cmdprops =
{
permission = 1,
parameters = "s"
};
function onTrigger(player, skill)
local skillList =
{
-- Combat Skills
["h2h"] = 1,
["dagger"] = 2,
["sword"] = 3,
["gsword"] = 4,
["axe"] = 5,
["gaxe"] = 6,
["scythe"] = 7,
["polearm"] = 8,
["katana"] = 9,
["gkatana"] = 10,
["club"] = 11,
["staff"] = 12,
["archery"] = 25,
["marksmanship"]= 26,
["throwing"] = 27,
["guard"] = 28,
["evasion"] = 29,
["shield"] = 30,
["parry"] = 31,
-- Magic Skills
["divine"] = 32,
["healing"] = 33,
["enhancing"] = 34,
["enfeebling"] = 35,
["elemental"] = 36,
["dark"] = 37,
["summoning"] = 38,
["ninjitsu"] = 39,
-- Everyone spells it wrong. NinjUtsu is correct!
["ninjutsu"] = 39,
["singing"] = 40,
["string"] = 41,
["wind"] = 42,
["blue"] = 43,
["bluemagic"] = 43,
["geomancy"] = 44
};
if (skill == nil) then
player:PrintToPlayer( "You must enter a valid skill name." );
return;
end
if (tonumber(skill) ~= 0 and tonumber(skill) ~= nil) then
local skillId = tonumber(skill);
player:capSkill( skillId );
for k, v in pairs(skillList) do
if (v == skillId) then
player:PrintToPlayer( string.format( "Capped skill '%s'.", k ) );
return;
end
end
end
local skillId = skillList[ string.lower( skill ) ];
if (skillId == nil) then
player:PrintToPlayer( string.format( "Invalid skill '%s' given.", skill ) );
else
player:capSkill( skillId );
player:PrintToPlayer( string.format( "Capped skill '%s'.", skill ) );
end
end
--[[
if (skill == nil) then
player:PrintToPlayer( "You must enter a valid skill name." );
return;
end
local skillId = skillList[ string.lower( skill ) ];
if (tonumber(skill) ~= 0) then
skillId = tonumber(skill);
player:capSkill( skillId );
for k, v in pairs(skillList) do
if (v == skillId) then
player:PrintToPlayer( string.format( "Capped skill '%s'.", k ) );
return;
end
end
else
skillId = skillList[ string.lower( skill ) ];
if (skillId == nil) then
player:PrintToPlayer( string.format( "Invalid skill '%s' given.", skill ) );
return;
end
end
end
]] | gpl-3.0 |
UnfortunateFruit/darkstar | scripts/zones/Southern_San_dOria/npcs/Maleme.lua | 27 | 1530 | -----------------------------------
-- Area: Southern San dOria
-- NPC: Maleme
-- Type: Weather Reporter
-- Involved in Quest: Flyers for Regine
-----------------------------------
package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/quests");
require("scripts/zones/Southern_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
-- "Flyers for Regine" conditional script
if (player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE) == QUEST_ACCEPTED) then
local count = trade:getItemCount();
local MagicFlyer = trade:hasItemQty(532,1);
if (MagicFlyer == true and count == 1) then
player:messageSpecial(FLYER_REFUSED);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x0278,0,0,0,0,0,0,0,VanadielTime());
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 |
Cyumus/NutScript | gamemode/core/libs/sh_anims.lua | 3 | 14354 | nut.anim = nut.anim or {}
nut.anim.citizen_male = {
normal = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE, ACT_IDLE_ANGRY_SMG1},
[ACT_MP_CROUCH_IDLE] = {ACT_COVER_LOW, ACT_COVER_LOW},
[ACT_MP_WALK] = {ACT_WALK, ACT_WALK_AIM_RIFLE_STIMULATED},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH, ACT_WALK_CROUCH_AIM_RIFLE},
[ACT_MP_RUN] = {ACT_RUN, ACT_RUN_AIM_RIFLE_STIMULATED}
},
pistol = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE, ACT_RANGE_ATTACK_PISTOL},
[ACT_MP_CROUCH_IDLE] = {ACT_COVER_PISTOL_LOW, ACT_RANGE_AIM_PISTOL_LOW},
[ACT_MP_WALK] = {ACT_WALK, ACT_WALK_AIM_RIFLE_STIMULATED},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH, ACT_WALK_CROUCH_AIM_RIFLE},
[ACT_MP_RUN] = {ACT_RUN, ACT_RUN_AIM_RIFLE_STIMULATED},
attack = ACT_GESTURE_RANGE_ATTACK_PISTOL,
reload = ACT_RELOAD_PISTOL
},
smg = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE_SMG1_RELAXED, ACT_IDLE_ANGRY_SMG1},
[ACT_MP_CROUCH_IDLE] = {ACT_COVER_SMG1_LOW, ACT_RANGE_AIM_SMG1_LOW},
[ACT_MP_WALK] = {ACT_WALK_RIFLE_RELAXED, ACT_WALK_AIM_RIFLE_STIMULATED},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH_RIFLE, ACT_WALK_CROUCH_AIM_RIFLE},
[ACT_MP_RUN] = {ACT_RUN_RIFLE_RELAXED, ACT_RUN_AIM_RIFLE_STIMULATED},
attack = ACT_GESTURE_RANGE_ATTACK_SMG1,
reload = ACT_GESTURE_RELOAD_SMG1
},
shotgun = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE_SHOTGUN_RELAXED, ACT_IDLE_ANGRY_SMG1},
[ACT_MP_CROUCH_IDLE] = {ACT_COVER_SMG1_LOW, ACT_RANGE_AIM_SMG1_LOW},
[ACT_MP_WALK] = {ACT_WALK_RIFLE_RELAXED, ACT_WALK_AIM_RIFLE_STIMULATED},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH_RIFLE, ACT_WALK_CROUCH_RIFLE},
[ACT_MP_RUN] = {ACT_RUN_RIFLE_RELAXED, ACT_RUN_AIM_RIFLE_STIMULATED},
attack = ACT_GESTURE_RANGE_ATTACK_SHOTGUN
},
grenade = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE, ACT_IDLE_MANNEDGUN},
[ACT_MP_CROUCH_IDLE] = {ACT_COVER_LOW, ACT_COVER_PISTOL_LOW},
[ACT_MP_WALK] = {ACT_WALK, ACT_WALK_AIM_RIFLE_STIMULATED},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH, ACT_WALK_CROUCH_AIM_RIFLE},
[ACT_MP_RUN] = {ACT_RUN, ACT_RUN_RIFLE_STIMULATED},
attack = ACT_RANGE_ATTACK_THROW
},
melee = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE_SUITCASE, ACT_IDLE_ANGRY_MELEE},
[ACT_MP_CROUCH_IDLE] = {ACT_COVER_LOW, ACT_COVER_LOW},
[ACT_MP_WALK] = {ACT_WALK, ACT_WALK_AIM_RIFLE},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH, ACT_WALK_CROUCH},
[ACT_MP_RUN] = {ACT_RUN, ACT_RUN},
attack = ACT_MELEE_ATTACK_SWING
},
glide = ACT_GLIDE,
vehicle = {
["prop_vehicle_prisoner_pod"] = {"podpose", Vector(-3, 0, 0)},
["prop_vehicle_jeep"] = {"sitchair1", Vector(14, 0, -14)},
["prop_vehicle_airboat"] = {"sitchair1", Vector(8, 0, -20)},
chair = {"sitchair1", Vector(1, 0, -23)}
},
}
nut.anim.citizen_female = {
normal = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE, ACT_IDLE_MANNEDGUN},
[ACT_MP_CROUCH_IDLE] = {ACT_COVER_LOW, ACT_COVER_LOW},
[ACT_MP_WALK] = {ACT_WALK, ACT_RANGE_AIM_SMG1_LOW},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH, ACT_WALK_CROUCH_AIM_RIFLE},
[ACT_MP_RUN] = {ACT_RUN, ACT_RUN_AIM_RIFLE_STIMULATED}
},
pistol = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE_PISTOL, ACT_IDLE_ANGRY_PISTOL},
[ACT_MP_CROUCH_IDLE] = {ACT_COVER_LOW, ACT_RANGE_AIM_SMG1_LOW},
[ACT_MP_WALK] = {ACT_WALK, ACT_WALK_AIM_PISTOL},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH, ACT_WALK_CROUCH_AIM_RIFLE},
[ACT_MP_RUN] = {ACT_RUN, ACT_RUN_AIM_PISTOL},
attack = ACT_GESTURE_RANGE_ATTACK_PISTOL,
reload = ACT_RELOAD_PISTOL
},
smg = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE_SMG1_RELAXED, ACT_IDLE_ANGRY_SMG1},
[ACT_MP_CROUCH_IDLE] = {ACT_COVER_LOW, ACT_RANGE_AIM_SMG1_LOW},
[ACT_MP_WALK] = {ACT_WALK_RIFLE_RELAXED, ACT_WALK_AIM_RIFLE_STIMULATED},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH_RIFLE, ACT_WALK_CROUCH_AIM_RIFLE},
[ACT_MP_RUN] = {ACT_RUN_RIFLE_RELAXED, ACT_RUN_AIM_RIFLE_STIMULATED},
attack = ACT_GESTURE_RANGE_ATTACK_SMG1,
reload = ACT_GESTURE_RELOAD_SMG1
},
shotgun = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE_SHOTGUN_RELAXED, ACT_IDLE_ANGRY_SMG1},
[ACT_MP_CROUCH_IDLE] = {ACT_COVER_LOW, ACT_RANGE_AIM_SMG1_LOW},
[ACT_MP_WALK] = {ACT_WALK_RIFLE_RELAXED, ACT_WALK_AIM_RIFLE_STIMULATED},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH_RIFLE, ACT_WALK_CROUCH_AIM_RIFLE},
[ACT_MP_RUN] = {ACT_RUN_RIFLE_RELAXED, ACT_RUN_AIM_RIFLE_STIMULATED},
attack = ACT_GESTURE_RANGE_ATTACK_SHOTGUN
},
grenade = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE, ACT_IDLE_MANNEDGUN},
[ACT_MP_CROUCH_IDLE] = {ACT_COVER_LOW, ACT_RANGE_AIM_SMG1_LOW},
[ACT_MP_WALK] = {ACT_WALK, ACT_WALK_AIM_PISTOL},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH, ACT_WALK_CROUCH_AIM_RIFLE},
[ACT_MP_RUN] = {ACT_RUN, ACT_RUN_AIM_PISTOL},
attack = ACT_RANGE_ATTACK_THROW
},
melee = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE_SUITCASE, ACT_IDLE_ANGRY_MELEE},
[ACT_MP_CROUCH_IDLE] = {ACT_COVER_LOW, ACT_COVER_LOW},
[ACT_MP_WALK] = {ACT_WALK, ACT_WALK_AIM_RIFLE},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH, ACT_WALK_CROUCH},
[ACT_MP_RUN] = {ACT_RUN, ACT_RUN},
attack = ACT_MELEE_ATTACK_SWING
},
glide = ACT_GLIDE,
vehicle = nut.anim.citizen_male.vehicle
}
nut.anim.metrocop = {
normal = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE, ACT_IDLE_ANGRY_SMG1},
[ACT_MP_CROUCH_IDLE] = {ACT_COVER_PISTOL_LOW, ACT_COVER_SMG1_LOW},
[ACT_MP_WALK] = {ACT_WALK, ACT_WALK_AIM_RIFLE},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH, ACT_WALK_CROUCH},
[ACT_MP_RUN] = {ACT_RUN, ACT_RUN}
},
pistol = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE_PISTOL, ACT_IDLE_ANGRY_PISTOL},
[ACT_MP_CROUCH_IDLE] = {ACT_COVER_PISTOL_LOW, ACT_COVER_PISTOL_LOW},
[ACT_MP_WALK] = {ACT_WALK_PISTOL, ACT_WALK_AIM_PISTOL},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH, ACT_WALK_CROUCH},
[ACT_MP_RUN] = {ACT_RUN_PISTOL, ACT_RUN_AIM_PISTOL},
attack = ACT_GESTURE_RANGE_ATTACK_PISTOL,
reload = ACT_GESTURE_RELOAD_PISTOL
},
smg = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE_SMG1, ACT_IDLE_ANGRY_SMG1},
[ACT_MP_CROUCH_IDLE] = {ACT_COVER_SMG1_LOW, ACT_COVER_SMG1_LOW},
[ACT_MP_WALK] = {ACT_WALK_RIFLE, ACT_WALK_AIM_RIFLE},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH, ACT_WALK_CROUCH},
[ACT_MP_RUN] = {ACT_RUN_RIFLE, ACT_RUN_AIM_RIFLE}
},
shotgun = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE_SMG1, ACT_IDLE_ANGRY_SMG1},
[ACT_MP_CROUCH_IDLE] = {ACT_COVER_SMG1_LOW, ACT_COVER_SMG1_LOW},
[ACT_MP_WALK] = {ACT_WALK_RIFLE, ACT_WALK_AIM_RIFLE},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH, ACT_WALK_CROUCH},
[ACT_MP_RUN] = {ACT_RUN_RIFLE, ACT_RUN_AIM_RIFLE}
},
grenade = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE, ACT_IDLE_ANGRY_MELEE},
[ACT_MP_CROUCH_IDLE] = {ACT_COVER_PISTOL_LOW, ACT_COVER_PISTOL_LOW},
[ACT_MP_WALK] = {ACT_WALK, ACT_WALK_ANGRY},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH, ACT_WALK_CROUCH},
[ACT_MP_RUN] = {ACT_RUN, ACT_RUN},
attack = ACT_COMBINE_THROW_GRENADE
},
melee = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE, ACT_IDLE_ANGRY_MELEE},
[ACT_MP_CROUCH_IDLE] = {ACT_COVER_PISTOL_LOW, ACT_COVER_PISTOL_LOW},
[ACT_MP_WALK] = {ACT_WALK, ACT_WALK_ANGRY},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH, ACT_WALK_CROUCH},
[ACT_MP_RUN] = {ACT_RUN, ACT_RUN},
attack = ACT_MELEE_ATTACK_SWING_GESTURE
},
glide = ACT_GLIDE,
vehicle = {
chair = {ACT_COVER_PISTOL_LOW, Vector(5, 0, -5)},
["prop_vehicle_airboat"] = {ACT_COVER_PISTOL_LOW, Vector(10, 0, 0)},
["prop_vehicle_jeep"] = {ACT_COVER_PISTOL_LOW, Vector(18, -2, 4)},
["prop_vehicle_prisoner_pod"] = {ACT_IDLE, Vector(-4, -0.5, 0)}
}
}
nut.anim.overwatch = {
normal = {
[ACT_MP_STAND_IDLE] = {"idle_unarmed", ACT_IDLE_ANGRY},
[ACT_MP_CROUCH_IDLE] = {ACT_CROUCHIDLE, ACT_CROUCHIDLE},
[ACT_MP_WALK] = {"walkunarmed_all", ACT_WALK_RIFLE},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH_RIFLE, ACT_WALK_CROUCH_RIFLE},
[ACT_MP_RUN] = {ACT_RUN_AIM_RIFLE, ACT_RUN_AIM_RIFLE}
},
pistol = {
[ACT_MP_STAND_IDLE] = {"idle_unarmed", ACT_IDLE_ANGRY_SMG1},
[ACT_MP_CROUCH_IDLE] = {ACT_CROUCHIDLE, ACT_CROUCHIDLE},
[ACT_MP_WALK] = {"walkunarmed_all", ACT_WALK_RIFLE},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH_RIFLE, ACT_WALK_CROUCH_RIFLE},
[ACT_MP_RUN] = {ACT_RUN_AIM_RIFLE, ACT_RUN_AIM_RIFLE}
},
smg = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE_SMG1, ACT_IDLE_ANGRY_SMG1},
[ACT_MP_CROUCH_IDLE] = {ACT_CROUCHIDLE, ACT_CROUCHIDLE},
[ACT_MP_WALK] = {ACT_WALK_RIFLE, ACT_WALK_AIM_RIFLE},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH_RIFLE, ACT_WALK_CROUCH_RIFLE},
[ACT_MP_RUN] = {ACT_RUN_RIFLE, ACT_RUN_AIM_RIFLE}
},
shotgun = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE_SMG1, ACT_IDLE_ANGRY_SHOTGUN},
[ACT_MP_CROUCH_IDLE] = {ACT_CROUCHIDLE, ACT_CROUCHIDLE},
[ACT_MP_WALK] = {ACT_WALK_RIFLE, ACT_WALK_AIM_SHOTGUN},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH_RIFLE, ACT_WALK_CROUCH_RIFLE},
[ACT_MP_RUN] = {ACT_RUN_RIFLE, ACT_RUN_AIM_SHOTGUN}
},
grenade = {
[ACT_MP_STAND_IDLE] = {"idle_unarmed", ACT_IDLE_ANGRY},
[ACT_MP_CROUCH_IDLE] = {ACT_CROUCHIDLE, ACT_CROUCHIDLE},
[ACT_MP_WALK] = {"walkunarmed_all", ACT_WALK_RIFLE},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH_RIFLE, ACT_WALK_CROUCH_RIFLE},
[ACT_MP_RUN] = {ACT_RUN_AIM_RIFLE, ACT_RUN_AIM_RIFLE}
},
melee = {
[ACT_MP_STAND_IDLE] = {"idle_unarmed", ACT_IDLE_ANGRY},
[ACT_MP_CROUCH_IDLE] = {ACT_CROUCHIDLE, ACT_CROUCHIDLE},
[ACT_MP_WALK] = {"walkunarmed_all", ACT_WALK_RIFLE},
[ACT_MP_CROUCHWALK] = {ACT_WALK_CROUCH_RIFLE, ACT_WALK_CROUCH_RIFLE},
[ACT_MP_RUN] = {ACT_RUN_AIM_RIFLE, ACT_RUN_AIM_RIFLE},
attack = ACT_MELEE_ATTACK_SWING_GESTURE
},
glide = ACT_GLIDE
}
nut.anim.vort = {
normal = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE, "actionidle"},
[ACT_MP_CROUCH_IDLE] = {"crouchidle", "crouchidle"},
[ACT_MP_WALK] = {ACT_WALK, "walk_all_holdgun"},
[ACT_MP_CROUCHWALK] = {ACT_WALK, "walk_all_holdgun"},
[ACT_MP_RUN] = {ACT_RUN, ACT_RUN}
},
pistol = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE, "tcidle"},
[ACT_MP_CROUCH_IDLE] = {"crouchidle", "crouchidle"},
[ACT_MP_WALK] = {ACT_WALK, "walk_all_holdgun"},
[ACT_MP_CROUCHWALK] = {ACT_WALK, "walk_all_holdgun"},
[ACT_MP_RUN] = {ACT_RUN, "run_all_tc"}
},
smg = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE, "tcidle"},
[ACT_MP_CROUCH_IDLE] = {"crouchidle", "crouchidle"},
[ACT_MP_WALK] = {ACT_WALK, "walk_all_holdgun"},
[ACT_MP_CROUCHWALK] = {ACT_WALK, "walk_all_holdgun"},
[ACT_MP_RUN] = {ACT_RUN, "run_all_tc"}
},
shotgun = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE, "tcidle"},
[ACT_MP_CROUCH_IDLE] = {"crouchidle", "crouchidle"},
[ACT_MP_WALK] = {ACT_WALK, "walk_all_holdgun"},
[ACT_MP_CROUCHWALK] = {ACT_WALK, "walk_all_holdgun"},
[ACT_MP_RUN] = {ACT_RUN, "run_all_tc"}
},
grenade = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE, "tcidle"},
[ACT_MP_CROUCH_IDLE] = {"crouchidle", "crouchidle"},
[ACT_MP_WALK] = {ACT_WALK, "walk_all_holdgun"},
[ACT_MP_CROUCHWALK] = {ACT_WALK, "walk_all_holdgun"},
[ACT_MP_RUN] = {ACT_RUN, "run_all_tc"}
},
melee = {
[ACT_MP_STAND_IDLE] = {ACT_IDLE, "tcidle"},
[ACT_MP_CROUCH_IDLE] = {"crouchidle", "crouchidle"},
[ACT_MP_WALK] = {ACT_WALK, "walk_all_holdgun"},
[ACT_MP_CROUCHWALK] = {ACT_WALK, "walk_all_holdgun"},
[ACT_MP_RUN] = {ACT_RUN, "run_all_tc"}
},
glide = ACT_GLIDE
}
nut.anim.player = {
normal = {
[ACT_MP_STAND_IDLE] = ACT_HL2MP_IDLE,
[ACT_MP_CROUCH_IDLE] = ACT_HL2MP_IDLE_CROUCH,
[ACT_MP_WALK] = ACT_HL2MP_WALK,
[ACT_MP_RUN] = ACT_HL2MP_RUN
},
passive = {
[ACT_MP_STAND_IDLE] = ACT_HL2MP_IDLE_PASSIVE,
[ACT_MP_WALK] = ACT_HL2MP_WALK_PASSIVE,
[ACT_MP_CROUCHWALK] = ACT_HL2MP_WALK_CROUCH_PASSIVE,
[ACT_MP_RUN] = ACT_HL2MP_RUN_PASSIVE
}
}
nut.anim.zombie = {
[ACT_MP_STAND_IDLE] = ACT_HL2MP_IDLE_ZOMBIE,
[ACT_MP_CROUCH_IDLE] = ACT_HL2MP_IDLE_CROUCH_ZOMBIE,
[ACT_MP_CROUCHWALK] = ACT_HL2MP_WALK_CROUCH_ZOMBIE_01,
[ACT_MP_WALK] = ACT_HL2MP_WALK_ZOMBIE_02,
[ACT_MP_RUN] = ACT_HL2MP_RUN_ZOMBIE
}
nut.anim.fastZombie = {
[ACT_MP_STAND_IDLE] = ACT_HL2MP_WALK_ZOMBIE,
[ACT_MP_CROUCH_IDLE] = ACT_HL2MP_IDLE_CROUCH_ZOMBIE,
[ACT_MP_CROUCHWALK] = ACT_HL2MP_WALK_CROUCH_ZOMBIE_05,
[ACT_MP_WALK] = ACT_HL2MP_WALK_ZOMBIE_06,
[ACT_MP_RUN] = ACT_HL2MP_RUN_ZOMBIE_FAST
}
local translations = {}
function nut.anim.setModelClass(model, class)
if (!nut.anim[class]) then
error("'"..tostring(class).."' is not a valid animation class!")
end
translations[model:lower()] = class
end
-- Micro-optimization since the get class function gets called a lot.
local stringLower = string.lower
local stringFind = string.find
function nut.anim.getModelClass(model)
model = stringLower(model)
local class = translations[model]
if (!class and stringFind(model, "/player")) then
return "player"
end
class = class or "citizen_male"
if (class == "citizen_male" and (stringFind(model, "female") or stringFind(model, "alyx") or stringFind(model, "mossman"))) then
class = "citizen_female"
end
return class
end
nut.anim.setModelClass("models/police.mdl", "metrocop")
nut.anim.setModelClass("models/combine_super_soldier.mdl", "overwatch")
nut.anim.setModelClass("models/combine_soldier_prisonGuard.mdl", "overwatch")
nut.anim.setModelClass("models/combine_soldier.mdl", "overwatch")
nut.anim.setModelClass("models/vortigaunt.mdl", "vort")
nut.anim.setModelClass("models/vortigaunt_blue.mdl", "vort")
nut.anim.setModelClass("models/vortigaunt_doctor.mdl", "vort")
nut.anim.setModelClass("models/vortigaunt_slave.mdl", "vort")
do
local playerMeta = FindMetaTable("Player")
function playerMeta:forceSequence(sequence, callback, time, noFreeze)
hook.Run("OnPlayerEnterSequence", self, sequence, callback, time, noFreeze)
if (!sequence) then
return netstream.Start(nil, "seqSet", self)
end
local sequence = self:LookupSequence(sequence)
if (sequence and sequence > 0) then
time = time or self:SequenceDuration(sequence)
self.nutSeqCallback = callback
self.nutSeq = sequence
if (!noFreeze) then
self:SetMoveType(MOVETYPE_NONE)
end
if (time > 0) then
timer.Create("nutSeq"..self:EntIndex(), time, 1, function()
if (IsValid(self)) then
self:leaveSequence()
end
end)
end
netstream.Start(nil, "seqSet", self, sequence)
return time
end
return false
end
function playerMeta:leaveSequence()
hook.Run("OnPlayerLeaveSequence", self)
netstream.Start(nil, "seqSet", self)
self:SetMoveType(MOVETYPE_WALK)
self.nutSeq = nil
if (self.nutSeqCallback) then
self:nutSeqCallback()
end
end
if (CLIENT) then
netstream.Hook("seqSet", function(entity, sequence)
if (IsValid(entity)) then
if (!sequence) then
entity.nutForceSeq = nil
return
end
entity:SetCycle(0)
entity:SetPlaybackRate(1)
entity.nutForceSeq = sequence
end
end)
end
end
| mit |
craigbarnes/lua-gumbo | test/Set.lua | 3 | 1735 | local Set = require "gumbo.Set"
local assert, error, pcall = assert, error, pcall
local tostring, rawequal = tostring, rawequal
local _ENV = nil
local base = Set{"div", "table", "h1"}
do
local union1 = assert(base + Set{"a", "p"})
local union2 = assert(base + Set{"p", "a"})
assert(union1 == union2)
assert(not rawequal(union1, union2))
end
do
local u1 = assert(base + Set{"a", "p"})
local u2 = assert(base + Set{"a"})
local u3 = assert(base + Set{"p"})
assert(u1 ~= u2)
assert(u1 ~= u3)
assert(u2 ~= u3)
assert(not rawequal(u1, u2))
assert(not rawequal(u1, u3))
assert(not rawequal(u2, u3))
assert(u1 + Set() == u1)
assert(u1 + u2 == u1)
assert(u1 + u2 + u3 == u1)
assert(u1 + Set{"z"} ~= u1)
assert(u2:isSubsetOf(u1) == true)
assert(u3:isSubsetOf(u1) == true)
assert(u1:isSubsetOf(u2) == false)
assert(u1:isSubsetOf(u3) == false)
end
do
assert(base + Set{"a"} == base:union(Set{"a"}))
assert(base + Set{"a"} ~= base:union(Set{"p"}))
end
do
assert(not pcall(Set, true))
assert(not pcall(Set, false))
assert(not pcall(Set, 100))
assert(not pcall(Set, function() end))
end
do
local function assertTypeError(status, err)
if not (status == false and err:find("TypeError")) then
error("Expected TypeError, got: '" .. tostring(err) .."'", 2)
end
end
assertTypeError(pcall(base.union, base, 5))
assertTypeError(pcall(base.union, base, "five"))
assertTypeError(pcall(base.isSubsetOf, base, 5))
assertTypeError(pcall(base.isSubsetOf, base, "five"))
assertTypeError(pcall(function() return base + 5 end))
assertTypeError(pcall(function() return base + "five" end))
end
| apache-2.0 |
UnfortunateFruit/darkstar | scripts/zones/Toraimarai_Canal/Zone.lua | 28 | 1801 | -----------------------------------
--
-- Zone: Toraimarai_Canal (169)
--
-----------------------------------
package.loaded["scripts/zones/Toraimarai_Canal/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings")
require("scripts/globals/zone");
require("scripts/zones/Toraimarai_Canal/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
local tomes = {17469846,17469847,17469848,17469849};
SetGroundsTome(tomes);
UpdateTreasureSpawnPoint(17469831);
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos(-259.98,21.794,81.887,66);
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);
end; | gpl-3.0 |
nesstea/darkstar | scripts/zones/Windurst_Waters_[S]/npcs/Mearuru.lua | 13 | 1059 | -----------------------------------
-- Area: Windurst Waters (S)
-- NPC: Mearuru
-- Type: Standard NPC
-- @zone: 94
-- @pos 153.798 -1 153.712
--
-- Auto-Script: Requires Verification (Verified by Brawndo)
-----------------------------------
package.loaded["scripts/zones/Windurst_Waters_[S]/TextIDs"] = nil;
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x01a2);
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 |
FailcoderAddons/supervillain-ui | SVUI_Skins/components/addons/DXE.lua | 2 | 3831 | --[[
##########################################################
S V U I By: Failcoder
##########################################################
LOCALIZED LUA FUNCTIONS
##########################################################
]]--
--[[ GLOBALS ]]--
local _G = _G;
local unpack = _G.unpack;
local select = _G.select;
local pairs = _G.pairs;
local string = _G.string;
--[[ STRING METHODS ]]--
local format = string.format;
--[[
##########################################################
GET ADDON DATA
##########################################################
]]--
local SV = _G['SVUI'];
local L = SV.L;
local MOD = SV.Skins;
local Schema = MOD.Schema;
local playerName = UnitName("player");
local playerRealm = GetRealmName();
local playerKey = ("%s - %s"):format(playerName, playerRealm)
--[[
##########################################################
DXE
##########################################################
]]--
local function StyleDXEBar(bar)
bar:SetStyle("!_Frame", "Transparent")
bar.bg:SetTexture("")
bar.border.Show = SV.fubar
bar.border:Hide()
bar.statusbar:SetStatusBarTexture(SV.media.statusbar.default)
bar.statusbar:ClearAllPoints()
bar.statusbar:InsetPoints()
bar.righticon:SetStyle("!_Frame", "Default")
bar.righticon.border.Show = SV.fubar
bar.righticon.border:Hide()
bar.righticon:ClearAllPoints()
bar.righticon:SetPoint("LEFT", bar, "RIGHT", 2, 0)
bar.righticon.t:SetTexCoord(0.1,0.9,0.1,0.9)
bar.righticon.t:ClearAllPoints()
bar.righticon.t:InsetPoints()
bar.righticon.t:SetDrawLayer("ARTWORK")
bar.lefticon:SetStyle("!_Frame", "Default")
bar.lefticon.border.Show = SV.fubar
bar.lefticon.border:Hide()
bar.lefticon:ClearAllPoints()
bar.lefticon:SetPoint("RIGHT", bar, "LEFT", -2, 0)
bar.lefticon.t:SetTexCoord(0.1,0.9,0.1,0.9)
bar.lefticon.t:ClearAllPoints()
bar.lefticon.t:InsetPoints()
bar.lefticon.t:SetDrawLayer("ARTWORK")
end
local function RefreshDXEBars(frame)
if frame.refreshing then return end
frame.refreshing = true
local i = 1
while _G["DXEAlertBar"..i] do
local bar = _G["DXEAlertBar"..i]
if not bar.styled then
bar:SetScale(1)
bar.SetScale = SV.fubar
StyleDXEBar(bar)
bar.styled = true
end
i = i + 1
end
frame.refreshing = false
end
LoadAddOn("DXE")
local function StyleDXE()
assert(DXE, "AddOn Not Loaded")
DXE.LayoutHealthWatchers_ = DXE.LayoutHealthWatchers
DXE.LayoutHealthWatchers = function(frame)
DXE:LayoutHealthWatchers_()
for i,hw in ipairs(frame.HW) do
if hw:IsShown() then
hw:SetStyle("!_Frame", "Transparent")
hw.border.Show = SV.fubar
hw.border:Hide()
hw.healthbar:SetStatusBarTexture(SV.media.statusbar.default)
end
end
end
local DXEAlerts = DXE:GetModule("Alerts")
local frame = CreateFrame("Frame")
frame.elapsed = 1
frame:SetScript("OnUpdate", function(frame,elapsed)
frame.elapsed = frame.elapsed + elapsed
if(frame.elapsed >= 1) then
RefreshDXEBars(DXEAlerts)
frame.elapsed = 0
end
end)
hooksecurefunc(DXEAlerts, "Simple", RefreshDXEBars)
hooksecurefunc(DXEAlerts, "RefreshBars", RefreshDXEBars)
DXE:LayoutHealthWatchers()
DXE.Alerts:RefreshBars()
if not DXEDB then DXEDB = {} end
if not DXEDB["profiles"] then DXEDB["profiles"] = {} end
if not DXEDB["profiles"][playerKey] then DXEDB["profiles"][playerKey] = {} end
if not DXEDB["profiles"][playerKey]["Globals"] then DXEDB["profiles"][playerKey]["Globals"] = {} end
DXEDB["profiles"][playerKey]["Globals"]["BackgroundTexture"] = [[Interface\BUTTONS\WHITE8X8]]
DXEDB["profiles"][playerKey]["Globals"]["BarTexture"] = SV.media.statusbar.default
DXEDB["profiles"][playerKey]["Globals"]["Border"] = "None"
DXEDB["profiles"][playerKey]["Globals"]["Font"] = SV.media.font.dialog
DXEDB["profiles"][playerKey]["Globals"]["TimerFont"] = SV.media.font.dialog
end
MOD:SaveAddonStyle("DXE", StyleDXE)
| mit |
UnfortunateFruit/darkstar | scripts/globals/weaponskills/shadow_of_death.lua | 29 | 1260 | -----------------------------------
-- Shadow Of Death
-- Scythe weapon skill
-- Skill Level: 70
-- Delivers a dark elemental attack. Damage varies with TP.
-- Aligned with the Snow Gorget & Aqua Gorget.
-- Aligned with the Snow Belt & Aqua Belt.
-- Element: Dark
-- Modifiers: STR:40% ; INT:40%
-- 100%TP 200%TP 300%TP
-- 1.00 2.50 3.00
-----------------------------------
require("scripts/globals/magic");
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
-----------------------------------
function onUseWeaponSkill(player, target, wsID)
local params = {};
params.ftp100 = 1; params.ftp200 = 2.5; params.ftp300 = 3;
params.str_wsc = 0.3; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.3; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
params.ele = ELE_DARK;
params.skill = SKILL_SYH;
params.includemab = true;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.str_wsc = 0.4; params.int_wsc = 0.4;
end
local damage, criticalHit, tpHits, extraHits = doMagicWeaponskill(player, target, params);
damage = damage * WEAPON_SKILL_POWER
return tpHits, extraHits, criticalHit, damage;
end
| gpl-3.0 |
nesstea/darkstar | scripts/zones/Mine_Shaft_2716/Zone.lua | 30 | 1733 | -----------------------------------
--
-- Zone: Mine_Shaft_2716 (13)
--
-----------------------------------
package.loaded["scripts/zones/Mine_Shaft_2716/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/Mine_Shaft_2716/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onConquestUpdate
-----------------------------------
function onConquestUpdate(zone, updatetype)
local players = zone:getPlayers();
for name, player in pairs(players) do
conquestUpdate(zone, player, updatetype, CONQUEST_BASE);
end
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then
player:setPos(-116.599,-122.103,-620.01,253);
end
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
nesstea/darkstar | scripts/zones/Windurst_Woods/npcs/Gottah_Maporushanoh.lua | 13 | 1141 | -----------------------------------
-- Area: Windurst Woods
-- NPC: Gottah Maporushanoh
-- Working 100%
-----------------------------------
require("scripts/globals/settings");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
AmazinScorpio = player:getQuestStatus(WINDURST,THE_AMAZIN_SCORPIO);
if (AmazinScorpio == QUEST_COMPLETED) then
player:startEvent(0x01e6);
elseif (AmazinScorpio == QUEST_ACCEPTED) then
player:startEvent(0x01e3);
else
player:startEvent(0x1a4);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
UnfortunateFruit/darkstar | scripts/zones/Apollyon/bcnms/Central_Apollyon.lua | 13 | 1179 | -----------------------------------
-- Area: Appolyon
-- Name:
-----------------------------------
require("scripts/globals/limbus");
require("scripts/globals/keyitems");
-- After registering the BCNM via bcnmRegister(bcnmid)
function onBcnmRegister(player,instance)
SetServerVariable("[Central_Apollyon]UniqueID",GenerateLimbusKey());
HideArmouryCrates(GetInstanceRegion(1296),APPOLLYON_SE_NE);
GetNPCByID(16933248):setAnimation(8);
if(IsMobDead(16933125)==false)then DespawnMob(16933125);end
player:setVar("Limbus_Trade_Item",0);
end;
-- Physically entering the BCNM via bcnmEnter(bcnmid)
function onBcnmEnter(player,instance)
player:setVar("limbusbitmap",0);
player:setVar("characterLimbusKey",GetServerVariable("[Central_Apollyon]UniqueID"));
player:setVar("LimbusID",1296);
player:delKeyItem(COSMOCLEANSE);
end;
-- Leaving by every mean possible, given by the LeaveCode
-- 3=Disconnected or warped out (if dyna is empty: launch 4 after 3)
-- 4=Finish
function onBcnmLeave(player,instance,leavecode)
--print("leave code "..leavecode);
if(leavecode == 4) then
player:setPos(-668,0.1,-666);
ResetPlayerLimbusVariable(player)
end
end; | gpl-3.0 |
UnfortunateFruit/darkstar | scripts/zones/Silver_Sea_Remnants/Zone.lua | 36 | 1134 | -----------------------------------
--
-- Zone: Silver_Sea_Remnants
--
-----------------------------------
require("scripts/globals/settings");
package.loaded["scripts/zones/Silver_Sea_Remnants/TextIDs"] = nil;
require("scripts/zones/Silver_Sea_Remnants/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
cs = -1;
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;
| gpl-3.0 |
UnfortunateFruit/darkstar | scripts/zones/Aydeewa_Subterrane/npcs/qm2.lua | 37 | 1276 | -----------------------------------
-- Area: Aydeewa Subterrane
-- NPC: ??? (Spawn Pandemonium Warden)
-- @pos 200 33 -140 68
-----------------------------------
package.loaded["scripts/zones/Aydeewa_Subterrane/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Aydeewa_Subterrane/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
-- Pandemonium key
if (trade:hasItemQty(2572,1) and trade:getItemCount() == 1 and GetMobAction(17056168) == 0) then
SpawnMob(17056168,180):updateClaim(player); -- Pandemonium Warden
player:tradeComplete();
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:messageSpecial(NOTHING_HAPPENS);
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 |
dstruthers/computercraft | ninja.lua | 1 | 1975 | function dig ()
while turtle.detect() do
turtle.dig()
end
end
function forward (count)
if count == nil then
count = 1
end
while count > 0 do
if turtle.detect() then
dig()
end
if not turtle.forward() then
turtle.attack()
forward()
end
count = count - 1
end
end
function digUp ()
while turtle.detectUp() do
turtle.digUp()
end
end
function up (count)
if count == nil then
count = 1
end
while count > 0 do
if turtle.detectUp() then
digUp()
end
if not turtle.up() then
turtle.attackUp()
up()
end
count = count - 1
end
end
function digDown ()
while turtle.detectDown() do
turtle.digDown()
end
end
function down (count)
if count == nil then
count = 1
end
while count > 0 do
if turtle.detectDown() then
digDown()
end
if not turtle.down() then
turtle.attackDown()
down()
end
count = count - 1
end
end
function turnAround ()
turtle.turnRight()
turtle.turnRight()
end
function back (count)
if count == nil or count == 1 then
if not turtle.back() then
turnAround()
forward()
turnAround()
end
else
turnAround()
while count > 0 do
forward()
count = count - 1
end
turnAround()
end
end
function sortInventory ()
for i = 1, 15 do
if turtle.getItemCount(i) > 0 then
spaceLeft = turtle.getItemSpace(i)
if spaceLeft > 0 then
for j = i + 1, 16 do
turtle.select(i)
if i ~= j then
if turtle.compareTo(j) then
turtle.select(j)
if turtle.getItemCount(j) <= spaceLeft then
spaceLeft = spaceLeft - turtle.getItemCount(j)
else
spaceLeft = 0
end
turtle.transferTo(i)
end
end
if spaceLeft == 0 then
break
end
end
end
end
end
end
| mit |
UnfortunateFruit/darkstar | scripts/zones/Yuhtunga_Jungle/mobs/Overgrown_Rose.lua | 29 | 1385 | -----------------------------------
-- Area: Yuhtunga Jungle
-- MOB: Overgrown Rose
-----------------------------------
function onMobRoam(mob)
local Rose_Garden = 17281357;
local Rose_Garden_PH = 0;
local Rose_Garden_PH_Table =
{
17281356
};
local Rose_Garden_ToD = GetMobByID(Rose_Garden):getLocalVar("1");
if (Rose_Garden_ToD <= os.time()) then
Rose_Garden_PH = math.random((0), (table.getn(Rose_Garden_PH_Table)));
if (Rose_Garden_PH_Table[Rose_Garden_PH] ~= nil) then
if (GetMobAction(Rose_Garden) == 0) then
SetServerVariable("Rose_Garden_PH", Rose_Garden_PH_Table[Rose_Garden_PH]);
DeterMob(Rose_Garden_PH_Table[Rose_Garden_PH], true);
DeterMob(Rose_Garden, false);
DespawnMob(Rose_Garden_PH_Table[Rose_Garden_PH]);
SpawnMob(Rose_Garden, "", 0);
end
end
end
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, killer)
local Overgrown_Rose = mob:getID();
local Rose_Garden = 17281357;
local Rose_Garden_PH_Table =
{
17281356
};
for i = 1, table.getn(Rose_Garden_PH_Table), 1 do
if (Rose_Garden_PH_Table[i] ~= nil) then
if (Overgrown_Rose == Rose_Garden_PH_Table[i]) then
GetMobByID(Rose_Garden):setLocalVar("1",os.time() + math.random((36000), (37800)));
end
end
end
end;
| gpl-3.0 |
nesstea/darkstar | scripts/zones/Nashmau/npcs/Poporoon.lua | 13 | 1224 | -----------------------------------
-- Area: Nashmau
-- NPC: Poporoon
-- Standard Merchant NPC
-----------------------------------
package.loaded["scripts/zones/Nashmau/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Nashmau/TextIDs");
require("scripts/globals/shop");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc,POPOROON_SHOP_DIALOG);
stock = {0x3298,336, -- Leather Highboots
0x3299,3438, -- Lizard Ledelsens
0x329A,11172, -- Studded Boots
0x329B,20532} -- Cuir Highboots
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 |
dpino/snabbswitch | src/program/lisper/dev-env-perftest/gen_pcap.lua | 14 | 2506 | #!snabb/src/snabb snsh
local pcap = require'lib.pcap.pcap'
local eth = require'lib.protocol.ethernet'
local ipv6 = require'lib.protocol.ipv6'
local ffi = require'ffi'
local lib = require'core.lib'
local f
local function file(filename)
if f then f:close() end
if not filename then return end
print('opening '..filename)
f = io.open(filename, "w")
pcap.write_file_header(f)
end
local function write(p)
local buf, len = p.data, p.length
pcap.write_record_header(f, len)
print(string.format('writing %d bytes packet', p.length))
f:write(ffi.string(buf, len))
end
local l2tp_ct = ffi.typeof[[
struct {
// ethernet
char dmac[6];
char smac[6];
uint16_t ethertype; // dd:86 = ipv6
// ipv6
uint32_t flow_id; // version, tc, flow_id
int16_t payload_length;
int8_t next_header; // 115 = L2TPv3
uint8_t hop_limit;
char src_ip[16];
char dst_ip[16];
// l2tp
uint32_t session_id;
char cookie[8];
// tunneled ethernet frame
char l2tp_dmac[6];
char l2tp_smac[6];
} __attribute__((packed))
]]
local l2tp_ct_size = ffi.sizeof(l2tp_ct)
local l2tp_ctp = ffi.typeof("$*", l2tp_ct)
local function gen(len, smac, dmac, src_ip, dst_ip, sid, cookie, l2tp_smac, l2tp_dmac)
local dp = packet.allocate()
local hsize = src_ip and l2tp_ct_size or 12
dp.length = hsize + len
ffi.copy(dp.data + hsize, ('x'):rep(len))
local p = ffi.cast(l2tp_ctp, dp.data)
ffi.copy(p.smac, eth:pton(smac), 6)
ffi.copy(p.dmac, eth:pton(dmac), 6)
if src_ip then
p.ethertype = 0xdd86 --ipv6
p.flow_id = 0x60 --ipv6
p.payload_length = lib.htons(len + 12 + 12) --payload + ETH + L2TPv3
p.next_header = 115 --L2TPv3
p.hop_limit = 64 --default
ffi.copy(p.src_ip, ipv6:pton(src_ip), 16)
ffi.copy(p.dst_ip, ipv6:pton(dst_ip), 16)
p.session_id = lib.htonl(sid)
ffi.copy(p.cookie, cookie, 8)
ffi.copy(p.l2tp_smac, eth:pton(l2tp_smac), 6)
ffi.copy(p.l2tp_dmac, eth:pton(l2tp_dmac), 6)
end
write(dp)
end
file'lisper01.pcap'
gen(150, '00:00:00:00:02:01', '00:00:00:00:02:02')
file'lisper02.pcap'
local n = math.random(100, 200)
for i=1,n do
local len = math.random(20, 200)
local cookie = '\0\0\0\0\0\0\0\0'
gen(len, '00:00:00:00:00:21', '00:00:00:00:00:01', 'fd80::21', 'fd80::01', 1, cookie, '00:00:00:00:01:01', '00:00:00:00:01:02')
gen(len, '00:00:00:00:00:22', '00:00:00:00:00:01', 'fd80::22', 'fd80::01', 1, cookie, '00:00:00:00:01:02', '00:00:00:00:01:01')
end
file()
| apache-2.0 |
nesstea/darkstar | scripts/zones/Horlais_Peak/mobs/Maat.lua | 6 | 1120 | -----------------------------------
-- Area: Horlais Peak
-- MOB: Maat
-- Genkai 5 Fight
-----------------------------------
package.loaded["scripts/zones/Horlais_Peak/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Horlais_Peak/TextIDs");
-----------------------------------
-- onMobSpawn Action
-----------------------------------
function onMobSpawn(mob)
end;
-----------------------------------
-- onMobEngaged Action
-----------------------------------
function onMobEngaged(mob,target)
target:showText(mob,YOU_DECIDED_TO_SHOW_UP);
printf("Maat Horlais Peak works");
-- When he take damage: target:showText(mob,THAT_LL_HURT_IN_THE_MORNING);
-- He use dragon kick or tackle: target:showText(mob,TAKE_THAT_YOU_WHIPPERSNAPPER);
-- He use spining attack: target:showText(mob,TEACH_YOU_TO_RESPECT_ELDERS);
-- If you dying: target:showText(mob,LOOKS_LIKE_YOU_WERENT_READY);
end;
-----------------------------------
-- onMobDeath Action
-----------------------------------
function onMobDeath(mob,killer,ally)
killer:showText(mob,YOUVE_COME_A_LONG_WAY);
end; | gpl-3.0 |
UnfortunateFruit/darkstar | scripts/zones/Windurst_Waters_[S]/npcs/Mikhe_Aryohcha.lua | 38 | 1124 | -----------------------------------
-- Area: Windurst Waters (S)
-- NPC: Mikhe Aryohcha
-- Type: Standard NPC
-- @zone: 94
-- @pos -56.645 -4.5 13.014
--
-- Auto-Script: Requires Verification (Verified by Brawndo)
-----------------------------------
package.loaded["scripts/zones/Windurst_Waters_[S]/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Windurst_Waters_[S]/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:showText(npc, MIKHE_ARYOHCHA_DIALOG);
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
-- printf("CSID: %u",csid);
-- printf("RESULT: %u",option);
end;
| gpl-3.0 |
cmassiot/vlc-broadcast | share/lua/intf/dumpmeta.lua | 6 | 2201 | --[==========================================================================[
dumpmeta.lua: dump a file's meta data on stdout/stderr
--[==========================================================================[
Copyright (C) 2010 the VideoLAN team
$Id$
Authors: Antoine Cellerier <dionoea at videolan dot org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
--]==========================================================================]
--[[ to dump meta data information in the debug output, run:
vlc -I lua --lua-intf dumpmeta coolmusic.mp3
Additional options can improve performance and output readability:
-V dummy -A dummy --no-video-title --no-media-library --verbose-objects +lua,-all -v=0
--]]
local item
repeat
item = vlc.input.item()
until (item and item:is_preparsed()) or vlc.misc.should_die()
-- preparsing doesn't always provide all the information we want (like duration)
repeat
until item:stats()["demux_read_bytes"] > 0 or vlc.misc.should_die()
vlc.msg.info("name: "..item:name())
vlc.msg.info("uri: "..vlc.strings.decode_uri(item:uri()))
vlc.msg.info("duration: "..tostring(item:duration()))
vlc.msg.info("meta data:")
local meta = item:metas()
if meta then
for key, value in pairs(meta) do
vlc.msg.info(" "..key..": "..value)
end
else
vlc.msg.info(" no meta data available")
end
vlc.msg.info("info:")
for cat, data in pairs(item:info()) do
vlc.msg.info(" "..cat)
for key, value in pairs(data) do
vlc.msg.info(" "..key..": "..value)
end
end
vlc.misc.quit()
| gpl-2.0 |
heyuqi/wxFormBuilder | build/premake/4.3/tests/test_gcc.lua | 6 | 1429 | --
-- tests/test_gcc.lua
-- Automated test suite for the GCC toolset interface.
-- Copyright (c) 2009 Jason Perkins and the Premake project
--
T.gcc = { }
local suite = T.gcc
local cfg
function suite.setup()
cfg = { }
cfg.basedir = "."
cfg.location = "."
cfg.language = "C++"
cfg.project = { name = "MyProject" }
cfg.flags = { }
cfg.objectsdir = "obj"
cfg.platform = "Native"
cfg.links = { }
cfg.libdirs = { }
cfg.linktarget = { fullpath="libMyProject.a" }
end
function suite.cflags_SharedLib_Windows()
cfg.kind = "SharedLib"
cfg.system = "windows"
local r = premake.gcc.getcflags(cfg)
test.isequal('', table.concat(r,"|"))
end
function suite.ldflags_SharedLib_Windows()
cfg.kind = "SharedLib"
cfg.system = "windows"
local r = premake.gcc.getldflags(cfg)
test.isequal('-s|-shared|-Wl,--out-implib="libMyProject.a"', table.concat(r,"|"))
end
function suite.cflags_OnFpFast()
cfg.flags = { "FloatFast" }
local r = premake.gcc.getcflags(cfg)
test.isequal('-ffast-math', table.concat(r,"|"))
end
function suite.cflags_OnFpStrict()
cfg.flags = { "FloatStrict" }
local r = premake.gcc.getcflags(cfg)
test.isequal('-ffloat-store', table.concat(r,"|"))
end
function suite.linkflags_OnFrameworks()
cfg.links = { "Cocoa.framework" }
local r = premake.gcc.getlinkflags(cfg)
test.isequal('-framework Cocoa', table.concat(r,"|"))
end
| gpl-2.0 |
nesstea/darkstar | scripts/zones/AlTaieu/npcs/qm1.lua | 27 | 1451 | -----------------------------------
-- Area: Al'Taieu
-- NPC: ??? (Jailer of Hope Spawn)
-- Allows players to spawn the Jailer of Hope by trading the First Virtue, Deed of Placidity and HQ Phuabo Organ to a ???.
-- @pos -693 -1 -62 33
-----------------------------------
package.loaded["scripts/zones/AlTaieu/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/AlTaieu/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
-- Trade the First Virtue, Deed of Placidity and HQ Phuabo Organ
if (GetMobAction(16912838) == 0 and trade:hasItemQty(1850,1) and trade:hasItemQty(1851,1) and trade:hasItemQty(1852,1) and trade:getItemCount() == 3) then
player:tradeComplete();
SpawnMob(16912838,900):updateClaim(player); -- Spawn Jailer of Hope
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("onUpdate CSID: %u",csid);
--printf("onUpdate RESULT: %u",option);
end;
-----------------------------------
-- onEventFinish Action
-----------------------------------
function onEventFinish(player,csid,option)
--printf("onFinish CSID: %u",csid);
--printf("onFinish RESULT: %u",option);
end; | gpl-3.0 |
NezzKryptic/Wire-Extras | beta/expressions/expr_tokenizer.lua | 3 | 2123 | EXPR_TOKENIZER = {}
function EXPR_TOKENIZER:new()
local obj = {}
setmetatable( obj, {__index = EXPR_TOKENIZER} )
--Recognised patterns
obj.pattern = {}
obj.pattern.digit = "(%-?)(%d+%.?%d*)(%%?)"
obj.pattern.input = "(.?#%u[%w_]+)"
obj.pattern.op = "([%^%+%-%*%/%\\])"
obj.pattern.func = "([%a_]+)"
--The input to consume
obj.input = ""
obj.token = nil
return obj
end
function EXPR_TOKENIZER:setInput( newInput )
self.input = newInput:gsub( "(%s)", "" )
end
function EXPR_TOKENIZER:getNextToken()
if( self.input:match( "^%s*(%()" ) ) then
self.input = self.input:sub( 2 )
return {type="OPENBRACE", value="("}
elseif( self.input:match( "^%s*(%))" ) ) then
self.input = self.input:sub( 2 )
return {type="CLOSEBRACE", value=")"}
elseif( self.input:match( "^%s*"..self.pattern.func ) ) then
local func = self.input:match( "^([%a_]+)" )
self.input = self.input:sub( func:len()+1 )
return {type="FUNC", value=func}
elseif( self.input:match( "^%s*"..self.pattern.input ) ) then
print("INPUT")
local name = self.input:match( "^%s*"..self.pattern.input )
self.input = self.input:sub( name:len()+1 )
return {type="VALUE", value="4"}
elseif( self.input:match( "^%s*"..self.pattern.op ) ) then
local op = self.input:match( self.pattern.op )
self.input = self.input:sub( 2 )
if ( op == "+" ) then
return {type="OP", value="+"}
elseif( op == "-" ) then
return {type="OP", value="-"}
elseif( op == "*" ) then
return {type="OP", value="*"}
elseif( op == "\\" or op == "/" ) then
return {type="OP", value="/"}
elseif( op == "^" ) then
return {type="OP", value="^"}
end
print("ERR! Got what appears to be an operator... but couldn't recognise it!")
return nil
elseif( self.input:match( "^%s*"..self.pattern.digit ) ) then
local sign, magnitude, percent = self.input:match( self.pattern.digit )
self.input = self.input:sub( (sign..magnitude..percent):len()+1 )
return {type="VALUE", value=tonumber(sign..magnitude)}
end
if( self.input:len() > 0 ) then
print("ERR! Untokenable input!")
end
return nil
end
| gpl-3.0 |
plajjan/snabbswitch | lib/ljsyscall/syscall/osx/ffi.lua | 18 | 7808 | -- ffi definitions of OSX types
local require, error, assert, tonumber, tostring,
setmetatable, pairs, ipairs, unpack, rawget, rawset,
pcall, type, table, string =
require, error, assert, tonumber, tostring,
setmetatable, pairs, ipairs, unpack, rawget, rawset,
pcall, type, table, string
local abi = require "syscall.abi"
local ffi = require "ffi"
require "syscall.ffitypes"
-- for version detection - not implemented yet
ffi.cdef [[
int sysctl(const int *name, unsigned int namelen, void *oldp, size_t *oldlenp, const void *newp, size_t newlen);
]]
local defs = {}
local function append(str) defs[#defs + 1] = str end
append [[
typedef uint16_t mode_t;
typedef uint8_t sa_family_t;
typedef uint32_t dev_t;
typedef int64_t blkcnt_t;
typedef int32_t blksize_t;
typedef int32_t suseconds_t;
typedef uint16_t nlink_t;
typedef uint64_t ino_t; // at least on recent desktop; TODO define as ino64_t
typedef long time_t;
typedef int32_t daddr_t;
typedef unsigned long clock_t;
typedef unsigned int nfds_t;
typedef uint32_t id_t; // check as not true in freebsd
typedef unsigned long tcflag_t;
typedef unsigned long speed_t;
typedef int kern_return_t;
typedef unsigned int natural_t;
typedef natural_t mach_port_name_t;
typedef mach_port_name_t *mach_port_name_array_t;
typedef mach_port_name_t mach_port_t;
typedef mach_port_t task_t;
typedef mach_port_t task_name_t;
typedef mach_port_t thread_t;
typedef mach_port_t thread_act_t;
typedef mach_port_t ipc_space_t;
typedef mach_port_t host_t;
typedef mach_port_t host_priv_t;
typedef mach_port_t host_security_t;
typedef mach_port_t processor_t;
typedef mach_port_t processor_set_t;
typedef mach_port_t processor_set_control_t;
typedef mach_port_t semaphore_t;
typedef mach_port_t lock_set_t;
typedef mach_port_t ledger_t;
typedef mach_port_t alarm_t;
typedef mach_port_t clock_serv_t;
typedef mach_port_t clock_ctrl_t;
typedef int alarm_type_t;
typedef int sleep_type_t;
typedef int clock_id_t;
typedef int clock_flavor_t;
typedef int *clock_attr_t;
typedef int clock_res_t;
/* osx has different clock functions so clockid undefined, but so POSIX headers work, define it
similarly with timer_t */
typedef int clockid_t;
typedef int timer_t;
/* actually not a struct at all in osx, just a uint32_t but for compatibility fudge it */
/* TODO this should work, but really need to move all sigset_t handling out of common types */
typedef struct {
uint32_t sig[1];
} sigset_t;
typedef struct fd_set {
int32_t fds_bits[32];
} fd_set;
struct pollfd
{
int fd;
short events;
short revents;
};
struct cmsghdr {
size_t cmsg_len;
int cmsg_level;
int cmsg_type;
char cmsg_data[?];
};
struct msghdr {
void *msg_name;
socklen_t msg_namelen;
struct iovec *msg_iov;
int msg_iovlen;
void *msg_control;
socklen_t msg_controllen;
int msg_flags;
};
struct timespec {
time_t tv_sec;
long tv_nsec;
};
struct timeval {
time_t tv_sec;
suseconds_t tv_usec;
};
struct itimerspec {
struct timespec it_interval;
struct timespec it_value;
};
struct itimerval {
struct timeval it_interval;
struct timeval it_value;
};
struct sockaddr {
uint8_t sa_len;
sa_family_t sa_family;
char sa_data[14];
};
struct sockaddr_storage {
uint8_t ss_len;
sa_family_t ss_family;
char __ss_pad1[6];
int64_t __ss_align;
char __ss_pad2[128 - 2 - 8 - 6];
};
struct sockaddr_in {
uint8_t sin_len;
sa_family_t sin_family;
in_port_t sin_port;
struct in_addr sin_addr;
int8_t sin_zero[8];
};
struct sockaddr_in6 {
uint8_t sin6_len;
sa_family_t sin6_family;
in_port_t sin6_port;
uint32_t sin6_flowinfo;
struct in6_addr sin6_addr;
uint32_t sin6_scope_id;
};
struct sockaddr_un {
uint8_t sun_len;
sa_family_t sun_family;
char sun_path[104];
};
struct stat {
dev_t st_dev;
mode_t st_mode;
nlink_t st_nlink;
ino_t st_ino;
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
struct timespec st_atimespec;
struct timespec st_mtimespec;
struct timespec st_ctimespec;
struct timespec st_birthtimespec;
off_t st_size;
blkcnt_t st_blocks;
blksize_t st_blksize;
uint32_t st_flags;
uint32_t st_gen;
int32_t st_lspare;
int64_t st_qspare[2];
};
union sigval {
int sival_int;
void *sival_ptr;
};
typedef struct __siginfo {
int si_signo;
int si_errno;
int si_code;
pid_t si_pid;
uid_t si_uid;
int si_status;
void *si_addr;
union sigval si_value;
long si_band;
unsigned long __pad[7];
} siginfo_t;
union __sigaction_u {
void (*__sa_handler)(int);
void (*__sa_sigaction)(int, struct __siginfo *, void *);
};
struct sigaction {
union __sigaction_u __sigaction_u;
sigset_t sa_mask;
int sa_flags;
};
struct sigevent {
int sigev_notify;
int sigev_signo;
union sigval sigev_value;
void (*sigev_notify_function)(union sigval);
void *sigev_notify_attributes; /* pthread_attr_t */
};
struct dirent {
uint64_t d_ino;
uint64_t d_seekoff;
uint16_t d_reclen;
uint16_t d_namlen;
uint8_t d_type;
char d_name[1024];
};
struct legacy_dirent {
uint32_t d_ino;
uint16_t d_reclen;
uint8_t d_type;
uint8_t d_namlen;
char d_name[256];
};
struct flock {
off_t l_start;
off_t l_len;
pid_t l_pid;
short l_type;
short l_whence;
};
struct termios {
tcflag_t c_iflag;
tcflag_t c_oflag;
tcflag_t c_cflag;
tcflag_t c_lflag;
cc_t c_cc[20];
speed_t c_ispeed;
speed_t c_ospeed;
};
struct rusage {
struct timeval ru_utime;
struct timeval ru_stime;
long ru_maxrss;
long ru_ixrss;
long ru_idrss;
long ru_isrss;
long ru_minflt;
long ru_majflt;
long ru_nswap;
long ru_inblock;
long ru_oublock;
long ru_msgsnd;
long ru_msgrcv;
long ru_nsignals;
long ru_nvcsw;
long ru_nivcsw;
};
struct kevent {
uintptr_t ident;
int16_t filter;
uint16_t flags;
uint32_t fflags;
intptr_t data;
void *udata;
};
struct aiocb {
int aio_fildes;
off_t aio_offset;
volatile void *aio_buf;
size_t aio_nbytes;
int aio_reqprio;
struct sigevent aio_sigevent;
int aio_lio_opcode;
};
struct mach_timebase_info {
uint32_t numer;
uint32_t denom;
};
typedef struct mach_timebase_info *mach_timebase_info_t;
typedef struct mach_timebase_info mach_timebase_info_data_t;
struct mach_timespec {
unsigned int tv_sec;
clock_res_t tv_nsec;
};
typedef struct mach_timespec mach_timespec_t;
]]
append [[
int ioctl(int d, unsigned long request, void *arg);
int mount(const char *type, const char *dir, int flags, void *data);
int stat64(const char *path, struct stat *sb);
int lstat64(const char *path, struct stat *sb);
int fstat64(int fd, struct stat *sb);
int _getdirentries(int fd, char *buf, int nbytes, long *basep);
int _sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
/* mach_absolute_time uses rtdsc, so careful if move CPU */
uint64_t mach_absolute_time(void);
kern_return_t mach_timebase_info(mach_timebase_info_t info);
kern_return_t mach_wait_until(uint64_t deadline);
extern mach_port_t mach_task_self_;
mach_port_t mach_host_self(void);
kern_return_t mach_port_deallocate(ipc_space_t task, mach_port_name_t name);
kern_return_t host_get_clock_service(host_t host, clock_id_t clock_id, clock_serv_t *clock_serv);
kern_return_t clock_get_time(clock_serv_t clock_serv, mach_timespec_t *cur_time);
]]
ffi.cdef(table.concat(defs, ""))
require "syscall.bsd.ffi"
| apache-2.0 |
vonflynee/opencomputersserver | world/opencomputers/6d437cc7-8fe8-4147-8a29-4c8b62fcedc7/bin/wget.lua | 7 | 2727 | local component = require("component")
local fs = require("filesystem")
local internet = require("internet")
local shell = require("shell")
local text = require("text")
if not component.isAvailable("internet") then
io.stderr:write("This program requires an internet card to run.")
return
end
local args, options = shell.parse(...)
options.q = options.q or options.Q
if #args < 1 then
io.write("Usage: wget [-fq] <url> [<filename>]\n")
io.write(" -f: Force overwriting existing files.\n")
io.write(" -q: Quiet mode - no status messages.\n")
io.write(" -Q: Superquiet mode - no error messages.")
return
end
local url = text.trim(args[1])
local filename = args[2]
if not filename then
filename = url
local index = string.find(filename, "/[^/]*$")
if index then
filename = string.sub(filename, index + 1)
end
index = string.find(filename, "?", 1, true)
if index then
filename = string.sub(filename, 1, index - 1)
end
end
filename = text.trim(filename)
if filename == "" then
if not options.Q then
io.stderr:write("could not infer filename, please specify one")
end
return nil, "missing target filename" -- for programs using wget as a function
end
filename = shell.resolve(filename)
if fs.exists(filename) then
if not options.f or not os.remove(filename) then
if not options.Q then
io.stderr:write("file already exists")
end
return nil, "file already exists" -- for programs using wget as a function
end
end
local f, reason = io.open(filename, "wb")
if not f then
if not options.Q then
io.stderr:write("failed opening file for writing: " .. reason)
end
return nil, "failed opening file for writing: " .. reason -- for programs using wget as a function
end
if not options.q then
io.write("Downloading... ")
end
local result, response = pcall(internet.request, url)
if result then
local result, reason = pcall(function()
for chunk in response do
f:write(chunk)
end
end)
if not result then
if not options.q then
io.stderr:write("failed.\n")
end
f:close()
fs.remove(filename)
if not options.Q then
io.stderr:write("HTTP request failed: " .. reason .. "\n")
end
return nil, reason -- for programs using wget as a function
end
if not options.q then
io.write("success.\n")
end
f:close()
if not options.q then
io.write("Saved data to " .. filename .. "\n")
end
else
if not options.q then
io.write("failed.\n")
end
f:close()
fs.remove(filename)
if not options.Q then
io.stderr:write("HTTP request failed: " .. response .. "\n")
end
return nil, response -- for programs using wget as a function
end
return true -- for programs using wget as a function | mit |
nesstea/darkstar | scripts/zones/Dynamis-Xarcabard/mobs/Animated_Spear.lua | 6 | 1502 | -----------------------------------
-- Area: Dynamis Xarcabard
-- MOB: Animated Spear
-----------------------------------
require("scripts/globals/status");
require("scripts/zones/Dynamis-Xarcabard/TextIDs");
-----------------------------------
-- onMobEngaged
-----------------------------------
function onMobEngaged(mob,target)
if (mob:AnimationSub() == 3) then
SetDropRate(114,1578,1000);
else
SetDropRate(114,1578,0);
end
target:showText(mob,ANIMATED_SPEAR_DIALOG);
SpawnMob(17330423,120):updateEnmity(target);
SpawnMob(17330424,120):updateEnmity(target);
SpawnMob(17330425,120):updateEnmity(target);
SpawnMob(17330435,120):updateEnmity(target);
SpawnMob(17330436,120):updateEnmity(target);
SpawnMob(17330437,120):updateEnmity(target);
end;
-----------------------------------
-- onMobFight Action
-----------------------------------
function onMobFight(mob,target)
-- TODO: add battle dialog
end;
-----------------------------------
-- onMobDisengage
-----------------------------------
function onMobDisengage(mob)
mob:showText(mob,ANIMATED_SPEAR_DIALOG+2);
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob,killer,ally)
ally:showText(mob,ANIMATED_SPEAR_DIALOG+1);
DespawnMob(17330423);
DespawnMob(17330424);
DespawnMob(17330425);
DespawnMob(17330435);
DespawnMob(17330436);
DespawnMob(17330437);
end; | gpl-3.0 |
NezzKryptic/Wire-Extras | lua/weapons/gmod_tool/stools/wire_materializer.lua | 4 | 5440 |
TOOL.Category = "Wire Extras/Visuals"
TOOL.Name = "Materializer"
TOOL.Command = nil
TOOL.ConfigName = ""
TOOL.Tab = "Wire"
if CLIENT then
language.Add( "Tool.wire_materializer.name", "Materializer Tool (Wire)" )
language.Add( "Tool.wire_materializer.desc", "Spawns a constant materializer prop for use with the wire system." )
language.Add( "Tool.wire_materializer.0", "Primary: Create/Update Materializer" )
language.Add( "WireMaterializerTool_materializer", "Materializer:" )
language.Add( "WireMaterializerTool_outMat", "Output Material:" )
language.Add( "WireMaterializerTool_Range", "Max Range:" )
language.Add( "WireMaterializerTool_Model", "Choose a Model:")
language.Add( "sboxlimit_wire_materializers", "You've hit Materializers limit!" )
language.Add( "undone_Wire Materializer", "Undone Wire Materializer" )
end
if SERVER then
CreateConVar('sbox_maxwire_materializers', 20)
end
local matmodels = {
["models/jaanus/wiretool/wiretool_siren.mdl"] = {},
["models/jaanus/wiretool/wiretool_beamcaster.mdl"] = {},
["models/jaanus/wiretool/wiretool_range.mdl"] = {}
}
--TOOL.Model = "models/jaanus/wiretool/wiretool_siren.mdl"
TOOL.ClientConVar[ "Model" ] = "models/jaanus/wiretool/wiretool_siren.mdl"
TOOL.ClientConVar[ "outMat" ] = "0"
TOOL.ClientConVar[ "Range" ] = "2000"
cleanup.Register( "wire_materializers" )
function TOOL:LeftClick( trace )
if !trace.HitPos then return false end
if trace.Entity:IsPlayer() then return false end
if CLIENT then return true end
local ply = self:GetOwner()
if IsValid(trace.Entity) and trace.Entity:GetClass() == "gmod_wire_materializer" and trace.Entity:GetTable().pl == ply then
trace.Entity:SetBeamLength( self:GetClientNumber( "Range" ) )
return true
end
if !self:GetSWEP():CheckLimit( "wire_materializers" ) then return false end
local Ang = trace.HitNormal:Angle()
Ang.pitch = Ang.pitch + 90
local outMat = (self:GetClientNumber( "outMat" ) ~= 0)
local range = self:GetClientNumber( "Range" )
local model = self:GetClientInfo( "Model" )
local wire_materializer = MakeWireMaterializer( ply, trace.HitPos, outMat, range, model, Ang )
local min = wire_materializer:OBBMins()
wire_materializer:SetPos( trace.HitPos - trace.HitNormal * min.z )
local const = WireLib.Weld( wire_materializer, trace.Entity, trace.PhysicsBone, true )
undo.Create( "Wire Materializer" )
undo.AddEntity( wire_materializer )
undo.AddEntity( const )
undo.SetPlayer( ply )
undo.Finish()
ply:AddCleanup( "wire_materializers", wire_materializer )
return true
end
function TOOL:RightClick( trace )
return false
end
if SERVER then
function MakeWireMaterializer( pl, Pos, outMat, Range, Model, Ang )
if !pl:CheckLimit( "wire_materializers" ) then return false end
local wire_materializer = ents.Create( "gmod_wire_materializer" )
if !IsValid(wire_materializer) then return false end
wire_materializer:SetAngles( Ang )
wire_materializer:SetPos( Pos )
wire_materializer:SetModel( Model )
wire_materializer:Spawn()
wire_materializer:Setup( outMat, Range )
wire_materializer:SetPlayer( pl )
local ttable = {
outMat = outMat,
Range = Range,
pl = pl
}
table.Merge(wire_materializer:GetTable(), ttable )
pl:AddCount( "wire_materializers", wire_materializer )
return wire_materializer
end
duplicator.RegisterEntityClass("gmod_wire_materializer", MakeWireMaterializer, "Pos", "outMat", "Range", "Model", "Ang", "Vel", "aVel", "frozen")
end
function TOOL:UpdateGhostWireMaterializer( ent, player )
if !IsValid(ent) then return end
local tr = util.GetPlayerTrace( player, player:GetAimVector() )
local trace = util.TraceLine( tr )
if !trace.Hit or trace.Entity:IsPlayer() or trace.Entity:GetClass() == "gmod_wire_materializer" then
ent:SetNoDraw( true )
return
end
local Ang = trace.HitNormal:Angle()
Ang.pitch = Ang.pitch + 90
local min = ent:OBBMins()
ent:SetPos( trace.HitPos - trace.HitNormal * min.z )
ent:SetAngles( Ang )
ent:SetNoDraw( false )
end
function TOOL:Think()
if !self.GhostEntity or !self.GhostEntity:IsValid() or self.GhostEntity:GetModel() != self:GetClientInfo("Model") then
self:MakeGhostEntity( self:GetClientInfo("Model"), Vector(0,0,0), Angle(0,0,0) )
end
self:UpdateGhostWireMaterializer( self.GhostEntity, self:GetOwner() )
end
function TOOL.BuildCPanel(panel)
panel:AddControl("Header", { Text = "#Tool.wire_materializer.name", Description = "#Tool.wire_materializer.desc" })
panel:AddControl("ComboBox", {
Label = "#Presets",
MenuButton = "1",
Folder = "wire_materializer",
Options = {
Default = {
wire_materializer_outMat = "0",
}
},
CVars = {
[0] = "wire_materializer_outMat"
}
})
panel:AddControl( "PropSelect", { Label = "#WireMaterializerTool_Model",
ConVar = "wire_materializer_Model",
Category = "Wire Materializers",
Models = matmodels } )
panel:AddControl("CheckBox", {
Label = "#WireMaterializerTool_outMat",
Command = "wire_materializer_outMat"
})
panel:AddControl("Slider", {
Label = "#WireMaterializerTool_Range",
Type = "Float",
Min = "1",
Max = "10000",
Command = "wire_materializer_Range"
})
end
| gpl-3.0 |
nesstea/darkstar | scripts/zones/Lower_Jeuno/npcs/Sutarara.lua | 13 | 1644 | -----------------------------------
-- Area: Lower Jeuno
-- NPC: Sutarara
-- Involved in Quests: Tenshodo Menbership (before accepting)
-- @pos 30 0.1 -2 245
-----------------------------------
package.loaded["scripts/zones/Lower_Jeuno/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/zones/Lower_Jeuno/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local TenshodoMembership = player:getQuestStatus(JEUNO,TENSHODO_MEMBERSHIP);
local WildcatJeuno = player:getVar("WildcatJeuno");
if (player:getQuestStatus(JEUNO,LURE_OF_THE_WILDCAT_JEUNO) == QUEST_ACCEPTED and player:getMaskBit(WildcatJeuno,10) == false) then
player:startEvent(10055);
elseif (TenshodoMembership ~= QUEST_COMPLETED) then
player:startEvent(0x00d0);
elseif (TenshodoMembership == QUEST_COMPLETED) then
player:startEvent(0x00d3);
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 == 10055) then
player:setMaskBit(player:getVar("WildcatJeuno"),"WildcatJeuno",10,true);
end
end; | gpl-3.0 |
longhf/torch7 | init.lua | 6 | 5692 | -- We are using paths.require to appease mkl
-- Make this work with LuaJIT in Lua 5.2 compatibility mode, which
-- renames string.gfind (already deprecated in 5.1)
if not string.gfind then
string.gfind = string.gmatch
end
if not table.unpack then
table.unpack = unpack
end
require "paths"
paths.require "libtorch"
-- Keep track of all thread local variables torch.
-- if a Lua VM is passed to another thread thread local
-- variables need to be updated.
function torch.updatethreadlocals()
torch.updateerrorhandlers()
local tracking = torch._heaptracking
if tracking == nil then tracking = false end
torch.setheaptracking(tracking)
end
--- package stuff
function torch.packageLuaPath(name)
if not name then
local ret = string.match(torch.packageLuaPath('torch'), '(.*)/')
if not ret then --windows?
ret = string.match(torch.packageLuaPath('torch'), '(.*)\\')
end
return ret
end
for path in string.gmatch(package.path, "[^;]+") do
path = string.gsub(path, "%?", name)
local f = io.open(path)
if f then
f:close()
local ret = string.match(path, "(.*)/")
if not ret then --windows?
ret = string.match(path, "(.*)\\")
end
return ret
end
end
end
local function include(file, depth)
paths.dofile(file, 3 + (depth or 0))
end
rawset(_G, 'include', include)
function torch.include(package, file)
dofile(torch.packageLuaPath(package) .. '/' .. file)
end
function torch.class(...)
local tname, parenttname, module
if select('#', ...) == 3
and type(select(1, ...)) == 'string'
and type(select(2, ...)) == 'string'
and type(select(3, ...)) == 'table'
then
tname = select(1, ...)
parenttname = select(2, ...)
module = select(3, ...)
elseif select('#', ...) == 2
and type(select(1, ...)) == 'string'
and type(select(2, ...)) == 'string'
then
tname = select(1, ...)
parenttname = select(2, ...)
elseif select('#', ...) == 2
and type(select(1, ...)) == 'string'
and type(select(2, ...)) == 'table'
then
tname = select(1, ...)
module = select(2, ...)
elseif select('#', ...) == 1
and type(select(1, ...)) == 'string'
then
tname = select(1, ...)
else
error('<class name> [<parent class name>] [<module table>] expected')
end
local function constructor(...)
local self = {}
torch.setmetatable(self, tname)
if self.__init then
self:__init(...)
end
return self
end
local function factory()
local self = {}
torch.setmetatable(self, tname)
return self
end
local mt = torch.newmetatable(tname, parenttname, constructor, nil, factory, module)
local mpt
if parenttname then
mpt = torch.getmetatable(parenttname)
end
return mt, mpt
end
function torch.setdefaulttensortype(typename)
assert(type(typename) == 'string', 'string expected')
if torch.getconstructortable(typename) then
torch.Tensor = torch.getconstructortable(typename)
torch.Storage = torch.getconstructortable(torch.typename(torch.Tensor(1):storage()))
else
error(string.format("<%s> is not a string describing a torch object", typename))
end
end
function torch.type(obj)
local class = torch.typename(obj)
if not class then
class = type(obj)
end
return class
end
-- Returns true if the type given by the passed-in typeName equals typeSpec.
local function exactTypeMatch(typeName, typeSpec)
return typeName == typeSpec
end
--[[ Returns true if the type given by the passed-in typeName either equals
typeSpec, or ends with ".<typeSpec>". For example, "ab.cd.ef" matches type specs
"ef", "cd.ef", and "ab.cd.ef", but not "f" or "d.ef". ]]
local function partialTypeMatch(typeName, typeSpec)
local diffLen = #typeName - #typeSpec
if diffLen < 0 then
return false
end
if typeName:sub(diffLen+1) ~= typeSpec then
return false
end
return diffLen == 0 or typeName:sub(diffLen, diffLen) == '.'
end
--[[ See if a given object is an instance of the provided torch class. ]]
function torch.isTypeOf(obj, typeSpec)
-- typeSpec can be provided as either a string, regexp, or the constructor.
-- If the constructor is used, we look in the __typename field of the
-- metatable to find a string to compare to.
local matchFunc
if type(typeSpec) == 'table' then
typeSpec = getmetatable(typeSpec).__typename
matchFunc = exactTypeMatch
elseif type(typeSpec) == 'string' then
matchFunc = partialTypeMatch
else
error("type must be provided as [regexp] string, or factory")
end
local mt = getmetatable(obj)
while mt do
if mt.__typename and matchFunc(mt.__typename, typeSpec) then
return true
end
mt = getmetatable(mt)
end
return false
end
torch.setdefaulttensortype('torch.DoubleTensor')
include('Tensor.lua')
include('File.lua')
include('CmdLine.lua')
include('FFI.lua')
include('Tester.lua')
include('test.lua')
function torch.totable(obj)
if torch.isTensor(obj) or torch.isStorage(obj) then
return obj:totable()
else
error("obj must be a Storage or a Tensor")
end
end
function torch.isTensor(obj)
local typename = torch.typename(obj)
if typename and typename:find('torch.*Tensor') then
return true
end
return false
end
function torch.isStorage(obj)
local typename = torch.typename(obj)
if typename and typename:find('torch.*Storage') then
return true
end
return false
end
-- alias for convenience
torch.Tensor.isTensor = torch.isTensor
return torch
| bsd-3-clause |
nesstea/darkstar | scripts/zones/Port_San_dOria/npcs/Eaugouint.lua | 13 | 1357 | -----------------------------------
-- Area: Port San d'Oria
-- NPC: Eaugouint
-- Standard Info NPC
-----------------------------------
package.loaded["scripts/zones/Port_San_dOria/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/quests");
require("scripts/zones/Port_San_dOria/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
-- "Flyers for Regine" conditional script
FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE);
if (FlyerForRegine == 1) then
count = trade:getItemCount();
MagicFlyer = trade:hasItemQty(532,1);
if (MagicFlyer == true and count == 1) then
player:messageSpecial(FLYER_REFUSED);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x243);
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 |
zuzuf/TA3D | src/ta3d/mods/ta3d/scripts/coravp.lua | 2 | 7123 | -- Arm Advanced Vehicle Plant Script
createUnitScript("coravp")
__this:piece( "base", "pipes", "blink_1", "blink_2",
"wing_1", "bay_1", "arm_1", "nano_1", "pow_1",
"wing_2", "bay_2", "arm_2", "nano_2", "pow_2",
"wing_3", "bay_3", "arm_3", "nano_3", "pow_3" )
__this.SMOKEPIECE1 = __this.base
__this.spray = 0
#include "StateChg.lh"
#include "smokeunit.lh"
#include "exptype.lh"
#include "yard.lh"
__this.activatescr = function(this)
this:turn( this.wing_1, z_axis, 90, 45)
this:turn( this.bay_1, z_axis, -90, 45)
this:turn( this.wing_2, x_axis, -90, 45)
this:turn( this.bay_2, x_axis, 90, 45)
this:turn( this.wing_3, z_axis, -90, 45)
this:turn( this.bay_3, z_axis, 90, 45)
this:wait_for_turn( this.bay_1, z_axis )
this:turn( this.arm_1, z_axis, -135, 45)
this:turn( this.nano_1, z_axis, 90, 45)
this:turn( this.arm_2, x_axis, 135, 45)
this:turn( this.nano_2, x_axis, -90, 45)
this:turn( this.arm_3, z_axis, 135, 45)
this:turn( this.nano_3, z_axis, -90, 45)
this:wait_for_turn( this.arm_1, z_axis )
this:turn( this.pow_1, z_axis, -90, 45)
this:turn( this.pow_2, x_axis, 90, 45)
this:turn( this.pow_3, z_axis, 90, 45)
this:wait_for_turn( this.pow_1, z_axis )
end
__this.deactivatescr = function(this)
this:turn( this.pow_1, z_axis, 0, 45)
this:turn( this.pow_2, x_axis, 0, 45)
this:turn( this.pow_3, z_axis, 0, 45)
this:wait_for_turn( this.pow_1, z_axis )
this:turn( this.arm_1, z_axis, 0, 45)
this:turn( this.nano_1, z_axis, 0, 45)
this:turn( this.arm_2, x_axis, 0, 45)
this:turn( this.nano_2, x_axis, 0, 45)
this:turn( this.arm_3, z_axis, 0, 45)
this:turn( this.nano_3, z_axis, 0, 45)
this:wait_for_turn( this.arm_1, z_axis )
this:turn( this.wing_1, z_axis, 0, 45)
this:turn( this.bay_1, z_axis, 0, 45)
this:turn( this.wing_2, x_axis, 0, 45)
this:turn( this.bay_2, x_axis, 0, 45)
this:turn( this.wing_3, z_axis, 0, 45)
this:turn( this.bay_3, z_axis, 0, 45)
this:wait_for_turn( this.bay_1, z_axis )
end
__this.Go = function(this)
this:activatescr()
this:OpenYard()
this:set( INBUILDSTANCE, true )
end
__this.Stop = function(this)
this:sleep( 5.0 )
this:set( INBUILDSTANCE, false )
this:CloseYard()
this:deactivatescr()
end
__this.ACTIVATECMD = __this.Go
__this.DEACTIVATECMD = __this.Stop
__this.Create = function(this)
this:InitState()
this:start_script( this.SmokeUnit, this )
end
__this.QueryNanoPiece = function(this)
if this.spray == 0 then
this.spray = 1
return this.nano_1
elseif this.spray == 1 then
this.spray = 2
return this.nano_2
end
this.spray = 0
return this.nano_3
end
__this.Activate = function(this)
this:start_script( this.RequestState, this, ACTIVE )
end
__this.Deactivate = function(this)
this:start_script( this.RequestState, this, INACTIVE )
end
__this.QueryBuildInfo = function(this)
return this.base
end
__this.SweetSpot = function(this)
return this.base
end
__this.Killed = function( this, severity )
if severity <= 25 then
this:explode( this.base, BITMAPONLY + BITMAP1 )
this:explode( this.nano_1, BITMAPONLY + BITMAP2 )
this:explode( this.nano_2, BITMAPONLY + BITMAP3 )
this:explode( this.nano_3, BITMAPONLY + BITMAP3 )
this:explode( this.blink_1, BITMAPONLY + BITMAP4 )
this:explode( this.blink_2, BITMAPONLY + BITMAP4 )
this:explode( this.arm_1, BITMAPONLY + BITMAP5 )
this:explode( this.arm_2, BITMAPONLY + BITMAP1 )
this:explode( this.arm_3, BITMAPONLY + BITMAP1 )
this:explode( this.pow_1, BITMAPONLY + BITMAP2 )
this:explode( this.pow_2, BITMAPONLY + BITMAP2 )
this:explode( this.pow_3, BITMAPONLY + BITMAP2 )
this:explode( this.wing_1, BITMAPONLY + BITMAP5 )
this:explode( this.wing_2, BITMAPONLY + BITMAP1 )
this:explode( this.wing_3, BITMAPONLY + BITMAP2 )
return 1
elseif severity <= 50 then
this:explode( this.base, BITMAPONLY + BITMAP1 )
this:explode( this.nano_1, FALL + BITMAP2 )
this:explode( this.nano_2, FALL + BITMAP3 )
this:explode( this.nano_3, FALL + BITMAP3 )
this:explode( this.blink_1, SHATTER + BITMAP4 )
this:explode( this.blink_2, SHATTER + BITMAP4 )
this:explode( this.arm_1, FALL + BITMAP5 )
this:explode( this.arm_2, FALL + BITMAP1 )
this:explode( this.arm_3, FALL + BITMAP1 )
this:explode( this.pow_1, FALL + BITMAP2 )
this:explode( this.pow_2, FALL + BITMAP3 )
this:explode( this.pow_3, FALL + BITMAP3 )
this:explode( this.wing_1, BITMAPONLY + BITMAP5 )
this:explode( this.wing_2, BITMAPONLY + BITMAP1 )
this:explode( this.wing_3, BITMAPONLY + BITMAP2 )
return 2
elseif severity <= 99 then
this:explode( this.base, BITMAPONLY + BITMAP1 )
this:explode( this.nano_1, FALL + SMOKE + FIRE + EXPLODE_ON_HIT + BITMAP2 )
this:explode( this.nano_2, FALL + SMOKE + FIRE + EXPLODE_ON_HIT + BITMAP3 )
this:explode( this.blink_1, SHATTER + BITMAP4 )
this:explode( this.blink_2, SHATTER + BITMAP4 )
this:explode( this.arm_1, FALL + SMOKE + FIRE + EXPLODE_ON_HIT + BITMAP5 )
this:explode( this.arm_2, FALL + SMOKE + FIRE + EXPLODE_ON_HIT + BITMAP1 )
this:explode( this.arm_3, FALL + SMOKE + FIRE + EXPLODE_ON_HIT + BITMAP1 )
this:explode( this.pow_1, FALL + SMOKE + FIRE + EXPLODE_ON_HIT + BITMAP2 )
this:explode( this.pow_2, FALL + SMOKE + FIRE + EXPLODE_ON_HIT + BITMAP3 )
this:explode( this.pow_3, FALL + SMOKE + FIRE + EXPLODE_ON_HIT + BITMAP3 )
this:explode( this.wing_1, BITMAPONLY + BITMAP5 )
this:explode( this.wing_2, BITMAPONLY + BITMAP1 )
this:explode( this.wing_3, BITMAPONLY + BITMAP2 )
return 3
end
this:explode( this.base, BITMAPONLY + BITMAP1 )
this:explode( this.nano_1, FALL + SMOKE + FIRE + EXPLODE_ON_HIT + BITMAP2 )
this:explode( this.nano_2, FALL + SMOKE + FIRE + EXPLODE_ON_HIT + BITMAP3 )
this:explode( this.nano_3, FALL + SMOKE + FIRE + EXPLODE_ON_HIT + BITMAP3 )
this:explode( this.blink_1, SHATTER + EXPLODE_ON_HIT + BITMAP4 )
this:explode( this.blink_2, SHATTER + EXPLODE_ON_HIT + BITMAP4 )
this:explode( this.arm_1, FALL + SMOKE + FIRE + EXPLODE_ON_HIT + BITMAP5 )
this:explode( this.arm_2, FALL + SMOKE + FIRE + EXPLODE_ON_HIT + BITMAP1 )
this:explode( this.arm_3, FALL + SMOKE + FIRE + EXPLODE_ON_HIT + BITMAP5 )
this:explode( this.pow_1, FALL + SMOKE + FIRE + EXPLODE_ON_HIT + BITMAP2 )
this:explode( this.pow_2, FALL + SMOKE + FIRE + EXPLODE_ON_HIT + BITMAP3 )
this:explode( this.pow_3, BITMAPONLY + BITMAP4 )
this:explode( this.wing_1, BITMAPONLY + BITMAP5 )
this:explode( this.wing_2, BITMAPONLY + BITMAP1 )
this:explode( this.wing_3, BITMAPONLY + BITMAP2 )
return 3
end
| gpl-2.0 |
nesstea/darkstar | scripts/globals/items/roast_trout.lua | 18 | 1260 | -----------------------------------------
-- ID: 4404
-- Item: roast_trout
-- Food Effect: 30Min, All Races
-----------------------------------------
-- Dexterity 3
-- Mind -1
-- Ranged ATT % 14
-----------------------------------------
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,4404);
end;
-----------------------------------
-- onEffectGain Action
-----------------------------------
function onEffectGain(target,effect)
target:addMod(MOD_DEX, 3);
target:addMod(MOD_MND, -1);
target:addMod(MOD_RATTP, 14);
end;
-----------------------------------------
-- onEffectLose Action
-----------------------------------------
function onEffectLose(target,effect)
target:delMod(MOD_DEX, 3);
target:delMod(MOD_MND, -1);
target:delMod(MOD_RATTP, 14);
end;
| gpl-3.0 |
nesstea/darkstar | scripts/zones/Pashhow_Marshlands/npcs/Cavernous_Maw.lua | 29 | 1460 | -----------------------------------
-- Area: Pashhow Marshlands
-- NPC: Cavernous Maw
-- @pos 418 25 27 109
-- Teleports Players to Pashhow Marshlands [S]
-----------------------------------
package.loaded["scripts/zones/Pashhow_Marshlands/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/teleports");
require("scripts/globals/campaign");
require("scripts/zones/Pashhow_Marshlands/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (ENABLE_WOTG == 1 and player:hasKeyItem(PURE_WHITE_FEATHER) and hasMawActivated(player,4)) then
player:startEvent(0x0389);
else
player:messageSpecial(NOTHING_HAPPENS);
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 (csid == 0x0389 and option == 1) then
toMaw(player,15);
end
end; | gpl-3.0 |
nesstea/darkstar | scripts/zones/Port_Jeuno/npcs/Guddal.lua | 13 | 2230 | -----------------------------------
-- Area: Port Jeuno
-- NPC: Guddal
-- Starts and Finishes Quest: Kazham Airship Pass (This quest does not appear in your quest log)
-- @zone 246
-- @pos -14 8 44
-----------------------------------
package.loaded["scripts/zones/Port_Jeuno/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/zones/Port_Jeuno/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
if (player:hasKeyItem(AIRSHIP_PASS_FOR_KAZHAM) == false) then
if (trade:hasItemQty(1024,1) == true and trade:hasItemQty(1025,1) == true and trade:hasItemQty(1026,1) == true and
trade:getGil() == 0 and trade:getItemCount() == 3) then
player:startEvent(0x012d); -- Ending quest "Kazham Airship Pass"
else
player:startEvent(0x012e);
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
if (player:hasKeyItem(AIRSHIP_PASS_FOR_KAZHAM) == false) then
player:startEvent(0x012c);
end
end;
-----------------------------------
-- onEventUpdate
-----------------------------------
function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x012c) then
if (player:delGil(148000)) then
player:addKeyItem(AIRSHIP_PASS_FOR_KAZHAM);
player:updateEvent(0,1);
end
end
end;
-----------------------------------
-- onEventFinish
-----------------------------------
function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
if (csid == 0x012c) then
if (player:hasKeyItem(AIRSHIP_PASS_FOR_KAZHAM) == true) then
player:messageSpecial(KEYITEM_OBTAINED,AIRSHIP_PASS_FOR_KAZHAM);
end
elseif (csid == 0x012d) then
player:addKeyItem(AIRSHIP_PASS_FOR_KAZHAM);
player:messageSpecial(KEYITEM_OBTAINED,AIRSHIP_PASS_FOR_KAZHAM);
player:tradeComplete();
end
end;
| gpl-3.0 |
nesstea/darkstar | scripts/zones/Windurst_Woods/npcs/Miiri-Wohri.lua | 13 | 1052 | -----------------------------------
-- Area: Windurst Woods
-- NPC: Miiri-Wohri
-- Type: Standard NPC
-- @zone: 241
-- @pos 106.766 -6 -30.492
--
-- Auto-Script: Requires Verification (Verfied by Brawndo)
-----------------------------------
package.loaded["scripts/zones/Windurst_Woods/TextIDs"] = nil;
-----------------------------------
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x006f);
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 |
nesstea/darkstar | scripts/zones/Den_of_Rancor/npcs/_4g4.lua | 27 | 2344 | -----------------------------------
-- Area: Den of Rancor
-- NPC: Lantern (NW)
-- @pos -59 45 24 160
-----------------------------------
package.loaded["scripts/zones/Den_of_Rancor/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/zones/Den_of_Rancor/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
local Lantern_ID = 17433047
local LSW = GetNPCByID(Lantern_ID):getAnimation();
local LNW = GetNPCByID(Lantern_ID+1):getAnimation();
local LNE = GetNPCByID(Lantern_ID+2):getAnimation();
local LSE = GetNPCByID(Lantern_ID+3):getAnimation();
-- Trade Crimson Rancor Flame
if (trade:hasItemQty(1139,1) and trade:getItemCount() == 1) then
if (LNW == 8) then
player:messageSpecial(LANTERN_OFFSET + 7); -- already lit
elseif (LNW == 9) then
npc:openDoor(LANTERNS_STAY_LIT);
local ALL = LSW+LNE+LSE;
player:tradeComplete();
player:addItem(1138); -- Unlit Lantern
if ALL == 27 then
player:messageSpecial(LANTERN_OFFSET + 9);
elseif ALL == 26 then
player:messageSpecial(LANTERN_OFFSET + 10);
elseif ALL == 25 then
player:messageSpecial(LANTERN_OFFSET + 11);
elseif ALL == 24 then
player:messageSpecial(LANTERN_OFFSET + 12);
GetNPCByID(Lantern_ID+3):closeDoor(1);
GetNPCByID(Lantern_ID+2):closeDoor(1);
GetNPCByID(Lantern_ID+1):closeDoor(1);
GetNPCByID(Lantern_ID):closeDoor(1);
GetNPCByID(Lantern_ID+4):openDoor(30);
GetNPCByID(Lantern_ID+3):openDoor(30);
GetNPCByID(Lantern_ID+2):openDoor(30);
GetNPCByID(Lantern_ID+1):openDoor(30);
GetNPCByID(Lantern_ID):openDoor(30);
end
end
end
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local npca = npc:getAnimation()
if (npca == 8) then
player:messageSpecial(LANTERN_OFFSET + 7); -- already lit
else
player:messageSpecial(LANTERN_OFFSET + 20); -- unlit
end
return 0;
end; | gpl-3.0 |
UnfortunateFruit/darkstar | scripts/zones/Dynamis-San_dOria/bcnms/dynamis_sandoria.lua | 10 | 1179 | -----------------------------------
-- Area: Dynamis San d'Oria
-- Name: Dynamis San d'Oria
-----------------------------------
-- After registering the BCNM via bcnmRegister(bcnmid)
function onBcnmRegister(player,instance)
SetServerVariable("[DynaSandoria]UniqueID",player:getDynamisUniqueID(1281));
SetServerVariable("[DynaSandoria]Boss_Trigger",0);
SetServerVariable("[DynaSandoria]Already_Received",0);
end;
-- Physically entering the BCNM via bcnmEnter(bcnmid)
function onBcnmEnter(player,instance)
player:setVar("DynamisID",GetServerVariable("[DynaSandoria]UniqueID"));
local realDay = os.time();
local dynaWaitxDay = player:getVar("dynaWaitxDay");
if ((dynaWaitxDay + (BETWEEN_2DYNA_WAIT_TIME * 24 * 60 * 60)) < realDay) then
player:setVar("dynaWaitxDay",realDay);
end
end;
-- Leaving the Dynamis by every mean possible, given by the LeaveCode
-- 3=Disconnected or warped out (if dyna is empty: launch 4 after 3)
-- 4=Finish he dynamis
function onBcnmLeave(player,instance,leavecode)
--print("leave code "..leavecode);
if(leavecode == 4) then
GetNPCByID(17535224):setStatus(2);
SetServerVariable("[DynaSandoria]UniqueID",0);
end
end; | gpl-3.0 |
UnfortunateFruit/darkstar | scripts/zones/Bastok_Mines/npcs/Tall_Mountain.lua | 17 | 1884 | -----------------------------------
-- Area: Bastok Mines
-- NPC: Tall Mountain
-- Involved in Quest: Stamp Hunt
-- Finish Mission: Bastok 6-1
-- @pos 71 7 -7 234
-----------------------------------
package.loaded["scripts/zones/Bastok_Mines/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/globals/missions");
require("scripts/globals/quests");
require("scripts/zones/Bastok_Mines/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
local StampHunt = player:getQuestStatus(BASTOK,STAMP_HUNT);
if(player:getCurrentMission(BASTOK) == RETURN_OF_THE_TALEKEEPER and player:getVar("MissionStatus") == 3) then
player:startEvent(0x00b6);
elseif (StampHunt == QUEST_ACCEPTED and player:getMaskBit(player:getVar("StampHunt_Mask"),1) == false) then
player:startEvent(0x0055);
else
player:startEvent(0x0037);
end
end;
-- 0x7fb5 0x0037 0x0055 0x00b0 0x00b4 0x00b6 0x024f 0x0251
-----------------------------------
-- 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 == 0x00b6) then
finishMissionTimeline(player,1,csid,option);
elseif (csid == 0x0055) then
player:setMaskBit(player:getVar("StampHunt_Mask"),"StampHunt_Mask",1,true);
end
end;
| gpl-3.0 |
osdba/sysbench2 | sysbench/tests/db/select_random_ranges.lua | 11 | 4066 | -- This test is designed for testing MariaDB's key_cache_segments for MyISAM,
-- and should work with other storage engines as well.
--
-- For details about key_cache_segments please refer to:
-- http://kb.askmonty.org/v/segmented-key-cache
--
function prepare()
local query
local i
set_vars()
db_connect()
print("Creating table 'sbtest'...")
if (db_driver == "mysql") then
query = [[
CREATE TABLE sbtest (
id INTEGER UNSIGNED NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
k INTEGER UNSIGNED DEFAULT '0' NOT NULL,
c CHAR(120) DEFAULT '' NOT NULL,
pad CHAR(60) DEFAULT '' NOT NULL,
PRIMARY KEY (id)
) /*! ENGINE = ]] .. mysql_table_engine .. " MAX_ROWS = " .. myisam_max_rows .. " */"
elseif (db_driver == "oracle") then
query = [[
CREATE TABLE sbtest (
id INTEGER NOT NULL,
k INTEGER,
c CHAR(120) DEFAULT '' NOT NULL,
pad CHAR(60 DEFAULT '' NOT NULL,
PRIMARY KEY (id)
) ]]
elseif (db_driver == "pgsql") then
query = [[
CREATE TABLE sbtest (
id ]] .. (sb.oltp_auto_inc and "SERIAL") or "" .. [[,
k INTEGER DEFAULT '0' NOT NULL,
c CHAR(120) DEFAULT '' NOT NULL,
pad CHAR(60) DEFAULT '' NOT NULL,
PRIMARY KEY (id)
) ]]
elseif (db_driver == "drizzle") then
query = [[
CREATE TABLE sbtest (
id INTEGER NOT NULL ]] .. ((oltp_auto_inc and "AUTO_INCREMENT") or "") .. [[,
k INTEGER DEFAULT '0' NOT NULL,
c CHAR(120) DEFAULT '' NOT NULL,
pad CHAR(60) DEFAULT '' NOT NULL,
PRIMARY KEY (id)
) ]]
else
print("Unknown database driver: " .. db_driver)
return 1
end
db_query(query)
if (db_driver == "oracle") then
db_query("CREATE SEQUENCE sbtest_seq")
db_query([[CREATE TRIGGER sbtest_trig BEFORE INSERT ON sbtest
FOR EACH ROW BEGIN SELECT sbtest_seq.nextval INTO :new.id FROM DUAL; END;]])
end
db_query("CREATE INDEX k on sbtest(k)")
print("Inserting " .. oltp_table_size .. " records into 'sbtest'")
if (oltp_auto_inc) then
db_bulk_insert_init("INSERT INTO sbtest(k, c, pad) VALUES")
else
db_bulk_insert_init("INSERT INTO sbtest(id, k, c, pad) VALUES")
end
for i = 1,oltp_table_size do
if (oltp_auto_inc) then
db_bulk_insert_next("("..i..", ' ', 'qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
else
db_bulk_insert_next("("..i..", "..i..", ' ', 'qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt')")
end
end
db_bulk_insert_done()
return 0
end
function cleanup()
print("Dropping table 'sbtest'...")
db_query("DROP TABLE sbtest")
end
function thread_init(thread_id)
set_vars()
ranges = ""
for i = 1,number_of_ranges do
ranges = ranges .. "k BETWEEN ? AND ? OR "
end
-- Get rid of last OR and space.
ranges = string.sub(ranges, 1, string.len(ranges) - 3)
stmt = db_prepare([[
SELECT count(k)
FROM sbtest
WHERE ]] .. ranges .. [[
]])
params = {}
for j = 1,number_of_ranges * 2 do
params[j] = 1
end
db_bind_param(stmt, params)
end
function event(thread_id)
local rs
-- To prevent overlapping of our range queries we need to partition the whole table
-- into num_threads segments and then make each thread work with its own segment.
for i = 1,number_of_ranges * 2,2 do
params[i] = sb_rand(oltp_table_size / num_threads * thread_id, oltp_table_size / num_threads * (thread_id + 1))
params[i + 1] = params[i] + delta
end
rs = db_execute(stmt)
db_store_results(rs)
db_free_results(rs)
end
function set_vars()
oltp_table_size = oltp_table_size or 10000
number_of_ranges = number_of_ranges or 10
delta = random_ranges_delta or 5
if (oltp_auto_inc == 'off') then
oltp_auto_inc = false
else
oltp_auto_inc = true
end
end
| gpl-2.0 |
DavisDev/OneInstaller | system/libs/lib_scroll.lua | 1 | 1286 | --[[
Libreria Scroll
Ideada principalmente en facilitar el manejo de un scroll
Para la utilizacion del metodo:
for i=ini,lim do
if i=sel then
else
end
end
]]
scroll = {}
function scroll.set(num,tab,mxn)
scroll[num] = {ini=1,sel=1,lim=1,maxim=1}
if #tab > mxn then scroll[num].lim=mxn else scroll[num].lim=#tab end
scroll[num].maxim = #tab
end
function scroll.max(num,mx)
scroll[num].maxim = #mx
end
function scroll.up(num)
if scroll[num].sel>scroll[num].ini then scroll[num].sel=scroll[num].sel-1
elseif scroll[num].ini-1>=1 then
scroll[num].ini,scroll[num].sel,scroll[num].lim=scroll[num].ini-1,scroll[num].sel-1,scroll[num].lim-1
end
end
function scroll.down(num)
if scroll[num].sel<scroll[num].lim then scroll[num].sel=scroll[num].sel+1
elseif scroll[num].lim+1<=scroll[num].maxim then
scroll[num].ini,scroll[num].sel,scroll[num].lim=scroll[num].ini+1,scroll[num].sel+1,scroll[num].lim+1
end
end
function scroll.print(num,x,y,h,tabla,color1,color2,tam)--Funcion de prueba
scroll[num].y = y
for i=scroll[num].ini,scroll[num].lim do
if i==scroll[num].sel then
screen.print(x,scroll[num].y,tabla[i],tam,color1)
else
screen.print(x,scroll[num].y,tabla[i],tam,color2)
end
scroll[num].y = scroll[num].y + h
end
end | cc0-1.0 |
gabri94/packages-2 | utils/yunbridge/files/usr/lib/lua/luci/controller/arduino/index.lua | 103 | 12089 | --[[
This file is part of YunWebUI.
YunWebUI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
As a special exception, you may use this file as part of a free software
library without restriction. Specifically, if other files instantiate
templates or use macros or inline functions from this file, or you compile
this file and link it with other files to produce an executable, this
file does not by itself cause the resulting executable to be covered by
the GNU General Public License. This exception does not however
invalidate any other reasons why the executable file might be covered by
the GNU General Public License.
Copyright 2013 Arduino LLC (http://www.arduino.cc/)
]]
module("luci.controller.arduino.index", package.seeall)
local function not_nil_or_empty(value)
return value and value ~= ""
end
local function get_first(cursor, config, type, option)
return cursor:get_first(config, type, option)
end
local function set_first(cursor, config, type, option, value)
cursor:foreach(config, type, function(s)
if s[".type"] == type then
cursor:set(config, s[".name"], option, value)
end
end)
end
local function to_key_value(s)
local parts = luci.util.split(s, ":")
parts[1] = luci.util.trim(parts[1])
parts[2] = luci.util.trim(parts[2])
return parts[1], parts[2]
end
function http_error(code, text)
luci.http.prepare_content("text/plain")
luci.http.status(code)
if text then
luci.http.write(text)
end
end
function index()
function luci.dispatcher.authenticator.arduinoauth(validator, accs, default)
require("luci.controller.arduino.index")
local user = luci.http.formvalue("username")
local pass = luci.http.formvalue("password")
local basic_auth = luci.http.getenv("HTTP_AUTHORIZATION")
if user and validator(user, pass) then
return user
end
if basic_auth and basic_auth ~= "" then
local decoded_basic_auth = nixio.bin.b64decode(string.sub(basic_auth, 7))
user = string.sub(decoded_basic_auth, 0, string.find(decoded_basic_auth, ":") - 1)
pass = string.sub(decoded_basic_auth, string.find(decoded_basic_auth, ":") + 1)
end
if user then
if #pass ~= 64 and validator(user, pass) then
return user
elseif #pass == 64 then
local uci = luci.model.uci.cursor()
uci:load("yunbridge")
local stored_encrypted_pass = uci:get_first("yunbridge", "bridge", "password")
if pass == stored_encrypted_pass then
return user
end
end
end
luci.http.header("WWW-Authenticate", "Basic realm=\"yunbridge\"")
luci.http.status(401)
return false
end
local function make_entry(path, target, title, order)
local page = entry(path, target, title, order)
page.leaf = true
return page
end
-- web panel
local webpanel = entry({ "webpanel" }, alias("webpanel", "go_to_homepage"), _("%s Web Panel") % luci.sys.hostname(), 10)
webpanel.sysauth = "root"
webpanel.sysauth_authenticator = "arduinoauth"
make_entry({ "webpanel", "go_to_homepage" }, call("go_to_homepage"), nil)
--api security level
local uci = luci.model.uci.cursor()
uci:load("yunbridge")
local secure_rest_api = uci:get_first("yunbridge", "bridge", "secure_rest_api")
local rest_api_sysauth = false
if secure_rest_api == "true" then
rest_api_sysauth = webpanel.sysauth
end
--storage api
local data_api = node("data")
data_api.sysauth = rest_api_sysauth
data_api.sysauth_authenticator = webpanel.sysauth_authenticator
make_entry({ "data", "get" }, call("storage_send_request"), nil).sysauth = rest_api_sysauth
make_entry({ "data", "put" }, call("storage_send_request"), nil).sysauth = rest_api_sysauth
make_entry({ "data", "delete" }, call("storage_send_request"), nil).sysauth = rest_api_sysauth
local mailbox_api = node("mailbox")
mailbox_api.sysauth = rest_api_sysauth
mailbox_api.sysauth_authenticator = webpanel.sysauth_authenticator
make_entry({ "mailbox" }, call("build_bridge_mailbox_request"), nil).sysauth = rest_api_sysauth
--plain socket endpoint
local plain_socket_endpoint = make_entry({ "arduino" }, call("board_plain_socket"), nil)
plain_socket_endpoint.sysauth = rest_api_sysauth
plain_socket_endpoint.sysauth_authenticator = webpanel.sysauth_authenticator
end
function go_to_homepage()
luci.http.redirect("/index.html")
end
local function build_bridge_request(command, params)
local bridge_request = {
command = command
}
if command == "raw" then
params = table.concat(params, "/")
if not_nil_or_empty(params) then
bridge_request["data"] = params
end
return bridge_request
end
if command == "get" then
if not_nil_or_empty(params[1]) then
bridge_request["key"] = params[1]
end
return bridge_request
end
if command == "put" and not_nil_or_empty(params[1]) and params[2] then
bridge_request["key"] = params[1]
bridge_request["value"] = params[2]
return bridge_request
end
if command == "delete" and not_nil_or_empty(params[1]) then
bridge_request["key"] = params[1]
return bridge_request
end
return nil
end
local function extract_jsonp_param(query_string)
if not not_nil_or_empty(query_string) then
return nil
end
local qs_parts = string.split(query_string, "&")
for idx, value in ipairs(qs_parts) do
if string.find(value, "jsonp") == 1 or string.find(value, "callback") == 1 then
return string.sub(value, string.find(value, "=") + 1)
end
end
end
local function parts_after(url_part)
local url = luci.http.getenv("PATH_INFO")
local url_after_part = string.find(url, "/", string.find(url, url_part) + 1)
if not url_after_part then
return {}
end
return luci.util.split(string.sub(url, url_after_part + 1), "/")
end
function storage_send_request()
local method = luci.http.getenv("REQUEST_METHOD")
local jsonp_callback = extract_jsonp_param(luci.http.getenv("QUERY_STRING"))
local parts = parts_after("data")
local command = parts[1]
if not command or command == "" then
luci.http.status(404)
return
end
local params = {}
for idx, param in ipairs(parts) do
if idx > 1 and not_nil_or_empty(param) then
table.insert(params, param)
end
end
-- TODO check method?
local bridge_request = build_bridge_request(command, params)
if not bridge_request then
luci.http.status(403)
return
end
local uci = luci.model.uci.cursor()
uci:load("yunbridge")
local socket_timeout = uci:get_first("yunbridge", "bridge", "socket_timeout", 5)
local sock, code, msg = nixio.connect("127.0.0.1", 5700)
if not sock then
code = code or ""
msg = msg or ""
http_error(500, "nil socket, " .. code .. " " .. msg)
return
end
sock:setopt("socket", "sndtimeo", socket_timeout)
sock:setopt("socket", "rcvtimeo", socket_timeout)
sock:setopt("tcp", "nodelay", 1)
local json = require("luci.json")
sock:write(json.encode(bridge_request))
sock:writeall("\n")
local response_text = {}
while true do
local bytes = sock:recv(4096)
if bytes and #bytes > 0 then
table.insert(response_text, bytes)
end
local json_response = json.decode(table.concat(response_text))
if json_response then
sock:close()
luci.http.status(200)
if jsonp_callback then
luci.http.prepare_content("application/javascript")
luci.http.write(jsonp_callback)
luci.http.write("(")
luci.http.write_json(json_response)
luci.http.write(");")
else
luci.http.prepare_content("application/json")
luci.http.write(json.encode(json_response))
end
return
end
if not bytes or #response_text == 0 then
sock:close()
http_error(500, "Empty response")
return
end
end
sock:close()
end
function board_plain_socket()
local function send_response(response_text, jsonp_callback)
if not response_text then
luci.http.status(500)
return
end
local rows = luci.util.split(response_text, "\r\n")
if #rows == 1 or string.find(rows[1], "Status") ~= 1 then
luci.http.prepare_content("text/plain")
luci.http.status(200)
luci.http.write(response_text)
return
end
local body_start_at_idx = -1
local content_type = "text/plain"
for idx, row in ipairs(rows) do
if row == "" then
body_start_at_idx = idx
break
end
local key, value = to_key_value(row)
if string.lower(key) == "status" then
luci.http.status(tonumber(value))
elseif string.lower(key) == "content-type" then
content_type = value
else
luci.http.header(key, value)
end
end
local response_body = table.concat(rows, "\r\n", body_start_at_idx + 1)
if content_type == "application/json" and jsonp_callback then
local json = require("luci.json")
luci.http.prepare_content("application/javascript")
luci.http.write(jsonp_callback)
luci.http.write("(")
luci.http.write_json(json.decode(response_body))
luci.http.write(");")
else
luci.http.prepare_content(content_type)
luci.http.write(response_body)
end
end
local method = luci.http.getenv("REQUEST_METHOD")
local jsonp_callback = extract_jsonp_param(luci.http.getenv("QUERY_STRING"))
local parts = parts_after("arduino")
local params = {}
for idx, param in ipairs(parts) do
if not_nil_or_empty(param) then
table.insert(params, param)
end
end
if #params == 0 then
luci.http.status(404)
return
end
params = table.concat(params, "/")
local uci = luci.model.uci.cursor()
uci:load("yunbridge")
local socket_timeout = uci:get_first("yunbridge", "bridge", "socket_timeout", 5)
local sock, code, msg = nixio.connect("127.0.0.1", 5555)
if not sock then
code = code or ""
msg = msg or ""
http_error(500, "Could not connect to YunServer " .. code .. " " .. msg)
return
end
sock:setopt("socket", "sndtimeo", socket_timeout)
sock:setopt("socket", "rcvtimeo", socket_timeout)
sock:setopt("tcp", "nodelay", 1)
sock:write(params)
sock:writeall("\r\n")
local response_text = sock:readall()
sock:close()
send_response(response_text, jsonp_callback)
end
function build_bridge_mailbox_request()
local method = luci.http.getenv("REQUEST_METHOD")
local jsonp_callback = extract_jsonp_param(luci.http.getenv("QUERY_STRING"))
local parts = parts_after("mailbox")
local params = {}
for idx, param in ipairs(parts) do
if not_nil_or_empty(param) then
table.insert(params, param)
end
end
if #params == 0 then
luci.http.status(400)
return
end
local bridge_request = build_bridge_request("raw", params)
if not bridge_request then
luci.http.status(403)
return
end
local uci = luci.model.uci.cursor()
uci:load("yunbridge")
local socket_timeout = uci:get_first("yunbridge", "bridge", "socket_timeout", 5)
local sock, code, msg = nixio.connect("127.0.0.1", 5700)
if not sock then
code = code or ""
msg = msg or ""
http_error(500, "nil socket, " .. code .. " " .. msg)
return
end
sock:setopt("socket", "sndtimeo", socket_timeout)
sock:setopt("socket", "rcvtimeo", socket_timeout)
sock:setopt("tcp", "nodelay", 1)
local json = require("luci.json")
sock:write(json.encode(bridge_request))
sock:writeall("\n")
sock:close()
luci.http.status(200)
end
| gpl-2.0 |
UnfortunateFruit/darkstar | scripts/zones/Aht_Urhgan_Whitegate/npcs/Zhamwaa.lua | 34 | 1032 | -----------------------------------
-- Area: Aht Urhgan Whitegate
-- NPC: Zhamwaa
-- Standard Info NPC
-----------------------------------
package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil;
-----------------------------------
require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs");
-----------------------------------
-- onTrade Action
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- onTrigger Action
-----------------------------------
function onTrigger(player,npc)
player:startEvent(0x01F4);
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 |
albfan/clink | clink/test/test_args.lua | 4 | 10010 | --
-- Copyright (c) 2013 Martin Ridgers
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--
--------------------------------------------------------------------------------
local p
local q
local r
local s
--------------------------------------------------------------------------------
s = clink.arg.new_parser()
s:set_arguments({ "one" , "two" })
r = clink.arg.new_parser()
r:set_arguments({ "five", "six" })
r:loop()
q = clink.arg.new_parser()
q:set_arguments({ "four" .. r })
p = clink.arg.new_parser()
p:set_arguments(
{
"one",
"two",
"three" .. q,
"spa ce" .. s,
}
)
clink.arg.register_parser("argcmd", p)
clink.test.test_matches(
"Node matches 1",
"argcmd ",
{ "one", "two", "three", "spa ce" }
)
clink.test.test_matches(
"Node matches 2",
"argcmd t",
{ "two", "three" }
)
clink.test.test_matches(
"Node matches 3 (.exe)",
"argcmd.exe t",
{ "two", "three" }
)
clink.test.test_matches(
"Node matches 4 (.bat)",
"argcmd.bat t",
{ "two", "three" }
)
clink.test.test_matches(
"Node matches quoted 1",
"argcmd \"t",
{ "two", "three" }
)
clink.test.test_matches(
"Node matches quoted executable",
"\"argcmd\" t",
{ "two", "three" }
)
clink.test.test_output(
"Key as only match.",
"argcmd three",
"argcmd three four "
)
clink.test.test_matches(
"Simple traversal 1",
"argcmd three four ",
{ "five", "six" }
)
clink.test.test_output(
"Simple traversal 2",
"argcmd th\tf",
"argcmd three four "
)
clink.test.test_output(
"Simple traversal 3",
"argcmd one one one",
"argcmd one one one"
)
clink.test.test_matches(
"Simple traversal 4",
"argcmd one one "
)
clink.test.test_matches(
"Quoted traversal 1",
"argcmd \"three\" four ",
{ "five", "six" }
)
clink.test.test_matches(
"Quoted traversal 2a",
"argcmd three four \"",
{ "five", "six" }
)
clink.test.test_output(
"Quoted traversal 2b",
"argcmd three four \"fi",
"argcmd three four \"five\" "
)
clink.test.test_output(
"Quoted traversal 2c",
"argcmd three four \"five\" five five s",
"argcmd three four \"five\" five five six "
)
clink.test.test_output(
"Quoted traversal 3",
"argcmd \"three\"",
"argcmd three four "
)
clink.test.test_matches(
"Quoted traversal 4",
"argcmd \"spa ce\" ",
{ "one", "two" }
)
clink.test.test_output(
"Quoted traversal 5",
"argcmd spa",
"argcmd \"spa ce\" "
)
clink.test.test_matches(
"Loop property: basic",
"argcmd three four six \t",
{ "five", "six" }
)
clink.test.test_matches(
"Loop property: miss",
"argcmd three four green four \t",
{ "five", "six" }
)
clink.test.test_matches(
"Separator && 1",
"nullcmd && argcmd t",
{ "two", "three" }
)
clink.test.test_matches(
"Separator && 1",
"nullcmd &&argcmd t",
{ "two", "three" }
)
clink.test.test_matches(
"Separator && 2",
"nullcmd \"&&\" && argcmd t",
{ "two", "three" }
)
clink.test.test_matches(
"Separator && 3",
"nullcmd \"&&\"&&argcmd t",
{ "two", "three" }
)
clink.test.test_matches(
"Separator &",
"nullcmd & argcmd t",
{ "two", "three" }
)
clink.test.test_matches(
"Separator | 1",
"nullcmd | argcmd t",
{ "two", "three" }
)
clink.test.test_matches(
"Separator | 2",
"nullcmd|argcmd t",
{ "two", "three" }
)
clink.test.test_matches(
"Separator multiple 1",
"nullcmd | nullcmd && argcmd t",
{ "two", "three" }
)
clink.test.test_matches(
"Separator multiple 2",
"nullcmd | nullcmd && argcmd |argcmd t",
{ "two", "three" }
)
clink.test.test_output(
"Not separator",
"argcmd three four \" &&foobar\" f",
"argcmd three four \" &&foobar\" five "
)
clink.test.test_matches(
"Path: relative",
".\\foo\\bar\\argcmd t",
{ "two", "three" }
)
clink.test.test_matches(
"Path: absolute",
"c:\\foo\\bar\\argcmd t",
{ "two", "three" }
)
--------------------------------------------------------------------------------
p = clink.arg.new_parser()
p:set_arguments({
"true",
"sub_parser" .. clink.arg.new_parser():disable_file_matching(),
"this_parser"
})
clink.arg.register_parser("argcmd_file", p)
clink.test.test_matches(
"File matching enabled",
"argcmd_file true "
)
clink.test.test_output(
"File matching disabled: sub",
"argcmd_file sub_parser ",
"argcmd_file sub_parser "
)
p:disable_file_matching()
clink.test.test_output(
"File matching disabled: this",
"argcmd_file this_parser ",
"argcmd_file this_parser "
)
--------------------------------------------------------------------------------
clink.arg.register_parser("argcmd_table", {"two", "three", "one"});
clink.test.test_matches(
"Parserless: table",
"argcmd_table t",
{ "two", "three" }
)
--------------------------------------------------------------------------------
q = clink.arg.new_parser()
q:set_arguments({ "four", "five" })
p = clink.arg.new_parser()
p:set_arguments(
{ "one", "onetwo", "onethree" } .. q
)
clink.arg.register_parser("argcmd_substr", p);
clink.test.test_matches(
"Full match is also partial match 1",
"argcmd_substr one",
{ "one", "onetwo", "onethree" }
)
clink.test.test_matches(
"Full match is also partial match 2",
"argcmd_substr one f",
{ "four", "five" }
)
--------------------------------------------------------------------------------
local tbl_1 = { "one", "two", "three" }
local tbl_2 = { "four", "five", tbl_1 }
q = clink.arg.new_parser()
q:set_arguments({ "fifth", tbl_2 })
p = clink.arg.new_parser()
p:set_arguments({ "once", tbl_1 } .. q)
clink.arg.register_parser("argcmd_nested", p)
clink.test.test_matches(
"Nested table: simple",
"argcmd_nested on",
{ "once", "one" }
)
clink.test.test_matches(
"Nested table: sub-parser",
"argcmd_nested once f",
{ "fifth", "four", "five" }
)
--------------------------------------------------------------------------------
q = clink.arg.new_parser()
q:set_arguments({ "two", "three" }, { "four", "banana" })
q:loop()
p = clink.arg.new_parser()
p:set_arguments({ "one" }, q)
clink.arg.register_parser("argcmd_parser", p)
clink.test.test_matches(
"Nested full parser",
"argcmd_parser one t",
{ "two", "three" }
)
clink.test.test_matches(
"Nested full parser - loop",
"argcmd_parser one two four t",
{ "two", "three" }
)
--------------------------------------------------------------------------------
p = clink.arg.new_parser()
p:set_flags("/one", "/two", "/twenty")
q = clink.arg.new_parser()
q:set_flags("-one", "-two", "-twenty")
clink.arg.register_parser("argcmd_flags_s", p)
clink.arg.register_parser("argcmd_flags_d", q)
clink.test.test_output(
"Flags: slash 1a",
"argcmd_flags_s nothing /",
"argcmd_flags_s nothing /"
)
clink.test.test_output(
"Flags: slash 1b",
"argcmd_flags_s /",
"argcmd_flags_s /"
)
p:disable_file_matching()
clink.test.test_output(
"Flags: slash 1c",
"argcmd_flags_s /",
"argcmd_flags_s /"
)
clink.test.test_output(
"Flags: slash 1d",
"argcmd_flags_s nothing /",
"argcmd_flags_s nothing /"
)
clink.test.test_matches(
"Flags: slash 2a",
"argcmd_flags_s nothing /tw",
{ "/two", "/twenty" }
)
clink.test.test_matches(
"Flags: slash 2b",
"argcmd_flags_s out of bounds /tw",
{ "/two", "/twenty" }
)
clink.test.test_matches(
"Flags: slash 2c",
"argcmd_flags_s /tw",
{ "/two", "/twenty" }
)
clink.test.test_output(
"Flags: dash 1",
"argcmd_flags_d -t",
"argcmd_flags_d -tw"
)
clink.test.test_matches(
"Flags: dash 2",
"argcmd_flags_d -tw",
{ "-two", "-twenty" }
)
--------------------------------------------------------------------------------
q = clink.arg.new_parser()
q:set_arguments({ "two", "three" })
p = clink.arg.new_parser()
p:set_arguments({ "one" }, { "nine" })
p:set_flags("-flag_a" .. q, "-flag_b" .. q)
clink.arg.register_parser("argcmd_skip", p)
clink.test.test_matches(
"Skip 1",
"argcmd_skip one two -fla\t",
{ "-flag_a", "-flag_b" }
)
clink.test.test_matches(
"Skip 2",
"argcmd_skip one two -flag_a t",
{ "two", "three" }
)
clink.test.test_matches(
"Skip 3",
"argcmd_skip one two -flag_a two four five -f\t",
{ "-flag_a", "-flag_b" }
)
--------------------------------------------------------------------------------
p = clink.arg.new_parser(
"-flag" .. clink.arg.new_parser({ "red", "green", "blue"}),
{ "one", "two", "three" },
{ "four", "five" }
)
clink.arg.register_parser("argcmd_lazy", p)
clink.test.test_output(
"Lazy init 1",
"argcmd_lazy o",
"argcmd_lazy one f"
)
clink.test.test_matches(
"Lazy init 2",
"argcmd_lazy one f",
{ "four", "five" }
)
clink.test.test_matches(
"Lazy init 2",
"argcmd_lazy one four -flag ",
{ "red", "green", "blue" }
)
| gpl-3.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.