repo_name
stringlengths
6
69
path
stringlengths
6
178
copies
stringclasses
278 values
size
stringlengths
4
7
content
stringlengths
671
917k
license
stringclasses
15 values
FailcoderAddons/supervillain-ui
SVUI_!Core/system/media.lua
1
46844
--- Handlers for media functions -- @submodule SVUI_Core local _G = _G; local select = _G.select; local unpack = _G.unpack; local pairs = _G.pairs; local ipairs = _G.ipairs; local type = _G.type; local print = _G.print; local string = _G.string; local math = _G.math; local table = _G.table; local GetTime = _G.GetTime; local format = string.format; local floor, modf = math.floor, math.modf; local twipe, tsort = table.wipe, table.sort; local NAMEPLATE_FONT = _G.NAMEPLATE_FONT local CHAT_FONT_HEIGHTS = _G.CHAT_FONT_HEIGHTS local STANDARD_TEXT_FONT = _G.STANDARD_TEXT_FONT local UNIT_NAME_FONT = _G.UNIT_NAME_FONT local CUSTOM_CLASS_COLORS = _G.CUSTOM_CLASS_COLORS local RAID_CLASS_COLORS = _G.RAID_CLASS_COLORS local UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT = _G.UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT ---- GET ADDON DATA ---- local SV = select(2, ...) local SVUILib = Librarian("Registry") local L = SV.L local classToken = select(2,UnitClass("player")) SV.MaxBackdrops = {Pattern = 14, Art = 5, Unit = 17} ---- DEFINE SOUND EFFECTS ---- local SOUND = SV.Sounds; SOUND:Register("Buttons", 567407)--sound\interface\uchatscrollbutton.ogg]]) SOUND:Register("Levers", 915755)--sound\interface\ui_blizzardstore_buynow.ogg]]) SOUND:Register("Levers", 565308)--sound\doodad\g_levermetalcustom0.ogg]]) SOUND:Register("Levers", 567719)-- sound\item\weapons\gun\gunload01.ogg]]) SOUND:Register("Levers", 567720)--sound\item\weapons\gun\gunload02.ogg]]) SOUND:Register("Levers", 551391)--sound\creature\gyrocopter\gyrocoptergearshift2.ogg]]) SOUND:Register("Gears", 551387)--sound\creature\gyrocopter\gyrocoptergearshift3.ogg]]) SOUND:Register("Gears", 566502)--sound\doodad\g_buttonbigredcustom0.ogg]]) SOUND:Register("Sparks", 566693)--sound\doodad\fx_electricitysparkmedium_02.ogg]]) SOUND:Register("Sparks", 797948)--sound\doodad\fx_electrical_zaps01.ogg]]) SOUND:Register("Sparks", 797950)--sound\doodad\fx_electrical_zaps02.ogg]]) SOUND:Register("Sparks", 797952)--sound\doodad\fx_electrical_zaps03.ogg]]) SOUND:Register("Sparks", 797954)--sound\doodad\fx_electrical_zaps04.ogg]]) SOUND:Register("Sparks", 797956)--sound\doodad\fx_electrical_zaps05.ogg]]) SOUND:Register("Static", 569693)--sound\spells\uni_fx_radiostatic_01.ogg]]) SOUND:Register("Static", 568039)--sound\spells\uni_fx_radiostatic_02.ogg]]) SOUND:Register("Static", 568977)--sound\spells\uni_fx_radiostatic_03.ogg]]) SOUND:Register("Static", 568792)--sound\spells\uni_fx_radiostatic_04.ogg]]) SOUND:Register("Static", 569734)--sound\spells\uni_fx_radiostatic_05.ogg]]) SOUND:Register("Static", 568565)--sound\spells\uni_fx_radiostatic_06.ogg]]) SOUND:Register("Static", 568775)--sound\spells\uni_fx_radiostatic_07.ogg]]) SOUND:Register("Static", 568777)--sound\spells\uni_fx_radiostatic_08.ogg]]) SOUND:Register("Wired", 595373)--sound\doodad\goblin_christmaslight_green_01.ogg]]) SOUND:Register("Wired", 595997)--sound\doodad\goblin_christmaslight_green_02.ogg]]) SOUND:Register("Wired", 596384)--sound\doodad\goblin_christmaslight_green_03.ogg]]) SOUND:Register("Phase", 565875)--sound\doodad\be_scryingorb_explode.ogg]]) ---- DEFINE SHARED MEDIA ---- local LSM = _G.LibStub("LibSharedMedia-3.0") LSM:Register("background", "SVUI Default BG", [[Interface\AddOns\SVUI_!Core\assets\backgrounds\DEFAULT]]) LSM:Register("background", "SVUI Transparent BG", [[Interface\AddOns\SVUI_!Core\assets\backgrounds\TRANSPARENT]]) LSM:Register("background", "SVUI Button BG", [[Interface\AddOns\SVUI_!Core\assets\backgrounds\BUTTON]]) LSM:Register("background", "SVUI Model BG", [[Interface\AddOns\SVUI_!Core\assets\backgrounds\MODEL]]) for i = 1, SV.MaxBackdrops.Pattern do LSM:Register("background", "SVUI Backdrop "..i, [[Interface\AddOns\SVUI_!Core\assets\backgrounds\pattern\PATTERN]]..i) end for i = 1, SV.MaxBackdrops.Art do LSM:Register("background", "SVUI Artwork "..i, [[Interface\AddOns\SVUI_!Core\assets\backgrounds\art\ART]]..i) end for i = 1, SV.MaxBackdrops.Unit do LSM:Register("background", "SVUI UnitBG "..i, [[Interface\AddOns\SVUI_!Core\assets\backgrounds\unit\UNIT-BG]]..i) LSM:Register("background", "SVUI SmallUnitBG "..i, [[Interface\AddOns\SVUI_!Core\assets\backgrounds\unit\UNIT-SMALL-BG]]..i) end LSM:Register("border", "SVUI Border", [[Interface\AddOns\SVUI_!Core\assets\borders\DEFAULT]]) LSM:Register("border", "SVUI Border 2", [[Interface\BUTTONS\WHITE8X8]]) LSM:Register("border", "SVUI Textured Border", [[Interface\AddOns\SVUI_!Core\assets\borders\TEXTURED]]) LSM:Register("border", "SVUI Inset Shadow", [[Interface\AddOns\SVUI_!Core\assets\borders\INSET]]) LSM:Register("border", "SVUI Shadow Border", [[Interface\AddOns\SVUI_!Core\assets\borders\SHADOW]]) LSM:Register("statusbar", "SVUI BasicBar", [[Interface\AddOns\SVUI_!Core\assets\statusbars\DEFAULT]]) LSM:Register("statusbar", "SVUI MultiColorBar", [[Interface\AddOns\SVUI_!Core\assets\statusbars\GRADIENT]]) LSM:Register("statusbar", "SVUI SmoothBar", [[Interface\AddOns\SVUI_!Core\assets\statusbars\SMOOTH]]) LSM:Register("statusbar", "SVUI PlainBar", [[Interface\AddOns\SVUI_!Core\assets\statusbars\FLAT]]) LSM:Register("statusbar", "SVUI FancyBar", [[Interface\AddOns\SVUI_!Core\assets\statusbars\TEXTURED]]) LSM:Register("statusbar", "SVUI GlossBar", [[Interface\AddOns\SVUI_!Core\assets\statusbars\GLOSS]]) LSM:Register("statusbar", "SVUI GlowBar", [[Interface\AddOns\SVUI_!Core\assets\statusbars\GLOWING]]) LSM:Register("statusbar", "SVUI LazerBar", [[Interface\AddOns\SVUI_!Core\assets\statusbars\LAZER]]) LSM:Register("sound", "Whisper Alert", [[Interface\AddOns\SVUI_!Core\assets\sounds\whisper.mp3]]) LSM:Register("sound", "Mention Alert", [[Interface\AddOns\SVUI_!Core\assets\sounds\whisper.mp3]]) LSM:Register("sound", "Toasty", [[Interface\AddOns\SVUI_!Core\assets\sounds\toasty.mp3]]) LSM:Register("font", "SVUI Default Font", [[Interface\AddOns\SVUI_!Core\assets\fonts\Default.ttf]],LSM.LOCALE_BIT_ruRU+LSM.LOCALE_BIT_western) LSM:Register("font", "SVUI Pixel Font", [[Interface\AddOns\SVUI_!Core\assets\fonts\Pixel.ttf]],LSM.LOCALE_BIT_ruRU+LSM.LOCALE_BIT_western) LSM:Register("font", "SVUI Caps Font", [[Interface\AddOns\SVUI_!Core\assets\fonts\Caps.ttf]],LSM.LOCALE_BIT_ruRU+LSM.LOCALE_BIT_western) LSM:Register("font", "SVUI Classic Font", [[Interface\AddOns\SVUI_!Core\assets\fonts\Classic.ttf]]) LSM:Register("font", "SVUI Combat Font", [[Interface\AddOns\SVUI_!Core\assets\fonts\Combat.ttf]]) LSM:Register("font", "SVUI Dialog Font", [[Interface\AddOns\SVUI_!Core\assets\fonts\Dialog.ttf]]) LSM:Register("font", "SVUI Number Font", [[Interface\AddOns\SVUI_!Core\assets\fonts\Numbers.ttf]]) LSM:Register("font", "SVUI Zone Font", [[Interface\AddOns\SVUI_!Core\assets\fonts\Zone.ttf]]) LSM:Register("font", "SVUI Flash Font", [[Interface\AddOns\SVUI_!Core\assets\fonts\Flash.ttf]]) LSM:Register("font", "SVUI Alert Font", [[Interface\AddOns\SVUI_!Core\assets\fonts\Alert.ttf]]) LSM:Register("font", "SVUI Narrator Font", [[Interface\AddOns\SVUI_!Core\assets\fonts\Narrative.ttf]]) LSM:Register("font", "Open-Dyslexic", [[Interface\AddOns\SVUI_!Core\assets\fonts\Dyslexic.ttf]]) ---- CREATE AND POPULATE MEDIA DATA ---- do local cColor = RAID_CLASS_COLORS[classToken] local r1,g1,b1 = cColor.r,cColor.g,cColor.b local r2,g2,b2 = cColor.r*.25, cColor.g*.25, cColor.b*.25 local ir1,ig1,ib1 = (1 - r1), (1 - g1), (1 - b1) local ir2,ig2,ib2 = (1 - cColor.r)*.25, (1 - cColor.g)*.25, (1 - cColor.b)*.25 SV.mediadefaults = { ["extended"] = {}, ["shared"] = { ["font"] = { ["default"] = {file = "SVUI Default Font", size = 12, outline = "OUTLINE"}, ["dialog"] = {file = "SVUI Default Font", size = 12, outline = "OUTLINE"}, ["title"] = {file = "SVUI Default Font", size = 16, outline = "OUTLINE"}, ["number"] = {file = "SVUI Number Font", size = 11, outline = "OUTLINE"}, ["number_big"] = {file = "SVUI Number Font", size = 18, outline = "OUTLINE"}, ["header"] = {file = "SVUI Number Font", size = 18, outline = "OUTLINE"}, ["combat"] = {file = "SVUI Combat Font", size = 64, outline = "OUTLINE"}, ["alert"] = {file = "SVUI Alert Font", size = 20, outline = "OUTLINE"}, ["flash"] = {file = "SVUI Flash Font", size = 18, outline = "OUTLINE"}, ["zone"] = {file = "SVUI Zone Font", size = 16, outline = "OUTLINE"}, ["caps"] = {file = "SVUI Caps Font", size = 12, outline = "OUTLINE"}, ["aura"] = {file = "SVUI Number Font", size = 10, outline = "OUTLINE"}, ["data"] = {file = "SVUI Number Font", size = 11, outline = "OUTLINE"}, ["narrator"] = {file = "SVUI Narrator Font", size = 12, outline = "OUTLINE"}, ["lootdialog"] = {file = "SVUI Default Font", size = 14, outline = "OUTLINE"}, ["lootnumber"] = {file = "SVUI Number Font", size = 11, outline = "OUTLINE"}, ["rolldialog"] = {file = "SVUI Default Font", size = 14, outline = "OUTLINE"}, ["rollnumber"] = {file = "SVUI Number Font", size = 11, outline = "OUTLINE"}, ["tipdialog"] = {file = "SVUI Default Font", size = 12, outline = "NONE"}, ["tipheader"] = {file = "SVUI Default Font", size = 14, outline = "NONE"}, ["pixel"] = {file = "SVUI Pixel Font", size = 8, outline = "MONOCHROMEOUTLINE"}, }, ["statusbar"] = { ["default"] = {file = "SVUI BasicBar", offset = 0}, ["gradient"] = {file = "SVUI MultiColorBar", offset = 0}, ["smooth"] = {file = "SVUI SmoothBar", offset = 0}, ["flat"] = {file = "SVUI PlainBar", offset = 0}, ["textured"] = {file = "SVUI FancyBar", offset = 0}, ["gloss"] = {file = "SVUI GlossBar", offset = 0}, ["glow"] = {file = "SVUI GlowBar", offset = 2}, ["lazer"] = {file = "SVUI LazerBar", offset = 10}, }, ["background"] = { ["default"] = {file = "SVUI Default BG", size = 0, tiled = false}, ["transparent"] = {file = "SVUI Transparent BG", size = 0, tiled = false}, ["button"] = {file = "SVUI Button BG", size = 0, tiled = false}, ["pattern"] = {file = "SVUI Backdrop 1", size = 0, tiled = false}, ["premium"] = {file = "SVUI Artwork 1", size = 0, tiled = false}, ["model"] = {file = "SVUI Model BG", size = 0, tiled = false}, ["unitlarge"] = {file = "SVUI UnitBG 1", size = 0, tiled = false}, ["unitsmall"] = {file = "SVUI SmallUnitBG 1", size = 0, tiled = false}, }, ["border"] = { ["default"] = {file = "SVUI Border", size = 1}, ["transparent"] = {file = "SVUI Border", size = 1}, ["button"] = {file = "SVUI Border 2", size = 1}, ["pattern"] = {file = "SVUI Border", size = 1}, ["premium"] = {file = "SVUI Textured Border", size = 15}, ["model"] = {file = "SVUI Border", size = 1}, ["shadow"] = {file = "SVUI Shadow Border", size = 3}, ["inset"] = {file = "SVUI Inset Shadow", size = 6}, ["unitlarge"] = {file = "SVUI Border 2", size = 0}, ["unitsmall"] = {file = "SVUI Border 2", size = 0}, }, }, ["font"] = { ["default"] = [[Interface\AddOns\SVUI_!Core\assets\fonts\Default.ttf]], ["dialog"] = [[Interface\AddOns\SVUI_!Core\assets\fonts\Default.ttf]], ["number"] = [[Interface\AddOns\SVUI_!Core\assets\fonts\Numbers.ttf]], ["combat"] = [[Interface\AddOns\SVUI_!Core\assets\fonts\Combat.ttf]], ["zone"] = [[Interface\AddOns\SVUI_!Core\assets\fonts\Zone.ttf]], ["alert"] = [[Interface\AddOns\SVUI_!Core\assets\fonts\Alert.ttf]], ["caps"] = [[Interface\AddOns\SVUI_!Core\assets\fonts\Caps.ttf]], ["narrator"] = [[Interface\AddOns\SVUI_!Core\assets\fonts\Narrative.ttf]], ["flash"] = [[Interface\AddOns\SVUI_!Core\assets\fonts\Flash.ttf]], ["pixel"] = [[Interface\AddOns\SVUI_!Core\assets\fonts\Pixel.ttf]], }, ["statusbar"] = { ["default"] = [[Interface\AddOns\SVUI_!Core\assets\statusbars\DEFAULT]], ["gradient"] = [[Interface\AddOns\SVUI_!Core\assets\statusbars\GRADIENT]], ["smooth"] = [[Interface\AddOns\SVUI_!Core\assets\statusbars\SMOOTH]], ["flat"] = [[Interface\AddOns\SVUI_!Core\assets\statusbars\FLAT]], ["textured"] = [[Interface\AddOns\SVUI_!Core\assets\statusbars\TEXTURED]], ["gloss"] = [[Interface\AddOns\SVUI_!Core\assets\statusbars\GLOSS]], ["glow"] = [[Interface\AddOns\SVUI_!Core\assets\statusbars\GLOWING]], ["lazer"] = [[Interface\AddOns\SVUI_!Core\assets\statusbars\LAZER]], }, ["background"] = { ["default"] = [[Interface\AddOns\SVUI_!Core\assets\backgrounds\DEFAULT]], ["transparent"] = [[Interface\AddOns\SVUI_!Core\assets\backgrounds\TRANSPARENT]], ["button"] = [[Interface\AddOns\SVUI_!Core\assets\backgrounds\BUTTON]], ["pattern"] = [[Interface\AddOns\SVUI_!Core\assets\backgrounds\pattern\PATTERN1]], ["premium"] = [[Interface\AddOns\SVUI_!Core\assets\backgrounds\art\ART1]], ["model"] = [[Interface\AddOns\SVUI_!Core\assets\backgrounds\MODEL]], ["unitlarge"] = [[Interface\AddOns\SVUI_!Core\assets\backgrounds\unit\UNIT-BG1]], ["unitsmall"] = [[Interface\AddOns\SVUI_!Core\assets\backgrounds\unit\UNIT-SMALL-BG1]], ["checkbox"] = [[Interface\AddOns\SVUI_!Core\assets\buttons\CHECK-BG]], ["dark"] = [[Interface\AddOns\SVUI_!Core\assets\backgrounds\DARK]], }, ["border"] = { ["default"] = [[Interface\AddOns\SVUI_!Core\assets\borders\DEFAULT]], ["button"] = [[Interface\AddOns\SVUI_!Core\assets\borders\DEFAULT]], ["pattern"] = [[Interface\AddOns\SVUI_!Core\assets\borders\DEFAULT]], ["premium"] = [[Interface\AddOns\SVUI_!Core\assets\borders\TEXTURED]], ["model"] = [[Interface\AddOns\SVUI_!Core\assets\borders\DEFAULT]], ["shadow"] = [[Interface\AddOns\SVUI_!Core\assets\borders\SHADOW]], ["inset"] = [[Interface\AddOns\SVUI_!Core\assets\borders\INSET]], ["unitlarge"] = [[Interface\BUTTONS\WHITE8X8]], ["unitsmall"] = [[Interface\BUTTONS\WHITE8X8]], ["checkbox"] = [[Interface\AddOns\SVUI_!Core\assets\borders\DEFAULT]], }, ["color"] = { ["default"] = {0.15, 0.15, 0.15, 1}, ["secondary"] = {0.2, 0.2, 0.2, 1}, ["button"] = {0.2, 0.2, 0.2, 1}, ["special"] = {0.37, 0.32, 0.29, 1}, ["specialdark"] = {.23, .22, .21, 1}, ["unique"] = {0.32, 0.258, 0.21, 1}, ["paper"] = {0.77, 0.72, 0.69, 1}, ["dusty"] = {.28, .27, .26, 1}, ["class"] = {r1, g1, b1, 1}, ["bizzaro"] = {ir1, ig1, ib1, 1}, ["medium"] = {0.47, 0.47, 0.47}, ["dark"] = {0.1, 0.1, 0.1, 1}, ["darkest"] = {0, 0, 0, 1}, ["light"] = {0.95, 0.95, 0.95, 1}, ["light2"] = {0.65, 0.65, 0.65, 1}, ["lightgrey"] = {0.32, 0.35, 0.38, 1}, ["highlight"] = {0.28, 0.75, 1, 1}, ["checked"] = {0.25, 0.9, 0.08, 1}, ["green"] = {0.25, 0.9, 0.08, 1}, ["blue"] = {0.08, 0.25, 0.82, 1}, ["tan"] = {0.4, 0.32, 0.23, 1}, ["red"] = {0.9, 0.08, 0.08, 1}, ["yellow"] = {1, 1, 0, 1}, ["gold"] = {1, 0.68, 0.1, 1}, ["transparent"] = {0, 0, 0, 0.5}, ["hinted"] = {0, 0, 0, 0.35}, ["invisible"] = {0, 0, 0, 0}, ["white"] = {1, 1, 1, 1}, }, ["bordercolor"] = { ["default"] = {0, 0, 0, 1}, ["class"] = {r1, g1, b1, 1}, ["checkbox"] = {0.1, 0.1, 0.1, 1}, }, ["gradient"] = { ["default"] = {"VERTICAL", 0.08, 0.08, 0.08, 0.22, 0.22, 0.22}, ["secondary"] = {"VERTICAL", 0.08, 0.08, 0.08, 0.22, 0.22, 0.22}, ["button"] = {"VERTICAL", 0.08, 0.08, 0.08, 0.22, 0.22, 0.22}, ["special"] = {"VERTICAL", 0.33, 0.25, 0.13, 0.47, 0.39, 0.27}, ["specialdark"] = {"VERTICAL", 0.23, 0.15, 0.03, 0.33, 0.25, 0.13}, ["paper"] = {"VERTICAL", 0.53, 0.45, 0.33, 0.77, 0.72, 0.69}, ["dusty"] = {"VERTICAL", 0.12, 0.11, 0.1, 0.22, 0.21, 0.2}, ["class"] = {"VERTICAL", r2, g2, b2, r1, g1, b1}, ["bizzaro"] = {"VERTICAL", ir2, ig2, ib2, ir1, ig1, ib1}, ["medium"] = {"VERTICAL", 0.22, 0.22, 0.22, 0.47, 0.47, 0.47}, ["dark"] = {"VERTICAL", 0.02, 0.02, 0.02, 0.22, 0.22, 0.22}, ["darkest"] = {"VERTICAL", 0.15, 0.15, 0.15, 0, 0, 0}, ["darkest2"] = {"VERTICAL", 0, 0, 0, 0.12, 0.12, 0.12}, ["light"] = {"VERTICAL", 0.65, 0.65, 0.65, 0.95, 0.95, 0.95}, ["light2"] = {"VERTICAL", 0.95, 0.95, 0.95, 0.65, 0.65, 0.65}, ["highlight"] = {"VERTICAL", 0.3, 0.8, 1, 0.1, 0.9, 1}, ["checked"] = {"VERTICAL", 0.08, 0.9, 0.25, 0.25, 0.9, 0.08}, ["green"] = {"VERTICAL", 0.08, 0.9, 0.25, 0.25, 0.9, 0.08}, ["red"] = {"VERTICAL", 0.5, 0, 0, 0.9, 0.08, 0.08}, ["yellow"] = {"VERTICAL", 1, 0.3, 0, 1, 1, 0}, ["tan"] = {"VERTICAL", 0.15, 0.08, 0, 0.37, 0.22, 0.1}, ["inverse"] = {"VERTICAL", 0.25, 0.25, 0.25, 0.12, 0.12, 0.12}, ["icon"] = {"VERTICAL", 0.5, 0.53, 0.55, 0.8, 0.8, 1}, ["white"] = {"VERTICAL", 0.75, 0.75, 0.75, 1, 1, 1}, }, ["button"] = { ["check"] = [[Interface\AddOns\SVUI_!Core\assets\buttons\CHECK]], ["checkbg"] = [[Interface\AddOns\SVUI_!Core\assets\buttons\CHECK-BG]], ["uncheck"] = [[Interface\AddOns\SVUI_!Core\assets\buttons\CHECK-DISABLED]], ["round"] = [[Interface\AddOns\SVUI_!Core\assets\buttons\ROUND-BORDER]], ["roundbg"] = [[Interface\AddOns\SVUI_!Core\assets\buttons\ROUND-BG]], ["scrollup"] = [[Interface\AddOns\SVUI_!Core\assets\buttons\SCROLLBAR-UP]], ["scrolldown"] = [[Interface\AddOns\SVUI_!Core\assets\buttons\SCROLLBAR-DOWN]], ["knob"] = [[Interface\AddOns\SVUI_!Core\assets\buttons\SCROLLBAR-KNOB]], ["option"] = [[Interface\AddOns\SVUI_!Core\assets\buttons\SETUP-OPTION]], ["arrow"] = [[Interface\AddOns\SVUI_!Core\assets\buttons\SETUP-ARROW]], ["radio"] = [[Interface\AddOns\SVUI_!Core\assets\buttons\RADIO]], }, ["icon"] = { ["default"] = [[Interface\AddOns\SVUI_!Core\assets\icons\SVUI]], ["theme"] = [[Interface\AddOns\SVUI_!Core\assets\icons\THEME]], ["vs"] = [[Interface\AddOns\SVUI_!Core\assets\icons\VS]], ["close"] = [[Interface\AddOns\SVUI_!Core\assets\icons\CLOSE]], ["star"] = [[Interface\AddOns\SVUI_!Core\assets\icons\FAVORITE-STAR]], ["info"] = [[Interface\AddOns\SVUI_!Core\assets\icons\FAVORITE-STAR]], ["move_up"] = [[Interface\AddOns\SVUI_!Core\assets\icons\MOVE-UP]], ["move_down"] = [[Interface\AddOns\SVUI_!Core\assets\icons\MOVE-DOWN]], ["move_left"] = [[Interface\AddOns\SVUI_!Core\assets\icons\MOVE-LEFT]], ["move_right"] = [[Interface\AddOns\SVUI_!Core\assets\icons\MOVE-RIGHT]], ["exitIcon"] = [[Interface\AddOns\SVUI_!Core\assets\icons\EXIT]] }, ["dock"] = { ["durabilityLabel"] = [[Interface\AddOns\SVUI_!Core\assets\textures\Dock\LABEL-DUR]], ["reputationLabel"] = [[Interface\AddOns\SVUI_!Core\assets\textures\Dock\LABEL-REP]], ["experienceLabel"] = [[Interface\AddOns\SVUI_!Core\assets\textures\Dock\LABEL-XP]], ["artifactLabel"] = [[Interface\AddOns\SVUI_!Core\assets\textures\Dock\LABEL-ART]], ["azeriteLabel"] = [[Interface\AddOns\SVUI_!Core\assets\textures\Dock\LABEL-ART]], ["sizeIcon"] = [[Interface\AddOns\SVUI_!Core\assets\textures\Dock\DOCK-ICON-SIZE]], ["optionsIcon"] = [[Interface\AddOns\SVUI_!Core\assets\textures\Dock\DOCK-ICON-OPTIONS]], ["breakStuffIcon"] = [[Interface\AddOns\SVUI_!Core\assets\textures\Dock\DOCK-ICON-BREAKSTUFF]], ["hearthIcon"] = [[Interface\AddOns\SVUI_!Core\assets\textures\Dock\DOCK-ICON-HEARTH]], ["raidToolIcon"] = [[Interface\AddOns\SVUI_!Core\assets\textures\Dock\DOCK-ICON-RAIDTOOL]], ["garrisonToolIcon"] = [[Interface\AddOns\SVUI_!Core\assets\textures\Dock\DOCK-ICON-GARRISON]], ["specSwapIcon"] = [[Interface\AddOns\SVUI_!Core\assets\textures\Dock\DOCK-ICON-SPECSWAP]], ["powerIcon"] = [[Interface\AddOns\SVUI_!Core\assets\textures\Dock\DOCK-ICON-POWER]], ["professionIconFile"] = [[Interface\AddOns\SVUI_!Core\assets\textures\Dock\PROFESSIONS]], ["professionIconCoords"]= { [171] = {0,0.25,0,0.25}, -- PRO-ALCHEMY [794] = {0.25,0.5,0,0.25,80451}, -- PRO-ARCHAELOGY [164] = {0.5,0.75,0,0.25}, -- PRO-BLACKSMITH [185] = {0.75,1,0,0.25,818,67097}, -- PRO-COOKING [333] = {0,0.25,0.25,0.5,13262}, -- PRO-ENCHANTING [202] = {0.25,0.5,0.25,0.5}, -- PRO-ENGINEERING [129] = {0.5,0.75,0.25,0.5}, -- PRO-FIRSTAID [773] = {0,0.25,0.5,0.75,51005}, -- PRO-INSCRIPTION [755] = {0.25,0.5,0.5,0.75,31252}, -- PRO-JEWELCRAFTING [165] = {0.5,0.75,0.5,0.75}, -- PRO-LEATHERWORKING [186] = {0.75,1,0.5,0.75}, -- PRO-MINING [197] = {0.25,0.5,0.75,1}, -- PRO-TAILORING }, ["sparks"] = { [[Interface\AddOns\SVUI_!Core\assets\textures\Dock\DOCK-SPARKS-1]], [[Interface\AddOns\SVUI_!Core\assets\textures\Dock\DOCK-SPARKS-2]], [[Interface\AddOns\SVUI_!Core\assets\textures\Dock\DOCK-SPARKS-3]], }, }, ["backdrop"] = { ["default"] = { bgFile = [[Interface\AddOns\SVUI_!Core\assets\backgrounds\DEFAULT]], tile = false, tileSize = 0, edgeFile = [[Interface\AddOns\SVUI_!Core\assets\borders\DEFAULT]], edgeSize = 1, insets = { left = 0, right = 0, top = 0, bottom = 0, }, }, ["button"] = { bgFile = [[Interface\AddOns\SVUI_!Core\assets\backgrounds\BUTTON]], tile = false, tileSize = 0, edgeFile = [[Interface\BUTTONS\WHITE8X8]], edgeSize = 1, insets = { left = 0, right = 0, top = 0, bottom = 0, }, }, ["pattern"] = { bgFile = [[Interface\AddOns\SVUI_!Core\assets\backgrounds\pattern\PATTERN1]], tile = false, tileSize = 0, edgeFile = [[Interface\AddOns\SVUI_!Core\assets\borders\TEXTURED]], edgeSize = 1, insets = { left = 0, right = 0, top = 0, bottom = 0, }, }, ["premium"] = { bgFile = [[Interface\AddOns\SVUI_!Core\assets\backgrounds\art\ART1]], tile = false, tileSize = 0, edgeFile = [[Interface\AddOns\SVUI_!Core\assets\borders\TEXTURED]], edgeSize = 15, insets = { left = 3, right = 3, top = 3, bottom = 3, }, }, ["model"] = { bgFile = [[Interface\AddOns\SVUI_!Core\assets\backgrounds\MODEL]], tile = false, tileSize = 0, edgeFile = [[Interface\AddOns\SVUI_!Core\assets\borders\DEFAULT]], edgeSize = 1, insets = { left = 0, right = 0, top = 0, bottom = 0, }, }, ["buttonred"] = { bgFile = [[Interface\AddOns\SVUI_!Core\assets\backgrounds\BUTTON]], tile = false, tileSize = 0, edgeFile = [[Interface\AddOns\SVUI_!Core\assets\borders\DEFAULT]], edgeSize = 1, insets = { left = 0, right = 0, top = 0, bottom = 0, }, }, ["aura"] = { bgFile = [[Interface\BUTTONS\WHITE8X8]], tile = false, tileSize = 0, edgeFile = [[Interface\AddOns\SVUI_!Core\assets\borders\SHADOW]], edgeSize = 1, insets = { left = 1, right = 1, top = 1, bottom = 1, }, }, ["glow"] = { bgFile = [[Interface\BUTTONS\WHITE8X8]], tile = false, tileSize = 0, edgeFile = [[Interface\AddOns\SVUI_!Core\assets\borders\SHADOW]], edgeSize = 3, insets = { left = 0, right = 0, top = 0, bottom = 0, }, }, ["tooltip"] = { bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], tile = false, tileSize = 0, edgeFile = [[Interface\AddOns\SVUI_!Core\assets\textures\EMPTY]], edgeSize = 1, insets = { left = 0, right = 0, top = 0, bottom = 0, }, }, ["outline"] = { bgFile = [[Interface\AddOns\SVUI_!Core\assets\textures\EMPTY]], tile = false, tileSize = 0, edgeFile = [[Interface\AddOns\SVUI_!Core\assets\borders\DEFAULT]], edgeSize = 1, insets = { left = 0, right = 0, top = 0, bottom = 0, }, }, ["shadowoutline"] = { bgFile = [[Interface\AddOns\SVUI_!Core\assets\textures\EMPTY]], tile = false, tileSize = 0, edgeFile = [[Interface\AddOns\SVUI_!Core\assets\borders\SHADOW]], edgeSize = 3, insets = { left = 0, right = 0, top = 0, bottom = 0, }, }, ["darkened"] = { bgFile = [[Interface\AddOns\SVUI_!Core\assets\backgrounds\DARK]], tile = false, tileSize = 0, edgeFile = [[Interface\AddOns\SVUI_!Core\assets\borders\SHADOW]], edgeSize = 3, insets = { left = 0, right = 0, top = 0, bottom = 0, }, }, } }; end ---- SOME CORE VARS ---- SV.DialogFontDefault = "SVUI Dialog Font"; if(GetLocale() ~= "enUS") then SV.DialogFontDefault = "SVUI Default Font"; end SV.SplashImage = [[Interface\AddOns\SVUI_!Core\assets\textures\SPLASH]]; SV.BaseTexture = [[Interface\AddOns\SVUI_!Core\assets\backgrounds\DEFAULT]]; SV.NoTexture = [[Interface\AddOns\SVUI_!Core\assets\textures\EMPTY]]; --------------------------------------------------------------------- -- Returns a color value based on percentages. -- @function ColorGradient -- @tparam number percentage The needed gradient percent. -- @param ... (vararg) remaining arguments are up to 3 sets of numeric color values (r,g,b). -- @return red value, green value, blue value -- @usage SV:ColorGradient(50,1,0,0,1,1,0,0,1,0) --------------------------------------------------------------------- function SV:ColorGradient(percentage, ...) if percentage >= 1 then return select(select('#', ...) - 2, ...) elseif percentage <= 0 then return ... end local num = select('#', ...) / 3 local segment, relative = modf(percentage*(num-1)) local r1, g1, b1, r2, g2, b2 = select((segment*3)+1, ...) local rOut = r1 + (r2-r1)*relative; local gOut = g1 + (g2-g1)*relative; local bOut = b1 + (b2-b1)*relative; return rOut, gOut, bOut end --------------------------------------------------------------------- -- Returns a hexadecimal color value. -- @function HexColor -- @tparam number red Color, red value. -- @tparam number green Color, green value. -- @tparam number blue Color, blue value. -- @return Hexadecimal string color -- @usage SV:HexColor(0.1, 0.2, 0.3) --------------------------------------------------------------------- function SV:HexColor(red, green, blue) local r,g,b; if red and type(red) == "string" then local t if(self.media) then t = self.media.color[red] if((not t) and (self.media.extended and self.media.extended.unitframes)) then t = self.media.extended.unitframes[red] end end if t then r,g,b = t[1],t[2],t[3] else r,g,b = 0,0,0 end else r = type(red) == "number" and red or 0; g = type(green) == "number" and green or 0; b = type(blue) == "number" and blue or 0; end r = (r < 0 or r > 1) and 0 or (r * 255) g = (g < 0 or g > 1) and 0 or (g * 255) b = (b < 0 or b > 1) and 0 or (b * 255) local hexString = ("%02x%02x%02x"):format(r,g,b) return hexString end ---- ALTERING GLOBAL FONTS ---- local function UpdateChatFontSizes() _G.CHAT_FONT_HEIGHTS[1] = 8 _G.CHAT_FONT_HEIGHTS[2] = 9 _G.CHAT_FONT_HEIGHTS[3] = 10 _G.CHAT_FONT_HEIGHTS[4] = 11 _G.CHAT_FONT_HEIGHTS[5] = 12 _G.CHAT_FONT_HEIGHTS[6] = 13 _G.CHAT_FONT_HEIGHTS[7] = 14 _G.CHAT_FONT_HEIGHTS[8] = 15 _G.CHAT_FONT_HEIGHTS[9] = 16 _G.CHAT_FONT_HEIGHTS[10] = 17 _G.CHAT_FONT_HEIGHTS[11] = 18 _G.CHAT_FONT_HEIGHTS[12] = 19 _G.CHAT_FONT_HEIGHTS[13] = 20 end hooksecurefunc("FCF_ResetChatWindows", UpdateChatFontSizes) local function ChangeGlobalFonts() local fontsize = SV.media.shared.font.default.size; STANDARD_TEXT_FONT = LSM:Fetch("font", SV.media.shared.font.default.file); UNIT_NAME_FONT = LSM:Fetch("font", SV.media.shared.font.caps.file); NAMEPLATE_FONT = STANDARD_TEXT_FONT UpdateChatFontSizes() UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT = fontsize end ---- FONT TEMPLATING METHODS ---- local ManagedFonts = {}; --------------------------------------------------------------------- -- Adds a font object to the custom SVUI font manager. -- @function FontManager -- @param obj Font object. -- @tparam string template Internal name of the media-font to be assigned. -- @param abstract A multi-use flag. -- @param sizeMod Font size override. -- @param styleOverride Outline override. -- @tparam number red Color, red value. -- @tparam number green Color, green value. -- @tparam number blue Color, blue value. -- @usage SV:FontManager(FontObject, 'default', false, false, 'OUTLINE', 1, 1, 1) --------------------------------------------------------------------- function SV:FontManager(obj, template, abstract, sizeMod, styleOverride, red, green, blue) -- @todo document this better if not obj then return end template = template or "default"; local info = SV.media.shared.font[template] or SV.media.shared.font.default; if(not info) then return end local isSystemFont = false; if(abstract and (abstract == 'SYSTEM')) then isSystemFont = true; end local file = SV.media.font[template] or SV.media.font.default; local size = info.size; local outline = info.outline; if(styleOverride) then obj.___fontOutline = styleOverride; outline = styleOverride; end obj.___fontSizeMod = sizeMod or 0; obj:SetFont(file, (size + obj.___fontSizeMod), outline) if(abstract == 'SHADOW') then obj:SetShadowColor(0, 0, 0, 0.75) obj:SetShadowOffset(2, -2) elseif(not isSystemFont) then if((not info.outline) or info.outline ~= "NONE") then obj:SetShadowColor(0, 0, 0, 0) elseif(info.outline and info.outline == "NONE") then obj:SetShadowColor(0, 0, 0, 0.75) else obj:SetShadowColor(0, 0, 0, 0.2) end if(not obj.noShadowOffset) then obj:SetShadowOffset(1, -1) else obj:SetShadowOffset(0, 0) end obj:SetJustifyH(abstract or "CENTER") obj:SetJustifyV("MIDDLE") end if(red and green and blue) then obj:SetTextColor(red, green, blue); end if(not ManagedFonts[template]) then ManagedFonts[template] = {} end ManagedFonts[template][obj] = true end local function _shadowFont(globalName, template, sizeMod, styleOverride, cR, cG, cB) if(not template) then return end if(not _G[globalName]) then return end styleOverride = styleOverride or "NONE" SV:FontManager(_G[globalName], template, "SHADOW", sizeMod, styleOverride, cR, cG, cB); end local function _alterFont(globalName, template, sizeMod, styleOverride, cR, cG, cB) if(not template) then return end if(not _G[globalName]) then return end styleOverride = styleOverride or "NONE" SV:FontManager(_G[globalName], template, "SYSTEM", sizeMod, styleOverride, cR, cG, cB); end local function ChangeSystemFonts() _shadowFont("GameFontNormal", "default", 0, "NONE") _alterFont("GameFontWhite", "default", 0, 'OUTLINE', 1, 1, 1) _alterFont("GameFontWhiteSmall", "default", 0, 'NONE', 1, 1, 1) _alterFont("GameFontBlack", "default", 0, 'NONE', 0, 0, 0) _alterFont("GameFontBlackSmall", "default", -1, 'NONE', 0, 0, 0) _alterFont("GameFontNormalMed2", "default", 2) _alterFont("Game15Font_o1", "number", 1, "OUTLINE") _alterFont("GameFontNormalLarge", "default") _alterFont("GameFontNormalLargeOutline", "default") _alterFont("GameFontHighlightSmall", "default") _alterFont("GameFontHighlight", "default", 1) _alterFont("GameFontHighlightLeft", "default", 1) _alterFont("GameFontHighlightRight", "default", 1) _alterFont("GameFontHighlightLarge2", "default", 2) _alterFont("MailFont_Large", "default", 3) _alterFont("SystemFont_Med1", "default") _alterFont("SystemFont_Med3", "default") _alterFont("SystemFont_Outline_Small", "default", 0, "OUTLINE") _alterFont("FriendsFont_Normal", "default") _alterFont("FriendsFont_Small", "default") _alterFont("FriendsFont_Large", "default", 3) _alterFont("FriendsFont_UserText", "default", -1) _alterFont("SystemFont_Small", "default", -1) _alterFont("GameFontNormalSmall", "default", -1) _alterFont("GameFontNormalSmall2", "default") _alterFont("NumberFont_Shadow_Med", "default", -1, "OUTLINE") _alterFont("NumberFont_Shadow_Small", "default", -1, "OUTLINE") _alterFont("SystemFont_Tiny", "default", -1) _alterFont("SystemFont_Shadow_Med1", "default") _alterFont("SystemFont_Shadow_Med1_Outline", "default") _alterFont("SystemFont_Shadow_Med2", "default") _alterFont("SystemFont_Shadow_Med3", "default") _alterFont("SystemFont_Large", "default") _alterFont("SystemFont_Huge1", "default", 4) _alterFont("SystemFont_Huge1_Outline", "default", 4) _alterFont("SystemFont_Shadow_Small", "default") _alterFont("SystemFont_Shadow_Large", "default", 3) _alterFont("QuestFont", "dialog"); _alterFont("QuestFont_Enormous", "zone", 15, "OUTLINE"); _alterFont("SpellFont_Small", "dialog", 0, "OUTLINE", 1, 1, 1); _alterFont("SystemFont_Shadow_Outline_Large", "title", 0, "OUTLINE"); _alterFont("SystemFont_Shadow_Outline_Huge2", "title", 8, "OUTLINE"); _alterFont("GameFont_Gigantic", "alert", 0, "OUTLINE", 32) _alterFont("SystemFont_Shadow_Huge1", "alert", 0, "OUTLINE") _alterFont("SystemFont_OutlineThick_Huge4", "zone", 6, "OUTLINE"); _alterFont("SystemFont_OutlineThick_WTF", "zone", 9, "OUTLINE"); _alterFont("SystemFont_OutlineThick_WTF2", "zone", 15, "OUTLINE"); _alterFont("QuestFont_Large", "zone", -3); _alterFont("QuestFont_Huge", "zone", -2); _alterFont("QuestFont_Super_Huge", "zone"); _alterFont("QuestFont_Shadow_Huge", "zone"); _alterFont("SystemFont_OutlineThick_Huge2", "zone", 2, "OUTLINE"); _alterFont("Game18Font", "number", 1) _alterFont("Game24Font", "number", 3) _alterFont("Game27Font", "number", 5) _alterFont("Game30Font", "number_big") _alterFont("Game32Font", "number_big", 1) _alterFont("NumberFont_OutlineThick_Mono_Small", "number", 0, "OUTLINE") _alterFont("NumberFont_Outline_Huge", "number_big", 0, "OUTLINE") _shadowFont("NumberFont_Outline_Large", "number", 2, "OUTLINE") _alterFont("NumberFont_Outline_Med", "number", 1, "OUTLINE") _alterFont("NumberFontNormal", "number", 0, "OUTLINE") _alterFont("NumberFont_GameNormal", "number", 0, "OUTLINE") _alterFont("NumberFontNormalRight", "number", 0, "OUTLINE") _alterFont("NumberFontNormalRightRed", "number", 0, "OUTLINE") _alterFont("NumberFontNormalRightYellow", "number", 0, "OUTLINE") _alterFont("GameTooltipHeader", "tipheader") _alterFont("Tooltip_Med", "tipdialog") _alterFont("Tooltip_Small", "tipdialog", -1) _alterFont("SystemFont_Shadow_Huge3", "combat", -10, "OUTLINE") _alterFont("CombatTextFont", "combat", 64, "OUTLINE") end local function _defineFont(globalName, template) if(not template) then return end if(not _G[globalName]) then return end SV:FontManager(_G[globalName], template); end local function UpdateFontTemplate(template) template = template or "default"; local info = SV.media.shared.font[template]; if(not info) then return end local file = LSM:Fetch("font", info.file); local size = info.size; local line = info.outline; local list = ManagedFonts[template]; if(not list) then return end for object in pairs(list) do if object then if(object.___fontOutline) then object:SetFont(file, (size + object.___fontSizeMod), object.___fontOutline); else object:SetFont(file, (size + object.___fontSizeMod), line); end else ManagedFonts[template][object] = nil; end end end local function UpdateAllFontTemplates() for template, _ in pairs(ManagedFonts) do UpdateFontTemplate(template) end ChangeGlobalFonts(); end local function UpdateFontGroup(...) for i = 1, select('#', ...) do local template = select(i, ...) if not template then break end UpdateFontTemplate(template) end end SV.Events:On("ALL_FONTS_UPDATED", UpdateAllFontTemplates, true); SV.Events:On("FONT_GROUP_UPDATED", UpdateFontGroup, true); --------------------------------------------------------------------- -- Create an add-in set of specific font configuration options. -- @function GenerateFontOptionGroup -- @tparam string groupName Options group to insert into. -- @tparam number groupCount Option order for this option. -- @tparam string groupOverview Option group name for this option. -- @tparam table groupList Array of relevant font data. -- @usage SV:GenerateFontOptionGroup(groupName, groupCount, groupOverview, groupList) --------------------------------------------------------------------- function SV:GenerateFontOptionGroup(groupName, groupCount, groupOverview, groupList) self.Options.args.Fonts.args.fontGroup.args[groupName] = { order = groupCount, type = "group", name = groupName, args = { overview = { order = 1, name = groupOverview, type = "description", width = "full", }, spacer0 = { order = 2, name = "", type = "description", width = "full", }, }, }; local orderCount = 3; for template, info in pairs(groupList) do self.Options.args.Fonts.args.fontGroup.args[groupName].args[template] = { order = orderCount + info.order, type = "group", guiInline = true, name = info.name, get = function(key) return self.media.shared.font[template][key[#key]] end, set = function(key,value) self.media.shared.font[template][key[#key]] = value; if(groupCount == 1) then self:StaticPopup_Show("RL_CLIENT") else self.Events:Trigger("FONT_GROUP_UPDATED", template); end end, args = { description = { order = 1, name = info.desc, type = "description", width = "full", }, spacer1 = { order = 2, name = "", type = "description", width = "full", }, spacer2 = { order = 3, name = "", type = "description", width = "full", }, file = { type = "select", dialogControl = 'LSM30_Font', order = 4, name = self.L["Font File"], desc = self.L["Set the font file to use with this font-type."], values = _G.AceVillainWidgets.font, }, outline = { order = 5, name = self.L["Font Outline"], desc = self.L["Set the outlining to use with this font-type."], type = "select", values = { ["NONE"] = self.L["None"], ["OUTLINE"] = "OUTLINE", ["MONOCHROMEOUTLINE"] = "MONOCROMEOUTLINE", ["THICKOUTLINE"] = "THICKOUTLINE" }, }, size = { order = 6, name = self.L["Font Size"], desc = self.L["Set the font size to use with this font-type."], type = "range", min = 6, max = 64, step = 1, }, } } end end ---- MEDIA CORE ---- local function tablesplice(mergeTable, targetTable) if type(targetTable) ~= "table" then targetTable = {} end if type(mergeTable) == 'table' then for key,val in pairs(mergeTable) do if type(val) == "table" then targetTable[key] = tablesplice(val, targetTable[key]) else targetTable[key] = val end end end return targetTable end SV.media = tablesplice(SV.mediadefaults, {}); local GLOBAL_SVUI_FONTS = { ["SVUI_Font_Default"] = "default", ["SVUI_Font_Aura"] = "aura", ["SVUI_Font_Number"] = "number", ["SVUI_Font_Number_Huge"] = "number_big", ["SVUI_Font_Header"] = "header", ["SVUI_Font_Data"] = "data", ["SVUI_Font_Caps"] = "caps", ["SVUI_Font_Narrator"] = "narrator", ["SVUI_Font_Pixel"] = "pixel", ["SVUI_Font_Roll"] = "rolldialog", ["SVUI_Font_Roll_Number"] = "rollnumber", ["SVUI_Font_Loot"] = "lootdialog", ["SVUI_Font_Loot_Number"] = "lootnumber", }; function SV:AssignMedia(mediaType, id, ...) if((not mediaType) or (not id)) then return end if(mediaType == "globalfont") then local globalName = ...; if(globalName) then GLOBAL_SVUI_FONTS[globalName] = id; end return end if(mediaType == "template") then local globalName = ...; if(globalName) then self.API.Templates[id] = globalName; end return end local settings = self.mediadefaults.shared[mediaType]; if(settings) then if(mediaType == "font") then local file, size, outline = ... if(settings[id]) then if(file) then settings[id].file = file end if(size) then settings[id].size = size end if(outline) then settings[id].outline = outline end else file = file or "SVUI Default Font"; size = size or 12; outline = outline or "OUTLINE"; settings[id] = {file = file, size = size, outline = outline} end elseif(mediaType == "statusbar") then local file, offset = ... if(settings[id]) then if(file) then settings[id].file = file end if(offset) then settings[id].offset = offset end else file = file or "SVUI BasicBar"; offset = offset or 0; settings[id] = {file = file, offset = offset} end elseif(mediaType == "background") then local file, size, tiled = ... if(settings[id]) then if(file) then settings[id].file = file end if(size) then settings[id].size = size end if(tiled) then settings[id].tiled = tiled end else file = file or "SVUI Default BG"; size = size or 0; tiled = tiled or false; settings[id] = {file = file, size = size, tiled = tiled} end elseif(mediaType == "border") then local file, size = ... if(settings[id]) then if(file) then settings[id].file = file end if(size) then settings[id].size = size end else file = file or "SVUI Border"; size = size or 1; settings[id] = {file = file, size = size} end end else settings = self.mediadefaults[mediaType]; if(settings) then if(settings[id]) then if(type(settings[id]) == "table") then for i = 1, select('#', ...) do local v = select(i, ...) if(not v) then break end if(type(v) == "table") then settings[id] = tablesplice(v, settings[id]); else settings[id][i] = v; end end else local newMedia = ...; if(newMedia) then settings[id] = newMedia; end end else local valueCount = select('#', ...) if(valueCount > 1) then settings[id] = {}; for i = 1, select('#', ...) do local v = select(i, ...) if(not v) then break end if(type(v) == "table") then settings[id] = tablesplice(v, settings[id]); else settings[id][i] = v; end end else local newMedia = ...; if(newMedia) then settings[id] = newMedia; end end end end end end function SV:UpdateSharedMedia() local settings = self.media.shared for mediaType, mediaData in pairs(settings) do if(self.media[mediaType]) then for name,userSettings in pairs(mediaData) do if(userSettings.file) then self.media[mediaType][name] = LSM:Fetch(mediaType, userSettings.file) end end end end for name, bd in pairs(self.media.backdrop) do if(self.media.background[name] and self.media.border[name]) then local bordersetup = self.media.shared.border[name]; local bgsetup = self.media.shared.background[name]; bd.bgFile = self.media.background[name]; bd.tile = bgsetup.tiled; bd.tileSize = bgsetup.size; bd.edgeFile = self.media.border[name]; bd.edgeSize = bordersetup.size; local offset = bordersetup.size * 0.2; bd.insets = { left = offset, right = offset, top = offset, bottom = offset, } end end local default = self.media.color.default self.media.gradient.default = {"VERTICAL", default[1]*.25, default[2]*.25, default[3]*.25, default[1], default[2], default[3]} local secondary = self.media.color.secondary self.media.gradient.secondary = {"VERTICAL", secondary[1]*.25, secondary[2]*.25, secondary[3]*.25, secondary[1], secondary[2], secondary[3]} local cColor1 = CUSTOM_CLASS_COLORS[classToken] local cColor2 = RAID_CLASS_COLORS[classToken] if(not self.db.general.customClassColor or not CUSTOM_CLASS_COLORS[classToken]) then cColor1 = RAID_CLASS_COLORS[classToken] end local r1,g1,b1 = cColor1.r,cColor1.g,cColor1.b local r2,g2,b2 = cColor2.r*.25, cColor2.g*.25, cColor2.b*.25 local ir1,ig1,ib1 = (1 - r1), (1 - g1), (1 - b1) local ir2,ig2,ib2 = (1 - cColor2.r)*.25, (1 - cColor2.g)*.25, (1 - cColor2.b)*.25 self.media.color.class = {r1, g1, b1, 1} self.media.color.bizzaro = {ir1, ig1, ib1, 1} self.media.bordercolor.class = {r1, g1, b1, 1} self.media.gradient.class = {"VERTICAL", r2, g2, b2, r1, g1, b1} self.media.gradient.bizzaro = {"VERTICAL", ir2, ig2, ib2, ir1, ig1, ib1} local special = self.media.color.special ---- self.media.gradient.special = {"VERTICAL", special[1], special[2], special[3], r1, g1, b1} ---- ---- self.media.color.special = {r1*.5, g1*.5, b1*.5, 1} ---- self.media.gradient.special = {"VERTICAL", special[1]*.25, special[2]*.25, special[3]*.25, special[1], special[2], special[3]} ---- self.media.gradient.special = {"VERTICAL",special[1], special[2], special[3], default[1], default[2], default[3]} ---- self.Events:Trigger("SHARED_MEDIA_UPDATED"); if(not InCombatLockdown()) then collectgarbage("collect"); end end function SV:RefreshAllMedia() self:UpdateSharedMedia(); ChangeGlobalFonts(); ChangeSystemFonts(); for globalName, id in pairs(GLOBAL_SVUI_FONTS) do local obj = _G[globalName]; if(obj) then self:FontManager(obj, id); end end self.Events:Trigger("ALL_FONTS_UPDATED"); self.MediaInitialized = true; end
mit
UnfortunateFruit/darkstar
scripts/zones/Beadeaux/npcs/The_Afflictor.lua
17
1213
----------------------------------- -- Area: Beadeaux -- NPC: The Afflictor -- @zone 147 -- @pos <many> ----------------------------------- package.loaded["scripts/zones/Beadeaux/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Beadeaux/TextIDs"); require("scripts/globals/quests"); require("scripts/globals/settings"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if(player:getQuestStatus(BASTOK,THE_CURSE_COLLECTOR) == QUEST_ACCEPTED and player:getVar("cCollectCurse") == 0) then player:setVar("cCollectCurse",1); 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/spells/archers_prelude.lua
27
1521
----------------------------------------- -- Spell: Archer's Prelude -- Gives party members ranged attack accuracy ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- 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 = 9; if (sLvl+iLvl > 130) then power = power + math.floor((sLvl+iLvl-200) / 10); end if (power >= 40) then power = 40; end local iBoost = caster:getMod(MOD_PRELUDE_EFFECT) + caster:getMod(MOD_ALL_SONGS_EFFECT); if (iBoost > 0) then power = power + 1 + (iBoost-1)*3; end 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_PRELUDE,power,0,duration,caster:getID(), 0, 2)) then spell:setMsg(75); end return EFFECT_PRELUDE; end;
gpl-3.0
gmorishere/bot
plugins/help.lua
6
1364
-- This plugin should go at the end of your plugin list in -- config.lua, but not after greetings.lua. local help_text = '*Available commands:*' for i,v in ipairs(plugins) do if v.command then help_text = help_text .. '\n /' .. v.command:gsub('%[', '\\[') end end help_text = help_text .. [[\n /help <command> Arguments: <required> \[optional] ]] local triggers = { '^/help[@'..bot.username..']*', '^/h[@'..bot.username..']*$', '^/start[@'..bot.username..']*' } local action = function(msg) local input = msg.text_lower:input() -- Attempts to send the help message via PM. -- If msg is from a group, it tells the group whether the PM was successful. if not input then local res = sendMessage(msg.from.id, help_text, true, nil, true) if not res then sendReply(msg, 'Please message me privately for a list of commands.') elseif msg.chat.type ~= 'private' then sendReply(msg, 'I have sent you the requested information in a private message.') end return end for i,v in ipairs(plugins) do if v.command and get_word(v.command, 1) == input and v.doc then local output = '*Help for* _' .. get_word(v.command, 1) .. '_ *:*\n' .. v.doc sendMessage(msg.chat.id, output, true, nil, true) return end end sendReply(msg, 'Sorry, there is no help for that command.') end return { action = action, triggers = triggers }
gpl-2.0
plajjan/snabbswitch
src/lib/protocol/keyed_ipv6_tunnel.lua
6
3390
-- Use of this source code is governed by the Apache 2.0 license; see COPYING. -- This is an implementation of the "Keyed IPv6 Tunnel" specification -- conforming to -- http://tools.ietf.org/html/draft-mkonstan-keyed-ipv6-tunnel-01. It -- uses a particular variant of the L2TPv3 encapsulation that uses no -- L2 sublayer header and a fixed cookie of 64 bits. It is only -- specified for IPv6 as transport protocol. -- -- It makes use of the same IP protocol number 115 as L2TPv3, which -- makes it hard to demultiplex, because the L2TPv3 header itself does -- not contain sufficient information. There are currently no -- implementations of other modes of L2TPv3 in Snabbswitch and protocol -- number 115 is simply mapped to this module from the IPv6 header -- class. module(..., package.seeall) local ffi = require("ffi") local C = ffi.C local header = require("lib.protocol.header") local lib = require("core.lib") local htonl, ntohl = lib.htonl, lib.ntohl ffi.cdef[[ typedef union { uint8_t cookie[8]; uint64_t cookie_64bit; } cookie_t; ]] local tunnel = subClass(header) local cookie_t = ffi.metatype(ffi.typeof("cookie_t"), { __tostring = function (c) local s = { "0x" } for i = 0, 7 do table.insert(s, string.format("%02x", c.cookie[i])) end return table.concat(s) end, __eq = function(lhs, rhs) return rhs and lhs.cookie_64bit == rhs.cookie_64bit end }) -- Class variables tunnel._name = "keyed ipv6 tunnel" tunnel._ulp = {} header.init(tunnel, { [1] = ffi.typeof[[ struct { uint32_t session_id; cookie_t cookie; } __attribute__((packed)) ]] }) -- Class methods function tunnel:new_cookie (s) assert(type(s) == 'string' and string.len(s) == 8, 'invalid cookie') local c = cookie_t() ffi.copy(c.cookie, s, 8) return c end local default = { session_id = 0xffffffff, cookie = tunnel:new_cookie('\x00\x00\x00\x00\x00\x00\x00\x00') } function tunnel:new (config) local o = tunnel:superClass().new(self) local config = config or default -- The spec for L2TPv3 over IPv6 recommends to set the session ID -- to 0xffffffff for the "static 1:1 mapping" scenario. o:session_id(config.session_id or default.session_id) o:cookie(config.cookie or default.cookie) return o end function tunnel:new_from_mem (mem, size) local o = tunnel:superClass().new_from_mem(self, mem, size) if o:session_id() == 0 then -- Session ID 0 is reserved for L2TPv3 control messages o:free() return nil end return o end -- Instance methods function tunnel:session_id (id) local h = self:header() if id ~= nil then assert(id ~= 0, "invalid session id 0") h.session_id = htonl(id) else return ntohl(h.session_id) end end function tunnel:cookie (c) local h = self:header() if c ~= nil then h.cookie.cookie_64bit = c.cookie_64bit else return h.cookie end end return tunnel
apache-2.0
VoxelDavid/rbx-lua-dump
source/modules/Version.lua
1
5899
--[[ This script is used to check the current game versions and return if they are up-to-date or not. The two versions are the built-in PlaceVersion value and a string set in Main.lua following the Semantic Versioning Specification (http://semver.org). PlaceVersion is a quick way to see if the server instance is out of date, while SemVer is a way to be more descriptive with the current game version, along with making it clear when creating releases of the software. --]] repeat wait() until _G.Ready local Data = require(_G.Modules.Data) local Version = {} --[[ Takes the version string and seperates each part into a key/value pair in a table. Eg. "v0.1.0-alpha.1" would be turned into: { "major" = 0, "minor" = 1, "patch" = 0, "alpha" = 1, "prerelease" = true } --]] function Version:ConvertToTable(versionString) -- versionString = "v0.1.0-alpha.1" local versionNumber = versionString:match("v%d+\.%d+\.%d+") -- "v0.1.0" local prereleaseVersion = versionString:match("\-%a*\.%d+") -- "-alpha.1" local versionTable = {} local function majorMinorPatch() -- Is there a method I can use to accomplish this without an iterator -- variable? local iterator = 0 for digit in versionNumber:gmatch("%d+") do if iterator == 0 then versionTable.major = tonumber(digit) -- 0 elseif iterator == 1 then versionTable.minor = tonumber(digit) -- 1 elseif iterator == 2 then versionTable.patch = tonumber(digit) -- 0 end iterator = iterator + 1 end end local function prerelease() local prereleaseName = prereleaseVersion:match("%a+") -- alpha local prereleaseNumber = prereleaseVersion:match("%d+") -- 1 versionTable[prereleaseName] = prereleaseNumber --[[ A value used to easily get the current prerelease version number, without having to search for "alpha" or "beta". eg: print(versionTable[versionTable.prerelease]) -- 1 --]] versionTable.prerelease = prereleaseName end majorMinorPatch() if prereleaseVersion then prerelease() end return versionTable end --[[ This convoluted function deciphers the server's semantic version number and returns if it's up to date or not. The complicated thing is, v0.5.0 is a greater version than v0.4.9, making lots of 'if' statements required to figure everything out. --]] function Version:LatestSemantic() local currentVersion = self:ConvertToTable(_G.Version) local latestVersion if Data:Get("Server", "version") then latestVersion = self:ConvertToTable(Data:Get("Server", "version")) else -- If you forget to set the place version in a new game. warn("Latest semantic version does not exist in the \"version\" DataStore. Set to _G.Version.") latestVersion = currentVersion end local majorUpdated local minorUpdated local function compareMajor(current, latest) if current.major > latest.major then majorUpdated = true return true -- MAJOR was updated. elseif current.major == latest.major then return true -- MAJOR is the same as latest. else return false end end local function compareMinor(current, latest) if current.minor < latest.minor and majorUpdated == true then minorUpdated = true return true -- MINOR decreased in value, MAJOR was updated. elseif current.minor > latest.minor then minorUpdated = true return true -- MINOR went up in value elseif current.minor == latest.minor then return true -- MINOR is the same as latest. else return false end end local function comparePatch(current, latest) if current.patch < latest.patch and minorUpdated == true then return true -- PATCH decreased in value, MINOR was updated. elseif current.patch > latest.patch then return true -- PATCH is greater than latest. elseif current.patch == latest.patch then return true -- PATCH is the same as latest. else return false end end local function comparePrerelease(current, latest) local pre = current.prerelease -- "alpha" if current[pre] >= latest[pre] then return true else return false end end local function compareVersions(current, latest) local major = compareMajor(current, latest) local minor = compareMinor(current, latest) local patch = comparePatch(current, latest) local prerelease = comparePrerelease(current, latest) -- print(major, minor, patch, prerelease) if major and minor and patch then if prerelease then return true else return false end return true else return false end end return compareVersions(currentVersion, latestVersion) end --[[ Compare the PlaceVersion value against the one on the server and return if the current one is up to date or not. (SO much easier than the semantic version number) --]] function Version:LatestPlace() local currentVersion = game.PlaceVersion local latestVersion if Data:Get("Server", "placeVersion") then latestVersion = Data:Get("Server", "placeVersion") else warn("Latest place version does not exist in the \"version\" DataStore. Set to game.PlaceVersion.") latestVersion = currentVersion end if currentVersion >= latestVersion then return true else return false end end --[[ Pushes up the current Semantic and Place versions to the "Server" datastore if they are the same or greater than the ones stored. --]] function Version:UpdateStoredData() if self:LatestSemantic() then Data:Update("Server", "version", _G.Version) end if self:LatestPlace() then Data:Update("Server", "placeVersion", game.PlaceVersion) end end function warn(message) game:GetService("TestService"):Warn(false, message) end return Version
mit
UnfortunateFruit/darkstar
scripts/zones/The_Garden_of_RuHmet/mobs/Ix_aern_drg.lua
13
3460
----------------------------------- -- Area: The Garden of Ru'Hmet -- NPC: Ix'aern (drg) ----------------------------------- require("scripts/globals/status"); require("scripts/zones/The_Garden_of_RuHmet/MobIDs"); ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) if (math.random(0,1) > 0) then SetDropRate(4396,1870,1000); -- Deed Of Sensib. SetDropRate(4396,1903,0); else SetDropRate(4396,1870,0); SetDropRate(4396,1903,1000); -- Vice Of Aspersion end end; ----------------------------------- -- onMobFight Action ----------------------------------- function onMobFight(mob,target) -- Spawn the pets if they are despawned -- TODO: summon animations? if (GetMobAction(wynavA) == 0) then GetMobByID(wynavA):setSpawn(mob:getXPos()+math.random(1,5), mob:getYPos(), mob:getZPos()+math.random(1,5)); SpawnMob(wynavA, 300):updateEnmity(target); elseif (GetMobAction(wynavB) == 0) then GetMobByID(wynavB):setSpawn(mob:getXPos()+math.random(1,5), mob:getYPos(), mob:getZPos()+math.random(1,5)); SpawnMob(wynavB, 300):updateEnmity(target); elseif (GetMobAction(wynavC) == 0) then GetMobByID(wynavC):setSpawn(mob:getXPos()+math.random(1,5), mob:getYPos(), mob:getZPos()+math.random(1,5)); SpawnMob(wynavC, 300):updateEnmity(target); end -- Ensure all spawned pets are doing stuff.. for pets = wynavA, wynavC do if (GetMobAction(pets) == 16) then -- Send pet after current target.. GetMobByID(pets):updateEnmity(target); end end end ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob, killer) -- Despawn pets.. DespawnMob(wynavA); DespawnMob(wynavB); DespawnMob(wynavC); local IxAernDRG_PH = GetServerVariable("[SEA]IxAernDRG_PH"); -- Should be be the ID of the mob that spawns the actual PH -- Pick the Ix'Aern (DRG) PH if the server doesn't have one, set it. if (GetMobAction(realAwAern_PH) == 0 and GetMobAction(IxAernDRG) == 0 and GetServerVariable("[SEA]IxAernDRG_PH") == 0) then -- This should be cleared when the mob is killed. IxAernDRG_PH = AwAernGroups[math.random(1, #AwAernGroups)] + math.random(0, 2); -- The 4th mobid in each group is a pet. F that son SetServerVariable("[SEA]IxAernDRG_PH", IxAernDRG_PH); end; end; ----------------------------------- -- OnMobDespawn ----------------------------------- function onMobDespawn( mob ) -- Despawn pets. DespawnMob(wynavA); DespawnMob(wynavB); DespawnMob(wynavC); local IxAernDRG_PH = GetServerVariable("[SEA]IxAernDRG_PH"); -- Should be be the ID of the mob that spawns the actual PH -- Pick the Ix'Aern (DRG) PH if the server doesn't have one, set it. if (GetMobAction(realAwAern_PH) == 0 and GetMobAction(IxAernDRG) == 0 and GetServerVariable("[SEA]IxAernDRG_PH") == 0) then -- This should be cleared when the mob is killed. local AwAernGroups = {16920777,16920781,16920785,16920789}; -- First Aw'Aerns in each group. IxAernDRG_PH = AwAernGroups[math.random(1, #AwAernGroups)] + math.random(0, 2); -- The 4th mobid in each group is a pet. F that son SetServerVariable("[SEA]IxAernDRG_PH", IxAernDRG_PH); end; end
gpl-3.0
UnfortunateFruit/darkstar
scripts/zones/Windurst_Woods/npcs/Bopa_Greso.lua
19
1724
----------------------------------- -- Area: Windurst Woods -- NPC: Bopa Greso -- Type: Standard NPC -- @zone: 241 -- @pos 59.773 -6.249 216.766 -- -- Auto-Script: Requires Verification (Verfied by Brawndo) ----------------------------------- package.loaded["scripts/zones/Windurst_Woods/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/quests"); require("scripts/globals/keyitems"); require("scripts/zones/Windurst_Woods/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) thickAsThieves = player:getQuestStatus(WINDURST,AS_THICK_AS_THIEVES); thickAsThievesCS = player:getVar("thickAsThievesCS"); if(thickAsThieves == QUEST_ACCEPTED) then player:startEvent(0x01FA); if (thickAsThievesCS == 1) then player:setVar("thickAsThievesCS",2); elseif (thickAsThievesCS == 3) then player:setVar("thickAsThievesCS",4); rand1 = math.random(2,7); player:setVar("thickAsThievesGrapplingCS",rand1); player:setVar("thickAsThievesGamblingCS",1); end else player:startEvent(0x004d); -- standard cs 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
alirezanile/LaSt-GaMfg
plugins/invite.lua
33
2849
--[[ Invite user into the chat group. Type !invite by replying to a message to invite replied user. Usefull when you want to reinviting kicked user. Most reliable. Use !invite 1234567890 (where 1234567890 is id_number) to invite a user by id_number. This is a very reliable method, and if failed, will failed silently. Use !invite @username to invite a user by @username. Less reliable. Some users don't have @username. Use !invite print_name to invite a user by print_name. Unreliable. Avoid if possible. Maybe need an initial communication with the user. If print_name is not exist, it will failed silently. --]] do local function invite_user(chat_id, user_id) if is_super_banned(user_id) or is_banned(user_id, chat_id) then return send_large_msg('chat#id'..chat_id, 'Invitation canceled.\n' ..'ID'..user_id..' is (super)banned.') end chat_add_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, false) end local function resolve_username(extra, success, result) if success == 1 then invite_user(extra.msg.to.id, result.id) else return send_large_msg('chat#id'..extra.msg.to.id, 'Failed to invite ' ..string.gsub(extra.msg.text, '!invite ', '') ..' into this group.\nPlease check if username is correct.') end end local function action_by_reply(extra, success, result) invite_user(result.to.id, result.from.id) end local function run(msg, matches) if is_chat_msg(msg) and is_mod(msg.from.id, msg.to.id) then if msg.reply_id and msg.text == "!invite" then msgr = get_message(msg.reply_id, action_by_reply, {msg=msg}) end if string.match(matches[1], '^%d+$') then invite_user(msg.to.id, matches[1]) elseif string.match(matches[1], '^@.+$') then msgr = res_user(string.gsub(matches[1], '@', ''), resolve_username, {msg=msg}) elseif string.match(matches[1], '.*$') then -- This one is tricky. Big chance are, you need an initial interaction with <print_name>. chat_add_user('chat#id'..msg.to.id, string.gsub(matches[1], ' ', '_'), ok_cb, false) end else return 'This is not a chat group!' end end return { description = 'Invite other user to the chat group.', usage = { moderator = { -- Need space in front of this, so bot won't consider it as a command ' !invite : If type by replying, bot will then inviting the replied user.', ' !invite <user_id> : Invite by their user_id.', ' !invite @<user_name> : Invite by their @<user_name>.', ' !invite <print_name> : Invite by their print_name.' }, }, patterns = { '^!invite$', '^!invite (.*)$', '^!invite (%d+)$' }, run = run, privileged = true } end
gpl-2.0
vonflynee/opencomputersserver
world/opencomputers/7c9ad1a8-61e1-4046-a969-190bd5607730/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
UnfortunateFruit/darkstar
scripts/globals/items/fish_chiefkabob.lua
35
1539
----------------------------------------- -- ID: 4575 -- Item: fish_chiefkabob -- Food Effect: 60Min, All Races ----------------------------------------- -- Dexterity 1 -- Vitality 2 -- Mind 1 -- Charisma 1 -- defense % 26 -- defense Cap 95 ----------------------------------------- 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,3600,4575); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_DEX, 1); target:addMod(MOD_VIT, 2); target:addMod(MOD_MND, 1); target:addMod(MOD_CHR, 1); target:addMod(MOD_FOOD_DEFP, 26); target:addMod(MOD_FOOD_DEF_CAP, 95); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_DEX, 1); target:delMod(MOD_VIT, 2); target:delMod(MOD_MND, 1); target:delMod(MOD_CHR, 1); target:delMod(MOD_FOOD_DEFP, 26); target:delMod(MOD_FOOD_DEF_CAP, 95); end;
gpl-3.0
albfan/clink
clink/lua/go.lua
4
6696
-- -- Copyright (c) 2013 Dobroslaw Zybort -- -- 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 function flags(...) local p = clink.arg.new_parser() p:set_flags(...) return p end -------------------------------------------------------------------------------- local go_tool_parser = clink.arg.new_parser() go_tool_parser:set_flags("-n") go_tool_parser:set_arguments({ "8a", "8c", "8g", "8l", "addr2line", "cgo", "dist", "nm", "objdump", "pack", "cover" .. flags("-func", "-html", "-mode", "-o", "-var"), "fix" .. flags("-diff", "-force", "-r"), "prof" .. flags("-p", "-t", "-d", "-P", "-h", "-f", "-l", "-r", "-s", "-hs"), "pprof" .. flags(-- Options: "--cum", "--base", "--interactive", "--seconds", "--add_lib", "--lib_prefix", -- Reporting Granularity: "--addresses", "--lines", "--functions", "--files", -- Output type: "--text", "--callgrind", "--gv", "--web", "--list", "--disasm", "--symbols", "--dot", "--ps", "--pdf", "--svg", "--gif", "--raw", -- Heap-Profile Options: "--inuse_space", "--inuse_objects", "--alloc_space", "--alloc_objects", "--show_bytes", "--drop_negative", -- Contention-profile options: "--total_delay", "--contentions", "--mean_delay", -- Call-graph Options: "--nodecount", "--nodefraction", "--edgefraction", "--focus", "--ignore", "--scale", "--heapcheck", -- Miscellaneous: "--tools", "--test", "--help", "--version"), "vet" .. flags("-all", "-asmdecl", "-assign", "-atomic", "-buildtags", "-composites", "-compositewhitelist", "-copylocks", "-methods", "-nilfunc", "-printf", "-printfuncs", "-rangeloops", "-shadow", "-shadowstrict", "-structtags", "-test", "-unreachable", "-v"), "yacc" .. flags("-l", "-o", "-p", "-v"), }) -------------------------------------------------------------------------------- local go_parser = clink.arg.new_parser() go_parser:set_arguments({ "env", "fix", "version", "build" .. flags("-o", "-a", "-n", "-p", "-installsuffix", "-v", "-x", "-work", "-gcflags", "-ccflags", "-ldflags", "-gccgoflags", "-tags", "-compiler", "-race"), "clean" .. flags("-i", "-n", "-r", "-x"), "fmt" .. flags("-n", "-x"), "get" .. flags("-d", "-fix", "-t", "-u", -- Build flags "-a", "-n", "-p", "-installsuffix", "-v", "-x", "-work", "-gcflags", "-ccflags", "-ldflags", "-gccgoflags", "-tags", "-compiler", "-race"), "install" .. flags(-- All `go build` flags "-o", "-a", "-n", "-p", "-installsuffix", "-v", "-x", "-work", "-gcflags", "-ccflags", "-ldflags", "-gccgoflags", "-tags", "-compiler", "-race"), "list" .. flags("-e", "-race", "-f", "-json", "-tags"), "run" .. flags("-exec", -- Build flags "-a", "-n", "-p", "-installsuffix", "-v", "-x", "-work", "-gcflags", "-ccflags", "-ldflags", "-gccgoflags", "-tags", "-compiler", "-race"), "test" .. flags(-- Local. "-c", "-file", "-i", "-cover", "-coverpkg", -- Build flags "-a", "-n", "-p", "-x", "-work", "-ccflags", "-gcflags", "-exec", "-ldflags", "-gccgoflags", "-tags", "-compiler", "-race", "-installsuffix", -- Passed to 6.out "-bench", "-benchmem", "-benchtime", "-covermode", "-coverprofile", "-cpu", "-cpuprofile", "-memprofile", "-memprofilerate", "-blockprofile", "-blockprofilerate", "-outputdir", "-parallel", "-run", "-short", "-timeout", "-v"), "tool" .. go_tool_parser, "vet" .. flags("-n", "-x"), }) -------------------------------------------------------------------------------- local go_help_parser = clink.arg.new_parser() go_help_parser:set_arguments({ "help" .. clink.arg.new_parser():set_arguments({ go_parser:flatten_argument(1) }) }) -------------------------------------------------------------------------------- local godoc_parser = clink.arg.new_parser() godoc_parser:set_flags( "-zip", "-write_index", "-analysis", "-http", "-server", "-html","-src", "-url", "-q", "-v", "-goroot", "-tabwidth", "-timestamps", "-templates", "-play", "-ex", "-links", "-index", "-index_files", "-maxresults", "-index_throttle", "-notes", "-httptest.serve" ) -------------------------------------------------------------------------------- local gofmt_parser = clink.arg.new_parser() gofmt_parser:set_flags( "-cpuprofile", "-d", "-e", "-l", "-r", "-s", "-w" ) -------------------------------------------------------------------------------- clink.arg.register_parser("go", go_parser) clink.arg.register_parser("go", go_help_parser) clink.arg.register_parser("godoc", godoc_parser) clink.arg.register_parser("gofmt", gofmt_parser)
gpl-3.0
nesstea/darkstar
scripts/globals/magic_maps.lua
35
9801
--------------------------------------------- -- -- Function that all map NPCS use. -- SE updated the map NPCs to sell maps from the normal areas, RoZ, and CoP areas (Update was in Nov 5, 2013) --------------------------------------------- require("scripts/globals/keyitems"); local Maps = {MAP_OF_THE_SAN_DORIA_AREA, MAP_OF_THE_BASTOK_AREA, MAP_OF_THE_WINDURST_AREA, MAP_OF_THE_JEUNO_AREA, MAP_OF_ORDELLES_CAVES, MAP_OF_GHELSBA, MAP_OF_DAVOI, MAP_OF_CARPENTERS_LANDING, MAP_OF_THE_ZERUHN_MINES, MAP_OF_THE_PALBOROUGH_MINES, MAP_OF_BEADEAUX, MAP_OF_GIDDEUS, MAP_OF_CASTLE_OZTROJA, MAP_OF_THE_MAZE_OF_SHAKHRAMI, MAP_OF_THE_LITELOR_REGION, MAP_OF_BIBIKI_BAY, MAP_OF_QUFIM_ISLAND, MAP_OF_THE_ELDIEME_NECROPOLIS, MAP_OF_THE_GARLAIGE_CITADEL, MAP_OF_THE_ELSHIMO_REGIONS, MAP_OF_THE_NORTHLANDS_AREA, MAP_OF_KING_RANPERRES_TOMB, MAP_OF_THE_DANGRUF_WADI, MAP_OF_THE_HORUTOTO_RUINS, MAP_OF_BOSTAUNIEUX_OUBLIETTE, MAP_OF_THE_TORAIMARAI_CANAL, MAP_OF_THE_GUSGEN_MINES, MAP_OF_THE_CRAWLERS_NEST, MAP_OF_THE_RANGUEMONT_PASS, MAP_OF_DELKFUTTS_TOWER, MAP_OF_FEIYIN, MAP_OF_CASTLE_ZVAHL, MAP_OF_THE_KUZOTZ_REGION, MAP_OF_THE_RUAUN_GARDENS, MAP_OF_NORG, MAP_OF_THE_TEMPLE_OF_UGGALEPIH, MAP_OF_THE_DEN_OF_RANCOR, MAP_OF_THE_KORROLOKA_TUNNEL, MAP_OF_THE_KUFTAL_TUNNEL, MAP_OF_THE_BOYAHDA_TREE, MAP_OF_THE_VELUGANNON_PALACE, MAP_OF_IFRITS_CAULDRON, MAP_OF_THE_QUICKSAND_CAVES, MAP_OF_THE_SEA_SERPENT_GROTTO, MAP_OF_THE_VOLLBOW_REGION, MAP_OF_THE_LABYRINTH_OF_ONZOZO, MAP_OF_THE_ULEGUERAND_RANGE, MAP_OF_THE_ATTOHWA_CHASM, MAP_OF_PSOXJA, MAP_OF_OLDTON_MOVALPOLOS, MAP_OF_NEWTON_MOVALPOLOS, MAP_OF_TAVNAZIA, MAP_OF_THE_AQUEDUCTS, MAP_OF_THE_SACRARIUM, MAP_OF_CAPE_RIVERNE, MAP_OF_ALTAIEU, MAP_OF_HUXZOI, MAP_OF_RUHMET, MAP_OF_AL_ZAHBI, MAP_OF_NASHMAU, MAP_OF_WAJAOM_WOODLANDS, MAP_OF_CAEDARVA_MIRE, MAP_OF_MOUNT_ZHAYOLM, MAP_OF_AYDEEWA_SUBTERRANE, MAP_OF_MAMOOK, MAP_OF_HALVUNG, MAP_OF_ARRAPAGO_REEF, MAP_OF_ALZADAAL_RUINS, MAP_OF_BHAFLAU_THICKETS, MAP_OF_VUNKERL_INLET, MAP_OF_GRAUBERG, MAP_OF_FORT_KARUGONARUGO}; local Uoption = { --User option selected. 1, --SanDoria Area 65537, --Bastok Area 131073, --Windurst Area 196609, --Jeuno Area 262145, --Ordelles Caves 327681, --Ghelsba 393217, --Davoi 458753, --Carpenters Landing 524289, --Zeruhn Mines 589825, --Palborough Mines 655361, --Beadeaux 720897, --Giddeus 786433, --Castle Oztroja 851969, --Maze of Shakhrami 917505, --Li'Telor Region 983041, --Bibiki Bay 1048577, --Qufim Island 1114113, --Eldieme Necropolis 1179649, --Garlaige Citadel 1245185, --Elshimo Regions 1310721, --Northlands Area 1376257, --King Ranperres Tomb 1441793, --Dangruf Wadi 1507329, --Horutoto Ruins 1572865, --Bostaunieux Oubliette 1638401, --Toraimarai Canal 1703937, --Gusgen Mines 1769473, --Crawlers Nest 1835009, --Ranguemont Pass 1900545, --Delkfutts Tower 1966081, --Feiyin 2031617, --Castle Zvahl 2097153, --Kuzotz region 2162689, --Ru'Aun Gardens 2228225, --Norg 2293761, --Temple of Uggalepih 2359297, --Den of Rancor 2424833, --Korroloka Tunnel 2490369, --Kuftal Tunnel 2555905, --Boyahda Tree 2621441, --Ve'Lugannon Palace 2686977, --Ifrit's Cauldron 2752513, --Quicksand Caves 2818049, --Sea Serpent Grotto 2883585, --Vollbow region 2949121, --Labyrinth of Onzozo 3014657, --Uleguerand Range 3080193, --Attohwa Chasm 3145729, --Pso'Xja 3211265, --Oldton Movalpolos 3276801, --Newton Movalpolos 3342337, --Tavnazia 3407873, --Aqueducts 3473409, --Sacrarium 3538945, --Cape Riverne 3604481, --Al'Taieu 3670017, --Hu'Xzoi 3735553, --Ru'Hmet 3801089, --Al Zahbi 3866625, --Nashmau 3932161, --Wajaom Woodlands 3997697, --Caedarva Mire 4063233, --Mount Zhayolm 4128769, --Aydeewa Subterrane 4194305, --Mamook 4259841, --Halvung 4325377, --Arrapago Reef 4390913, --Alzadall Ruins 4456449, --Bhaflau Thickets 4521985, --Vunkerl Inlet 4587521, --Grauberg 4653057 --Fort Karugo-Narugo }; --Groups maps by price, based off the user option. local p2 = { --Maps that are price at 200 gil Uoption[1], --SanDoria Area Uoption[2], --Bastok Area Uoption[3], --Windurst Area Uoption[9] --Zeruhn Mines }; local p6 = { --Maps that are price at 600 gil Uoption[4], --Jeuno Area Uoption[5], --Ordelles Caves Uoption[6], --Ghelsba Uoption[10], --Palborough Mines Uoption[11], --Beadeaux Uoption[12], --Giddeus Uoption[14], --Maze of Shakhrami Uoption[22], --King Ranperres Tomb Uoption[23], --Dangruf Wadi Uoption[24], --Horutoto Ruins Uoption[27], --Gusgen Mines Uoption[59] --Al Zahbi }; local p3 = { --Maps that are price at 3000 gil Uoption[7], --Davoi Uoption[8], --Carpenters Landing Uoption[13], --Castle Oztroja Uoption[15], --Li'Telor Region Uoption[16], --Bibiki Bay Uoption[17], --Qufim Island Uoption[18], --Eldieme Necropolis Uoption[19], --Garlaige Citadel Uoption[20], --Elshimo Regions Uoption[21], --Northlands Area Uoption[25], --Bostaunieux Oubliette Uoption[26], --Toraimarai Canal Uoption[28], --Crawlers Nest Uoption[29], --Ranguemont Pass Uoption[30], --Delkfutts Tower Uoption[31], --Feiyin Uoption[32], --Castle Zvahl Uoption[33], --Kuzotz region Uoption[34], --Ru'Aun Gardens Uoption[35], --Norg Uoption[36], --Temple of Uggalepih Uoption[37], --Den of Rancor Uoption[38], --Korroloka Tunnel Uoption[39], --Kuftal Tunnel Uoption[40], --Boyahda Tree Uoption[41], --Ve'Lugannon Palace Uoption[42], --Ifrit's Cauldron Uoption[43], --Quicksand Caves Uoption[44], --Sea Serpent Grotto Uoption[45], --Vollbow region Uoption[46], --Labyrinth of Onzozo Uoption[47], --Uleguerand Range Uoption[48], --Attohwa Chasm Uoption[49], --Pso'Xja Uoption[50], --Oldton Movalpolos Uoption[51], --Newton Movalpolos Uoption[52], --Tavnazia Uoption[53], --Aqueducts Uoption[54], --Sacrarium Uoption[55], --Cape Riverne Uoption[56], --Al'Taieu Uoption[57], --Hu'Xzoi Uoption[58], --Ru'Hmet Uoption[60], --Nashmau Uoption[61], --Wajaom Woodlands Uoption[62], --Caedarva Mire Uoption[63], --Mount Zhayolm Uoption[64], --Aydeewa Subterrane Uoption[65], --Mamook Uoption[66], --Halvung Uoption[67], --Arrapago Reef Uoption[68], --Alzadall Ruins Uoption[69] --Bhaflau Thickets }; local p30 = { --Maps that are price at 30,000 gil Uoption[70], --Vunkerl Inlet Uoption[71], --Grauberg Uoption[72] --Fort Karugo-Narugo }; function CheckMaps(player, npc, csid) local i = 0; local mapVar1 = 0; local mapVar2 = 0; local mapVar3 = 0; while i <= 31 do if player:hasKeyItem(Maps[i+1]) then mapVar1 = bit.bor(mapVar1, bit.lshift(1,i)); end i = i + 1; end while i <= 63 do if player:hasKeyItem(Maps[i+1]) then mapVar2 = bit.bor(mapVar2, bit.lshift(1,i)); end i = i + 1; end while i <= 71 do if player:hasKeyItem(Maps[i+1]) then mapVar3 = bit.bor(mapVar3, bit.lshift(1,i)); end i = i + 1; end player:startEvent(csid, mapVar1, mapVar2, mapVar3); end; function CheckMapsUpdate (player, option, NOT_HAVE_ENOUGH_GIL, KEYITEM_OBTAINED) local price = 0; local MadePurchase = false; local KI = 0; local i = 0; local mapVar1 = 0; local mapVar2 = 0; local mapVar3 = 0; while i <= 71 do if (option == Uoption[i+1]) then local x = 1; while x <= 53 do if (x <= 4 and option == p2[x]) then price = 200; elseif (x <= 12 and option == p6[x]) then price = 600; elseif (x <= 53 and option == p3[x]) then price = 3000; elseif (x <= 3 and option == p30[x]) then price = 30000; end x=x+1; end MadePurchase = true; KI = Maps[i+1]; end i = i + 1; end if (price > player:getGil()) then player:messageSpecial(NOT_HAVE_ENOUGH_GIL); MadePurchase = false; price = 0; elseif (price > 0 and MadePurchase == true) then player:delGil(price); MadePurchase = false; player:addKeyItem(KI); player:messageSpecial(KEYITEM_OBTAINED, KI); end i=0; while i <= 31 do if player:hasKeyItem(Maps[i+1]) then mapVar1 = bit.bor(mapVar1, bit.lshift(1,i)); end i = i + 1; end while i <= 63 do if player:hasKeyItem(Maps[i+1]) then mapVar2 = bit.bor(mapVar2, bit.lshift(1,i)); end i = i + 1; end while i <= 71 do if player:hasKeyItem(Maps[i+1]) then mapVar3 = bit.bor(mapVar3, bit.lshift(1,i)); end i = i + 1; end player:updateEvent(mapVar1, mapVar2, mapVar3); end;
gpl-3.0
nesstea/darkstar
scripts/zones/Northern_San_dOria/npcs/Fittesegat.lua
13
1044
----------------------------------- -- Area: Northern San d'Oria -- NPC: Fittesegat -- Type: Standard Dialogue NPC -- @zone: 231 -- @pos 144.250 0.000 138.203 -- ----------------------------------- package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil; require("scripts/zones/Northern_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc,FITTESEGAT_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
UnfortunateFruit/darkstar
scripts/zones/PsoXja/npcs/_098.lua
8
1608
----------------------------------- -- Area: Pso'Xja -- NPC: _098 (Stone Gate) -- Notes: Spawns Gargoyle when triggered -- @pos -330.000 14.074 -261.600 9 ----------------------------------- package.loaded["scripts/zones/PsoXja/TextIDs"] = nil; ----------------------------------- require("scripts/zones/PsoXja/TextIDs"); require("scripts/globals/keyitems"); ----------------------------------- -- onTrade ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger ----------------------------------- function onTrigger(player,npc) local X=player:getXPos(); if (npc:getAnimation() == 9) then if(X >= 259)then if(GetMobAction(16814089) == 0) then local Rand = math.random(1,10); if (Rand <=9) then -- Spawn Gargoyle player:messageSpecial(TRAP_ACTIVATED); SpawnMob(16814089,120):updateClaim(player); -- Gargoyle else player:messageSpecial(TRAP_FAILS); npc:openDoor(30); end else player:messageSpecial(DOOR_LOCKED); end elseif(X <= 258)then player:startEvent(0x001A); end end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) if(csid == 0x001A and option == 1) then player:setPos(260,-0.25,-20,254,111); end end;
gpl-3.0
UnfortunateFruit/darkstar
scripts/zones/Southern_San_dOria/npcs/Arpevion_TK.lua
28
4813
----------------------------------- -- Area: Southern San d'Oria -- NPC: Arpevion, T.K. -- X Grant Signet -- X Recharge Emperor Band, Empress Band, or Chariot Band -- X Accepts traded Crystals to fill up the Rank bar to open new Missions. -- X Sells items in exchange for Conquest Points -- X Start Supply Run Missions and offers a list of already-delivered supplies. -- Start an Expeditionary Force by giving an E.F. region insignia to you. ------------------------------------- package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil; ------------------------------------- require("scripts/globals/conquest"); require("scripts/zones/Southern_San_dOria/TextIDs"); local guardnation = SANDORIA; -- SANDORIA, BASTOK, WINDURST, JEUNO local guardtype = 1; -- 1: city, 2: foreign, 3: outpost, 4: border local size = table.getn(SandInv); local inventory = SandInv; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) tradeConquestGuard(player,npc,trade,guardnation,guardtype); end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:getNation() == guardnation and player:getVar("supplyQuest_started") > 0 and supplyRunFresh(player) == 0) then player:showText(npc,CONQUEST + 40); -- "We will dispose of those unusable supplies." local region = player:getVar("supplyQuest_region"); player:delKeyItem(getSupplyKey(region)); player:messageSpecial(KEYITEM_OBTAINED + 1,getSupplyKey(region)); player:setVar("supplyQuest_started",0); player:setVar("supplyQuest_region",0); else local Menu1 = getArg1(guardnation,player); local Menu2 = getExForceAvailable(guardnation,player); local Menu3 = conquestRanking(); local Menu4 = getSupplyAvailable(guardnation,player); local Menu5 = player:getNationTeleport(guardnation); local Menu6 = getArg6(player); local Menu7 = player:getCP(); local Menu8 = getRewardExForce(guardnation,player); player:startEvent(0x7ffb,Menu1,Menu2,Menu3,Menu4,Menu5,Menu6,Menu7,Menu8); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("onUpdateCSID: %u",csid); -- printf("onUpdateOPTION: %u",option); if (option >= 32768 and option <= 32944) then for Item = 1,size,3 do if (option == inventory[Item]) then CPVerify = 1; if (player:getCP() >= inventory[Item + 1]) then CPVerify = 0; end; player:updateEvent(2,CPVerify,inventory[Item + 2]); break; end; end; end; end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("onFinishCSID: %u",csid); -- printf("onFinishOPTION: %u",option); if (option == 1) then duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600; player:delStatusEffect(EFFECT_SIGIL); player:delStatusEffect(EFFECT_SANCTION); player:delStatusEffect(EFFECT_SIGNET); player:addStatusEffect(EFFECT_SIGNET,0,0,duration); -- Grant Signet elseif (option >= 32768 and option <= 32944) then for Item = 1,size,3 do if (option == inventory[Item]) then if (player:getFreeSlotsCount() >= 1) then -- Logic to impose limits on exp bands if (option >= 32933 and option <= 32935) then if (checkConquestRing(player) > 0) then player:messageSpecial(CONQUEST+60,0,0,inventory[Item+2]); break; else player:setVar("CONQUEST_RING_TIMER",getConquestTally()); end end if (player:getNation() == guardnation) then itemCP = inventory[Item + 1]; else if (inventory[Item + 1] <= 8000) then itemCP = inventory[Item + 1] * 2; else itemCP = inventory[Item + 1] + 8000; end; end; if (player:hasItem(inventory[Item + 2]) == false) then player:delCP(itemCP); player:addItem(inventory[Item + 2],1); player:messageSpecial(ITEM_OBTAINED,inventory[Item + 2]); else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,inventory[Item + 2]); end; else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,inventory[Item + 2]); end; break; end; end; elseif (option >= 65541 and option <= 65565) then -- player chose supply quest. local region = option - 65541; player:addKeyItem(getSupplyKey(region)); player:messageSpecial(KEYITEM_OBTAINED,getSupplyKey(region)); player:setVar("supplyQuest_started",vanaDay()); player:setVar("supplyQuest_region",region); player:setVar("supplyQuest_fresh",getConquestTally()); end; end;
gpl-3.0
UnfortunateFruit/darkstar
scripts/zones/Windurst_Waters_[S]/npcs/Romaa_Mihgo.lua
38
1047
----------------------------------- -- Area: Windurst Waters (S) -- NPC: Romaa Mihgo -- Type: Standard NPC -- @zone: 94 -- @pos -1.967 -3 -26.337 -- -- 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(0x000b); 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/Jugner_Forest_[S]/npcs/Glowing_Pebbles.lua
19
1305
----------------------------------- -- Area: Jugner Forest (S) -- NPC: Glowing Pebbles -- Type: Involved in Quest -- @pos -- player:startEvent(0x006a); Left over Cutscene ----------------------------------- package.loaded["scripts/zones/Jugner_Forest_[S]/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Jugner_Forest_[S]/TextIDs"); require("scripts/globals/keyitems"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if(player:getVar("Lakeside_Minuet_Progress") == 3 and player:hasKeyItem(STARDUST_PEBBLE) == false)then player:startEvent(0x0064); player:addKeyItem(STARDUST_PEBBLE); player:messageSpecial(KEYITEM_OBTAINED,STARDUST_PEBBLE); 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
mrkulk/inverse-graphics-networks
ParallelParallel.lua
1
12083
require 'nn' require 'parallel' local ParallelParallel, parent = torch.class('nn.ParallelParallel', 'nn.Container') function moduleWrapper() require 'nn' require 'ACR' require 'INTM' require 'Bias' require 'PrintModule' require 'INTMReg' require 'gradACRWrapper' torch.setnumthreads(1) local modelKeys = {'output', 'weight', 'bias', 'gradInput', 'gradWeight', 'gradBias', 'test'} function sanitize(m) if torch.typename(m) then local current = {} for _, key in ipairs(modelKeys) do current[key] = m[key] end if m.modules then local modules = {} for index, child in ipairs(m.modules) do table.insert(modules, sanitize(child)) end current.modules = modules end return current elseif type(m) == 'table' then local current = {} for index, elem in ipairs(m) do table.insert(current, sanitize(elem)) end else error("Must be a single torch object or a list of them!") end end function updateIn(m, tbl) -- recursively update any changed modules if tbl.modules then for moduleIndex, updates in pairs(tbl.modules) do updateIn(m.modules[moduleIndex], updates) end end -- set all the updated keys in this module for key, value in pairs(tbl) do if key ~= 'modules' then m[key] = value end end end function fetchFrom(m, keyList) if type(keyList) == 'table' then if #keyList > 1 then local key = table.remove(keyList, 1) return fetchFrom(m[key], keyList) else return m[keyList[1]] end else return m[keyList] end end parallel.yield() local mod = nil while true do local message = parallel.parent:receive() local messageType = message[1] local data = message[2] if messageType == 'module' then mod = data -- use with CPU parallel in the grad calculation -- for i, m in pairs(mod:findModules('nn.ACR')) do -- m:makeThreads() -- end elseif messageType == 'updateOutput' then parallel.parent:send(mod:updateOutput(data)) elseif messageType == 'updateGradInput' then parallel.parent:send(mod:updateGradInput(data[1], data[2])) elseif messageType == 'accGradParameters' then mod:accGradParameters(data[1], data[2], data[3]) elseif messageType == 'accUpdateGradParameters' then mod:accUpdateGradParameters(data[1], data[2], data[3]) elseif messageType == 'zeroGradParameters' then mod:zeroGradParameters() elseif messageType == 'updateParameters' then mod:updateParameters(data) elseif messageType == 'training' then mod:training() elseif messageType == 'evaluate' then mod:evaluate() elseif messageType == 'share' then mod:evaluate(data[1], data[2]) elseif messageType == 'reset' then mod:reset(data) elseif messageType == 'update' then updateIn(mod, data) parallel.parent:send(true) elseif messageType == 'dump' then parallel.parent:send(sanitize(mod)) elseif messageType == 'fetch' then parallel.parent:send(fetchFrom(mod, data)) else error("Not a valid message type!") end end end -- if I want to bring back caching -- local modelKeys = {'output', 'weight', 'bias', 'gradInput', 'gradWeight', 'gradBias'} function buildCache(module, parent, childIndex) -- print(module) local cache = {_hiddenData = {}} cache.__typename = torch.typename(module) if parent then cache._parent = parent cache._childIndex = childIndex end -- also for caching -- for _, key in ipairs(modelKeys) do -- cache._hiddenData[key] = module[key] -- end if module.modules then cache._hiddenData.modules = {} for i, submodule in ipairs(module.modules) do table.insert(cache._hiddenData.modules, buildCache(submodule, cache, i)) end end return cache end function setmetatable_recursive(tbl, mt) if tbl._hiddenData.modules then for _, module in ipairs(tbl._hiddenData.modules) do setmetatable_recursive(module, mt) end end setmetatable(tbl, mt) end function ParallelParallel:__init(inputDimension,outputDimension) parent.__init(self) self.modules = {} self.size = torch.LongStorage() self.inputDimension = inputDimension self.outputDimension = outputDimension self.childThreads = {} -- make self.childThreads act just like parallel.children parallel._fill(self.childThreads) end function setval_remote(tbl, key, value) if tbl._threadConnection then tbl._threadConnection:send({ 'update', {[key] = value} }) tbl._threadConnection:receive() elseif tbl._parent then setval_remote(tbl._parent, 'modules', {[tbl._childIndex] = {[key] = value}}) else error("No parent or threadConnection!") end end function ParallelParallel:add(mod) local child = parallel.fork() child:exec(moduleWrapper) table.insert(self.childThreads, child) local localmod = buildCache(mod) localmod._threadConnection = child setmetatable_recursive(localmod, { __index = function(tbl, key) if type(key) == 'string' then if string.sub(key, 1, 1) == '_' then -- if the table had that key, this query wouldn't be here return nil elseif key == 'modules' then return tbl._hiddenData[key] end end if tbl._threadConnection then if type(key) ~= 'table' then key = {key} end tbl._threadConnection:send({'fetch', key}) return tbl._threadConnection:receive() elseif tbl._parent then if type(key) == 'table' then table.insert(key, 1, tbl._childIndex) table.insert(key, 1, 'modules') return tbl._parent[key] else return tbl._parent[{'modules', tbl._childIndex, key}] end else error("No parent or threadConnection found!") end end, __newindex = function(tbl, key, value) setval_remote(tbl, key, value) -- #caching -- tbl._hiddenData[key] = value end }) table.insert(self.modules, localmod) child:join() child:send({'module', mod}) return self end function ParallelParallel:updateOutput(input) local nModule=input:size(self.inputDimension) for i = 1, #self.modules do local currentInput = input:select(self.inputDimension,i) self.childThreads[i]:send({'updateOutput', currentInput}) end local outputs = self.childThreads:receive() for i = 1, #outputs do -- #caching -- self.modules[i].output = outputs[i] local currentOutput = outputs[i] local outputSize = currentOutput:size(self.outputDimension) if i == 1 then self.size:resize(currentOutput:dim()):copy(currentOutput:size()) else self.size[self.outputDimension] = self.size[self.outputDimension] + outputSize end end self.output:resize(self.size) local offset = 1 for i=1,nModule do local currentOutput = outputs[i] local outputSize = currentOutput:size(self.outputDimension) self.output:narrow(self.outputDimension, offset, outputSize):copy(currentOutput) offset = offset + currentOutput:size(self.outputDimension) end return self.output end function ParallelParallel:updateGradInput(input, gradOutput) local nModule=input:size(self.inputDimension) self.gradInput:resizeAs(input) local offset = 1 for i = 1, #self.modules do -- #caching -- self.childThreads[i]:join() local currentInput = input:select(self.inputDimension,i) local currentOutput = self.modules[i].output local outputSize = currentOutput:size(self.outputDimension) local currentGradOutput = gradOutput:narrow(self.outputDimension, offset, outputSize) self.childThreads[i]:send({'updateGradInput', {currentInput, currentGradOutput}}) end local gradInputs = parallel.children:receive() for i=1,nModule do local currentGradInput = gradInputs[i] local currentOutput = self.modules[i].output local outputSize = currentOutput:size(self.outputDimension) self.gradInput:select(self.inputDimension,i):copy(currentGradInput) offset = offset + outputSize end return self.gradInput end function ParallelParallel:accGradParameters(input, gradOutput, scale) local nModule=input:size(self.inputDimension) local offset = 1 for i=1,nModule do local mod = self.modules[i] local currentOutput = mod.output local outputSize = currentOutput:size(self.outputDimension) self.childThreads[i]:send({ 'accGradParameters', {input:select(self.inputDimension,i), gradOutput:narrow(self.outputDimension, offset,outputSize), scale}}) offset = offset + outputSize end end function ParallelParallel:accUpdateGradParameters(input, gradOutput, lr) local nModule=input:size(self.inputDimension) local offset = 1 for i=1,nModule do local mod = self.modules[i]; local currentOutput = mod.output self.childThreads[i]:send({ 'accUpdateGradParameters', {input:select(self.inputDimension,i), gradOutput:narrow(self.outputDimension, offset, currentOutput:size(self.outputDimension)), lr}}) offset = offset + currentOutput:size(self.outputDimension) end end function ParallelParallel:zeroGradParameters() for i = 1, #self.modules do self.childThreads[i]:send({'zeroGradParameters'}) end end function ParallelParallel:training() for i = 1, #self.modules do self.childThreads[i]:send({'training'}) end end function ParallelParallel:evaluate() for i = 1, #self.modules do self.childThreads[i]:send({'evaluate'}) end end function ParallelParallel:reset(stdv) for i = 1, #self.modules do self.childThreads[i]:send({'reset', stdv}) end end function ParallelParallel:updateParameters(learningRate) for i = 1, #self.modules do self.childThreads[i]:send({'updateParameters', learningRate}) end end function ParallelParallel:share(mlp, ...) for i = 1, #self.modules do self.childThreads[i]:send({'share', {mlp.modules[i], ...}}) end end -- function ParallelParallel:findModules(name, container) -- container = container or self -- local nodes = {} -- local containers = {} -- local mod_type = torch.typename(self) -- if mod_type == typename then -- nodes[#nodes+1] = self -- containers[#containers+1] = container -- end -- -- Recurse on nodes with 'modules' -- if (self.modules ~= nil) then -- if (torch.type(self.modules) == 'table') then -- for i = 1, #self.modules do -- local child = self.modules[i] -- local cur_nodes, cur_containers = child:findModules(typename, self) -- assert(#cur_nodes == #cur_containers, -- 'Internal error: incorrect return length') -- This shouldn't happen -- -- add the list items from our child to our list (ie return a -- -- flattened table of the return nodes). -- for j = 1, #cur_nodes do -- nodes[#nodes+1] = cur_nodes[j] -- containers[#containers+1] = cur_containers[j] -- end -- end -- end -- end -- -- return nodes, containers -- container = container or self -- for i = 1, #self.modules do -- self.childThreads[i]:send({'findModules', {}}) -- end -- local results = self.childThreads:receive() -- -- return self.modules -- end function ParallelParallel:__tostring__() local tab = ' ' local line = '\n' local next = ' |`-> ' local ext = ' | ' local extlast = ' ' local last = ' ... -> ' local str = torch.type(self) str = str .. ' {' .. line .. tab .. 'input' for i=1,#self.modules do if i == self.modules then str = str .. line .. tab .. next .. '(' .. i .. '): ' .. tostring(self.modules[i]):gsub(line, line .. tab .. extlast) else str = str .. line .. tab .. next .. '(' .. i .. '): ' .. tostring(self.modules[i]):gsub(line, line .. tab .. ext) end end str = str .. line .. tab .. last .. 'output' str = str .. line .. '}' return str end
apache-2.0
alexander-koch/3D-Game-Engine
demos/a_star/scripts/main.lua
1
1356
dofile("scripts/util.lua") dofile("scripts/grid.lua") dofile("scripts/pathfinding.lua") scene = Scene() list = {} grid = nil path = nil start = {-10, 0, -10} target = {10, 0, 10} enemy = nil function onInit() scene:require("scripts/main.mat") local mesh = Mesh() mesh:loadCube(1) mesh:setScale({20, 0.1, 20}) mesh:setMaterial(Material("ground")) table.insert(list, mesh) scene:addEntity(mesh) local ground = RigidBody(Shape.Box, {20, 0.1, 20}) ground:setMass(0) ground:setMesh(mesh) ground:create({0, 0, 0, 1}, {0, 0, 0}) table.insert(list, ground) scene:addEntity(ground) cam = scene:getDefaultCamera() cam:setPosition({0, 40, -2}) --createObstacle({0, 10, 0}, scene, list) grid = Grid({0, 0, 0}, {40, 40}, 1) grid:create(scene, list) path = Path(grid) end function onUpdate() path:find(start, target) grid:debugPath(scene, list) grid:getNodeFromWorld(start).gizmo:setMaterial(Material("obstacle")) grid:getNodeFromWorld(target).gizmo:setMaterial(Material("obstacle")) if isKeyDown("W") then start[3] = start[3] - 0.3 end if isKeyDown("S") then start[3] = start[3] + 0.3 end if isKeyDown("A") then start[1] = start[1] - 0.3 end if isKeyDown("D") then start[1] = start[1] + 0.3 end end
apache-2.0
oralius/byond1
libs/dateparser.lua
502
6212
local difftime, time, date = os.difftime, os.time, os.date local format = string.format local tremove, tinsert = table.remove, table.insert local pcall, pairs, ipairs, tostring, tonumber, type, setmetatable = pcall, pairs, ipairs, tostring, tonumber, type, setmetatable local dateparser={} --we shall use the host OS's time conversion facilities. Dealing with all those leap seconds by hand can be such a bore. local unix_timestamp do local now = time() local local_UTC_offset_sec = difftime(time(date("!*t", now)), time(date("*t", now))) unix_timestamp = function(t, offset_sec) local success, improper_time = pcall(time, t) if not success or not improper_time then return nil, "invalid date. os.time says: " .. (improper_time or "nothing") end return improper_time - local_UTC_offset_sec - offset_sec end end local formats = {} -- format names local format_func = setmetatable({}, {__mode='v'}) --format functions ---register a date format parsing function function dateparser.register_format(format_name, format_function) if type(format_name)~="string" or type(format_function)~='function' then return nil, "improper arguments, can't register format handler" end local found for i, f in ipairs(format_func) do --for ordering if f==format_function then found=true break end end if not found then tinsert(format_func, format_function) end formats[format_name] = format_function return true end ---register a date format parsing function function dateparser.unregister_format(format_name) if type(format_name)~="string" then return nil, "format name must be a string" end formats[format_name]=nil end ---return the function responsible for handling format_name date strings function dateparser.get_format_function(format_name) return formats[format_name] or nil, ("format %s not registered"):format(format_name) end ---try to parse date string --@param str date string --@param date_format optional date format name, if known --@return unix timestamp if str can be parsed; nil, error otherwise. function dateparser.parse(str, date_format) local success, res, err if date_format then if not formats[date_format] then return 'unknown date format: ' .. tostring(date_format) end success, res = pcall(formats[date_format], str) else for i, func in ipairs(format_func) do success, res = pcall(func, str) if success and res then return res end end end return success and res end dateparser.register_format('W3CDTF', function(rest) local year, day_of_year, month, day, week local hour, minute, second, second_fraction, offset_hours local alt_rest year, rest = rest:match("^(%d%d%d%d)%-?(.*)$") day_of_year, alt_rest = rest:match("^(%d%d%d)%-?(.*)$") if day_of_year then rest=alt_rest end month, rest = rest:match("^(%d%d)%-?(.*)$") day, rest = rest:match("^(%d%d)(.*)$") if #rest>0 then rest = rest:match("^T(.*)$") hour, rest = rest:match("^([0-2][0-9]):?(.*)$") minute, rest = rest:match("^([0-6][0-9]):?(.*)$") second, rest = rest:match("^([0-6][0-9])(.*)$") second_fraction, alt_rest = rest:match("^%.(%d+)(.*)$") if second_fraction then rest=alt_rest end if rest=="Z" then rest="" offset_hours=0 else local sign, offset_h, offset_m sign, offset_h, rest = rest:match("^([+-])(%d%d)%:?(.*)$") local offset_m, alt_rest = rest:match("^(%d%d)(.*)$") if offset_m then rest=alt_rest end offset_hours = tonumber(sign .. offset_h) + (tonumber(offset_m) or 0)/60 end if #rest>0 then return nil end end year = tonumber(year) local d = { year = year and (year > 100 and year or (year < 50 and (year + 2000) or (year + 1900))), month = tonumber(month) or 1, day = tonumber(day) or 1, hour = tonumber(hour) or 0, min = tonumber(minute) or 0, sec = tonumber(second) or 0, isdst = false } local t = unix_timestamp(d, (offset_hours or 0) * 3600) if second_fraction then return t + tonumber("0."..second_fraction) else return t end end) do local tz_table = { --taken from http://www.timeanddate.com/library/abbreviations/timezones/ A = 1, B = 2, C = 3, D = 4, E=5, F = 6, G = 7, H = 8, I = 9, K = 10, L = 11, M = 12, N = -1, O = -2, P = -3, Q = -4, R = -5, S = -6, T = -7, U = -8, V = -9, W = -10, X = -11, Y = -12, Z = 0, EST = -5, EDT = -4, CST = -6, CDT = -5, MST = -7, MDT = -6, PST = -8, PDT = -7, GMT = 0, UT = 0, UTC = 0 } local month_val = {Jan=1, Feb=2, Mar=3, Apr=4, May=5, Jun=6, Jul=7, Aug=8, Sep=9, Oct=10, Nov=11, Dec=12} dateparser.register_format('RFC2822', function(rest) local year, month, day, day_of_year, week_of_year, weekday local hour, minute, second, second_fraction, offset_hours local alt_rest weekday, alt_rest = rest:match("^(%w%w%w),%s+(.*)$") if weekday then rest=alt_rest end day, rest=rest:match("^(%d%d?)%s+(.*)$") month, rest=rest:match("^(%w%w%w)%s+(.*)$") month = month_val[month] year, rest = rest:match("^(%d%d%d?%d?)%s+(.*)$") hour, rest = rest:match("^(%d%d?):(.*)$") minute, rest = rest:match("^(%d%d?)(.*)$") second, alt_rest = rest:match("^:(%d%d)(.*)$") if second then rest = alt_rest end local tz, offset_sign, offset_h, offset_m tz, alt_rest = rest:match("^%s+(%u+)(.*)$") if tz then rest = alt_rest offset_hours = tz_table[tz] else offset_sign, offset_h, offset_m, rest = rest:match("^%s+([+-])(%d%d)(%d%d)%s*(.*)$") offset_hours = tonumber(offset_sign .. offset_h) + (tonumber(offset_m) or 0)/60 end if #rest>0 or not (year and day and month and hour and minute) then return nil end year = tonumber(year) local d = { year = year and ((year > 100) and year or (year < 50 and (year + 2000) or (year + 1900))), month = month, day = tonumber(day), hour= tonumber(hour) or 0, min = tonumber(minute) or 0, sec = tonumber(second) or 0, isdst = false } return unix_timestamp(d, offset_hours * 3600) end) end dateparser.register_format('RFC822', formats.RFC2822) --2822 supercedes 822, but is not a strict superset. For our intents and purposes though, it's perfectly good enough dateparser.register_format('RFC3339', formats.W3CDTF) --RFC3339 is a subset of W3CDTF return dateparser
gpl-3.0
jj918160/cocos2d-x-samples
samples/FantasyWarrior3D/frameworks/runtime-src/Classes/custom/api/EffectSprite3D.lua
9
1697
-------------------------------- -- @module EffectSprite3D -- @extend Sprite3D -- @parent_module cc -------------------------------- -- -- @function [parent=#EffectSprite3D] setEffect3D -- @param self -- @param #cc.Effect3D effect -- @return EffectSprite3D#EffectSprite3D self (return value: cc.EffectSprite3D) -------------------------------- -- -- @function [parent=#EffectSprite3D] addEffect -- @param self -- @param #vec3_table outlineColor -- @param #float width -- @param #int order -- @return EffectSprite3D#EffectSprite3D self (return value: cc.EffectSprite3D) -------------------------------- -- -- @function [parent=#EffectSprite3D] getMesh -- @param self -- @return array_table#array_table ret (return value: array_table) -------------------------------- -- -- @function [parent=#EffectSprite3D] getMeshNum -- @param self -- @return int#int ret (return value: int) -------------------------------- -- -- @function [parent=#EffectSprite3D] create -- @param self -- @param #string modelPath -- @return EffectSprite3D#EffectSprite3D ret (return value: cc.EffectSprite3D) -------------------------------- -- -- @function [parent=#EffectSprite3D] createFromObjFileAndTexture -- @param self -- @param #string objFilePath -- @param #string textureFilePath -- @return EffectSprite3D#EffectSprite3D ret (return value: cc.EffectSprite3D) -------------------------------- -- -- @function [parent=#EffectSprite3D] draw -- @param self -- @param #cc.Renderer renderer -- @param #mat4_table transform -- @param #unsigned int flags -- @return EffectSprite3D#EffectSprite3D self (return value: cc.EffectSprite3D) return nil
mit
UnfortunateFruit/darkstar
scripts/zones/Windurst_Woods/npcs/Mokop-Sankop.lua
38
1043
----------------------------------- -- Area: Windurst Woods -- NPC: Mokop-Sankop -- Type: Conquest Troupe -- @zone: 241 -- @pos 11.542 1.05 -53.217 -- -- Auto-Script: Requires Verification (Verified 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(0x0032); 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/weaponskills/vidohunir.lua
6
2086
----------------------------------- -- Vidohunir -- Staff weapon skill -- Skill Level: N/A -- Lowers target's magic defense. Duration of effect varies with TP. Laevateinn: Aftermath effect varies with TP. -- Reduces enemy's magic defense by 10%. -- Available only after completing the Unlocking a Myth (Black Mage) quest. -- Aligned with the Breeze Gorget, Thunder Gorget, Aqua Gorget & Snow Gorget. -- Aligned with the Breeze Belt, Thunder Belt, Aqua Belt & Snow Belt. -- Element: Darkness -- Modifiers: INT:30% -- 100%TP 200%TP 300%TP -- 1.75 1.75 1.75 ----------------------------------- require("scripts/globals/magic"); require("scripts/globals/status"); require("scripts/globals/settings"); require("scripts/globals/weaponskills"); ----------------------------------- function onUseWeaponSkill(player, target, wsID, tp, primary) local params = {}; params.ftp100 = 1.75; params.ftp200 = 1.75; params.ftp300 = 1.75; params.str_wsc = 0.0; 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_STF; params.includemab = true; if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then params.int_wsc = 0.8; end local damage, criticalHit, tpHits, extraHits = doMagicWeaponskill(player, target, wsID, params, tp, primary); if (damage > 0) then local duration = (tp/1000 * 60); if (target:hasStatusEffect(EFFECT_MAGIC_DEF_DOWN) == false) then target:addStatusEffect(EFFECT_MAGIC_DEF_DOWN, 10, 0, duration); end end if ((player:getEquipID(SLOT_MAIN) == 18994) and (player:getMainJob() == JOB_BLM)) then if (damage > 0) then local params = initAftermathParams() params.power.lv2_inc = 1 params.subpower.lv1 = 2 params.subpower.lv2 = 3 params.subpower.lv3 = 1 applyAftermathEffect(player, tp, params) end end return tpHits, extraHits, criticalHit, damage; end
gpl-3.0
nesstea/darkstar
scripts/zones/Southern_San_dOria/npcs/Faulpie.lua
44
2855
----------------------------------- -- Area: Southern San d'Oria -- NPC: Faulpie -- Type: Leathercraft Guild Master -- @pos -178.882 -2 9.891 230 ----------------------------------- package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/status"); require("scripts/globals/crafting"); require("scripts/zones/Southern_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) local newRank = tradeTestItem(player,npc,trade,SKILL_LEATHERCRAFT); if (newRank ~= 0) then player:setSkillRank(SKILL_LEATHERCRAFT,newRank); player:startEvent(0x0289,0,0,0,0,newRank); end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local getNewRank = 0; local craftSkill = player:getSkillLevel(SKILL_LEATHERCRAFT); local testItem = getTestItem(player,npc,SKILL_LEATHERCRAFT); local guildMember = isGuildMember(player,7); if (guildMember == 1) then guildMember = 150995375; end if (canGetNewRank(player,craftSkill,SKILL_LEATHERCRAFT) == 1) then getNewRank = 100; end if (player:getCurrentMission(ASA) == THAT_WHICH_CURDLES_BLOOD and guildMember == 150995375 and getNewRank ~= 100) then local item = 0; local asaStatus = player:getVar("ASA_Status"); -- TODO: Other Enfeebling Kits if (asaStatus == 0) then item = 2779; else printf("Error: Unknown ASA Status Encountered <%u>", asaStatus); end -- The Parameters are Item IDs for the Recipe player:startEvent(0x03b0, item, 2773, 917, 917, 2776, 4103); else player:startEvent(0x0288,testItem,getNewRank,30,guildMember,44,0,0,0); end end; -- 0x0288 0x0289 0x02f8 0x02f9 0x02fa 0x02fb 0x02fc 0x02fd 0x0302 0x0303 0x0304 0x0305 0x0306 0x0307 0x03b0 0x0392 ----------------------------------- -- 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 == 0x0288 and option == 1) then local crystal = math.random(4096,4101); if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,crystal); else player:addItem(crystal); player:messageSpecial(ITEM_OBTAINED,crystal); signupGuild(player, SKILL_LEATHERCRAFT); end end end;
gpl-3.0
UnfortunateFruit/darkstar
scripts/zones/Port_Jeuno/npcs/Illauvolahaut.lua
20
1586
----------------------------------- -- Area: Port Jeuno -- NPC: Illauvolahaut -- @zone 246 -- @pos -12 8 54 ----------------------------------- package.loaded["scripts/zones/Port_Jeuno/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/zones/Port_Jeuno/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) KazhPass = player:hasKeyItem(AIRSHIP_PASS_FOR_KAZHAM); Gil = player:getGil(); if(KazhPass == false) then player:startEvent(0x0023); -- without pass elseif(KazhPass == true and Gil < 200) then player:startEvent(0x002d); -- Pass without money elseif(KazhPass == true) then player:startEvent(0x0025); -- Pass with money end end; -- 0x0029 without addons (ZM) ? ----------------------------------- -- 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 == 0x0025) then Z = player:getZPos(); if(Z >= 58 and Z <= 61) then player:delGil(200); end end end;
gpl-3.0
nesstea/darkstar
scripts/zones/FeiYin/TextIDs.lua
15
2354
-- Variable TextID Description text -- General Texts ITEM_CANNOT_BE_OBTAINED = 6558; -- You cannot obtain the item <item> come back again after sorting your inventory ITEM_OBTAINED = 6563; -- Obtained: <item> GIL_OBTAINED = 6564; -- Obtained <number> gil KEYITEM_OBTAINED = 6566; -- Obtained key item: <keyitem> FISHING_MESSAGE_OFFSET = 7224; -- You can't fish here HOMEPOINT_SET = 10679; -- Home point set! -- Treasure Coffer/Chest Dialog CHEST_UNLOCKED = 7349; -- You unlock the chest! CHEST_FAIL = 7350; -- Fails to open the chest. CHEST_TRAP = 7351; -- The chest was trapped! CHEST_WEAK = 7352; -- You cannot open the chest when you are in a weakened state. CHEST_MIMIC = 7353; -- The chest was a mimic! CHEST_MOOGLE = 7354; -- You cannot open the chest while participating in the moogle event. CHEST_ILLUSION = 7355; -- The chest was but an illusion... CHEST_LOCKED = 7356; -- The chest appears to be locked. -- Other Dialog SENSE_OF_FOREBODING = 6578; -- You are suddenly overcome with a sense of foreboding... NOTHING_OUT_OF_ORDINARY = 6577; -- There is nothing out of the ordinary here. -- ACP mission MARK_OF_SEED_HAS_VANISHED = 7492; -- The Mark of Seed has vanished without a trace... MARK_OF_SEED_IS_ABOUT_TO_DISSIPATE = 7491; -- The Mark of Seed is about to dissipate entirely! Only a faint outline remains... MARK_OF_SEED_GROWS_FAINTER = 7490; -- The Mark of Seed grows fainter still. Before long, it will fade away entirely... MARK_OF_SEED_FLICKERS = 7489; -- The glow of the Mark of Seed flickers and dims ever so slightly... SCINTILLATING_BURST_OF_LIGHT = 7480; -- As you extend your hand, there is a scintillating burst of light! YOU_REACH_FOR_THE_LIGHT = 7479; -- You reach for the light, but there is no discernable effect... EVEN_GREATER_INTENSITY = 7478; -- The emblem on your hand glows with even greater intensity! THE_LIGHT_DWINDLES = 7477; -- However, the light dwindles and grows dim almost at once... YOU_REACH_OUT_TO_THE_LIGHT = 7476; -- You reach out to the light, and one facet of a curious seed-shaped emblem materializes on the back of your hand. SOFTLY_SHIMMERING_LIGHT = 7475; -- You see a softly shimmering light... -- conquest Base CONQUEST_BASE = 3;
gpl-3.0
nesstea/darkstar
scripts/globals/weaponskills/fast_blade.lua
11
1341
----------------------------------- -- Fast Blade -- Sword weapon skill -- Skill Level: 5 -- Delivers a two-hit attack. Damage varies with TP. -- Will stack with Sneak Attack. -- Aligned with the Soil Gorget. -- Aligned with the Soil Belt. -- Element: None -- Modifiers: STR:20% ; DEX:20% -- 100%TP 200%TP 300%TP -- 1.00 1.50 2.00 ----------------------------------- require("scripts/globals/status"); require("scripts/globals/settings"); require("scripts/globals/weaponskills"); ----------------------------------- function onUseWeaponSkill(player, target, wsID, tp, primary) local params = {}; params.numHits = 2; params.ftp100 = 1; params.ftp200 = 1.5; params.ftp300 = 2; params.str_wsc = 0.2; params.dex_wsc = 0.2; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0; params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0; params.canCrit = false; params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0; params.atkmulti = 1; if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then params.str_wsc = 0.4; params.dex_wsc = 0.4; end local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, primary); return tpHits, extraHits, criticalHit, damage; end
gpl-3.0
nesstea/darkstar
scripts/zones/Southern_San_dOria/npcs/Valderotaux.lua
13
1765
----------------------------------- -- Area: Southern San d'Oria -- NPC: Valderotaux -- General Info NPC -- @pos 97 0.1 113 230 ------------------------------------- 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 if (trade:hasItemQty(532,1) and trade:getItemCount() == 1) then player:messageSpecial(FLYER_REFUSED); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local lakesideMin = player:getQuestStatus(JEUNO,LAKESIDE_MINUET); local lakeProg = player:getVar("Lakeside_Minuet_Progress"); if (lakeProg == 1) then player:startEvent(0x0378); -- Dance for the drunks! player:setVar("Lakeside_Minuet_Progress",2); elseif (lakeProg >= 2) then player:startEvent(0x0379); -- Immediate regret of failure! else player:startEvent(0x03A); 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/Kuftal_Tunnel/mobs/Guivre.lua
7
14748
---------------------------------- -- Area: Gustav Tunnel -- NM: Guivre ----------------------------------- local path = { 106.836830, 0.753614, -3.944333, 106.991020, 0.588184, -4.941793, 107.207207, 0.424275, -5.923915, 107.583046, 0.424275, -6.866960, 108.040382, 0.424275, -7.778655, 108.482483, 0.364732, -8.695824, 108.921669, 0.289885, -9.613388, 109.362129, 0.184958, -10.528788, 109.805786, 0.066048, -11.439518, 111.644989, 0.000000, -15.198928, 112.081032, 0.000000, -16.120642, 112.434616, 0.000000, -17.077393, 112.794510, 0.000000, -18.031784, 113.158630, 0.000000, -18.984592, 113.525223, 0.000000, -19.936440, 114.229553, 0.244860, -21.829271, 114.874275, 0.575834, -23.735594, 115.086800, 0.689463, -24.726152, 115.305222, 0.831800, -25.712254, 115.528206, 0.948544, -26.699181, 115.763580, 0.948544, -27.691650, 116.812645, 0.518518, -32.313782, 117.069260, 0.307952, -33.614750, 117.273041, 0.230719, -34.943283, 117.261650, 0.231090, -35.962982, 117.248177, 0.183139, -36.982887, 117.241623, -0.012887, -37.983841, 117.127762, 0.000000, -38.990234, 116.862022, 0.000000, -39.974133, 116.454262, 0.000000, -40.908192, 115.965675, 0.000000, -41.803535, 115.494179, 0.000000, -42.708023, 115.027023, 0.000000, -43.614761, 114.560127, 0.000000, -44.521637, 113.998978, -0.028513, -45.372234, 113.334190, 0.141798, -46.132935, 112.618889, 0.297568, -46.837734, 111.879662, 0.246952, -47.539852, 111.145302, 0.213181, -48.244881, 110.412346, 0.200519, -48.953037, 109.682579, 0.073200, -49.655846, 108.882729, 0.020027, -50.276154, 107.993965, -0.039275, -50.770645, 107.107376, -0.301162, -51.243320, 105.984108, -0.589100, -51.903667, 105.087524, -0.668489, -52.384327, 104.193001, -0.826998, -52.856438, 103.029999, -1.119595, -53.479015, 101.524078, -1.681683, -54.232483, 100.346069, -1.856236, -54.810303, 98.258423, -2.653062, -55.809986, 94.811630, -4.113267, -57.345276, 93.531342, -4.535689, -57.660553, 92.303452, -5.021625, -58.021339, 91.044044, -5.413645, -58.356346, 89.792992, -5.828867, -58.690666, 88.552742, -6.587278, -58.856159, 87.239265, -6.773692, -59.040783, 85.931122, -7.440585, -59.237297, 84.642632, -7.863066, -59.336357, 83.338280, -8.219630, -59.348583, 82.016800, -8.541007, -59.371071, 80.700005, -8.776169, -59.386993, 79.000061, -8.750005, -59.404205, 75.644821, -9.149647, -59.397270, 74.634064, -9.014733, -59.423302, 71.920708, -8.945028, -59.504490, 70.921768, -8.986447, -59.703518, 69.957237, -8.910275, -60.032097, 69.040680, -8.792699, -60.478394, 68.176872, -8.801409, -61.020370, 67.313622, -8.812502, -61.563572, 66.445267, -8.827121, -62.098515, 65.604500, -8.832716, -62.673820, 64.853836, -8.886011, -63.361320, 64.048332, -9.189323, -64.424530, 63.529961, -9.094744, -65.302437, 63.013744, -9.063213, -66.181328, 62.505089, -9.077284, -67.065010, 62.115822, -9.144894, -68.006805, 61.831207, -9.180872, -68.982086, 61.554005, -9.231291, -69.962242, 61.276596, -9.179898, -70.942604, 60.999046, -9.140337, -71.922745, 60.722118, -9.005057, -72.907417, 58.999298, -8.769359, -78.349106, 58.492390, -8.750000, -79.462196, 58.175842, -8.750000, -80.431839, 57.852287, -8.788690, -81.397903, 56.975307, -8.838920, -83.970108, 55.606792, -9.225280, -88.166565, 54.969444, -9.224050, -90.099770, 53.838299, -9.223946, -93.303070, 53.306873, -8.978403, -94.172638, 52.650906, -8.965917, -94.952515, 51.887714, -8.996368, -95.627831, 51.039528, -9.026613, -96.188911, 50.129826, -9.014540, -96.649712, 49.222870, -8.981197, -97.115295, 48.318565, -8.911366, -97.583122, 47.407032, -8.808225, -98.034767, 46.444683, -8.756307, -98.366364, 45.445477, -8.719460, -98.562843, 44.439350, -8.698065, -98.728958, 43.434891, -8.691673, -98.905418, 42.430725, -8.697237, -99.084343, 41.420193, -8.729889, -99.213470, 40.401783, -8.750000, -99.201477, 39.386082, -8.750000, -99.108139, 38.369362, -8.608469, -99.026604, 37.361057, -8.409928, -98.944649, 36.363045, -8.166966, -98.861526, 35.034431, -7.813974, -98.752487, 32.699688, -6.851008, -98.521561, 31.706427, -6.493926, -98.351158, 30.710039, -6.000926, -98.189049, 29.718033, -5.638355, -98.035667, 27.425087, -4.956075, -97.658463, 26.132277, -4.406496, -97.462463, 24.151098, -3.967233, -97.131180, 23.171007, -3.334724, -96.848778, 21.888128, -2.891352, -96.503868, 20.588747, -2.189068, -96.150612, 19.361200, -1.888149, -95.630508, 18.459362, -1.703711, -95.191124, 17.273445, -1.238759, -94.619148, 16.358973, -1.074295, -94.199028, 14.863462, -0.812591, -93.437744, 13.995891, -0.681874, -92.918854, 13.124660, -0.652185, -92.401703, 11.981263, -0.068438, -91.754562, 8.189893, 0.131953, -89.508270, 7.381987, 0.088618, -88.886955, 6.571380, 0.027514, -88.269890, 5.766691, -0.002299, -87.654968, 4.945962, 0.000000, -87.049316, 3.883574, 0.000000, -86.202354, 3.126469, 0.000000, -85.518845, 2.370068, -0.119624, -84.843323, 1.614515, -0.303587, -84.175644, 0.857115, 0.000000, -83.495300, -0.870769, 0.000000, -81.862190, -1.568556, 0.000000, -81.118217, -2.269822, 0.000000, -80.377510, -3.194349, 0.000000, -79.380562, -3.819240, 0.000000, -78.574409, -4.449546, 0.000000, -77.772438, -5.086962, 0.137702, -76.984360, -7.210657, 0.175519, -74.355286, -8.692932, -0.185115, -72.536095, -16.493408, 0.013434, -63.163830, -26.895781, 0.139084, -51.041916, -33.461296, 0.306640, -43.713573, -36.005562, 0.000000, -41.001808, -38.542736, -0.120660, -38.256161, -39.083927, 0.000000, -37.397449, -39.555202, 0.000000, -36.492863, -40.037514, 0.000000, -35.594105, -40.526558, 0.000000, -34.698994, -41.019489, -0.022164, -33.806004, -41.652416, 0.180338, -32.609749, -42.016624, 0.293460, -31.678379, -42.271152, 0.542783, -30.701290, -42.519249, 0.681291, -29.722433, -42.795589, 0.826644, -28.744770, -43.079948, 0.948544, -27.772430, -45.149635, 0.238260, -20.630129, -46.271828, 0.000000, -16.723400, -47.862793, 0.000000, -11.521264, -48.733509, 0.256991, -8.609860, -48.896648, 0.324526, -7.606351, -49.057713, 0.338616, -6.599248, -49.223305, 0.363505, -5.593130, -49.390556, 0.374511, -4.587783, -49.684200, 0.370477, -2.916082, -49.903740, 0.449262, -0.893895, -49.922726, 0.454472, 0.125913, -49.948883, 0.286609, 1.145556, -50.102844, -0.115937, 2.402715, -50.156853, 0.000000, 3.761640, -50.159981, 0.000000, 5.120244, -50.007885, -0.015259, 6.128576, -49.857365, -0.045265, 7.137108, -49.713821, 0.039034, 8.146688, -49.585705, 0.186338, 9.147921, -49.455704, 0.302599, 10.150855, -49.203857, 0.323244, 11.138046, -48.910267, 0.347195, 12.114579, -48.625202, 0.370449, 13.093660, -48.342144, 0.385329, 14.073327, -48.052616, 0.332701, 15.049960, -47.667847, 0.274040, 16.352327, -44.511124, 0.252378, 26.755022, -43.121750, -0.012623, 30.935074, -42.260540, -0.049747, 33.517990, -43.056217, -0.026659, 32.881931, -43.706509, -0.045365, 32.098381, -44.169453, 0.000000, 31.191624, -44.416973, 0.000000, 30.204136, -44.437744, 0.028373, 29.187935, -44.234550, 0.147605, 28.197554, -44.150120, 0.298818, 26.919199, -44.269028, 0.420611, 25.913910, -44.344677, 0.461140, 24.897463, -44.417439, 0.485243, 23.880436, -44.792072, 0.547829, 18.456495, -44.909702, 0.520047, 16.761114, -44.984016, 0.546042, 15.743969, -45.293648, 0.529866, 11.335310, -45.466782, -0.292093, 7.003008, -45.295456, -0.350010, 6.017503, -45.133808, -0.306995, 5.010587, -44.979404, -0.288531, 4.002648, -44.838799, -0.137383, 2.999915, -44.591873, 0.000000, 1.326093, -43.541481, -0.290097, -5.380277, -42.848728, -0.040544, -9.723336, -42.292336, 0.642154, -13.730497, -41.547997, 0.916541, -19.108713, -39.144688, -0.110269, -34.782520, -38.852798, -0.151156, -35.757435, -38.562496, -0.267764, -36.734951, -38.282818, -0.267764, -37.714661, -37.983608, -0.143293, -38.683777, -37.691250, 0.000000, -39.649914, -36.961990, 0.000000, -41.913502, -36.474354, 0.028213, -42.808399, -35.971992, 0.226432, -43.673664, -35.457680, 0.299082, -44.547100, -34.948200, 0.307759, -45.430702, -34.437958, 0.280654, -46.312672, -33.832745, 0.208592, -47.129368, -33.109161, 0.152678, -47.845551, -32.362976, 0.178447, -48.540161, -31.625460, 0.193057, -49.244442, -30.888935, 0.191501, -49.950066, -30.152180, 0.191501, -50.655468, -28.682632, 0.327592, -52.052853, -22.999739, -0.021864, -57.395721, -14.951417, 0.053770, -64.715271, -9.587814, -0.283296, -69.405060, 0.201969, 0.000000, -77.739349, 8.018144, 0.474488, -84.227051, 8.810593, 0.500000, -84.869247, 13.446918, -0.556004, -88.735023, 18.700258, -1.617588, -93.300865, 20.009169, -1.854144, -94.364220, 20.871933, -2.079291, -94.879112, 22.090717, -2.734235, -95.349945, 23.265066, -3.198344, -95.600243, 24.519112, -3.769525, -95.944420, 25.734962, -4.197329, -96.323906, 29.720675, -5.662676, -97.632629, 35.058762, -7.760355, -99.350182, 36.351494, -8.138969, -99.480362, 37.667927, -8.463923, -99.614883, 38.980259, -8.754398, -99.752815, 39.995571, -8.750000, -99.850632, 41.014687, -8.750000, -99.843651, 42.021122, -8.699507, -99.690598, 43.023811, -8.693951, -99.503616, 44.028286, -8.689321, -99.326424, 45.033279, -8.710691, -99.153366, 46.038563, -8.734357, -98.981979, 47.019447, -8.787255, -98.710304, 47.952656, -8.849693, -98.303986, 48.873344, -8.868368, -97.866592, 49.800724, -8.926785, -97.446609, 50.729198, -8.935081, -97.024788, 51.655121, -8.995463, -96.601227, 52.530022, -9.002600, -96.084099, 53.332405, -8.989055, -95.456009, 54.045231, -9.004202, -94.727470, 54.733864, -8.960525, -93.976273, 55.427677, -8.901531, -93.232239, 56.115280, -8.872164, -92.479927, 56.703072, -8.870046, -91.647278, 57.171017, -8.860332, -90.741814, 57.512268, -8.862024, -89.781326, 57.717064, -8.850554, -88.782913, 57.890076, -8.844110, -87.777725, 58.075729, -8.838920, -86.774788, 58.212158, -8.838920, -85.764946, 58.190685, -8.838920, -84.746010, 58.132496, -8.838920, -83.727676, 58.085430, -8.838920, -82.708755, 58.041931, -8.813974, -81.679680, 57.999989, -8.750000, -80.664566, 58.055069, -8.750000, -79.308144, 58.276073, -8.768729, -78.313454, 58.640610, -8.784549, -77.361809, 59.035458, -8.795819, -76.421379, 59.419872, -8.905950, -75.481468, 59.803303, -9.013034, -74.545952, 60.183582, -8.999618, -73.599487, 60.564983, -9.003467, -72.653481, 61.039726, -9.136139, -71.761078, 61.552238, -9.214413, -70.882713, 62.009228, -9.447116, -69.991959, 62.537430, -9.467735, -69.120331, 63.044746, -9.363365, -68.235588, 63.564800, -9.289007, -67.360374, 64.135468, -9.226895, -66.518372, 64.748192, -9.076785, -65.716934, 65.346390, -9.028047, -64.891052, 65.945122, -8.860834, -64.065323, 66.588593, -8.817420, -63.275833, 67.349281, -8.807837, -62.598480, 68.201759, -8.825143, -62.040005, 69.123352, -8.814865, -61.604710, 70.094444, -8.811885, -61.294819, 71.097076, -8.893328, -61.111229, 72.411018, -9.004781, -60.921368, 73.416824, -9.037530, -60.751774, 74.414474, -9.141319, -60.565445, 75.411049, -9.250545, -60.377529, 76.421310, -9.308679, -59.907219, 77.726753, -8.834991, -59.683815, 78.722717, -8.752763, -59.499489, 79.723335, -8.750000, -59.305267, 80.724586, -8.750000, -59.110531, 88.836075, -6.541266, -57.393227, 92.434395, -5.028264, -56.656715, 97.030624, -3.152335, -55.771854, 101.635529, -1.743830, -54.859383, 102.837372, -1.193740, -54.311890, 103.735199, -1.036099, -53.857418, 104.636528, -0.850292, -53.415447, 105.552078, -0.709825, -52.989338, 107.340843, -0.442860, -52.125702, 108.163712, -0.043214, -51.529591, 108.909218, -0.021570, -50.838665, 109.567856, 0.069812, -50.065910, 110.118469, 0.173837, -49.215237, 110.574730, 0.253699, -48.307762, 111.032120, 0.303196, -47.397114, 111.502792, 0.414660, -46.499710, 111.953445, 0.485286, -45.515354, 112.334724, 0.390197, -44.109322, 112.585159, 0.327591, -43.019482, 112.847252, 0.262069, -41.922249, 113.124084, 0.192864, -40.787575, 113.286522, 0.152224, -39.620495, 113.299835, 0.148355, -38.440830, 113.325317, 0.228800, -37.375103, 113.384865, 0.355033, -36.367905, 113.412315, 0.350082, -35.351025, 113.442711, 0.387855, -34.332180, 113.472527, 0.555494, -32.634743, 113.514076, 0.948544, -29.250244, 113.557159, 0.900203, -27.552439, 113.667038, -0.037840, -20.129488, 113.447464, 0.000000, -19.133646, 113.228622, 0.000000, -18.137411, 113.017487, 0.000000, -17.139507, 112.808426, 0.000000, -16.141161, 112.599602, 0.000000, -15.142765, 110.949753, 0.337926, -7.520249, 110.637054, 0.365284, -6.549754, 110.331459, 0.402835, -5.577313, 110.028595, 0.448456, -4.604719, 109.324074, 0.563950, -2.333729, 109.049179, 0.694935, -1.362919, 108.008881, 0.504658, 1.822723, 107.542999, 0.261044, 3.065771 }; ----------------------------------- -- onMobSpawn ----------------------------------- function onMobSpawn(mob) onMobRoam(mob); end; ----------------------------------- -- onPath ----------------------------------- function onPath(mob) pathfind.patrol(mob, path); end; ----------------------------------- -- onMobRoam ----------------------------------- function onMobRoam(mob) -- move to start position if not moving if (mob:isFollowingPath() == false) then mob:pathThrough(pathfind.first(path)); end end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob,killer,ally) -- Set Guivre's spawnpoint and respawn time (18-24 hours) UpdateNMSpawnPoint(mob:getID()); mob:setRespawnTime(math.random(64800,86400)); end;
gpl-3.0
UnfortunateFruit/darkstar
scripts/zones/Tavnazian_Safehold/npcs/Mazuro-Oozuro.lua
37
1265
----------------------------------- -- Area: Tavnazian Safehold -- NPC: Mazuro-Oozuro -- Standard Merchant NPC ----------------------------------- require("scripts/globals/shop"); package.loaded["scripts/zones/Tavnazian_Safehold/TextIDs"] = nil; require("scripts/zones/Tavnazian_Safehold/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc,MAZUROOOZURO_SHOP_DIALOG); stock = {0x426d,108, -- Lufaise Fly 0x43e7,2640, -- Clothespole 0x02b0,200, -- Arrowwood Log 0x02b2,7800, -- Elm Log 0x0b37,10000} -- Safehold Waystone 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
UnfortunateFruit/darkstar
scripts/zones/Dynamis-Tavnazia/bcnms/dynamis_Tavnazia.lua
10
1138
----------------------------------- -- Area: dynamis_Tavnazia -- Name: dynamis_Tavnazia ----------------------------------- -- After registering the BCNM via bcnmRegister(bcnmid) function onBcnmRegister(player,instance) SetServerVariable("[DynaTavnazia]UniqueID",player:getDynamisUniqueID(1289)); SetServerVariable("[DynaTavnazia]Boss_Trigger",0); SetServerVariable("[DynaTavnazia]Already_Received",0); end; -- Physically entering the BCNM via bcnmEnter(bcnmid) function onBcnmEnter(player,instance) player:setVar("DynamisID",GetServerVariable("[DynaTavnazia]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 SetServerVariable("[DynaTavnazia]UniqueID",0); end end;
gpl-3.0
UnfortunateFruit/darkstar
scripts/zones/West_Sarutabaruta/npcs/Slow_Axe_IM.lua
30
3064
----------------------------------- -- Area: West Sarutabaruta -- NPC: Slow Axe, I.M. -- Type: Border Conquest Guards -- @pos 399.450 -25.858 727.545 115 ----------------------------------- package.loaded["scripts/zones/West_Sarutabaruta/TextIDs"] = nil; ----------------------------------- require("scripts/globals/conquest"); require("scripts/zones/West_Sarutabaruta/TextIDs"); local guardnation = BASTOK; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno local guardtype = 4; -- 1: city, 2: foreign, 3: outpost, 4: border local region = SARUTABARUTA; local csid = 0x7ff8; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) tradeConquestGuard(player,npc,trade,guardnation,guardtype); end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:hasKeyItem(getSupplyKey(region)) and player:getNation() == guardnation) then if (supplyRunFresh(player) == 1) then player:startEvent(csid,16,0,0,0,1,0,0,255); -- you have brought us supplies ! else player:showText(npc, CONQUEST - 1); -- "Hmm... These supplies you have brought us are too old to be of any use." player:delKeyItem(getSupplyKey(region)); player:messageSpecial(KEYITEM_OBTAINED + 1, getSupplyKey(region)); player:setVar("supplyQuest_region",0); end else local arg1 = getArg1(guardnation, player) - 1; if (arg1 >= 1792) then -- foreign, non-allied player:startEvent(csid,1808,0,0,0,0,player:getRank(),0,0); else -- citizen or allied player:startEvent(csid,arg1,0,0x3F0000,0,0,getArg6(player),0,0); end end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("OPTION: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("OPTION: %u",option); if (option == 1) then local duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600; player:delStatusEffect(EFFECT_SIGIL); player:delStatusEffect(EFFECT_SANCTION); player:delStatusEffect(EFFECT_SIGNET); player:addStatusEffect(EFFECT_SIGNET,0,0,duration); -- Grant Signet elseif (option == 2) then player:delKeyItem(getSupplyKey(region)); player:addCP(supplyReward[region + 1]) player:messageSpecial(CONQUEST); -- "You've earned conquest points!" if (hasOutpost(player, region+5) == 0) then local supply_quests = 2^(region+5); player:addNationTeleport(guardnation,supply_quests); player:setVar("supplyQuest_region",0); end elseif (option == 4) then if (player:delGil(giltosetHP(guardnation,player))) then player:setHomePoint(); player:messageSpecial(CONQUEST + 94); -- "Your home point has been set." else player:messageSpecial(CONQUEST + 95); -- "You do not have enough gil to set your home point here." end end end;
gpl-3.0
facebook/iTorch
util.lua
4
3257
--[[ * Copyright (c) 2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * ]]-- local zmq = require 'lzmq' local zassert = zmq.assert local json = require 'cjson' local uuid = require 'uuid' local crypto = require 'crypto' local util = {} -------------------------------------------------------------- -- Signature Key and its setter local session_key = '' local function setSessionKey(key) session_key = key end -------------------------------------------------------------- -- Common decoder function for all messages (except heartbeats which are just looped back) local function ipyDecode(sock, m) m = m or zassert(sock:recv_all()) -- print('incoming:') -- print(m) local o = {} o.uuid = {} local i = -1 for k,v in ipairs(m) do if v == '<IDS|MSG>' then i = k+1; break; end o.uuid[k] = v end assert(i ~= -1, 'Failed parsing till <IDS|MSG>') -- json decode for j=i+1,i+4 do if m[j] == '{}' then m[j] = nil; else m[j] = json.decode(m[j]); end; end -- populate headers o.header = m[i+1] o.parent_header = m[i+2] o.metadata = m[i+3] o.content = m[i+4] for j=i+5,#m do o.blob = (o.blob or '') .. m[j] end -- process blobs return o end -- Common encoder function for all messages (except heartbeats which are just looped back) -- See http://ipython.org/ipython-doc/stable/development/messaging.html local function ipyEncodeAndSend(sock, m) -- Message digest (for HMAC signature) local d = crypto.hmac.new('sha256', session_key) d:update(json.encode(m.header)) if m.parent_header then d:update(json.encode(m.parent_header)) else d:update('{}') end if m.metadata then d:update(json.encode(m.metadata)) else d:update('{}') end if m.content then d:update(json.encode(m.content)) else d:update('{}') end local o = {} for k,v in ipairs(m.uuid) do o[#o+1] = v end o[#o+1] = '<IDS|MSG>' o[#o+1] = d:final() o[#o+1] = json.encode(m.header) if m.parent_header then o[#o+1] = json.encode(m.parent_header) else o[#o+1] = '{}' end if m.metadata then o[#o+1] = json.encode(m.metadata) else o[#o+1] = '{}' end if m.content then o[#o+1] = json.encode(m.content) else o[#o+1] = '{}' end if m.blob then o[#o+1] = m.blob end -- print('outgoing:') -- print(o) zassert(sock:send_all(o)) end local session_id = uuid.new() -- function for creating a new message object local function msg(msg_type, parent) local m = {} m.header = {} if parent then m.uuid = parent.uuid m.parent_header = parent.header else m.parent_header = {} end m.header.msg_id = uuid.new() m.header.msg_type = msg_type m.header.session = session_id m.header.date = os.date("%Y-%m-%dT%H:%M:%S") m.header.username = 'itorch' m.content = {} return m end --------------------------------------------------------------------------- util.ipyDecode = ipyDecode util.ipyEncodeAndSend = ipyEncodeAndSend util.msg = msg util.setSessionKey = setSessionKey return util
bsd-3-clause
nesstea/darkstar
scripts/zones/Al_Zahbi/npcs/Dabigo.lua
13
1045
----------------------------------- -- Area: Al Zahbi -- NPC: Dabigo -- Type: Delivery Box Manager -- @zone: 48 -- @pos -34.289 -1 -129.141 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Al_Zahbi/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x00d2); 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/Mhaura/npcs/Kotan-Purutan.lua
13
2521
----------------------------------- -- Area: Mhaura -- NPC: Kotan-Purutan -- Involved in Quest: Overnight Delivery -- @pos 40.323 -8.999 44.242 249 ----------------------------------- package.loaded["scripts/zones/Mhaura/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local OvernightDelivery = player:getQuestStatus(WINDURST,OVERNIGHT_DELIVERY); local KenapaOvernight = player:getVar("Kenapa_Overnight_var"); -- Variable to track progress for Overnight Delivery local KenapaOvernightDay = player:getVar("Kenapa_Overnight_Day_var"); -- Variable to track the day the quest is started. local KenapaOvernightHour = player:getVar("Kenapa_Overnight_Hour_var"); -- Variable to track the hour the quest is started. local HourOfTheDay = VanadielHour(); if (OvernightDelivery == QUEST_ACCEPTED and player:hasKeyItem(SMALL_BAG) == false and (KenapaOvernight >= 4 and KenapaOvernight <= 7) and (HourOfTheDay < 6 or HourOfTheDay >= 18)) then player:startEvent(0x008d); -- Gives Key Item at correct times of night elseif (OvernightDelivery == QUEST_ACCEPTED and player:hasKeyItem(SMALL_BAG) == false and (KenapaOvernight >= 4 and KenapaOvernight <= 7) and (HourOfTheDay >= 6 or HourOfTheDay < 18)) then player:startEvent(0x0090); -- Only at night elseif (player:hasKeyItem(SMALL_BAG) == true) then player:startEvent(0x008e); -- Reminder Dialogue elseif (OvernightDelivery == QUEST_COMPLETED) then player:startEvent(0x008f); -- Post quest else player:startEvent(0x008c); -- Standard 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 == 0x008d) then player:addKeyItem(SMALL_BAG); player:setVar("Kenapa_Overnight_Day_var",VanadielDayOfTheYear()); player:setVar("Kenapa_Overnight_Hour_var",VanadielHour()); player:messageSpecial(KEYITEM_OBTAINED,SMALL_BAG); end end;
gpl-3.0
nesstea/darkstar
scripts/zones/Tavnazian_Safehold/npcs/Ratonne.lua
14
4335
----------------------------------- -- Area: Tavnazian Safehold -- NPC: Ratonne -- Armor Storage NPC ----------------------------------- package.loaded["scripts/zones/Tavnazian_Safehold/TextIDs"] = nil; ----------------------------------- require("scripts/globals/quests"); require("scripts/globals/armorstorage"); require("scripts/zones/Tavnazian_Safehold/TextIDs"); Deposit = 0x01fe; Withdrawl = 0x01ff; ArraySize = table.getn(StorageArray); G1 = 0; G2 = 0; G3 = 0; G4 = 0; G5 = 0; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) for SetId = 1,ArraySize,11 do TradeCount = trade:getItemCount(); T1 = trade:hasItemQty(StorageArray[SetId + 5],1); if (T1 == true) then if (player:hasKeyItem(StorageArray[SetId + 10]) == false) then if (TradeCount == StorageArray[SetId + 3]) then T2 = trade:hasItemQty(StorageArray[SetId + 4],1); T3 = trade:hasItemQty(StorageArray[SetId + 6],1); T4 = trade:hasItemQty(StorageArray[SetId + 7],1); T5 = trade:hasItemQty(StorageArray[SetId + 8],1); if (StorageArray[SetId + 4] == 0) then T2 = true; end; if (StorageArray[SetId + 6] == 0) then T3 = true; end; if (StorageArray[SetId + 7] == 0) then T4 = true; end; if (StorageArray[SetId + 8] == 0) then T5 = true; end; if (T2 == true and T3 == true and T4 == true and T5 == true) then player:startEvent(Deposit,0,0,0,0,0,StorageArray[SetId + 9]); player:addKeyItem(StorageArray[SetId + 10]); player:messageSpecial(KEYITEM_OBTAINED,StorageArray[SetId + 10]); break; end; end; end; end; end; end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) CurrGil = player:getGil(); for KeyItem = 11,ArraySize,11 do if player:hasKeyItem(StorageArray[KeyItem]) then if StorageArray[KeyItem - 9] == 1 then G1 = G1 + StorageArray[KeyItem - 8]; elseif StorageArray[KeyItem - 9] == 2 then G2 = G2 + StorageArray[KeyItem - 8]; elseif StorageArray[KeyItem - 9] == 3 then G3 = G3 + StorageArray[KeyItem - 8]; elseif StorageArray[KeyItem - 9] == 4 then G4 = G4 + StorageArray[KeyItem - 8]; elseif StorageArray[KeyItem - 9] == 6 then G5 = G5 + StorageArray[KeyItem - 8]; end; end; end; player:startEvent(Withdrawl,G1,G2,G3,G4,CurrGil,G5); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) if (csid == Withdrawl) then player:updateEvent(StorageArray[option * 11 - 6], StorageArray[option * 11 - 5], StorageArray[option * 11 - 4], StorageArray[option * 11 - 3], StorageArray[option * 11 - 2], StorageArray[option * 11 - 1]); end; end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) if (csid == Withdrawl) then if (option > 0 and option <= StorageArray[ArraySize] - 10) then if (player:getFreeSlotsCount() >= StorageArray[option * 11 - 7]) then for Item = 2,6,1 do if (StorageArray[option * 11 - Item] > 0) then player:addItem(StorageArray[option * 11 - Item],1); player:messageSpecial(ITEM_OBTAINED,StorageArray[option * 11 - Item]); end; end; player:delKeyItem(StorageArray[option * 11]); player:setGil(player:getGil() - StorageArray[option * 11 - 1]); else for Item = 2,6,1 do if (StorageArray[option * 11 - Item] > 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,StorageArray[option * 11 - Item]); end; end; end; end; end; if (csid == Deposit) then player:tradeComplete(); end; end;
gpl-3.0
nesstea/darkstar
scripts/zones/Ifrits_Cauldron/npcs/Flame_Spout.lua
13
1587
---------------------------------- -- Area: Ifrit's Cauldron -- NPC: Flame Spout -- @pos 193.967 -0.400 19.492 205 ----------------------------------- require("scripts/zones/Ifrits_Cauldron/TextIDs"); require("scripts/globals/settings"); require("scripts/globals/quests"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) local npcid = npc:getID(); if (trade:getItemCount() == 1 and trade:hasItemQty(4105,1) == true) then -- Ice Cluster Trade GetNPCByID(npcid+5):openDoor(90); player:tradeComplete(); end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) -- printf("%u",npc:getID()) local npcid = npc:getID(); -- Commented out to preserve CSIDs for the quest, since the workaround was removed. --[[if (npcid == 17617204) then player:startEvent(0x000b); elseif (npcid == 17617205) then player:startEvent(0x000c); elseif (npcid == 17617206) then player:startEvent(0x000d); elseif (npcid == 17617207) then player:startEvent(0x000e); 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/apkallu_egg.lua
18
1174
----------------------------------------- -- ID: 5568 -- Item: Apkallu Egg -- Food Effect: 5Min, All Races ----------------------------------------- -- Health 6 -- Magic 6 ----------------------------------------- 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,300,5568); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_HP, 6); target:addMod(MOD_MP, 6); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_HP, 6); target:delMod(MOD_MP, 6); end;
gpl-3.0
nesstea/darkstar
scripts/zones/Inner_Horutoto_Ruins/TextIDs.lua
22
1317
-- Variable TextID Description text -- General Texts ITEM_CANNOT_BE_OBTAINED = 6548; -- You cannot obtain the item <item>. Come back after sorting your inventory. ITEM_OBTAINED = 6553; -- Obtained: <item>. GIL_OBTAINED = 6554; -- Obtained <number> gil. KEYITEM_OBTAINED = 6556; -- Obtained key item: <keyitem>. NOT_BROKEN_ORB = 7230; -- The Mana Orb in this receptacle is not broken. EXAMINED_RECEPTACLE = 7231; -- You have already examined this receptacle. DOOR_FIRMLY_CLOSED = 7258; -- The door is firmly closed. -- Treasure Coffer/Chest Dialog CHEST_UNLOCKED = 7333; -- You unlock the chest! CHEST_FAIL = 7334; -- Fails to open the chest. CHEST_TRAP = 7335; -- The chest was trapped! CHEST_WEAK = 7336; -- You cannot open the chest when you are in a weakened state. CHEST_MIMIC = 7337; -- The chest was a mimic! CHEST_MOOGLE = 7338; -- You cannot open the chest while participating in the moogle event. CHEST_ILLUSION = 7339; -- The chest was but an illusion... CHEST_LOCKED = 7340; -- The chest appears to be locked. -- Other texts PORTAL_SEALED_BY_3_MAGIC = 8; -- The Sealed Portal is sealed by three kinds of magic. PORTAL_NOT_OPEN_THAT_SIDE = 9; -- The Sealed Portal cannot be opened from this side. -- conquest Base CONQUEST_BASE = 10;
gpl-3.0
JulioC/telegram-bot
plugins/isX.lua
605
2031
local https = require "ssl.https" local ltn12 = require "ltn12" local function request(imageUrl) -- Edit data/mashape.lua with your Mashape API key -- http://docs.mashape.com/api-keys local mashape = load_from_file('data/mashape.lua', { api_key = '' }) local api_key = mashape.api_key if api_key:isempty() then return nil, 'Configure your Mashape API Key' end local api = "https://sphirelabs-advanced-porn-nudity-and-adult-content-detection.p.mashape.com/v1/get/index.php?" local parameters = "&url="..(URL.escape(imageUrl) or "") local url = api..parameters local respbody = {} local headers = { ["X-Mashape-Key"] = api_key, ["Accept"] = "Accept: application/json" } print(url) local body, code, headers, status = https.request{ url = url, method = "GET", headers = headers, sink = ltn12.sink.table(respbody), protocol = "tlsv1" } if code ~= 200 then return "", code end local body = table.concat(respbody) return body, code end local function parseData(data) local jsonBody = json:decode(data) local response = "" print(data) if jsonBody["Error Occured"] ~= nil then response = response .. jsonBody["Error Occured"] elseif jsonBody["Is Porn"] == nil or jsonBody["Reason"] == nil then response = response .. "I don't know if that has adult content or not." else if jsonBody["Is Porn"] == "True" then response = response .. "Beware!\n" end response = response .. jsonBody["Reason"] end return jsonBody["Is Porn"], response end local function run(msg, matches) local data, code = request(matches[1]) if code ~= 200 then return "There was an error. "..code end local isPorn, result = parseData(data) return result end return { description = "Does this photo contain adult content?", usage = { "!isx [url]", "!isporn [url]" }, patterns = { "^!is[x|X] (.*)$", "^!is[p|P]orn (.*)$" }, run = run }
gpl-2.0
UnfortunateFruit/darkstar
scripts/zones/FeiYin/npcs/_no4.lua
6
2211
----------------------------------- -- Area: Fei'Yin -- NPC: Cermet Door (triggers Rukususu dialog) -- Type: Quest NPC -- @pos -183 0 190 204 -- Involved in Quests: Curses, Foiled A-Golem!?,SMN AF2: Class Reunion, SMN AF3: Carbuncle Debacle -- Involved in Missions: Windurst 5-1/7-2/8-2 ----------------------------------- package.loaded["scripts/zones/FeiYin/TextIDs"] = nil; ----------------------------------- require("scripts/globals/quests"); require("scripts/globals/settings"); require("scripts/zones/FeiYin/TextIDs"); require("scripts/globals/keyitems"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) -- Windurst 8-2 if(player:getCurrentMission(WINDURST) == THE_JESTER_WHO_D_BE_KING and player:getVar("MissionStatus") == 1) then player:startEvent(0x0016); -- Curses, Foiled A_Golem!? if(player:hasKeyItem(SHANTOTTOS_NEW_SPELL)) then player:startEvent(0x000E); -- deliver spell elseif(player:hasKeyItem(SHANTOTTOS_EXSPELL)) then player:startEvent(0x000D); -- spell erased, try again! -- standard dialog else player:startEvent(0x000f); end end return 1; end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); -- Curses, Foiled A_Golem!? if(csid == 0x000E) then player:setVar("foiledagolemdeliverycomplete",1); player:delKeyItem(SHANTOTTOS_NEW_SPELL); -- remove key item elseif(csid == 0x0016) then player:addKeyItem(RHINOSTERY_RING); player:messageSpecial(KEYITEM_OBTAINED,RHINOSTERY_RING); if(player:hasKeyItem(AURASTERY_RING) and player:hasKeyItem(OPTISTERY_RING)) then player:setVar("MissionStatus",2) end end end;
gpl-3.0
wolfy1339/Wolfy-Powder-Toy
src/lua/luascripts/eventcompat.lua
3
5493
if not event then return end local deprecated_scripts = {} local timer = nil local function print_deprecation_warnings() if not timer or timer <= 0 then event.unregister(event.tick, print_deprecation_warnings) else timer = timer - 1 return end local deprecated = {} for k,v in pairs(deprecated_scripts) do table.insert(deprecated, k) end local start_message = #deprecated == 1 and "This script is" or "These scripts are" print(start_message.." using a legacy event api and should be updated: ") print("\""..table.concat(deprecated, "\", \"").."\"") end local function deprecationwarning() -- no warning for now --[[local calling_file_info = debug.getinfo(3, "S") if calling_file_info then calling_file_info = calling_file_info["short_src"] if calling_file_info then deprecated_scripts[calling_file_info] = true if not timer then timer = 5 event.register(event.tick, print_deprecation_warnings) end end end]] end function tpt.register_step(f) deprecationwarning() event.register(event.tick, f) end function tpt.unregister_step(f) deprecationwarning() event.unregister(event.tick, f) end local registered_mouseclicks = {} function tpt.register_mouseclick(f) deprecationwarning() if registered_mouseclicks[f] then return end local mousex = -1 local mousey = -1 local mousedown = -1 local function mousedownfunc(x, y, button) --replicate hack in original function if button == 3 then button = 4 end mousex = x mousey = y mousedown = button return f(x, y, button, 1, 0) end local function mouseupfunc(x, y, button, evt) --ignore automatic mouseup event sent when switching windows if mousedown == -1 and evt == 1 then return end --replicate hack in original function if button == 3 then button = 4 end local evtType = 2 if evt == 1 then evtType = 4 elseif evt == 2 then evtType = 5 end --zoom window cancel --Original function would have started returning 0 for mousetick events --(until the actual mousedown), but we don't replicate that here if evt ~= 2 then mousedown = -1 end return f(x, y, button, evtType, 0) end local function mousemovefunc(x, y, dx, dy) mousex = x mousey = y end local function mousewheelfunc(x, y, d) return f(x, y, 0, 0, d) end local function tickfunc() if mousedown ~= -1 then return f(mousex, mousey, mousedown, 3, 0) end end event.register(event.mousedown, mousedownfunc) event.register(event.mouseup, mouseupfunc) event.register(event.mousemove, mousemovefunc) event.register(event.mousewheel, mousewheelfunc) event.register(event.tick, tickfunc) local funcs = {mousedownfunc, mouseupfunc, mousemovefunc, mousewheelfunc, tickfunc} registered_mouseclicks[f] = funcs end tpt.register_mouseevent = tpt.register_mouseclick function tpt.unregister_mouseclick(f) if not registered_mouseclicks[f] then return end local funcs = registered_mouseclicks[f] event.unregister(event.mousedown, funcs[1]) event.unregister(event.mouseup, funcs[2]) event.unregister(event.mousemove, funcs[3]) event.unregister(event.mousewheel, funcs[4]) event.unregister(event.tick, funcs[5]) registered_mouseclicks[f] = nil end tpt.unregister_mouseevent = tpt.unregister_mouseclick local registered_keypresses = {} function tpt.register_keypress(f) deprecationwarning() if registered_keypresses[f] then return end local keyMapping = {} -- lctrl, rctlr, lshift, rshift, lalt, ralt keyMapping[225] = 304 keyMapping[229] = 303 keyMapping[224] = 306 keyMapping[228] = 305 keyMapping[226] = 308 keyMapping[230] = 307 --up, down, right, left keyMapping[82] = 273 keyMapping[81] = 274 keyMapping[79] = 275 keyMapping[80] = 276 -- shift mapping for US keyboard layout local shiftMapping = { ["`"] = "~", ["1"] = "!", ["2"] = "@", ["3"] = "#", ["4"] = "$", ["5"] = "%", ["6"] = "^", ["7"] = "&", ["8"] = "*", ["9"] = "(", ["0"] = ")", ["-"] = "_", ["="] = "+", ["["] = "{", ["]"] = "}", ["\\"] = "|", [";"] = ":", ["'"] = "\"", [","] = "<", ["."] = ">", ["/"] = "?" } local function keypress(key, scan, rep, shift, ctrl, alt) if rep then return end local mod = event.getmodifiers() -- attempt to convert to string representation err, keyStr = pcall(string.char, key) if not err then keyStr = "" end if keyStr ~= "" and shift then keyStr = shiftMapping[keyStr] and shiftMapping[keyStr] or string.upper(keyStr) end -- key mapping for common keys, extremely incomplete if keyMapping[scan] then key = keyMapping[scan] end return f(keyStr, key, mod, 1) end local function keyrelease(key, scan, rep, shift, ctrl, alt) local mod = event.getmodifiers() -- attempt to convert to string representation err, keyStr = pcall(string.char, key) if not err then keyStr = "" end -- key mapping for common keys, extremely incomplete if keyMapping[scan] then key = keyMapping[scan] end return f(keyStr, key, mod, 2) end event.register(event.keypress, keypress) event.register(event.keyrelease, keyrelease) local funcs = { keypress, keyrelease } registered_keypresses[f] = funcs end tpt.register_keyevent = tpt.register_keypress function tpt.unregister_keypress(f) if not registered_keypresses[f] then return end local funcs = registered_keypresses[f] event.unregister(event.keypress, funcs[1]) event.unregister(event.keyrelease, funcs[2]) registered_keypresses[f] = nil end tpt.unregister_keyevent = tpt.unregister_keypress
gpl-3.0
vonflynee/opencomputersserver
world/opencomputers/689b9f29-1d36-4106-bf0e-c06a2ebfb1ef/lib/rc.lua
15
3243
local fs = require('filesystem') local serialization = require('serialization') -- Keeps track of loaded scripts to retain local values between invocation -- of their command callbacks. local loaded = {} local rc = {} local function loadConfig() local env = {} local result, reason = loadfile('/etc/rc.cfg', 't', env) if result then result, reason = xpcall(result, debug.traceback) if result then return env end end return nil, reason end local function saveConfig(conf) local file, reason = io.open('/etc/rc.cfg', 'w') if not file then return nil, reason end for key, value in pairs(conf) do file:write(tostring(key) .. " = " .. serialization.serialize(value) .. "\n") end file:close() return true end function rc.load(name, args) if loaded[name] then return loaded[name] end local fileName = fs.concat('/etc/rc.d/', name .. '.lua') local env = setmetatable({args = args}, {__index = _G}) local result, reason = loadfile(fileName, 't', env) if result then result, reason = xpcall(result, debug.traceback) if result then loaded[name] = env return env end end return nil, reason end function rc.unload(name) loaded[name] = nil end local function rawRunCommand(conf, name, cmd, args, ...) local result, what = rc.load(name, args) if result then if not cmd then io.output():write("Commands for service " .. name .. "\n") for command, val in pairs(result) do if type(val) == "function" then io.output():write(tostring(command) .. " ") end end return true elseif type(result[cmd]) == "function" then res, what = xpcall(result[cmd], debug.traceback, ...) if res then return true end elseif cmd == "restart" and type(result["stop"]) == "function" and type(result["start"]) == "function" then res, what = xpcall(result["stop"], debug.traceback, ...) if res then res, what = xpcall(result["start"], debug.traceback, ...) if res then return true end end elseif cmd == "enable" then conf.enabled = conf.enabled or {} for _, _name in ipairs(conf.enabled) do if name == _name then return nil, "Service already enabled" end end conf.enabled[#conf.enabled + 1] = name return saveConfig(conf) elseif cmd == "disable" then conf.enabled = conf.enabled or {} for n, _name in ipairs(conf.enabled) do if name == _name then table.remove(conf.enabled, n) end end return saveConfig(conf) else what = "Command '" .. cmd .. "' not found in daemon '" .. name .. "'" end end return nil, what end function rc.runCommand(name, cmd, ...) local conf, reason = loadConfig() if not conf then return nil, reason end return rawRunCommand(conf, name, cmd, conf[name], ...) end function rc.allRunCommand(cmd, ...) local conf, reason = loadConfig() if not conf then return nil, reason end local results = {} for _, name in ipairs(conf.enabled or {}) do results[name] = table.pack(rawRunCommand(conf, name, cmd, conf[name], ...)) end return results end return rc
mit
UnfortunateFruit/darkstar
scripts/zones/North_Gustaberg/npcs/Butsutsu_WW.lua
30
3058
----------------------------------- -- Area: North Gustaberg -- NPC: Butsutsu, W.W. -- Type: Border Conquest Guards -- @pos -520.704 38.75 560.258 106 ----------------------------------- package.loaded["scripts/zones/North_Gustaberg/TextIDs"] = nil; ----------------------------------- require("scripts/globals/conquest"); require("scripts/zones/North_Gustaberg/TextIDs"); local guardnation = WINDURST; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno local guardtype = 4; -- 1: city, 2: foreign, 3: outpost, 4: border local region = GUSTABERG; local csid = 0x7ff6; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) tradeConquestGuard(player,npc,trade,guardnation,guardtype); end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:hasKeyItem(getSupplyKey(region)) and player:getNation() == guardnation) then if (supplyRunFresh(player) == 1) then player:startEvent(csid,16,0,0,0,1,0,0,255); -- you have brought us supplies ! else player:showText(npc, CONQUEST - 1); -- "Hmm... These supplies you have brought us are too old to be of any use." player:delKeyItem(getSupplyKey(region)); player:messageSpecial(KEYITEM_OBTAINED + 1, getSupplyKey(region)); player:setVar("supplyQuest_region",0); end else local arg1 = getArg1(guardnation, player) - 1; if (arg1 >= 1792) then -- foreign, non-allied player:startEvent(csid,1808,0,0,0,0,player:getRank(),0,0); else -- citizen or allied player:startEvent(csid,arg1,0,0x3F0000,0,0,getArg6(player),0,0); end end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("OPTION: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("OPTION: %u",option); if (option == 1) then local duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600; player:delStatusEffect(EFFECT_SIGIL); player:delStatusEffect(EFFECT_SANCTION); player:delStatusEffect(EFFECT_SIGNET); player:addStatusEffect(EFFECT_SIGNET,0,0,duration); -- Grant Signet elseif (option == 2) then player:delKeyItem(getSupplyKey(region)); player:addCP(supplyReward[region + 1]) player:messageSpecial(CONQUEST); -- "You've earned conquest points!" if (hasOutpost(player, region+5) == 0) then local supply_quests = 2^(region+5); player:addNationTeleport(guardnation,supply_quests); player:setVar("supplyQuest_region",0); end elseif (option == 4) then if (player:delGil(giltosetHP(guardnation,player))) then player:setHomePoint(); player:messageSpecial(CONQUEST + 94); -- "Your home point has been set." else player:messageSpecial(CONQUEST + 95); -- "You do not have enough gil to set your home point here." end end end;
gpl-3.0
heyuqi/wxFormBuilder
build/premake/4.3/tests/test_vs2010_sln.lua
6
3138
T.vs2010_sln = { } local vs_magic_cpp_build_tool_id = "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942" local constant_uuid = "AE61726D-187C-E440-BD07-2556188A6565" local constant_project_name = "MyProject" -- -- Configure a solution for testing -- local sln function T.vs2010_sln.setup() _ACTION = "vs2010" sln = solution "MySolution" configurations { "Debug", "Release" } platforms {} prj = project(constant_project_name) language "C++" kind "ConsoleApp" uuid(constant_uuid) premake.buildconfigs() end local function escape_id(str) return string.gsub(str,"%-+","%%%-") end local function assert_has_project(buffer,uid,name,ext) test.string_contains(buffer,"Project(\"{"..escape_id(vs_magic_cpp_build_tool_id).."}\") = \""..name.."\", \""..name.."."..ext.."\", \"{"..escape_id(uid).."}\"") end local function assert_find_uuid(buffer,id) test.string_contains(buffer,escape_id(id)) end local function get_buffer() io.capture() premake.vs_generic_solution(sln) buffer = io.endcapture() return buffer end function T.vs2010_sln.action_formatVersionis11() local buffer = get_buffer() test.string_contains(buffer,'Format Version 11.00') end function T.vs2010_sln.action_vsIs2010() local buffer = get_buffer() test.string_contains(buffer,'# Visual Studio 2010') end function T.vs2010_sln.action_hasProjectScope() local buffer = get_buffer() test.string_contains(buffer,"Project(.*)EndProject") end function T.vs2010_sln.containsVsCppMagicId() local buffer = get_buffer() assert_find_uuid(buffer,vs_magic_cpp_build_tool_id) end function T.vs2010_sln.action_findMyProjectID() local buffer = get_buffer() test.string_contains(buffer,escape_id(constant_uuid)) end function T.vs2010_sln.action_findsExtension() local buffer = get_buffer() test.string_contains(buffer,".vcxproj") end function T.vs2010_sln.action_hasGlobalStartBlock() local buffer = get_buffer() test.string_contains(buffer,"Global") end function T.vs2010_sln.action_hasGlobalEndBlock() local buffer = get_buffer() test.string_contains(buffer,"EndGlobal") end function T.vs2010_sln.BasicLayout() io.capture() premake.vs_generic_solution(sln) test.capture ('\239\187\191' .. [[ Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyProject", "MyProject.vcxproj", "{AE61726D-187C-E440-BD07-2556188A6565}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.ActiveCfg = Debug|Win32 {AE61726D-187C-E440-BD07-2556188A6565}.Debug|Win32.Build.0 = Debug|Win32 {AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.ActiveCfg = Release|Win32 {AE61726D-187C-E440-BD07-2556188A6565}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal ]]) end
gpl-2.0
mahdib9/9
plugins/qr.lua
21
1783
--- https://github.com/amirhmz --- https://telegram.me/AmirDark local function get_hex(str) local colors = { red = "f00", blue = "00f", green = "0f0", yellow = "ff0", purple = "f0f", white = "fff", black = "000", gray = "ccc" } for color, value in pairs(colors) do if color == str then return value end end return str end local function qr(receiver, text, color, bgcolor) local url = "http://api.qrserver.com/v1/create-qr-code/?" .."size=600x600" --fixed size otherways it's low detailed .."&data="..URL.escape(text:trim()) if color then url = url.."&color="..get_hex(color) end if bgcolor then url = url.."&bgcolor="..get_hex(bgcolor) end local response, code, headers = http.request(url) if code ~= 200 then return "Oops! Error: " .. code end if #response > 0 then send_photo_from_url(receiver, url) return end return "Oops! Something strange happened :(" end local function run(msg, matches) local receiver = get_receiver(msg) local text = matches[1] local color local back if #matches > 1 then text = matches[3] color = matches[2] back = matches[1] end return qr(receiver, text, color, back) end return { description = {"qr code plugin for telegram, given a text it returns the qr code"}, usage = { "!qr [text]", '!qr "[background color]" "[data color]" [text]\n' .."Color through text: red|green|blue|purple|black|white|gray\n" .."Colors through hex notation: (\"a56729\" is brown)\n" .."Or colors through decimals: (\"255-192-203\" is pink)" }, patterns = { '^[!/]qr "(%w+)" "(%w+)" (.+)$', "^[!/]qr (.+)$" }, run = run } --- https://github.com/amirhmz --- https://telegram.me/AmirDark
gpl-2.0
nesstea/darkstar
scripts/globals/items/cone_calamary.lua
18
1313
----------------------------------------- -- ID: 5128 -- Item: Cone Calamary -- Food Effect: 5Min, Mithra only ----------------------------------------- -- Dexterity 3 -- Mind -5 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) result = 0 if (target:getRace() ~= 7) then result = 247; end if (target:getMod(MOD_EAT_RAW_FISH) == 1) then result = 0; end 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,300,5128); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_DEX, 3); target:addMod(MOD_MND, -5); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_DEX, 3); target:delMod(MOD_MND, -5); end;
gpl-3.0
bowlofstew/Macaroni
Main/Libraries/Macaroni/CppStd/2003/Source/PrepareBoostBuild.lua
4
1049
require "Macaroni.IO.GeneratedFileWriter"; require "Macaroni.IO.Path"; function getIncludePath() local success, path = pcall(function() return properties.boost["1.45.0"].include; end); if (not success) then error([[Could not find variable properties.boost["1.45.0"].include.]] .. [[ Please set this in init.lua to the path of Boost headers.]]); end return path; end function Prepare(library, sources, outputPath, installPath, extraArgs) local includePath = getIncludePath(); local buildjam = outputPath:NewPath("/jamroot.jam"); print("Creating Boost.Build file at " .. buildjam.AbsolutePath .. "."); local writer = buildjam:CreateFile(); writer:Write([[ # Generated by Macaroni. import boost ; import path ; use-project /boost : "]] .. includePath .. [[" ; alias library : /boost//headers ; ]]); writer:Close(); end -- --project -- : usage-requirements -- <include>]] .. includePath .. [[ -- ; -- --alias libSources -- : -- : <include>]] .. includePath .. [[ -- ;
apache-2.0
nesstea/darkstar
scripts/zones/Port_San_dOria/npcs/Ufanne.lua
13
1581
----------------------------------- -- Area: Port San d'Oria -- NPC: Ufanne -- Type: Standard NPC -- @zone: 232 -- @pos -15.965 -3 -47.748 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Port_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Port_San_dOria/TextIDs"); require("scripts/globals/quests"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local fishCountVar = 0; if (player:getQuestStatus(SANDORIA,THE_RIVALRY) == QUEST_ACCEPTED) then fishCountVar = player:getVar("theCompetitionFishCountVar"); player:startEvent(0x0135,0,0,fishCountVar); elseif (player:getQuestStatus(SANDORIA,THE_COMPETITION) == QUEST_ACCEPTED) then fishCountVar = player:getVar("theCompetitionFishCountVar"); player:startEvent(0x0135,1,0,fishCountVar); else player:startEvent(0x0136); 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
Badboy30/badboy30
plugins/xkcd.lua
628
1374
do function get_last_id() local res,code = https.request("http://xkcd.com/info.0.json") if code ~= 200 then return "HTTP ERROR" end local data = json:decode(res) return data.num end function get_xkcd(id) local res,code = http.request("http://xkcd.com/"..id.."/info.0.json") if code ~= 200 then return "HTTP ERROR" end local data = json:decode(res) local link_image = data.img if link_image:sub(0,2) == '//' then link_image = msg.text:sub(3,-1) end return link_image, data.title, data.alt end function get_xkcd_random() local last = get_last_id() local i = math.random(1, last) return get_xkcd(i) end function send_title(cb_extra, success, result) if success then local message = cb_extra[2] .. "\n" .. cb_extra[3] send_msg(cb_extra[1], message, ok_cb, false) end end function run(msg, matches) local receiver = get_receiver(msg) if matches[1] == "!xkcd" then url, title, alt = get_xkcd_random() else url, title, alt = get_xkcd(matches[1]) end file_path = download_to_file(url) send_photo(receiver, file_path, send_title, {receiver, title, alt}) return false end return { description = "Send comic images from xkcd", usage = {"!xkcd (id): Send an xkcd image and title. If not id, send a random one"}, patterns = { "^!xkcd$", "^!xkcd (%d+)", "xkcd.com/(%d+)" }, run = run } end
gpl-2.0
Mashape/kong
spec/01-unit/04-prefix_handler_spec.lua
1
33383
local helpers = require "spec.helpers" local conf_loader = require "kong.conf_loader" local prefix_handler = require "kong.cmd.utils.prefix_handler" local exists = helpers.path.exists local join = helpers.path.join describe("NGINX conf compiler", function() describe("gen_default_ssl_cert()", function() local conf = assert(conf_loader(helpers.test_conf_path, { prefix = "ssl_tmp", ssl_cert = "spec/fixtures/kong_spec.crt", ssl_cert_key = "spec/fixtures/kong_spec.key", admin_ssl_cert = "spec/fixtures/kong_spec.crt", admin_ssl_cert_key = "spec/fixtures/kong_spec.key", })) before_each(function() helpers.dir.makepath("ssl_tmp") end) after_each(function() pcall(helpers.dir.rmtree, "ssl_tmp") end) describe("proxy", function() it("auto-generates SSL certificate and key", function() assert(prefix_handler.gen_default_ssl_cert(conf)) assert(exists(conf.ssl_cert_default)) assert(exists(conf.ssl_cert_key_default)) end) it("does not re-generate if they already exist", function() assert(prefix_handler.gen_default_ssl_cert(conf)) local cer = helpers.file.read(conf.ssl_cert_default) local key = helpers.file.read(conf.ssl_cert_key_default) assert(prefix_handler.gen_default_ssl_cert(conf)) assert.equal(cer, helpers.file.read(conf.ssl_cert_default)) assert.equal(key, helpers.file.read(conf.ssl_cert_key_default)) end) end) describe("admin", function() it("auto-generates SSL certificate and key", function() assert(prefix_handler.gen_default_ssl_cert(conf, true)) assert(exists(conf.admin_ssl_cert_default)) assert(exists(conf.admin_ssl_cert_key_default)) end) it("does not re-generate if they already exist", function() assert(prefix_handler.gen_default_ssl_cert(conf, true)) local cer = helpers.file.read(conf.admin_ssl_cert_default) local key = helpers.file.read(conf.admin_ssl_cert_key_default) assert(prefix_handler.gen_default_ssl_cert(conf, true)) assert.equal(cer, helpers.file.read(conf.admin_ssl_cert_default)) assert.equal(key, helpers.file.read(conf.admin_ssl_cert_key_default)) end) end) end) describe("#stream compile_kong_stream_conf()", function() it("enables ssl_preread conditionally", function() local save_nginx_configure = ngx.config.nginx_configure -- luacheck: ignore finally(function() ngx.config.nginx_configure = save_nginx_configure -- luacheck: ignore end) -- with ssl_preread enabled ngx.config.nginx_configure = function() -- luacheck: ignore return "--with-foo --with-stream_ssl_preread_module --with-bar" end local conf = assert(conf_loader(helpers.test_conf_path, { stream_listen = "0.0.0.0:9100", })) local kong_nginx_stream_conf = prefix_handler.compile_kong_stream_conf(conf) assert.matches("ssl_preread on", kong_nginx_stream_conf, nil, true) -- without ssl_preread enabled ngx.config.nginx_configure = function() -- luacheck: ignore return " --with-foo --with-bar" end conf = assert(conf_loader(helpers.test_conf_path, { stream_listen = "0.0.0.0:9100", })) kong_nginx_stream_conf = prefix_handler.compile_kong_stream_conf(conf) assert.not_matches("ssl_preread on", kong_nginx_stream_conf, nil, true) end) end) describe("compile_kong_conf()", function() it("compiles the Kong NGINX conf chunk", function() local kong_nginx_conf = prefix_handler.compile_kong_conf(helpers.test_conf) assert.matches("lua_package_path './spec/fixtures/custom_plugins/?.lua;;'", kong_nginx_conf, nil, true) assert.matches("listen 0.0.0.0:9000;", kong_nginx_conf, nil, true) assert.matches("listen 127.0.0.1:9001;", kong_nginx_conf, nil, true) assert.matches("server_name kong;", kong_nginx_conf, nil, true) assert.matches("server_name kong_admin;", kong_nginx_conf, nil, true) assert.not_matches("lua_ssl_trusted_certificate", kong_nginx_conf, nil, true) end) it("compiles with custom conf", function() local conf = assert(conf_loader(helpers.test_conf_path, { mem_cache_size = "128k", proxy_listen = "0.0.0.0:80", admin_listen = "127.0.0.1:8001" })) local kong_nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("lua_shared_dict kong_db_cache%s+128k;", kong_nginx_conf) assert.matches("listen 0.0.0.0:80;", kong_nginx_conf, nil, true) assert.matches("listen 127.0.0.1:8001;", kong_nginx_conf, nil, true) end) it("enables HTTP/2", function() local conf = assert(conf_loader(helpers.test_conf_path, { proxy_listen = "0.0.0.0:9000, 0.0.0.0:9443 http2 ssl", admin_listen = "127.0.0.1:9001, 127.0.0.1:9444 http2 ssl", })) local kong_nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("listen 0.0.0.0:9000;", kong_nginx_conf, nil, true) assert.matches("listen 0.0.0.0:9443 ssl http2;", kong_nginx_conf, nil, true) assert.matches("listen 127.0.0.1:9001;", kong_nginx_conf, nil, true) assert.matches("listen 127.0.0.1:9444 ssl http2;", kong_nginx_conf, nil, true) conf = assert(conf_loader(helpers.test_conf_path, { proxy_listen = "0.0.0.0:9000, 0.0.0.0:9443 http2 ssl", admin_listen = "127.0.0.1:9001, 127.0.0.1:8444 ssl", })) kong_nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("listen 0.0.0.0:9000;", kong_nginx_conf, nil, true) assert.matches("listen 0.0.0.0:9443 ssl http2;", kong_nginx_conf, nil, true) assert.matches("listen 127.0.0.1:9001;", kong_nginx_conf, nil, true) assert.matches("listen 127.0.0.1:8444 ssl;", kong_nginx_conf, nil, true) conf = assert(conf_loader(helpers.test_conf_path, { proxy_listen = "0.0.0.0:9000, 0.0.0.0:9443 ssl", admin_listen = "127.0.0.1:9001, 127.0.0.1:8444 http2 ssl", })) kong_nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("listen 0.0.0.0:9000;", kong_nginx_conf, nil, true) assert.matches("listen 0.0.0.0:9443 ssl;", kong_nginx_conf, nil, true) assert.matches("listen 127.0.0.1:9001;", kong_nginx_conf, nil, true) assert.matches("listen 127.0.0.1:8444 ssl http2;", kong_nginx_conf, nil, true) end) it("enables proxy_protocol", function() local conf = assert(conf_loader(helpers.test_conf_path, { proxy_listen = "0.0.0.0:9000 proxy_protocol", real_ip_header = "proxy_protocol", })) local kong_nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("listen 0.0.0.0:9000 proxy_protocol;", kong_nginx_conf, nil, true) assert.matches("real_ip_header%s+proxy_protocol;", kong_nginx_conf) end) it("enables deferred", function() local conf = assert(conf_loader(helpers.test_conf_path, { proxy_listen = "0.0.0.0:9000 deferred", })) local kong_nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("listen 0.0.0.0:9000 deferred;", kong_nginx_conf, nil, true) end) it("enables bind", function() local conf = assert(conf_loader(helpers.test_conf_path, { proxy_listen = "0.0.0.0:9000 bind", })) local kong_nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("listen 0.0.0.0:9000 bind;", kong_nginx_conf, nil, true) end) it("enables reuseport", function() local conf = assert(conf_loader(helpers.test_conf_path, { proxy_listen = "0.0.0.0:9000 reuseport", })) local kong_nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("listen 0.0.0.0:9000 reuseport;", kong_nginx_conf, nil, true) end) it("disables SSL", function() local conf = assert(conf_loader(helpers.test_conf_path, { proxy_listen = "127.0.0.1:8000", admin_listen = "127.0.0.1:8001", })) local kong_nginx_conf = prefix_handler.compile_kong_conf(conf) assert.not_matches("listen %d+%.%d+%.%d+%.%d+:%d+ ssl;", kong_nginx_conf) assert.not_matches("ssl_certificate", kong_nginx_conf) assert.not_matches("ssl_certificate_key", kong_nginx_conf) assert.not_matches("ssl_certificate_by_lua_block", kong_nginx_conf) end) describe("handles client_ssl", function() it("on", function() local conf = assert(conf_loader(helpers.test_conf_path, { client_ssl = true, client_ssl_cert = "spec/fixtures/kong_spec.crt", client_ssl_cert_key = "spec/fixtures/kong_spec.key", })) local kong_nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("proxy_ssl_certificate.*spec/fixtures/kong_spec.crt", kong_nginx_conf) assert.matches("proxy_ssl_certificate_key.*spec/fixtures/kong_spec.key", kong_nginx_conf) end) it("off", function() local conf = assert(conf_loader(helpers.test_conf_path, { client_ssl = false, })) local kong_nginx_conf = prefix_handler.compile_kong_conf(conf) assert.not_matches("proxy_ssl_certificate.*spec/fixtures/kong_spec.crt", kong_nginx_conf) assert.not_matches("proxy_ssl_certificate_key.*spec/fixtures/kong_spec.key", kong_nginx_conf) end) end) it("sets lua_ssl_verify_depth", function() local conf = assert(conf_loader(helpers.test_conf_path, { lua_ssl_verify_depth = "2" })) local kong_nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("lua_ssl_verify_depth 2;", kong_nginx_conf, nil, true) end) it("includes default lua_ssl_verify_depth", function() local conf = assert(conf_loader(helpers.test_conf_path)) local kong_nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("lua_ssl_verify_depth 1;", kong_nginx_conf, nil, true) end) it("does not include lua_ssl_trusted_certificate by default", function() local conf = assert(conf_loader(helpers.test_conf_path)) local kong_nginx_conf = prefix_handler.compile_kong_conf(conf) assert.not_matches("lua_ssl_trusted_certificate", kong_nginx_conf, nil, true) end) it("sets lua_ssl_trusted_certificate", function() local conf = assert(conf_loader(helpers.test_conf_path, { lua_ssl_trusted_certificate = "/path/to/ca.cert", })) local kong_nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("lua_ssl_trusted_certificate '/path/to/ca.cert';", kong_nginx_conf, nil, true) end) it("compiles without anonymous reports", function() local conf = assert(conf_loader(nil, { anonymous_reports = false, })) local nginx_conf = prefix_handler.compile_kong_conf(conf) assert.not_matches("error_log syslog:server=.+ error;", nginx_conf) end) it("compiles with anonymous reports", function() local conf = assert(conf_loader(nil, { anonymous_reports = true, })) local nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("error_log syslog:server=.+:61828 error;", nginx_conf) end) it("defines the client_max_body_size by default", function() local conf = assert(conf_loader(nil, {})) local nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("client_max_body_size 0", nginx_conf, nil, true) end) it("writes the client_max_body_size as defined", function() local conf = assert(conf_loader(nil, { client_max_body_size = "1m", })) local nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("client_max_body_size 1m", nginx_conf, nil, true) end) it("defines the client_body_buffer_size directive by default", function() local conf = assert(conf_loader(nil, {})) local nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("client_body_buffer_size 8k", nginx_conf, nil, true) end) it("writes the client_body_buffer_size directive as defined", function() local conf = assert(conf_loader(nil, { client_body_buffer_size = "128k", })) local nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("client_body_buffer_size 128k", nginx_conf, nil, true) end) it("writes kong_cassandra shm if using Cassandra", function() local conf = assert(conf_loader(nil, { database = "cassandra", })) local nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("lua_shared_dict%s+kong_cassandra", nginx_conf) end) it("does not write kong_cassandra shm if not using Cassandra", function() local conf = assert(conf_loader(nil, { database = "postgres", })) local nginx_conf = prefix_handler.compile_kong_conf(conf) assert.not_matches("lua_shared_dict%s+kong_cassandra", nginx_conf) end) describe("user directive", function() it("is not included by default", function() local conf = assert(conf_loader(helpers.test_conf_path)) local nginx_conf = prefix_handler.compile_nginx_conf(conf) assert.not_matches("user[^;]*;", nginx_conf, nil, true) end) it("is not included when 'nobody'", function() local conf = assert(conf_loader(helpers.test_conf_path, { nginx_user = "nobody" })) local nginx_conf = prefix_handler.compile_nginx_conf(conf) assert.not_matches("user[^;]*;", nginx_conf, nil, true) end) it("is not included when 'nobody nobody'", function() local conf = assert(conf_loader(helpers.test_conf_path, { nginx_user = "nobody nobody" })) local nginx_conf = prefix_handler.compile_nginx_conf(conf) assert.not_matches("user[^;]*;", nginx_conf, nil, true) end) it("is included when otherwise", function() local conf = assert(conf_loader(helpers.test_conf_path, { nginx_user = "www_data www_data" })) local nginx_conf = prefix_handler.compile_nginx_conf(conf) assert.matches("user www_data www_data;", nginx_conf, nil, true) end) end) describe("ngx_http_realip_module settings", function() it("defaults", function() local conf = assert(conf_loader()) local nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("real_ip_header%s+X%-Real%-IP;", nginx_conf) assert.matches("real_ip_recursive%s+off;", nginx_conf) assert.not_matches("set_real_ip_from", nginx_conf) end) it("real_ip_recursive on", function() local conf = assert(conf_loader(nil, { real_ip_recursive = true, })) local nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("real_ip_recursive%s+on;", nginx_conf) end) it("real_ip_recursive off", function() local conf = assert(conf_loader(nil, { real_ip_recursive = false, })) local nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("real_ip_recursive%s+off;", nginx_conf) end) it("set_real_ip_from", function() local conf = assert(conf_loader(nil, { trusted_ips = "192.168.1.0/24,192.168.2.1,2001:0db8::/32" })) local nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("set_real_ip_from%s+192.168.1.0/24", nginx_conf) assert.matches("set_real_ip_from%s+192.168.1.0", nginx_conf) assert.matches("set_real_ip_from%s+2001:0db8::/32", nginx_conf) end) it("set_real_ip_from (stream proxy)", function() local conf = assert(conf_loader(nil, { trusted_ips = "192.168.1.0/24,192.168.2.1,2001:0db8::/32" })) local nginx_conf = prefix_handler.compile_kong_stream_conf(conf) assert.matches("set_real_ip_from%s+192.168.1.0/24", nginx_conf) assert.matches("set_real_ip_from%s+192.168.1.0", nginx_conf) assert.matches("set_real_ip_from%s+2001:0db8::/32", nginx_conf) end) it("proxy_protocol", function() local conf = assert(conf_loader(nil, { proxy_listen = "0.0.0.0:8000 proxy_protocol, 0.0.0.0:8443 ssl", real_ip_header = "proxy_protocol", })) local nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("real_ip_header%s+proxy_protocol", nginx_conf) assert.matches("listen 0.0.0.0:8000 proxy_protocol;", nginx_conf) assert.matches("listen 0.0.0.0:8443 ssl;", nginx_conf) end) end) describe("injected NGINX directives", function() it("injects ngx_http_* directives", function() local conf = assert(conf_loader(nil, { nginx_http_large_client_header_buffers = "8 24k", nginx_http_log_format = "custom_fmt '$connection $request_time'" })) local nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("large_client_header_buffers%s+8 24k;", nginx_conf) assert.matches("log_format custom_fmt '$connection $request_time';", nginx_conf, nil, true) end) it("injects ngx_proxy_* directives", function() local conf = assert(conf_loader(nil, { nginx_http_large_client_header_buffers = "16 24k", })) local nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("large_client_header_buffers%s+16 24k;", nginx_conf) end) it("injects ngx_admin_* directives", function() local conf = assert(conf_loader(nil, { nginx_http_large_client_header_buffers = "4 24k", })) local nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("large_client_header_buffers%s+4 24k;", nginx_conf) end) it("injects nginx_http_upstream_* directives", function() local conf = assert(conf_loader(nil, { nginx_http_upstream_keepalive = "120", })) local nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("keepalive 120;", nginx_conf, nil, true) end) it("does not inject directives if value is 'NONE'", function() local conf = assert(conf_loader(nil, { nginx_http_upstream_keepalive = "NONE", })) local nginx_conf = prefix_handler.compile_kong_conf(conf) assert.not_matches("keepalive %d+;", nginx_conf) end) describe("default injected NGINX directives", function() it("configures default http upstream{} block directives", function() local conf = assert(conf_loader()) local nginx_conf = prefix_handler.compile_kong_conf(conf) assert.matches("keepalive 60;", nginx_conf, nil, true) assert.matches("keepalive_requests 100;", nginx_conf, nil, true) assert.matches("keepalive_timeout 60s;", nginx_conf, nil, true) end) end) end) end) describe("compile_nginx_conf()", function() it("compiles a main NGINX conf", function() local nginx_conf = prefix_handler.compile_nginx_conf(helpers.test_conf) assert.matches("worker_processes 1;", nginx_conf, nil, true) assert.matches("daemon on;", nginx_conf, nil, true) end) it("compiles with custom conf", function() local conf = assert(conf_loader(helpers.test_conf_path, { nginx_daemon = "off" })) local nginx_conf = prefix_handler.compile_nginx_conf(conf) assert.matches("daemon off;", nginx_conf, nil, true) end) it("compiles without opinionated nginx optimizations", function() local conf = assert(conf_loader(nil, { nginx_optimizations = false, })) local nginx_conf = prefix_handler.compile_nginx_conf(conf) assert.not_matches("worker_rlimit_nofile %d+;", nginx_conf) assert.not_matches("worker_connections %d+;", nginx_conf) assert.not_matches("multi_accept on;", nginx_conf) end) it("compiles with opinionated nginx optimizations", function() local conf = assert(conf_loader(nil, { nginx_optimizations = true, })) local nginx_conf = prefix_handler.compile_nginx_conf(conf) assert.matches("worker_rlimit_nofile %d+;", nginx_conf) assert.matches("worker_connections %d+;", nginx_conf) assert.matches("multi_accept on;", nginx_conf) end) it("converts dns_resolver to string", function() local nginx_conf = prefix_handler.compile_nginx_conf({ dns_resolver = { "8.8.8.8", "8.8.4.4" } }, [[ "resolver ${{DNS_RESOLVER}} ipv6=off;" ]]) assert.matches("resolver 8.8.8.8 8.8.4.4 ipv6=off;", nginx_conf, nil, true) end) end) describe("prepare_prefix()", function() local tmp_config = conf_loader(helpers.test_conf_path, { prefix = "servroot_tmp" }) before_each(function() pcall(helpers.dir.rmtree, tmp_config.prefix) helpers.dir.makepath(tmp_config.prefix) end) after_each(function() pcall(helpers.dir.rmtree, tmp_config.prefix) end) it("creates inexistent prefix", function() finally(function() pcall(helpers.dir.rmtree, "inexistent") end) local config = assert(conf_loader(helpers.test_conf_path, { prefix = "inexistent" })) assert(prefix_handler.prepare_prefix(config)) assert.truthy(exists("inexistent")) end) it("ensures prefix is a directory", function() local tmp = os.tmpname() finally(function() os.remove(tmp) end) local config = assert(conf_loader(helpers.test_conf_path, { prefix = tmp })) local ok, err = prefix_handler.prepare_prefix(config) assert.equal(tmp .. " is not a directory", err) assert.is_nil(ok) end) it("creates pids folder", function() assert(prefix_handler.prepare_prefix(tmp_config)) assert.truthy(exists(join(tmp_config.prefix, "pids"))) end) it("creates NGINX conf and log files", function() assert(prefix_handler.prepare_prefix(tmp_config)) assert.truthy(exists(tmp_config.kong_env)) assert.truthy(exists(tmp_config.nginx_kong_conf)) assert.truthy(exists(tmp_config.nginx_err_logs)) assert.truthy(exists(tmp_config.nginx_acc_logs)) assert.truthy(exists(tmp_config.admin_acc_logs)) end) it("dumps Kong conf", function() assert(prefix_handler.prepare_prefix(tmp_config)) local in_prefix_kong_conf = assert(conf_loader(tmp_config.kong_env)) assert.same(tmp_config, in_prefix_kong_conf) end) it("dump Kong conf (custom conf)", function() local conf = assert(conf_loader(nil, { pg_database = "foobar", pg_schema = "foo", prefix = tmp_config.prefix })) assert.equal("foobar", conf.pg_database) assert.equal("foo", conf.pg_schema) assert(prefix_handler.prepare_prefix(conf)) local in_prefix_kong_conf = assert(conf_loader(tmp_config.kong_env, { pg_database = "foobar", pg_schema = "foo", prefix = tmp_config.prefix, })) assert.same(conf, in_prefix_kong_conf) end) it("writes custom plugins in Kong conf", function() local conf = assert(conf_loader(nil, { plugins = { "foo", "bar" }, prefix = tmp_config.prefix })) assert(prefix_handler.prepare_prefix(conf)) local in_prefix_kong_conf = assert(conf_loader(tmp_config.kong_env)) assert.True(in_prefix_kong_conf.loaded_plugins.foo) assert.True(in_prefix_kong_conf.loaded_plugins.bar) end) describe("ssl", function() it("does not create SSL dir if disabled", function() local conf = conf_loader(nil, { prefix = tmp_config.prefix, proxy_listen = "127.0.0.1:8000", admin_listen = "127.0.0.1:8001", }) assert(prefix_handler.prepare_prefix(conf)) assert.falsy(exists(join(conf.prefix, "ssl"))) end) it("does not create SSL dir if using custom cert", function() local conf = conf_loader(nil, { prefix = tmp_config.prefix, proxy_listen = "127.0.0.1:8000 ssl", admin_listen = "127.0.0.1:8001 ssl", ssl_cert = "spec/fixtures/kong_spec.crt", ssl_cert_key = "spec/fixtures/kong_spec.key", admin_ssl_cert = "spec/fixtures/kong_spec.crt", admin_ssl_cert_key = "spec/fixtures/kong_spec.key", }) assert(prefix_handler.prepare_prefix(conf)) assert.falsy(exists(join(conf.prefix, "ssl"))) end) it("generates default SSL cert", function() local conf = conf_loader(nil, { prefix = tmp_config.prefix, proxy_listen = "127.0.0.1:8000 ssl", admin_listen = "127.0.0.1:8001 ssl", }) assert(prefix_handler.prepare_prefix(conf)) assert.truthy(exists(join(conf.prefix, "ssl"))) assert.truthy(exists(conf.ssl_cert_default)) assert.truthy(exists(conf.ssl_cert_key_default)) assert.truthy(exists(conf.admin_ssl_cert_default)) assert.truthy(exists(conf.admin_ssl_cert_key_default)) end) end) describe("custom template", function() local templ_fixture = "spec/fixtures/custom_nginx.template" it("accepts a custom NGINX conf template", function() assert(prefix_handler.prepare_prefix(tmp_config, templ_fixture)) assert.truthy(exists(tmp_config.nginx_conf)) local contents = helpers.file.read(tmp_config.nginx_conf) assert.matches("# This is a custom nginx configuration template for Kong specs", contents, nil, true) assert.matches("daemon on;", contents, nil, true) assert.matches("listen 0.0.0.0:9000;", contents, nil, true) end) it("errors on non-existing file", function() local ok, err = prefix_handler.prepare_prefix(tmp_config, "spec/fixtures/inexistent.template") assert.is_nil(ok) assert.equal("no such file: spec/fixtures/inexistent.template", err) end) it("reports Penlight templating errors", function() local u = helpers.unindent local tmp = os.tmpname() helpers.file.write(tmp, u[[ > if t.hello then > end ]]) finally(function() helpers.file.delete(tmp) end) local ok, err = prefix_handler.prepare_prefix(helpers.test_conf, tmp) assert.is_nil(ok) assert.matches("failed to compile nginx config template: .* " .. "attempt to index global 't' %(a nil value%)", err) end) end) describe("nginx_* injected directives aliases", function() -- Aliases maintained for pre-established Nginx directives specified -- as Kong config properties describe("'upstream_keepalive'", function() describe("1.2 Nginx template", function() local templ_fixture = "spec/fixtures/1.2_custom_nginx.template" it("compiles", function() assert(prefix_handler.prepare_prefix(tmp_config, templ_fixture)) assert.truthy(exists(tmp_config.nginx_conf)) local contents = helpers.file.read(tmp_config.nginx_conf) assert.matches("# This is the Kong 1.2 default template", contents, nil, true) assert.matches("daemon on;", contents, nil, true) assert.matches("listen 0.0.0.0:9000;", contents, nil, true) assert.matches("keepalive 60;", contents, nil, true) end) it("'upstream_keepalive = 0' disables keepalive", function() local conf = assert(conf_loader(helpers.test_conf_path, { prefix = tmp_config.prefix, upstream_keepalive = 0, })) assert(prefix_handler.prepare_prefix(conf, templ_fixture)) assert.truthy(exists(conf.nginx_conf)) local contents = helpers.file.read(tmp_config.nginx_conf) assert.matches("# This is the Kong 1.2 default template", contents, nil, true) assert.not_matches("keepalive %d+;", contents) local conf = assert(conf_loader(helpers.test_conf_path, { prefix = tmp_config.prefix, nginx_http_upstream_keepalive = "120", -- not used by template upstream_keepalive = 0, })) assert(prefix_handler.prepare_prefix(conf, templ_fixture)) assert.truthy(exists(conf.nginx_conf)) local contents = helpers.file.read(tmp_config.nginx_conf) assert.matches("# This is the Kong 1.2 default template", contents, nil, true) assert.not_matches("keepalive %d+;", contents) end) it("'upstream_keepalive' also sets keepalive if specified", function() local conf = assert(conf_loader(helpers.test_conf_path, { prefix = tmp_config.prefix, nginx_http_upstream_keepalive = "NONE", -- not used by template upstream_keepalive = 60, })) assert(prefix_handler.prepare_prefix(conf, templ_fixture)) assert.truthy(exists(conf.nginx_conf)) local contents = helpers.file.read(tmp_config.nginx_conf) assert.matches("# This is the Kong 1.2 default template", contents, nil, true) assert.matches("keepalive 60;", contents, nil, true) local conf = assert(conf_loader(helpers.test_conf_path, { prefix = tmp_config.prefix, nginx_http_upstream_keepalive = "120", -- not used by template upstream_keepalive = 60, })) assert(prefix_handler.prepare_prefix(conf, templ_fixture)) assert.truthy(exists(conf.nginx_conf)) local contents = helpers.file.read(tmp_config.nginx_conf) assert.matches("# This is the Kong 1.2 default template", contents, nil, true) assert.matches("keepalive 60;", contents, nil, true) end) end) describe("latest Nginx template", function() local templ_fixture = "spec/fixtures/custom_nginx.template" it("'upstream_keepalive = 0' has highest precedence", function() local conf = assert(conf_loader(helpers.test_conf_path, { prefix = tmp_config.prefix, upstream_keepalive = 0, })) assert(prefix_handler.prepare_prefix(conf, templ_fixture)) assert.truthy(exists(conf.nginx_conf)) local contents = helpers.file.read(tmp_config.nginx_conf) assert.not_matches("keepalive %d+;", contents) local conf = assert(conf_loader(helpers.test_conf_path, { prefix = tmp_config.prefix, nginx_http_upstream_keepalive = "120", upstream_keepalive = 0, })) assert(prefix_handler.prepare_prefix(conf, templ_fixture)) assert.truthy(exists(conf.nginx_conf)) local contents = helpers.file.read(tmp_config.nginx_conf) assert.not_matches("keepalive %d+;", contents) end) it("'nginx_http_upstream_keepalive' has second highest precedence", function() local conf = assert(conf_loader(helpers.test_conf_path, { prefix = tmp_config.prefix, nginx_http_upstream_keepalive = "120", upstream_keepalive = 60, })) assert(prefix_handler.prepare_prefix(conf, templ_fixture)) assert.truthy(exists(conf.nginx_conf)) local contents = helpers.file.read(tmp_config.nginx_conf) assert.matches("keepalive 120;", contents, nil, true) local conf = assert(conf_loader(helpers.test_conf_path, { prefix = tmp_config.prefix, nginx_http_upstream_keepalive = "60", upstream_keepalive = 120, })) assert(prefix_handler.prepare_prefix(conf, templ_fixture)) assert.truthy(exists(conf.nginx_conf)) local contents = helpers.file.read(tmp_config.nginx_conf) assert.matches("keepalive 60;", contents, nil, true) end) it("'upstream_keepalive' has lowest precedence", function() local conf = assert(conf_loader(helpers.test_conf_path, { prefix = tmp_config.prefix, upstream_keepalive = 120, })) assert(prefix_handler.prepare_prefix(conf, templ_fixture)) assert.truthy(exists(conf.nginx_conf)) local contents = helpers.file.read(tmp_config.nginx_conf) assert.matches("keepalive 120;", contents, nil, true) local conf = assert(conf_loader(helpers.test_conf_path, { prefix = tmp_config.prefix, upstream_keepalive = 120, })) assert(prefix_handler.prepare_prefix(conf, templ_fixture)) assert.truthy(exists(conf.nginx_conf)) local contents = helpers.file.read(tmp_config.nginx_conf) assert.matches("keepalive 120;", contents, nil, true) end) end) end) end) end) end)
apache-2.0
UnfortunateFruit/darkstar
scripts/globals/spells/bluemagic/hecatomb_wave.lua
9
1946
----------------------------------------- -- Spell: Hecatomb Wave -- Deals wind damage to enemies within a fan-shaped area originating from the caster. Additional effect: Blindness -- Spell cost: 116 MP -- Monster Type: Demons -- Spell Type: Magical (Wind) -- Blue Magic Points: 3 -- Stat Bonus: AGI+1 -- Level: 54 -- Casting Time: 5.25 seconds -- Recast Time: 33.75 seconds -- Magic Bursts on: Detonation, Fragmentation, Light -- Combos: Max MP Boost ----------------------------------------- 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 resist = applyResistance(caster,spell,target,caster:getStat(MOD_INT) - target:getStat(MOD_INT),BLUE_SKILL,1.0); local params = {}; -- This data should match information on http://wiki.ffxiclopedia.org/wiki/Calculating_Blue_Magic_Damage params.multiplier = 1.375; params.tMultiplier = 1.0; params.duppercap = 54; params.str_wsc = 0.0; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.3; params.chr_wsc = 0.0; damage = BlueMagicalSpell(caster, target, spell, params, MND_BASED); damage = BlueFinalAdjustments(caster, target, spell, damage, params); if(damage > 0 and resist > 0.125) then local typeEffect = EFFECT_BLINDNESS; target:delStatusEffect(typeEffect); target:addStatusEffect(typeEffect,5,0,getBlueEffectDuration(caster,resist,typeEffect)); end return damage; end;
gpl-3.0
UnfortunateFruit/darkstar
scripts/globals/mobskills/Hexidiscs.lua
7
1122
--------------------------------------------- -- Hexidiscs -- -- Description: A sixfold attack damages targets in a fan-shaped area of effect. -- Type: Physical -- Utsusemi/Blink absorb: 6 shadows -- Range: Unknown cone -- Notes: Only used in "ball" form. --------------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/monstertpmoves"); --------------------------------------------- --------------------------------------------------- -- onMobSkillCheck -- if not in Ball form, then ignore. --------------------------------------------------- function onMobSkillCheck(target,mob,skill) if(mob:AnimationSub() ~=0) then return 1; else return 0; end end; function onMobWeaponSkill(target, mob, skill) local numhits = 6; local accmod = 1; local dmgmod = .7; local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,TP_NO_EFFECT); local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_PHYSICAL,MOBPARAM_BLUNT,info.hitslanded); target:delHP(dmg); return dmg; end;
gpl-3.0
UnfortunateFruit/darkstar
scripts/zones/Xarcabard/npcs/Trail_Markings.lua
19
2465
----------------------------------- -- Area: Xarcabard -- NPC: Trail Markings -- Dynamis-Xarcabard Enter -- @pos 570 0 -272 112 ----------------------------------- package.loaded["scripts/zones/Xarcabard/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/dynamis"); require("scripts/zones/Xarcabard/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if(player:getVar("DynaXarcabard_Win") == 1) then player:startEvent(0x0020,HYDRA_CORPS_BATTLE_STANDARD); -- Win CS elseif(player:hasKeyItem(HYDRA_CORPS_INSIGNIA)) then local firstDyna = 0; local realDay = os.time(); local dynaWaitxDay = player:getVar("dynaWaitxDay"); if(checkFirstDyna(player,6)) then -- First Dyna-Xarcabard => CS firstDyna = 1; end if(player:getMainLvl() < DYNA_LEVEL_MIN) then player:messageSpecial(PLAYERS_HAVE_NOT_REACHED_LEVEL,DYNA_LEVEL_MIN); elseif((dynaWaitxDay + (BETWEEN_2DYNA_WAIT_TIME * 24 * 60 * 60)) < realDay or player:getVar("DynamisID") == GetServerVariable("[DynaXarcabard]UniqueID")) then player:startEvent(0x0010,6,firstDyna,0,BETWEEN_2DYNA_WAIT_TIME,32,VIAL_OF_SHROUDED_SAND,4236,4237); else dayRemaining = math.floor(((dynaWaitxDay + (BETWEEN_2DYNA_WAIT_TIME * 24 * 60 * 60)) - realDay)/3456); player:messageSpecial(YOU_CANNOT_ENTER_DYNAMIS,dayRemaining,6); end else player:messageSpecial(UNUSUAL_ARRANGEMENT_OF_PEBBLES); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("updateRESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("finishRESULT: %u",option); if(csid == 0x0020) then player:setVar("DynaXarcabard_Win",0); elseif(csid == 0x0010 and option == 0) then if(checkFirstDyna(player,6)) then player:setVar("Dynamis_Status",player:getVar("Dynamis_Status") + 64); end player:setPos(569.312,-0.098,-270.158,90,0x87); end end;
gpl-3.0
UnfortunateFruit/darkstar
scripts/zones/Leujaoam_Sanctum/npcs/rune_of_release.lua
32
1876
----------------------------------- -- Area: Leujaoam Sanctum ----------------------------------- require("scripts/globals/besieged") require("scripts/zones/Leujaoam_Sanctum/IDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local instance = npc:getInstance(); if (instance:completed()) then player:startEvent(100,0); end return 1; end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 100 and option == 1) then local instance = player:getInstance() local chars = instance:getChars(); local id = instance:getID(); local points = 0; if (id == 1) then points = 1000 - math.max(0, #chars - 3); end for i,v in pairs(chars) do v:messageSpecial(Leujaoam.text.ASSAULT_POINTS_OBTAINED,points); v:addAssaultPoint(LEUJAOAM_ASSAULT_POINT,points); v:setVar("AssaultComplete",1); if (v:hasCompletedAssault(v:getCurrentAssault())) then v:setVar("AssaultPromotion", v:getVar("AssaultPromotion")+1); else v:setVar("AssaultPromotion", v:getVar("AssaultPromotion")+5); end if (v ~= player) then v:startEvent(102); end end end end;
gpl-3.0
nesstea/darkstar
scripts/zones/Aht_Urhgan_Whitegate/npcs/Prillaure.lua
13
1055
----------------------------------- -- Area: Aht Urhgan Whitegate -- NPC: Prillaure -- Type: Event Scene Replayer -- @pos -143.000 0.999 9.000 50 ----------------------------------- package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x01f7); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
johnmccabe/dockercraft
world/Plugins/InfoDump.lua
25
22555
#!/usr/bin/lua -- InfoDump.lua --[[ Loads plugins' Info.lua and dumps its g_PluginInfo into various text formats This is used for generating plugin documentation for the forum and for GitHub's INFO.md files This script can be used in two ways: Executing "lua InfoDump.lua" will go through all subfolders and dump each Info.lua file it can find Note that this mode of operation requires LuaRocks with LFS installed; instructions are printed when the prerequisites are not met. Executing "lua InfoDump.lua PluginName" will load the Info.lua file from PluginName's folder and dump only that one plugin's documentation. This mode of operation doesn't require LuaRocks --]] -- If this file is called using the loadfile function the arg variable isn't filled. We have to do it manualy then. local arg = arg or {...} -- Check Lua version. We use 5.1-specific construct when loading the plugin info, 5.2 is not compatible! if (_VERSION ~= "Lua 5.1") then print("Unsupported Lua version. This script requires Lua version 5.1, this Lua is version " .. (_VERSION or "<nil>")) return end --- Replaces generic formatting with forum-specific formatting -- Also removes the single line-ends local function ForumizeString(a_Str) assert(type(a_Str) == "string") -- Remove the indentation, unless in the code tag: -- Only one code or /code tag per line is supported! local IsInCode = false local function RemoveIndentIfNotInCode(s) if (IsInCode) then -- we're in code section, check if this line terminates it IsInCode = (s:find("{%%/code}") ~= nil) return s .. "\n" else -- we're not in code section, check if this line starts it IsInCode = (s:find("{%%code}") ~= nil) return s:gsub("^%s*", "") .. "\n" end end a_Str = a_Str:gsub("(.-)\n", RemoveIndentIfNotInCode) -- Replace multiple line ends with {%p} and single line ends with a space, -- so that manual word-wrap in the Info.lua file doesn't wrap in the forum. a_Str = a_Str:gsub("\n\n", "{%%p}") a_Str = a_Str:gsub("\n", " ") -- Replace the generic formatting: a_Str = a_Str:gsub("{%%p}", "\n\n") a_Str = a_Str:gsub("{%%b}", "[b]"):gsub("{%%/b}", "[/b]") a_Str = a_Str:gsub("{%%i}", "[i]"):gsub("{%%/i}", "[/i]") a_Str = a_Str:gsub("{%%list}", "\n[list]"):gsub("{%%/list}", "[/list]") a_Str = a_Str:gsub("{%%li}", "\n[*]"):gsub("{%%/li}", "\n") -- Process links: {%a LinkDestination}LinkText{%/a} a_Str = a_Str:gsub("{%%a%s([^}]*)}([^{]*){%%/a}", "[url=%1]%2[/url]") -- TODO: Other formatting return a_Str end --- Replaces generic formatting with forum-specific formatting -- Also removes the single line-ends local function GithubizeString(a_Str) assert(type(a_Str) == "string") -- Remove the indentation, unless in the code tag: -- Only one code or /code tag per line is supported! local IsInCode = false local function RemoveIndentIfNotInCode(s) if (IsInCode) then -- we're in code section, check if this line terminates it IsInCode = (s:find("{%%/code}") ~= nil) return s .. "\n" else -- we're not in code section, check if this line starts it IsInCode = (s:find("{%%code}") ~= nil) return s:gsub("^%s*", "") .. "\n" end end a_Str = a_Str:gsub("(.-)\n", RemoveIndentIfNotInCode) -- Replace multiple line ends with {%p} and single line ends with a space, -- so that manual word-wrap in the Info.lua file doesn't wrap in the forum. a_Str = a_Str:gsub("\n\n", "{%%p}") a_Str = a_Str:gsub("\n", " ") -- Replace the generic formatting: a_Str = a_Str:gsub("{%%p}", "\n\n") a_Str = a_Str:gsub("{%%b}", "**"):gsub("{%%/b}", "**") a_Str = a_Str:gsub("{%%i}", "*"):gsub("{%%/i}", "*") a_Str = a_Str:gsub("{%%list}", "\n"):gsub("{%%/list}", "\n") a_Str = a_Str:gsub("{%%li}", "\n - "):gsub("{%%/li}", "") -- Process links: {%a LinkDestination}LinkText{%/a} a_Str = a_Str:gsub("{%%a%s([^}]*)}([^{]*){%%/a}", "[%2](%1)") -- TODO: Other formatting return a_Str end --- Builds an array of categories, each containing all the commands belonging to the category, -- and the category description, if available. -- Returns the array table, each item has the following format: -- { Name = "CategoryName", Description = "CategoryDescription", Commands = {{CommandString = "/cmd verb", Info = {...}}, ...}} local function BuildCategories(a_PluginInfo) -- The returned result -- This will contain both an array and a dict of the categories, to allow fast search local res = {} -- For each command add a reference to it into all of its categories: local function AddCommands(a_CmdPrefix, a_Commands) for cmd, info in pairs(a_Commands or {}) do local NewCmd = { CommandString = a_CmdPrefix .. cmd, Info = info, } if ((info.HelpString ~= nil) and (info.HelpString ~= "")) then -- Add to each specified category: local Category = info.Category if (type(Category) == "string") then Category = {Category} end for idx, cat in ipairs(Category or {""}) do local CatEntry = res[cat] if (CatEntry == nil) then -- First time we came across this category, create it: local NewCat = {Name = cat, Description = "", Commands = {NewCmd}} table.insert(res, NewCat) res[cat] = NewCat else -- We already have this category, just add the command to its list of commands: table.insert(CatEntry.Commands, NewCmd) end end -- for idx, cat - Category[] end -- if (HelpString valid) -- Recurse all subcommands: if (info.Subcommands ~= nil) then AddCommands(a_CmdPrefix .. cmd .. " ", info.Subcommands) end end -- for cmd, info - a_Commands[] end -- AddCommands() AddCommands("", a_PluginInfo.Commands) -- Assign descriptions to categories: for name, desc in pairs(a_PluginInfo.Categories or {}) do local CatEntry = res[name] if (CatEntry ~= nil) then -- The result has this category, add the description: CatEntry.Description = desc.Description end end -- Alpha-sort each category's command list: for idx, cat in ipairs(res) do table.sort(cat.Commands, function (cmd1, cmd2) return (string.lower(cmd1.CommandString) < string.lower(cmd2.CommandString)) end ) end return res end --- Returns a string specifying the command. -- If a_Command is a simple string, returns a_Command colorized to blue -- If a_Command is a table, expects members Name (full command name) and Params (command parameters), -- colorizes command name blue and params green local function GetCommandRefForum(a_Command) if (type(a_Command) == "string") then return "[color=blue]" .. a_Command .. "[/color]" end return "[color=blue]" .. a_Command.Name .. "[/color] [color=green]" .. (a_Command.Params or "") .. "[/color]" end --- Returns a string specifying the command. -- If a_CommandParams is nil, returns a_CommandName apostrophed -- If a_CommandParams is a string, apostrophes a_CommandName with a_CommandParams local function GetCommandRefGithub(a_CommandName, a_CommandParams) assert(type(a_CommandName) == "string") if (a_CommandParams == nil) then return "`" .. a_CommandName .. "`" end assert(type(a_CommandParams) == "table") if ((a_CommandParams.Params == nil) or (a_CommandParams.Params == "")) then return "`" .. a_CommandName .. "`" end assert(type(a_CommandParams.Params) == "string") return "`" .. a_CommandName .. " " .. a_CommandParams.Params .. "`" end --- Writes the specified command detailed help array to the output file, in the forum dump format local function WriteCommandParameterCombinationsForum(a_CmdString, a_ParameterCombinations, f) assert(type(a_CmdString) == "string") assert(type(a_ParameterCombinations) == "table") assert(f ~= nil) if (#a_ParameterCombinations == 0) then -- No explicit parameter combinations to write return end f:write("The following parameter combinations are recognized:\n") for idx, combination in ipairs(a_ParameterCombinations) do f:write("[color=blue]", a_CmdString, "[/color] [color=green]", combination.Params or "", "[/color]") if (combination.Help ~= nil) then f:write(" - ", ForumizeString(combination.Help)) end if (combination.Permission ~= nil) then f:write(" (Requires permission '[color=red]", combination.Permission, "[/color]')") end f:write("\n") end end --- Writes the specified command detailed help array to the output file, in the forum dump format local function WriteCommandParameterCombinationsGithub(a_CmdString, a_ParameterCombinations, f) assert(type(a_CmdString) == "string") assert(type(a_ParameterCombinations) == "table") assert(f ~= nil) if (#a_ParameterCombinations == 0) then -- No explicit parameter combinations to write return end f:write("The following parameter combinations are recognized:\n\n") for idx, combination in ipairs(a_ParameterCombinations) do f:write(GetCommandRefGithub(a_CmdString, combination)) if (combination.Help ~= nil) then f:write(" - ", GithubizeString(combination.Help)) end if (combination.Permission ~= nil) then f:write(" (Requires permission '**", combination.Permission, "**')") end f:write("\n") end end --- Writes all commands in the specified category to the output file, in the forum dump format local function WriteCommandsCategoryForum(a_Category, f) -- Write category name: local CategoryName = a_Category.Name if (CategoryName == "") then CategoryName = "General" end f:write("\n[size=Large]", ForumizeString(a_Category.DisplayName or CategoryName), "[/size]\n") -- Write description: if (a_Category.Description ~= "") then f:write(ForumizeString(a_Category.Description), "\n") end -- Write commands: f:write("\n[list]") for idx2, cmd in ipairs(a_Category.Commands) do f:write("\n[b]", cmd.CommandString, "[/b] - ", ForumizeString(cmd.Info.HelpString or "UNDOCUMENTED"), "\n") if (cmd.Info.Permission ~= nil) then f:write("Permission required: [color=red]", cmd.Info.Permission, "[/color]\n") end if (cmd.Info.DetailedDescription ~= nil) then f:write(ForumizeString(cmd.Info.DetailedDescription)) end if (cmd.Info.ParameterCombinations ~= nil) then WriteCommandParameterCombinationsForum(cmd.CommandString, cmd.Info.ParameterCombinations, f) end end f:write("[/list]\n\n") end --- Writes all commands in the specified category to the output file, in the Github dump format local function WriteCommandsCategoryGithub(a_Category, f) -- Write category name: local CategoryName = a_Category.Name if (CategoryName == "") then CategoryName = "General" end f:write("\n### ", GithubizeString(a_Category.DisplayName or CategoryName), "\n") -- Write description: if (a_Category.Description ~= "") then f:write(GithubizeString(a_Category.Description), "\n\n") end f:write("| Command | Permission | Description |\n") f:write("| ------- | ---------- | ----------- |\n") -- Write commands: for idx2, cmd in ipairs(a_Category.Commands) do f:write("|", cmd.CommandString, " | ", cmd.Info.Permission or "", " | ", GithubizeString(cmd.Info.HelpString or "UNDOCUMENTED"), "|\n") end f:write("\n\n") end local function DumpCommandsForum(a_PluginInfo, f) -- Copy all Categories from a dictionary into an array: local Categories = BuildCategories(a_PluginInfo) -- Sort the categories by name: table.sort(Categories, function(cat1, cat2) return (string.lower(cat1.Name) < string.lower(cat2.Name)) end ) if (#Categories == 0) then return end f:write("\n[size=X-Large]Commands[/size]\n") -- Dump per-category commands: for idx, cat in ipairs(Categories) do WriteCommandsCategoryForum(cat, f) end end local function DumpCommandsGithub(a_PluginInfo, f) -- Copy all Categories from a dictionary into an array: local Categories = BuildCategories(a_PluginInfo) -- Sort the categories by name: table.sort(Categories, function(cat1, cat2) return (string.lower(cat1.Name) < string.lower(cat2.Name)) end ) if (#Categories == 0) then return end f:write("\n# Commands\n") -- Dump per-category commands: for idx, cat in ipairs(Categories) do WriteCommandsCategoryGithub(cat, f) end end local function DumpAdditionalInfoForum(a_PluginInfo, f) local AInfo = a_PluginInfo.AdditionalInfo if (type(AInfo) ~= "table") then -- There is no AdditionalInfo in a_PluginInfo return end for idx, info in ipairs(a_PluginInfo.AdditionalInfo) do if ((info.Title ~= nil) and (info.Contents ~= nil)) then f:write("\n[size=X-Large]", ForumizeString(info.Title), "[/size]\n") f:write(ForumizeString(info.Contents), "\n") end end end local function DumpAdditionalInfoGithub(a_PluginInfo, f) local AInfo = a_PluginInfo.AdditionalInfo if (type(AInfo) ~= "table") then -- There is no AdditionalInfo in a_PluginInfo return end for idx, info in ipairs(a_PluginInfo.AdditionalInfo) do if ((info.Title ~= nil) and (info.Contents ~= nil)) then f:write("\n# ", GithubizeString(info.Title), "\n") f:write(GithubizeString(info.Contents), "\n") end end end --- Collects all permissions mentioned in the info, returns them as a sorted array -- Each array item is {Name = "PermissionName", Info = { PermissionInfo }} local function BuildPermissions(a_PluginInfo) -- Collect all used permissions from Commands, reference the commands that use the permission: local Permissions = a_PluginInfo.Permissions or {} local function CollectPermissions(a_CmdPrefix, a_Commands) for cmd, info in pairs(a_Commands or {}) do CommandString = a_CmdPrefix .. cmd if ((info.Permission ~= nil) and (info.Permission ~= "")) then -- Add the permission to the list of permissions: local Permission = Permissions[info.Permission] or {} Permissions[info.Permission] = Permission -- Add the command to the list of commands using this permission: Permission.CommandsAffected = Permission.CommandsAffected or {} -- First, make sure that we don't already have this command in the list, -- it may have already been present in a_PluginInfo local NewCommand = true for _, existCmd in ipairs(Permission.CommandsAffected) do if CommandString == existCmd then NewCommand = false break end end if NewCommand then table.insert(Permission.CommandsAffected, CommandString) end end -- Process the command param combinations for permissions: local ParamCombinations = info.ParameterCombinations or {} for idx, comb in ipairs(ParamCombinations) do if ((comb.Permission ~= nil) and (comb.Permission ~= "")) then -- Add the permission to the list of permissions: local Permission = Permissions[comb.Permission] or {} Permissions[info.Permission] = Permission -- Add the command to the list of commands using this permission: Permission.CommandsAffected = Permission.CommandsAffected or {} table.insert(Permission.CommandsAffected, {Name = CommandString, Params = comb.Params}) end end -- Process subcommands: if (info.Subcommands ~= nil) then CollectPermissions(CommandString .. " ", info.Subcommands) end end end CollectPermissions("", a_PluginInfo.Commands) -- Copy the list of permissions to an array: local PermArray = {} for name, perm in pairs(Permissions) do table.insert(PermArray, {Name = name, Info = perm}) end -- Sort the permissions array: table.sort(PermArray, function(p1, p2) return (p1.Name < p2.Name) end ) return PermArray end local function DumpPermissionsForum(a_PluginInfo, f) -- Get the processed sorted array of permissions: local Permissions = BuildPermissions(a_PluginInfo) if ((Permissions == nil) or (#Permissions <= 0)) then return end -- Dump the permissions: f:write("\n[size=X-Large]Permissions[/size]\n[list]\n") for idx, perm in ipairs(Permissions) do f:write(" - [color=red]", perm.Name, "[/color] - ") f:write(ForumizeString(perm.Info.Description or "")) local CommandsAffected = perm.Info.CommandsAffected or {} if (#CommandsAffected > 0) then f:write("\n[list] Commands affected:\n- ") local Affects = {} for idx2, cmd in ipairs(CommandsAffected) do table.insert(Affects, GetCommandRefForum(cmd)) end f:write(table.concat(Affects, "\n - ")) f:write("\n[/list]") end if (perm.Info.RecommendedGroups ~= nil) then f:write("\n[list] Recommended groups: ", perm.Info.RecommendedGroups, "[/list]") end f:write("\n") end f:write("[/list]") end local function DumpPermissionsGithub(a_PluginInfo, f) -- Get the processed sorted array of permissions: local Permissions = BuildPermissions(a_PluginInfo) if ((Permissions == nil) or (#Permissions <= 0)) then return end -- Dump the permissions: f:write("\n# Permissions\n") f:write("| Permissions | Description | Commands | Recommended groups |\n") f:write("| ----------- | ----------- | -------- | ------------------ |\n") for idx, perm in ipairs(Permissions) do f:write("| ", perm.Name, " | ") f:write(GithubizeString(perm.Info.Description or ""), " | ") local CommandsAffected = perm.Info.CommandsAffected or {} if (#CommandsAffected > 0) then local Affects = {} for idx2, cmd in ipairs(CommandsAffected) do if (type(cmd) == "string") then table.insert(Affects, GetCommandRefGithub(cmd)) else table.insert(Affects, GetCommandRefGithub(cmd.Name, cmd)) end end f:write(table.concat(Affects, ", ")) end f:write(" | ") if (perm.Info.RecommendedGroups ~= nil) then f:write(perm.Info.RecommendedGroups) end f:write(" |\n") end end --- Dumps the forum-format info for the plugin -- Returns true on success, nil and error message on failure local function DumpPluginInfoForum(a_PluginFolder, a_PluginInfo) -- Open the output file: local f, msg = io.open(a_PluginFolder .. "/forum_info.txt", "w") if (f == nil) then return nil, msg end -- Write the description: f:write(ForumizeString(a_PluginInfo.Description), "\n") DumpAdditionalInfoForum(a_PluginInfo, f) DumpCommandsForum(a_PluginInfo, f) DumpPermissionsForum(a_PluginInfo, f) if (a_PluginInfo.SourceLocation ~= nil) then f:write("\n[b]Source[/b]: ", a_PluginInfo.SourceLocation, "\n") end if (a_PluginInfo.DownloadLocation ~= nil) then f:write("[b]Download[/b]: ", a_PluginInfo.DownloadLocation) end f:close() return true end --- Dumps the README.md file into the plugin's folder with the GitHub Markdown format -- Returns true on success, nil and error message on failure local function DumpPluginInfoGithub(a_PluginFolder, a_PluginInfo) -- Check the params: assert(type(a_PluginFolder) == "string") assert(type(a_PluginInfo) == "table") -- Open the output file: local f, msg = io.open(a_PluginFolder .. "/README.md", "w") if (f == nil) then print("\tCannot dump github info for plugin " .. a_PluginFolder .. ": " .. msg) return nil, msg end -- Write the description: f:write(GithubizeString(a_PluginInfo.Description), "\n") DumpAdditionalInfoGithub(a_PluginInfo, f) DumpCommandsGithub(a_PluginInfo, f) DumpPermissionsGithub(a_PluginInfo, f) f:close() return true end --- Tries to load the g_PluginInfo from the plugin's Info.lua file -- Returns the g_PluginInfo table on success, or nil and error message on failure local function LoadPluginInfo(a_FolderName) -- Load and compile the Info file: local cfg, err = loadfile(a_FolderName .. "/Info.lua") if (cfg == nil) then return nil, "Cannot open 'Info.lua': " .. err end -- Execute the loaded file in a sandbox: -- This is Lua-5.1-specific and won't work in Lua 5.2! local Sandbox = {} setfenv(cfg, Sandbox) local isSuccess, errMsg = pcall(cfg) if not(isSuccess) then return nil, "Cannot load Info.lua: " .. (errMsg or "<unknown error>") end if (Sandbox.g_PluginInfo == nil) then return nil, "Info.lua doesn't contain the g_PluginInfo declaration" end return Sandbox.g_PluginInfo end --- Processes the info for one plugin -- Returns true on success, nil and error message on failure local function ProcessPluginFolder(a_FolderName) -- Load the plugin info: local PluginInfo, Msg = LoadPluginInfo(a_FolderName) if (PluginInfo == nil) then return nil, "Cannot load info for plugin " .. a_FolderName .. ": " .. (Msg or "<unknown error>") end -- Dump the forum format: local isSuccess isSuccess, Msg = DumpPluginInfoForum(a_FolderName, PluginInfo) if not(isSuccess) then return nil, "Cannot dump forum info for plugin " .. a_FolderName .. ": " .. (Msg or "<unknown error>") end -- Dump the GitHub format: isSuccess, Msg = DumpPluginInfoGithub(a_FolderName, PluginInfo) if not(isSuccess) then return nil, "Cannot dump GitHub info for plugin " .. a_FolderName .. ": " .. (Msg or "<unknown error>") end -- All OK, return success return true end --- Tries to load LFS through LuaRocks, returns the LFS instance, or nil on error local function LoadLFS() -- Try to load lfs, do not abort if not found ... local lfs, err = pcall( function() return require("lfs") end ) -- ... rather, print a nice message with instructions: if not(lfs) then print([[ Cannot load LuaFileSystem Install it through luarocks by executing the following command: luarocks install luafilesystem (Windows) sudo luarocks install luafilesystem (*nix) If you don't have luarocks installed, you need to install them using your OS's package manager, usually: sudo apt-get install luarocks (Ubuntu / Debian) On windows, a binary distribution can be downloaded from the LuaRocks homepage, http://luarocks.org/en/Download ]]) print("Original error text: ", err) return nil end -- We now know that LFS is present, get it normally: return require("lfs") end local Arg1 = arg[1] if ((Arg1 ~= nil) and (Arg1 ~= "")) then -- Called with a plugin folder name, export only that one local isSuccess, msg = ProcessPluginFolder(Arg1) if not(isSuccess) then print(msg or "<unknown error>") end else -- Called without any arguments, process all subfolders: local lfs = LoadLFS() if (lfs == nil) then -- LFS not loaded, error has already been printed, just bail out return end print("Processing plugin subfolders:") for fnam in lfs.dir(".") do if ((fnam ~= ".") and (fnam ~= "..")) then local Attributes = lfs.attributes(fnam) if (Attributes ~= nil) then if (Attributes.mode == "directory") then print(fnam) local isSuccess, msg = ProcessPluginFolder(fnam) if not(isSuccess) then print(" " .. (msg or "<unknown error>")) end end end end end end print("Done.")
apache-2.0
niessner/Matterport
tasks/surface_normal/config.lua
1
2671
require "utils" --- All parameters goes here local config = config or {} function config.parse(arg) local cmd = torch.CmdLine() cmd:text() cmd:text('Multi-Task Classification FCN') cmd:text() -- Parameters -- model configuration cmd:option('-model', 'model_deep.lua', 'model file') cmd:option('-input_channel', 3, '# of input channels') cmd:option('-output_channel', 3, '# of output channels') -- testing cmd:option('-test_model', '', 'model used for testing') cmd:option('-result_path', './result/', 'path to save result') cmd:option('-max_count', 1000000, 'max number of data to test') -- data loader cmd:option('-root_path', '~/matterport/v1/', 'path to the root of the dataset') cmd:option('-train_file', './data_list/train_list_noup.txt', 'train file, compulsory'); cmd:option('-test_file', './data_list/test_list_horizontal_small.txt', 'test file, compulsory'); -- training and testing cmd:option('-gpuid', 1, 'gpu id') cmd:option('-optim_state', {rho=0.95, eps=1e-6, learningRate=1e-3, learningRateMin=1e-7, momentum=0.9}, 'optim state') cmd:option('-lr_decay', 150000, 'iterations between lr decreses') cmd:option('-lr_decay_t', 5, 'lr decay times') cmd:option('-nb_epoch', 20, 'number of epoches') cmd:option('-batch_size', 1, 'batch size') cmd:option('-pixel_means', {128, 128, 128}, 'Pixel mean values (RGB order)') -- resume cmd:option('-resume_training', false, 'whether resume training') cmd:option('-saved_model_weights', '', 'path to saved model weights') cmd:option('-saved_optim_state', '', 'path to saved model weights') -- finetune cmd:option('-finetune', false, '') cmd:option('-finetune_model', '', '') cmd:option('-finetune_init_lr', 1e-4, '') -- save/print/log cmd:option('-snapshot_iters', 10000, 'Iterations between snapshots (used for saving the network)') cmd:option('-print_iters', 20, 'Iterations between print') cmd:option('-log_iters', 20, 'Iterations between log') cmd:option('-log_path','./logs/','Path to be used for logging') cmd:option('-ps', '', 'prefix: path&name to model and snapshot') cmd:option('-verbose', false, 'show more message') -- Parsing the command line config = cmd:parse(arg or {}) config.colors = {{0, 0, 0}, -- black {1, 0, 0}, -- red {0, 1, 0}, -- green {0, 0, 1}, -- blue {1, 1, 0}, -- yellow {1, 0, 1}, -- magenta {0, 1, 1}, -- cyan {1, 1, 1} -- white } return config end return config
mit
nesstea/darkstar
scripts/globals/spells/poisonga.lua
26
1126
----------------------------------------- -- Spell: Poisonga ----------------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) local effect = EFFECT_POISON; local duration = 60; local pINT = caster:getStat(MOD_INT); local mINT = target:getStat(MOD_INT); local dINT = (pINT - mINT); local power = caster:getSkillLevel(ENFEEBLING_MAGIC_SKILL) / 20 + 1; if power > 6 then power = 6; end local resist = applyResistanceEffect(caster,spell,target,dINT,ENFEEBLING_MAGIC_SKILL,0,effect); if (resist == 1 or resist == 0.5) then -- effect taken duration = duration * resist; if (target:addStatusEffect(effect,power,3,duration)) then spell:setMsg(236); else spell:setMsg(75); end else -- resist entirely. spell:setMsg(85); end return effect; end;
gpl-3.0
VurtualRuler98/kswep2-NWI
lua/ins_sounds/sounds_kar98k.lua
1
2916
if (SERVER) then AddCSLuaFile() end --kar98 sound.Add({ name="Weapon_kar98.Single", volume = 1.0, pitch = {100,105}, sound = "weapons/kar98/kar98_fp.wav", level = 142, channel = CHAN_STATIC }) sound.Add({ name="Weapon_kar98.MagIn", volume = 0.2, sound = "weapons/kar98/handling/kar98_magin.wav", level = 65, channel = CHAN_ITEM }) sound.Add({ name="Weapon_kar98.MagFetch", volume = 0.3, sound = "weapons/kar98/handling/kar98_fetchmag.wav", level = 65, channel = CHAN_ITEM }) sound.Add({ name="Weapon_kar98.Magin", volume = 0.2, sound = "weapons/kar98/handling/kar98_magin.wav", level = 65, channel = CHAN_ITEM }) sound.Add({ name="Weapon_kar98.Magout", volume = 0.2, sound = "weapons/kar98/handling/kar98_magout.wav", level = 65, channel = CHAN_ITEM }) sound.Add({ name="Weapon_kar98.MagHit", volume = 0.2, sound = "weapons/kar98/handling/kar98_maghit.wav", level = 65, channel = CHAN_ITEM }) sound.Add({ name="Weapon_kar98.Rattle", volume = 0.2, sound = "weapons/kar98/handling/kar98_rattle.wav", level = 65, channel = CHAN_ITEM }) sound.Add({ name="Weapon_kar98.Roundin", volume = 0.2, sound = "weapons/kar98/handling/kar98_bulletin_1.wav", level = 65, channel = CHAN_ITEM }) sound.Add({ name="Weapon_kar98.ClipRemove", volume = 0.2, sound = "weapons/kar98/handling/kar98_clipremove.wav", level = 65, channel = CHAN_ITEM }) sound.Add({ name="Weapon_kar98.RoundsIn", volume = 0.2, sound = "weapons/kar98/handling/kar98_RoundsIn.wav", level = 65, channel = CHAN_ITEM }) sound.Add({ name="Weapon_kar98.Melee", volume = 0.3, sound = "weapons/universal/weapon_melee_01.wav", level = 65, channel = CHAN_STATIC }) sound.Add({ name="Weapon_kar98.Boltback", volume = 0.3, sound = "weapons/kar98/handling/kar98_boltback.wav", level = 65, channel = CHAN_ITEM }) sound.Add({ name="Weapon_kar98.Boltforward", volume = 0.2, sound = "weapons/kar98/handling/kar98_boltforward.wav", level = 65, channel = CHAN_ITEM }) sound.Add({ name="Weapon_kar98.BoltforwardStripperClip", volume = 0.2, sound = "weapons/kar98/handling/kar98_boltforward_stripperclip.wav", level = 65, channel = CHAN_ITEM }) sound.Add({ name="Weapon_kar98.StripperClipEject", volume = 0.2, sound = "weapons/kar98/handling/kar98_stripperclip_eject.wav", level = 65, channel = CHAN_ITEM }) sound.Add({ name="Weapon_kar98.BoltLatch", volume = 0.2, sound = "weapons/kar98/handling/kar98_boltlatch.wav", level = 65, channel = CHAN_ITEM }) sound.Add({ name="Weapon_kar98.BoltRelease", volume = 0.2, sound = "weapons/kar98/handling/kar98_boltrelease.wav", level = 65, channel = CHAN_ITEM }) sound.Add({ name="Weapon_kar98.Boltrelease", volume = 0.3, sound = "weapons/kar98/handling/kar98_boltrelease.wav", level = 65, channel = CHAN_ITEM }) sound.Add({ name="weapon_kar98.Empty", volume=0.2, level=65, sound="weapons/kar98/handling/kar98_empty.wav", channel = CHAN_ITEM })
apache-2.0
nesstea/darkstar
scripts/zones/Castle_Oztroja/npcs/Tebhi.lua
13
1053
----------------------------------- -- Area: Castle Oztroja -- NPC: Tebhi -- @pos -136 24 -21 151 ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if (trade:hasItemQty(13121,1) and trade:getItemCount() == 1) then -- Trade Beast collar player:tradeComplete(); -- Tebhi disappears for 15min -------------- NOT IMPLEMENTED player:setVar("scatIntoShadowCS",2); end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) 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); end;
gpl-3.0
UnfortunateFruit/darkstar
scripts/zones/Windurst_Woods/npcs/Ju_Kamja.lua
38
1032
---------------------------------- -- Area: Windurst Woods -- NPC: Ju Kamja -- Type: Item Deliverer -- @zone: 241 -- @pos 58.145 -2.5 -136.91 -- ----------------------------------- package.loaded["scripts/zones/Windurst_Woods/TextIDs"] = nil; require("scripts/zones/Windurst_Woods/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc, ITEM_DELIVERY_DIALOG); player:openSendBox(); 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/Maze_of_Shakhrami/npcs/Ahko_Mhalijikhari.lua
19
1922
----------------------------------- -- Area: Maze of Shakhrami -- NPC: Ahko Mhalijikhari -- Type: Quest NPC -- @pos -344.617 -12.226 -166.233 198 -- 0x003d 0x003e 0x003f 0x0040 0x0041 ----------------------------------- package.loaded["scripts/zones/Maze_of_Shakhrami/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Maze_of_Shakhrami/TextIDs"); require("scripts/globals/settings"); require("scripts/globals/quests"); require("scripts/globals/keyitems"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) --player:startEvent(0x0040); if(player:getQuestStatus(WINDURST,ECO_WARRIOR_WIN) ~= QUEST_AVAILABLE and player:getVar("ECO_WARRIOR_ACTIVE") == 238) then if(player:hasKeyItem(INDIGESTED_MEAT)) then player:startEvent(0x0041); -- After NM's dead elseif(player:hasStatusEffect(EFFECT_LEVEL_RESTRICTION) == false) then player:startEvent(0x003e); -- else player:startEvent(0x0040); end else player:startEvent(0x003d); -- default 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 == 0x003e and option == 1) then player:addStatusEffect(EFFECT_LEVEL_RESTRICTION,20,0,0); elseif(csid == 0x0041) then player:setVar("ECOR_WAR_WIN-NMs_killed",0); player:delStatusEffect(EFFECT_LEVEL_RESTRICTION); elseif(csid == 0x0040) then player:delStatusEffect(EFFECT_LEVEL_RESTRICTION); end end;
gpl-3.0
niessner/Matterport
tasks/surface_normal/main_train_matterport.lua
1
5254
require 'nn' require 'cutorch' require 'cunn' require 'cudnn' require 'nngraph' require 'optim' require 'BatchIterator' require 'utils' require 'utils_matterport' require 'BatchIterator_matterport' -- config local config = dofile('config.lua') -- print(arg) config = config.parse(arg) -- print(config) cutorch.setDevice(config.gpuid) print("Start: " .. config.ps) -- model local model = dofile(config.model)(config) parameters, gradParameters = model:getParameters() model:cuda() parameters, gradParameters = model:getParameters() -- resume training if config.resume_training then print('loading saved model weight...') parameters:copy(torch.load(config.saved_model_weights)) config.optim_state = torch.load(config.saved_optim_state) end if config.finetune then print('finetune from saved model weight...') parameters:copy(torch.load(config.finetune_model)) print('set up learning rate...') config.optim_state.learningRate = config.finetune_init_lr end -- criterion local criterion_n = nn.CosineEmbeddingCriterion():cuda() -- dataset local train_data = loadMatterport(config.train_file, config.root_path) local test_data = loadMatterport(config.test_file, config.root_path) local batch_iterator = BatchIterator(config, train_data, test_data) -- logger local logger = optim.Logger(config.log_path .. 'log', true) -- main training for it_batch = 1, math.floor(config.nb_epoch * #batch_iterator.train.data / config.batch_size) do -- print(">>") local batch = batch_iterator:nextBatchMatterport('train', config) -- print(batch.norm_valid:size()) -- print("batch done") -- print('4') -- print(batch_iterator:currentName('train')) -- image.save('color.png', batch.pr_color[1]:add(0.5)) -- image.save('norml.png', batch.cam_normal[1]:add(1):mul(0.5)) -- image.save('valid.png', batch.norm_valid[1]) -- image.load() -- print(batch.input:size()) -- local temp = batch.input[{1,{},{},{}}]:view(3,240,320) -- image.save('color1.png', temp:add(0.5)) -- temp = batch.input[{3,{},{},{}}]:view(3,240,320) -- image.save('color3.png', temp:add(0.5)) -- temp = batch.input[{5,{},{},{}}]:view(3,240,320) -- image.save('color5.png', temp:add(0.5)) -- inputs and targets local inputs = batch.pr_color inputs = inputs:contiguous():cuda() -- print(inputs:size()) local feval = function(x) -- prepare collectgarbage() if x ~= parameters then parameters:copy(x) end -- forward propagation -- print('111') local est = model:forward(inputs) -- print(est:size()) local valid = batch.norm_valid valid = valid:cuda() local gnd = batch.cam_normal gnd = gnd:cuda() bz, ch, h, w = est:size(1), est:size(2), est:size(3), est:size(4) est = est:permute(1,3,4,2):contiguous():view(-1,ch) local normalize_layer = nn.Normalize(2):cuda() est_n = normalize_layer:forward(est) gnd = gnd:permute(1,3,4,2):contiguous():view(-1,ch) -- print(est_n:size()) -- print(gnd:size()) f = criterion_n:forward({est_n, gnd}, torch.Tensor(est_n:size(1)):cuda():fill(1)) df = criterion_n:backward({est_n, gnd}, torch.Tensor(est_n:size(1)):cuda():fill(1)) -- print(df) df = df[1] -- print(df:size()) df = normalize_layer:backward(est, df) -- print(valid:size()) valid = valid:view(-1,1):expandAs(df) -- print(valid:size()) df[torch.eq(valid,0)] = 0 df = df:view(-1, h, w, ch) df = df:permute(1, 4, 2, 3):contiguous() gradParameters:zero() model:backward(inputs, df) -- print if it_batch % config.print_iters == 0 then print( it_batch, f) end -- log if it_batch % config.log_iters == 0 then -- logger:add{['normal_loss'] = f} -- logger:add{['segmentation_loss'] = fs} -- logger:add{ f_normal, f_semantic, f_boundary, f_room} logger:add{ f } end -- return -- return f_normal + f_semantic + f_boundary + f_room, gradParameters return f, gradParameters end -- optimizer optim.rmsprop(feval, parameters, config.optim_state) -- save if it_batch % config.snapshot_iters == 0 then print('saving model weight...') local filename filename = config.ps .. 'iter_' .. it_batch .. '.t7' torch.save(filename, parameters) filename = config.ps .. 'iter_' .. it_batch .. '_state.t7' torch.save(filename, config.optim_state) end -- lr if it_batch % config.lr_decay == 0 then config.optim_state.learningRate = config.optim_state.learningRate / config.lr_decay_t config.optim_state.learningRate = math.max(config.optim_state.learningRate, config.optim_state.learningRateMin) print('decresing lr... new lr:', config.optim_state.learningRate) end end print('saving model weight...') local filename filename = config.ps .. 'final' .. '.t7' torch.save(filename, parameters) filename = config.ps .. 'final' .. '_state.t7' torch.save(filename, config.optim_state)
mit
kidanger/Drystal
tests/graphics/filter.lua
1
1410
local drystal = require 'drystal' local spritesheet = assert(drystal.fromjson(io.open('image.json'):read('*all'))) local image = assert(drystal.load_surface(spritesheet.meta.image)) drystal.resize(600, 400) image:draw_from() local spritesrc = spritesheet.frames['character.png'].frame local sprite = drystal.new_sprite(spritesrc, 300, 180) sprite.angle = math.pi/3 local sprite2 = drystal.new_sprite(spritesrc, 220, 180, spritesrc.w*2, spritesrc.h*2) sprite2.angle = math.pi/2 local sprite3 = drystal.new_sprite(spritesrc, 350, 180, spritesrc.w*2, spritesrc.h*2) sprite3.angle = math.pi/2 function drystal.draw() drystal.draw_background() sprite:draw() sprite2:draw() sprite3:draw() local t = { angle=0, wfactor=1, hfactor=1, } drystal.draw_sprite({x=spritesrc.x, y=spritesrc.y, w=spritesrc.w, h=spritesrc.h}, 300, 220, t) end function drystal.key_press(k) if k == '[1]' then image:set_filter(drystal.filters.nearest) elseif k == '[2]' then image:set_filter(drystal.filters.linear) elseif k == '[3]' then image:set_filter(drystal.filters.bilinear) elseif k == '[4]' then image:set_filter(drystal.filters.trilinear) elseif k == 'a' then drystal.stop() end end function drystal.mouse_press(x, y, b) if b == drystal.WHEEL_UP then drystal.camera.zoom = drystal.camera.zoom * 1.2 elseif b == drystal.WHEEL_DOWN then drystal.camera.zoom = drystal.camera.zoom / 1.2 end end
gpl-3.0
nesstea/darkstar
scripts/zones/Palborough_Mines/npcs/_3z8.lua
13
1521
----------------------------------- -- Area: Palborough Mines -- NPC: Refiner Lever -- Involved In Mission: Journey Abroad -- @zone 143 -- @pos 180 -32 167 ----------------------------------- package.loaded["scripts/zones/Palborough_Mines/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/zones/Palborough_Mines/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:getVar("refiner_input") > 0) then player:startEvent(0x0011,1,1,1,1,1,1,1,1); -- machine is working, you hear the sound of metal hitting metal down below. refiner_output = player:getVar("refiner_output"); player:setVar("refiner_output",refiner_output + player:getVar("refiner_input")); player:setVar("refiner_input",0) else player:startEvent(0x0011); -- machine is working, but you cannot discern its purpose. 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
Ale32bit/Osmium
src/vfs.lua
1
2603
local UserPath = ".UserData" local native = {} for k,v in pairs(_G.fs) do native[k] = v end local fs = {} local function getPath(path) --Failsafe local fullPath = native.combine(path or "","") local basedrive = (native.getDrive(fullPath) or native.getDrive(native.getDir(fullPath))) if basedrive and basedrive ~= "hdd" then return fullPath end if fullPath:sub(1,#UserPath) == UserPath then return fullPath end --End failsafe fullPath = native.combine(UserPath,fullPath) if fullPath:sub(1,#UserPath) == UserPath then return fullPath else error("Path doesn't exist",2) end end --shell.setDir("/.UserData/") fs.open = function(file,mode) return native.open(getPath(file),mode) end fs.list = function(path) if native.combine(path,"") == "" then local l1 = native.list(getPath(path)) local l2 = native.list(path) for i,v in pairs(l2) do if native.getDrive(v) ~= "hdd" then if v ~= "rom" then table.insert(l1,v) end end end return l1 end return native.list(getPath(path)) end fs.exists = function(path) return native.exists(getPath(path)) end fs.isDir = function(path) return native.isDir(getPath(path)) end fs.isReadOnly = function(path) return native.isReadOnly(getPath(path)) end fs.getName = function(path) return native.getName(getPath(path)) end fs.getDrive = function(path) return native.getDrive(getPath(path)) end fs.getSize = function(path) return native.getSize(getPath(path)) end fs.getFreeSpace = function(path) return native.getFreeSpace(getPath(path)) end fs.makeDir = function(path) return native.makeDir(getPath(path)) end fs.move = function(path,target) return native.move(getPath(path), getPath(target)) end fs.copy = function(path,target) return native.copy(getPath(path),getPath(target)) end fs.delete = function(path) return native.delete(getPath(path)) end fs.find = function(wildcard) local data = native.find(getPath(wildcard)) local data2 = {} for i,v in pairs(data) do if v:sub(1,#UserPath) == UserPath then data2[i] = v:sub(string.len("./UserData")) else data2[i] = v end end return data2 end fs.getDir = function(path) return native.getDir(getPath(path)) end fs.complete = function(sName, path, _third, _fourth) return native.complete(sName,getPath(path),_third,_fourth) end fs.combine = function(first,second) return native.combine(first,second) end _G.fs = fs
gpl-3.0
nesstea/darkstar
scripts/globals/items/rolanberry.lua
18
1176
----------------------------------------- -- ID: 4365 -- Item: rolanberry -- Food Effect: 5Min, All Races ----------------------------------------- -- Agility -4 -- Intelligence 2 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,300,4365); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_AGI, -4); target:addMod(MOD_INT, 2); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_AGI, -4); target:delMod(MOD_INT, 2); end;
gpl-3.0
UnfortunateFruit/darkstar
scripts/globals/items/black_ghost.lua
18
1259
----------------------------------------- -- ID: 5138 -- Item: Black Ghost -- Food Effect: 5Min, Mithra only ----------------------------------------- -- Dexterity 4 -- Mind -6 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) result = 0 if (target:getRace() ~= 7) then result = 247; end if(target:getMod(MOD_EAT_RAW_FISH) == 1) then result = 0; end 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,300,5138); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_DEX, 4); target:addMod(MOD_MND, -6); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_DEX, 4); target:delMod(MOD_MND, -6); end;
gpl-3.0
UnfortunateFruit/darkstar
scripts/globals/items/blacksmiths_belt.lua
30
1204
----------------------------------------- -- ID: 15445 -- Item: Blacksmith's Belt -- Enchantment: Synthesis image support -- 2Min, All Races ----------------------------------------- -- Enchantment: Synthesis image support -- Duration: 2Min -- Smithing Skill +3 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_SMITHING_IMAGERY) == true) then result = 237; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_SMITHING_IMAGERY,3,0,120); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_SKILL_SMT, 1); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_SKILL_SMT, 1); end;
gpl-3.0
nesstea/darkstar
scripts/zones/Northern_San_dOria/npcs/Vavegallet.lua
13
1406
----------------------------------- -- Area: Northern San d'Oria -- NPC: Vavegallet -- Standard Info NPC ----------------------------------- package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/quests"); require("scripts/zones/Northern_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- "Flyers for Regine" conditional script FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE); if (FlyerForRegine == 1) then count = trade:getItemCount(); MagicFlyer = trade:hasItemQty(532,1); if (MagicFlyer == true and count == 1) then player:messageSpecial(FLYER_REFUSED); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(673); 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
abasshacker/extreme
plugins/sticker.lua
18
19218
do local administrators_only = 'For administrator only!' local moderators_only = 'For moderators only!' local function create_group(msg) if not is_admin(msg) then return administrators_only end 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 local function addgroup(msg) if not is_admin(msg) then return administrators_only end local data = load_data(_config.moderation.data) if data[tostring(msg.to.id)] then return 'Group is already added.' end -- create data array in moderation.json data[tostring(msg.to.id)] = { moderators ={}, settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_bots = 'no', lock_name = 'no', lock_photo = 'no', lock_member = 'no', anti_flood = 'no', welcome = 'no', sticker = 'ok' } } save_data(_config.moderation.data, data) return 'Group has been added.' end local function remgroup(msg) if not is_admin(msg) then return administrators_only end local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) if not data[tostring(msg.to.id)] then return 'Group is not added.' end data[tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) return 'Group has been removed' end local function export_chat_link_callback(extra, success, result) local msg = extra.msg local group_name = msg.to.title local data = extra.data local receiver = get_receiver(msg) if success == 0 then return send_large_msg(receiver, 'Cannot generate invite link for this group.\nMake sure you are an admin or a sudoer.') end data[tostring(msg.to.id)]['link'] = result save_data(_config.moderation.data, data) return send_large_msg(receiver,'Newest generated invite link for '..group_name..' is:\n'..result) end local function set_description(msg, data) if not is_mod(msg) then return moderators_only end local data_cat = 'description' data[tostring(msg.to.id)][data_cat] = deskripsi save_data(_config.moderation.data, data) return 'Set group description to:\n'..deskripsi end local function get_description(msg, data) local data_cat = 'description' if not data[tostring(msg.to.id)][data_cat] then return 'No description available.' end local about = data[tostring(msg.to.id)][data_cat] return string.gsub(msg.to.print_name, "_", " ")..':\n\n'..about end local function set_rules(msg, data) if not is_mod(msg) then return moderators_only end local data_cat = 'rules' data[tostring(msg.to.id)][data_cat] = rules save_data(_config.moderation.data, data) return 'Set group rules to:\n'..rules end local function get_rules(msg, data) local data_cat = 'rules' if not data[tostring(msg.to.id)][data_cat] then return 'No rules available.' end local rules = data[tostring(msg.to.id)][data_cat] local rules = string.gsub(msg.to.print_name, '_', ' ')..' rules:\n\n'..rules return rules end -- dis/allow APIs bots to enter group. Spam prevention. local function allow_api_bots(msg, data) if not is_mod(msg) then return moderators_only end local group_bot_lock = data[tostring(msg.to.id)]['settings']['lock_bots'] if group_bot_lock == 'no' then return 'Bots are allowed to enter group.' else data[tostring(msg.to.id)]['settings']['lock_bots'] = 'no' save_data(_config.moderation.data, data) return 'Group is open for bots.' end end local function disallow_api_bots(msg, data) if not is_mod(msg) then return moderators_only end local group_bot_lock = data[tostring(msg.to.id)]['settings']['lock_bots'] if group_bot_lock == 'yes' then return 'Group is already locked from bots.' else data[tostring(msg.to.id)]['settings']['lock_bots'] = 'yes' save_data(_config.moderation.data, data) return 'Group is locked from bots.' end end -- lock/unlock group name. bot automatically change group name when locked local function lock_group_name(msg, data) if not is_mod(msg) then return moderators_only end local group_name_set = data[tostring(msg.to.id)]['settings']['set_name'] local group_name_lock = data[tostring(msg.to.id)]['settings']['lock_name'] if group_name_lock == 'yes' then return 'Group name is already locked' else data[tostring(msg.to.id)]['settings']['lock_name'] = 'yes' save_data(_config.moderation.data, data) data[tostring(msg.to.id)]['settings']['set_name'] = string.gsub(msg.to.print_name, '_', ' ') save_data(_config.moderation.data, data) return 'Group name has been locked' end end local function unlock_group_name(msg, data) if not is_mod(msg) then return moderators_only end local group_name_set = data[tostring(msg.to.id)]['settings']['set_name'] local group_name_lock = data[tostring(msg.to.id)]['settings']['lock_name'] if group_name_lock == 'no' then return 'Group name is already unlocked' else data[tostring(msg.to.id)]['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) if not is_mod(msg) then return moderators_only end local group_member_lock = data[tostring(msg.to.id)]['settings']['lock_member'] if group_member_lock == 'yes' then return 'Group members are already locked' else data[tostring(msg.to.id)]['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) if not is_mod(msg) then return moderators_only end local group_member_lock = data[tostring(msg.to.id)]['settings']['lock_member'] if group_member_lock == 'no' then return 'Group members are not locked' else data[tostring(msg.to.id)]['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) if not is_mod(msg) then return moderators_only end local group_photo_lock = data[tostring(msg.to.id)]['settings']['lock_photo'] if group_photo_lock == 'yes' then return 'Group photo is already locked' else data[tostring(msg.to.id)]['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) if not is_mod(msg) then return moderators_only end local group_photo_lock = data[tostring(msg.to.id)]['settings']['lock_photo'] if group_photo_lock == 'no' then return 'Group photo is not locked' else data[tostring(msg.to.id)]['settings']['lock_photo'] = 'no' save_data(_config.moderation.data, data) return 'Group photo has been unlocked' end end local function set_group_photo(msg, success, result) local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) if success then local file = 'data/photos/chat_photo_'..msg.to.id..'.jpg' print('File downloaded to:', result) os.rename(result, file) print('File moved to:', file) chat_set_photo (receiver, file, ok_cb, false) data[tostring(msg.to.id)]['settings']['set_photo'] = file save_data(_config.moderation.data, data) data[tostring(msg.to.id)]['settings']['lock_photo'] = 'yes' save_data(_config.moderation.data, data) send_large_msg(receiver, 'Photo saved!', ok_cb, false) else print('Error downloading: '..msg.id) send_large_msg(receiver, 'Failed, please try again!', ok_cb, false) end end -- show group settings local function show_group_settings(msg, data) if not is_mod(msg) then return moderators_only end local settings = data[tostring(msg.to.id)]['settings'] if settings.lock_bots == 'yes' then lock_bots_state = 'ู‹ฺบโ€โ€™' elseif settings.lock_bots == 'no' then lock_bots_state = 'ู‹ฺบโ€โ€œ' end if settings.lock_name == 'yes' then lock_name_state = 'ู‹ฺบโ€โ€™' elseif settings.lock_name == 'no' then lock_name_state = 'ู‹ฺบโ€โ€œ' end if settings.lock_photo == 'yes' then lock_photo_state = 'ู‹ฺบโ€โ€™' elseif settings.lock_photo == 'no' then lock_photo_state = 'ู‹ฺบโ€โ€œ' end if settings.lock_member == 'yes' then lock_member_state = 'ู‹ฺบโ€โ€™' elseif settings.lock_member == 'no' then lock_member_state = 'ู‹ฺบโ€โ€œ' end if settings.anti_flood ~= 'no' then antiflood_state = 'ู‹ฺบโ€โ€™' elseif settings.anti_flood == 'no' then antiflood_state = 'ู‹ฺบโ€โ€œ' end if settings.welcome ~= 'no' then greeting_state = 'ู‹ฺบโ€โ€™' elseif settings.welcome == 'no' then greeting_state = 'ู‹ฺบโ€โ€œ' end if settings.sticker ~= 'ok' then sticker_state = 'ู‹ฺบโ€โ€™' elseif settings.sticker == 'ok' then sticker_state = 'ู‹ฺบโ€โ€œ' end local text = 'Group settings:\n' ..'\n'..lock_bots_state..' Lock group from bot : '..settings.lock_bots ..'\n'..lock_name_state..' Lock group name : '..settings.lock_name ..'\n'..lock_photo_state..' Lock group photo : '..settings.lock_photo ..'\n'..lock_member_state..' Lock group member : '..settings.lock_member ..'\n'..antiflood_state..' Flood protection : '..settings.anti_flood ..'\n'..greeting_state..' Welcome message : '..settings.welcome ..'\n'..sticker_state..' Sticker policy : '..settings.sticker return text end -- media handler. needed by group_photo_lock local function pre_process(msg) if not msg.text and msg.media then msg.text = '['..msg.media.type..']' end return msg end function run(msg, matches) if not is_chat_msg(msg) then return "This is not a group chat." end local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) -- create a group if matches[1] == 'mkgroup' and matches[2] then group_name = matches[2] return create_group(msg) end -- add a group to be moderated if matches[1] == 'addgroup' then return addgroup(msg) end -- remove group from moderation if matches[1] == 'remgroup' then return remgroup(msg) end if msg.media and is_chat_msg(msg) and is_momod(msg) then if msg.media.type == 'photo' and data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' then load_photo(msg.id, set_group_photo, msg) end end end if data[tostring(msg.to.id)] then local settings = data[tostring(msg.to.id)]['settings'] if matches[1] == 'setabout' and matches[2] then deskripsi = matches[2] return set_description(msg, data) end if matches[1] == 'about' then return get_description(msg, data) end if matches[1] == 'setrules' then rules = matches[2] return set_rules(msg, data) end if matches[1] == 'rules' then return get_rules(msg, data) end -- group link {get|set} if matches[1] == 'link' then if matches[2] == 'get' then if data[tostring(msg.to.id)]['link'] then local about = get_description(msg, data) local link = data[tostring(msg.to.id)]['link'] return about.."\n\n"..link else return 'Invite link does not exist.\nTry !link set to generate it.' end end if matches[2] == 'set' and is_mod(msg) then msgr = export_chat_link(receiver, export_chat_link_callback, {data=data, msg=msg}) end end if matches[1] == 'group' then -- lock {bot|name|member|photo|sticker} if matches[2] == 'lock' then if matches[3] == 'bot' then return disallow_api_bots(msg, data) end if matches[3] == 'name' then return lock_group_name(msg, data) end if matches[3] == 'member' then return lock_group_member(msg, data) end if matches[3] == 'photo' then return lock_group_photo(msg, data) end -- unlock {bot|name|member|photo|sticker} elseif matches[2] == 'unlock' then if matches[3] == 'bot' then return allow_api_bots(msg, data) end if matches[3] == 'name' then return unlock_group_name(msg, data) end if matches[3] == 'member' then return unlock_group_member(msg, data) end if matches[3] == 'photo' then return unlock_group_photo(msg, data) end -- view group settings elseif matches[2] == 'settings' then return show_group_settings(msg, data) end end if not is_momod(msg) then return "Mods Only!" end if matches[1] == 'sticker' then if matches[2] == 'warn' then if welcome_stat ~= 'warn' then data[tostring(msg.to.id)]['settings']['sticker'] = 'warn' save_data(_config.moderation.data, data) end return '[Alredy Enabled]\nSticker Sender will be warned first, then kicked for second Sticker.' end if matches[2] == 'kick' then if welcome_stat ~= 'kick' then data[tostring(msg.to.id)]['settings']['sticker'] = 'kick' save_data(_config.moderation.data, data) end return '[Already Enabled]Sticker Sender will be kicked!' end if matches[2] == 'ok' then if welcome_stat == 'ok' then return '[Already Disabled]Nothing Will Happend If Sticker Sent!' else data[tostring(msg.to.id)]['settings']['sticker'] = 'ok' save_data(_config.moderation.data, data) return 'Nothing Will Happend If Sticker Sent! ' end end end -- if group name is renamed if matches[1] == 'chat_rename' then if not msg.service then return 'Are you trying to troll me?' end local group_name_set = settings.set_name local group_name_lock = settings.lock_name local to_rename = 'chat#id'..msg.to.id if group_name_lock == 'yes' then if group_name_set ~= tostring(msg.to.print_name) then rename_chat(to_rename, group_name_set, ok_cb, false) end elseif group_name_lock == 'no' then return nil end end -- set group name if matches[1] == 'setname' and is_mod(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) end -- set group photo if matches[1] == 'setphoto' and is_mod(msg) then data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting' save_data(_config.moderation.data, data) return 'Please send me new group photo now' end -- if a user is added to group if matches[1] == 'chat_add_user' then if not msg.service then return 'Are you trying to troll me?' end local group_member_lock = settings.lock_member local group_bot_lock = settings.lock_bots local user = 'user#id'..msg.action.user.id if group_member_lock == 'yes' then chat_del_user(receiver, user, ok_cb, true) -- no APIs bot are allowed to enter chat group. elseif group_bot_lock == 'yes' and msg.action.user.flags == 4352 then chat_del_user(receiver, user, ok_cb, true) elseif group_bot_lock == 'no' or group_member_lock == 'no' then return nil end end -- if sticker is sent if msg.media and msg.media.caption == 'sticker.webp' and not is_momod(msg) then local user_id = msg.from.id local chat_id = msg.to.id local sticker_hash = 'mer_sticker:'..chat_id..':'..user_id local is_sticker_offender = redis:get(sticker_hash) if settings.sticker == 'warn' then if is_sticker_offender then chat_del_user(receiver, 'user#id'..user_id, ok_cb, true) redis:del(sticker_hash) return '[Warned Before]Kicked Because You Have Sent Stickers' elseif not is_sticker_offender then redis:set(sticker_hash, true) return ' Stop Sending Sticker.This Is A Warn Next Time You Will Kicked!' end elseif settings.sticker == 'kick' then chat_del_user(receiver, 'user#id'..user_id, ok_cb, true) return 'You Kicked Because You Have Sent Stickers??' elseif settings.sticker == 'ok' then return nil end end -- if group photo is deleted if matches[1] == 'chat_delete_photo' then if not msg.service then return 'Are you trying to troll me?' end local group_photo_lock = settings.lock_photo if group_photo_lock == 'yes' then chat_set_photo (receiver, settings.set_photo, ok_cb, false) elseif group_photo_lock == 'no' then return nil end end -- if group photo is changed if matches[1] == 'chat_change_photo' and msg.from.id ~= 0 then if not msg.service then return 'Are you trying to troll me?' end local group_photo_lock = settings.lock_photo if group_photo_lock == 'yes' then chat_set_photo (receiver, settings.set_photo, ok_cb, false) elseif group_photo_lock == 'no' then return nil end end end end return { description = 'Plugin to manage group chat.', usage = { admin = { '!mkgroup <group_name> : Make/create a new group.', '!addgroup : Add group to moderation list.', '!remgroup : Remove group from moderation list.' }, moderator = { '!group <lock|unlock> bot : {Dis}allow APIs bots.', '!group <lock|unlock> member : Lock/unlock group member.', '!group <lock|unlock> name : Lock/unlock group name.', '!group <lock|unlock> photo : Lock/unlock group photo.', '!group settings : Show group settings.', '!link <set> : Generate/revoke invite link.', '!setabout <description> : Set group description.', '!setname <new_name> : Set group name.', '!setphoto : Set group photo.', '!setrules <rules> : Set group rules.', '!sticker warn : Sticker restriction, sender will be warned for the first violation.', '!sticker kick : Sticker restriction, sender will be kick.', '!sticker ok : Disable sticker restriction.' }, user = { '!about : Read group description', '!rules : Read group rules', '!link <get> : Print invite link' }, }, patterns = { --"^!(about)$", --"^!(addgroup)$", "%[(audio)%]", "%[(document)%]", --"^!(group) (lock) (.*)$", --"^!(group) (settings)$", --"^!(group) (unlock) (.*)$", --"^!(link) (.*)$", --"^!(mkgroup) (.*)$", --"%[(photo)%]", --"^!(remgroup)$", --"^!(rules)$", -- "^!(setabout) (.*)$", -- "^!(setname) (.*)$", --"^!(setphoto)$", --"^!(setrules) (.*)$", "^[!/](sticker) (.*)$", "^!!tgservice (.+)$", "%[(video)%]" }, run = run, pre_process = pre_process } end
gpl-2.0
UnfortunateFruit/darkstar
scripts/globals/mobskills/flat_blade.lua
25
1097
--------------------------------------------- -- Flat Blade -- -- Description: Delivers a four-hit attack. Chance of critical varies with TP. -- Type: Physical -- Shadow per hit -- Range: Melee --------------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/zones/Qubia_Arena/TextIDs"); require("scripts/globals/monstertpmoves"); --------------------------------------------- function onMobSkillCheck(target,mob,skill) skill:setMsg(0) target:showText(mob,FLAT_PREPARE); return 0; end; function onMobWeaponSkill(target, mob, skill) skill:setMsg(0) target:showText(mob,FLAT_LAND); skill:setSkillchain(40); local numhits = 4; local accmod = 1; local dmgmod = 1.25; local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,TP_CRIT_VARIES,1.1,1.2,1.3); local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_PHYSICAL,MOBPARAM_SLASH,info.hitslanded); -- AA EV: Approx 900 damage to 75 DRG/35 THF. 400 to a NIN/WAR in Arhat, but took shadows. target:delHP(dmg); return dmg; end;
gpl-3.0
plajjan/snabbswitch
src/apps/rate_limiter/rate_limiter.lua
1
6509
-- Use of this source code is governed by the Apache 2.0 license; see COPYING. module(..., package.seeall) local app = require("core.app") local link = require("core.link") local config = require("core.config") local packet = require("core.packet") local timer = require("core.timer") local basic_apps = require("apps.basic.basic_apps") local ffi = require("ffi") local C = ffi.C local floor, min = math.floor, math.min --- # `Rate limiter` app: enforce a byte-per-second limit -- uses http://en.wikipedia.org/wiki/Token_bucket algorithm -- single bucket, drop non-conformant packets -- bucket capacity and content - bytes -- rate - bytes per second RateLimiter = {} -- Source produces synthetic packets of such size local PACKET_SIZE = 60 function RateLimiter:new (arg) local conf = arg and config.parse_app_arg(arg) or {} assert(conf.rate) assert(conf.bucket_capacity) conf.initial_capacity = conf.initial_capacity or conf.bucket_capacity local o = { rate = conf.rate, bucket_capacity = conf.bucket_capacity, bucket_content = conf.initial_capacity } return setmetatable(o, {__index=RateLimiter}) end function RateLimiter:reset(rate, bucket_capacity, initial_capacity) assert(rate) assert(bucket_capacity) self.rate = rate self.bucket_capacity = bucket_capacity self.bucket_content = initial_capacity or bucket_capacity end -- return statistics snapshot function RateLimiter:get_stat_snapshot () return { rx = link.stats(self.input.input).txpackets, tx = link.stats(self.output.output).txpackets, time = tonumber(C.get_time_ns()), } end function RateLimiter:push () local i = assert(self.input.input, "input port not found") local o = assert(self.output.output, "output port not found") do local cur_now = tonumber(app.now()) local last_time = self.last_time or cur_now self.bucket_content = min( self.bucket_content + self.rate * (cur_now - last_time), self.bucket_capacity ) self.last_time = cur_now end while not link.empty(i) and not link.full(o) do local p = link.receive(i) local length = p.length if length <= self.bucket_content then self.bucket_content = self.bucket_content - length link.transmit(o, p) else -- discard packet packet.free(p) end end end local function compute_effective_rate (rl, rate, snapshot) local elapsed_time = (tonumber(C.get_time_ns()) - snapshot.time) / 1e9 local tx = link.stats(rl.output.output).txpackets - snapshot.tx return floor(tx * PACKET_SIZE / elapsed_time) end function selftest () print("Rate limiter selftest") local c = config.new() config.app(c, "source", basic_apps.Source) -- app.apps.source = app.new(basic_apps.Source:new()) local ok = true local rate_non_busy_loop = 200000 local effective_rate_non_busy_loop -- bytes local bucket_size = rate_non_busy_loop / 4 -- should be big enough to process packets generated by Source:pull() -- during 100 ms - internal RateLimiter timer resolution -- small value may limit effective rate local arg = { rate = rate_non_busy_loop, bucket_capacity = rate_non_busy_loop / 4 } config.app(c, "ratelimiter", RateLimiter, arg) config.app(c, "sink", basic_apps.Sink) -- Create a pipeline: -- Source --> RateLimiter --> Sink config.link(c, "source.output -> ratelimiter.input") config.link(c, "ratelimiter.output -> sink.input") app.configure(c) -- XXX do this in new () ? local rl = app.app_table.ratelimiter local seconds_to_run = 5 -- print packets statistics every second timer.activate(timer.new( "report", function () app.report() seconds_to_run = seconds_to_run - 1 end, 1e9, -- every second 'repeating' )) -- bytes per second do print("\ntest effective rate, non-busy loop") local snapshot = rl:get_stat_snapshot() -- push some packets through it while seconds_to_run > 0 do app.breathe() timer.run() C.usleep(10) -- avoid busy loop end -- print final report app.report() effective_rate_non_busy_loop = compute_effective_rate( rl, rate_non_busy_loop, snapshot ) print("configured rate is", rate_non_busy_loop, "bytes per second") print( "effective rate is", effective_rate_non_busy_loop, "bytes per second" ) local accepted_min = floor(rate_non_busy_loop * 0.9) local accepted_max = floor(rate_non_busy_loop * 1.1) if effective_rate_non_busy_loop < accepted_min or effective_rate_non_busy_loop > accepted_max then print("test failed") ok = false end end do print("measure throughput on heavy load...") -- bytes per second local rate_busy_loop = 1200000000 local effective_rate_busy_loop -- bytes local bucket_size = rate_busy_loop / 10 -- should be big enough to process packets generated by Source:pull() -- during 100 ms - internal RateLimiter timer resolution -- small value may limit effective rate -- too big value may produce burst in the beginning rl:reset(rate_busy_loop, bucket_size) local snapshot = rl:get_stat_snapshot() for i = 1, 100000 do app.breathe() timer.run() end local elapsed_time = (tonumber(C.get_time_ns()) - snapshot.time) / 1e9 print("elapsed time ", elapsed_time, "seconds") local rx = link.stats(rl.input.input).txpackets - snapshot.rx print("packets received", rx, floor(rx / elapsed_time / 1e6), "Mpps") effective_rate_busy_loop = compute_effective_rate( rl, rate_busy_loop, snapshot ) print("configured rate is", rate_busy_loop, "bytes per second") print( "effective rate is", effective_rate_busy_loop, "bytes per second" ) print( "throughput is", floor(effective_rate_busy_loop / PACKET_SIZE / 1e6), "Mpps") -- on poor computer effective rate may be too small -- so no formal checks end if not ok then print("selftest failed") os.exit(1) end print("selftest passed") end
apache-2.0
UnfortunateFruit/darkstar
scripts/zones/Xarcabard/npcs/Magumo-Yagimo_WW.lua
30
3049
----------------------------------- -- Area: Xarcabard -- NPC: Magumo-Yagimo, W.W. -- Type: Outpost Conquest Guards -- @pos 207.548 -24.795 -203.694 112 ----------------------------------- package.loaded["scripts/zones/Xarcabard/TextIDs"] = nil; ----------------------------------- require("scripts/globals/conquest"); require("scripts/zones/Xarcabard/TextIDs"); local guardnation = WINDURST; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno local guardtype = 3; -- 1: city, 2: foreign, 3: outpost, 4: border local region = VALDEAUNIA; local csid = 0x7ff7; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) tradeConquestGuard(player,npc,trade,guardnation,guardtype); end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:hasKeyItem(getSupplyKey(region)) and player:getNation() == guardnation) then if (supplyRunFresh(player) == 1) then player:startEvent(csid,16,0,0,0,1,0,0,255); -- you have brought us supplies ! else player:showText(npc, CONQUEST - 1); -- "Hmm... These supplies you have brought us are too old to be of any use." player:delKeyItem(getSupplyKey(region)); player:messageSpecial(KEYITEM_OBTAINED + 1, getSupplyKey(region)); player:setVar("supplyQuest_region",0); end else local arg1 = getArg1(guardnation, player) - 1; if (arg1 >= 1792) then -- foreign, non-allied player:startEvent(csid,1808,0,0,0,0,player:getRank(),0,0); else -- citizen or allied player:startEvent(csid,arg1,0,0x3F0000,0,0,getArg6(player),0,0); end end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("OPTION: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("OPTION: %u",option); if (option == 1) then local duration = (player:getRank() + getNationRank(player:getNation()) + 3) * 3600; player:delStatusEffect(EFFECT_SIGIL); player:delStatusEffect(EFFECT_SANCTION); player:delStatusEffect(EFFECT_SIGNET); player:addStatusEffect(EFFECT_SIGNET,0,0,duration); -- Grant Signet elseif (option == 2) then player:delKeyItem(getSupplyKey(region)); player:addCP(supplyReward[region + 1]) player:messageSpecial(CONQUEST); -- "You've earned conquest points!" if (hasOutpost(player, region+5) == 0) then local supply_quests = 2^(region+5); player:addNationTeleport(guardnation,supply_quests); player:setVar("supplyQuest_region",0); end elseif (option == 4) then if (player:delGil(giltosetHP(guardnation,player))) then player:setHomePoint(); player:messageSpecial(CONQUEST + 94); -- "Your home point has been set." else player:messageSpecial(CONQUEST + 95); -- "You do not have enough gil to set your home point here." end end end;
gpl-3.0
VurtualRuler98/kswep2-NWI
lua/weapons/weapon_kswepi2_m590.lua
1
3592
--[[ Copyright 2015 vurtual VurtualRuler98@gmail.com vurtual.org Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ]]-- if (SERVER) then AddCSLuaFile() end if (CLIENT) then SWEP.PrintName = "ins2 Mossberg 590" SWEP.Author = "vurtual" SWEP.Slot = 2 SWEP.SlotPos = 0 end SWEP.Anims = SWEP.Anims or {} SWEP.Category = "KSwep Primary" SWEP.IronSightHeight=0.625 --from an ithaca SWEP.Base = "weapon_kswep" SWEP.Primary.Delay = 0.5 SWEP.Primary.Spread = 0.0045 SWEP.Spawnable = true SWEP.DefaultZerodata= { mils=false, bc=0.05, min=50, max=50, step=0, default=50, battlesight=false } SWEP.DrawOnce=false SWEP.MagClass="Shotshell" SWEP.AdminSpawnable = true SWEP.ViewModel = "models/weapons/v_m590.mdl" SWEP.WorldModel = "models/weapons/w_shot_m3super90.mdl" SWEP.FlashlightModel="models/weapons/upgrades/a_flashlight_ins_shotgun.mdl" SWEP.LaserModel="models/weapons/upgrades/a_laser_ins_shotgun.mdl" SWEP.UseHands = false SWEP.MuzzleVelMod=1 SWEP.MagSize = 8 SWEP.MaxMags = 8 SWEP.MaxMagsBonus = 24 SWEP.Primary.ClipSize = SWEP.MagSize SWEP.Caliber = "vammo_12gauge_00buck" SWEP.Primary.Sound = Sound("Weapon_m590.Single") SWEP.Primary.SoundSup = Sound("Weapon_m590.SingleSilenced") SWEP.ViewModelFlip = false SWEP.Secondary.Ammo = "" SWEP.CurrentlyReloading=0 SWEP.ReloadAnimTime=0 SWEP.RecoilMassModifier=0.2 SWEP.HandlingModifier=200 SWEP.InsAnims=true SWEP.Auto=false SWEP.Firemode=true SWEP.HoldType="ar2" SWEP.HoldOpen=false SWEP.Length=41 SWEP.LengthSup=12 SWEP.Suppressable=true SWEP.SuppressorModel="models/weapons/upgrades/a_suppressor_12ga.mdl" SWEP.MuzzleVelModSup= 1.01 SWEP.RecoilModSup=0.85 SWEP.SpreadModSup=0 SWEP.IdleType="passive" SWEP.SelectFire=true SWEP.MagType=nil SWEP.EmptyAnims=true SWEP.Anims.MidReloadAnimEmpty=ACT_VM_RELOAD_INSERT_PULL SWEP.Anims.StartReloadAnim = ACT_VM_RELOAD SWEP.Anims.MidReloadAnim = ACT_VM_RELOAD_INSERT SWEP.Anims.EndReloadAnim = ACT_VM_RELOAD_END SWEP.Anims.MidReloadAnimEmpty=ACT_VM_RELOADEMPTY SWEP.Anims.SafetyAnim=ACT_VM_FIREMODE SWEP.SingleReloadChambers=true SWEP.SingleReload=true SWEP.IronSightsPos = Vector(-2.008, -2, 0.90) SWEP.IronSightsAng = Vector(0.4, 0, 0) SWEP.ScopeOffsetPos=Vector(0,0,-1.31) SWEP.ScopeOffsetAng=Vector(-0.6,0,0) SWEP.InsNoIronAnim=true SWEP.MergeAttachments = { } SWEP.OpticMountModel = "models/weapons/upgrades/a_modkit_05.mdl" --TODO find a better optic mount than this one SWEP.DefaultSight=nil SWEP.NoDefaultSightModel=true SWEP.InsAttachments=true SWEP.Anims.InitialDrawAnim=ACT_VM_READY SWEP.CanFlashlight=true function SWEP:ReloadAct(force) self:ReloadTube() end function SWEP:DiscoverModelAnims() self:SetAnim("ShootAnim",self:DiscoverAnim("ACT_VM_PRIMARYATTACK_START")) self:SetAnim("IronShootAnim",self:DiscoverAnim("ACT_VM_ISHOOT_START")) self:SetAnim("RunAnim",self:DiscoverAnim("ACT_VM_SPRINT")) self:SetAnim("BoltAnim",self:DiscoverAnim("ACT_VM_PRIMARYATTACK_END")) self:SetAnim("BoltAnimIron",self:DiscoverAnim("ACT_VM_ISHOOT_END")) self:SetAnim("ShootLastAnim",self:DiscoverAnim("ACT_VM_PRIMARYATTACK_START")) self:SetAnim("ShootLastIronAnim",self:DiscoverAnim("ACT_VM_ISHOOT_START")) end
apache-2.0
FailcoderAddons/supervillain-ui
SVUI_Skins/components/addons/Altoholic.lua
2
10176
--[[ ########################################################## 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; --[[ ########################################################## ALTOHOLIC ########################################################## ]]-- local function ColorAltoBorder(self) if self.border then local Backdrop = self.backdrop or self.Backdrop if not Backdrop then return end local r, g, b = self.border:GetVertexColor() Backdrop:SetBackdropBorderColor(r, g, b, 1) end end local function ApplyTextureStyle(self) if not self then return end self:SetTexCoord(unpack(_G.SVUI_ICON_COORDS)) local parent = self:GetParent() if(parent) then self:InsetPoints(parent, 1, 1) end end local AltoholicFrameStyled = false; local function StyleAltoholic(event, addon) assert(AltoholicFrame, "AddOn Not Loaded") if not AltoholicFrameStyled then SV.API:Set("Tooltip", AltoTooltip) AltoholicFramePortrait:Die() SV.API:Set("Frame", AltoholicFrame, "Window2") SV.API:Set("Frame", AltoMsgBox) SV.API:Set("Button", AltoMsgBoxYesButton) SV.API:Set("Button", AltoMsgBoxNoButton) SV.API:Set("CloseButton", AltoholicFrameCloseButton) SV.API:Set("EditBox", AltoholicFrame_SearchEditBox, 175, 15) SV.API:Set("Button", AltoholicFrame_ResetButton) SV.API:Set("Button", AltoholicFrame_SearchButton) AltoholicFrameTab1:SetPoint("TOPLEFT", AltoholicFrame, "BOTTOMLEFT", -5, 2) AltoholicFrame_ResetButton:SetPoint("TOPLEFT", AltoholicFrame, "TOPLEFT", 25, -77) AltoholicFrame_SearchEditBox:SetPoint("TOPLEFT", AltoholicFrame, "TOPLEFT", 37, -56) AltoholicFrame_ResetButton:SetSize(85, 24) AltoholicFrame_SearchButton:SetSize(85, 24) AltoholicFrameStyled = true end if IsAddOnLoaded("Altoholic_Summary") then SV.API:Set("Frame", AltoholicFrameSummary) SV.API:Set("Frame", AltoholicFrameBagUsage) SV.API:Set("Frame", AltoholicFrameSkills) SV.API:Set("Frame", AltoholicFrameActivity) SV.API:Set("ScrollBar", AltoholicFrameSummaryScrollFrameScrollBar) SV.API:Set("ScrollBar", AltoholicFrameBagUsageScrollFrameScrollBar) SV.API:Set("ScrollBar", AltoholicFrameSkillsScrollFrameScrollBar) SV.API:Set("ScrollBar", AltoholicFrameActivityScrollFrameScrollBar) SV.API:Set("DropDown", AltoholicTabSummary_SelectLocation, 200) if(AltoholicFrameSummaryScrollFrame) then AltoholicFrameSummaryScrollFrameScrollBar:RemoveTextures(true) end if(AltoholicFrameBagUsageScrollFrame) then AltoholicFrameBagUsageScrollFrameScrollBar:RemoveTextures(true) end if(AltoholicFrameSkillsScrollFrame) then AltoholicFrameSkillsScrollFrameScrollBar:RemoveTextures(true) end if(AltoholicFrameActivityScrollFrame) then AltoholicFrameActivityScrollFrameScrollBar:RemoveTextures(true) end SV.API:Set("Button", AltoholicTabSummary_RequestSharing) ApplyTextureStyle(AltoholicTabSummary_RequestSharingIconTexture) SV.API:Set("Button", AltoholicTabSummary_Options) ApplyTextureStyle(AltoholicTabSummary_OptionsIconTexture) SV.API:Set("Button", AltoholicTabSummary_OptionsDataStore) ApplyTextureStyle(AltoholicTabSummary_OptionsDataStoreIconTexture) for i = 1, 5 do SV.API:Set("Button", _G["AltoholicTabSummaryMenuItem"..i], true) end for i = 1, 8 do SV.API:Set("Button", _G["AltoholicTabSummary_Sort"..i], true) end for i = 1, 7 do SV.API:Set("Tab", _G["AltoholicFrameTab"..i], true) end end if IsAddOnLoaded("Altoholic_Characters") then SV.API:Set("Frame", AltoholicFrameContainers) SV.API:Set("Frame", AltoholicFrameRecipes) SV.API:Set("Frame", AltoholicFrameQuests) SV.API:Set("Frame", AltoholicFrameGlyphs) SV.API:Set("Frame", AltoholicFrameMail) SV.API:Set("Frame", AltoholicFrameSpellbook) SV.API:Set("Frame", AltoholicFramePets) SV.API:Set("Frame", AltoholicFrameAuctions) SV.API:Set("ScrollBar", AltoholicFrameContainersScrollFrameScrollBar) SV.API:Set("ScrollBar", AltoholicFrameQuestsScrollFrameScrollBar) SV.API:Set("ScrollBar", AltoholicFrameRecipesScrollFrameScrollBar) SV.API:Set("DropDown", AltoholicFrameTalents_SelectMember) SV.API:Set("DropDown", AltoholicTabCharacters_SelectRealm) SV.API:Set("PageButton", AltoholicFrameSpellbookPrevPage) SV.API:Set("PageButton", AltoholicFrameSpellbookNextPage) SV.API:Set("PageButton", AltoholicFramePetsNormalPrevPage) SV.API:Set("PageButton", AltoholicFramePetsNormalNextPage) SV.API:Set("Button", AltoholicTabCharacters_Sort1) SV.API:Set("Button", AltoholicTabCharacters_Sort2) SV.API:Set("Button", AltoholicTabCharacters_Sort3) AltoholicFrameContainersScrollFrameScrollBar:RemoveTextures(true) AltoholicFrameQuestsScrollFrameScrollBar:RemoveTextures(true) AltoholicFrameRecipesScrollFrameScrollBar:RemoveTextures(true) local Buttons = { 'AltoholicTabCharacters_Characters', 'AltoholicTabCharacters_CharactersIcon', 'AltoholicTabCharacters_BagsIcon', 'AltoholicTabCharacters_QuestsIcon', 'AltoholicTabCharacters_TalentsIcon', 'AltoholicTabCharacters_AuctionIcon', 'AltoholicTabCharacters_MailIcon', 'AltoholicTabCharacters_SpellbookIcon', 'AltoholicTabCharacters_ProfessionsIcon', } for _, object in pairs(Buttons) do ApplyTextureStyle(_G[object..'IconTexture']) ApplyTextureStyle(_G[object]) end for i = 1, 7 do for j = 1, 14 do SV.API:Set("ItemButton", _G["AltoholicFrameContainersEntry"..i.."Item"..j]) _G["AltoholicFrameContainersEntry"..i.."Item"..j]:HookScript('OnShow', ColorAltoBorder) end end end if IsAddOnLoaded("Altoholic_Achievements") then SV.API:Set("!_Frame", AltoholicFrameAchievements) AltoholicFrameAchievementsScrollFrameScrollBar:RemoveTextures(true) AltoholicAchievementsMenuScrollFrameScrollBar:RemoveTextures(true) SV.API:Set("ScrollBar", AltoholicFrameAchievementsScrollFrameScrollBar) SV.API:Set("ScrollBar", AltoholicAchievementsMenuScrollFrameScrollBar) SV.API:Set("DropDown", AltoholicTabAchievements_SelectRealm) AltoholicTabAchievements_SelectRealm:SetPoint("TOPLEFT", AltoholicFrame, "TOPLEFT", 205, -57) for i = 1, 15 do SV.API:Set("Button", _G["AltoholicTabAchievementsMenuItem"..i], true) end for i = 1, 8 do for j = 1, 10 do SV.API:Set("!_Frame", _G["AltoholicFrameAchievementsEntry"..i.."Item"..j]) local Backdrop = _G["AltoholicFrameAchievementsEntry"..i.."Item"..j].backdrop or _G["AltoholicFrameAchievementsEntry"..i.."Item"..j].Backdrop ApplyTextureStyle(_G["AltoholicFrameAchievementsEntry"..i.."Item"..j..'_Background']) _G["AltoholicFrameAchievementsEntry"..i.."Item"..j..'_Background']:SetInside(Backdrop) end end end if IsAddOnLoaded("Altoholic_Agenda") then SV.API:Set("Frame", AltoholicFrameCalendarScrollFrame) SV.API:Set("Frame", AltoholicTabAgendaMenuItem1) SV.API:Set("ScrollBar", AltoholicFrameCalendarScrollFrameScrollBar) SV.API:Set("PageButton", AltoholicFrameCalendar_NextMonth) SV.API:Set("PageButton", AltoholicFrameCalendar_PrevMonth) SV.API:Set("Button", AltoholicTabAgendaMenuItem1, true) for i = 1, 14 do SV.API:Set("Frame", _G["AltoholicFrameCalendarEntry"..i]) end end if IsAddOnLoaded("Altoholic_Grids") then AltoholicFrameGridsScrollFrameScrollBar:RemoveTextures(true) SV.API:Set("!_Frame", AltoholicFrameGrids) SV.API:Set("ScrollBar", AltoholicFrameGridsScrollFrameScrollBar) SV.API:Set("DropDown", AltoholicTabGrids_SelectRealm) SV.API:Set("DropDown", AltoholicTabGrids_SelectView) for i = 1, 8 do for j = 1, 10 do SV.API:Set("!_Frame", _G["AltoholicFrameGridsEntry"..i.."Item"..j]) _G["AltoholicFrameGridsEntry"..i.."Item"..j]:HookScript('OnShow', ColorAltoBorder) end end AltoholicFrameGrids:HookScript('OnUpdate', function() for i = 1, 10 do for j = 1, 10 do if _G["AltoholicFrameGridsEntry"..i.."Item"..j.."_Background"] then _G["AltoholicFrameGridsEntry"..i.."Item"..j.."_Background"]:SetTexCoord(.08, .92, .08, .82) end end end end) end if IsAddOnLoaded("Altoholic_Guild") then SV.API:Set("Frame", AltoholicFrameGuildMembers) SV.API:Set("Frame", AltoholicFrameGuildBank) SV.API:Set("ScrollBar", AltoholicFrameGuildMembersScrollFrameScrollBar) AltoholicFrameGuildMembersScrollFrameScrollBar:RemoveTextures(true) for i = 1, 2 do SV.API:Set("Button", _G["AltoholicTabGuildMenuItem"..i]) end for i = 1, 7 do for j = 1, 14 do SV.API:Set("ItemButton", _G["AltoholicFrameGuildBankEntry"..i.."Item"..j]) end end for i = 1, 19 do SV.API:Set("ItemButton", _G["AltoholicFrameGuildMembersItem"..i]) end for i = 1, 5 do SV.API:Set("Button", _G["AltoholicTabGuild_Sort"..i]) end end if IsAddOnLoaded("Altoholic_Search") then SV.API:Set("!_Frame", AltoholicFrameSearch) AltoholicFrameSearchScrollFrameScrollBar:RemoveTextures(true) AltoholicSearchMenuScrollFrameScrollBar:RemoveTextures(true) SV.API:Set("ScrollBar", AltoholicFrameSearchScrollFrameScrollBar) SV.API:Set("ScrollBar", AltoholicSearchMenuScrollFrameScrollBar) SV.API:Set("DropDown", AltoholicTabSearch_SelectRarity) SV.API:Set("DropDown", AltoholicTabSearch_SelectSlot) SV.API:Set("DropDown", AltoholicTabSearch_SelectLocation) AltoholicTabSearch_SelectRarity:SetSize(125, 32) AltoholicTabSearch_SelectSlot:SetSize(125, 32) AltoholicTabSearch_SelectLocation:SetSize(175, 32) SV.API:Set("EditBox", _G["AltoholicTabSearch_MinLevel"]) SV.API:Set("EditBox", _G["AltoholicTabSearch_MaxLevel"]) for i = 1, 15 do SV.API:Set("Button", _G["AltoholicTabSearchMenuItem"..i]) end for i = 1, 8 do SV.API:Set("Button", _G["AltoholicTabSearch_Sort"..i]) end end end MOD:SaveAddonStyle("Altoholic", StyleAltoholic, false, true)
mit
nesstea/darkstar
scripts/zones/Crawlers_Nest/npcs/qm8.lua
26
2671
----------------------------------- -- Area: Crawlers Nest -- NPC: ??? -- Involved in Quest: The Crimson Trial -- @pos 59 0.1 66 197 ----------------------------------- package.loaded["scripts/zones/Crawlers_Nest/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/quests"); require("scripts/zones/Crawlers_Nest/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local cprog = player:getVar("theCrimsonTrial_prog"); local cdate = player:getVar("theCrimsonTrial_date"); local realday = tonumber(os.date("%j")); -- %M for next minute, %j for next day if (player:hasKeyItem(CRAWLER_BLOOD) == true and player:hasKeyItem(OLD_BOOTS) == true) then player:startEvent(4); elseif (cprog == 1 and cdate == realday) then player:messageSpecial(EQUIPMENT_COMPLETELY_PURIFIED); elseif (cprog == 1 and cdate ~= realday) then player:startEvent(5); else player:messageSpecial(SOMEONE_HAS_BEEN_DIGGING_HERE); 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 == 4 and option == 1) then player:delKeyItem(CRAWLER_BLOOD); player:delKeyItem(OLD_BOOTS); player:setVar("theCrimsonTrial_date", os.date("%j")); -- %M for next minute, %j for next day player:setVar("theCrimsonTrial_prog", 1); player:messageSpecial(YOU_BURY_THE,OLD_BOOTS,CRAWLER_BLOOD); elseif (csid == 5) then if (player:getFreeSlotsCount() == 0) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,14093); -- Warlock's Boots else player:addItem(14093); player:messageSpecial(ITEM_OBTAINED, 14093); -- Warlock's Boots player:setVar("theCrimsonTrial_date",0); player:setVar("theCrimsonTrial_prog",0); player:setVar("needs_crawler_blood",2); -- Fixed being unable start next quest player:addFame(SANDORIA,AF2_FAME); player:completeQuest(SANDORIA,ENVELOPED_IN_DARKNESS); end end end;
gpl-3.0
johnmccabe/dockercraft
world/Plugins/ChunkWorx/chunkworx_web.lua
6
10762
-- chunkworx_web.lua -- WebAdmin-related functions local function Buttons_Player( Name ) return "<form method='POST'><input type='hidden' name='PlayerName' value='"..Name.."'><input type='submit' name='PlayerExact' value='Exact'><input type='submit' name='Player3x3' value='3x3'></form>" end local function Button_World( Name ) return "<form method='POST'><input type='hidden' name='WorldName' value='"..Name.."'><input type='submit' name='SelectWorld' value='Select'></form>" end local function SaveSettings() local SettingsIni = cIniFile() SettingsIni:SetValueI("Area data", "StartX", AreaStartX) SettingsIni:SetValueI("Area data", "StartZ", AreaStartZ) SettingsIni:SetValueI("Area data", "EndX", AreaEndX) SettingsIni:SetValueI("Area data", "EndZ", AreaEndZ) SettingsIni:SetValueI("Radial data", "RadialX", RadialX) SettingsIni:SetValueI("Radial data", "RadialZ", RadialZ) SettingsIni:SetValueI("Radial data", "Radius", Radius) SettingsIni:WriteFile("ChunkWorx.ini") end function HandleRequest_Generation( Request ) local Content = "" if (Request.PostParams["AGHRRRR"] ~= nil) then GENERATION_STATE = 0 WW_instance:QueueSaveAllChunks() WW_instance:QueueUnloadUnusedChunks() LOGERROR("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": works ABORTED by admin") end --Content = Content .. "<head><meta http-equiv=\"refresh\" content=\"2;\"></head>" -- PROCESSING -------------------------------------------------------------------------------------------------- local function ProcessingContent() local _small_content = "" _small_content = _small_content .. "<head><meta http-equiv=\"refresh\" content=\"2;\"></head>" _small_content = _small_content .. "<h4>World for operations:</h4>"..WORK_WORLD if (OPERATION_CODE == 0) then _small_content = _small_content .. "<h4>Operation:</h4>Generation" elseif (OPERATION_CODE == 1) then _small_content = _small_content .. "<h4>Operation:</h4>Regeneration" end _small_content = _small_content .. "<h4>Area: </h4>["..AreaStartX..":"..AreaStartZ.."] ["..AreaEndX..":"..AreaEndZ.."]" _small_content = _small_content .. "<h4>Progress:</h4>"..CURRENT.."/"..TOTAL _small_content = _small_content .. "<br>" _small_content = _small_content .. "<form method='POST'>" _small_content = _small_content .. "<input type='submit' name='AGHRRRR' value='Stop'>" _small_content = _small_content .. "</form>" return _small_content end if (GENERATION_STATE == 2 or GENERATION_STATE == 4) then Content = ProcessingContent() return Content end -- SELECTING -------------------------------------------------------------------------------------------------- if ( Request.PostParams["FormSetWorld"] ) then WORK_WORLD = Request.PostParams["FormWorldName"] WW_instance = cRoot:Get():GetWorld(WORK_WORLD) end if( Request.PostParams["SelectWorld"] ~= nil and Request.PostParams["WorldName"] ~= nil ) then -- World is selected! WORK_WORLD = Request.PostParams["WorldName"] WW_instance = cRoot:Get():GetWorld(WORK_WORLD) end if(Request.PostParams["OperationGenerate"] ~= nil) then OPERATION_CODE = 0 end if(Request.PostParams["OperationReGenerate"] ~= nil) then OPERATION_CODE = 1 end if (GENERATION_STATE == 0) then if( Request.PostParams["FormAreaStartX"] ~= nil and Request.PostParams["FormAreaStartZ"] ~= nil and Request.PostParams["FormAreaEndX"] ~= nil and Request.PostParams["FormAreaEndZ"] ~= nil ) then --(Re)Generation valid! -- COMMON (Re)gen if( Request.PostParams["StartArea"]) then AreaStartX = tonumber(Request.PostParams["FormAreaStartX"]) AreaStartZ = tonumber(Request.PostParams["FormAreaStartZ"]) AreaEndX = tonumber(Request.PostParams["FormAreaEndX"]) AreaEndZ = tonumber(Request.PostParams["FormAreaEndZ"]) SaveSettings(); if (OPERATION_CODE == 0) then GENERATION_STATE = 1 elseif (OPERATION_CODE == 1) then GENERATION_STATE = 3 end Content = ProcessingContent() return Content end end if( Request.PostParams["FormRadialX"] ~= nil and Request.PostParams["FormRadialZ"] ~= nil and Request.PostParams["FormRadius"] ~= nil ) then --(Re)Generation valid! -- COMMON (Re)gen if( Request.PostParams["StartRadial"]) then RadialX = tonumber(Request.PostParams["FormRadialX"]) or 0 RadialZ = tonumber(Request.PostParams["FormRadialZ"]) or 0 Radius = tonumber(Request.PostParams["FormRadius"]) or 10 AreaStartX = RadialX - Radius AreaStartZ = RadialZ - Radius AreaEndX = RadialX + Radius AreaEndZ = RadialZ + Radius SaveSettings() if (OPERATION_CODE == 0) then GENERATION_STATE = 1 elseif (OPERATION_CODE == 1) then GENERATION_STATE = 3 end Content = ProcessingContent() return Content end end -- POINT REGEN! if( Request.PostParams["FormPointX"] ~= nil and Request.PostParams["FormPointZ"] ~= nil ) then --ReGeneration valid! -- EXACT if ( Request.PostParams["PointExact"] ~= nil) then AreaStartX = tonumber(Request.PostParams["FormPointX"]) AreaStartZ = tonumber(Request.PostParams["FormPointZ"]) AreaEndX = AreaStartX AreaEndZ = AreaStartZ GENERATION_STATE = 3 Content = ProcessingContent() return Content end -- 3x3 if ( Request.PostParams["Point3x3"] ~= nil) then AreaStartX = tonumber(Request.PostParams["FormPointX"]) - 1 AreaStartZ = tonumber(Request.PostParams["FormPointZ"]) - 1 AreaEndX = AreaStartX + 2 AreaEndZ = AreaStartZ + 2 GENERATION_STATE = 3 Content = ProcessingContent() return Content end end local GetAreaByPlayer = function(Player) -- Player is valid only within this function, it cannot be stord and used later! AreaStartX = Player:GetChunkX() AreaStartZ = Player:GetChunkZ() end -- PLAYERS REGEN! if( Request.PostParams["PlayerExact"] ~= nil and Request.PostParams["PlayerName"] ~= nil ) then -- Making BOOM! I meant, regenereate... cRoot:Get():GetWorld(WORK_WORLD):DoWithPlayer(Request.PostParams["PlayerName"],GetAreaByPlayer) AreaEndX = AreaStartX AreaEndZ = AreaStartZ GENERATION_STATE = 3 Content = ProcessingContent() return Content end if( Request.PostParams["Player3x3"] ~= nil and Request.PostParams["PlayerName"] ~= nil ) then -- Making BOOM! I meant, regenereate... cRoot:Get():GetWorld(WORK_WORLD):DoWithPlayer(Request.PostParams["PlayerName"],GetAreaByPlayer) AreaStartX = AreaStartX - 1 AreaStartZ = AreaStartZ - 1 AreaEndX = AreaStartX + 2 AreaEndZ = AreaStartZ + 2 GENERATION_STATE = 3 Content = ProcessingContent() return Content end end --Content = Content .. "<h4>World for operations: " .. WORK_WORLD .. "</h4>" --Content = Content .. "<form method='POST'>" --Content = Content .. "<input type='text' name='FormWorldName' value='Input world name here'><input type='submit' name='FormSetWorld' value='Set world'>" --Content = Content .. "</form>" -- SELECTING WORK_WORLD Content = Content .. "<h4>World for operations: " .. WORK_WORLD .. "</h4>" Content = Content .. "<table>" local WorldNum = 0 local AddWorldToTable = function(World) WorldNum = WorldNum + 1 Content = Content .. "<tr>" Content = Content .. "<td style='width: 10px;'>" .. WorldNum .. ".</td>" Content = Content .. "<td>" .. World:GetName() .. "</td>" Content = Content .. "<td>" .. Button_World(World:GetName()) .. "</td>" Content = Content .. "</tr>" end cRoot:Get():ForEachWorld(AddWorldToTable) if( WorldNum == 0 ) then Content = Content .. "<tr><td>No worlds! O_O</td></tr>" end Content = Content .. "</table>" Content = Content .. "<br>" -- SELECTING OPERATION if (OPERATION_CODE == 0) then Content = Content .. "<h4>Operation: Generation</h4>" elseif (OPERATION_CODE == 1) then Content = Content .. "<h4>Operation: Regeneration</h4>" end Content = Content .. "<form method='POST'>" Content = Content .. "<input type='submit' name='OperationGenerate' value='Generation'>" Content = Content .. "<input type='submit' name='OperationReGenerate' value='Regeneration'>" Content = Content .. "</form>" -- SELECTING AREA Content = Content .. "<h4>Area: </h4>Start X, Start Z; End X, End Z" Content = Content .. "<form method='POST'>" Content = Content .. "<input type='text' name='FormAreaStartX' value='" .. AreaStartX .. "'><input type='text' name='FormAreaStartZ' value='" .. AreaStartZ .. "'>" Content = Content .. "<input type='text' name='FormAreaEndX' value='" .. AreaEndX .. "'><input type='text' name='FormAreaEndZ' value='" .. AreaEndZ .. "'>" Content = Content .. "<input type='submit' name='StartArea' value='Start'>" Content = Content .. "</form>" -- SELECTING RADIAL Content = Content .. "<h4>Radial: </h4>Center X, Center Z, Radius" Content = Content .. "<form method='POST'>" Content = Content .. "<input type='text' name='FormRadialX' value='" .. RadialX .. "'><input type='text' name='FormRadialZ' value='" .. RadialZ .. "'><input type='text' name='FormRadius' value='" .. Radius .. "'>" Content = Content .. "<input type='submit' name='StartRadial' value='Start'>" Content = Content .. "</form>" Content = Content .. "<br>" Content = Content .. "<br>" Content = Content .. "<br>" -- SELECTING POINT Content = Content .. "<h4>Point regeneration:</h4> X, Z" Content = Content .. "<form method='POST'>" Content = Content .. "<input type='text' name='FormPointX' value='0'><input type='text' name='FormPointZ' value='0'>" Content = Content .. "<input type='submit' name='PointExact' value='Exact'>" Content = Content .. "<input type='submit' name='Point3x3' value='3x3'>" Content = Content .. "</form>" -- SELECTING PLAYERS Content = Content .. "<h4>Player-based regeneration:</h4>" Content = Content .. "<table>" local PlayerNum = 0 local AddPlayerToTable = function( Player ) PlayerNum = PlayerNum + 1 Content = Content .. "<tr>" Content = Content .. "<td style='width: 10px;'>" .. PlayerNum .. ".</td>" Content = Content .. "<td>" .. Player:GetName() .. "</td>" Content = Content .. "<td>" .. Buttons_Player(Player:GetName()) .. "</td>" Content = Content .. "</tr>" end if (cRoot:Get():GetWorld(WORK_WORLD) == nil) then Content = Content .. "<tr><td>Incorrect world selection</td></tr>" else cRoot:Get():GetWorld(WORK_WORLD):ForEachPlayer( AddPlayerToTable ) if( PlayerNum == 0 ) then Content = Content .. "<tr><td>No connected players</td></tr>" end end Content = Content .. "</table>" Content = Content .. "<br>" return Content end
apache-2.0
nesstea/darkstar
scripts/zones/Beadeaux/npcs/The_Afflictor.lua
13
1182
----------------------------------- -- Area: Beadeaux -- NPC: The Afflictor -- @zone 147 -- @pos <many> ----------------------------------- package.loaded["scripts/zones/Beadeaux/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Beadeaux/TextIDs"); require("scripts/globals/quests"); require("scripts/globals/settings"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:getQuestStatus(BASTOK,THE_CURSE_COLLECTOR) == QUEST_ACCEPTED and player:getVar("cCollectCurse") == 0) then player:setVar("cCollectCurse",1); 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/Metalworks/npcs/Kaela.lua
38
1389
----------------------------------- -- Area: Metalworks -- NPC: Kaela -- Type: Adventurer's Assistant -- @pos 40.167 -14.999 16.073 237 ----------------------------------- package.loaded["scripts/zones/Metalworks/TextIDs"] = nil; ----------------------------------- require("scripts/globals/quests"); require("scripts/zones/Metalworks/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local WildcatBastok = player:getVar("WildcatBastok"); if (player:getQuestStatus(BASTOK,LURE_OF_THE_WILDCAT_BASTOK) == QUEST_ACCEPTED and player:getMaskBit(WildcatBastok,8) == false) then player:startEvent(0x03a6); else player:startEvent(0x02e5); 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 == 0x03a6) then player:setMaskBit(player:getVar("WildcatBastok"),"WildcatBastok",8,true); end end;
gpl-3.0
nesstea/darkstar
scripts/zones/Bastok_Mines/TextIDs.lua
8
6682
-- Variable TextID Description text -- General Texts ITEM_CANNOT_BE_OBTAINED = 6379; -- Come back after sorting your inventory. FULL_INVENTORY_AFTER_TRADE = 6383; -- Try trading again after sorting your inventory. ITEM_OBTAINED = 6384; -- Obtained: <<<Unknown Parameter (Type: 80) 1>>><<<Possible Special Code: 01>>><<<Possible Special Code: 05>>> GIL_OBTAINED = 6385; -- Obtained <<<Numeric Parameter 0>>> gil. NOT_HAVE_ENOUGH_GIL = 6389; -- You do not have enough gil. KEYITEM_OBTAINED = 6387; -- Obtained key item: <<<Unknown Parameter (Type: 80) 1>>> HOMEPOINT_SET = 6475; -- Home point set! ALCHEMY_SUPPORT = 7046; -- Your Multiple Choice (Parameter 1)[fishing/woodworking/smithing/goldsmithing/clothcraft/leatherworking/bonecraft/alchemy/cooking] skills went up GUILD_TERMINATE_CONTRACT = 7060; -- You have terminated your trading contract with the ?Multiple Choice (Parameter 1)?[Fishermen's/Carpenters'/Blacksmiths'/Goldsmiths'/Weavers'/Tanners'/Boneworkers'/Alchemists'/Culinarians'] Guild and formed a new one with the ?Multiple Choice (Parameter 0)?[Fishermen's/Carpenters'/Blacksmiths'/Goldsmiths'/Weavers'/Tanners'/Boneworkers'/Alchemists'/Culinarians'] Guild.?Prompt? GUILD_NEW_CONTRACT = 7068; -- You have formed a new trading contract with the ?Multiple Choice (Parameter 0)?[Fishermen's/Carpenters'/Blacksmiths'/Goldsmiths'/Weavers'/Tanners'/Boneworkers'/Alchemists'/Culinarians'] Guild.?Prompt? NO_MORE_GP_ELIGIBLE = 7075; --You are not eligible to receive guild points at this time. GP_OBTAINED = 7064; --Obtained <<<Numeric Parameter 0>>> guild points. NOT_HAVE_ENOUGH_GP = 7081; --You do not have enough guild points. FISHING_MESSAGE_OFFSET = 10791; -- You can't fish here. -- Conquest System CONQUEST = 11091; --You've earned conquest points! -- Mission Dialogs YOU_ACCEPT_THE_MISSION = 6504; -- You have accepted the mission. ORIGINAL_MISSION_OFFSET = 6509; -- You can consult the ission section of the main menu to review your objectives. Speed and efficiency are your priorities. Dismissed. EXTENDED_MISSION_OFFSET = 11594; -- Go to Ore Street and talk to Medicine Eagle. He says he was there when the commotion started. -- Dynamis dialogs YOU_CANNOT_ENTER_DYNAMIS = 11704; -- You cannot enter Dynamis PLAYERS_HAVE_NOT_REACHED_LEVEL = 11706; -- Players who have not reached levelare prohibited from entering Dynamis. UNUSUAL_ARRANGEMENT_PEBBLES = 11717; -- There is an unusual arrangement of pebbles here. -- Dialog Texts HEMEWMEW_DIALOG = 7053; -- I have been appointed by the Guildworkers' Union to manage the trading of manufactured crafts and the exchange of guild points. VIRNAGE_DIALOG_1 = 10968; -- They stayed in a citadel on the Sauromugue Champaign. The paint may be there still! VIRNAGE_DIALOG_2 = 10974; -- Hand my letter to Eperdur in the San d'Oria Cathedral to claim your reward. THE_GATE_IS_LOCKED = 12139; -- The gate is locked. -- Harvest Festival TRICK_OR_TREAT = 11666; -- Trick or treat... THANK_YOU_TREAT = 11667; -- And now for your treat... HERE_TAKE_THIS = 11668; -- Here, take this... IF_YOU_WEAR_THIS = 11669; -- If you put this on and walk around, something...unexpected might happen... THANK_YOU = 11667; -- Thank you... -- Shop Texts FAUSTIN_CLOSED_DIALOG = 10770; -- I'm trying to start a business selling goods from Ronfaure, RODELLIEUX_CLOSED_DIALOG = 10771; -- I'm trying to start a business selling goods from Fauregandi, MILLE_CLOSED_DIALOG = 10772; -- I'm trying to start a business selling goods from Norvallen, TIBELDA_CLOSED_DIALOG = 10773; -- I'm trying to start a business selling goods from Valdeaunia, GALDEO_CLOSED_DIALOG = 10774; -- I'm trying to start a business selling goods from Li'Telor, DEEGIS_SHOP_DIALOG = 10886; -- The only things an adventurer needs are courage and a good suit of armor! Welcome to Deegis's Armour! ZEMEDARS_SHOP_DIALOG = 10887; -- Everything in our store is top-grade and Galka-made! What're you lookin' for? BOYTZ_SHOP_DIALOG = 10888; -- Welcome to Boytz's Knickknacks. GELZERIO_SHOP_DIALOG = 10889; -- ...Yes? GRISELDA_SHOP_DIALOG = 10890; -- Good of you to drop by the Bat's Lair Inn! Why don't you try some of our specialty plates? NEIGEPANCE_SHOP_DIALOG = 10891; -- Hello there. A well-fed chocobo is a happy chocobo! FAUSTIN_OPEN_DIALOG = 10892; -- Hello there! Might I interest you specialty goods from Ronfaure? MILLE_OPEN_DIALOG = 10893; -- Hello there! Might I interest you specialty goods from Norvallen? RODELLIEUX_OPEN_DIALOG = 10894; -- Hello there! Might I interest you specialty goods from Fauregandi? TIBELDA_OPEN_DIALOG = 10895; -- Goods of all varieties, imported directly from the northern land of Valdeaunia! MAYMUNAH_SHOP_DIALOG = 10896; -- Welcome to the Alchemists' Guild! Looking for something specific? ODOBA_SHOP_DIALOG = 10897; -- Welcome to the Alchemists' Guild. How may I help you? GALDEO_OPEN_DIALOG = 11451; -- Come! Take a look at all the wonderful goods from Li'Telor. AULAVIA_OPEN_DIALOG = 11452; -- May I interest you in some specialty goods from Vollbow? AULAVIA_CLOSED_DIALOG = 11453; -- I'm trying to start a business selling goods from Vollbow, PROUDBEARD_SHOP_DIALOG = 11622; -- Would you be interested in a nice suit of adventurer-issue armor? Be careful when you buy, though. We offer no refunds. EMALIVEULAUX_COP_NOT_COMPLETED = 12220; -- I'd like to start my own business someday, but I just haven't found anything that truly interests me. EMALIVEULAUX_OPEN_DIALOG = 12221; -- Rare Tavnazian imports! Get them before they're gone! EMALIVEULAUX_CLOSED_DIALOG = 12222; -- I'd love to sell you goods imported from the island of Tavnazia, but with the area under foreign control, I can't secure my trade routes... -- Weather Dialog MARIADOK_DIALOG = 6736; -- Your fate rides on the changing winds of Vana'diel. I can give you insight on the local weather. -- Standard NPC Dialog ITEM_DELIVERY_DIALOG = 10426; -- Need something sent to a friend's house? Sending items to your own house? You've come to the right place! -- conquest Base CONQUEST_BASE = 6577; -- Tallying conquest results...
gpl-3.0
nesstea/darkstar
scripts/globals/weaponskills/dragon_kick.lua
9
1693
----------------------------------- -- Dragon Kick -- Hand-to-Hand weapon skill -- Skill Level: 225 -- Damage varies with TP. -- Despite the name, Dragon Kick damage is not affected by Kick Attacks or equipment that enhances kick attacks such as Dune Boots. http://www.bluegartr.com/threads/121610-Rehauled-Weapon-Skills-tier-lists?p=6140907&viewfull=1#post6140907 -- Will stack with Sneak Attack. -- Aligned with the Breeze Gorget & Thunder Gorget. -- Aligned with the Breeze Belt & Thunder Belt. -- Element: None -- Modifiers: STR:50% ; VIT:50% -- 100%TP 200%TP 300%TP -- 2.00 2.75 3.50 ----------------------------------- 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 = 2; params.ftp200 = 2.75; params.ftp300 = 3.5; params.str_wsc = 0.5; params.dex_wsc = 0.0; params.vit_wsc = 0.5; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0; params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0; params.canCrit = false; params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0; params.atkmulti = 1; if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then params.ftp100 = 2; params.ftp200 = 3.6; params.ftp300 = 6.5; params.str_wsc = 0.5; params.dex_wsc = 0.5; params.vit_wsc = 0.0; end local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, primary); return tpHits, extraHits, criticalHit, damage; end
gpl-3.0
MuhammadWang/MCServer
MCServer/Plugins/APIDump/Hooks/OnChunkUnloading.lua
8
1082
return { HOOK_CHUNK_UNLOADING = { CalledWhen = " A chunk is about to be unloaded from the memory. Plugins may refuse the unload.", DefaultFnName = "OnChunkUnloading", -- also used as pagename Desc = [[ MCServer calls this function when a chunk is about to be unloaded from the memory. A plugin may force MCServer to keep the chunk in memory by returning true.</p> <p> FIXME: The return value should be used only for event propagation stopping, not for the actual decision whether to unload. ]], Params = { { Name = "World", Type = "{{cWorld}}", Notes = "The world from which the chunk is unloading" }, { Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" }, { Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" }, }, Returns = [[ If the function returns false or no value, the next plugin's callback is called and finally MCServer unloads the chunk. If the function returns true, no other callback is called for this event and the chunk is left in the memory. ]], }, -- HOOK_CHUNK_UNLOADING }
apache-2.0
nesstea/darkstar
scripts/globals/weaponskills/atonement.lua
3
4266
----------------------------------- -- Atonement -- TODO: This needs to be reworked, as this weapon skill does damage based on current enmity, not based on stat modifiers. http://wiki.ffxiclopedia.org/wiki/Atonement http://www.bg-wiki.com/bg/Atonement -- Sword weapon skill -- Skill Level: N/A -- Delivers a Twofold attack. Damage varies with TP. Conqueror: Aftermath effect varies with TP. -- Available only after completing the Unlocking a Myth (Paladin) quest. -- Aligned with the Aqua Gorget, Flame Gorget & Light Gorget. -- Aligned with the Aqua Belt, Flame Belt & Light Belt. -- Element: None -- Modifiers (old): damage varies with enmity -- 100%TP 200%TP 300%TP -- 0.09 0.11 0.20 -CE -- 0.11 0.14 0.25 -VE -- Modifiers (new): enmity from damage varies with TP -- 100%TP 200%TP 300%TP -- 1.00 1.5 2.0 -- Modifiers (non-mob, wrong): STR:40% VIT:50% -- 100%TP 200%TP 300%TP -- 1.00 1.25 1.50 ----------------------------------- require("scripts/globals/status"); require("scripts/globals/settings"); require("scripts/globals/weaponskills"); ----------------------------------- function onUseWeaponSkill(player, target, wsID, tp, primary) local params = {}; params.numHits = 2; params.ftp100 = 1; params.ftp200 = 1.25; params.ftp300 = 1.5; params.str_wsc = 0.4; params.dex_wsc = 0.0; params.vit_wsc = 0.5; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0; 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 tpHits = 0; local extraHits = 0; local criticalHit = false; local enmityMult = 1; local damage = 0; if (target:getObjType() ~= TYPE_MOB) then -- this isn't correct but might as well use what was originally here if someone uses this on a non-mob if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then params.ftp100 = 1; params.ftp200 = 1.5; params.ftp300 = 2.0; end damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, primary); else local dmg; if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then dmg = (target:getCE(player) + target:getVE(player))/6; -- tp affects enmity multiplier, 1.0 at 1k, 1.5 at 2k, 2.0 at 3k. Gorget/Belt adds 100 tp each. enmityMult = enmityMult + (tp + (handleWSGorgetBelt(player) * 1000) - 1000)/2000; enmityMult = utils.clamp(enmityMult, 1, 2); -- necessary because of Gorget/Belt bonus else local effectiveTP = tp + handleWSGorgetBelt(player) * 1000; effectiveTP = utils.clamp(effectiveTP, 0, 3000); -- necessary because of Gorget/Belt bonus local ceMod = fTP(effectiveTP, 0.09, 0.11, 0.20); -- CE portion of Atonement local veMod = fTP(effectiveTP, 0.11, 0.14, 0.25); -- VE portion of Atonement dmg = math.floor(target:getCE(player) * ceMod) + math.floor(target:getVE(player) * veMod); end dmg = utils.clamp(dmg, 0, player:getMainLvl() * 10); -- Damage is capped to player's level * 10, before WS damage mods damage = target:breathDmgTaken(dmg); if (player:getMod(MOD_WEAPONSKILL_DAMAGE_BASE + wsID) > 0) then damage = damage * (100 + player:getMod(MOD_WEAPONSKILL_DAMAGE_BASE + wsID))/100 end damage = damage * WEAPON_SKILL_POWER; if (damage > 0) then if (player:getOffhandDmg() > 0) then tpHits = 2; else tpHits = 1; end extraHits = 1; -- for whatever reason, Atonement always yields the a TP return of a 2 hit WS, unless it does 0 damage. end damage = target:takeWeaponskillDamage(player, damage, SLOT_MAIN, tpHits, extraHits, 1); target:updateEnmityFromDamage(player, damage * enmityMult); end if ((player:getEquipID(SLOT_MAIN) == 18997) and (player:getMainJob() == JOB_PLD)) then if (damage > 0) then applyAftermathEffect(player, tp) end end return tpHits, extraHits, criticalHit, damage; end;
gpl-3.0
UnfortunateFruit/darkstar
scripts/zones/GM_Home/npcs/Trader.lua
25
1134
----------------------------------- -- Area: GM Home -- NPC: Trader -- Type: Debug NPC for testing trades. ----------------------------------- package.loaded["scripts/zones/GM_Home/TextIDs"] = nil; ----------------------------------- require("scripts/zones/GM_Home/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if (trade:hasItemQty(4096,1) and trade:getItemCount() == 1) then player:startEvent(126); end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(127); 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/Kazham/npcs/Ronta-Onta.lua
23
4041
----------------------------------- -- Area: Kazham -- NPC: Ronta-Onta -- Starts and Finishes Quest: Trial by Fire -- @pos 100 -15 -97 250 ----------------------------------- package.loaded["scripts/zones/Kazham/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/shop"); require("scripts/globals/quests"); require("scripts/zones/Kazham/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) TrialByFire = player:getQuestStatus(OUTLANDS,TRIAL_BY_FIRE); WhisperOfFlames = player:hasKeyItem(WHISPER_OF_FLAMES); realday = tonumber(os.date("%j")); -- %M for next minute, %j for next day if((TrialByFire == QUEST_AVAILABLE and player:getFameLevel(KAZHAM) >= 6) or (TrialByFire == QUEST_COMPLETED and realday ~= player:getVar("TrialByFire_date"))) then player:startEvent(0x010e,0,TUNING_FORK_OF_FIRE); -- Start and restart quest "Trial by Fire" elseif(TrialByFire == QUEST_ACCEPTED and player:hasKeyItem(TUNING_FORK_OF_FIRE) == false and WhisperOfFlames == false) then player:startEvent(0x011d,0,TUNING_FORK_OF_FIRE); -- Defeat against Ifrit : Need new Fork elseif(TrialByFire == QUEST_ACCEPTED and WhisperOfFlames == false) then player:startEvent(0x010f,0,TUNING_FORK_OF_FIRE,0); elseif(TrialByFire == QUEST_ACCEPTED and WhisperOfFlames) then numitem = 0; if(player:hasItem(17665)) then numitem = numitem + 1; end -- Ifrits Blade if(player:hasItem(13241)) then numitem = numitem + 2; end -- Fire Belt if(player:hasItem(13560)) then numitem = numitem + 4; end -- Fire Ring if(player:hasItem(1203)) then numitem = numitem + 8; end -- Egil's Torch if(player:hasSpell(298)) then numitem = numitem + 32; end -- Ability to summon Ifrit player:startEvent(0x0111,0,TUNING_FORK_OF_FIRE,0,0,numitem); else player:startEvent(0x0112); -- Standard dialog end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if(csid == 0x010e and option == 1) then if(player:getQuestStatus(OUTLANDS,TRIAL_BY_FIRE) == QUEST_COMPLETED) then player:delQuest(OUTLANDS,TRIAL_BY_FIRE); end player:addQuest(OUTLANDS,TRIAL_BY_FIRE); player:setVar("TrialByFire_date", 0); player:addKeyItem(TUNING_FORK_OF_FIRE); player:messageSpecial(KEYITEM_OBTAINED,TUNING_FORK_OF_FIRE); elseif(csid == 0x011d) then player:addKeyItem(TUNING_FORK_OF_FIRE); player:messageSpecial(KEYITEM_OBTAINED,TUNING_FORK_OF_FIRE); elseif(csid == 0x0111) then item = 0; if(option == 1) then item = 17665; -- Ifrits Blade elseif(option == 2) then item = 13241; -- Fire Belt elseif(option == 3) then item = 13560; -- Fire Ring elseif(option == 4) then item = 1203; -- Egil's Torch end if(player:getFreeSlotsCount() == 0 and (option ~= 5 or option ~= 6)) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,item); else if(option == 5) then player:addGil(GIL_RATE*10000); player:messageSpecial(GIL_OBTAINED,GIL_RATE*10000); -- Gil elseif(option == 6) then player:addSpell(298); -- Ifrit Spell player:messageSpecial(IFRIT_UNLOCKED,0,0,0); else player:addItem(item); player:messageSpecial(ITEM_OBTAINED,item); -- Item end player:addTitle(HEIR_OF_THE_GREAT_FIRE); player:delKeyItem(WHISPER_OF_FLAMES); player:setVar("TrialByFire_date", os.date("%j")); -- %M for next minute, %j for next day player:addFame(KAZHAM,WIN_FAME*30); player:completeQuest(OUTLANDS,TRIAL_BY_FIRE); end end end;
gpl-3.0
FailcoderAddons/supervillain-ui
SVUI_!Core/libs/_SVUI_Lib/LUA.lua
3
17177
--- LUA companion library. -- @class file -- @name LUA -- @author Steven Jackson (2014) -- @release 1.0.0 local _G = getfenv(0) local select = _G.select; local assert = _G.assert; local type = _G.type; local error = _G.error; local pairs = _G.pairs; local next = _G.next; local ipairs = _G.ipairs; local loadstring = _G.loadstring; local setmetatable = _G.setmetatable; local getmetatable = _G.getmetatable; local rawset = _G.rawset; local rawget = _G.rawget; local tostring = _G.tostring; local tonumber = _G.tonumber; local xpcall = _G.xpcall; local pcall = _G.pcall; local table = _G.table; local tconcat = table.concat; local tremove = table.remove; local tinsert = table.insert; local table_sort = table.sort; local string = _G.string; local match = string.match; local gmatch = string.gmatch; local gsub = string.gsub; local rep = string.rep; local char = string.char; local strmatch = _G.strmatch; local bit = _G.bit; local band = bit.band; local math = _G.math; local floor = math.floor; local huge = math.huge; --------------------------------------------------------------------- -- Math -- @section MATH UTILITIES --------------------------------------------------------------------- --------------------------------------------------------------------- -- Integer float utility for lua. -- @return floating point integer -- @param value The integer amount to be adjusted. -- @param decimal Number of decimal places allowed. --------------------------------------------------------------------- function math.parsefloat(value, decimal) value = value or 0 if(decimal and decimal > 0) then local calc1 = 10 ^ decimal; local calc2 = (value * calc1) + 0.5; return floor(calc2) / calc1 end return floor(value + 0.5) end --------------------------------------------------------------------- -- Pickle -- @section SERIALIZE UTILITIES --------------------------------------------------------------------- --------------------------------------------------------------------- -- Global class used by pickle/unpickle functions. -- @todo Does this need to be global? --------------------------------------------------------------------- Pickle = { clone = function (t) local nt={}; for i, v in pairs(t) do nt[i]=v end return nt end } --------------------------------------------------------------------- -- A table serialization utility for lua. -- @return serialized table data -- @param t A table to be serialized. -- @author Steve Dekorte, http://www.dekorte.com, Apr 2000 --------------------------------------------------------------------- function pickle(t) return Pickle:clone():pickle_(t) end function Pickle:pickle_(root) if type(root) ~= "table" then error("can only pickle tables, not ".. type(root).."s") end self._tableToRef = {} self._refToTable = {} local savecount = 0 self:ref_(root) local s = "" while table.getn(self._refToTable) > savecount do savecount = savecount + 1 local t = self._refToTable[savecount] s = s.."{\n" for i, v in pairs(t) do s = string.format("%s[%s]=%s,\n", s, self:value_(i), self:value_(v)) end s = s.."},\n" end return string.format("{%s}", s) end function Pickle:value_(v) local vtype = type(v) if vtype == "string" then return string.format("%q", v) elseif vtype == "number" then return v elseif vtype == "boolean" then return tostring(v) elseif vtype == "table" then return "{"..self:ref_(v).."}" else --error("pickle a "..type(v).." is not supported") end end function Pickle:ref_(t) local ref = self._tableToRef[t] if not ref then if t == self then error("can't pickle the pickle class") end table.insert(self._refToTable, t) ref = table.getn(self._refToTable) self._tableToRef[t] = ref end return ref end --------------------------------------------------------------------- -- Un-serialization tool (pretty sure thats not a word). -- @return serialized table data -- @param s A serialized table to be reversed. -- @author Steve Dekorte, http://www.dekorte.com, Apr 2000 --------------------------------------------------------------------- function unpickle(s) if type(s) ~= "string" then error("can't unpickle a "..type(s)..", only strings") end local gentables = loadstring("return "..s) local tables = gentables() for tnum = 1, table.getn(tables) do local t = tables[tnum] local tcopy = {}; for i, v in pairs(t) do tcopy[i] = v end for i, v in pairs(tcopy) do local ni, nv if type(i) == "table" then ni = tables[i[1]] else ni = i end if type(v) == "table" then nv = tables[v[1]] else nv = v end t[i] = nil t[ni] = nv end end return tables[1] end --------------------------------------------------------------------- -- String -- @section STRING UTILITIES --------------------------------------------------------------------- local char_table='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' --------------------------------------------------------------------- -- Base64 encoding tool. -- @return encoded string -- @param data string data to be encoded. --------------------------------------------------------------------- function string.encode(data) return ((data:gsub('.', function(x) local r,b='',x:byte() for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end return r; end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x) if (#x < 6) then return '' end local c=0 for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end return char_table:sub(c+1,c+1) end)..({ '', '==', '=' })[#data%3+1]) end --------------------------------------------------------------------- -- Base64 decoding tool. -- @return decoded string -- @param data encoded string to be decoded. --------------------------------------------------------------------- function string.decode(data) data = gsub(data, '[^'..char_table..'=]', '') return (data:gsub('.', function(x) if (x == '=') then return '' end local r,f='',(char_table:find(x)-1) for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end return r; end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x) if (#x ~= 8) then return '' end local c=0 for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end return char(c) end)) end --------------------------------------------------------------------- -- String to array utility. -- @return table data -- @param data string to be converted to table data. -- @param delim Character delimiter to separate the string by. --------------------------------------------------------------------- function string.explode(data, delim) local pattern = format("([^%s]+)", delim); local res = {}; local count = 1; for line in gmatch(data, pattern) do res[count] = line; count = count + 1; end return res end function string.loadtable(data) local t = {} local f = assert(loadstring(data)) setfenv(f, t) f() return t end ------------------------------------------------------------------- --PRETTY PRINT FOR TABLES local prettify = {} prettify.KEY = setmetatable({}, {__tostring = function() return 'prettify.KEY' end}) prettify.METATABLE = setmetatable({}, {__tostring = function() return 'prettify.METATABLE' end}) -- Apostrophizes the string if it has quotes, but not aphostrophes -- Otherwise, it returns a regular quoted string local function smartQuote(str) if str:match('"') and not str:match("'") then return "'" .. str .. "'" end return '"' .. str:gsub('"', '\\"') .. '"' end local controlCharsTranslation = { ["\a"] = "\\a", ["\b"] = "\\b", ["\f"] = "\\f", ["\n"] = "\\n", ["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v" } local function escape(str) local result = str:gsub("\\", "\\\\"):gsub("(%c)", controlCharsTranslation) return result end local function isIdentifier(str) return type(str) == 'string' and str:match( "^[_%a][_%a%d]*$" ) end local function isSequenceKey(k, length) return type(k) == 'number' and 1 <= k and k <= length and floor(k) == k end local defaultTypeOrders = { ['number'] = 1, ['boolean'] = 2, ['string'] = 3, ['table'] = 4, ['function'] = 5, ['userdata'] = 6, ['thread'] = 7 } local function sortKeys(a, b) local ta, tb = type(a), type(b) -- strings and numbers are sorted numerically/alphabetically if ta == tb and (ta == 'string' or ta == 'number') then return a < b end local dta, dtb = defaultTypeOrders[ta], defaultTypeOrders[tb] -- Two default types are compared according to the defaultTypeOrders table if dta and dtb then return defaultTypeOrders[ta] < defaultTypeOrders[tb] elseif dta then return true -- default types before custom ones elseif dtb then return false -- custom types after default ones end -- custom types are sorted out alphabetically return ta < tb end local function getNonSequentialKeys(t) local keys, length = {}, #t for k,_ in pairs(t) do if not isSequenceKey(k, length) then table.insert(keys, k) end end table.sort(keys, sortKeys) return keys end local function getToStringResultSafely(t, mt) local __tostring = type(mt) == 'table' and rawget(mt, '__tostring') local str, ok if type(__tostring) == 'function' then ok, str = pcall(__tostring, t) str = ok and str or 'error: ' .. tostring(str) end if type(str) == 'string' and #str > 0 then return str end end local maxIdsMetaTable = { __index = function(self, typeName) rawset(self, typeName, 0) return 0 end } local idsMetaTable = { __index = function (self, typeName) local col = setmetatable({}, {__mode = "kv"}) rawset(self, typeName, col) return col end } local function countTableAppearances(t, tableAppearances) tableAppearances = tableAppearances or setmetatable({}, {__mode = "k"}) if type(t) == 'table' then if not tableAppearances[t] then tableAppearances[t] = 1 for k,v in pairs(t) do countTableAppearances(k, tableAppearances) countTableAppearances(v, tableAppearances) end countTableAppearances(getmetatable(t), tableAppearances) else tableAppearances[t] = tableAppearances[t] + 1 end end return tableAppearances end local copySequence = function(s) local copy, len = {}, #s for i=1, len do copy[i] = s[i] end return copy, len end local function makePath(path, ...) local keys = {...} local newPath, len = copySequence(path) for i=1, #keys do newPath[len + i] = keys[i] end return newPath end local function processRecursive(process, item, path) if item == nil then return nil end local processed = process(item, path) if type(processed) == 'table' then local processedCopy = {} local processedKey for k,v in pairs(processed) do processedKey = processRecursive(process, k, makePath(path, k, prettify.KEY)) if processedKey ~= nil then processedCopy[processedKey] = processRecursive(process, v, makePath(path, processedKey)) end end local mt = processRecursive(process, getmetatable(processed), makePath(path, prettify.METATABLE)) setmetatable(processedCopy, mt) processed = processedCopy end return processed end ------------------------------------------------------------------- local PrettifyTable = {} local PrettifyTable_mt = {__index = PrettifyTable} function PrettifyTable:puts(...) local args = {...} local buffer = self.buffer local len = #buffer for i=1, #args do len = len + 1 buffer[len] = tostring(args[i]) end end function PrettifyTable:down(f) self.level = self.level + 1 f() self.level = self.level - 1 end function PrettifyTable:tabify() self:puts(self.newline, rep(self.indent, self.level)) end function PrettifyTable:alreadyVisited(v) return self.ids[type(v)][v] ~= nil end function PrettifyTable:getId(v) local tv = type(v) local id = self.ids[tv][v] if not id then id = self.maxIds[tv] + 1 self.maxIds[tv] = id self.ids[tv][v] = id end return id end function PrettifyTable:putKey(k) if isIdentifier(k) then return self:puts(k) end self:puts("[") self:putValue(k) self:puts("]") end function PrettifyTable:putTable(t) if t == prettify.KEY or t == prettify.METATABLE then self:puts(tostring(t)) elseif self:alreadyVisited(t) then self:puts('<table ', self:getId(t), '>') elseif self.level >= self.depth then self:puts('{...}') else if self.tableAppearances[t] > 1 then self:puts('<', self:getId(t), '>') end local nonSequentialKeys = getNonSequentialKeys(t) local length = #t local mt = getmetatable(t) local toStringResult = getToStringResultSafely(t, mt) self:puts('{') self:down(function() if toStringResult then self:puts(' -- ', escape(toStringResult)) if length >= 1 then self:tabify() end end local count = 0 for i=1, length do if count > 0 then self:puts(',') end self:puts(' ') self:putValue(t[i]) count = count + 1 end for _,k in ipairs(nonSequentialKeys) do if count > 0 then self:puts(',') end self:tabify() self:putKey(k) self:puts(' = ') self:putValue(t[k]) count = count + 1 end if mt then if count > 0 then self:puts(',') end self:tabify() self:puts('<metatable> = ') self:putValue(mt) end end) if #nonSequentialKeys > 0 or mt then -- result is multi-lined. Justify closing } self:tabify() elseif length > 0 then -- array tables have one extra space before closing } self:puts(' ') end self:puts('}') end end function PrettifyTable:putValue(v) local tv = type(v) if tv == 'string' then self:puts(smartQuote(escape(v))) elseif tv == 'number' or tv == 'boolean' or tv == 'nil' then self:puts(tostring(v)) elseif tv == 'table' then self:putTable(v) else self:puts('<',tv,' ',self:getId(v),'>') end end function prettify.prettify(root, options) options = options or {} local depth = options.depth or huge local newline = options.newline or '\n' local indent = options.indent or ' ' local process = options.process if process then root = processRecursive(process, root, {}) end local prettify_table = setmetatable({ depth = depth, buffer = {}, level = 0, ids = setmetatable({}, idsMetaTable), maxIds = setmetatable({}, maxIdsMetaTable), newline = newline, indent = indent, tableAppearances = countTableAppearances(root) }, PrettifyTable_mt) prettify_table:putValue(root) return tconcat(prettify_table.buffer) end setmetatable(prettify, { __call = function(_, ...) return prettify.prettify(...) end }) --------------------------------------------------------------------- -- Table -- @section TABLE UTILITIES --------------------------------------------------------------------- function table.val_to_str(v) if "string" == type(v) then v = gsub(v, "\n", "\\n") if match( gsub(v,"[^'\"]",""), '^"+$') then return "'" .. v .. "'" end return '"' .. gsub(v,'"', '\\"') .. '"' else return "table" == type(v) and table.tostring(v) or tostring(v) end end function table.key_to_str(k) if "string" == type(k) and match(k, "^[_%a][_%a%d]*$") then return k else return "[" .. table.val_to_str(k) .. "]" end end --------------------------------------------------------------------- -- Dump table contents to string -- @return string value -- @param tbl A table to be stringified. -- @param pretty Flag to syntactically format the result. --------------------------------------------------------------------- function table.tostring(tbl, pretty) if(pretty) then return prettify(tbl) else local result, done = {}, {} for k, v in ipairs(tbl) do tinsert(result, table.val_to_str(v)) done[k] = true end for k, v in pairs(tbl) do if not done[k] then tinsert(result, table.key_to_str(k) .. "=" .. table.val_to_str(v)) end end return "{" .. tconcat( result, "," ) .. "}" end end --------------------------------------------------------------------- -- Copy all table data from a source to another table -- @return copied data -- @param targetTable The recipient of the copied data. -- @param deepCopy Flag the use of DEEP copying. -- @param mergeTable The origin of the copied data. --------------------------------------------------------------------- function table.copy(targetTable, deepCopy, mergeTable) mergeTable = mergeTable or {}; if(targetTable == nil) then return nil end if(mergeTable[targetTable]) then return mergeTable[targetTable] end local replacementTable = {} for key,value in pairs(targetTable)do if deepCopy and type(value) == "table" then replacementTable[key] = table.copy(value, deepCopy, mergeTable) else replacementTable[key] = value end end setmetatable(replacementTable, table.copy(getmetatable(targetTable), deepCopy, mergeTable)) mergeTable[targetTable] = replacementTable; return replacementTable end
mit
UnfortunateFruit/darkstar
scripts/globals/mobskills/Feather_Maelstrom.lua
30
1043
--------------------------------------------- -- Feather Maelstrom -- Sends a storm of feathers to a single target. -- Additional effect: Bio & Amnesia --------------------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); require("scripts/globals/monstertpmoves"); --------------------------------------------- function onMobSkillCheck(target,mob,skill) return 0; end; function onMobWeaponSkill(target, mob, skill) local typeEffect1 = EFFECT_BIO; local typeEffect2 = EFFECT_AMNESIA; local numhits = 1; local accmod = 2; local dmgmod = 2.8; local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,TP_DMG_VARIES,1,2,3); local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_PHYSICAL,MOBPARAM_PIERCE,info.hitslanded); MobPhysicalStatusEffectMove(mob, target, skill, typeEffect1, 6, 3, 60); MobPhysicalStatusEffectMove(mob, target, skill, typeEffect2, 1, 0, 60); target:delHP(dmg); return dmg; end;
gpl-3.0
hussian/hell_iraq
plugins/supergroup.lua
1
104281
--[[ โ–€โ–„ โ–„โ–€โ–€โ–„โ–„โ–€โ–€โ–„โ–„โ–€โ–€โ–„โ–„โ–€โ–€โ–„โ–„โ–€โ–€โ–„โ–„โ–€โ–€โ–„โ–„โ–€โ–€โ–„โ–€โ–„โ–„โ–€โ–€โ–„โ–„โ–€โ–€โ–„โ–„โ–€โ–€โ–„โ–„โ–€โ–€ โ–€โ–„ โ–„โ–€ โ–€โ–„ โ–„โ–€ โ–€โ–„ โ–„โ–€ BY(@AHMED_ALOBIDE) โ–€โ–„ โ–„โ–€ โ–€โ–„ โ–„โ–€ BY(@hussian_9) โ–€โ–„ โ–„โ–€ โ–€โ–„ โ–„โ–€ โ–€โ–„ โ–„โ–€ โ–€โ–„ โ–„โ–€ ู…ู„ู ุงู„ุณูˆุจุฑ ุงู„ุงู†ูƒู„ุด โ–€โ–„ โ–„โ–€ โ–€โ–„โ–€โ–€โ–„โ–„โ–€โ–€โ–„โ–„โ–€โ–„โ–„โ–€โ–€โ–„โ–„โ–€โ–€โ–„โ–„โ–€โ–„โ–„โ–€โ–€โ–„โ–„โ–€โ–€โ–„โ–„โ–€โ–„โ–„โ–€โ–€โ–„โ–„โ–€โ–€โ–„โ–„โ–€โ–„โ–„โ–€โ–€ --]] local function check_member_super(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg if success == 0 then send_large_msg(receiver, "Promote me to admin first!") end for k,v in pairs(result) do local member_id = v.peer_id if member_id ~= our_id then -- SuperGroup configuration data[tostring(msg.to.id)] = { group_type = 'SuperGroup', long_id = msg.to.peer_id, moderators = {}, set_owner = member_id , settings = { set_name = string.gsub(msg.to.title, '_', ' '), lock_arabic = 'no', lock_link = "no", flood = 'yes', lock_spam = 'yes', lock_sticker = 'no', member = 'no', public = 'no', lock_rtl = 'no', lock_tgservice = 'yes', lock_contacts = 'no', strict = 'no' } } save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = {} save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) local text = '๐ŸŒšุชู… ุชูุนูŠู„ ุงู„ู…ุฌู…ูˆุนู‡ ุงู†ุทูˆ ู…ุฌุงู„ ู„ู„ุณุชุงุฐูŠ ู„ุงุชูƒู…ุฒูˆู†๐Ÿ–•๐Ÿฟ'..msg.to.title return reply_msg(msg.id, text, ok_cb, false) end end end --Check Members #rem supergroup local function check_member_superrem(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result) do local member_id = v.id if member_id ~= our_id then -- Group configuration removal data[tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = nil save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) local text = 'bot has been removed โŽ in Group๐Ÿ”น'..msg.to.title return reply_msg(msg.id, text, ok_cb, false) end end end --Function to Add supergroup local function superadd(msg) local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) channel_get_users(receiver, check_member_super,{receiver = receiver, data = data, msg = msg}) end --Function to remove supergroup local function superrem(msg) local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) channel_get_users(receiver, check_member_superrem,{receiver = receiver, data = data, msg = msg}) end --Get and output admins and bots in supergroup local function callback(cb_extra, success, result) local i = 1 local chat_name = string.gsub(cb_extra.msg.to.print_name, "_", " ") local member_type = cb_extra.member_type local text = member_type.." for "..chat_name..":\n" for k,v in pairsByKeys(result) do if not v.first_name then name = " " else vname = v.first_name:gsub("โ€ฎ", "") name = vname:gsub("_", " ") end text = text.."\n"..i.." - "..name.."["..v.peer_id.."]" i = i + 1 end send_large_msg(cb_extra.receiver, text) end --Get and output info about supergroup local function callback_info(cb_extra, success, result) local title ="Info for SuperGroup: ["..result.title.."]\n\n" local admin_num = "Admin count: "..result.admins_count.."\n" local user_num = "User count: "..result.participants_count.."\n" local kicked_num = "Kicked user count: "..result.kicked_count.."\n" local channel_id = "ID: "..result.peer_id.."\n" if result.username then channel_username = "Username: @"..result.username else channel_username = "" end local text = title..admin_num..user_num..kicked_num..channel_id..channel_username send_large_msg(cb_extra.receiver, text) end --Get and output members of supergroup local function callback_who(cb_extra, success, result) local text = "Members for "..cb_extra.receiver local i = 1 for k,v in pairsByKeys(result) do if not v.print_name then name = " " else vname = v.print_name:gsub("โ€ฎ", "") name = vname:gsub("_", " ") end if v.username then username = " @"..v.username else username = "" end text = text.."\n"..i.." - "..name.." "..username.." [ "..v.peer_id.." ]\n" --text = text.."\n"..username Channel : @DevPointTeam i = i + 1 end local file = io.open("./groups/lists/supergroups/"..cb_extra.receiver..".txt", "w") file:write(text) file:flush() file:close() send_document(cb_extra.receiver,"./groups/lists/supergroups/"..cb_extra.receiver..".txt", ok_cb, false) post_msg(cb_extra.receiver, text, ok_cb, false) end --Get and output list of kicked users for supergroup local function callback_kicked(cb_extra, success, result) --vardump(result) local text = "Kicked Members for SuperGroup "..cb_extra.receiver.."\n\n" local i = 1 for k,v in pairsByKeys(result) do if not v.print_name then name = " " else vname = v.print_name:gsub("โ€ฎ", "") name = vname:gsub("_", " ") end if v.username then name = name.." @"..v.username end text = text.."\n"..i.." - "..name.." [ "..v.peer_id.." ]\n" i = i + 1 end local file = io.open("./groups/lists/supergroups/kicked/"..cb_extra.receiver..".txt", "w") file:write(text) file:flush() file:close() send_document(cb_extra.receiver,"./groups/lists/supergroups/kicked/"..cb_extra.receiver..".txt", ok_cb, false) --send_large_msg(cb_extra.receiver, text) end --Begin supergroup locks local function lock_group_links(msg, data, target) if not is_momod(msg) then return end local group_link_lock = data[tostring(target)]['settings']['lock_link'] if group_link_lock == 'yes' then return 'Links is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['lock_link'] = 'yes' save_data(_config.moderation.data, data) return 'Links has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_links(msg, data, target) if not is_momod(msg) then return end local group_link_lock = data[tostring(target)]['settings']['lock_link'] if group_link_lock == 'no' then return 'Links is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['lock_link'] = 'no' save_data(_config.moderation.data, data) return 'Links has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_all(msg, data, target) if not is_momod(msg) then return end local group_all_lock = data[tostring(target)]['settings']['all'] if group_all_lock == 'yes' then return 'all settings is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['all'] = 'yes' save_data(_config.moderation.data, data) return 'all settings has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_all(msg, data, target) if not is_momod(msg) then return end local group_all_lock = data[tostring(target)]['settings']['all'] if group_all_lock == 'no' then return 'all settings is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['all'] = 'no' save_data(_config.moderation.data, data) return 'all settings has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_etehad(msg, data, target) if not is_momod(msg) then return end local group_etehad_lock = data[tostring(target)]['settings']['etehad'] if group_etehad_lock == 'yes' then return 'etehad setting is already locked' else data[tostring(target)]['settings']['etehad'] = 'yes' save_data(_config.moderation.data, data) return 'etehad setting has been locked' end end local function unlock_group_etehad(msg, data, target) if not is_momod(msg) then return end local group_etehad_lock = data[tostring(target)]['settings']['etehad'] if group_etehad_lock == 'no' then return 'etehad setting is not locked' else data[tostring(target)]['settings']['etehad'] = 'no' save_data(_config.moderation.data, data) return 'etehad setting has been unlocked' end end local function lock_group_leave(msg, data, target) if not is_momod(msg) then return end local group_leave_lock = data[tostring(target)]['settings']['leave'] if group_leave_lock == 'yes' then return 'leave is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['leave'] = 'yes' save_data(_config.moderation.data, data) return 'leave has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_leave(msg, data, target) if not is_momod(msg) then return end local group_leave_lock = data[tostring(target)]['settings']['leave'] if group_leave_lock == 'no' then return 'leave is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['leave'] = 'no' save_data(_config.moderation.data, data) return 'leave has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_operator(msg, data, target) if not is_momod(msg) then return end local group_operator_lock = data[tostring(target)]['settings']['operator'] if group_operator_lock == 'yes' then return 'operator is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['operator'] = 'yes' save_data(_config.moderation.data, data) return 'operator has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_operator(msg, data, target) if not is_momod(msg) then return end local group_operator_lock = data[tostring(target)]['settings']['operator'] if group_operator_lock == 'no' then return 'operator is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['operator'] = 'no' save_data(_config.moderation.data, data) return 'operator has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_reply(msg, data, target) if not is_momod(msg) then return end local group_reply_lock = data[tostring(target)]['settings']['reply'] if group_reply_lock == 'yes' then return 'Reply is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['reply'] = 'yes' save_data(_config.moderation.data, data) return 'Reply has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_reply(msg, data, target) if not is_momod(msg) then return end local group_reply_lock = data[tostring(target)]['settings']['reply'] if group_reply_lock == 'no' then return 'Reply is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['reply'] = 'no' save_data(_config.moderation.data, data) return 'Reply has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_username(msg, data, target) if not is_momod(msg) then return end local group_username_lock = data[tostring(target)]['settings']['username'] if group_username_lock == 'yes' then return 'Username is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['username'] = 'yes' save_data(_config.moderation.data, data) return 'Username has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_username(msg, data, target) if not is_momod(msg) then return end local group_username_lock = data[tostring(target)]['settings']['username'] if group_username_lock == 'no' then return 'Username is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['username'] = 'no' save_data(_config.moderation.data, data) return 'Username has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_media(msg, data, target) if not is_momod(msg) then return end local group_media_lock = data[tostring(target)]['settings']['media'] if group_media_lock == 'yes' then return 'Media is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['media'] = 'yes' save_data(_config.moderation.data, data) return 'Media has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_media(msg, data, target) if not is_momod(msg) then return end local group_media_lock = data[tostring(target)]['settings']['media'] if group_media_lock == 'no' then return 'Media is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['media'] = 'no' save_data(_config.moderation.data, data) return 'Media has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_fosh(msg, data, target) if not is_momod(msg) then return end local group_fosh_lock = data[tostring(target)]['settings']['fosh'] if group_fosh_lock == 'yes' then return 'badword is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['fosh'] = 'yes' save_data(_config.moderation.data, data) return 'badword has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_fosh(msg, data, target) if not is_momod(msg) then return end local group_fosh_lock = data[tostring(target)]['settings']['fosh'] if group_fosh_lock == 'no' then return 'badword is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['fosh'] = 'no' save_data(_config.moderation.data, data) return 'badword has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_join(msg, data, target) if not is_momod(msg) then return end local group_join_lock = data[tostring(target)]['settings']['join'] if group_join_lock == 'yes' then return 'join is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['join'] = 'yes' save_data(_config.moderation.data, data) return 'join has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_join(msg, data, target) if not is_momod(msg) then return end local group_join_lock = data[tostring(target)]['settings']['join'] if group_join_lock == 'no' then return 'join is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['join'] = 'no' save_data(_config.moderation.data, data) return 'join has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_fwd(msg, data, target) if not is_momod(msg) then return end local group_fwd_lock = data[tostring(target)]['settings']['fwd'] if group_fwd_lock == 'yes' then return 'fwd is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['fwd'] = 'yes' save_data(_config.moderation.data, data) return 'fwd has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_fwd(msg, data, target) if not is_momod(msg) then return end local group_fwd_lock = data[tostring(target)]['settings']['fwd'] if group_fwd_lock == 'no' then return 'fwd is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['fwd'] = 'no' save_data(_config.moderation.data, data) return 'fwd has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_english(msg, data, target) if not is_momod(msg) then return end local group_english_lock = data[tostring(target)]['settings']['english'] if group_english_lock == 'yes' then return 'English is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['english'] = 'yes' save_data(_config.moderation.data, data) return 'English has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_english(msg, data, target) if not is_momod(msg) then return end local group_english_lock = data[tostring(target)]['settings']['english'] if group_english_lock == 'no' then return 'English is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['english'] = 'no' save_data(_config.moderation.data, data) return 'English has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_emoji(msg, data, target) if not is_momod(msg) then return end local group_emoji_lock = data[tostring(target)]['settings']['emoji'] if group_emoji_lock == 'yes' then return 'Emoji is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['emoji'] = 'yes' save_data(_config.moderation.data, data) return 'Emoji has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_emoji(msg, data, target) if not is_momod(msg) then return end local group_emoji_lock = data[tostring(target)]['settings']['emoji'] if group_emoji_lock == 'no' then return 'Emoji is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['emoji'] = 'no' save_data(_config.moderation.data, data) return 'Emoji has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_tag(msg, data, target) if not is_momod(msg) then return end local group_tag_lock = data[tostring(target)]['settings']['tag'] if group_tag_lock == 'yes' then return 'tag is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['tag'] = 'yes' save_data(_config.moderation.data, data) return 'tag has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_tag(msg, data, target) if not is_momod(msg) then return end local group_tag_lock = data[tostring(target)]['settings']['tag'] if group_tag_lock == 'no' then return 'tag is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['tag'] = 'no' save_data(_config.moderation.data, data) return 'tag has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_all(msg, data, target) if not is_momod(msg) then return end local group_all_lock = data[tostring(target)]['settings']['all'] if group_all_lock == 'no' then return 'all settings is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['all'] = 'no' save_data(_config.moderation.data, data) return 'all settings has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_spam(msg, data, target) if not is_momod(msg) then return end if not is_owner(msg) then return "Owners only!" end local group_spam_lock = data[tostring(target)]['settings']['lock_spam'] if group_spam_lock == 'yes' then return 'Spam is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['lock_spam'] = 'yes' save_data(_config.moderation.data, data) return 'Spam has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_spam(msg, data, target) if not is_momod(msg) then return end local group_spam_lock = data[tostring(target)]['settings']['lock_spam'] if group_spam_lock == 'no' then return 'Spam is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['lock_spam'] = 'no' save_data(_config.moderation.data, data) return 'Spam has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_flood(msg, data, target) if not is_momod(msg) then return end local group_flood_lock = data[tostring(target)]['settings']['flood'] if group_flood_lock == 'yes' then return 'Flood is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['flood'] = 'yes' save_data(_config.moderation.data, data) return 'Flood has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_flood(msg, data, target) if not is_momod(msg) then return end local group_flood_lock = data[tostring(target)]['settings']['flood'] if group_flood_lock == 'no' then return 'Flood is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['flood'] = 'no' save_data(_config.moderation.data, data) return 'Flood has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_arabic(msg, data, target) if not is_momod(msg) then return end local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic'] if group_arabic_lock == 'yes' then return 'Arabic is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['lock_arabic'] = 'yes' save_data(_config.moderation.data, data) return 'Arabic has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_arabic(msg, data, target) if not is_momod(msg) then return end local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic'] if group_arabic_lock == 'no' then return 'Arabic is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['lock_arabic'] = 'no' save_data(_config.moderation.data, data) return 'Arabic has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_membermod(msg, data, target) if not is_momod(msg) then return end local group_member_lock = data[tostring(target)]['settings']['lock_member'] if group_member_lock == 'yes' then return 'Members are already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['lock_member'] = 'yes' save_data(_config.moderation.data, data) end return 'Members has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end local function unlock_group_membermod(msg, data, target) if not is_momod(msg) then return end local group_member_lock = data[tostring(target)]['settings']['lock_member'] if group_member_lock == 'no' then return 'Members are not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['lock_member'] = 'no' save_data(_config.moderation.data, data) return 'Members has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_rtl(msg, data, target) if not is_momod(msg) then return end local group_rtl_lock = data[tostring(target)]['settings']['lock_rtl'] if group_rtl_lock == 'yes' then return 'RTL is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['lock_rtl'] = 'yes' save_data(_config.moderation.data, data) return 'RTL has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_rtl(msg, data, target) if not is_momod(msg) then return end local group_rtl_lock = data[tostring(target)]['settings']['lock_rtl'] if group_rtl_lock == 'no' then return 'RTL is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['lock_rtl'] = 'no' save_data(_config.moderation.data, data) return 'RTL has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_tgservice(msg, data, target) if not is_momod(msg) then return end local group_tgservice_lock = data[tostring(target)]['settings']['lock_tgservice'] if group_tgservice_lock == 'yes' then return 'Tgservice is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['lock_tgservice'] = 'yes' save_data(_config.moderation.data, data) return 'Tgservice has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_tgservice(msg, data, target) if not is_momod(msg) then return end local group_tgservice_lock = data[tostring(target)]['settings']['lock_tgservice'] if group_tgservice_lock == 'no' then return 'Tgservice is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['lock_tgservice'] = 'no' save_data(_config.moderation.data, data) return 'Tgservice has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_sticker(msg, data, target) if not is_momod(msg) then return end local group_sticker_lock = data[tostring(target)]['settings']['lock_sticker'] if group_sticker_lock == 'yes' then return 'Sticker is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['lock_sticker'] = 'yes' save_data(_config.moderation.data, data) return 'Sticker has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_sticker(msg, data, target) if not is_momod(msg) then return end local group_sticker_lock = data[tostring(target)]['settings']['lock_sticker'] if group_sticker_lock == 'no' then return 'Sticker is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['lock_sticker'] = 'no' save_data(_config.moderation.data, data) return 'Sticker has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_bots(msg, data, target) if not is_momod(msg) then return end local group_bots_lock = data[tostring(target)]['settings']['lock_bots'] if group_bots_lock == 'yes' then return 'Bots is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['lock_bots'] = 'yes' save_data(_config.moderation.data, data) return 'Bots has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_bots(msg, data, target) if not is_momod(msg) then return end local group_bots_lock = data[tostring(target)]['settings']['lock_bots'] if group_bots_lock == 'no' then return 'Bots is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['lock_bots'] = 'no' save_data(_config.moderation.data, data) return 'Bots has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function lock_group_contacts(msg, data, target) if not is_momod(msg) then return end local group_rtl_lock = data[tostring(target)]['settings']['lock_contacts'] if group_contacts_lock == 'yes' then return 'Contact is already locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['lock_contacts'] = 'yes' save_data(_config.moderation.data, data) return 'Contact has been locked ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function unlock_group_contacts(msg, data, target) if not is_momod(msg) then return end local group_contacts_lock = data[tostring(target)]['settings']['lock_contacts'] if group_contacts_lock == 'no' then return 'Contact is not locked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['lock_contacts'] = 'no' save_data(_config.moderation.data, data) return 'Contact has been unlocked ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function enable_strict_rules(msg, data, target) if not is_momod(msg) then return end local group_strict_lock = data[tostring(target)]['settings']['strict'] if group_strict_lock == 'yes' then return 'Settings are already strictly enforced ๐Ÿ›ก\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['strict'] = 'yes' save_data(_config.moderation.data, data) return 'Settings will be strictly enforced ๐Ÿ›ก\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end local function disable_strict_rules(msg, data, target) if not is_momod(msg) then return end local group_strict_lock = data[tostring(target)]['settings']['strict'] if group_strict_lock == 'no' then return 'Settings are not strictly enforced ๐Ÿ›ก\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else data[tostring(target)]['settings']['strict'] = 'no' save_data(_config.moderation.data, data) return 'Settings will not be strictly enforced ๐Ÿ›ก\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end --End supergroup locks --'Set supergroup rules' function local function set_rulesmod(msg, data, target) if not is_momod(msg) then return end local data_cat = 'rules' data[tostring(target)][data_cat] = rules save_data(_config.moderation.data, data) return 'SuperGroup rules set' end --'Get supergroup rules' function local function get_rules(msg, data) local data_cat = 'rules' if not data[tostring(msg.to.id)][data_cat] then return 'No rules available.' end local rules = data[tostring(msg.to.id)][data_cat] local group_name = data[tostring(msg.to.id)]['settings']['set_name'] local rules = group_name..' rules:\n\n'..rules:gsub("/n", " ") return rules end --Set supergroup to public or not public function local function set_public_membermod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_public_lock = data[tostring(target)]['settings']['public'] local long_id = data[tostring(target)]['long_id'] if not long_id then data[tostring(target)]['long_id'] = msg.to.peer_id save_data(_config.moderation.data, data) end if group_public_lock == 'yes' then return 'Group is already public' else data[tostring(target)]['settings']['public'] = 'yes' save_data(_config.moderation.data, data) end return 'SuperGroup is now: public' end local function unset_public_membermod(msg, data, target) if not is_momod(msg) then return end local group_public_lock = data[tostring(target)]['settings']['public'] local long_id = data[tostring(target)]['long_id'] if not long_id then data[tostring(target)]['long_id'] = msg.to.peer_id save_data(_config.moderation.data, data) end if group_public_lock == 'no' then return 'Group is not public' else data[tostring(target)]['settings']['public'] = 'no' data[tostring(target)]['long_id'] = msg.to.long_id save_data(_config.moderation.data, data) return 'SuperGroup is now: not public' end end --Show supergroup settings; function function show_supergroup_settingsmod(msg, target) if not is_momod(msg) then return end local data = load_data(_config.moderation.data) if data[tostring(target)] then if data[tostring(target)]['settings']['flood_msg_max'] then NUM_MSG_MAX = tonumber(data[tostring(target)]['settings']['flood_msg_max']) print('custom'..NUM_MSG_MAX) else NUM_MSG_MAX = 5 end end local bots_protection = "Yes" if data[tostring(target)]['settings']['lock_bots'] then bots_protection = data[tostring(target)]['settings']['lock_bots'] end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['public'] then data[tostring(target)]['settings']['public'] = 'no' end end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['lock_rtl'] then data[tostring(target)]['settings']['lock_rtl'] = 'no' end end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['lock_tgservice'] then data[tostring(target)]['settings']['lock_tgservice'] = 'no' end end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['tag'] then data[tostring(target)]['settings']['tag'] = 'no' end end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['emoji'] then data[tostring(target)]['settings']['emoji'] = 'no' end end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['english'] then data[tostring(target)]['settings']['english'] = 'no' end end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['fwd'] then data[tostring(target)]['settings']['fwd'] = 'no' end end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['reply'] then data[tostring(target)]['settings']['reply'] = 'no' end end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['join'] then data[tostring(target)]['settings']['join'] = 'no' end end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['fosh'] then data[tostring(target)]['settings']['fosh'] = 'no' end end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['username'] then data[tostring(target)]['settings']['username'] = 'no' end end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['media'] then data[tostring(target)]['settings']['media'] = 'no' end end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['leave'] then data[tostring(target)]['settings']['leave'] = 'no' end end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['lock_member'] then data[tostring(target)]['settings']['lock_member'] = 'no' end end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['all'] then data[tostring(target)]['settings']['all'] = 'no' end end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['operator'] then data[tostring(target)]['settings']['operator'] = 'no' end end if data[tostring(target)]['settings'] then if not data[tostring(target)]['settings']['etehad'] then data[tostring(target)]['settings']['etehad'] = 'no' end end local gp_type = data[tostring(msg.to.id)]['group_type'] local settings = data[tostring(target)]['settings'] local text = "๐ŸŽ—โž–โž–โž–๐ŸŽ—โž–โž–โž–๐ŸŽ—\nโ„น๏ธSuperGroups Settings: โฌ‡๏ธ\n๐Ÿ’ŸGroup name : "..msg.to.title.."\n๐ŸŽ—โž–โž–โž–๐ŸŽ—โž–โž–โž–๐ŸŽ—\n๐Ÿ”—lock links : "..settings.lock_link.."\n๐Ÿ“ตLock contacts: "..settings.lock_contacts.."\n๐Ÿ”Lock flood: "..settings.flood.."\n๐Ÿ‘พFlood sensitivity : "..NUM_MSG_MAX.."\n๐Ÿ“ŠLock spam: "..settings.lock_spam.."\n๐Ÿ†ŽLock Arabic: "..settings.lock_arabic.."\n๐Ÿ” Lock english: "..settings.english.."\n๐Ÿ‘คLock Member: "..settings.lock_member.."\n๐Ÿ“ŒLock RTL: "..settings.lock_rtl.."\n๐Ÿ”ฏLock Tgservice: "..settings.lock_tgservice.."\n๐ŸŽกLock sticker: "..settings.lock_sticker.."\nโž•Lock tag(#): "..settings.tag.."\n๐Ÿ˜ƒLock emoji: "..settings.emoji.."\n๐Ÿค–Lock bots: "..bots_protection.."\nโ†ฉ๏ธLock fwd(forward): "..settings.fwd.."\n๐Ÿ”ƒlock reply: "..settings.reply.."\n๐ŸšทLock join: "..settings.join.."\nโ™๏ธLock username(@): "..settings.username.."\n๐Ÿ†˜Lock media: "..settings.media.."\n๐ŸงLock badword: "..settings.fosh.."\n๐ŸšถLock leave: "..settings.leave.."\n๐Ÿ”•Lock all: "..settings.all.."\n๐ŸŽ—โž–โž–โž–๐ŸŽ—โž–โž–โž–๐ŸŽ—\nโ„น๏ธAbout Group: โฌ‡๏ธ\n๐ŸŽ—โž–โž–โž–๐ŸŽ—โž–โž–โž–๐ŸŽ—\nโš ๏ธGroup type: "..gp_type.."\nโœณ๏ธPublic: "..settings.public.."\nโ›”๏ธStrict settings: "..settings.strict.."\n๐ŸŽ—โž–โž–โž–๐ŸŽ—โž–โž–โž–๐ŸŽ—\nโ„น๏ธbot version : v1.1\n\n๐ŸŒ DEV๐ŸŽ—POINT๐ŸŽ—TEAM ๐ŸŒ" return text end local function promote_admin(receiver, member_username, user_id) local data = load_data(_config.moderation.data) local group = string.gsub(receiver, 'channel#id', '') local member_tag_username = string.gsub(member_username, '@', '(at)') if not data[group] then return end if data[group]['moderators'][tostring(user_id)] then return send_large_msg(receiver, member_username..' is already a moderator.') end data[group]['moderators'][tostring(user_id)] = member_tag_username save_data(_config.moderation.data, data) end local function demote_admin(receiver, member_username, user_id) local data = load_data(_config.moderation.data) local group = string.gsub(receiver, 'channel#id', '') if not data[group] then return end if not data[group]['moderators'][tostring(user_id)] then return send_large_msg(receiver, member_tag_username..' is not a moderator.') end data[group]['moderators'][tostring(user_id)] = nil save_data(_config.moderation.data, data) end local function promote2(receiver, member_username, user_id) local data = load_data(_config.moderation.data) local group = string.gsub(receiver, 'channel#id', '') local member_tag_username = string.gsub(member_username, '@', '(at)') if not data[group] then return send_large_msg(receiver, 'SuperGroup is not added.') end if data[group]['moderators'][tostring(user_id)] then return send_large_msg(receiver, member_username..' is already a moderator.') end data[group]['moderators'][tostring(user_id)] = member_tag_username save_data(_config.moderation.data, data) send_large_msg(receiver, member_username..' has been promoted.') end local function demote2(receiver, member_username, user_id) local data = load_data(_config.moderation.data) local group = string.gsub(receiver, 'channel#id', '') if not data[group] then return send_large_msg(receiver, 'Group is not added.') end if not data[group]['moderators'][tostring(user_id)] then return send_large_msg(receiver, member_tag_username..' is not a moderator.') end data[group]['moderators'][tostring(user_id)] = nil save_data(_config.moderation.data, data) send_large_msg(receiver, member_username..' has been demoted.') end local function modlist(msg) local data = load_data(_config.moderation.data) local groups = "groups" if not data[tostring(groups)][tostring(msg.to.id)] then return 'SuperGroup is not added.' end -- determine if table is empty if next(data[tostring(msg.to.id)]['moderators']) == nil then return 'No moderator in this group.' end local i = 1 local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n' for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do message = message ..i..' - '..v..' [' ..k.. '] \n' i = i + 1 end return message end -- Start by reply actions function get_message_callback(extra, success, result) local get_cmd = extra.get_cmd local msg = extra.msg local data = load_data(_config.moderation.data) local print_name = user_print_name(msg.from):gsub("โ€ฎ", "") local name_log = print_name:gsub("_", " ") if get_cmd == "id" and not result.action then local channel = 'channel#id'..result.to.peer_id savelog(msg.to.id, name_log.." ["..msg.from.id.."] obtained id for: ["..result.from.peer_id.."]") id1 = send_large_msg(channel, result.from.peer_id) elseif get_cmd == 'id' and result.action then local action = result.action.type if action == 'chat_add_user' or action == 'chat_del_user' or action == 'chat_rename' or action == 'chat_change_photo' then if result.action.user then user_id = result.action.user.peer_id else user_id = result.peer_id end local channel = 'channel#id'..result.to.peer_id savelog(msg.to.id, name_log.." ["..msg.from.id.."] obtained id by service msg for: ["..user_id.."]") id1 = send_large_msg(channel, user_id) end elseif get_cmd == "idfrom" then local channel = 'channel#id'..result.to.peer_id savelog(msg.to.id, name_log.." ["..msg.from.id.."] obtained id for msg fwd from: ["..result.fwd_from.peer_id.."]") id2 = send_large_msg(channel, result.fwd_from.peer_id) elseif get_cmd == 'channel_block' and not result.action then local member_id = result.from.peer_id local channel_id = result.to.peer_id if member_id == msg.from.id then return send_large_msg("channel#id"..channel_id, "Leave using kickme command") end if is_momod2(member_id, channel_id) and not is_admin2(msg.from.id) then return send_large_msg("channel#id"..channel_id, "You can't kick mods/owner/admins") end if is_admin2(member_id) then return send_large_msg("channel#id"..channel_id, "You can't kick other admins") end --savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked: ["..user_id.."] by reply") kick_user(member_id, channel_id) elseif get_cmd == 'channel_block' and result.action and result.action.type == 'chat_add_user' then local user_id = result.action.user.peer_id local channel_id = result.to.peer_id if member_id == msg.from.id then return send_large_msg("channel#id"..channel_id, "Leave using kickme command") end if is_momod2(member_id, channel_id) and not is_admin2(msg.from.id) then return send_large_msg("channel#id"..channel_id, "You can't kick mods/owner/admins") end if is_admin2(member_id) then return send_large_msg("channel#id"..channel_id, "You can't kick other admins") end savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked: ["..user_id.."] by reply to sev. msg.") kick_user(user_id, channel_id) elseif get_cmd == "del" then delete_msg(result.id, ok_cb, false) savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted a message by reply") elseif get_cmd == "setadmin" then local user_id = result.from.peer_id local channel_id = "channel#id"..result.to.peer_id channel_set_admin(channel_id, "user#id"..user_id, ok_cb, false) if result.from.username then text = "@"..result.from.username.." set as an admin" else text = "[ "..user_id.." ]set as an admin" end savelog(msg.to.id, name_log.." ["..msg.from.id.."] set: ["..user_id.."] as admin by reply") send_large_msg(channel_id, text) elseif get_cmd == "demoteadmin" then local user_id = result.from.peer_id local channel_id = "channel#id"..result.to.peer_id if is_admin2(result.from.peer_id) then return send_large_msg(channel_id, "You can't demote global admins!") end channel_demote(channel_id, "user#id"..user_id, ok_cb, false) if result.from.username then text = "@"..result.from.username.." has been demoted from admin" else text = "[ "..user_id.." ] has been demoted from admin" end savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted: ["..user_id.."] from admin by reply") send_large_msg(channel_id, text) elseif get_cmd == "setowner" then local group_owner = data[tostring(result.to.peer_id)]['set_owner'] if group_owner then local channel_id = 'channel#id'..result.to.peer_id if not is_admin2(tonumber(group_owner)) and not is_support(tonumber(group_owner)) then local user = "user#id"..group_owner channel_demote(channel_id, user, ok_cb, false) end local user_id = "user#id"..result.from.peer_id channel_set_admin(channel_id, user_id, ok_cb, false) data[tostring(result.to.peer_id)]['set_owner'] = tostring(result.from.peer_id) save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] set: ["..result.from.peer_id.."] as owner by reply") if result.from.username then text = "@"..result.from.username.." [ "..result.from.peer_id.." ] added as owner" else text = "[ "..result.from.peer_id.." ] added as owner" end send_large_msg(channel_id, text) end elseif get_cmd == "promote" then local receiver = result.to.peer_id local full_name = (result.from.first_name or '')..' '..(result.from.last_name or '') local member_name = full_name:gsub("โ€ฎ", "") local member_username = member_name:gsub("_", " ") if result.from.username then member_username = '@'.. result.from.username end local member_id = result.from.peer_id if result.to.peer_type == 'channel' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted mod: @"..member_username.."["..result.from.peer_id.."] by reply") promote2("channel#id"..result.to.peer_id, member_username, member_id) --channel_set_mod(channel_id, user, ok_cb, false) end elseif get_cmd == "demote" then local full_name = (result.from.first_name or '')..' '..(result.from.last_name or '') local member_name = full_name:gsub("โ€ฎ", "") local member_username = member_name:gsub("_", " ") if result.from.username then member_username = '@'.. result.from.username end local member_id = result.from.peer_id --local user = "user#id"..result.peer_id savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted mod: @"..member_username.."["..result.from.peer_id.."] by reply") demote2("channel#id"..result.to.peer_id, member_username, member_id) --channel_demote(channel_id, user, ok_cb, false) elseif get_cmd == 'mute_user' then if result.service then local action = result.action.type if action == 'chat_add_user' or action == 'chat_del_user' or action == 'chat_rename' or action == 'chat_change_photo' then if result.action.user then user_id = result.action.user.peer_id end end if action == 'chat_add_user_link' then if result.from then user_id = result.from.peer_id end end else user_id = result.from.peer_id end local receiver = extra.receiver local chat_id = msg.to.id print(user_id) print(chat_id) if is_muted_user(chat_id, user_id) then unmute_user(chat_id, user_id) send_large_msg(receiver, "["..user_id.."] removed from the muted user list") elseif is_admin1(msg) then mute_user(chat_id, user_id) send_large_msg(receiver, " ["..user_id.."] added to the muted user list") end end end -- End by reply actions --By ID actions local function cb_user_info(extra, success, result) local receiver = extra.receiver local user_id = result.peer_id local get_cmd = extra.get_cmd local data = load_data(_config.moderation.data) --[[if get_cmd == "setadmin" then local user_id = "user#id"..result.peer_id channel_set_admin(receiver, user_id, ok_cb, false) if result.username then text = "@"..result.username.." has been set as an admin" else text = "[ "..result.peer_id.." ] has been set as an admin" end send_large_msg(receiver, text)]] if get_cmd == "demoteadmin" then if is_admin2(result.peer_id) then return send_large_msg(receiver, "You can't demote global admins!") end local user_id = "user#id"..result.peer_id channel_demote(receiver, user_id, ok_cb, false) if result.username then text = "@"..result.username.." has been demoted from admin" send_large_msg(receiver, text) else text = "[ "..result.peer_id.." ] has been demoted from admin" send_large_msg(receiver, text) end elseif get_cmd == "promote" then if result.username then member_username = "@"..result.username else member_username = string.gsub(result.print_name, '_', ' ') end promote2(receiver, member_username, user_id) elseif get_cmd == "demote" then if result.username then member_username = "@"..result.username else member_username = string.gsub(result.print_name, '_', ' ') end demote2(receiver, member_username, user_id) end end -- Begin resolve username actions local function callbackres(extra, success, result) local member_id = result.peer_id local member_username = "@"..result.username local get_cmd = extra.get_cmd if get_cmd == "res" then local user = result.peer_id local name = string.gsub(result.print_name, "_", " ") local channel = 'channel#id'..extra.channelid send_large_msg(channel, user..'\n'..name) return user elseif get_cmd == "id" then local user = result.peer_id local channel = 'channel#id'..extra.channelid send_large_msg(channel, user) return user elseif get_cmd == "invite" then local receiver = extra.channel local user_id = "user#id"..result.peer_id channel_invite(receiver, user_id, ok_cb, false) --[[elseif get_cmd == "channel_block" then local user_id = result.peer_id local channel_id = extra.channelid local sender = extra.sender if member_id == sender then return send_large_msg("channel#id"..channel_id, "Leave using kickme command") end if is_momod2(member_id, channel_id) and not is_admin2(sender) then return send_large_msg("channel#id"..channel_id, "You can't kick mods/owner/admins") end if is_admin2(member_id) then return send_large_msg("channel#id"..channel_id, "You can't kick other admins") end kick_user(user_id, channel_id) elseif get_cmd == "setadmin" then local user_id = "user#id"..result.peer_id local channel_id = extra.channel channel_set_admin(channel_id, user_id, ok_cb, false) if result.username then text = "@"..result.username.." has been set as an admin" send_large_msg(channel_id, text) else text = "@"..result.peer_id.." has been set as an admin" send_large_msg(channel_id, text) end elseif Dev = Point elseif get_cmd == "setowner" then local receiver = extra.channel local channel = string.gsub(receiver, 'channel#id', '') local from_id = extra.from_id local group_owner = data[tostring(channel)]['set_owner'] if group_owner then local user = "user#id"..group_owner if not is_admin2(group_owner) and not is_support(group_owner) then channel_demote(receiver, user, ok_cb, false) end local user_id = "user#id"..result.peer_id channel_set_admin(receiver, user_id, ok_cb, false) data[tostring(channel)]['set_owner'] = tostring(result.peer_id) save_data(_config.moderation.data, data) savelog(channel, name_log.." ["..from_id.."] set ["..result.peer_id.."] as owner by username") if result.username then text = member_username.." [ "..result.peer_id.." ] added as owner" else text = "[ "..result.peer_id.." ] added as owner" end send_large_msg(receiver, text) end]] elseif get_cmd == "promote" then local receiver = extra.channel local user_id = result.peer_id --local user = "user#id"..result.peer_id promote2(receiver, member_username, user_id) --channel_set_mod(receiver, user, ok_cb, false) elseif get_cmd == "demote" then local receiver = extra.channel local user_id = result.peer_id local user = "user#id"..result.peer_id demote2(receiver, member_username, user_id) elseif get_cmd == "demoteadmin" then local user_id = "user#id"..result.peer_id local channel_id = extra.channel if is_admin2(result.peer_id) then return send_large_msg(channel_id, "You can't demote global admins!") end channel_demote(channel_id, user_id, ok_cb, false) if result.username then text = "@"..result.username.." has been demoted from admin" send_large_msg(channel_id, text) else text = "@"..result.peer_id.." has been demoted from admin" send_large_msg(channel_id, text) end local receiver = extra.channel local user_id = result.peer_id demote_admin(receiver, member_username, user_id) elseif get_cmd == 'mute_user' then local user_id = result.peer_id local receiver = extra.receiver local chat_id = string.gsub(receiver, 'channel#id', '') if is_muted_user(chat_id, user_id) then unmute_user(chat_id, user_id) send_large_msg(receiver, " ["..user_id.."] removed from muted user list") elseif is_owner(extra.msg) then mute_user(chat_id, user_id) send_large_msg(receiver, " ["..user_id.."] added to muted user list") end end end --End resolve username actions --Begin non-channel_invite username actions local function in_channel_cb(cb_extra, success, result) local get_cmd = cb_extra.get_cmd local receiver = cb_extra.receiver local msg = cb_extra.msg local data = load_data(_config.moderation.data) local print_name = user_print_name(cb_extra.msg.from):gsub("โ€ฎ", "") local name_log = print_name:gsub("_", " ") local member = cb_extra.username local memberid = cb_extra.user_id if member then text = 'No user @'..member..' in this SuperGroup.' else text = 'No user ['..memberid..'] in this SuperGroup.' end if get_cmd == "channel_block" then for k,v in pairs(result) do vusername = v.username vpeer_id = tostring(v.peer_id) if vusername == member or vpeer_id == memberid then local user_id = v.peer_id local channel_id = cb_extra.msg.to.id local sender = cb_extra.msg.from.id if user_id == sender then return send_large_msg("channel#id"..channel_id, "Leave using kickme command") end if is_momod2(user_id, channel_id) and not is_admin2(sender) then return send_large_msg("channel#id"..channel_id, "You can't kick mods/owner/admins") end if is_admin2(user_id) then return send_large_msg("channel#id"..channel_id, "You can't kick other admins") end if v.username then text = "" savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked: @"..v.username.." ["..v.peer_id.."]") else text = "" savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked: ["..v.peer_id.."]") end kick_user(user_id, channel_id) return end end elseif get_cmd == "setadmin" then for k,v in pairs(result) do vusername = v.username vpeer_id = tostring(v.peer_id) if vusername == member or vpeer_id == memberid then local user_id = "user#id"..v.peer_id local channel_id = "channel#id"..cb_extra.msg.to.id channel_set_admin(channel_id, user_id, ok_cb, false) if v.username then text = "@"..v.username.." ["..v.peer_id.."] has been set as an admin" savelog(msg.to.id, name_log.." ["..msg.from.id.."] set admin @"..v.username.." ["..v.peer_id.."]") else text = "["..v.peer_id.."] has been set as an admin" savelog(msg.to.id, name_log.." ["..msg.from.id.."] set admin "..v.peer_id) end if v.username then member_username = "@"..v.username else member_username = string.gsub(v.print_name, '_', ' ') end local receiver = channel_id local user_id = v.peer_id promote_admin(receiver, member_username, user_id) end send_large_msg(channel_id, text) return end elseif get_cmd == 'setowner' then for k,v in pairs(result) do vusername = v.username vpeer_id = tostring(v.peer_id) if vusername == member or vpeer_id == memberid then local channel = string.gsub(receiver, 'channel#id', '') local from_id = cb_extra.msg.from.id local group_owner = data[tostring(channel)]['set_owner'] if group_owner then if not is_admin2(tonumber(group_owner)) and not is_support(tonumber(group_owner)) then local user = "user#id"..group_owner channel_demote(receiver, user, ok_cb, false) end local user_id = "user#id"..v.peer_id channel_set_admin(receiver, user_id, ok_cb, false) data[tostring(channel)]['set_owner'] = tostring(v.peer_id) save_data(_config.moderation.data, data) savelog(channel, name_log.."["..from_id.."] set ["..v.peer_id.."] as owner by username") if result.username then text = member_username.." ["..v.peer_id.."] added as owner" else text = "["..v.peer_id.."] added as owner" end end elseif memberid and vusername ~= member and vpeer_id ~= memberid then local channel = string.gsub(receiver, 'channel#id', '') local from_id = cb_extra.msg.from.id local group_owner = data[tostring(channel)]['set_owner'] if group_owner then if not is_admin2(tonumber(group_owner)) and not is_support(tonumber(group_owner)) then local user = "user#id"..group_owner channel_demote(receiver, user, ok_cb, false) end data[tostring(channel)]['set_owner'] = tostring(memberid) save_data(_config.moderation.data, data) savelog(channel, name_log.."["..from_id.."] set ["..memberid.."] as owner by username") text = "["..memberid.."] added as owner" end end end end send_large_msg(receiver, text) end --End non-channel_invite username actions --'Set supergroup photo' function local function set_supergroup_photo(msg, success, result) local data = load_data(_config.moderation.data) if not data[tostring(msg.to.id)] then return end local receiver = get_receiver(msg) if success then local file = 'data/photos/channel_photo_'..msg.to.id..'.jpg' print('File downloaded to:', result) os.rename(result, file) print('File moved to:', file) channel_set_photo(receiver, file, ok_cb, false) data[tostring(msg.to.id)]['settings']['set_photo'] = file save_data(_config.moderation.data, data) send_large_msg(receiver, 'Photo saved!', ok_cb, false) else print('Error downloading: '..msg.id) send_large_msg(receiver, 'Failed, please try again!', ok_cb, false) end end --Run function local function DevPointTeam(msg, matches) if msg.to.type == 'chat' then if matches[1] == 'tosuper' then if not is_admin1(msg) then return end local receiver = get_receiver(msg) chat_upgrade(receiver, ok_cb, false) end elseif msg.to.type == 'channel'then if matches[1] == 'tosuper' then if not is_admin1(msg) then return end return "Already a SuperGroup" end end if msg.to.type == 'channel' then local support_id = msg.from.id local receiver = get_receiver(msg) local print_name = user_print_name(msg.from):gsub("โ€ฎ", "") local name_log = print_name:gsub("_", " ") local data = load_data(_config.moderation.data) if matches[1] == 'addbot' and not matches[2] then if not is_admin1(msg) and not is_support(support_id) then return end if is_super_group(msg) then local iDev1 = "is already added !" return send_large_msg(receiver, iDev1) end print("SuperGroup "..msg.to.print_name.."("..msg.to.id..") added") savelog(msg.to.id, name_log.." ["..msg.from.id.."] added SuperGroup") superadd(msg) set_mutes(msg.to.id) channel_set_admin(receiver, 'user#id'..msg.from.id, ok_cb, false) end if matches[1] == 'addbot' and is_admin1(msg) and not matches[2] then if not is_super_group(msg) then local iDev1 = "This Group not added ๐Ÿค– OK I will add this Group" return send_large_msg(receiver, iDev1) end print("SuperGroup "..msg.to.print_name.."("..msg.to.id..") removed") superrem(msg) rem_mutes(msg.to.id) end if matches[1] == 'rembot' and is_admin1(msg) and not matches[2] then if not is_super_group(msg) then return reply_msg(msg.id, 'SuperGroup is not added.', ok_cb, false) end print("SuperGroup "..msg.to.print_name.."("..msg.to.id..") removed") superrem(msg) rem_mutes(msg.to.id) end if not data[tostring(msg.to.id)] then return end--@DevPointTeam = Dont Remove if matches[1] == "gpinfo" then if not is_owner(msg) then return end savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup info") channel_info(receiver, callback_info, {receiver = receiver, msg = msg}) end if matches[1] == "admins" then if not is_owner(msg) and not is_support(msg.from.id) then return end member_type = 'Admins' savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup Admins list") admins = channel_get_admins(receiver,callback, {receiver = receiver, msg = msg, member_type = member_type}) end if matches[1] == "owner" then local group_owner = data[tostring(msg.to.id)]['set_owner'] if not group_owner then return "no owner,ask admins in support groups to set owner for your SuperGroup" end savelog(msg.to.id, name_log.." ["..msg.from.id.."] used /owner") return "SuperGroup owner is ["..group_owner..']' end if matches[1] == "modlist" then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group modlist") return modlist(msg) -- channel_get_admins(receiver,callback, {receiver = receiver}) end if matches[1] == "bots" and is_momod(msg) then member_type = 'Bots' savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup bots list") channel_get_bots(receiver, callback, {receiver = receiver, msg = msg, member_type = member_type}) end if matches[1] == "who" and not matches[2] and is_momod(msg) then local user_id = msg.from.peer_id savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup users list") channel_get_users(receiver, callback_who, {receiver = receiver}) end if matches[1] == "kicked" and is_momod(msg) then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested Kicked users list") channel_get_kicked(receiver, callback_kicked, {receiver = receiver}) end if matches[1] == 'del' and is_momod(msg) then if type(msg.reply_id) ~= "nil" then local cbreply_extra = { get_cmd = 'del', msg = msg } delete_msg(msg.id, ok_cb, false) get_message(msg.reply_id, get_message_callback, cbreply_extra) end end if matches[1] == 'bb' or matches[1] == 'kick' and is_momod(msg) then if type(msg.reply_id) ~= "nil" then local cbreply_extra = { get_cmd = 'channel_block', msg = msg } get_message(msg.reply_id, get_message_callback, cbreply_extra) elseif matches[1] == 'bb' or matches[1] == 'kick' and string.match(matches[2], '^%d+$') then --[[local user_id = matches[2] local channel_id = msg.to.id Dev = Point if is_momod2(user_id, channel_id) and not is_admin2(user_id) then return send_large_msg(receiver, "You can't kick mods/owner/admins") end @DevPointTeam savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked: [ user#id"..user_id.." ]") kick_user(user_id, channel_id)]] local get_cmd = 'channel_block' local msg = msg local user_id = matches[2] channel_get_users (receiver, in_channel_cb, {get_cmd=get_cmd, receiver=receiver, msg=msg, user_id=user_id}) elseif msg.text:match("@[%a%d]") then --[[local cbres_extra = { channelid = msg.to.id, get_cmd = 'channel_block', sender = msg.from.id Dev = Point } local username = matches[2] local username = string.gsub(matches[2], '@', '') savelog(msg.to.id, name_log.." ["..msg.from.id.."] kicked: @"..username) resolve_username(username, callbackres, cbres_extra)]] local get_cmd = 'channel_block' local msg = msg local username = matches[2] local username = string.gsub(matches[2], '@', '') channel_get_users (receiver, in_channel_cb, {get_cmd=get_cmd, receiver=receiver, msg=msg, username=username}) end end if matches[1] == 'id' then if type(msg.reply_id) ~= "nil" and is_momod(msg) and not matches[2] then local cbreply_extra = { get_cmd = 'id', msg = msg } get_message(msg.reply_id, get_message_callback, cbreply_extra) elseif type(msg.reply_id) ~= "nil" and matches[2] == "from" and is_momod(msg) then local cbreply_extra = { get_cmd = 'idfrom', msg = msg } get_message(msg.reply_id, get_message_callback, cbreply_extra) elseif msg.text:match("@[%a%d]") then local cbres_extra = { channelid = msg.to.id, get_cmd = 'id' } local username = matches[2] local username = username:gsub("@","") savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested ID for: @"..username) resolve_username(username, callbackres, cbres_extra) else savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup ID") local text = "โ™๏ธ- Name: " ..string.gsub(msg.from.print_name, "_", " ").. "\nโ™‘๏ธ- Username: @"..(msg.from.username or '----').."\n๐Ÿ†”- ID: "..msg.from.id.."\n๐Ÿ’Ÿ- Group Name: " ..string.gsub(msg.to.print_name, "_", " ").. "\nโ„น๏ธ- Group ID: "..msg.to.id return reply_msg(msg.id, text, ok_cb, false) end end if matches[1] == 'kickme' then if msg.to.type == 'channel' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] left via kickme") channel_kick("channel#id"..msg.to.id, "user#id"..msg.from.id, ok_cb, false) end end if matches[1] == 'newlink' and is_momod(msg)then local function callback_link (extra , success, result) local receiver = get_receiver(msg) if success == 0 then send_large_msg(receiver, '*Error: Failed to retrieve link* \nReason: Not creator.\n\nIf you have the link, please use /setlink to set it') data[tostring(msg.to.id)]['settings']['set_link'] = nil save_data(_config.moderation.data, data) else send_large_msg(receiver, "Created a new link") data[tostring(msg.to.id)]['settings']['set_link'] = result save_data(_config.moderation.data, data) end end savelog(msg.to.id, name_log.." ["..msg.from.id.."] attempted to create a new SuperGroup link") export_channel_link(receiver, callback_link, false) end if matches[1] == 'setlink' and is_owner(msg) then data[tostring(msg.to.id)]['settings']['set_link'] = 'waiting' save_data(_config.moderation.data, data) return 'Please send the new group link now' end if msg.text then if msg.text:match("^(https://telegram.me/joinchat/%S+)$") and data[tostring(msg.to.id)]['settings']['set_link'] == 'waiting' and is_owner(msg) then data[tostring(msg.to.id)]['settings']['set_link'] = msg.text save_data(_config.moderation.data, data) return "New link set" end end if matches[1] == 'link' then if not is_momod(msg) then return end local group_link = data[tostring(msg.to.id)]['settings']['set_link'] if not group_link then return "Create a link using /newlink first!\n\nOr if I am not creator use /setlink to set your link" end savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group link ["..group_link.."]") return "link Group ["..msg.to.title.."] :\n"..group_link end if matches[1] == "invite" and is_sudo(msg) then local cbres_extra = { channel = get_receiver(msg), get_cmd = "invite" } local username = matches[2] local username = username:gsub("@","") savelog(msg.to.id, name_log.." ["..msg.from.id.."] invited @"..username) resolve_username(username, callbackres, cbres_extra) end if matches[1] == 'res' and is_owner(msg) then local cbres_extra = { channelid = msg.to.id, get_cmd = 'res' } local username = matches[2] local username = username:gsub("@","") savelog(msg.to.id, name_log.." ["..msg.from.id.."] resolved username: @"..username) resolve_username(username, callbackres, cbres_extra) end --[[if matches[1] == 'kick' and is_momod(msg) then local receiver = channel..matches[3] local user = "user#id"..matches[2] chaannel_kick(receiver, user, ok_cb, false) @DevPointTeam end]] if matches[1] == 'setadmin' then if not is_support(msg.from.id) and not is_owner(msg) then return end if type(msg.reply_id) ~= "nil" then local cbreply_extra = { get_cmd = 'setadmin', msg = msg } setadmin = get_message(msg.reply_id, get_message_callback, cbreply_extra) elseif matches[1] == 'setadmin' and string.match(matches[2], '^%d+$') then --[[] local receiver = get_receiver(msg) local user_id = "user#id"..matches[2] local get_cmd = 'setadmin' Dev = Point user_info(user_id, cb_user_info, {receiver = receiver, get_cmd = get_cmd})]] local get_cmd = 'setadmin' local msg = msg local user_id = matches[2] channel_get_users (receiver, in_channel_cb, {get_cmd=get_cmd, receiver=receiver, msg=msg, user_id=user_id}) elseif matches[1] == 'setadmin' and not string.match(matches[2], '^%d+$') then --[[local cbres_extra = { channel = get_receiver(msg), get_cmd = 'setadmin' } local username = matches[2] local username = string.gsub(matches[2], '@', '') savelog(msg.to.id, name_log.." ["..msg.from.id.."] set admin @"..username) resolve_username(username, callbackres, cbres_extra)]] local get_cmd = 'setadmin' local msg = msg local username = matches[2] local username = string.gsub(matches[2], '@', '') channel_get_users (receiver, in_channel_cb, {get_cmd=get_cmd, receiver=receiver, msg=msg, username=username}) end end if matches[1] == 'demoteadmin' then if not is_support(msg.from.id) and not is_owner(msg) then return end if type(msg.reply_id) ~= "nil" then local cbreply_extra = { get_cmd = 'demoteadmin', msg = msg } demoteadmin = get_message(msg.reply_id, get_message_callback, cbreply_extra) elseif matches[1] == 'demoteadmin' and string.match(matches[2], '^%d+$') then local receiver = get_receiver(msg) local user_id = "user#id"..matches[2] local get_cmd = 'demoteadmin' user_info(user_id, cb_user_info, {receiver = receiver, get_cmd = get_cmd}) elseif matches[1] == 'demoteadmin' and not string.match(matches[2], '^%d+$') then local cbres_extra = { channel = get_receiver(msg), get_cmd = 'demoteadmin' } local username = matches[2] local username = string.gsub(matches[2], '@', '') savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted admin @"..username) resolve_username(username, callbackres, cbres_extra) end end if matches[1] == 'setowner' and is_owner(msg) then if type(msg.reply_id) ~= "nil" then local cbreply_extra = { get_cmd = 'setowner', msg = msg } setowner = get_message(msg.reply_id, get_message_callback, cbreply_extra) elseif matches[1] == 'setowner' and string.match(matches[2], '^%d+$') then --[[ local group_owner = data[tostring(msg.to.id)]['set_owner'] if group_owner then local receiver = get_receiver(msg) local user_id = "user#id"..group_owner if not is_admin2(group_owner) and not is_support(group_owner) then channel_demote(receiver, user_id, ok_cb, false) end local user = "user#id"..matches[2] channel_set_admin(receiver, user, ok_cb, false) data[tostring(msg.to.id)]['set_owner'] = tostring(matches[2]) save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] set ["..matches[2].."] as owner") local text = "[ "..matches[2].." ] added as owner" return text Dev = Point end]] local get_cmd = 'setowner' local msg = msg local user_id = matches[2] channel_get_users (receiver, in_channel_cb, {get_cmd=get_cmd, receiver=receiver, msg=msg, user_id=user_id}) elseif matches[1] == 'setowner' and not string.match(matches[2], '^%d+$') then local get_cmd = 'setowner' local msg = msg local username = matches[2] local username = string.gsub(matches[2], '@', '') channel_get_users (receiver, in_channel_cb, {get_cmd=get_cmd, receiver=receiver, msg=msg, username=username}) end end if matches[1] == 'promote' then if not is_momod(msg) then return end if not is_owner(msg) then return "Only owner/admin can promote" end if type(msg.reply_id) ~= "nil" then local cbreply_extra = { get_cmd = 'promote', msg = msg } promote = get_message(msg.reply_id, get_message_callback, cbreply_extra) elseif matches[1] == 'promote' and string.match(matches[2], '^%d+$') then local receiver = get_receiver(msg) local user_id = "user#id"..matches[2] local get_cmd = 'promote' savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted user#id"..matches[2]) user_info(user_id, cb_user_info, {receiver = receiver, get_cmd = get_cmd}) elseif matches[1] == 'promote' and not string.match(matches[2], '^%d+$') then local cbres_extra = { channel = get_receiver(msg), get_cmd = 'promote', } local username = matches[2] local username = string.gsub(matches[2], '@', '') savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted @"..username) return resolve_username(username, callbackres, cbres_extra) end end if matches[1] == 'mp' and is_sudo(msg) then channel = get_receiver(msg) user_id = 'user#id'..matches[2] channel_set_mod(channel, user_id, ok_cb, false) return "ok" end if matches[1] == 'md' and is_sudo(msg) then channel = get_receiver(msg) user_id = 'user#id'..matches[2] channel_demote(channel, user_id, ok_cb, false) return "ok" end if matches[1] == 'demote' then if not is_momod(msg) then return end if not is_owner(msg) then return "Only owner/support/admin can promote" end if type(msg.reply_id) ~= "nil" then local cbreply_extra = { get_cmd = 'demote', msg = msg } demote = get_message(msg.reply_id, get_message_callback, cbreply_extra) elseif matches[1] == 'demote' and string.match(matches[2], '^%d+$') then local receiver = get_receiver(msg) local user_id = "user#id"..matches[2] local get_cmd = 'demote' savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted user#id"..matches[2]) user_info(user_id, cb_user_info, {receiver = receiver, get_cmd = get_cmd}) elseif not string.match(matches[2], '^%d+$') then local cbres_extra = { channel = get_receiver(msg), get_cmd = 'demote' } local username = matches[2] local username = string.gsub(matches[2], '@', '') savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted @"..username) return resolve_username(username, callbackres, cbres_extra) end end if matches[1] == "setname" and is_momod(msg) then local receiver = get_receiver(msg) local set_name = string.gsub(matches[2], '_', '') savelog(msg.to.id, name_log.." ["..msg.from.id.."] renamed SuperGroup to: "..matches[2]) rename_channel(receiver, set_name, ok_cb, false) end if msg.service and msg.action.type == 'chat_rename' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] renamed SuperGroup to: "..msg.to.title) data[tostring(msg.to.id)]['settings']['set_name'] = msg.to.title save_data(_config.moderation.data, data) end if matches[1] == "setabout" and is_momod(msg) then local receiver = get_receiver(msg) local about_text = matches[2] local data_cat = 'description' local target = msg.to.id data[tostring(target)][data_cat] = about_text save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup description to: "..about_text) channel_set_about(receiver, about_text, ok_cb, false) return "Description has been set.\n\nSelect the chat again to see the changes." end if matches[1] == "setusername" and is_admin1(msg) then local function ok_username_cb (extra, success, result) local receiver = extra.receiver if success == 1 then send_large_msg(receiver, "SuperGroup username Set.\n\nSelect the chat again to see the changes.") elseif success == 0 then send_large_msg(receiver, "Failed to set SuperGroup username.\nUsername may already be taken.\n\nNote: Username can use a-z, 0-9 and underscores.\nMinimum length is 5 characters.") end end local username = string.gsub(matches[2], '@', '') channel_set_username(receiver, username, ok_username_cb, {receiver=receiver}) end if matches[1] == 'setrules' and is_momod(msg) then rules = matches[2] local target = msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group rules to ["..matches[2].."]") return set_rulesmod(msg, data, target) end if msg.media then if msg.media.type == 'photo' and data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' and is_momod(msg) then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set new SuperGroup photo") load_photo(msg.id, set_supergroup_photo, msg) return end end if matches[1] == 'setphoto' and is_momod(msg) then data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting' save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] started setting new SuperGroup photo") return 'Please send the new group photo now' end if matches[1] == 'clean' then if not is_momod(msg) then return end if not is_momod(msg) then return "Only owner can clean" end if matches[2] == 'modlist' then if next(data[tostring(msg.to.id)]['moderators']) == nil then return 'No moderator(s) in this SuperGroup.' end for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do data[tostring(msg.to.id)]['moderators'][tostring(k)] = nil save_data(_config.moderation.data, data) end savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned modlist") return 'Modlist has been cleaned' end if matches[2] == 'rules' then local data_cat = 'rules' if data[tostring(msg.to.id)][data_cat] == nil then return "Rules have not been set" end data[tostring(msg.to.id)][data_cat] = nil save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned rules") return 'Rules have been cleaned' end if matches[2] == 'about' then local receiver = get_receiver(msg) local about_text = ' ' local data_cat = 'description' if data[tostring(msg.to.id)][data_cat] == nil then return 'About is not set' end data[tostring(msg.to.id)][data_cat] = nil save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned about") channel_set_about(receiver, about_text, ok_cb, false) return "About has been cleaned" end if matches[2] == 'silentlist' then chat_id = msg.to.id local hash = 'mute_user:'..chat_id redis:del(hash) return "silentlist Cleaned" end if matches[2] == 'username' and is_admin1(msg) then local function ok_username_cb (extra, success, result) local receiver = extra.receiver if success == 1 then send_large_msg(receiver, "SuperGroup username cleaned.") elseif success == 0 then send_large_msg(receiver, "Failed to clean SuperGroup username.") end end local username = "" channel_set_username(receiver, username, ok_username_cb, {receiver=receiver}) end end if matches[1] == 'lock' and is_momod(msg) then local target = msg.to.id if matches[2] == 'all' then local safemode ={ lock_group_links(msg, data, target), lock_group_tag(msg, data, target), lock_group_spam(msg, data, target), lock_group_flood(msg, data, target), lock_group_arabic(msg, data, target), lock_group_membermod(msg, data, target), lock_group_rtl(msg, data, target), lock_group_tgservice(msg, data, target), lock_group_sticker(msg, data, target), lock_group_contacts(msg, data, target), lock_group_english(msg, data, target), lock_group_fwd(msg, data, target), lock_group_reply(msg, data, target), lock_group_join(msg, data, target), lock_group_emoji(msg, data, target), lock_group_username(msg, data, target), lock_group_fosh(msg, data, target), lock_group_media(msg, data, target), lock_group_leave(msg, data, target), lock_group_bots(msg, data, target), lock_group_operator(msg, data, target), } return lock_group_all(msg, data, target), safemode end if matches[2] == 'etehad' then local etehad ={ unlock_group_links(msg, data, target), lock_group_tag(msg, data, target), lock_group_spam(msg, data, target), lock_group_flood(msg, data, target), unlock_group_arabic(msg, data, target), lock_group_membermod(msg, data, target), unlock_group_rtl(msg, data, target), lock_group_tgservice(msg, data, target), lock_group_sticker(msg, data, target), unlock_group_contacts(msg, data, target), unlock_group_english(msg, data, target), unlock_group_fwd(msg, data, target), unlock_group_reply(msg, data, target), lock_group_join(msg, data, target), unlock_group_emoji(msg, data, target), unlock_group_username(msg, data, target), lock_group_fosh(msg, data, target), unlock_group_media(msg, data, target), lock_group_leave(msg, data, target), lock_group_bots(msg, data, target), unlock_group_operator(msg, data, target), } return lock_group_etehad(msg, data, target), etehad end if matches[2] == 'links' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked link posting ") return lock_group_links(msg, data, target) end if matches[2] == 'join' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked join ") return lock_group_join(msg, data, target) end if matches[2] == 'tag' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked tag ") return lock_group_tag(msg, data, target) end if matches[2] == 'spam' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked spam ") return lock_group_spam(msg, data, target) end if matches[2] == 'flood' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked flood ") return lock_group_flood(msg, data, target) end if matches[2] == 'arabic' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked arabic ") return lock_group_arabic(msg, data, target) end if matches[2] == 'member' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked member ") return lock_group_membermod(msg, data, target) end if matches[2]:lower() == 'rtl' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked rtl chars. in names") return lock_group_rtl(msg, data, target) end if matches[2] == 'tgservice' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked Tgservice Actions") return lock_group_tgservice(msg, data, target) end if matches[2] == 'sticker' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked sticker posting") return lock_group_sticker(msg, data, target) end if matches[2] == 'contacts' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked contact posting") return lock_group_contacts(msg, data, target) end if matches[2] == 'strict' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked enabled strict settings") return enable_strict_rules(msg, data, target) end if matches[2] == 'english' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked english") return lock_group_english(msg, data, target) end if matches[2] == 'fwd' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked fwd") return lock_group_fwd(msg, data, target) end if matches[2] == 'reply' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked reply") return lock_group_reply(msg, data, target) end if matches[2] == 'emoji' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked emoji") return lock_group_emoji(msg, data, target) end if matches[2] == 'badword' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked fosh") return lock_group_fosh(msg, data, target) end if matches[2] == 'media' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked media") return lock_group_media(msg, data, target) end if matches[2] == 'username' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked username") return lock_group_username(msg, data, target) end if matches[2] == 'leave' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked leave") return lock_group_leave(msg, data, target) end if matches[2] == 'bots' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked bots") return lock_group_bots(msg, data, target) end if matches[2] == 'operator' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked operator") return lock_group_operator(msg, data, target) end end if matches[1] == 'unlock' and is_momod(msg) then local target = msg.to.id if matches[2] == 'all' then local dsafemode ={ unlock_group_links(msg, data, target), unlock_group_tag(msg, data, target), unlock_group_spam(msg, data, target), unlock_group_flood(msg, data, target), unlock_group_arabic(msg, data, target), unlock_group_membermod(msg, data, target), unlock_group_rtl(msg, data, target), unlock_group_tgservice(msg, data, target), unlock_group_sticker(msg, data, target), unlock_group_contacts(msg, data, target), unlock_group_english(msg, data, target), unlock_group_fwd(msg, data, target), unlock_group_reply(msg, data, target), unlock_group_join(msg, data, target), unlock_group_emoji(msg, data, target), unlock_group_username(msg, data, target), unlock_group_fosh(msg, data, target), unlock_group_media(msg, data, target), unlock_group_leave(msg, data, target), unlock_group_bots(msg, data, target), unlock_group_operator(msg, data, target), } return unlock_group_all(msg, data, target), dsafemode end if matches[2] == 'etehad' then local detehad ={ lock_group_links(msg, data, target), unlock_group_tag(msg, data, target), lock_group_spam(msg, data, target), lock_group_flood(msg, data, target), unlock_group_arabic(msg, data, target), unlock_group_membermod(msg, data, target), unlock_group_rtl(msg, data, target), unlock_group_tgservice(msg, data, target), unlock_group_sticker(msg, data, target), unlock_group_contacts(msg, data, target), unlock_group_english(msg, data, target), unlock_group_fwd(msg, data, target), unlock_group_reply(msg, data, target), unlock_group_join(msg, data, target), unlock_group_emoji(msg, data, target), unlock_group_username(msg, data, target), unlock_group_fosh(msg, data, target), unlock_group_media(msg, data, target), unlock_group_leave(msg, data, target), unlock_group_bots(msg, data, target), unlock_group_operator(msg, data, target), } return unlock_group_etehad(msg, data, target), detehad end if matches[2] == 'links' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked link posting") return unlock_group_links(msg, data, target) end if matches[2] == 'join' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked join") return unlock_group_join(msg, data, target) end if matches[2] == 'tag' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked tag") return unlock_group_tag(msg, data, target) end if matches[2] == 'spam' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked spam") return unlock_group_spam(msg, data, target) end if matches[2] == 'flood' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked flood") return unlock_group_flood(msg, data, target) end if matches[2] == 'arabic' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked Arabic") return unlock_group_arabic(msg, data, target) end if matches[2] == 'member' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked member ") return unlock_group_membermod(msg, data, target) end if matches[2]:lower() == 'rtl' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked RTL chars. in names") return unlock_group_rtl(msg, data, target) end if matches[2] == 'tgservice' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked tgservice actions") return unlock_group_tgservice(msg, data, target) end if matches[2] == 'sticker' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked sticker posting") return unlock_group_sticker(msg, data, target) end if matches[2] == 'contacts' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked contact posting") return unlock_group_contacts(msg, data, target) end if matches[2] == 'strict' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked disabled strict settings") return disable_strict_rules(msg, data, target) end if matches[2] == 'english' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked english") return unlock_group_english(msg, data, target) end if matches[2] == 'fwd' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked fwd") return unlock_group_fwd(msg, data, target) end if matches[2] == 'reply' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked reply") return unlock_group_reply(msg, data, target) end if matches[2] == 'emoji' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked disabled emoji") return unlock_group_emoji(msg, data, target) end if matches[2] == 'badword' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked fosh") return unlock_group_fosh(msg, data, target) end if matches[2] == 'media' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked media") return unlock_group_media(msg, data, target) end if matches[2] == 'username' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked disabled username") return unlock_group_username(msg, data, target) end if matches[2] == 'leave' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked leave") return unlock_group_leave(msg, data, target) end if matches[2] == 'bots' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked bots") return unlock_group_bots(msg, data, target) end if matches[2] == 'operator' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked operator") return unlock_group_operator(msg, data, target) end end if matches[1] == 'setflood' then if not is_momod(msg) then return end if tonumber(matches[2]) < 5 or tonumber(matches[2]) > 20 then return "Wrong number,range is [5-20]" end local flood_max = matches[2] data[tostring(msg.to.id)]['settings']['flood_msg_max'] = flood_max save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] set flood to ["..matches[2].."]") return 'Flood has been set to: '..matches[2] end if matches[1] == 'public' and is_momod(msg) then local target = msg.to.id if matches[2] == 'yes' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: public") return set_public_membermod(msg, data, target) end if matches[2] == 'no' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: not public") return unset_public_membermod(msg, data, target) end end if matches[1] == 'mute' and is_owner(msg) then local chat_id = msg.to.id if matches[2] == 'audio' then local msg_type = 'Audio' if not is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type) mute(chat_id, msg_type) return 'Audio has been muted ๐ŸŽต๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else return 'Audio is already muted ๐ŸŽต๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end if matches[2] == 'photo' then local msg_type = 'Photo' if not is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type) mute(chat_id, msg_type) return 'Photo has been muted ๐ŸŽก๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else return 'Photo is already muted ๐ŸŽก๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end if matches[2] == 'video' then local msg_type = 'Video' if not is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type) mute(chat_id, msg_type) return 'Video has been muted ๐ŸŽฅ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else return 'Video is already muted ๐ŸŽฅ๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end if matches[2] == 'gifs' then local msg_type = 'Gifs' if not is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type) mute(chat_id, msg_type) return 'Gifs has been muted ๐ŸŽ†๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else return 'Gifs is already muted ๐ŸŽ†๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end if matches[2] == 'doc' then local msg_type = 'Documents' if not is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type) mute(chat_id, msg_type) return 'documents has been muted ๐Ÿ“‚๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else return 'documents is already muted ๐Ÿ“‚๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end if matches[2] == 'text' then local msg_type = 'Text' if not is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type) mute(chat_id, msg_type) return 'Text has been muted ๐Ÿ“๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else return 'Text is already muted ๐Ÿ“๐Ÿ”\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end if matches[2] == 'all' then local msg_type = 'All' if not is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: mute "..msg_type) mute(chat_id, msg_type) return 'Mute all has been enabled ๐Ÿ”•\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else return 'Mute all is already enabled ๐Ÿ”•\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end end if matches[1] == 'unmute' and is_momod(msg) then local chat_id = msg.to.id if matches[2] == 'audio' then local msg_type = 'Audio' if is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute "..msg_type) unmute(chat_id, msg_type) return 'Audio has been unmuted ๐ŸŽต๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else return 'Audio is already unmuted ๐ŸŽต๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end if matches[2] == 'photo' then local msg_type = 'Photo' if is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute "..msg_type) unmute(chat_id, msg_type) return 'Photo has been unmuted ๐ŸŽก๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else return 'Photo is already unmuted ๐ŸŽก๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end if matches[2] == 'video' then local msg_type = 'Video' if is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute "..msg_type) unmute(chat_id, msg_type) return 'Video has been unmuted ๐ŸŽฅ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else return 'Video is already unmuted ๐ŸŽฅ๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end if matches[2] == 'gifs' then local msg_type = 'Gifs' if is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute "..msg_type) unmute(chat_id, msg_type) return 'Gifs has been unmuted ๐ŸŽ†๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else return 'Gifs is already unmuted ๐ŸŽ†๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end if matches[2] == 'doc' then local msg_type = 'Documents' if is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute "..msg_type) unmute(chat_id, msg_type) return 'documents has been unmuted ๐Ÿ“‚๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else return 'documents is already unmuted ๐Ÿ“‚๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end if matches[2] == 'text' then local msg_type = 'Text' if is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute message") unmute(chat_id, msg_type) return 'Text has been unmuted ๐Ÿ“๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else return 'Text is already unmuted ๐Ÿ“๐Ÿ”“\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end if matches[2] == 'all' then local msg_type = 'All' if is_muted(chat_id, msg_type..': yes') then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set SuperGroup to: unmute "..msg_type) unmute(chat_id, msg_type) return 'Mute all has been disabled ๐Ÿ””\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username else return 'Mute all is already disabled ๐Ÿ””\n๐Ÿ‘ฎ Order by :๏ธ @'..msg.from.username end end end if matches[1] == "silent" or matches[1] == "unsilent" and is_momod(msg) then local chat_id = msg.to.id local hash = "mute_user"..chat_id local user_id = "" if type(msg.reply_id) ~= "nil" then local receiver = get_receiver(msg) local get_cmd = "mute_user" muteuser = get_message(msg.reply_id, get_message_callback, {receiver = receiver, get_cmd = get_cmd, msg = msg}) elseif matches[1] == "silent" or matches[1] == "unsilent" and string.match(matches[2], '^%d+$') then local user_id = matches[2] if is_muted_user(chat_id, user_id) then unmute_user(chat_id, user_id) savelog(msg.to.id, name_log.." ["..msg.from.id.."] removed ["..user_id.."] from the muted users list") return "["..user_id.."] removed from the muted users list" elseif is_momod(msg) then mute_user(chat_id, user_id) savelog(msg.to.id, name_log.." ["..msg.from.id.."] added ["..user_id.."] to the muted users list") return "["..user_id.."] added to the muted user list" end elseif matches[1] == "silent" or matches[1] == "unsilent" and not string.match(matches[2], '^%d+$') then local receiver = get_receiver(msg) local get_cmd = "mute_user" local username = matches[2] local username = string.gsub(matches[2], '@', '') resolve_username(username, callbackres, {receiver = receiver, get_cmd = get_cmd, msg=msg}) end end if matches[1] == "muteslist" and is_momod(msg) then local chat_id = msg.to.id if not has_mutes(chat_id) then set_mutes(chat_id) return mutes_list(chat_id) end savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup muteslist") return mutes_list(chat_id) end if matches[1] == "silentlist" and is_momod(msg) then local chat_id = msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup mutelist") return muted_user_list(chat_id) end if matches[1] == 'settings' and is_momod(msg) then local target = msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested SuperGroup settings ") return show_supergroup_settingsmod(msg, target) end if matches[1] == 'rules' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group rules") return get_rules(msg, data) end if matches[1] == 'help' and not is_owner(msg) then text = "Only managers ๐Ÿ˜โ›”๏ธ" reply_msg(msg.id, text, ok_cb, false) elseif matches[1] == 'help' and is_owner(msg) then local name_log = user_print_name(msg.from) savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /superhelp") return super_help() end if matches[1] == 'peer_id' and is_admin1(msg)then text = msg.to.peer_id reply_msg(msg.id, text, ok_cb, false) post_large_msg(receiver, text) end if matches[1] == 'msg.to.id' and is_admin1(msg) then text = msg.to.id reply_msg(msg.id, text, ok_cb, false) post_large_msg(receiver, text) end --Admin Join Service Message if msg.service then local action = msg.action.type if action == 'chat_add_user_link' then if is_owner2(msg.from.id) then local receiver = get_receiver(msg) local user = "user#id"..msg.from.id savelog(msg.to.id, name_log.." Admin ["..msg.from.id.."] joined the SuperGroup via link") channel_set_admin(receiver, user, ok_cb, false) end if is_support(msg.from.id) and not is_owner2(msg.from.id) then local receiver = get_receiver(msg) local user = "user#id"..msg.from.id savelog(msg.to.id, name_log.." Support member ["..msg.from.id.."] joined the SuperGroup") channel_set_mod(receiver, user, ok_cb, false) end end if action == 'chat_add_user' then if is_owner2(msg.action.user.id) then local receiver = get_receiver(msg) local user = "user#id"..msg.action.user.id savelog(msg.to.id, name_log.." Admin ["..msg.action.user.id.."] added to the SuperGroup by [ "..msg.from.id.." ]") channel_set_admin(receiver, user, ok_cb, false) end if is_support(msg.action.user.id) and not is_owner2(msg.action.user.id) then local receiver = get_receiver(msg) local user = "user#id"..msg.action.user.id savelog(msg.to.id, name_log.." Support member ["..msg.action.user.id.."] added to the SuperGroup by [ "..msg.from.id.." ]") channel_set_mod(receiver, user, ok_cb, false) end end end if matches[1] == 'msg.to.peer_id' then post_large_msg(receiver, msg.to.peer_id) end end end local function pre_process(msg) if not msg.text and msg.media then msg.text = '['..msg.media.type..']' end return msg end return { patterns = { "^[#!/]([Aa]ddbot)$", "^[#!/]([Rr]embot)$", "^[#!/]([Mm]ove) (.*)$", "^[#!/]([Gg]pinfo)$", "^[#!/]([Aa]dmins)$", "^[#!/]([Oo]wner)$", "^[#!/]([Mm]odlist)$", "^[#!/]([Bb]ots)$", "^[#!/]([Ww]ho)$", "^[#!/]([Kk]icked)$", "^[#!/]([Bb]b) (.*)", "^[#!/]([Bb]b)", "^[#!/]([Kk]ick) (.*)", "^[#!/]([Kk]ick)", "^[#!/]([Tt]osuper)$", "^[#!/]([Ii][Dd])$", "^[#!/]([Ii][Dd]) (.*)$", "^[#!/]([Kk]ickme)$", "^[#!/]([Nn]ewlink)$", "^[#!/]([Ss]etlink)$", "^[#!/]([Ll]ink)$", "^[#!/]([Rr]es) (.*)$", "^[#!/]([Ss]etadmin) (.*)$", "^[#!/]([Ss]etadmin)", "^[#!/]([Dd]emoteadmin) (.*)$", "^[#!/]([Dd]emoteadmin)", "^[#!/]([Ss]etowner) (.*)$", "^[#!/]([Ss]etowner)$", "^[#!/]([Pp]romote) (.*)$", "^[#!/]([Pp]romote)", "^[#!/]([Dd]emote) (.*)$", "^[#!/]([Dd]emote)", "^[#!/]([Ss]etname) (.*)$", "^[#!/]([Ss]etabout) (.*)$", "^[#!/]([Ss]etrules) (.*)$", "^[#!/]([Ss]etphoto)$", "^[#!/]([Ss]etusername) (.*)$", "^[#!/]([Dd]el)$", "^[#!/]([Ll]ock) (.*)$", "^[#!/]([Uu]nlock) (.*)$", "^[#!/]([Mm]ute) ([^%s]+)$", "^[#!/]([Uu]nmute) ([^%s]+)$", "^[#!/]([Ss]ilent)$", "^[#!/]([Ss]ilent) (.*)$", "^[#!/]([Uu]nsilent)$", "^[#!/]([Uu]nsilent) (.*)$", "^[#!/]([Pp]ublic) (.*)$", "^[#!/]([Ss]ettings)$", "^[#!/]([Rr]ules)$", "^[#!/]([Ss]etflood) (%d+)$", "^[#!/]([Cc]lean) (.*)$", "^[#!/]([Hh]elp)$", "^[#!/]([Mm]uteslist)$", "^[#!/]([Ss]ilentlist)$", "[#!/](mp) (.*)", "[#!/](md) (.*)", "^(https://telegram.me/joinchat/%S+)$", "msg.to.peer_id", "%[(document)%]", "%[(photo)%]", "%[(video)%]", "%[(audio)%]", "%[(contact)%]", "^!!tgservice (.+)$", }, run = AHMED_ALOBIDE, pre_process = pre_process }
gpl-2.0
nesstea/darkstar
scripts/zones/Provenance/Zone.lua
30
1295
----------------------------------- -- -- Zone: Provenance (222) -- ----------------------------------- package.loaded["scripts/zones/Provenance/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Provenance/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn( player, prevZone) cs = -1; if ( player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then player:setPos(-640,-20,-519.999,192); 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
ruisebastiao/nodemcu-firmware
lua_examples/make_phone_call.lua
75
3145
--[[ 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. ]]-- -- Your access point's SSID and password local SSID = "xxxxxx" local SSID_PASSWORD = "xxxxxx" -- configure ESP as a station wifi.setmode(wifi.STATION) wifi.sta.config(SSID,SSID_PASSWORD) wifi.sta.autoconnect(1) local TWILIO_ACCOUNT_SID = "xxxxxx" local TWILIO_TOKEN = "xxxxxx" local HOST = "iot-https-relay.appspot.com" -- visit http://iot-https-relay.appspot.com/ to learn more about this service -- Please be sure to understand the security issues of using this relay app and use at your own risk. local URI = "/twilio/Calls.json" function build_post_request(host, uri, data_table) local data = "" for param,value in pairs(data_table) do data = data .. param.."="..value.."&" end request = "POST "..uri.." HTTP/1.1\r\n".. "Host: "..host.."\r\n".. "Connection: close\r\n".. "Content-Type: application/x-www-form-urlencoded\r\n".. "Content-Length: "..string.len(data).."\r\n".. "\r\n".. data print(request) return request end local function display(sck,response) print(response) end -- When using send_sms: the "from" number HAS to be your twilio number. -- If you have a free twilio account the "to" number HAS to be your twilio verified number. local function make_call(from,to,body) local data = { sid = TWILIO_ACCOUNT_SID, token = TWILIO_TOKEN, Body = string.gsub(body," ","+"), From = from, To = to } socket = net.createConnection(net.TCP,0) socket:on("receive",display) socket:connect(80,HOST) socket:on("connection",function(sck) local post_request = build_post_request(HOST,URI,data) sck:send(post_request) end) end function check_wifi() local ip = wifi.sta.getip() if(ip==nil) then print("Connecting...") else tmr.stop(0) print("Connected to AP!") print(ip) -- make a call with a voice message "your house is on fire" make_call("15558976687","1334856679","Your house is on fire!") end end tmr.alarm(0,2000,1,check_wifi)
mit
focusworld/aabb
plugins/exchange.lua
352
2076
local ltn12 = require "ltn12" local https = require "ssl.https" -- Edit data/mashape.lua with your Mashape API key -- http://docs.mashape.com/api-keys local function comma_value(n) -- credit http://richard.warburton.it local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$') return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right end local mashape = load_from_file('data/mashape.lua', { api_key = '' }) local function request(value, from, to) local api = "https://currency-exchange.p.mashape.com/exchange?" local par1 = "from="..from local par2 = "&q="..value local par3 = "&to="..to local url = api..par1..par2..par3 local api_key = mashape.api_key if api_key:isempty() then return 'Configure your Mashape API Key' end local headers = { ["X-Mashape-Key"] = api_key, ["Accept"] = "text/plain" } local respbody = {} local body, code = https.request{ url = url, method = "GET", headers = headers, sink = ltn12.sink.table(respbody), protocol = "tlsv1" } if code ~= 200 then return code end local body = table.concat(respbody) local curr = comma_value(value).." "..from.." = "..to.." "..comma_value(body) return curr end local function run(msg, matches) if tonumber(matches[1]) and not matches[2] then local from = "USD" local to = "IDR" local value = matches[1] return request(value, from, to) elseif matches[2] and matches[3] then local from = string.upper(matches[2]) or "USD" local to = string.upper(matches[3]) or "IDR" local value = matches[1] or "1" return request(value, from, to, value) end end return { description = "Currency Exchange", usage = { "!exchange [value] : Exchange value from USD to IDR (default).", "!exchange [value] [from] [to] : Get Currency Exchange by specifying the value of source (from) and destination (to).", }, patterns = { "^!exchange (%d+) (%a+) (%a+)$", "^!exchange (%d+)", }, run = run }
gpl-2.0
xinjiguaike/WebChimera
deps/playlist_youtube.lua
4
4674
--[[ Youtube playlist importer for VLC media player 1.1 and 2.0 Copyright 2012 Guillaume Le Maout Authors: Guillaume Le Maout Contact: http://addons.videolan.org/messages/?action=newmessage&username=exebetche 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. --]] --[[ MODified by Kai Gillmann, 19.01.2013, kaigillmann@googlemail.com: VLC HAS already a youtube importer, but not for playlists. IMO this mentioned one is better than this one, because it opens the video in the best possible video resolution. So i decided to remove all parts of the code which is not responsible for list handling. Now this lua script parses the list, as wanted, but for each video opened, the vlc default Youtube script is used, so the videos will be displayed properly. --]] -- Helper function to get a parameter's value in a URL function get_url_param( url, name ) local _, _, res = string.find( url, "[&?]"..name.."=([^&]*)" ) return res end -- Probe function. function probe() if vlc.access ~= "http" and vlc.access ~= "https" then return false end return string.match(vlc.path:match("([^/]+)"),"%w+.youtube.com") and (string.match(vlc.path, "list=")) end -- Parse function. function parse() if string.match( vlc.path, "list=" ) then local playlist_parsed, playlistData, line, s, item local p = {} local id_ref = {} local index = 1 local playlistID = get_url_param( vlc.path, "list" ) local videoID = get_url_param( vlc.path, "v" ) local playlistURL = "http://www.youtube.com/list_ajax?action_get_list=1&style=xml&list="..playlistID while true do playlistData = "" line = "" s = nil s = vlc.stream(playlistURL.."&index="..index) while line do playlistData = playlistData..line line = s:readline() end playlist_parsed = nil playlist_parsed = parse_xml(playlistData).root.video for i, video in ipairs(playlist_parsed) do vlc.msg.err(i.." "..video.encrypted_id.CDATA) if id_ref[video.encrypted_id.CDATA] and id_ref[video.encrypted_id.CDATA] == i then return p else id_ref[video.encrypted_id.CDATA] = i end item = nil item = {} item.path = "http://www.youtube.com/watch?v="..video.encrypted_id.CDATA item.title = video.title.CDATA item.artist = video.author.CDATA item.arturl = video.thumbnail.CDATA --~ item.description = video.description --~ item.rating = video.rating table.insert (p, item) end if #playlist_parsed == 100 then index = index +100 else return p end end end end function parse_xml(data) local tree = {} local stack = {} local tmp = {} local tmpTag = "" local level = 0 table.insert(stack, tree) for op, tag, attr, empty, val in string.gmatch( data, "<(%p?)([^%s>/]+)([^>]-)(%/?)>[%s\r\n\t]*([^<]*)[%s\r\n\t]*") do if op=="?" then --~ DOCTYPE elseif op=="/" then if level>0 then level = level - 1 table.remove(stack) end else level = level + 1 if op=="!" then stack[level]['CDATA'] = vlc.strings.resolve_xml_special_chars( string.gsub(tag..attr, "%[CDATA%[(.+)%]%]", "%1")) attr = "" level = level - 1 elseif type(stack[level][tag]) == "nil" then stack[level][tag] = {} table.insert(stack, stack[level][tag]) else if type(stack[level][tag][1]) == "nil" then tmp = nil tmp = stack[level][tag] stack[level][tag] = nil stack[level][tag] = {} table.insert(stack[level][tag], tmp) end tmp = nil tmp = {} table.insert(stack[level][tag], tmp) table.insert(stack, tmp) end if val~="" then stack[level][tag]['CDATA'] = {} stack[level][tag]['CDATA'] = vlc.strings.resolve_xml_special_chars(val) end if attr ~= "" then stack[level][tag]['ATTR'] = {} string.gsub(attr, "(%w+)=([\"'])(.-)%2", function (name, _, value) stack[level][tag]['ATTR'][name] = value end) end if empty ~= "" then level = level - 1 table.remove(stack) end end end return tree end
lgpl-2.1
UnfortunateFruit/darkstar
scripts/zones/Dynamis-Beaucedine/mobs/Adamantking_Effigy.lua
16
3421
----------------------------------- -- Area: Dynamis Beaucedine -- NPC: Adamantking Effigy -- 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/status"); 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) local X = mob:getXPos(); local Y = mob:getYPos(); local Z = mob:getZPos(); local spawnList = beaucedineQuadavList; if(mob:getStatPoppedMobs() == false) then mob:setStatPoppedMobs(true); for nb = 1, table.getn(spawnList), 2 do if(mob:getID() == spawnList[nb]) then for nbi = 1, table.getn(spawnList[nb + 1]), 1 do if((nbi % 2) == 0) then X=X+2; Z=Z+2; else X=X-2; Z=Z-2; end local mobNBR = spawnList[nb + 1][nbi]; if(mobNBR <= 20) then if(mobNBR == 0) then mobNBR = math.random(1,15); end -- Spawn random Vanguard (TEMPORARY) local DynaMob = getDynaMob(target,mobNBR,3); if(DynaMob ~= nil) then -- Spawn Mob SpawnMob(DynaMob):setMobMod(MOBMOD_SUPERLINK, mob:getShortID()); GetMobByID(DynaMob):setPos(X,Y,Z); GetMobByID(DynaMob):setSpawn(X,Y,Z); -- Spawn Pet for BST, DRG, and SMN if(mobNBR == 9 or mobNBR == 14 or mobNBR == 15) then SpawnMob(DynaMob + 1):setMobMod(MOBMOD_SUPERLINK, mob:getShortID()); GetMobByID(DynaMob + 1):setPos(X,Y,Z); GetMobByID(DynaMob + 1):setSpawn(X,Y,Z); end end elseif(mobNBR > 20) then SpawnMob(mobNBR):setMobMod(MOBMOD_SUPERLINK, mob:getShortID()); local MJob = GetMobByID(mobNBR):getMainJob(); if(MJob == 9 or MJob == 14 or MJob == 15) then -- Spawn Pet for BST, DRG, and SMN SpawnMob(mobNBR + 1):setMobMod(MOBMOD_SUPERLINK, mob:getShortID()); GetMobByID(mobNBR + 1):setPos(X,Y,Z); GetMobByID(mobNBR + 1):setSpawn(X,Y,Z); end end end end end end end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob,killer) local mobID = mob:getID(); -- Time Bonus: 063 066 if(mobID == 17326892 and mob:isInBattlefieldList() == false) then killer:addTimeToDynamis(15); mob:addInBattlefieldList(); elseif(mobID == 17326895 and mob:isInBattlefieldList() == false) then killer:addTimeToDynamis(15); mob:addInBattlefieldList(); -- HP Bonus: 056 059 065 070 074 103 elseif(mobID == 17326885 or mobID == 17326888 or mobID == 17326894 or mobID == 17326899 or mobID == 17326903 or mobID == 17326932) then killer:restoreHP(2000); killer:messageBasic(024,(killer:getMaxHP()-killer:getHP())); -- MP Bonus: 057 061 067 072 076 elseif(mobID == 17326886 or mobID == 17326890 or mobID == 17326896 or mobID == 17326901 or mobID == 17326905) then killer:restoreMP(2000); killer:messageBasic(025,(killer:getMaxMP()-killer:getMP())); end end;
gpl-3.0
UnfortunateFruit/darkstar
scripts/zones/Batallia_Downs/mobs/Weeping_Willow.lua
11
1354
----------------------------------- -- Area: Batallia Downs -- NPC: Weeping Willow ----------------------------------- require("scripts/globals/titles"); ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) end; ----------------------------------- -- onMobFight Action ----------------------------------- function onMobFight(mob,target) if(mob:getHP() <= mob:getMaxHP()/2 and GetServerVariable("NM-SpecialWeepWillowSapSpawn") < 1) then SpawnMob(17207303,600):updateEnmity(target); SpawnMob(17207304,600):updateEnmity(target); SpawnMob(17207305,600):updateEnmity(target); SpawnMob(17207306,600):updateEnmity(target); SpawnMob(17207307,600):updateEnmity(target); SetServerVariable("NM-SpecialWeepWillowSapSpawn",1); end end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob, killer) local JACK = 17207308; SpawnMob(JACK,600):updateEnmity(killer); GetMobByID(JACK):setPos( mob:getXPos(), mob:getYPos(), mob:getZPos(), 0); SetServerVariable("NM-SpecialWeepWillowSapSpawn",0); end; ----------------------------------- -- onMobDespawn ----------------------------------- function onMobDespawn(mob) SetServerVariable("[NM-Special]WeepWillowSapSpawn",0); end;
gpl-3.0
nesstea/darkstar
scripts/globals/abilities/curing_waltz_ii.lua
19
2262
----------------------------------- -- Ability: Curing Waltz II -- Heals HP to target player. -- Obtained: Dancer Level 30 -- TP Required: 35% -- Recast Time: 00:08 ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/status"); ----------------------------------- -- onAbilityCheck ----------------------------------- function onAbilityCheck(player,target,ability) if (target:getHP() == 0) then return MSGBASIC_CANNOT_ON_THAT_TARG,0; elseif (player:hasStatusEffect(EFFECT_SABER_DANCE)) then return MSGBASIC_UNABLE_TO_USE_JA2, 0; elseif (player:hasStatusEffect(EFFECT_TRANCE)) then return 0,0; elseif (player:getTP() < 350) then return MSGBASIC_NOT_ENOUGH_TP,0; else -- apply waltz recast modifiers if (player:getMod(MOD_WALTZ_RECAST)~=0) then local recastMod = -80 * (player:getMod(MOD_WALTZ_RECAST)); -- 400 ms per 5% (per merit) if (recastMod <0) then --TODO end end return 0,0; end end; ----------------------------------- -- onUseAbility ----------------------------------- function onUseAbility(player,target,ability) -- Only remove TP if the player doesn't have Trance. if not player:hasStatusEffect(EFFECT_TRANCE) then player:delTP(350); end; --Grabbing variables. local vit = target:getStat(MOD_VIT); local chr = player:getStat(MOD_CHR); local mjob = player:getMainJob(); --19 for DNC main. local sjob = player:getSubJob(); local cure = 0; --Performing sj mj check. if (mjob == 19) then cure = (vit+chr)*0.5+130; end if (sjob == 19) then cure = (vit+chr)*0.25+130; end -- apply waltz modifiers cure = math.floor(cure * (1.0 + (player:getMod(MOD_WALTZ_POTENTCY)/100))); --Reducing TP. --Applying server mods.... cure = cure * CURE_POWER; --Cap the final amount to max HP. if ((target:getMaxHP() - target:getHP()) < cure) then cure = (target:getMaxHP() - target:getHP()); end --Do it target:restoreHP(cure); target:wakeUp(); player:updateEnmityFromCure(target,cure); return cure; end;
gpl-3.0
letoram/prio
actions.lua
1
4244
local actions = {}; -- chain window local function wrun(fun) return function() if (priowin ~= nil) then fun(priowin); end end end -- use a rendertarget indirection for the screenshot to work around some driver -- bugs for the egl-dri/platform + mesa + ??? when trying to read the front buffer actions.save_screenshot = function() local cp = prio_clock_pulse; local ctr = 20; prio_clock_pulse = function(...) ctr = ctr - 1; if (ctr == 0) then zap_resource("prio_ss.png"); local dst = alloc_surface(VRESW, VRESH); local nsrf = null_surface(VRESW, VRESH); show_image(nsrf); image_sharestorage(WORLDID, nsrf); define_rendertarget(dst, {nsrf}, RENDERTARGET_DETACH, RENDERTARGET_NOSCALE, 0); rendertarget_forceupdate(dst); save_screenshot("prio_ss.png", FORMAT_PNG_FLIP, dst); delete_image(dst); prio_clock_pulse = cp; system_message("screenshot saved to prio_ss.png"); end cp(...); end end local active_rec; actions.record = function() if (valid_vid(active_rec)) then delete_image(active_rec); active_rec = nil; system_message("stopped recording"); else zap_resource("prio_rec.mkv"); active_rec = alloc_surface(1280, 720); if (valid_vid(active_rec)) then local tsrf = null_surface(1280, 720); show_image(tsrf); image_texfilter(tsrf, FILTER_BILINEAR); image_sharestorage(WORLDID, tsrf); image_set_txcos_default(tsrf, true); define_recordtarget(active_rec, "prio_rec.mkv", "vpreset=8:noaudio:fps=30", {tsrf}, {}, RENDERTARGET_DETACH, RENDERTARGET_NOSCALE, -1, function(src, status) if (status.kind == "terminated") then delete_image(src); active_rec = nil; end end); end end end actions.destroy_active_tab = wrun(function(wnd) wnd:lost(wnd.target); end); actions.destroy_active_window = wrun(function(wnd) wnd:destroy(); end); actions.select_tab_1 = wrun(function(wnd) wnd:set_tab(1); end); actions.select_tab_2 = wrun(function(wnd) wnd:set_tab(2); end); actions.select_tab_3 = wrun(function(wnd) wnd:set_tab(3); end); actions.select_tab_4 = wrun(function(wnd) wnd:set_tab(4); end); actions.select_tab_5 = wrun(function(wnd) wnd:set_tab(5); end); actions.select_tab_6 = wrun(function(wnd) wnd:set_tab(6); end); actions.select_tab_7 = wrun(function(wnd) wnd:set_tab(7); end); actions.select_tab_8 = wrun(function(wnd) wnd:set_tab(8); end); actions.select_tab_9 = wrun(function(wnd) wnd:set_tab(9); end); actions.select_tab_10= wrun(function(wnd) wnd:set_tab(10);end); actions.next_tab = wrun(function(wnd) wnd:set_tab(-2);end); actions.prev_tab = wrun(function(wnd) wnd:set_tab(-1);end); actions.paste = wrun(function(wnd) wnd:paste(CLIPBOARD_MESSAGE);end); actions.select_up = wrun(function(wnd) prio_sel_nearest(wnd, "t"); end); actions.select_down = wrun(function(wnd) prio_sel_nearest(wnd, "b"); end); actions.select_left = wrun(function(wnd) prio_sel_nearest(wnd, "l"); end); actions.select_right = wrun(function(wnd) prio_sel_nearest(wnd, "r"); end); actions.shrink_h = wrun(function(wnd) wnd:step_sz(1, 0,-1); end); actions.shrink_w = wrun(function(wnd) wnd:step_sz(1,-1, 0); end); actions.grow_h = wrun(function(wnd) wnd:step_sz(1, 0, 1); end); actions.grow_w = wrun(function(wnd) wnd:step_sz(1, 1, 0); end); actions.move_up = wrun(function(wnd) wnd:step_move(1, 0,-1); end); actions.move_down = wrun(function(wnd) wnd:step_move(1, 0, 1); end); actions.move_left = wrun(function(wnd) wnd:step_move(1,-1, 0); end); actions.move_right = wrun(function(wnd) wnd:step_move(1, 1, 0); end); actions.toggle_maximize = wrun(function(wnd) wnd:maximize("f"); end); actions.assign_top = wrun(function(wnd) wnd:maximize("t"); end); actions.assign_bottom = wrun(function(wnd) wnd:maximize("b"); end); actions.assign_left = wrun(function(wnd) wnd:maximize("l"); end); actions.assign_right = wrun(function(wnd) wnd:maximize("r"); end); actions.set_temp_prefix_1 = function() priosym.prefix = "t1_"; end actions.hide = wrun(function(wnd) wnd:hide(); end); actions.copy = wrun(function(wnd) if (wnd.clipboard_msg) then prioclip = wnd.clipboard_msg; end end); actions.paste = wrun(function(wnd) wnd:paste(CLIPBOARD_MESSAGE); end); -- -- others: hide all, copy, paste -- return actions;
bsd-3-clause
daedeloth/lsyncdln
examples/lpostcmd.lua
4
2618
----- -- User configuration file for lsyncd. -- This needs lsyncd >= 2.0.3 -- -- This configuration will execute a command on the remote host -- after every successfullycompleted rsync operation. -- for example to restart servlets on the target host or so. local rsyncpostcmd = { -- based on default rsync. default.rsync, -- for this config it is important to keep maxProcesses at 1, so -- the postcmds will only be spawned after the rsync completed maxProcesses = 1, -- called whenever something is to be done action = function(inlet) local event = inlet.getEvent() local config = inlet.getConfig() -- if the event is a blanket event and not the startup, -- its there to spawn the webservice restart at the target. if event.etype == "Blanket" then -- uses rawget to test if "isPostcmd" has been set without -- triggering an error if not. local isPostcmd = rawget(event, "isPostcmd") if event.isPostcmd then spawn(event, "/usr/bin/ssh", config.host, config.postcmd) return else -- this is the startup, forwards it to default routine. return default.rsync.action(inlet) end error("this should never be reached") end -- for any other event, a blanket event is created that -- will stack on the queue and do the postcmd when its finished local sync = inlet.createBlanketEvent() sync.isPostcmd = true -- the original event is simply forwarded to the normal action handler return default.rsync.action(inlet) end, -- called when a process exited. -- this can be a rsync command, the startup rsync or the postcmd collect = function(agent, exitcode) -- for the ssh commands 255 is network error -> try again local isPostcmd = rawget(agent, "isPostcmd") if not agent.isList and agent.etype == "Blanket" and isPostcmd then if exitcode == 255 then return "again" end return else --- everything else, forward to default collection handler return default.collect(agent,exitcode) end error("this should never be reached") end -- called before anything else -- builds the target from host and targetdir prepare = function(config) if not config.host then error("rsyncpostcmd neets 'host' configured", 4) end if not config.targetdir then error("rsyncpostcmd needs 'targetdir' configured", 4) end if not config.target then config.target = config.host .. ":" .. config.targetdir end return default.rsync.prepare(config) end } sync { rsyncpostcmd, source = "src", host = "beetle", targetdir = "/path/to/trg", postcmd = "/usr/local/bin/restart-servelt.sh", }
gpl-2.0