repo_name
stringlengths
6
78
path
stringlengths
4
206
copies
stringclasses
281 values
size
stringlengths
4
7
content
stringlengths
625
1.05M
license
stringclasses
15 values
aminkinghakerlifee/wolf-team
plugins/translate.lua
6
1615
--[[ -- Translate text using Google Translate. -- http://translate.google.com/translate_a/single?client=t&ie=UTF-8&oe=UTF-8&hl=en&dt=t&tl=en&sl=auto&text=hello --]] do function translate(source_lang, target_lang, text) local path = "http://translate.google.com/translate_a/single" -- URL query parameters local params = { client = "t", ie = "UTF-8", oe = "UTF-8", hl = "en", dt = "t", tl = target_lang or "en", sl = source_lang or "auto", text = URL.escape(text) } local query = format_http_params(params, true) local url = path..query local res, code = https.request(url) -- Return nil if error if code > 200 then return nil end local trans = res:gmatch("%[%[%[\"(.*)\"")():gsub("\"(.*)", "") return trans end function run(msg, matches) -- Third pattern if #matches == 1 then print("First") local text = matches[1] return translate(nil, nil, text) end -- Second pattern if #matches == 2 then print("Second") local target = matches[1] local text = matches[2] return translate(nil, target, text) end -- First pattern if #matches == 3 then print("Third") local source = matches[1] local target = matches[2] local text = matches[3] return translate(source, target, text) end end return { description = "Translate some text", usage = { "!translate text. Translate the text to English.", "!translate target_lang text.", "!translate source,target text", }, patterns = { "^!tr ([%w]+),([%a]+) (.+)", "^!tr ([%w]+) (.+)", "^!tr (.+)", }, run = run } end
gpl-3.0
aminkinghakerlifee/wolf-team
plugins/tr.lua
6
1615
--[[ -- Translate text using Google Translate. -- http://translate.google.com/translate_a/single?client=t&ie=UTF-8&oe=UTF-8&hl=en&dt=t&tl=en&sl=auto&text=hello --]] do function translate(source_lang, target_lang, text) local path = "http://translate.google.com/translate_a/single" -- URL query parameters local params = { client = "t", ie = "UTF-8", oe = "UTF-8", hl = "en", dt = "t", tl = target_lang or "en", sl = source_lang or "auto", text = URL.escape(text) } local query = format_http_params(params, true) local url = path..query local res, code = https.request(url) -- Return nil if error if code > 200 then return nil end local trans = res:gmatch("%[%[%[\"(.*)\"")():gsub("\"(.*)", "") return trans end function run(msg, matches) -- Third pattern if #matches == 1 then print("First") local text = matches[1] return translate(nil, nil, text) end -- Second pattern if #matches == 2 then print("Second") local target = matches[1] local text = matches[2] return translate(nil, target, text) end -- First pattern if #matches == 3 then print("Third") local source = matches[1] local target = matches[2] local text = matches[3] return translate(source, target, text) end end return { description = "Translate some text", usage = { "!translate text. Translate the text to English.", "!translate target_lang text.", "!translate source,target text", }, patterns = { "^!tr ([%w]+),([%a]+) (.+)", "^!tr ([%w]+) (.+)", "^!tr (.+)", }, run = run } end
gpl-3.0
kitala1/darkstar
scripts/globals/items/slice_of_lynx_meat.lua
18
1292
----------------------------------------- -- ID: 5667 -- Item: Slice of Lynx Meat -- Food Effect: 5 Min, Galka only ----------------------------------------- -- Strength 5 -- Intelligence -7 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:getRace() ~= 8) then result = 247; end if(target:getMod(MOD_EAT_RAW_MEAT) == 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,5667); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_STR, 5); target:addMod(MOD_INT, -7); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_STR, 5); target:delMod(MOD_INT, -7); end;
gpl-3.0
kitala1/darkstar
scripts/globals/items/elshimo_frog.lua
17
1477
----------------------------------------- -- ID: 4290 -- Item: elshimo_frog -- Food Effect: 5Min, Mithra only ----------------------------------------- -- Dexterity 2 -- Agility 2 -- Mind -4 -- Evasion 5 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local 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,4290); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_DEX, 2); target:addMod(MOD_AGI, 2); target:addMod(MOD_MND, -4); target:addMod(MOD_EVA, 5); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_DEX, 2); target:delMod(MOD_AGI, 2); target:delMod(MOD_MND, -4); target:delMod(MOD_EVA, 5); end;
gpl-3.0
kitala1/darkstar
scripts/zones/Port_San_dOria/npcs/Bonarpant.lua
36
1375
----------------------------------- -- Area: Port San d'Oria -- NPC: Bonarpant -- Standard Info NPC ----------------------------------- package.loaded["scripts/zones/Port_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/quests"); require("scripts/zones/Port_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- "Flyers for Regine" conditional script FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE); if (FlyerForRegine == 1) then count = trade:getItemCount(); MagicFlyer = trade:hasItemQty(532,1); if (MagicFlyer == true and count == 1) then player:messageSpecial(FLYER_REFUSED); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x253); 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
kitala1/darkstar
scripts/globals/items/cup_of_date_tea.lua
36
1352
----------------------------------------- -- ID: 5926 -- Item: Cup of Date Tea -- Food Effect: 3 Hrs, All Races ----------------------------------------- -- HP 20 -- MP 30 -- Vitality -1 -- Charisma 5 -- Intelligence 3 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,10800,5926); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_HP, 20); target:addMod(MOD_MP, 30); target:addMod(MOD_VIT, -1); target:addMod(MOD_CHR, 5); target:addMod(MOD_INT, 3); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_HP, 20); target:delMod(MOD_MP, 30); target:delMod(MOD_VIT, -1); target:delMod(MOD_CHR, 5); target:delMod(MOD_INT, 3); end;
gpl-3.0
kitala1/darkstar
scripts/zones/The_Shrouded_Maw/npcs/MementoCircle.lua
12
1419
----------------------------------- -- Area: The_Shrouded_Maw -- NPC: MementoCircle ----------------------------------- package.loaded["scripts/zones/The_Shrouded_Maw/TextIDs"] = nil; ----------------------------------- require("scripts/globals/bcnm"); require("scripts/globals/quests"); require("scripts/globals/missions"); require("scripts/zones/The_Shrouded_Maw/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if(TradeBCNM(player,player:getZoneID(),trade,npc))then return; end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if(EventTriggerBCNM(player,npc))then return 1; else return 1; end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("onUpdate CSID: %u",csid); --printf("onUpdate RESULT: %u",option); if(EventUpdateBCNM(player,csid,option))then return; end end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) --printf("onFinish CSID: %u",csid); --printf("onFinish RESULT: %u",option); if(EventFinishBCNM(player,csid,option))then return; end end;
gpl-3.0
Taracque/epgp
LibGearPoints-1.2.lua
1
24603
-- A library to compute Gear Points for items as described in -- http://code.google.com/p/epgp/wiki/GearPoints local MAJOR_VERSION = "LibGearPoints-1.2" local MINOR_VERSION = 10200 local lib, oldMinor = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION) if not lib then return end local Debug = LibStub("LibDebug-1.0") local ItemUtils = LibStub("LibItemUtils-1.0") -- This is the high price equipslot multiplier. local EQUIPSLOT_MULTIPLIER_1 = { INVTYPE_HEAD = 1, INVTYPE_NECK = 0.5, INVTYPE_SHOULDER = 0.75, INVTYPE_CHEST = 1, INVTYPE_ROBE = 1, INVTYPE_WAIST = 0.75, INVTYPE_LEGS = 1, INVTYPE_FEET = 0.75, INVTYPE_WRIST = 0.5, INVTYPE_HAND = 0.75, INVTYPE_FINGER = 0.5, INVTYPE_TRINKET = 1.25, INVTYPE_CLOAK = 0.5, INVTYPE_WEAPON = 1, INVTYPE_SHIELD = 1, INVTYPE_2HWEAPON = 2, INVTYPE_WEAPONMAINHAND = 1, INVTYPE_WEAPONOFFHAND = 1, INVTYPE_HOLDABLE = 1, INVTYPE_RANGED = 2.0, INVTYPE_RANGEDRIGHT = 2.0, INVTYPE_THROWN = 0.5, INVTYPE_RELIC = 0.5, -- Hack for Tier 9 25M heroic tokens. INVTYPE_CUSTOM_MULTISLOT_TIER = 0.9, } -- This is the low price equipslot multiplier (off hand weapons, non -- tanking shields). local EQUIPSLOT_MULTIPLIER_2 = { INVTYPE_WEAPON = 1, INVTYPE_2HWEAPON = 2, INVTYPE_SHIELD = 1, INVTYPE_RANGEDRIGHT = 2 } --Used to display GP values directly on tier tokens; keys are itemIDs, --values are rarity, ilvl, inventory slot, and an optional boolean --value indicating heroic/mythic ilvl should be derived from the bonus --list rather than the raw ilvl (mainly for T17+ tier gear) local CUSTOM_ITEM_DATA = { -- Tier 4 [29753] = { 4, 120, "INVTYPE_CHEST" }, [29754] = { 4, 120, "INVTYPE_CHEST" }, [29755] = { 4, 120, "INVTYPE_CHEST" }, [29756] = { 4, 120, "INVTYPE_HAND" }, [29757] = { 4, 120, "INVTYPE_HAND" }, [29758] = { 4, 120, "INVTYPE_HAND" }, [29759] = { 4, 120, "INVTYPE_HEAD" }, [29760] = { 4, 120, "INVTYPE_HEAD" }, [29761] = { 4, 120, "INVTYPE_HEAD" }, [29762] = { 4, 120, "INVTYPE_SHOULDER" }, [29763] = { 4, 120, "INVTYPE_SHOULDER" }, [29764] = { 4, 120, "INVTYPE_SHOULDER" }, [29765] = { 4, 120, "INVTYPE_LEGS" }, [29766] = { 4, 120, "INVTYPE_LEGS" }, [29767] = { 4, 120, "INVTYPE_LEGS" }, -- Tier 5 [30236] = { 4, 133, "INVTYPE_CHEST" }, [30237] = { 4, 133, "INVTYPE_CHEST" }, [30238] = { 4, 133, "INVTYPE_CHEST" }, [30239] = { 4, 133, "INVTYPE_HAND" }, [30240] = { 4, 133, "INVTYPE_HAND" }, [30241] = { 4, 133, "INVTYPE_HAND" }, [30242] = { 4, 133, "INVTYPE_HEAD" }, [30243] = { 4, 133, "INVTYPE_HEAD" }, [30244] = { 4, 133, "INVTYPE_HEAD" }, [30245] = { 4, 133, "INVTYPE_LEGS" }, [30246] = { 4, 133, "INVTYPE_LEGS" }, [30247] = { 4, 133, "INVTYPE_LEGS" }, [30248] = { 4, 133, "INVTYPE_SHOULDER" }, [30249] = { 4, 133, "INVTYPE_SHOULDER" }, [30250] = { 4, 133, "INVTYPE_SHOULDER" }, -- Tier 5 - BoE recipes - BoP crafts [30282] = { 4, 128, "INVTYPE_BOOTS" }, [30283] = { 4, 128, "INVTYPE_BOOTS" }, [30305] = { 4, 128, "INVTYPE_BOOTS" }, [30306] = { 4, 128, "INVTYPE_BOOTS" }, [30307] = { 4, 128, "INVTYPE_BOOTS" }, [30308] = { 4, 128, "INVTYPE_BOOTS" }, [30323] = { 4, 128, "INVTYPE_BOOTS" }, [30324] = { 4, 128, "INVTYPE_BOOTS" }, -- Tier 6 [31089] = { 4, 146, "INVTYPE_CHEST" }, [31090] = { 4, 146, "INVTYPE_CHEST" }, [31091] = { 4, 146, "INVTYPE_CHEST" }, [31092] = { 4, 146, "INVTYPE_HAND" }, [31093] = { 4, 146, "INVTYPE_HAND" }, [31094] = { 4, 146, "INVTYPE_HAND" }, [31095] = { 4, 146, "INVTYPE_HEAD" }, [31096] = { 4, 146, "INVTYPE_HEAD" }, [31097] = { 4, 146, "INVTYPE_HEAD" }, [31098] = { 4, 146, "INVTYPE_LEGS" }, [31099] = { 4, 146, "INVTYPE_LEGS" }, [31100] = { 4, 146, "INVTYPE_LEGS" }, [31101] = { 4, 146, "INVTYPE_SHOULDER" }, [31102] = { 4, 146, "INVTYPE_SHOULDER" }, [31103] = { 4, 146, "INVTYPE_SHOULDER" }, [34848] = { 4, 154, "INVTYPE_WRIST" }, [34851] = { 4, 154, "INVTYPE_WRIST" }, [34852] = { 4, 154, "INVTYPE_WRIST" }, [34853] = { 4, 154, "INVTYPE_WAIST" }, [34854] = { 4, 154, "INVTYPE_WAIST" }, [34855] = { 4, 154, "INVTYPE_WAIST" }, [34856] = { 4, 154, "INVTYPE_FEET" }, [34857] = { 4, 154, "INVTYPE_FEET" }, [34858] = { 4, 154, "INVTYPE_FEET" }, -- Tier 6 - BoE recipes - BoP crafts [32737] = { 4, 141, "INVTYPE_SHOULDER" }, [32739] = { 4, 141, "INVTYPE_SHOULDER" }, [32745] = { 4, 141, "INVTYPE_SHOULDER" }, [32747] = { 4, 141, "INVTYPE_SHOULDER" }, [32749] = { 4, 141, "INVTYPE_SHOULDER" }, [32751] = { 4, 141, "INVTYPE_SHOULDER" }, [32753] = { 4, 141, "INVTYPE_SHOULDER" }, [32755] = { 4, 141, "INVTYPE_SHOULDER" }, -- Magtheridon's Head [32385] = { 4, 125, "INVTYPE_FINGER" }, [32386] = { 4, 125, "INVTYPE_FINGER" }, -- Kael'thas' Sphere [32405] = { 4, 138, "INVTYPE_NECK" }, -- T7 [40610] = { 4, 200, "INVTYPE_CHEST" }, [40611] = { 4, 200, "INVTYPE_CHEST" }, [40612] = { 4, 200, "INVTYPE_CHEST" }, [40613] = { 4, 200, "INVTYPE_HAND" }, [40614] = { 4, 200, "INVTYPE_HAND" }, [40615] = { 4, 200, "INVTYPE_HAND" }, [40616] = { 4, 200, "INVTYPE_HEAD" }, [40617] = { 4, 200, "INVTYPE_HEAD" }, [40618] = { 4, 200, "INVTYPE_HEAD" }, [40619] = { 4, 200, "INVTYPE_LEGS" }, [40620] = { 4, 200, "INVTYPE_LEGS" }, [40621] = { 4, 200, "INVTYPE_LEGS" }, [40622] = { 4, 200, "INVTYPE_SHOULDER" }, [40623] = { 4, 200, "INVTYPE_SHOULDER" }, [40624] = { 4, 200, "INVTYPE_SHOULDER" }, -- T7 (heroic) [40625] = { 4, 213, "INVTYPE_CHEST" }, [40626] = { 4, 213, "INVTYPE_CHEST" }, [40627] = { 4, 213, "INVTYPE_CHEST" }, [40628] = { 4, 213, "INVTYPE_HAND" }, [40629] = { 4, 213, "INVTYPE_HAND" }, [40630] = { 4, 213, "INVTYPE_HAND" }, [40631] = { 4, 213, "INVTYPE_HEAD" }, [40632] = { 4, 213, "INVTYPE_HEAD" }, [40633] = { 4, 213, "INVTYPE_HEAD" }, [40634] = { 4, 213, "INVTYPE_LEGS" }, [40635] = { 4, 213, "INVTYPE_LEGS" }, [40636] = { 4, 213, "INVTYPE_LEGS" }, [40637] = { 4, 213, "INVTYPE_SHOULDER" }, [40638] = { 4, 213, "INVTYPE_SHOULDER" }, [40639] = { 4, 213, "INVTYPE_SHOULDER" }, -- Key to the Focusing Iris [44569] = { 4, 213, "INVTYPE_NECK" }, [44577] = { 4, 226, "INVTYPE_NECK" }, -- T8 [45635] = { 4, 219, "INVTYPE_CHEST" }, [45636] = { 4, 219, "INVTYPE_CHEST" }, [45637] = { 4, 219, "INVTYPE_CHEST" }, [45647] = { 4, 219, "INVTYPE_HEAD" }, [45648] = { 4, 219, "INVTYPE_HEAD" }, [45649] = { 4, 219, "INVTYPE_HEAD" }, [45644] = { 4, 219, "INVTYPE_HAND" }, [45645] = { 4, 219, "INVTYPE_HAND" }, [45646] = { 4, 219, "INVTYPE_HAND" }, [45650] = { 4, 219, "INVTYPE_LEGS" }, [45651] = { 4, 219, "INVTYPE_LEGS" }, [45652] = { 4, 219, "INVTYPE_LEGS" }, [45659] = { 4, 219, "INVTYPE_SHOULDER" }, [45660] = { 4, 219, "INVTYPE_SHOULDER" }, [45661] = { 4, 219, "INVTYPE_SHOULDER" }, -- T8 (heroic) [45632] = { 4, 226, "INVTYPE_CHEST" }, [45633] = { 4, 226, "INVTYPE_CHEST" }, [45634] = { 4, 226, "INVTYPE_CHEST" }, [45638] = { 4, 226, "INVTYPE_HEAD" }, [45639] = { 4, 226, "INVTYPE_HEAD" }, [45640] = { 4, 226, "INVTYPE_HEAD" }, [45641] = { 4, 226, "INVTYPE_HAND" }, [45642] = { 4, 226, "INVTYPE_HAND" }, [45643] = { 4, 226, "INVTYPE_HAND" }, [45653] = { 4, 226, "INVTYPE_LEGS" }, [45654] = { 4, 226, "INVTYPE_LEGS" }, [45655] = { 4, 226, "INVTYPE_LEGS" }, [45656] = { 4, 226, "INVTYPE_SHOULDER" }, [45657] = { 4, 226, "INVTYPE_SHOULDER" }, [45658] = { 4, 226, "INVTYPE_SHOULDER" }, -- Reply Code Alpha [46052] = { 4, 226, "INVTYPE_RING" }, [46053] = { 4, 239, "INVTYPE_RING" }, -- T9.245 (10M heroic/25M) [47242] = { 4, 245, "INVTYPE_CUSTOM_MULTISLOT_TIER" }, -- T9.258 (25M heroic) [47557] = { 4, 258, "INVTYPE_CUSTOM_MULTISLOT_TIER" }, [47558] = { 4, 258, "INVTYPE_CUSTOM_MULTISLOT_TIER" }, [47559] = { 4, 258, "INVTYPE_CUSTOM_MULTISLOT_TIER" }, -- T10.264 (10M heroic/25M) [52025] = { 4, 264, "INVTYPE_CUSTOM_MULTISLOT_TIER" }, [52026] = { 4, 264, "INVTYPE_CUSTOM_MULTISLOT_TIER" }, [52027] = { 4, 264, "INVTYPE_CUSTOM_MULTISLOT_TIER" }, -- T10.279 (25M heroic) [52028] = { 4, 279, "INVTYPE_CUSTOM_MULTISLOT_TIER" }, [52029] = { 4, 279, "INVTYPE_CUSTOM_MULTISLOT_TIER" }, [52030] = { 4, 279, "INVTYPE_CUSTOM_MULTISLOT_TIER" }, -- T11 [63683] = { 4, 359, "INVTYPE_HEAD" }, [63684] = { 4, 359, "INVTYPE_HEAD" }, [63682] = { 4, 359, "INVTYPE_HEAD" }, [64315] = { 4, 359, "INVTYPE_SHOULDER" }, [64316] = { 4, 359, "INVTYPE_SHOULDER" }, [64314] = { 4, 359, "INVTYPE_SHOULDER" }, -- T11 Heroic [65001] = { 4, 372, "INVTYPE_HEAD" }, [65000] = { 4, 372, "INVTYPE_HEAD" }, [65002] = { 4, 372, "INVTYPE_HEAD" }, [65088] = { 4, 372, "INVTYPE_SHOULDER" }, [65087] = { 4, 372, "INVTYPE_SHOULDER" }, [65089] = { 4, 372, "INVTYPE_SHOULDER" }, [67424] = { 4, 372, "INVTYPE_CHEST" }, [67425] = { 4, 372, "INVTYPE_CHEST" }, [67423] = { 4, 372, "INVTYPE_CHEST" }, [67426] = { 4, 372, "INVTYPE_LEGS" }, [67427] = { 4, 372, "INVTYPE_LEGS" }, [67428] = { 4, 372, "INVTYPE_LEGS" }, [67431] = { 4, 372, "INVTYPE_HAND" }, [67430] = { 4, 372, "INVTYPE_HAND" }, [67429] = { 4, 372, "INVTYPE_HAND" }, -- T12 [71674] = { 4, 378, "INVTYPE_SHOULDER" }, [71688] = { 4, 378, "INVTYPE_SHOULDER" }, [71681] = { 4, 378, "INVTYPE_SHOULDER" }, [71668] = { 4, 378, "INVTYPE_HEAD" }, [71682] = { 4, 378, "INVTYPE_HEAD" }, [71675] = { 4, 378, "INVTYPE_HEAD" }, -- T12 Heroic [71679] = { 4, 391, "INVTYPE_CHEST" }, [71686] = { 4, 391, "INVTYPE_CHEST" }, [71672] = { 4, 391, "INVTYPE_CHEST" }, [71677] = { 4, 391, "INVTYPE_HEAD" }, [71684] = { 4, 391, "INVTYPE_HEAD" }, [71670] = { 4, 391, "INVTYPE_HEAD" }, [71676] = { 4, 391, "INVTYPE_HAND" }, [71683] = { 4, 391, "INVTYPE_HAND" }, [71669] = { 4, 391, "INVTYPE_HAND" }, [71678] = { 4, 391, "INVTYPE_LEGS" }, [71685] = { 4, 391, "INVTYPE_LEGS" }, [71671] = { 4, 391, "INVTYPE_LEGS" }, [71680] = { 4, 391, "INVTYPE_SHOULDER" }, [71687] = { 4, 391, "INVTYPE_SHOULDER" }, [71673] = { 4, 391, "INVTYPE_SHOULDER" }, -- T12 misc [71617] = { 4, 391, "INVTYPE_TRINKET" }, -- crystallized firestone -- Other junk that drops; hard to really set a price for, so guilds -- will just have to decide on their own. -- 69815 -- seething cinder -- 71141 -- eternal ember -- 69237 -- living ember -- 71998 -- essence of destruction -- T13 normal [78184] = { 4, 397, "INVTYPE_CHEST" }, [78179] = { 4, 397, "INVTYPE_CHEST" }, [78174] = { 4, 397, "INVTYPE_CHEST" }, [78182] = { 4, 397, "INVTYPE_HEAD" }, [78177] = { 4, 397, "INVTYPE_HEAD" }, [78172] = { 4, 397, "INVTYPE_HEAD" }, [78183] = { 4, 397, "INVTYPE_HAND" }, [78178] = { 4, 397, "INVTYPE_HAND" }, [78173] = { 4, 397, "INVTYPE_HAND" }, [78181] = { 4, 397, "INVTYPE_LEGS" }, [78176] = { 4, 397, "INVTYPE_LEGS" }, [78171] = { 4, 397, "INVTYPE_LEGS" }, [78180] = { 4, 397, "INVTYPE_SHOULDER" }, [78175] = { 4, 397, "INVTYPE_SHOULDER" }, [78170] = { 4, 397, "INVTYPE_SHOULDER" }, -- T13 heroic [78847] = { 4, 410, "INVTYPE_CHEST" }, [78848] = { 4, 410, "INVTYPE_CHEST" }, [78849] = { 4, 410, "INVTYPE_CHEST" }, [78850] = { 4, 410, "INVTYPE_HEAD" }, [78851] = { 4, 410, "INVTYPE_HEAD" }, [78852] = { 4, 410, "INVTYPE_HEAD" }, [78853] = { 4, 410, "INVTYPE_HAND" }, [78854] = { 4, 410, "INVTYPE_HAND" }, [78855] = { 4, 410, "INVTYPE_HAND" }, [78856] = { 4, 410, "INVTYPE_LEGS" }, [78857] = { 4, 410, "INVTYPE_LEGS" }, [78858] = { 4, 410, "INVTYPE_LEGS" }, [78859] = { 4, 410, "INVTYPE_SHOULDER" }, [78860] = { 4, 410, "INVTYPE_SHOULDER" }, [78861] = { 4, 410, "INVTYPE_SHOULDER" }, -- T14 normal [89248] = { 4, 496, "INVTYPE_SHOULDER" }, [89247] = { 4, 496, "INVTYPE_SHOULDER" }, [89246] = { 4, 496, "INVTYPE_SHOULDER" }, [89245] = { 4, 496, "INVTYPE_LEGS" }, [89244] = { 4, 496, "INVTYPE_LEGS" }, [89243] = { 4, 496, "INVTYPE_LEGS" }, [89234] = { 4, 496, "INVTYPE_HEAD" }, [89236] = { 4, 496, "INVTYPE_HEAD" }, [89235] = { 4, 496, "INVTYPE_HEAD" }, [89242] = { 4, 496, "INVTYPE_HAND" }, [89241] = { 4, 496, "INVTYPE_HAND" }, [89240] = { 4, 496, "INVTYPE_HAND" }, [89239] = { 4, 496, "INVTYPE_CHEST" }, [89238] = { 4, 496, "INVTYPE_CHEST" }, [89237] = { 4, 496, "INVTYPE_CHEST" }, -- T14 heroic [89261] = { 4, 509, "INVTYPE_SHOULDER" }, [89263] = { 4, 509, "INVTYPE_SHOULDER" }, [89262] = { 4, 509, "INVTYPE_SHOULDER" }, [89252] = { 4, 509, "INVTYPE_LEGS" }, [89254] = { 4, 509, "INVTYPE_LEGS" }, [89253] = { 4, 509, "INVTYPE_LEGS" }, [89258] = { 4, 509, "INVTYPE_HEAD" }, [89260] = { 4, 509, "INVTYPE_HEAD" }, [89259] = { 4, 509, "INVTYPE_HEAD" }, [89255] = { 4, 509, "INVTYPE_HAND" }, [89257] = { 4, 509, "INVTYPE_HAND" }, [89256] = { 4, 509, "INVTYPE_HAND" }, [89249] = { 4, 509, "INVTYPE_CHEST" }, [89251] = { 4, 509, "INVTYPE_CHEST" }, [89250] = { 4, 509, "INVTYPE_CHEST" }, -- T15 normal [95573] = { 4, 522, "INVTYPE_SHOULDER" }, [95583] = { 4, 522, "INVTYPE_SHOULDER" }, [95578] = { 4, 522, "INVTYPE_SHOULDER" }, [95572] = { 4, 522, "INVTYPE_LEGS" }, [95581] = { 4, 522, "INVTYPE_LEGS" }, [95576] = { 4, 522, "INVTYPE_LEGS" }, [95571] = { 4, 522, "INVTYPE_HEAD" }, [95582] = { 4, 522, "INVTYPE_HEAD" }, [95577] = { 4, 522, "INVTYPE_HEAD" }, [95570] = { 4, 522, "INVTYPE_HAND" }, [95580] = { 4, 522, "INVTYPE_HAND" }, [95575] = { 4, 522, "INVTYPE_HAND" }, [95569] = { 4, 522, "INVTYPE_CHEST" }, [95579] = { 4, 522, "INVTYPE_CHEST" }, [95574] = { 4, 522, "INVTYPE_CHEST" }, -- T15 heroic [96699] = { 4, 535, "INVTYPE_SHOULDER" }, [96700] = { 4, 535, "INVTYPE_SHOULDER" }, [96701] = { 4, 535, "INVTYPE_SHOULDER" }, [96631] = { 4, 535, "INVTYPE_LEGS" }, [96632] = { 4, 535, "INVTYPE_LEGS" }, [96633] = { 4, 535, "INVTYPE_LEGS" }, [96625] = { 4, 535, "INVTYPE_HEAD" }, [96623] = { 4, 535, "INVTYPE_HEAD" }, [96624] = { 4, 535, "INVTYPE_HEAD" }, [96599] = { 4, 535, "INVTYPE_HAND" }, [96600] = { 4, 535, "INVTYPE_HAND" }, [96601] = { 4, 535, "INVTYPE_HAND" }, [96567] = { 4, 535, "INVTYPE_CHEST" }, [96568] = { 4, 535, "INVTYPE_CHEST" }, [96566] = { 4, 535, "INVTYPE_CHEST" }, -- T16 Normal (post-6.0) [99754] = { 4, 540, "INVTYPE_SHOULDER" }, [99755] = { 4, 540, "INVTYPE_SHOULDER" }, [99756] = { 4, 540, "INVTYPE_SHOULDER" }, [99751] = { 4, 540, "INVTYPE_LEGS" }, [99752] = { 4, 540, "INVTYPE_LEGS" }, [99753] = { 4, 540, "INVTYPE_LEGS" }, [99748] = { 4, 540, "INVTYPE_HEAD" }, [99749] = { 4, 540, "INVTYPE_HEAD" }, [99750] = { 4, 540, "INVTYPE_HEAD" }, [99745] = { 4, 540, "INVTYPE_HAND" }, [99746] = { 4, 540, "INVTYPE_HAND" }, [99747] = { 4, 540, "INVTYPE_HAND" }, [99742] = { 4, 540, "INVTYPE_CHEST" }, [99743] = { 4, 540, "INVTYPE_CHEST" }, [99744] = { 4, 540, "INVTYPE_CHEST" }, -- T16 Normal Essences (post-6.0) [105863] = { 4, 540, "INVTYPE_HEAD" }, [105865] = { 4, 540, "INVTYPE_HEAD" }, [105864] = { 4, 540, "INVTYPE_HEAD" }, -- T16 Heroic (Normal pre-6.0) [99685] = { 4, 553, "INVTYPE_SHOULDER" }, [99695] = { 4, 553, "INVTYPE_SHOULDER" }, [99690] = { 4, 553, "INVTYPE_SHOULDER" }, [99684] = { 4, 553, "INVTYPE_LEGS" }, [99693] = { 4, 553, "INVTYPE_LEGS" }, [99688] = { 4, 553, "INVTYPE_LEGS" }, [99683] = { 4, 553, "INVTYPE_HEAD" }, [99694] = { 4, 553, "INVTYPE_HEAD" }, [99689] = { 4, 553, "INVTYPE_HEAD" }, [99682] = { 4, 553, "INVTYPE_HAND" }, [99692] = { 4, 553, "INVTYPE_HAND" }, [99687] = { 4, 553, "INVTYPE_HAND" }, [99696] = { 4, 553, "INVTYPE_CHEST" }, [99691] = { 4, 553, "INVTYPE_CHEST" }, [99686] = { 4, 553, "INVTYPE_CHEST" }, -- T16 Heroic Essences (Normal pre-6.0) [105857] = { 4, 553, "INVTYPE_HEAD" }, [105859] = { 4, 553, "INVTYPE_HEAD" }, [105858] = { 4, 553, "INVTYPE_HEAD" }, -- T16 Mythic (Heroic pre-6.0) [99717] = { 4, 566, "INVTYPE_SHOULDER" }, [99719] = { 4, 566, "INVTYPE_SHOULDER" }, [99718] = { 4, 566, "INVTYPE_SHOULDER" }, [99726] = { 4, 566, "INVTYPE_LEGS" }, [99713] = { 4, 566, "INVTYPE_LEGS" }, [99712] = { 4, 566, "INVTYPE_LEGS" }, [99723] = { 4, 566, "INVTYPE_HEAD" }, [99725] = { 4, 566, "INVTYPE_HEAD" }, [99724] = { 4, 566, "INVTYPE_HEAD" }, [99720] = { 4, 566, "INVTYPE_HAND" }, [99722] = { 4, 566, "INVTYPE_HAND" }, [99721] = { 4, 566, "INVTYPE_HAND" }, [99714] = { 4, 566, "INVTYPE_CHEST" }, [99716] = { 4, 566, "INVTYPE_CHEST" }, [99715] = { 4, 566, "INVTYPE_CHEST" }, -- T16 Mythic Essences (Heroic pre-6.0) [105868] = { 4, 566, "INVTYPE_HEAD" }, [105867] = { 4, 566, "INVTYPE_HEAD" }, [105866] = { 4, 566, "INVTYPE_HEAD" }, -- T17 -- Item IDs are identical across difficulties, so specify nil for item level -- and specify the tier number instead: the raid difficulty and tier number -- will be used to get the item level. [119309] = { 4, 670, "INVTYPE_SHOULDER", true }, [119322] = { 4, 670, "INVTYPE_SHOULDER", true }, [119314] = { 4, 670, "INVTYPE_SHOULDER", true }, [119307] = { 4, 670, "INVTYPE_LEGS", true }, [119320] = { 4, 670, "INVTYPE_LEGS", true }, [119313] = { 4, 670, "INVTYPE_LEGS", true }, [119308] = { 4, 670, "INVTYPE_HEAD", true }, [119321] = { 4, 670, "INVTYPE_HEAD", true }, [119312] = { 4, 670, "INVTYPE_HEAD", true }, [119306] = { 4, 670, "INVTYPE_HAND", true }, [119319] = { 4, 670, "INVTYPE_HAND", true }, [119311] = { 4, 670, "INVTYPE_HAND", true }, [119305] = { 4, 670, "INVTYPE_CHEST", true }, [119318] = { 4, 670, "INVTYPE_CHEST", true }, [119315] = { 4, 670, "INVTYPE_CHEST", true }, -- T17 essences [119310] = { 4, 670, "INVTYPE_HEAD", true }, [120277] = { 4, 670, "INVTYPE_HEAD", true }, [119323] = { 4, 670, "INVTYPE_HEAD", true }, [120279] = { 4, 670, "INVTYPE_HEAD", true }, [119316] = { 4, 670, "INVTYPE_HEAD", true }, [120278] = { 4, 670, "INVTYPE_HEAD", true }, -- T18 [127957] = { 4, 695, "INVTYPE_SHOULDER", true }, [127967] = { 4, 695, "INVTYPE_SHOULDER", true }, [127961] = { 4, 695, "INVTYPE_SHOULDER", true }, [127955] = { 4, 695, "INVTYPE_LEGS", true }, [127965] = { 4, 695, "INVTYPE_LEGS", true }, [127960] = { 4, 695, "INVTYPE_LEGS", true }, [127956] = { 4, 695, "INVTYPE_HEAD", true }, [127966] = { 4, 695, "INVTYPE_HEAD", true }, [127959] = { 4, 695, "INVTYPE_HEAD", true }, [127954] = { 4, 695, "INVTYPE_HAND", true }, [127964] = { 4, 695, "INVTYPE_HAND", true }, [127958] = { 4, 695, "INVTYPE_HAND", true }, [127953] = { 4, 695, "INVTYPE_CHEST", true }, [127963] = { 4, 695, "INVTYPE_CHEST", true }, [127962] = { 4, 695, "INVTYPE_CHEST", true }, -- T18 trinket tokens (note: slightly higher ilvl) [127969] = { 4, 705, "INVTYPE_TRINKET", true }, [127970] = { 4, 705, "INVTYPE_TRINKET", true }, [127968] = { 4, 705, "INVTYPE_TRINKET", true }, } -- Used to add extra GP if the item contains bonus stats -- generally considered chargeable. local ITEM_BONUS_GP = { [40] = 0, -- avoidance, no material value [41] = 0, -- leech, no material value [42] = 25, -- speed, arguably useful, so 25 gp [43] = 0, -- indestructible, no material value [523] = 200, -- extra socket [563] = 200, -- extra socket [564] = 200, -- extra socket [565] = 200, -- extra socket [572] = 200, -- extra socket } -- The default quality threshold: -- 0 - Poor -- 1 - Uncommon -- 2 - Common -- 3 - Rare -- 4 - Epic -- 5 - Legendary -- 6 - Artifact local quality_threshold = 4 local recent_items_queue = {} local recent_items_map = {} -- Given a list of item bonuses, return the ilvl delta it represents -- (15 for Heroic, 30 for Mythic) local function GetItemBonusLevelDelta(itemBonuses) for _, value in pairs(itemBonuses) do -- Item modifiers for heroic are 566 and 570; mythic are 567 and 569 if value == 566 or value == 570 then return 15 end if value == 567 or value == 569 then return 30 end end return 0 end local function UpdateRecentLoot(itemLink) if recent_items_map[itemLink] then return end -- Debug("Adding %s to recent items", itemLink) table.insert(recent_items_queue, 1, itemLink) recent_items_map[itemLink] = true if #recent_items_queue > 15 then local itemLink = table.remove(recent_items_queue) -- Debug("Removing %s from recent items", itemLink) recent_items_map[itemLink] = nil end end function lib:GetNumRecentItems() return #recent_items_queue end function lib:GetRecentItemLink(i) return recent_items_queue[i] end --- Return the currently set quality threshold. function lib:GetQualityThreshold() return quality_threshold end --- Set the minimum quality threshold. -- @param itemQuality Lowest allowed item quality. function lib:SetQualityThreshold(itemQuality) itemQuality = itemQuality and tonumber(itemQuality) if not itemQuality or itemQuality > 6 or itemQuality < 0 then return error("Usage: SetQualityThreshold(itemQuality): 'itemQuality' - number [0,6].", 3) end quality_threshold = itemQuality end function lib:GetValue(item) if not item then return end local _, itemLink, rarity, level, _, _, _, _, equipLoc = GetItemInfo(item) if not itemLink then return end -- Get the item ID to check against known token IDs local itemID = itemLink:match("item:(%d+)") if not itemID then return end itemID = tonumber(itemID) -- For now, just use the actual ilvl, not the upgraded cost -- level = ItemUtils:GetItemIlevel(item, level) -- Check if item is relevant. Item is automatically relevant if it -- is in CUSTOM_ITEM_DATA (as of 6.0, can no longer rely on ilvl alone -- for these). if level < 463 and not CUSTOM_ITEM_DATA[itemID] then return nil, nil, level, rarity, equipLoc end -- Get the bonuses for the item to check against known bonuses local itemBonuses = ItemUtils:BonusIDs(itemLink) -- Check to see if there is custom data for this item ID if CUSTOM_ITEM_DATA[itemID] then rarity, level, equipLoc, useItemBonuses = unpack(CUSTOM_ITEM_DATA[itemID]) if useItemBonuses then level = level + GetItemBonusLevelDelta(itemBonuses) end if not level then return error("GetValue(item): could not determine item level from CUSTOM_ITEM_DATA.", 3) end end -- Is the item above our minimum threshold? if not rarity or rarity < quality_threshold then return nil, nil, level, rarity, equipLoc end -- Does the item have bonus sockets or tertiary stats? If so, -- set extra GP to apply later. We don't care about warforged -- here as that uses the increased item level instead. local extra_gp = 0 for _, value in pairs(itemBonuses) do extra_gp = extra_gp + (ITEM_BONUS_GP[value] or 0) end UpdateRecentLoot(itemLink) local slot_multiplier1 = EQUIPSLOT_MULTIPLIER_1[equipLoc] local slot_multiplier2 = EQUIPSLOT_MULTIPLIER_2[equipLoc] if not slot_multiplier1 then return nil, nil, level, rarity, equipLoc end -- 0.06973 is our coefficient so that ilvl 359 chests cost exactly -- 1000gp. In 4.2 and higher, we renormalize to make ilvl 378 -- chests cost 1000. Repeat ad infinitum! local standard_ilvl local ilvl_denominator = 26 local version = select(4, GetBuildInfo()) local level_cap = MAX_PLAYER_LEVEL_TABLE[GetExpansionLevel()] if version < 40200 then standard_ilvl = 359 elseif version < 40300 then standard_ilvl = 378 elseif version < 50200 then standard_ilvl = 496 elseif version < 50400 then standard_ilvl = 522 elseif version < 60000 or level_cap == 90 then standard_ilvl = 553 elseif version < 60200 then standard_ilvl = 680 ilvl_denominator = 30 else standard_ilvl = 710 ilvl_denominator = 30 end local multiplier = 1000 * 2 ^ (-standard_ilvl / ilvl_denominator) local gp_base = multiplier * 2 ^ (level/ilvl_denominator) local high = math.floor(0.5 + gp_base * slot_multiplier1) + extra_gp local low = slot_multiplier2 and math.floor(0.5 + gp_base * slot_multiplier2) + extra_gp or nil return high, low, level, rarity, equipLoc end
bsd-3-clause
m13790115/AVENGERRS
plugins/ingroup.lua
87
48801
do -- Check Member local function check_member_autorealm(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { group_type = 'Realm', settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_join = 'no', antitag = 'no', antilink = 'no', lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes' } } save_data(_config.moderation.data, data) local realms = 'realms' if not data[tostring(realms)] then data[tostring(realms)] = {} save_data(_config.moderation.data, data) end data[tostring(realms)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Welcome to your new realm !') end end end local function check_member_realm_add(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { group_type = 'Realm', settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_join = 'no', antitag = 'no', antilink = 'no', lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes' } } save_data(_config.moderation.data, data) local realms = 'realms' if not data[tostring(realms)] then data[tostring(realms)] = {} save_data(_config.moderation.data, data) end data[tostring(realms)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Realm has been added!') end end end function check_member_group(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { group_type = 'Group', moderators = {}, set_owner = member_id , settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_join = 'no', antitag = 'no', antilink = 'no', lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes', } } save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = {} save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, 'You have been promoted as the owner.') end end end local function check_member_modadd(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { group_type = 'Group', moderators = {}, set_owner = member_id , settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_join = 'no', antitag = 'no', antilink = 'no', lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes', } } save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = {} save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Group is added and you have been promoted as the owner ') end end end local function automodadd(msg) local data = load_data(_config.moderation.data) if msg.action.type == 'chat_created' then receiver = get_receiver(msg) chat_info(receiver, check_member_group,{receiver=receiver, data=data, msg = msg}) end end local function autorealmadd(msg) local data = load_data(_config.moderation.data) if msg.action.type == 'chat_created' then receiver = get_receiver(msg) chat_info(receiver, check_member_autorealm,{receiver=receiver, data=data, msg = msg}) end end local function check_member_realmrem(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Realm configuration removal data[tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) local realms = 'realms' if not data[tostring(realms)] then data[tostring(realms)] = nil save_data(_config.moderation.data, data) end data[tostring(realms)][tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Realm has been removed!') end end end local function check_member_modrem(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration removal data[tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = nil save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Group has been removed') end end end --End Check Member local function show_group_settingsmod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local data = load_data(_config.moderation.data) if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['settings']['flood_msg_max'] then NUM_MSG_MAX = tonumber(data[tostring(msg.to.id)]['settings']['flood_msg_max']) print('custom'..NUM_MSG_MAX) else NUM_MSG_MAX = 5 end end local bots_protection = "Yes" if data[tostring(msg.to.id)]['settings']['lock_bots'] then bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots'] end local leave_ban = "no" if data[tostring(msg.to.id)]['settings']['leave_ban'] then leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban'] end local settings = data[tostring(target)]['settings'] local text = "Group settings:\nLock group join : "..settings.lock_join.."\nLock group tag : "..settings.antitag.."\nLock group link : "..settings.antilink.."\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nLock group leave : "..leave_ban.."\nflood sensitivity : "..NUM_MSG_MAX.."\nBot protection : "..bots_protection--"\nPublic: "..public return text end local function set_descriptionmod(msg, data, target, about) if not is_momod(msg) then return "For moderators only!" end local data_cat = 'description' data[tostring(target)][data_cat] = about save_data(_config.moderation.data, data) return 'Set group description to:\n'..about end local function get_description(msg, data) local data_cat = 'description' if not data[tostring(msg.to.id)][data_cat] then return 'No description available.' end local about = data[tostring(msg.to.id)][data_cat] local about = string.gsub(msg.to.print_name, "_", " ")..':\n\n'..about return 'About '..about end local function lock_group_arabic(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic'] if group_arabic_lock == 'yes' then return 'Arabic is already locked' else data[tostring(target)]['settings']['lock_arabic'] = 'yes' save_data(_config.moderation.data, data) return 'Arabic has been locked' end end local function unlock_group_arabic(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic'] if group_arabic_lock == 'no' then return 'Arabic is already unlocked' else data[tostring(target)]['settings']['lock_arabic'] = 'no' save_data(_config.moderation.data, data) return 'Arabic has been unlocked' end end local function lock_group_bots(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_bots_lock = data[tostring(target)]['settings']['lock_bots'] if group_bots_lock == 'yes' then return 'Bots protection is already enabled' else data[tostring(target)]['settings']['lock_bots'] = 'yes' save_data(_config.moderation.data, data) return 'Bots protection has been enabled' end end local function unlock_group_bots(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_bots_lock = data[tostring(target)]['settings']['lock_bots'] if group_bots_lock == 'no' then return 'Bots protection is already disabled' else data[tostring(target)]['settings']['lock_bots'] = 'no' save_data(_config.moderation.data, data) return 'Bots protection has been disabled' end end local function lock_group_tag(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_tag_lock = data[tostring(target)]['settings']['antitag'] if group_tag_lock == 'yes' then return 'Tag is already locked' else data[tostring(target)]['settings']['antitag'] = 'yes' save_data(_config.moderation.data, data) return 'Tag has been locked' end end local function unlock_group_tag(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_tag_lock = data[tostring(target)]['settings']['antitag'] if group_tag_lock == 'no' then return 'Tag is already unlocked' else data[tostring(target)]['settings']['antitag'] = 'no' save_data(_config.moderation.data, data) return 'Tag has been unlocked' end end local function lock_group_join(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_join_lock = data[tostring(target)]['settings']['lock_join'] if group_join_lock == 'yes' then return ' joining Link is already locked' else data[tostring(target)]['settings']['lock_join'] = 'yes' save_data(_config.moderation.data, data) return 'joining Link has been locked' end end local function unlock_group_join(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_join_lock = data[tostring(target)]['settings']['lock_join'] if group_join_lock == 'no' then return ' joining Link is already unlocked' else data[tostring(target)]['settings']['lock_join'] = 'no' save_data(_config.moderation.data, data) return ' joining Link has been unlocked' end end local function lock_group_link(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_link_lock = data[tostring(target)]['settings']['antilink'] if group_link_lock == 'yes' then return 'Link is already locked' else data[tostring(target)]['settings']['antilink'] = 'yes' save_data(_config.moderation.data, data) return 'Link has been locked' end end local function unlock_group_link(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_link_lock = data[tostring(target)]['settings']['antilink'] if group_link_lock == 'no' then return 'Link is already unlocked' else data[tostring(target)]['settings']['antilink'] = 'no' save_data(_config.moderation.data, data) return 'Link has been unlocked' end end local function lock_group_namemod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_name_set = data[tostring(target)]['settings']['set_name'] local group_name_lock = data[tostring(target)]['settings']['lock_name'] if group_name_lock == 'yes' then return 'Group name is already locked' else data[tostring(target)]['settings']['lock_name'] = 'yes' save_data(_config.moderation.data, data) rename_chat('chat#id'..target, group_name_set, ok_cb, false) return 'Group name has been locked' end end local function unlock_group_namemod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_name_set = data[tostring(target)]['settings']['set_name'] local group_name_lock = data[tostring(target)]['settings']['lock_name'] if group_name_lock == 'no' then return 'Group name is already unlocked' else data[tostring(target)]['settings']['lock_name'] = 'no' save_data(_config.moderation.data, data) return 'Group name has been unlocked' end end local function lock_group_floodmod(msg, data, target) if not is_owner(msg) then return "Only admins can do it for now" end local group_flood_lock = data[tostring(target)]['settings']['flood'] if group_flood_lock == 'yes' then return 'Group flood is locked' else data[tostring(target)]['settings']['flood'] = 'yes' save_data(_config.moderation.data, data) return 'Group flood has been locked' end end local function unlock_group_floodmod(msg, data, target) if not is_owner(msg) then return "Only admins can do it for now" end local group_flood_lock = data[tostring(target)]['settings']['flood'] if group_flood_lock == 'no' then return 'Group flood is not locked' else data[tostring(target)]['settings']['flood'] = 'no' save_data(_config.moderation.data, data) return 'Group flood has been unlocked' end end local function lock_group_membermod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_member_lock = data[tostring(target)]['settings']['lock_member'] if group_member_lock == 'yes' then return 'Group members are already locked' else data[tostring(target)]['settings']['lock_member'] = 'yes' save_data(_config.moderation.data, data) end return 'Group members has been locked' end local function unlock_group_membermod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_member_lock = data[tostring(target)]['settings']['lock_member'] if group_member_lock == 'no' then return 'Group members are not locked' else data[tostring(target)]['settings']['lock_member'] = 'no' save_data(_config.moderation.data, data) return 'Group members has been unlocked' end end local function set_public_membermod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_member_lock = data[tostring(target)]['settings']['public'] if group_member_lock == 'yes' then return 'Group is already public' else data[tostring(target)]['settings']['public'] = 'yes' save_data(_config.moderation.data, data) end return 'Group is now: public' end local function unset_public_membermod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_member_lock = data[tostring(target)]['settings']['public'] if group_member_lock == 'no' then return 'Group is not public' else data[tostring(target)]['settings']['public'] = 'no' save_data(_config.moderation.data, data) return 'Group is now: not public' end end local function lock_group_leave(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban'] if leave_ban == 'yes' then return 'Leaving users will be banned' else data[tostring(msg.to.id)]['settings']['leave_ban'] = 'yes' save_data(_config.moderation.data, data) end return 'Leaving users will be banned' end local function unlock_group_leave(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban'] if leave_ban == 'no' then return 'Leaving users will not be banned' else data[tostring(msg.to.id)]['settings']['leave_ban'] = 'no' save_data(_config.moderation.data, data) return 'Leaving users will not be banned' end end local function unlock_group_photomod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_photo_lock = data[tostring(target)]['settings']['lock_photo'] if group_photo_lock == 'no' then return 'Group photo is not locked' else data[tostring(target)]['settings']['lock_photo'] = 'no' save_data(_config.moderation.data, data) return 'Group photo has been unlocked' end end local function set_rulesmod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local data_cat = 'rules' data[tostring(target)][data_cat] = rules save_data(_config.moderation.data, data) return 'Set group rules to:\n'..rules end local function modadd(msg) -- superuser and admins only (because sudo are always has privilege) if not is_admin(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if is_group(msg) then return 'Group is already added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_modadd,{receiver=receiver, data=data, msg = msg}) end local function realmadd(msg) -- superuser and admins only (because sudo are always has privilege) if not is_admin(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if is_realm(msg) then return 'Realm is already added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_realm_add,{receiver=receiver, data=data, msg = msg}) end -- Global functions function modrem(msg) -- superuser and admins only (because sudo are always has privilege) if not is_admin(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if not is_group(msg) then return 'Group is not added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_modrem,{receiver=receiver, data=data, msg = msg}) end function realmrem(msg) -- superuser and admins only (because sudo are always has privilege) if not is_admin(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if not is_realm(msg) then return 'Realm is not added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_realmrem,{receiver=receiver, data=data, msg = msg}) end local function get_rules(msg, data) local data_cat = 'rules' if not data[tostring(msg.to.id)][data_cat] then return 'No rules available.' end local rules = data[tostring(msg.to.id)][data_cat] local rules = 'Chat rules:\n'..rules return rules end local function set_group_photo(msg, success, result) local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) if success then local file = 'data/photos/chat_photo_'..msg.to.id..'.jpg' print('File downloaded to:', result) os.rename(result, file) print('File moved to:', file) chat_set_photo (receiver, file, ok_cb, false) data[tostring(msg.to.id)]['settings']['set_photo'] = file save_data(_config.moderation.data, data) data[tostring(msg.to.id)]['settings']['lock_photo'] = 'yes' save_data(_config.moderation.data, data) send_large_msg(receiver, 'Photo saved!', ok_cb, false) else print('Error downloading: '..msg.id) send_large_msg(receiver, 'Failed, please try again!', ok_cb, false) end end local function promote(receiver, member_username, member_id) local data = load_data(_config.moderation.data) local group = string.gsub(receiver, 'chat#id', '') if not data[group] then return send_large_msg(receiver, 'Group is not added.') end if data[group]['moderators'][tostring(member_id)] then return send_large_msg(receiver, member_username..' is already a moderator.') end data[group]['moderators'][tostring(member_id)] = member_username save_data(_config.moderation.data, data) return send_large_msg(receiver, member_username..' has been promoted.') end local function promote_by_reply(extra, success, result) local msg = result local full_name = (msg.from.first_name or '')..' '..(msg.from.last_name or '') if msg.from.username then member_username = '@'.. msg.from.username else member_username = full_name end local member_id = msg.from.id if msg.to.type == 'chat' then return promote(get_receiver(msg), member_username, member_id) end end local function demote(receiver, member_username, member_id) local data = load_data(_config.moderation.data) local group = string.gsub(receiver, 'chat#id', '') if not data[group] then return send_large_msg(receiver, 'Group is not added.') end if not data[group]['moderators'][tostring(member_id)] then return send_large_msg(receiver, member_username..' is not a moderator.') end data[group]['moderators'][tostring(member_id)] = nil save_data(_config.moderation.data, data) return send_large_msg(receiver, member_username..' has been demoted.') end local function demote_by_reply(extra, success, result) local msg = result local full_name = (msg.from.first_name or '')..' '..(msg.from.last_name or '') if msg.from.username then member_username = '@'..msg.from.username else member_username = full_name end local member_id = msg.from.id if msg.to.type == 'chat' then return demote(get_receiver(msg), member_username, member_id) end end local function setowner_by_reply(extra, success, result) local msg = result local receiver = get_receiver(msg) local data = load_data(_config.moderation.data) local name_log = msg.from.print_name:gsub("_", " ") data[tostring(msg.to.id)]['set_owner'] = tostring(msg.from.id) save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] setted ["..msg.from.id.."] as owner") local text = msg.from.print_name:gsub("_", " ").." is the owner now" return send_large_msg(receiver, text) end local function promote_demote_res(extra, success, result) --vardump(result) --vardump(extra) local member_id = result.id local member_username = "@"..result.username local chat_id = extra.chat_id local mod_cmd = extra.mod_cmd local receiver = "chat#id"..chat_id if mod_cmd == 'promote' then return promote(receiver, member_username, member_id) elseif mod_cmd == 'demote' then return demote(receiver, member_username, member_id) end end local function modlist(msg) local data = load_data(_config.moderation.data) local groups = "groups" if not data[tostring(groups)][tostring(msg.to.id)] then return 'Group is not added.' end -- determine if table is empty if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way return 'No moderator in this group.' end local i = 1 local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n' for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do message = message ..i..' - '..v..' [' ..k.. '] \n' i = i + 1 end return message end local function callbackres(extra, success, result) --vardump(result) local user = result.id local name = string.gsub(result.print_name, "_", " ") local chat = 'chat#id'..extra.chatid send_large_msg(chat, user..'\n'..name) return user end local function help() local help_text = tostring(_config.help_text) return help_text end local function cleanmember(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name for k,v in pairs(result.members) do kick_user(v.id, result.id) end end local function killchat(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name for k,v in pairs(result.members) do kick_user_any(v.id, result.id) end end local function killrealm(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name for k,v in pairs(result.members) do kick_user_any(v.id, result.id) end end local function user_msgs(user_id, chat_id) local user_info local uhash = 'user:'..user_id local user = redis:hgetall(uhash) local um_hash = 'msgs:'..user_id..':'..chat_id user_info = tonumber(redis:get(um_hash) or 0) return user_info end local function kick_zero(cb_extra, success, result) local chat_id = cb_extra.chat_id local chat = "chat#id"..chat_id local ci_user local re_user for k,v in pairs(result.members) do local si = false ci_user = v.id local hash = 'chat:'..chat_id..':users' local users = redis:smembers(hash) for i = 1, #users do re_user = users[i] if tonumber(ci_user) == tonumber(re_user) then si = true end end if not si then if ci_user ~= our_id then if not is_momod2(ci_user, chat_id) then chat_del_user(chat, 'user#id'..ci_user, ok_cb, true) end end end end end local function kick_inactive(chat_id, num, receiver) local hash = 'chat:'..chat_id..':users' local users = redis:smembers(hash) -- Get user info for i = 1, #users do local user_id = users[i] local user_info = user_msgs(user_id, chat_id) local nmsg = user_info if tonumber(nmsg) < tonumber(num) then if not is_momod2(user_id, chat_id) then chat_del_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, true) end end end return chat_info(receiver, kick_zero, {chat_id = chat_id}) end local function run(msg, matches) local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) local name_log = user_print_name(msg.from) local group = msg.to.id if msg.media then if msg.media.type == 'photo' and data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' and is_chat_msg(msg) and is_momod(msg) then load_photo(msg.id, set_group_photo, msg) end end if matches[1] == 'add' and not matches[2] then if is_realm(msg) then return 'Error: Already a realm.' end print("group "..msg.to.print_name.."("..msg.to.id..") added") return modadd(msg) end if matches[1] == 'add' and matches[2] == 'realm' then if is_group(msg) then return 'Error: Already a group.' end print("group "..msg.to.print_name.."("..msg.to.id..") added as a realm") return realmadd(msg) end if matches[1] == 'rem' and not matches[2] then print("group "..msg.to.print_name.."("..msg.to.id..") removed") return modrem(msg) end if matches[1] == 'rem' and matches[2] == 'realm' then print("group "..msg.to.print_name.."("..msg.to.id..") removed as a realm") return realmrem(msg) end if matches[1] == 'chat_created' and msg.from.id == 0 and group_type == "group" then return automodadd(msg) end if matches[1] == 'chat_created' and msg.from.id == 0 and group_type == "realm" then return autorealmadd(msg) end if msg.to.id and data[tostring(msg.to.id)] then local settings = data[tostring(msg.to.id)]['settings'] if matches[1] == 'chat_add_user' then if not msg.service then return "Are you trying to troll me?" end local group_member_lock = settings.lock_member local user = 'user#id'..msg.action.user.id local chat = 'chat#id'..msg.to.id if group_member_lock == 'yes' and not is_owner2(msg.action.user.id, msg.to.id) then chat_del_user(chat, user, ok_cb, true) elseif group_member_lock == 'yes' and tonumber(msg.from.id) == tonumber(our_id) then return nil elseif group_member_lock == 'no' then return nil end end if matches[1] == 'chat_del_user' then if not msg.service then -- return "Are you trying to troll me?" end local user = 'user#id'..msg.action.user.id local chat = 'chat#id'..msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..user) end if matches[1] == 'chat_delete_photo' then if not msg.service then return "Are you trying to troll me?" end local group_photo_lock = settings.lock_photo if group_photo_lock == 'yes' then local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:incr(picturehash) --- local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id local picprotectionredis = redis:get(picturehash) if picprotectionredis then if tonumber(picprotectionredis) == 4 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id) end if tonumber(picprotectionredis) == 8 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id) local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:set(picturehash, 0) end end savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to deleted picture but failed ") chat_set_photo(receiver, settings.set_photo, ok_cb, false) elseif group_photo_lock == 'no' then return nil end end if matches[1] == 'chat_change_photo' and msg.from.id ~= 0 then if not msg.service then return "Are you trying to troll me?" end local group_photo_lock = settings.lock_photo if group_photo_lock == 'yes' then local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:incr(picturehash) --- local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id local picprotectionredis = redis:get(picturehash) if picprotectionredis then if tonumber(picprotectionredis) == 4 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id) end if tonumber(picprotectionredis) == 8 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id) local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:set(picturehash, 0) end end savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change picture but failed ") chat_set_photo(receiver, settings.set_photo, ok_cb, false) elseif group_photo_lock == 'no' then return nil end end if matches[1] == 'chat_rename' then if not msg.service then return "Are you trying to troll me?" end local group_name_set = settings.set_name local group_name_lock = settings.lock_name local to_rename = 'chat#id'..msg.to.id if group_name_lock == 'yes' then if group_name_set ~= tostring(msg.to.print_name) then local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id redis:incr(namehash) local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id local nameprotectionredis = redis:get(namehash) if nameprotectionredis then if tonumber(nameprotectionredis) == 4 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id) end if tonumber(nameprotectionredis) == 8 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id) local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id redis:set(namehash, 0) end end savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change name but failed ") rename_chat(to_rename, group_name_set, ok_cb, false) end elseif group_name_lock == 'no' then return nil end end if matches[1] == 'setname' and is_momod(msg) then local new_name = string.gsub(matches[2], '_', ' ') data[tostring(msg.to.id)]['settings']['set_name'] = new_name save_data(_config.moderation.data, data) local group_name_set = data[tostring(msg.to.id)]['settings']['set_name'] local to_rename = 'chat#id'..msg.to.id rename_chat(to_rename, group_name_set, ok_cb, false) savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]") end if matches[1] == 'setphoto' and is_momod(msg) then data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting' save_data(_config.moderation.data, data) return 'Please send me new group photo now' end if matches[1] == 'promote' and not matches[2] then if not is_owner(msg) then return "Only the owner can prmote new moderators" end if type(msg.reply_id)~="nil" then msgr = get_message(msg.reply_id, promote_by_reply, false) end end if matches[1] == 'promote' and matches[2] then if not is_momod(msg) then return end if not is_owner(msg) then return "Only owner can promote" end local member = matches[2] savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted @".. member) local cbres_extra = { chat_id = msg.to.id, mod_cmd = 'promote', from_id = msg.from.id } local username = matches[2] local username = string.gsub(matches[2], '@', '') return res_user(username, promote_demote_res, cbres_extra) end if matches[1] == 'demote' and not matches[2] then if not is_owner(msg) then return "Only the owner can demote moderators" end if type(msg.reply_id)~="nil" then msgr = get_message(msg.reply_id, demote_by_reply, false) end end if matches[1] == 'demote' and matches[2] then if not is_momod(msg) then return end if not is_owner(msg) then return "Only owner can demote" end if string.gsub(matches[2], "@", "") == msg.from.username and not is_owner(msg) then return "You can't demote yourself" end local member = matches[2] savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted @".. member) local cbres_extra = { chat_id = msg.to.id, mod_cmd = 'demote', from_id = msg.from.id } local username = matches[2] local username = string.gsub(matches[2], '@', '') return res_user(username, promote_demote_res, cbres_extra) end if matches[1] == 'modlist' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group modlist") return modlist(msg) end if matches[1] == 'about' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group description") return get_description(msg, data) end if matches[1] == 'rules' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group rules") return get_rules(msg, data) end if matches[1] == 'set' then if matches[2] == 'rules' then rules = matches[3] local target = msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group rules to ["..matches[3].."]") return set_rulesmod(msg, data, target) end if matches[2] == 'about' then local data = load_data(_config.moderation.data) local target = msg.to.id local about = matches[3] savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group description to ["..matches[3].."]") return set_descriptionmod(msg, data, target, about) end end if matches[1] == 'lock' then local target = msg.to.id if matches[2] == 'name' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked name ") return lock_group_namemod(msg, data, target) end if matches[2] == 'member' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked member ") return lock_group_membermod(msg, data, target) end if matches[2] == 'flood' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked flood ") return lock_group_floodmod(msg, data, target) end if matches[2] == 'arabic' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked arabic ") return lock_group_arabic(msg, data, target) end if matches[2] == 'bots' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked bots ") return lock_group_bots(msg, data, target) end if matches[2] == 'leave' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked leaving ") return lock_group_leave(msg, data, target) end if matches[2] == 'link' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked link ") return lock_group_link(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] == 'join' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked joining link ") return lock_group_join(msg, data, target) end end if matches[1] == 'unlock' then local target = msg.to.id if matches[2] == 'name' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked name ") return unlock_group_namemod(msg, data, target) end if matches[2] == 'member' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked member ") return unlock_group_membermod(msg, data, target) end if matches[2] == 'photo' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked photo ") return unlock_group_photomod(msg, data, target) end if matches[2] == 'flood' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked flood ") return unlock_group_floodmod(msg, data, target) end if matches[2] == 'arabic' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked arabic ") return unlock_group_arabic(msg, data, target) end if matches[2] == 'link' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked link ") return unlock_group_link(msg, data, target) end if matches[2] == 'bots' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked bots ") return unlock_group_bots(msg, data, target) end if matches[2] == 'join' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked joining link ") return unlock_group_join(msg, data, target) end if matches[2] == 'leave' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked leaving ") return unlock_group_leave(msg, data, target) end if matches[2] == 'tag' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked tag ") return unlock_group_tag(msg, data, target) end end if matches[1] == 'settings' then local target = msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group settings ") return show_group_settingsmod(msg, data, target) end --[[if matches[1] == 'public' then local target = msg.to.id if matches[2] == 'yes' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: public") return set_public_membermod(msg, data, target) end if matches[2] == 'no' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: not public") return unset_public_membermod(msg, data, target) end end]] if matches[1] == 'newlink' and not is_realm(msg) then if not is_momod(msg) then return "For moderators only!" end local function callback (extra , success, result) local receiver = 'chat#'..msg.to.id if success == 0 then return send_large_msg(receiver, '*Error: Invite link failed* \nReason: Not creator.') end send_large_msg(receiver, "Created a new link") data[tostring(msg.to.id)]['settings']['set_link'] = result save_data(_config.moderation.data, data) end local receiver = 'chat#'..msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] revoked group link ") return export_chat_link(receiver, callback, true) end if matches[1] == 'link' then if not is_momod(msg) then return "For moderators only!" end local group_link = data[tostring(msg.to.id)]['settings']['set_link'] if not group_link then return "Create a link using /newlink first !" end savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group link ["..group_link.."]") return "Group link:\n"..group_link end if matches[1] == 'linkpv' then if not is_momod(msg) then return "For moderators only!" end local group_link = data[tostring(msg.to.id)]['settings']['set_link'] if not group_link then return "Create a link using /newlink first !" end savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group link ["..group_link.."]") send_large_msg('user#id'..msg.from.id, "Group link:\n"..group_link) end if matches[1] == 'setowner' and matches[2] then if not is_owner(msg) then return "For owner only!" end data[tostring(msg.to.id)]['set_owner'] = matches[2] save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] set ["..matches[2].."] as owner") local text = matches[2].." added as owner" return text end if matches[1] == 'setowner' and not matches[2] then if not is_owner(msg) then return "only for the owner!" end if type(msg.reply_id)~="nil" then msgr = get_message(msg.reply_id, setowner_by_reply, false) end end if matches[1] == 'owner' then local group_owner = data[tostring(msg.to.id)]['set_owner'] if not group_owner then return "no owner,ask admins in support groups to set owner for your group" end savelog(msg.to.id, name_log.." ["..msg.from.id.."] used /owner") return "Group owner is ["..group_owner..']' end if matches[1] == 'setgpowner' then local receiver = "chat#id"..matches[2] if not is_admin(msg) then return "For admins only!" end data[tostring(matches[2])]['set_owner'] = matches[3] save_data(_config.moderation.data, data) local text = matches[3].." added as owner" send_large_msg(receiver, text) return end if matches[1] == 'setflood' then if not is_momod(msg) then return "For moderators only!" end if tonumber(matches[2]) < 5 or tonumber(matches[2]) > 20 then return "Wrong number,range is [5-20]" end local flood_max = matches[2] data[tostring(msg.to.id)]['settings']['flood_msg_max'] = flood_max save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] set flood to ["..matches[2].."]") return 'Group flood has been set to '..matches[2] end if matches[1] == 'clean' then if not is_owner(msg) then return "Only owner can clean" end if matches[2] == 'member' then if not is_owner(msg) then return "Only admins can clean members" end local receiver = get_receiver(msg) chat_info(receiver, cleanmember, {receiver=receiver}) end if matches[2] == 'modlist' then if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way return 'No moderator in this group.' end local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n' for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do data[tostring(msg.to.id)]['moderators'][tostring(k)] = nil save_data(_config.moderation.data, data) end savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned modlist") end if matches[2] == 'rules' then local data_cat = 'rules' data[tostring(msg.to.id)][data_cat] = nil save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned rules") end if matches[2] == 'about' then local data_cat = 'description' data[tostring(msg.to.id)][data_cat] = nil save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned about") end end if matches[1] == 'kill' and matches[2] == 'chat' then if not is_admin(msg) then return nil end if not is_realm(msg) then local receiver = get_receiver(msg) return modrem(msg), print("Closing Group..."), chat_info(receiver, killchat, {receiver=receiver}) else return 'This is a realm' end end if matches[1] == 'kill' and matches[2] == 'realm' then if not is_admin(msg) then return nil end if not is_group(msg) then local receiver = get_receiver(msg) return realmrem(msg), print("Closing Realm..."), chat_info(receiver, killrealm, {receiver=receiver}) else return 'This is a group' end end if matches[1] == 'help' then if not is_momod(msg) or is_realm(msg) then return end savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help") return help() end if matches[1] == 'res' and is_momod(msg) then local cbres_extra = { chatid = msg.to.id } local username = matches[2] local username = username:gsub("@","") savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username) return res_user(username, callbackres, cbres_extra) end if matches[1] == 'kickinactive' then --send_large_msg('chat#id'..msg.to.id, 'I\'m in matches[1]') if not is_momod(msg) then return 'Only a moderator can kick inactive users' end local num = 1 if matches[2] then num = matches[2] end local chat_id = msg.to.id local receiver = get_receiver(msg) return kick_inactive(chat_id, num, receiver) end end end return { patterns = { "^[!/](add)$", "^[!/](add) (realm)$", "^[!/](rem)$", "^[!/](rem) (realm)$", "^[!/](rules)$", "^[!/](about)$", "^[!/](setname) (.*)$", "^[!/](setphoto)$", "^[!/](promote) (.*)$", "^[!/](promote)", "^[!/](help)$", "^[!/](clean) (.*)$", "^[!/](kill) (chat)$", "^[!/](kill) (realm)$", "^[!/](demote) (.*)$", "^[!/](demote)", "^[!/](set) ([^%s]+) (.*)$", "^[!/](lock) (.*)$", "^[!/](setowner) (%d+)$", "^[!/](setowner)", "^[!/](owner)$", "^[!/](res) (.*)$", "^[!/](setgpowner) (%d+) (%d+)$",-- (group id) (owner id) "^[!/](unlock) (.*)$", "^[!/](setflood) (%d+)$", "^[!/](settings)$", "^[!/](public) (.*)$", "^[!/](modlist)$", "^[!/](newlink)$", "^[!/](link)$", "^[!/](linkpv)$", "^[!/](kickinactive)$", "^[!/](kickinactive) (%d+)$", "^([Aa]dd)$", "^([Rr]em)$", "^([Rr]ules)$", "^({Aa]bout)$", "^([Ss]etname) (.*)$", "^([Ss]etphoto)$", "^([Pp]romote) (.*)$", "^([Pp]romote)$", "^([Hh]elp)$", "^([Cc]lean) (.*)$", "^([Dd]emote) (.*)$", "^([Dd]emote)$", "^([Ss]et) ([^%s]+) (.*)$", "^([Ll]ock) (.*)$", "^([Ss]etowner) (%d+)$", "^([Ss]etowner)$", "^([Oo]wner)$", "^([Rr]es) (.*)$", "^([Ss]etgpowner) (%d+) (%d+)$",-- (group id) (owner id) "^([Uu]nlock) (.*)$", "^([Ss]etflood) (%d+)$", "^([Ss]ettings)$", "^([Mm]odlist)$", "^([Nn]ewlink)$", "^([Ll]ink)$", "%[(photo)%]", "^!!tgservice (.+)$", }, run = run } end
gpl-2.0
kitala1/darkstar
scripts/globals/items/plate_of_squid_sushi.lua
35
1598
----------------------------------------- -- ID: 5148 -- Item: plate_of_squid_sushi -- Food Effect: 30Min, All Races ----------------------------------------- -- Health 30 -- Dexterity 6 -- Agility 5 -- Mind -1 -- Accuracy % 15 -- Ranged ACC % 15 -- Sleep Resist 5 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,1800,5148); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_HP, 30); target:addMod(MOD_DEX, 6); target:addMod(MOD_AGI, 5); target:addMod(MOD_MND, -1); target:addMod(MOD_ACCP, 15); target:addMod(MOD_RACCP, 15); target:addMod(MOD_SLEEPRES, 5); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_HP, 30); target:delMod(MOD_DEX, 6); target:delMod(MOD_AGI, 5); target:delMod(MOD_MND, -1); target:delMod(MOD_ACCP, 15); target:delMod(MOD_RACCP, 15); target:delMod(MOD_SLEEPRES, 5); end;
gpl-3.0
d-o/LUA-LIB
tests/unit/stream.lua
2
6110
------------------------------------------------------------------------------- -- Streaming unit test. -- @author Pauli -- @copyright 2014 Rinstrum Pty Ltd ------------------------------------------------------------------------------- describe("Streaming #stream", function () local start, stop = 1, 0 local manual, auto, auto10, auto3, auto1, onchange = 0, 1, 2, 3, 4, 5 local function makeModule() local m, p, d = {}, { deviceType='' }, {} require("rinLibrary.utilities")(m, p, d) require("rinLibrary.rinCon")(m, p, d) require("rinLibrary.K400Reg")(m, p, d) require("rinLibrary.GenericStream")(m, p, d) require("rinLibrary.K400Setpoint")(m, p, d) p.processDeviceInitialisers() return m, p, d end it("enumerations", function() local _, _, d = makeModule() for k, v in pairs{ start = start, stop = stop, freq_manual = manual, freq_auto = auto, freq_auto10 = auto10, freq_auto3 = auto3, freq_auto1 = auto1, freq_onchange = onchange } do it("test "..k, function() assert.equal(v, d['STM_' .. string.upper(k)]) end) end end) describe("set", function() local m = makeModule() local z = require "tests.messages" for _, t in pairs{ { s='auto1', r='gross', c={ { r=0x026, f='getRegDecimalPlaces' }, { r=0x026, f='getRegType' }, { r=0x341, f='writeRegHexAsync', auto1 }, { r=0x342, f='writeRegAsync', 0x0026 }, { r=0x340, f='exRegAsync', start } }}, { s='onchange', r='grossnet', c={ { r=0x025, f='getRegDecimalPlaces' }, { r=0x025, f='getRegType' }, { r=0x341, f='writeRegHexAsync', onchange}, { r=0x343, f='writeRegAsync', 0x0025 }, { r=0x340, f='exRegAsync', start } }}, { s='auto', r='tare', c={ { r=0x028, f='getRegDecimalPlaces' }, { r=0x028, f='getRegType' }, { r=0x341, f='writeRegHexAsync', auto }, { r=0x344, f='writeRegAsync', 0x0028 }, { r=0x340, f='exRegAsync', start } }}, { s='auto10', r='net', c={ { r=0x027, f='getRegDecimalPlaces' }, { r=0x027, f='getRegType' }, { r=0x341, f='writeRegHexAsync', auto10 }, { r=0x345, f='writeRegAsync', 0x0027 }, { r=0x340, f='exRegAsync', start } }}, { s='auto3', r='fullscale', c={ { r=0x02F, f='getRegDecimalPlaces' }, { r=0x02F, f='getRegType' }, { r=0x341, f='writeRegHexAsync', auto3 }, { r=0x346, f='writeRegAsync', 0x002F }, { r=0x340, f='exRegAsync', start } }}, } do it(t.s, function() z.checkNoReg(m, m.setStreamFreq, t.s) -- z.checkReg(m, t.c, m.addStream, t.r, function() end, 'always') end) end end) -- it("clear", function() -- local m, p = makeModule() -- local z = require "tests.messages" -- local saved = z.saveRegFunctions(m) -- p.writeRegAsync = spy.new(function() end) -- -- -- set speed -- z.checkNoReg(m, m.setStreamFreq, 'auto') -- -- -- set first stream -- local d1 = m.addStream('net', function() end, 'always') -- assert.spy(p.writeRegAsync).was.called_with(0x342, 0x27) -- -- -- set second stream -- local d2 = m.addStream('tare', function() end, 'always') -- assert.spy(p.writeRegAsync).was.called_with(0x343, 0x28) -- -- -- remove first stream -- z.checkReg(m, {{ r=0x342, f='writeReg', 0 }}, m.removeStream, d1) -- -- -- set first stream again, should reuse the stream register -- d1 = m.addStream('grossnet', function() end, 'always') -- assert.spy(p.writeRegAsync).was.called_with(0x342, 0x25) -- -- -- rmove both steams -- z.checkReg(m, { { r=0x343, f='writeReg', 0 } }, m.removeStream, d2) -- z.checkReg(m, { { r=0x342, f='writeReg', 0 }, -- { r=0x340, f='exReg', 0 } }, m.removeStream, d1) -- -- -- clean up and finish -- z.restoreRegFunctions(saved) -- end) describe("many streams", function() local m = makeModule() local z = require "tests.messages" m.setStreamFreq('onchange') for _, t in pairs{ { r='adcsample', reg=0x342, arg=0x0020 }, { r='sysstatus', reg=0x343, arg=0x0021 }, { r='syserr', reg=0x344, arg=0x0022 }, { r='absmvv', reg=0x345, arg=0x0023 }, { r='grossnet', reg=0x346, arg=0x0025 }, { r='gross', reg=0x352, arg=0x0026 }, { r='net', reg=0x353, arg=0x0027 }, { r='tare', reg=0x354, arg=0x0028 }, { r='peakhold', reg=0x355, arg=0x0029 }, { r='manhold', reg=0x356, arg=0x002A }, { r='grandtotal', reg=0x042, arg=12 }, { r='altgross', reg=0x043, arg=13 }, { r='fullscale', reg=0x044, arg=15 }, { r='io_status', reg=0x045, arg=16 }, { r='altnet', reg=0x046, arg=14 } } do it(t.r, function() local c = {{ r = t.reg, f = 'writeRegAsync', t.arg }} -- z.checkReg(m, c, m.addStream, t.r, function() end, 'always') end) end end) end)
gpl-3.0
MrUnknownGamer/pointshop
lua/pointshop/sh_config.lua
2
2081
PS.Config = {} -- Edit below PS.Config.CommunityName = "My Community" PS.Config.DataProvider = 'pdata' PS.Config.Branch = 'https://raw.github.com/adamdburton/pointshop/master/' -- Master is most stable, used for version checking. PS.Config.CheckVersion = true -- Do you want to be notified when a new version of Pointshop is avaliable? PS.Config.ShopKey = 'F3' -- F1, F2, F3 or F4, or blank to disable PS.Config.ShopCommand = 'ps_shop' -- Console command to open the shop, set to blank to disable PS.Config.ShopChatCommand = '!shop' -- Chat command to open the shop, set to blank to disable PS.Config.NotifyOnJoin = true -- Should players be notified about opening the shop when they spawn? PS.Config.PointsOverTime = true -- Should players be given points over time? PS.Config.PointsOverTimeDelay = 1 -- If so, how many minutes apart? PS.Config.PointsOverTimeAmount = 10 -- And if so, how many points to give after the time? PS.Config.AdminCanAccessAdminTab = true -- Can Admins access the Admin tab? PS.Config.SuperAdminCanAccessAdminTab = true -- Can SuperAdmins access the Admin tab? PS.Config.CanPlayersGivePoints = true -- Can players give points away to other players? PS.Config.DisplayPreviewInMenu = true -- Can players see the preview of their items in the menu? PS.Config.PointsName = 'Points' -- What are the points called? PS.Config.SortItemsBy = 'Name' -- How are items sorted? Set to 'Price' to sort by price. -- Edit below if you know what you're doing PS.Config.CalculateBuyPrice = function(ply, item) -- You can do different calculations here to return how much an item should cost to buy. -- There are a few examples below, uncomment them to use them. -- Everything half price for admins: -- if ply:IsAdmin() then return math.Round(item.Price * 0.5) end -- 25% off for the 'donators' group -- if ply:IsUserGroup('donators') then return math.Round(item.Price * 0.75) end return item.Price end PS.Config.CalculateSellPrice = function(ply, item) return math.Round(item.Price * 0.75) -- 75% or 3/4 (rounded) of the original item price end
mit
ithoq/afrimesh
villagebus/lua/urlcode.lua
5
3561
-- http://keplerproject.github.com/cgilua/index.html#download ---------------------------------------------------------------------------- -- Utility functions for encoding/decoding of URLs. -- -- @release $Id: urlcode.lua,v 1.10 2008/01/21 16:11:32 carregal Exp $ ---------------------------------------------------------------------------- local ipairs, next, pairs, tonumber, type = ipairs, next, pairs, tonumber, type local string = string local table = table --module ("cgilua.urlcode") module ("urlcode") ---------------------------------------------------------------------------- -- Decode an URL-encoded string (see RFC 2396) ---------------------------------------------------------------------------- function unescape (str) str = string.gsub (str, "+", " ") str = string.gsub (str, "%%(%x%x)", function(h) return string.char(tonumber(h,16)) end) str = string.gsub (str, "\r\n", "\n") return str end ---------------------------------------------------------------------------- -- URL-encode a string (see RFC 2396) ---------------------------------------------------------------------------- function escape (str) str = string.gsub (str, "\n", "\r\n") str = string.gsub (str, "([^0-9a-zA-Z ])", -- locale independent function (c) return string.format ("%%%02X", string.byte(c)) end) str = string.gsub (str, " ", "+") return str end ---------------------------------------------------------------------------- -- Insert a (name=value) pair into table [[args]] -- @param args Table to receive the result. -- @param name Key for the table. -- @param value Value for the key. -- Multi-valued names will be represented as tables with numerical indexes -- (in the order they came). ---------------------------------------------------------------------------- function insertfield (args, name, value) if not args[name] then args[name] = value else local t = type (args[name]) if t == "string" then args[name] = { args[name], value, } elseif t == "table" then table.insert (args[name], value) else error ("CGILua fatal error (invalid args table)!") end end end ---------------------------------------------------------------------------- -- Parse url-encoded request data -- (the query part of the script URL or url-encoded post data) -- -- Each decoded (name=value) pair is inserted into table [[args]] -- @param query String to be parsed. -- @param args Table where to store the pairs. ---------------------------------------------------------------------------- function parsequery (query, args) if type(query) == "string" then local insertfield, unescape = insertfield, unescape string.gsub (query, "([^&=]+)=([^&=]*)&?", function (key, val) insertfield (args, unescape(key), unescape(val)) end) end end ---------------------------------------------------------------------------- -- URL-encode the elements of a table creating a string to be used in a -- URL for passing data/parameters to another script -- @param args Table where to extract the pairs (name=value). -- @return String with the resulting encoding. ---------------------------------------------------------------------------- function encodetable (args) if args == nil or next(args) == nil then -- no args or empty args? return "" end local strp = "" for key, vals in pairs(args) do if type(vals) ~= "table" then vals = {vals} end for i,val in ipairs(vals) do strp = strp.."&"..escape(key).."="..escape(val) end end -- remove first & return string.sub(strp,2) end
bsd-3-clause
Elv2/imageGeneration
generate.lua
1
1948
require 'mobdebug'.start() require 'nn' require 'inn' --require 'cudnn' require 'nngraph' require 'optim' require 'image' require 'loadcaffe' require 'cifar.torch/provider' local c = require 'trepl.colorize' nngraph.setDebug(true) -- setting opt = lapp[[ --model (default "logs/debug/model.net") Model used to generate image -s,--save (default "/test/") Relative subdirectory to save images ]] -- save directory gen_folder = paths.dirname(opt.model) .. opt.save .. 'generate/' gt_folder = paths.dirname(opt.model) .. opt.save .. 'gt/' paths.mkdir(gen_folder) paths.mkdir(gt_folder) -- load torch training model model = torch.load(opt.model) -- data datafile = '/home/tt3/DATA/caoqingxing/text2image/cifar.torch/providerMeanStdNorm.t7' provider = torch.load(datafile) provider.testData.data = provider.testData.data:cuda() -- test -- disable flips, dropouts and batch normalization model:evaluate() print(c.blue '==>'.." testing") local bs = 125 test_loss = 0; for i=1,100 do if i > provider.testData.data:size(1) then break end xlua.progress(i,100) x_predictions, loss_xs = unpack(model:forward(provider.testData.data:narrow(1,i,1))) test_loss = test_loss + torch.sum(loss_xs:double()) im = x_predictions im_gt = provider.testData.data[i]:clone() for channel=1,3 do -- over each image channel im[{ {channel}, {}, {} }]:mul(provider.trainData.std[channel]) -- std scaling im[{ {channel}, {}, {} }]:add(provider.trainData.mean[channel]) -- mean subtraction im_gt[{ {channel}, {}, {} }]:mul(provider.trainData.std[channel]) -- std scaling im_gt[{ {channel}, {}, {} }]:add(provider.trainData.mean[channel]) -- mean subtraction end image.save(gen_folder .. tostring(i) .. '.jpg', im:div(255)) image.save(gt_folder .. tostring(i) .. '.jpg', im_gt:div(255)) end test_loss = test_loss / provider.testData.data:size(1) print('Test accuracy:', test_loss)
mit
kitala1/darkstar
scripts/zones/AlTaieu/npcs/qm3.lua
8
1610
----------------------------------- -- Area: Al'Taieu -- NPC: ??? (Jailer of Prudence Spawn) -- Allows players to spawn the Jailer of Prudence by trading the Third Virtue, Deed of Sensibility, and High-Quality Hpemde Organ to a ???. -- @pos , 706 -1 22 ----------------------------------- package.loaded["scripts/zones/AlTaieu/TextIDs"] = nil; ----------------------------------- require("scripts/zones/AlTaieu/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- Trade the Third Virtue, Deed of Sensibility, and High-Quality Hpemde Organ --[[if(GetMobAction(16912846) == 0 and GetMobAction(16912847) == 0 and trade:hasItemQty(1856,1) and trade:hasItemQty(1870,1) and trade:hasItemQty(1871,1) and trade:getItemCount() == 3) then player:tradeComplete(); SpawnMob(16912846,900):updateClaim(player);-- Spawn Jailer of Prudence 1 SpawnMob(16912847,900):updateClaim(player);-- Spawn Jailer of Prudence 2 end]] end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("onUpdate CSID: %u",csid); --printf("onUpdate RESULT: %u",option); end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) --printf("onFinish CSID: %u",csid); --printf("onFinish RESULT: %u",option); end;
gpl-3.0
chucksellick/factorio-portal-research
src/modules/scanners.lua
1
3677
local Scanners = {} function Scanners.setupWorkerEntity(scanner) -- The only scanner that needs a worker entity currently is the orbital space telescope -- TODO: Setting the force makes debug easier otherwise we can't access the GUI. The consequence is this will show up under production. -- Need to decide what is wanted. scanner.entity = Sites.addHiddenWorkerEntity(scanner, { name = "space-telescope-worker", force = scanner.force }) end function Scanners.destroyWorkerEntity(scanner) Sites.removeHiddenWorkerEntity(scanner) end local scanner_types = {} scanner_types["observatory"] = { max_size = 3, base_distance = 1, scan_chance = 0.01 } scanner_types["space-telescope-worker"] = { max_size = 5, base_distance = 10, scan_chance = 0.05 } -- TODO: Fix UPS -- TODO: For orbital scanners, stop scanning (deactive entity) whilst in transit function Scanners.scan(event) for i,scanner in pairs(global.scanners) do local result = scanner.entity.get_inventory(defines.inventory.assembling_machine_output) if result[1].valid_for_read and result[1].count > 0 then local scan_spec = scanner_types[scanner.entity.name] for n = 1, result[1].count do -- TODO: Can improve with research etc if math.random() < scan_spec.scan_chance then -- TODO: Set more parameters of site local newSite = Sites.generateRandom(scanner.entity.force, scanner, scan_spec) scanner.entity.force.print({"site-discovered", {"entity-name."..scanner.entity.name}, newSite.name}) -- TODO: Show site details only if no window open -- TODO: Use a notifications queue for events like this -- TODO: Show "last find" in orbital + observatory details --for i,player in pairs(scanner.entity.force.connected_players) do -- Gui.showSiteDetails(player, newSite) --end else -- TODO: Some chance for other finds eventually. e.g. incoming solar storms / meteorites, -- mysterious objects from ancient civilisations, space debris, pods (send probes to intercept) -- TODO: This message will get really annoying with a whole bunch of scanners. Instead, the first time -- this happens, display a tutorial message saying "Your scanner found nothing this time, keep trying yada yada" (once for each player) --scanner.entity.force.print({"scan-found-nothing", {"entity-name."..scanner.entity.name}}) end end result[1].clear() end end -- TODO: Could additionally require inserting the "scan result" into some kind of navigational computer ("Space Command Mainframe?"). Might seem like busywork. Space telescopes -- would download their results to some kind of printer? Requires some medium to store the result? (circuits) ... not sure about this. But could -- be cool to require *some* sort of ground-based structures that actually coordinate and track all the orbital activity and even portals, and requiring more computers the -- more stuff you have in the air. Mainframes should have a neighbour bonus like nuke plants due to parallel processing, and require use of heat pipes and coolant to keep within -- operational temperature. Going too hot e.g. 200C causes a shutdown and a long reboot process only once temperature comes back under 100C. -- Mainframes could also interact with observatories to track things better, and/or make orbitals generally work quicker, avoid damage, etc etc. -- (Note: mainframe buildable without space science, need them around from the start ... even before the first satellite ... should also make satellites do things! (Map reveal?)) end return Scanners
mit
Roblox/Core-Scripts
CoreScriptsRoot/CoreScripts/NotificationScript2.lua
1
36868
--[[ Filename: NotificationScript2.lua Version 1.1 Written by: jmargh Description: Handles notification gui for the following in game ROBLOX events Badge Awarded Player Points Awarded Friend Request Recieved/New Friend Graphics Quality Changed Teleports CreatePlaceInPlayerInventoryAsync --]] local BadgeService = game:GetService('BadgeService') local GuiService = game:GetService('GuiService') local Players = game:GetService('Players') local PointsService = game:GetService('PointsService') local MarketplaceService = game:GetService('MarketplaceService') local TeleportService = game:GetService('TeleportService') local TextService = game:GetService("TextService") local HttpService = game:GetService("HttpService") local UserInputService = game:GetService("UserInputService") local ContextActionService = game:GetService("ContextActionService") local StarterGui = game:GetService("StarterGui") local CoreGui = game:GetService("CoreGui") local AnalyticsService = game:GetService("AnalyticsService") local VRService = game:GetService("VRService") local RobloxGui = CoreGui:WaitForChild("RobloxGui") local Settings = UserSettings() local GameSettings = Settings.GameSettings local success, result = pcall(function() return settings():GetFFlag('UseNotificationsLocalization') end) local FFlagUseNotificationsLocalization = success and result local FFlagCoreScriptsUseLocalizationModule = settings():GetFFlag('CoreScriptsUseLocalizationModule') local FFlagNotificationScript2UseFormatByKey = settings():GetFFlag('NotificationScript2UseFormatByKey') local RobloxTranslator if FFlagCoreScriptsUseLocalizationModule then RobloxTranslator = require(RobloxGui:WaitForChild("Modules"):WaitForChild("RobloxTranslator")) end local function LocalizedGetString(key, rtv) pcall(function() if FFlagCoreScriptsUseLocalizationModule then rtv = RobloxTranslator:FormatByKey(key) else local LocalizationService = game:GetService("LocalizationService") local CorescriptLocalization = LocalizationService:GetCorescriptLocalizations()[1] rtv = CorescriptLocalization:GetString(LocalizationService.RobloxLocaleId, key) end end) return rtv end local LocalPlayer = nil while not Players.LocalPlayer do wait() end LocalPlayer = Players.LocalPlayer local RbxGui = script.Parent local NotificationQueue = {} local OverflowQueue = {} local FriendRequestBlacklist = {} local BadgeBlacklist = {} local CurrentGraphicsQualityLevel = GameSettings.SavedQualityLevel.Value local BindableEvent_SendNotificationInfo = Instance.new('BindableEvent') BindableEvent_SendNotificationInfo.Name = "SendNotificationInfo" BindableEvent_SendNotificationInfo.Parent = RobloxGui local isPaused = false RobloxGui:WaitForChild("Modules"):WaitForChild("TenFootInterface") local isTenFootInterface = require(RobloxGui.Modules.TenFootInterface):IsEnabled() local pointsNotificationsActive = true local badgesNotificationsActive = true local SocialUtil = require(RobloxGui.Modules:WaitForChild("SocialUtil")) local GameTranslator = require(RobloxGui.Modules.GameTranslator) local BG_TRANSPARENCY = 0.7 local MAX_NOTIFICATIONS = 3 local NOTIFICATION_Y_OFFSET = isTenFootInterface and 145 or 64 local NOTIFICATION_TITLE_Y_OFFSET = isTenFootInterface and 40 or 12 local NOTIFICATION_TEXT_Y_OFFSET = isTenFootInterface and -16 or 1 local NOTIFICATION_FRAME_WIDTH = isTenFootInterface and 450 or 200 local NOTIFICATION_TEXT_HEIGHT = isTenFootInterface and 85 or 28 local NOTIFICATION_TEXT_HEIGHT_MAX = isTenFootInterface and 170 or 56 local NOTIFICATION_TITLE_FONT_SIZE = isTenFootInterface and Enum.FontSize.Size42 or Enum.FontSize.Size18 local NOTIFICATION_TEXT_FONT_SIZE = isTenFootInterface and Enum.FontSize.Size36 or Enum.FontSize.Size14 local IMAGE_SIZE = isTenFootInterface and 72 or 48 local EASE_DIR = Enum.EasingDirection.InOut local EASE_STYLE = Enum.EasingStyle.Sine local TWEEN_TIME = 0.35 local DEFAULT_NOTIFICATION_DURATION = 5 local MAX_GET_FRIEND_IMAGE_YIELD_TIME = 5 local FRIEND_REQUEST_NOTIFICATION_THROTTLE = 5 local friendRequestNotificationFIntSuccess, friendRequestNotificationFIntValue = pcall(function() return tonumber(settings():GetFVariable("FriendRequestNotificationThrottle")) end) if friendRequestNotificationFIntSuccess and friendRequestNotificationFIntValue ~= nil then FRIEND_REQUEST_NOTIFICATION_THROTTLE = friendRequestNotificationFIntValue end local FFlagCoreScriptTranslateGameText2 = settings():GetFFlag("CoreScriptTranslateGameText2") local PLAYER_POINTS_IMG = 'https://www.roblox.com/asset?id=206410433' local BADGE_IMG = 'https://www.roblox.com/asset?id=206410289' local FRIEND_IMAGE = 'https://www.roblox.com/thumbs/avatar.ashx?userId=' local function createFrame(name, size, position, bgt) local frame = Instance.new('Frame') frame.Name = name frame.Size = size frame.Position = position frame.BackgroundTransparency = bgt return frame end --remove along with FFlagCoreScriptTranslateGameText2 local function createTextButtonOld(name, text, position) local button = Instance.new('TextButton') button.Name = name button.Size = UDim2.new(0.5, -2, 0.5, 0) button.Position = position button.BackgroundTransparency = BG_TRANSPARENCY button.BackgroundColor3 = Color3.new(0, 0, 0) button.Font = Enum.Font.SourceSansBold button.FontSize = Enum.FontSize.Size18 button.TextColor3 = Color3.new(1, 1, 1) button.Text = text return button end local function createTextButton(name, position) local button = Instance.new('TextButton') button.Name = name button.Size = UDim2.new(0.5, -2, 0.5, 0) button.Position = position button.BackgroundTransparency = BG_TRANSPARENCY button.BackgroundColor3 = Color3.new(0, 0, 0) button.Font = Enum.Font.SourceSansBold button.FontSize = Enum.FontSize.Size18 button.TextColor3 = Color3.new(1, 1, 1) return button end local NotificationFrame = createFrame("NotificationFrame", UDim2.new(0, NOTIFICATION_FRAME_WIDTH, 0.42, 0), UDim2.new(1, -NOTIFICATION_FRAME_WIDTH-4, 0.50, 0), 1.0) NotificationFrame.Parent = RbxGui local DefaultNotification = createFrame("Notification", UDim2.new(1, 0, 0, NOTIFICATION_Y_OFFSET), UDim2.new(0, 0, 0, 0), BG_TRANSPARENCY) DefaultNotification.BackgroundColor3 = Color3.new(0, 0, 0) DefaultNotification.BorderSizePixel = 0 local NotificationTitle = Instance.new('TextLabel') NotificationTitle.Name = "NotificationTitle" NotificationTitle.Size = UDim2.new(0, 0, 0, 0) NotificationTitle.Position = UDim2.new(0.5, 0, 0.5, -12) NotificationTitle.BackgroundTransparency = 1 NotificationTitle.Font = Enum.Font.SourceSansBold NotificationTitle.FontSize = NOTIFICATION_TITLE_FONT_SIZE NotificationTitle.TextColor3 = Color3.new(0.97, 0.97, 0.97) local NotificationText = Instance.new('TextLabel') NotificationText.Name = "NotificationText" NotificationText.Size = UDim2.new(1, -20, 0, 28) NotificationText.Position = UDim2.new(0, 10, 0.5, 1) NotificationText.BackgroundTransparency = 1 NotificationText.Font = Enum.Font.SourceSans NotificationText.FontSize = NOTIFICATION_TEXT_FONT_SIZE NotificationText.TextColor3 = Color3.new(0.92, 0.92, 0.92) NotificationText.TextWrap = true NotificationText.TextYAlignment = Enum.TextYAlignment.Top local NotificationImage = Instance.new('ImageLabel') NotificationImage.Name = "NotificationImage" NotificationImage.Size = UDim2.new(0, IMAGE_SIZE, 0, IMAGE_SIZE) NotificationImage.Position = UDim2.new(0, (1.0/6.0) * IMAGE_SIZE, 0, 0.5 * (NOTIFICATION_Y_OFFSET - IMAGE_SIZE)) NotificationImage.BackgroundTransparency = 1 NotificationImage.Image = "" -- Would really like to get rid of this but some events still require this local PopupFrame = createFrame("PopupFrame", UDim2.new(0, 360, 0, 160), UDim2.new(0.5, -180, 0.5, -50), 0) PopupFrame.Style = Enum.FrameStyle.DropShadow PopupFrame.ZIndex = 4 PopupFrame.Visible = false PopupFrame.Parent = RbxGui local PopupAcceptButton = Instance.new('TextButton') PopupAcceptButton.Name = "PopupAcceptButton" PopupAcceptButton.Size = UDim2.new(0, 100, 0, 50) PopupAcceptButton.Position = UDim2.new(0.5, -102, 1, -58) PopupAcceptButton.Style = Enum.ButtonStyle.RobloxRoundButton PopupAcceptButton.Font = Enum.Font.SourceSansBold PopupAcceptButton.FontSize = Enum.FontSize.Size24 PopupAcceptButton.TextColor3 = Color3.new(1, 1, 1) PopupAcceptButton.Text = "Accept" PopupAcceptButton.ZIndex = 5 PopupAcceptButton.Parent = PopupFrame local PopupDeclineButton = PopupAcceptButton:Clone() PopupDeclineButton.Name = "PopupDeclineButton" PopupDeclineButton.Position = UDim2.new(0.5, 2, 1, -58) PopupDeclineButton.Text = "Decline" PopupDeclineButton.Parent = PopupFrame local PopupOKButton = PopupAcceptButton:Clone() PopupOKButton.Name = "PopupOKButton" PopupOKButton.Position = UDim2.new(0.5, -50, 1, -58) PopupOKButton.Text = "OK" PopupOKButton.Visible = false PopupOKButton.Parent = PopupFrame local PopupText = Instance.new('TextLabel') PopupText.Name = "PopupText" PopupText.Size = UDim2.new(1, -16, 0.8, 0) PopupText.Position = UDim2.new(0, 8, 0, 8) PopupText.BackgroundTransparency = 1 PopupText.Font = Enum.Font.SourceSansBold PopupText.FontSize = Enum.FontSize.Size36 PopupText.TextColor3 = Color3.new(0.97, 0.97, 0.97) PopupText.TextWrap = true PopupText.ZIndex = 5 PopupText.TextYAlignment = Enum.TextYAlignment.Top PopupText.Text = "This is a popup" PopupText.Parent = PopupFrame local insertNotification local removeNotification local function getFriendImage(playerId) -- SocialUtil.GetPlayerImage can yield for up to MAX_GET_FRIEND_IMAGE_YIELD_TIME seconds while waiting for thumbnail to be final. -- It will just return an invalid thumbnail if a valid one can not be generated in time. return SocialUtil.GetPlayerImage(playerId, Enum.ThumbnailSize.Size48x48, Enum.ThumbnailType.HeadShot, --[[timeOut = ]] MAX_GET_FRIEND_IMAGE_YIELD_TIME) end local function createNotification(title, text, image) local notificationFrame = DefaultNotification:Clone() notificationFrame.Position = UDim2.new(1, 4, 1, -NOTIFICATION_Y_OFFSET - 4) local notificationTitle = NotificationTitle:Clone() notificationTitle.Text = title notificationTitle.Parent = notificationFrame local notificationText = NotificationText:Clone() notificationText.Text = text notificationText.Parent = notificationFrame if (image == nil or image == "") then notificationFrame.Parent = NotificationFrame if not notificationText.TextFits then local textSize = TextService:GetTextSize(notificationText.Text, notificationText.TextSize, notificationText.Font, Vector2.new(notificationText.AbsoluteSize.X, 1000)) local addHeight = math.min(textSize.Y - notificationText.Size.Y.Offset, NOTIFICATION_TEXT_HEIGHT_MAX - notificationText.Size.Y.Offset) notificationTitle.Position = notificationTitle.Position - UDim2.new(0, 0, 0, addHeight/2) notificationText.Position = notificationText.Position - UDim2.new(0, 0, 0, addHeight/2) notificationFrame.Size = notificationFrame.Size + UDim2.new(0, 0, 0, addHeight) notificationText.Size = notificationText.Size + UDim2.new(0, 0, 0, addHeight) end notificationFrame.Parent = nil end if image and image ~= "" then local notificationImage = NotificationImage:Clone() notificationImage.Image = image notificationImage.Parent = notificationFrame notificationTitle.Position = UDim2.new(0, (4.0/3.0) * IMAGE_SIZE, 0.5, -NOTIFICATION_TITLE_Y_OFFSET) notificationTitle.TextXAlignment = Enum.TextXAlignment.Left notificationFrame.Parent = NotificationFrame notificationText.Size = UDim2.new(1, -IMAGE_SIZE - 16, 0, NOTIFICATION_TEXT_HEIGHT) notificationText.Position = UDim2.new(0, (4.0/3.0) * IMAGE_SIZE, 0.5, NOTIFICATION_TEXT_Y_OFFSET) notificationText.TextXAlignment = Enum.TextXAlignment.Left if not notificationText.TextFits then local extraText = nil local text = notificationText.Text for i = string.len(text) - 1, 2, -1 do if string.sub(text, i, i) == " " then notificationText.Text = string.sub(text, 1, i - 1) if notificationText.TextFits then extraText = string.sub(text, i + 1) break end end end if extraText then local notificationText2 = NotificationText:Clone() notificationText2.TextXAlignment = Enum.TextXAlignment.Left notificationText2.Text = extraText notificationText2.Name = "ExtraText" notificationText2.Parent = notificationFrame local textSize = TextService:GetTextSize(extraText, notificationText2.TextSize, notificationText2.Font, Vector2.new(notificationText2.AbsoluteSize.X, 1000)) local addHeight = math.min(textSize.Y, NOTIFICATION_TEXT_HEIGHT_MAX - notificationText.Size.Y.Offset) notificationTitle.Position = notificationTitle.Position - UDim2.new(0, 0, 0, addHeight/2) notificationText.Position = notificationText.Position - UDim2.new(0, 0, 0, addHeight/2) notificationFrame.Size = notificationFrame.Size + UDim2.new(0, 0, 0, addHeight) notificationText2.Size = UDim2.new(notificationText2.Size.X.Scale, notificationText2.Size.X.Offset, 0, addHeight) notificationText2.AnchorPoint = Vector2.new(0.5, 0) notificationText2.Position = UDim2.new(0.5, 0, notificationText.Position.Y.Scale, notificationText.Position.Y.Offset + notificationText.AbsoluteSize.Y) else notificationText.Text = text end end notificationFrame.Parent = nil end GuiService:AddSelectionParent(HttpService:GenerateGUID(false), notificationFrame) return notificationFrame end local function findNotification(notification) local index = nil for i = 1, #NotificationQueue do if NotificationQueue[i] == notification then return i end end end local function updateNotifications() local pos = 1 local yOffset = 0 for i = #NotificationQueue, 1, -1 do local currentNotification = NotificationQueue[i] if currentNotification then local frame = currentNotification.Frame if frame and frame.Parent then local thisOffset = currentNotification.IsFriend and (NOTIFICATION_Y_OFFSET + 2) * 1.5 or NOTIFICATION_Y_OFFSET thisOffset = currentNotification.IsFriend and frame.Size.Y.Offset + ((NOTIFICATION_Y_OFFSET + 2) * 0.5) or frame.Size.Y.Offset yOffset = yOffset + thisOffset frame:TweenPosition(UDim2.new(0, 0, 1, -yOffset - (pos * 4)), EASE_DIR, EASE_STYLE, TWEEN_TIME, true, function() if currentNotification.TweenOutCallback then currentNotification.TweenOutCallback() end end) pos = pos + 1 end end end end local lastTimeInserted = 0 insertNotification = function(notification) spawn(function() while isPaused do wait() end notification.IsActive = true local size = #NotificationQueue if size == MAX_NOTIFICATIONS then NotificationQueue[1].Duration = 0 OverflowQueue[#OverflowQueue + 1] = notification return end NotificationQueue[size + 1] = notification notification.Frame.Parent = NotificationFrame spawn(function() wait(TWEEN_TIME * 2) -- Wait for it to tween in, and then wait that same amount of time before calculating lifetime. -- This is to have it not zoom out while half tweened in when the OverflowQueue forcibly -- makes room for itself. while(notification.Duration > 0) do wait(0.2) notification.Duration = notification.Duration - 0.2 end removeNotification(notification) end) while tick() - lastTimeInserted < TWEEN_TIME do wait() end lastTimeInserted = tick() updateNotifications() end) end removeNotification = function(notification) if not notification then return end -- local index = findNotification(notification) table.remove(NotificationQueue, index) local frame = notification.Frame if frame and frame.Parent then notification.IsActive = false spawn(function() while isPaused do wait() end -- Tween out now, or set up to tween out immediately after current tween is finished, but don't interrupt. local function doTweenOut() return frame:TweenPosition(UDim2.new(1, 0, 1, frame.Position.Y.Offset), EASE_DIR, EASE_STYLE, TWEEN_TIME, false, function() frame:Destroy() notification = nil end) end if (not doTweenOut()) then notification.TweenOutCallback = doTweenOut end end) end if #OverflowQueue > 0 then local nextNotification = OverflowQueue[1] table.remove(OverflowQueue, 1) insertNotification(nextNotification) if (#OverflowQueue > 0 and NotificationQueue[1]) then NotificationQueue[1].Duration = 0 end else updateNotifications() end end local function sendNotificationInfo(notificationInfo) notificationInfo.Duration = notificationInfo.Duration or DEFAULT_NOTIFICATION_DURATION BindableEvent_SendNotificationInfo:Fire(notificationInfo) end local function onSendNotificationInfo(notificationInfo) if VRService.VREnabled then --If VR is enabled, notifications will be handled by Modules.VR.NotificationHub return end local callback = notificationInfo.Callback local button1Text = notificationInfo.Button1Text local button2Text = notificationInfo.Button2Text local localizedButton1Text = notificationInfo.Button1TextLocalized --remove along with FFlagCoreScriptTranslateGameText2 local localizedButton2Text = notificationInfo.Button2TextLocalized --remove along with FFlagCoreScriptTranslateGameText2 local notification = {} local notificationFrame if FFlagCoreScriptTranslateGameText2 then notificationFrame = createNotification( GameTranslator:TranslateGameText(CoreGui, notificationInfo.Title), GameTranslator:TranslateGameText(CoreGui, notificationInfo.Text), notificationInfo.Image) else notificationFrame = createNotification(notificationInfo.Title, notificationInfo.Text, notificationInfo.Image) end local button1 if button1Text and button1Text ~= "" then notification.IsFriend = true -- Prevents other notifications overlapping the buttons if FFlagCoreScriptTranslateGameText2 then button1 = createTextButton("Button1", UDim2.new(0, 0, 1, 2)) if notificationInfo.AutoLocalize then GameTranslator:TranslateAndRegister(button1, CoreGui, button1Text) else button1.Text = button1Text end else button1 = createTextButtonOld("Button1", localizedButton1Text or button1Text, UDim2.new(0, 0, 1, 2)) end button1.Parent = notificationFrame local button1ClickedConnection = nil button1ClickedConnection = button1.MouseButton1Click:connect(function() if button1ClickedConnection then button1ClickedConnection:disconnect() button1ClickedConnection = nil removeNotification(notification) if callback and type(callback) ~= "function" then -- callback should be a bindable pcall(function() callback:Invoke(button1Text) end) elseif type(callback) == "function" then callback(button1Text) end end end) end local button2 if button2Text and button2Text ~= "" then notification.IsFriend = true if FFlagCoreScriptTranslateGameText2 then button2 = createTextButton("Button2", UDim2.new(0.5, 2, 1, 2)) if notificationInfo.AutoLocalize then GameTranslator:TranslateAndRegister(button2, CoreGui, button2Text) else button2.Text = button2Text end else button2 = createTextButtonOld("Button1", localizedButton2Text or button2Text, UDim2.new(0.5, 2, 1, 2)) end button2.Parent = notificationFrame local button2ClickedConnection = nil button2ClickedConnection = button2.MouseButton1Click:connect(function() if button2ClickedConnection then button2ClickedConnection:disconnect() button2ClickedConnection = nil removeNotification(notification) if callback and type(callback) ~= "function" then -- callback should be a bindable pcall(function() callback:Invoke(button2Text) end) elseif type(callback) == "function" then callback(notificationInfo.Button2Text) end end end) else -- Resize button1 to take up all the space under the notification if button2 doesn't exist if button1 then button1.Size = UDim2.new(1, -2, .5, 0) end end notification.Frame = notificationFrame notification.Duration = notificationInfo.Duration insertNotification(notification) end BindableEvent_SendNotificationInfo.Event:connect(onSendNotificationInfo) -- New follower notification spawn(function() if isTenFootInterface then --If on console, New follower notification should be blocked return end local RobloxReplicatedStorage = game:GetService('RobloxReplicatedStorage') local RemoteEvent_NewFollower = RobloxReplicatedStorage:WaitForChild('NewFollower', 86400) or RobloxReplicatedStorage:WaitForChild('NewFollower') RemoteEvent_NewFollower.OnClientEvent:connect(function(followerRbxPlayer) local message = ("%s is now following you"):format(followerRbxPlayer.Name) if FFlagNotificationScript2UseFormatByKey then message = RobloxTranslator:FormatByKey("NotificationScript2.NewFollower", {RBX_NAME = followerRbxPlayer.Name}) else if FFlagUseNotificationsLocalization then message = string.gsub(LocalizedGetString("NotificationScript2.NewFollower",message),"{RBX_NAME}",followerRbxPlayer.Name) end end local image = getFriendImage(followerRbxPlayer.UserId) sendNotificationInfo { GroupName = "Friends", Title = "New Follower", Text = message, DetailText = message, Image = image, Duration = 5 } end) end) local checkFriendRequestIsThrottled; do local friendRequestThrottlingMap = {} checkFriendRequestIsThrottled = function(fromPlayer) local throttleFinishedTime = friendRequestThrottlingMap[fromPlayer] if throttleFinishedTime then if tick() < throttleFinishedTime then return true end end friendRequestThrottlingMap[fromPlayer] = tick() + FRIEND_REQUEST_NOTIFICATION_THROTTLE return false end end local function sendFriendNotification(fromPlayer) if checkFriendRequestIsThrottled(fromPlayer) then return end local acceptText = "Accept" local declineText = "Decline" sendNotificationInfo { GroupName = "Friends", Title = fromPlayer.Name, Text = "Sent you a friend request!", DetailText = fromPlayer.Name, Image = getFriendImage(fromPlayer.UserId), Duration = 8, Callback = function(buttonChosen) if buttonChosen == acceptText then AnalyticsService:ReportCounter("NotificationScript-RequestFriendship") AnalyticsService:TrackEvent("Game", "RequestFriendship", "NotificationScript") LocalPlayer:RequestFriendship(fromPlayer) else AnalyticsService:ReportCounter("NotificationScript-RevokeFriendship") AnalyticsService:TrackEvent("Game", "RevokeFriendship", "NotificationScript") LocalPlayer:RevokeFriendship(fromPlayer) FriendRequestBlacklist[fromPlayer] = true end end, Button1Text = acceptText, Button2Text = declineText } end local function onFriendRequestEvent(fromPlayer, toPlayer, event) if fromPlayer ~= LocalPlayer and toPlayer ~= LocalPlayer then return end -- if fromPlayer == LocalPlayer then if event == Enum.FriendRequestEvent.Accept then local detailText = "You are now friends with " .. toPlayer.Name .. "!" if FFlagNotificationScript2UseFormatByKey then detailText = RobloxTranslator:FormatByKey( "NotificationScript2.FriendRequestEvent.Accept", {RBX_NAME = toPlayer.Name}) else if FFlagUseNotificationsLocalization then detailText = string.gsub(LocalizedGetString("NotificationScript2.FriendRequestEvent.Accept",detailText), "{RBX_NAME}", toPlayer.Name) end end sendNotificationInfo { GroupName = "Friends", Title = "New Friend", Text = toPlayer.Name, DetailText = detailText, Image = getFriendImage(toPlayer.UserId), Duration = DEFAULT_NOTIFICATION_DURATION } end elseif toPlayer == LocalPlayer then if event == Enum.FriendRequestEvent.Issue then if FriendRequestBlacklist[fromPlayer] then return end sendFriendNotification(fromPlayer) elseif event == Enum.FriendRequestEvent.Accept then local detailText = "You are now friends with " .. fromPlayer.Name .. "!" if FFlagNotificationScript2UseFormatByKey then detailText = RobloxTranslator:FormatByKey("NotificationScript2.FriendRequestEvent.Accept", {RBX_NAME = fromPlayer.Name}) sendNotificationInfo { GroupName = "Friends", Title = "New Friend", Text = fromPlayer.Name, DetailText = detailText, Image = getFriendImage(fromPlayer.UserId), Duration = DEFAULT_NOTIFICATION_DURATION } else if FFlagUseNotificationsLocalization then detailText = string.gsub(LocalizedGetString("NotificationScript2.FriendRequestEvent.Accept",detailText), "{RBX_NAME}", fromPlayer.Name) end sendNotificationInfo { GroupName = "Friends", Title = "New Friend", Text = fromPlayer.Name, DetailText = "You are now friends with " .. fromPlayer.Name .. "!", Image = getFriendImage(fromPlayer.UserId), Duration = DEFAULT_NOTIFICATION_DURATION } end end end end local function onPointsAwarded(userId, pointsAwarded, userBalanceInGame, userTotalBalance) if pointsNotificationsActive and userId == LocalPlayer.UserId then local title, text, detailText if pointsAwarded == 1 then title = "Point Awarded" text = "You received 1 point!" if FFlagNotificationScript2UseFormatByKey then text = RobloxTranslator:FormatByKey("NotificationScript2.onPointsAwarded.single", {RBX_NUMBER = tostring(pointsAwarded)}) else if FFlagUseNotificationsLocalization then text = string.gsub(LocalizedGetString("NotificationScript2.onPointsAwarded.single",text),"{RBX_NUMBER}",pointsAwarded) end end elseif pointsAwarded > 0 then title = "Points Awarded" text = ("You received %d points!"):format(pointsAwarded) if FFlagNotificationScript2UseFormatByKey then text = RobloxTranslator:FormatByKey("NotificationScript2.onPointsAwarded.multiple", {RBX_NUMBER = tostring(pointsAwarded)}) else if FFlagUseNotificationsLocalization then text = string.gsub(LocalizedGetString("NotificationScript2.onPointsAwarded.multiple",text),"{RBX_NUMBER}",pointsAwarded) end end elseif pointsAwarded < 0 then title = "Points Lost" text = ("You lost %d points!"):format(math.abs(pointsAwarded)) if FFlagNotificationScript2UseFormatByKey then text = RobloxTranslator:FormatByKey("NotificationScript2.onPointsAwarded.negative", {RBX_NUMBER = tostring(pointsAwarded)}) else if FFlagUseNotificationsLocalization then text = string.gsub(LocalizedGetString("NotificationScript2.onPointsAwarded.negative",text),"{RBX_NUMBER}",math.abs(pointsAwarded)) end end else --don't notify for 0 points, shouldn't even happen return end detailText = text sendNotificationInfo { GroupName = "PlayerPoints", Title = title, Text = text, DetailText = detailText, Image = PLAYER_POINTS_IMG, Duration = DEFAULT_NOTIFICATION_DURATION } end end local function onBadgeAwarded(message, userId, badgeId) if not BadgeBlacklist[badgeId] and badgesNotificationsActive and userId == LocalPlayer.UserId then BadgeBlacklist[badgeId] = true --SPTODO: Badge notifications are generated on the web and are not (for now) localized. sendNotificationInfo { GroupName = "BadgeAwards", Title = "Badge Awarded", Text = message, DetailText = message, Image = BADGE_IMG, Duration = DEFAULT_NOTIFICATION_DURATION } end end function onGameSettingsChanged(property, amount) if property == "SavedQualityLevel" then local level = GameSettings.SavedQualityLevel.Value + amount if level > 10 then level = 10 elseif level < 1 then level = 1 end -- value of 0 is automatic, we do not want to send a notification in that case if level > 0 and level ~= CurrentGraphicsQualityLevel and GameSettings.SavedQualityLevel ~= Enum.SavedQualitySetting.Automatic then local action = (level > CurrentGraphicsQualityLevel) and "Increased" or "Decreased" local message = ("%s to (%d)"):format(action, level) if FFlagNotificationScript2UseFormatByKey then if level > CurrentGraphicsQualityLevel then message = RobloxTranslator:FormatByKey("NotificationScrip2.onCurrentGraphicsQualityLevelChanged.Increased", {RBX_NUMBER = tostring(level)}) else message = RobloxTranslator:FormatByKey("NotificationScrip2.onCurrentGraphicsQualityLevelChanged.Decreased", {RBX_NUMBER = tostring(level)}) end else if FFlagUseNotificationsLocalization then if level > CurrentGraphicsQualityLevel then message = string.gsub(LocalizedGetString("NotificationScrip2.onCurrentGraphicsQualityLevelChanged.Increased",message),"{RBX_NUMBER}",tostring(level)) else message = string.gsub(LocalizedGetString("NotificationScrip2.onCurrentGraphicsQualityLevelChanged.Decreased",message),"{RBX_NUMBER}",tostring(level)) end end end sendNotificationInfo { GroupName = "Graphics", Title = "Graphics Quality", Text = message, DetailText = message, Image = "", Duration = 2 } CurrentGraphicsQualityLevel = level end end end BadgeService.BadgeAwarded:connect(onBadgeAwarded) if not isTenFootInterface then Players.FriendRequestEvent:connect(onFriendRequestEvent) PointsService.PointsAwarded:connect(onPointsAwarded) --GameSettings.Changed:connect(onGameSettingsChanged) game.GraphicsQualityChangeRequest:connect(function(graphicsIncrease) --graphicsIncrease is a boolean onGameSettingsChanged("SavedQualityLevel", graphicsIncrease == true and 1 or -1) end) end game.ScreenshotReady:Connect(function(path) sendNotificationInfo { Title = "Screenshot Taken", Text = "Check out your screenshots folder to see it.", Duration = 3.0, Button1Text = "Open Folder", Callback = function(text) if text == "Open Folder" then game:OpenScreenshotsFolder() end end } end) settings():GetService("GameSettings").VideoRecordingChangeRequest:Connect(function(value) if not value then sendNotificationInfo { Title = "Video Recorded", Text = "Check out your videos folder to see it.", Duration = 3.0, Button1Text = "Open Folder", Callback = function(text) if text == "Open Folder" then game:OpenVideosFolder() end end } end end) GuiService.SendCoreUiNotification = function(title, text) local notification = createNotification(title, text, "") notification.BackgroundTransparency = .5 notification.Size = UDim2.new(.5, 0, .1, 0) notification.Position = UDim2.new(.25, 0, -0.1, 0) notification.NotificationTitle.FontSize = Enum.FontSize.Size36 notification.NotificationText.FontSize = Enum.FontSize.Size24 notification.Parent = RbxGui notification:TweenPosition(UDim2.new(.25, 0, 0, 0), EASE_DIR, EASE_STYLE, TWEEN_TIME, true) wait(5) if notification then notification:Destroy() end end -- This is used for when a player calls CreatePlaceInPlayerInventoryAsync local function onClientLuaDialogRequested(msg, accept, decline) PopupText.Text = msg -- local acceptCn, declineCn = nil, nil local function disconnectCns() if acceptCn then acceptCn:disconnect() end if declineCn then declineCn:disconnect() end -- GuiService:RemoveCenterDialog(PopupFrame) PopupFrame.Visible = false end acceptCn = PopupAcceptButton.MouseButton1Click:connect(function() disconnectCns() MarketplaceService:SignalServerLuaDialogClosed(true) end) declineCn = PopupDeclineButton.MouseButton1Click:connect(function() disconnectCns() MarketplaceService:SignalServerLuaDialogClosed(false) end) local centerDialogSuccess = pcall( function() GuiService:AddCenterDialog(PopupFrame, Enum.CenterDialogType.QuitDialog, function() PopupOKButton.Visible = false PopupAcceptButton.Visible = true PopupDeclineButton.Visible = true PopupAcceptButton.Text = accept PopupDeclineButton.Text = decline PopupFrame.Visible = true end, function() PopupFrame.Visible = false end) end) if not centerDialogSuccess then PopupFrame.Visible = true PopupAcceptButton.Text = accept PopupDeclineButton.Text = decline end return true end MarketplaceService.ClientLuaDialogRequested:connect(onClientLuaDialogRequested) local function createDeveloperNotification(notificationTable) if type(notificationTable) == "table" then if type(notificationTable.Title) == "string" and type(notificationTable.Text) == "string" then local iconImage = (type(notificationTable.Icon) == "string" and notificationTable.Icon or "") local duration = (type(notificationTable.Duration) == "number" and notificationTable.Duration or DEFAULT_NOTIFICATION_DURATION) local bindable = (typeof(notificationTable.Callback) == "Instance" and notificationTable.Callback:IsA("BindableFunction") and notificationTable.Callback or nil) local button1Text = (type(notificationTable.Button1) == "string" and notificationTable.Button1 or "") local button2Text = (type(notificationTable.Button2) == "string" and notificationTable.Button2 or "") -- AutoLocalize allows developers to disable automatic localization if they have pre-localized it. Defaults true. local autoLocalize = notificationTable.AutoLocalize == nil or notificationTable.AutoLocalize == true local title = notificationTable.Title local text = notificationTable.Text sendNotificationInfo { GroupName = "Developer", Title = title, Text = text, Image = iconImage, Duration = duration, Callback = bindable, Button1Text = button1Text, Button2Text = button2Text, AutoLocalize = autoLocalize, } end end end StarterGui:RegisterSetCore("PointsNotificationsActive", function(value) if type(value) == "boolean" then pointsNotificationsActive = value end end) StarterGui:RegisterSetCore("BadgesNotificationsActive", function(value) if type(value) == "boolean" then badgesNotificationsActive = value end end) StarterGui:RegisterGetCore("PointsNotificationsActive", function() return pointsNotificationsActive end) StarterGui:RegisterGetCore("BadgesNotificationsActive", function() return badgesNotificationsActive end) StarterGui:RegisterSetCore("SendNotification", createDeveloperNotification) if not isTenFootInterface then local gamepadMenu = RobloxGui:WaitForChild("CoreScripts/GamepadMenu") local gamepadNotifications = gamepadMenu:FindFirstChild("GamepadNotifications") while not gamepadNotifications do wait() gamepadNotifications = gamepadMenu:FindFirstChild("GamepadNotifications") end local leaveNotificationFunc = function(name, state, inputObject) if state ~= Enum.UserInputState.Begin then return end if GuiService.SelectedCoreObject:IsDescendantOf(NotificationFrame) then GuiService.SelectedCoreObject = nil end ContextActionService:UnbindCoreAction("LeaveNotificationSelection") end gamepadNotifications.Event:connect(function(isSelected) if not isSelected then return end isPaused = true local notifications = NotificationFrame:GetChildren() for i = 1, #notifications do local noteComponents = notifications[i]:GetChildren() for j = 1, #noteComponents do if noteComponents[j]:IsA("GuiButton") and noteComponents[j].Visible then GuiService.SelectedCoreObject = noteComponents[j] break end end end if GuiService.SelectedCoreObject then ContextActionService:BindCoreAction("LeaveNotificationSelection", leaveNotificationFunc, false, Enum.KeyCode.ButtonB) else isPaused = false local utility = require(RobloxGui.Modules.Settings.Utility) local okPressedFunc = function() end utility:ShowAlert("You have no notifications", "Ok", --[[settingsHub]] nil, okPressedFunc, true) end end) GuiService.Changed:connect(function(prop) if prop == "SelectedCoreObject" then if not GuiService.SelectedCoreObject or not GuiService.SelectedCoreObject:IsDescendantOf(NotificationFrame) then isPaused = false end end end) end local UserInputService = game:GetService('UserInputService') local Platform = UserInputService:GetPlatform() local Modules = RobloxGui:FindFirstChild('Modules') local CSMModule = Modules:FindFirstChild('ControllerStateManager') if Modules and not CSMModule then local ShellModules = Modules:FindFirstChild('Shell') if ShellModules then CSMModule = ShellModules:FindFirstChild('ControllerStateManager') end end if Platform == Enum.Platform.XBoxOne then -- Platform hook for controller connection events -- Displays overlay to user on controller connection lost local PlatformService = nil pcall(function() PlatformService = game:GetService('PlatformService') end) if PlatformService and CSMModule then local controllerStateManager = require(CSMModule) if controllerStateManager then controllerStateManager:Initialize() if not game:IsLoaded() then game.Loaded:wait() end -- retro check in case of controller disconnect while loading -- for now, gamepad1 is always mapped to the active user controllerStateManager:CheckUserConnected() end end end
apache-2.0
theonlywild/erfaaan
plugins/all.lua
46
4833
do data = load_data(_config.moderation.data) local function get_msgs_user_chat(user_id, chat_id) local user_info = {} local uhash = 'user:'..user_id local user = redis:hgetall(uhash) local um_hash = 'msgs:'..user_id..':'..chat_id user_info.msgs = tonumber(redis:get(um_hash) or 0) user_info.name = user_print_name(user)..' ['..user_id..']' return user_info end local function chat_stats(chat_id) local hash = 'chat:'..chat_id..':users' local users = redis:smembers(hash) local users_info = {} for i = 1, #users do local user_id = users[i] local user_info = get_msgs_user_chat(user_id, chat_id) table.insert(users_info, user_info) end table.sort(users_info, function(a, b) if a.msgs and b.msgs then return a.msgs > b.msgs end end) local text = 'آمار گروه:\n' for k,user in pairs(users_info) do text = text..user.name..' = '..user.msgs..'\n' end return text end local function get_group_type(target) local data = load_data(_config.moderation.data) local group_type = data[tostring(target)]['group_type'] if not group_type or group_type == nil then return 'No group type available.' end return group_type end local function show_group_settings(target) local data = load_data(_config.moderation.data) if data[tostring(target)] then if data[tostring(target)]['settings']['flood_msg_max'] then NUM_MSG_MAX = tonumber(data[tostring(target)]['settings']['flood_msg_max']) print('custom'..NUM_MSG_MAX) else NUM_MSG_MAX = 5 end end local settings = data[tostring(target)]['settings'] local text = "Lock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nflood sensitivity : "..NUM_MSG_MAX return text end local function get_description(target) local data = load_data(_config.moderation.data) local data_cat = 'description' if not data[tostring(target)][data_cat] then return 'No description available.' end local about = data[tostring(target)][data_cat] return about end local function get_rules(target) local data = load_data(_config.moderation.data) local data_cat = 'rules' if not data[tostring(target)][data_cat] then return 'No rules available.' end local rules = data[tostring(target)][data_cat] return rules end local function modlist(target) local data = load_data(_config.moderation.data) local groups = 'groups' if not data[tostring(groups)] or not data[tostring(groups)][tostring(target)] then return 'Group is not added or is Realm.' end if next(data[tostring(target)]['moderators']) == nil then return 'No moderator in this group.' end local i = 1 local message = '\nList of moderators :\n' for k,v in pairs(data[tostring(target)]['moderators']) do message = message ..i..' - @'..v..' [' ..k.. '] \n' i = i + 1 end return message end local function get_link(target) local data = load_data(_config.moderation.data) local group_link = data[tostring(target)]['settings']['set_link'] if not group_link or group_link == nil then return "No link" end return "Group link:\n"..group_link end local function all(target, receiver) local text = "همه چیز درباره گروه:\n\n" local group_type = get_group_type(target) text = text.."نوع گروه: \n"..group_type local settings = show_group_settings(target) text = text.."\n\nتنظیمات گروه: \n"..settings local rules = get_rules(target) text = text.."\n\nقوانین گروه: \n"..rules local description = get_description(target) text = text.."\n\nدرباره گروه: \n"..description local modlist = modlist(target) text = text.."\n\nمدیران: \n"..modlist local link = get_link(target) text = text.."\n\nلینک گروه: \n"..link local stats = chat_stats(target) text = text.."\n\n"..stats local ban_list = ban_list(target) text = text.."\n\n"..ban_list local file = io.open("./groups/all/"..target.."all.txt", "w") file:write(text) file:flush() file:close() send_document(receiver,"./groups/all/"..target.."all.txt", ok_cb, false) return end function run(msg, matches) if matches[1] == "مشخصات کامل گروه" and matches[2] and is_owner2(msg.from.id, matches[2]) then local receiver = get_receiver(msg) local target = matches[2] return all(target, receiver) end if not is_owner(msg) then return end if matches[1] == "مشخصات کامل گروه" and not matches[2] then local receiver = get_receiver(msg) if not is_owner(msg) then return end return all(msg.to.id, receiver) end end return { patterns = { "^(مشخصات کامل گروه)$", "^(مشخصات کامل گروه) (%d+)$" }, run = run } end
gpl-2.0
DangerCove/libquvi-scripts
share/lua/website/ard.lua
1
5236
-- libquvi-scripts -- Copyright (C) 2013 Thomas Weißschuh -- -- This file is part of libquvi-scripts <http://quvi.sourceforge.net/>. -- -- This library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public -- License as published by the Free Software Foundation; either -- version 2.1 of the License, or (at your option) any later version. -- -- This library 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 -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this library; if not, write to the Free Software -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -- 02110-1301 USA local Ard = {} function ident(self) local C = require 'quvi/const' local U = require 'quvi/util' local B = require 'quvi/bit' local r = {} r.domain = 'www%.ardmediathek%.de' r.formats = 'default|best' r.categories = B.bit_or(C.proto_http, C.proto_rtmp) r.handles = U.handles(self.page_url, {r.domain}, nil, {"documentId=%d+$"}) return r end function query_formats(self) local config = Ard.get_config(self) local formats = Ard.iter_formats(config) local t = {} for _,v in pairs(formats) do table.insert(t, Ard.to_s(v)) end table.sort(t) self.formats = table.concat(t, "|") return self end function parse(self) local config = Ard.get_config(self) local Util = require 'quvi/util' self.host_id = 'ard' self.title = config:match( '<meta property="og:title" content="([^"]*)' ):gsub( '%s*%- %w-$', '' -- remove name of station ):gsub( '%s*%(FSK.*', '' -- remove FSK nonsense ) or error('no match: media title') self.thumbnail_url = config:match( '<meta property="og:image" content="([^"]*)' ) or '' local formats = Ard.iter_formats(config) local format = Util.choose_format(self, formats, Ard.choose_best, Ard.choose_default, Ard.to_s) or error('unable to choose format') if not format.url then error('no match: media url') end self.url = { format.url } return self end function Ard.test_availability(page) -- some videos are only scrapable at certain times local fsk_pattern = 'Der Clip ist deshalb nur von (%d%d?) bis (%d%d?) Uhr verfügbar' local from, to = page:match(fsk_pattern) if from and to then error('video only available from ' ..from.. ':00 to ' ..to.. ':00 CET') end end function Ard.get_config(self) local c = quvi.fetch(self.page_url) self.id = self.page_url:match('documentId=(%d*)') or error('no match: media id') if c:match('<title>ARD Mediathek %- Fehlerseite</title>') then error('invalid URL, maybe the media is no longer available') end return c end function Ard.choose_best(t) return t[#t] -- return the last from the array end function Ard.choose_default(t) return t[1] -- return the first from the array end function Ard.to_s(t) return string.format("%s_%s_i%02d%s%s", (t.quality) and t.quality or 'sd', t.container, t.stream_id, (t.encoding) and '_'..t.encoding or '', (t.height) and '_'..t.height or '') end function Ard.quality_from(suffix) local q = suffix:match('%.web(%w)%.') or suffix:match('%.(%w)%.') or suffix:match('[=%.]Web%-(%w)') -- .webs. or Web-S or .s if q then q = q:lower() local t = {s='ld', m='md', l='sd', xl='hd'} for k,v in pairs(t) do if q == k then return v end end end return q end function Ard.height_from(suffix) local h = suffix:match('_%d+x(%d+)[_%.]') if h then return h..'p' end end function Ard.container_from(suffix) return suffix:match('^(...):') or suffix:match('%.(...)$') or 'mp4' end function Ard.iter_formats(page) local r = {} local s = 'mediaCollection%.addMediaStream' .. '%(0, (%d+), "(.-)", "(.-)", "%w+"%);' Ard.test_availability(page) for s_id, prefix, suffix in page:gmatch(s) do local u = prefix .. suffix u = u:match('^(.-)?') or u -- remove querystring local t = { container = Ard.container_from(suffix), encoding = suffix:match('%.(h264)%.'), quality = Ard.quality_from(suffix), height = Ard.height_from(suffix), stream_id = s_id, -- internally (by service) used stream ID url = u } table.insert(r,t) end if #r == 0 then error('no media urls found') end return r end -- vim: set ts=4 sw=4 sts=4 tw=72 expandtab:
lgpl-2.1
juhans/ardupilot
Tools/CHDK-Scripts/Cannon S100/3DR_EAI_S100.lua
178
29694
--[[ KAP UAV Exposure Control Script v3.2 -- Released under GPL by waterwingz and wayback/peabody http://chdk.wikia.com/wiki/KAP_%26_UAV_Exposure_Control_Script 3DR EAI 1.0 is a fork of KAP 3.1 with settings specific to Canon cameras triggered off the Pixhawk autopilot. Changelog: -Modified Tv, Av, and ISO settings for the Canon SX260 -Added an option to turn the GPS on and off -Added control of GPS settings in Main Loop -Changed USB OneShot mode to listen for 100ms command pulse from Pixhawk -Adapted for S100 settings @title 3DR EAI 1.0 - Lets Map! @param i Shot Interval (sec) @default i 2 @range i 2 120 @param s Total Shots (0=infinite) @default s 0 @range s 0 10000 @param j Power off when done? @default j 0 @range j 0 1 @param e Exposure Comp (stops) @default e 6 @values e -2.0 -1.66 -1.33 -1.0 -0.66 -0.33 0.0 0.33 0.66 1.00 1.33 1.66 2.00 @param d Start Delay Time (sec) @default d 0 @range d 0 10000 @param y Tv Min (sec) @default y 5 @values y None 1/60 1/100 1/200 1/400 1/640 @param t Target Tv (sec) @default t 7 @values t 1/100 1/200 1/400 1/640 1/800 1/1000 1/1250 1/1600 1/2000 @param x Tv Max (sec) @default x 4 @values x 1/1000 1/1250 1/1600 1/2000 1/3200 1/5000 1/10000 @param f Av Low(f-stop) @default f 1 @values f 1.8 2.0 2.2 2.6 2.8 3.2 3.5 4.0 4.5 5.0 5.6 6.3 7.1 8.0 @param a Av Target (f-stop) @default a 2 @values a 1.8 2.0 2.2 2.6 2.8 3.2 3.5 4.0 4.5 5.0 5.6 6.3 7.1 8.0 @param m Av Max (f-stop) @default m 13 @values m 1.8 2.0 2.2 2.6 2.8 3.2 3.5 4.0 4.5 5.0 5.6 6.3 7.1 8.0 @param p ISO Min @default p 0 @values p 80 100 200 400 800 1250 1600 @param q ISO Max1 @default q 1 @values q 100 200 400 800 1250 1600 @param r ISO Max2 @default r 3 @values r 100 200 400 800 1250 1600 @param n Allow use of ND filter? @default n 0 @values n No Yes @param z Zoom position @default z 0 @values z Off 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% @param c Focus @ Infinity Mode @default c 3 @values c None @Shot AFL MF @param v Video Interleave (shots) @default v 0 @values v Off 1 5 10 25 50 100 @param w Video Duration (sec) @default w 10 @range w 5 300 @param u Trigger Type @default u 2 @values u Interval Cont. USB PWM @param g GPS On @default g 1 @range g 0 1 @param b Backlight Off? @default b 1 @range b 0 1 @param l Logging @default l 3 @values l Off Screen SDCard Both --]] props=require("propcase") capmode=require("capmode") -- convert user parameter to usable variable names and values tv_table = { -320, 576, 640, 736, 832, 896, 928, 960, 992, 1024, 1056, 1113, 1180, 1276} tv96target = tv_table[t+3] tv96max = tv_table[x+8] tv96min = tv_table[y+1] sv_table = { 381, 411, 507, 603, 699, 761, 795 } sv96min = sv_table[p+1] sv96max1 = sv_table[q+2] sv96max2 = sv_table[r+2] av_table = { 171, 192, 218, 265, 285, 322, 347, 384, 417, 446, 477, 510, 543, 576 } av96target = av_table[a+1] av96minimum = av_table[f+1] av96max = av_table[m+1] ec96adjust = (e - 6)*32 video_table = { 0, 1, 5, 10, 25, 50, 100 } video_mode = video_table[v+1] video_duration = w interval = i*1000 max_shots = s poff_if_done = j start_delay = d backlight = b log_mode= l focus_mode = c usb_mode = u gps = g if ( z==0 ) then zoom_setpoint = nil else zoom_setpoint = (z-1)*10 end -- initial configuration values nd96offset=3*96 -- ND filter's number of equivalent f-stops (f * 96) infx = 50000 -- focus lock distance in mm (approximately 55 yards) shot_count = 0 -- shot counter blite_timer = 300 -- backlight off delay in 100mSec increments old_console_timeout = get_config_value( 297 ) shot_request = false -- pwm mode flag to request a shot be taken -- check camera Av configuration ( variable aperture and/or ND filter ) if n==0 then -- use of nd filter allowed? if get_nd_present()==1 then -- check for ND filter only Av_mode = 0 -- 0 = ND disabled and no iris available else Av_mode = 1 -- 1 = ND disabled and iris available end else Av_mode = get_nd_present()+1 -- 1 = iris only , 2=ND filter only, 3= both ND & iris end function printf(...) if ( log_mode == 0) then return end local str=string.format(...) if (( log_mode == 1) or (log_mode == 3)) then print(str) end if ( log_mode > 1 ) then local logname="A/3DR_EAI_log.log" log=io.open(logname,"a") log:write(os.date("%Y%b%d %X ")..string.format(...),"\n") log:close() end end tv_ref = { -- note : tv_ref values set 1/2 way between shutter speed values -608, -560, -528, -496, -464, -432, -400, -368, -336, -304, -272, -240, -208, -176, -144, -112, -80, -48, -16, 16, 48, 80, 112, 144, 176, 208, 240, 272, 304, 336, 368, 400, 432, 464, 496, 528, 560, 592, 624, 656, 688, 720, 752, 784, 816, 848, 880, 912, 944, 976, 1008, 1040, 1072, 1096, 1129, 1169, 1192, 1225, 1265, 1376 } tv_str = { ">64", "64", "50", "40", "32", "25", "20", "16", "12", "10", "8.0", "6.0", "5.0", "4.0", "3.2", "2.5", "2.0", "1.6", "1.3", "1.0", "0.8", "0.6", "0.5", "0.4", "0.3", "1/4", "1/5", "1/6", "1/8", "1/10", "1/13", "1/15", "1/20", "1/25", "1/30", "1/40", "1/50", "1/60", "1/80", "1/100", "1/125", "1/160", "1/200", "1/250", "1/320", "1/400", "1/500", "1/640", "1/800", "1/1000","1/1250", "1/1600","1/2000","1/2500","1/3200","1/4000","1/5000","1/6400","1/8000","1/10000","hi" } function print_tv(val) if ( val == nil ) then return("-") end local i = 1 while (i <= #tv_ref) and (val > tv_ref[i]) do i=i+1 end return tv_str[i] end av_ref = { 160, 176, 208, 243, 275, 304, 336, 368, 400, 432, 464, 480, 496, 512, 544, 592, 624, 656, 688, 720, 752, 784 } av_str = {"n/a","1.8", "2.0","2.2","2.6","2.8","3.2","3.5","4.0","4.5","5.0","5.6","5.9","6.3","7.1","8.0","9.0","10.0","11.0","13.0","14.0","16.0","hi"} function print_av(val) if ( val == nil ) then return("-") end local i = 1 while (i <= #av_ref) and (val > av_ref[i]) do i=i+1 end return av_str[i] end sv_ref = { 370, 397, 424, 456, 492, 523, 555, 588, 619, 651, 684, 731, 779, 843, 907 } sv_str = {"n/a","80","100","120","160","200","250","320","400","500","640","800","1250","1600","3200","hi"} function print_sv(val) if ( val == nil ) then return("-") end local i = 1 while (i <= #sv_ref) and (val > sv_ref[i]) do i=i+1 end return sv_str[i] end function pline(message, line) -- print line function fg = 258 bg=259 end -- switch between shooting and playback modes function switch_mode( m ) if ( m == 1 ) then if ( get_mode() == false ) then set_record(1) -- switch to shooting mode while ( get_mode() == false ) do sleep(100) end sleep(1000) end else if ( get_mode() == true ) then set_record(0) -- switch to playback mode while ( get_mode() == true ) do sleep(100) end sleep(1000) end end end -- focus lock and unlock function lock_focus() if (focus_mode > 1) then -- focus mode requested ? if ( focus_mode == 2 ) then -- method 1 : set_aflock() command enables MF if (chdk_version==120) then set_aflock(1) set_prop(props.AF_LOCK,1) else set_aflock(1) end if (get_prop(props.AF_LOCK) == 1) then printf(" AFL enabled") else printf(" AFL failed ***") end else -- mf mode requested if (chdk_version==120) then -- CHDK 1.2.0 : call event proc or levents to try and enable MF mode if call_event_proc("SS.Create") ~= -1 then if call_event_proc("SS.MFOn") == -1 then call_event_proc("PT_MFOn") end elseif call_event_proc("RegisterShootSeqEvent") ~= -1 then if call_event_proc("PT_MFOn") == -1 then call_event_proc("MFOn") end end if (get_prop(props.FOCUS_MODE) == 0 ) then -- MF not set - try levent PressSw1AndMF post_levent_for_npt("PressSw1AndMF") sleep(500) end elseif (chdk_version >= 130) then -- CHDK 1.3.0 : set_mf() if ( set_mf(1) == 0 ) then set_aflock(1) end -- as a fall back, try setting AFL is set_mf fails end if (get_prop(props.FOCUS_MODE) == 1) then printf(" MF enabled") else printf(" MF enable failed ***") end end sleep(1000) set_focus(infx) sleep(1000) end end function unlock_focus() if (focus_mode > 1) then -- focus mode requested ? if (focus_mode == 2 ) then -- method 1 : AFL if (chdk_version==120) then set_aflock(0) set_prop(props.AF_LOCK,0) else set_aflock(0) end if (get_prop(props.AF_LOCK) == 0) then printf(" AFL unlocked") else printf(" AFL unlock failed") end else -- mf mode requested if (chdk_version==120) then -- CHDK 1.2.0 : call event proc or levents to try and enable MF mode if call_event_proc("SS.Create") ~= -1 then if call_event_proc("SS.MFOff") == -1 then call_event_proc("PT_MFOff") end elseif call_event_proc("RegisterShootSeqEvent") ~= -1 then if call_event_proc("PT_MFOff") == -1 then call_event_proc("MFOff") end end if (get_prop(props.FOCUS_MODE) == 1 ) then -- MF not reset - try levent PressSw1AndMF post_levent_for_npt("PressSw1AndMF") sleep(500) end elseif (chdk_version >= 130) then -- CHDK 1.3.0 : set_mf() if ( set_mf(0) == 0 ) then set_aflock(0) end -- fall back so reset AFL is set_mf fails end if (get_prop(props.FOCUS_MODE) == 0) then printf(" MF disabled") else printf(" MF disable failed") end end sleep(100) end end -- zoom position function update_zoom(zpos) local count = 0 if(zpos ~= nil) then zstep=((get_zoom_steps()-1)*zpos)/100 printf("setting zoom to "..zpos.." percent step="..zstep) sleep(200) set_zoom(zstep) sleep(2000) press("shoot_half") repeat sleep(100) count = count + 1 until (get_shooting() == true ) or (count > 40 ) release("shoot_half") end end -- restore camera settings on shutdown function restore() set_config_value(121,0) -- USB remote disable set_config_value(297,old_console_timeout) -- restore console timeout value if (backlight==1) then set_lcd_display(1) end -- display on unlock_focus() if( zoom_setpoint ~= nil ) then update_zoom(0) end if( shot_count >= max_shots) and ( max_shots > 1) then if ( poff_if_done == 1 ) then -- did script ending because # of shots done ? printf("power off - shot count at limit") -- complete power down sleep(2000) post_levent_to_ui('PressPowerButton') else set_record(0) end -- just retract lens end end -- Video mode function check_video(shot) local capture_mode if ((video_mode>0) and(shot>0) and (shot%video_mode == 0)) then unlock_focus() printf("Video mode started. Button:"..tostring(video_button)) if( video_button ) then click "video" else capture_mode=capmode.get() capmode.set('VIDEO_STD') press("shoot_full") sleep(300) release("shoot_full") end local end_second = get_day_seconds() + video_duration repeat wait_click(500) until (is_key("menu")) or (get_day_seconds() > end_second) if( video_button ) then click "video" else press("shoot_full") sleep(300) release("shoot_full") capmode.set(capture_mode) end printf("Video mode finished.") sleep(1000) lock_focus() return(true) else return(false) end end -- PWM USB pulse functions function ch1up() printf(" * usb pulse = ch1up") shot_request = true end function ch1mid() printf(" * usb pulse = ch1mid") if ( get_mode() == false ) then switch_mode(1) lock_focus() end end function ch1down() printf(" * usb pulse = ch1down") switch_mode(0) end function ch2up() printf(" * usb pulse = ch2up") update_zoom(100) end function ch2mid() printf(" * usb pulse = ch2mid") if ( zoom_setpoint ~= nil ) then update_zoom(zoom_setpoint) else update_zoom(50) end end function ch2down() printf(" * usb pulse = ch2down") update_zoom(0) end function pwm_mode(pulse_width) if pulse_width > 0 then if pulse_width < 5 then ch1up() elseif pulse_width < 8 then ch1mid() elseif pulse_width < 11 then ch1down() elseif pulse_width < 14 then ch2up() elseif pulse_width < 17 then ch2mid() elseif pulse_width < 20 then ch2down() else printf(" * usb pulse width error") end end end -- Basic exposure calculation using shutter speed and ISO only -- called for Tv-only and ND-only cameras (cameras without an iris) function basic_tv_calc() tv96setpoint = tv96target av96setpoint = nil local min_av = get_prop(props.MIN_AV) -- calculate required ISO setting sv96setpoint = tv96setpoint + min_av - bv96meter -- low ambient light ? if (sv96setpoint > sv96max2 ) then -- check if required ISO setting is too high sv96setpoint = sv96max2 -- clamp at max2 ISO if so tv96setpoint = math.max(bv96meter+sv96setpoint-min_av,tv96min) -- recalculate required shutter speed down to Tv min -- high ambient light ? elseif (sv96setpoint < sv96min ) then -- check if required ISO setting is too low sv96setpoint = sv96min -- clamp at minimum ISO setting if so tv96setpoint = bv96meter + sv96setpoint - min_av -- recalculate required shutter speed and hope for the best end end -- Basic exposure calculation using shutter speed, iris and ISO -- called for iris-only and "both" cameras (cameras with an iris & ND filter) function basic_iris_calc() tv96setpoint = tv96target av96setpoint = av96target -- calculate required ISO setting sv96setpoint = tv96setpoint + av96setpoint - bv96meter -- low ambient light ? if (sv96setpoint > sv96max1 ) then -- check if required ISO setting is too high sv96setpoint = sv96max1 -- clamp at first ISO limit av96setpoint = bv96meter + sv96setpoint - tv96setpoint -- calculate new aperture setting if ( av96setpoint < av96min ) then -- check if new setting is goes below lowest f-stop av96setpoint = av96min -- clamp at lowest f-stop sv96setpoint = tv96setpoint + av96setpoint - bv96meter -- recalculate ISO setting if (sv96setpoint > sv96max2 ) then -- check if the result is above max2 ISO sv96setpoint = sv96max2 -- clamp at highest ISO setting if so tv96setpoint = math.max(bv96meter+sv96setpoint-av96setpoint,tv96min) -- recalculate required shutter speed down to tv minimum end end -- high ambient light ? elseif (sv96setpoint < sv96min ) then -- check if required ISO setting is too low sv96setpoint = sv96min -- clamp at minimum ISO setting if so tv96setpoint = bv96meter + sv96setpoint - av96setpoint -- recalculate required shutter speed if (tv96setpoint > tv96max ) then -- check if shutter speed now too fast tv96setpoint = tv96max -- clamp at maximum shutter speed if so av96setpoint = bv96meter + sv96setpoint - tv96setpoint -- calculate new aperture setting if ( av96setpoint > av96max ) then -- check if new setting is goes above highest f-stop av96setpoint = av96max -- clamp at highest f-stop tv96setpoint = bv96meter + sv96setpoint - av96setpoint -- recalculate shutter speed needed and hope for the best end end end end -- calculate exposure for cams without adjustable iris or ND filter function exposure_Tv_only() insert_ND_filter = nil basic_tv_calc() end -- calculate exposure for cams with ND filter only function exposure_NDfilter() insert_ND_filter = false basic_tv_calc() if (tv96setpoint > tv96max ) then -- check if shutter speed now too fast insert_ND_filter = true -- flag the ND filter to be inserted bv96meter = bv96meter - nd96offset -- adjust meter for ND offset basic_tv_calc() -- start over, but with new meter value bv96meter = bv96meter + nd96offset -- restore meter for later logging end end -- calculate exposure for cams with adjustable iris only function exposure_iris() insert_ND_filter = nil basic_iris_calc() end -- calculate exposure for cams with both adjustable iris and ND filter function exposure_both() insert_ND_filter = false -- NOTE : assume ND filter never used automatically by Canon firmware basic_iris_calc() if (tv96setpoint > tv96max ) then -- check if shutter speed now too fast insert_ND_filter = true -- flag the ND filter to be inserted bv96meter = bv96meter - nd96offset -- adjust meter for ND offset basic_iris_calc() -- start over, but with new meter value bv96meter = bv96meter + nd96offset -- restore meter for later logging end end -- ========================== Main Program ================================= set_console_layout(1 ,1, 45, 14 ) --printf("KAP 3.1 started - press MENU to exit") printf("3DR EAI 1.0 Canon SX260 - Lets Map!") printf("Based On KAP 3.1") printf("Press the shutter button to pause") bi=get_buildinfo() printf("%s %s-%s %s %s %s", bi.version, bi.build_number, bi.build_revision, bi.platform, bi.platsub, bi.build_date) chdk_version= tonumber(string.sub(bi.build_number,1,1))*100 + tonumber(string.sub(bi.build_number,3,3))*10 + tonumber(string.sub(bi.build_number,5,5)) if ( tonumber(bi.build_revision) > 0 ) then build = tonumber(bi.build_revision) else build = tonumber(string.match(bi.build_number,'-(%d+)$')) end if ((chdk_version<120) or ((chdk_version==120)and(build<3276)) or ((chdk_version==130)and(build<3383))) then printf("CHDK 1.2.0 build 3276 or higher required") else if( props.CONTINUOUS_AF == nil ) then caf=-999 else caf = get_prop(props.CONTINUOUS_AF) end if( props.SERVO_AF == nil ) then saf=-999 else saf = get_prop(props.SERVO_AF) end cmode = capmode.get_name() printf("Mode:%s,Continuous_AF:%d,Servo_AF:%d", cmode,caf,saf) printf(" Tv:"..print_tv(tv96target).." max:"..print_tv(tv96max).." min:"..print_tv(tv96min).." ecomp:"..(ec96adjust/96).."."..(math.abs(ec96adjust*10/96)%10) ) printf(" Av:"..print_av(av96target).." minAv:"..print_av(av96minimum).." maxAv:"..print_av(av96max) ) printf(" ISOmin:"..print_sv(sv96min).." ISO1:"..print_sv(sv96max1).." ISO2:"..print_sv(sv96max2) ) printf(" MF mode:"..focus_mode.." Video:"..video_mode.." USB:"..usb_mode) printf(" AvM:"..Av_mode.." int:"..(interval/1000).." Shts:"..max_shots.." Dly:"..start_delay.." B/L:"..backlight) sleep(500) if (start_delay > 0 ) then printf("entering start delay of ".. start_delay.." seconds") sleep( start_delay*1000 ) end -- CAMERA CONFIGURATION - -- FIND config table here http://subversion.assembla.com/svn/chdk/trunk/core/conf.c set_config_value(2,0) --Save raw: off if (gps==1) then set_config_value(282,1) --turn GPS on --set_config_value(278,1) --show GPS symbol set_config_value(261,1) --wait for signal time set_config_value(266,5) --battery shutdown percentage end -- enable USB remote in USB remote moded if (usb_mode > 0 ) then set_config_value(121,1) -- make sure USB remote is enabled if (get_usb_power(1) == 0) then -- can we start ? printf("waiting on USB signal") repeat wait_click(20) until ((get_usb_power(1) == 1) or ( is_key("menu"))) --changed sleep from 1000 to 500 else sleep(500) end printf("USB signal received") end -- switch to shooting mode switch_mode(1) -- set zoom position update_zoom(zoom_setpoint) -- lock focus at infinity lock_focus() -- disable flash and AF assist lamp set_prop(props.FLASH_MODE, 2) -- flash off set_prop(props.AF_ASSIST_BEAM,0) -- AF assist off if supported for this camera set_config_value( 297, 60) -- set console timeout to 60 seconds if (usb_mode > 2 ) then repeat until (get_usb_power(2) == 0 ) end -- flush pulse buffer next_shot_time = get_tick_count() script_exit = false if( get_video_button() == 1) then video_button = true else video_button = false end set_console_layout(2 ,0, 45, 4 ) repeat --BB: Set get_usb_power(2) > 7 for a 70/100s pulse --BB: Could consider a max threshold to prevent erroneous trigger events --eg. get_usb_power(2) > 7 && get_usb_power(2) < 13 if( ( (usb_mode < 2 ) and ( next_shot_time <= get_tick_count() ) ) or ( (usb_mode == 2 ) and (get_usb_power(2) > 7 ) ) or ( (usb_mode == 3 ) and (shot_request == true ) ) ) then -- time to insert a video sequence ? if( check_video(shot_count) == true) then next_shot_time = get_tick_count() end -- intervalometer timing next_shot_time = next_shot_time + interval -- set focus at infinity ? (maybe redundant for AFL & MF mode but makes sure its set right) if (focus_mode > 0) then set_focus(infx) sleep(100) end -- check exposure local count = 0 local timeout = false press("shoot_half") repeat sleep(50) count = count + 1 if (count > 40 ) then timeout = true end until (get_shooting() == true ) or (timeout == true) -- shoot in auto mode if meter reading invalid, else calculate new desired exposure if ( timeout == true ) then release("shoot_half") repeat sleep(50) until get_shooting() == false shoot() -- shoot in Canon auto mode if we don't have a valid meter reading shot_count = shot_count + 1 printf(string.format('IMG_%04d.JPG',get_exp_count()).." : shot in auto mode, meter reading invalid") else -- get meter reading values (and add in exposure compensation) bv96raw=get_bv96() bv96meter=bv96raw-ec96adjust tv96meter=get_tv96() av96meter=get_av96() sv96meter=get_sv96() -- set minimum Av to larger of user input or current min for zoom setting av96min= math.max(av96minimum,get_prop(props.MIN_AV)) if (av96target < av96min) then av96target = av96min end -- calculate required setting for current ambient light conditions if (Av_mode == 1) then exposure_iris() elseif (Av_mode == 2) then exposure_NDfilter() elseif (Av_mode == 3) then exposure_both() else exposure_Tv_only() end -- set up all exposure overrides set_tv96_direct(tv96setpoint) set_sv96(sv96setpoint) if( av96setpoint ~= nil) then set_av96_direct(av96setpoint) end if(Av_mode > 1) and (insert_ND_filter == true) then -- ND filter available and needed? set_nd_filter(1) -- activate the ND filter nd_string="NDin" else set_nd_filter(2) -- make sure the ND filter does not activate nd_string="NDout" end -- and finally shoot the image press("shoot_full_only") sleep(100) release("shoot_full") repeat sleep(50) until get_shooting() == false shot_count = shot_count + 1 -- update shooting statistic and log as required shot_focus=get_focus() if(shot_focus ~= -1) and (shot_focus < 20000) then focus_string=" foc:"..(shot_focus/1000).."."..(((shot_focus%1000)+50)/100).."m" if(focus_mode>0) then error_string=" **WARNING : focus not at infinity**" end else focus_string=" foc:infinity" error_string=nil end printf(string.format('%d) IMG_%04d.JPG',shot_count,get_exp_count())) printf(" meter : Tv:".. print_tv(tv96meter) .." Av:".. print_av(av96meter) .." Sv:"..print_sv(sv96meter).." "..bv96raw ..":"..bv96meter) printf(" actual: Tv:".. print_tv(tv96setpoint).." Av:".. print_av(av96setpoint).." Sv:"..print_sv(sv96setpoint)) printf(" AvMin:".. print_av(av96min).." NDF:"..nd_string..focus_string ) if ((max_shots>0) and (shot_count >= max_shots)) then script_exit = true end shot_request = false -- reset shot request flag end collectgarbage() end -- check if USB remote enabled in intervalometer mode and USB power is off -> pause if so if ((usb_mode == 1 ) and (get_usb_power(1) == 0)) then printf("waiting on USB signal") unlock_focus() switch_mode(0) repeat wait_click(20) until ((get_usb_power(1) == 1) or ( is_key("menu"))) switch_mode(1) lock_focus() if ( is_key("menu")) then script_exit = true end printf("USB wait finished") sleep(100) end if (usb_mode == 3 ) then pwm_mode(get_usb_power(2)) end if (blite_timer > 0) then blite_timer = blite_timer-1 if ((blite_timer==0) and (backlight==1)) then set_lcd_display(0) end end if( error_string ~= nil) then draw_string( 16, 144, string.sub(error_string.." ",0,42), 258, 259) end wait_click(100) if( not( is_key("no_key"))) then if ((blite_timer==0) and (backlight==1)) then set_lcd_display(1) end blite_timer=300 if ( is_key("menu") ) then script_exit = true end end until (script_exit==true) printf("script halt requested") restore() end --[[ end of file ]]--
gpl-3.0
kitala1/darkstar
scripts/zones/Labyrinth_of_Onzozo/mobs/Flying_Manta.lua
23
1422
----------------------------------- -- Area: Labyrinth of Onzozo -- MOB: Flying Manta -- Note: Place holder Lord of Onzozo ----------------------------------- require("scripts/zones/Labyrinth_of_Onzozo/MobIDs"); ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob,killer) checkGoVregime(killer,mob,774,1); local mob = mob:getID(); if (Lord_of_Onzozo_PH[mob] ~= nil) then local ToD = GetServerVariable("[POP]Lord_of_Onzozo"); if (ToD <= os.time(t) and GetMobAction(Lord_of_Onzozo) == 0) then if (math.random((1),(25)) == 5) then UpdateNMSpawnPoint(Lord_of_Onzozo); GetMobByID(Lord_of_Onzozo):setRespawnTime(GetMobRespawnTime(mob)); SetServerVariable("[PH]Lord_of_Onzozo", mob); DeterMob(mob, true); end end elseif (Peg_Powler_PH[mob] ~= nil) then local ToD = GetServerVariable("[POP]Peg_Powler"); if (ToD <= os.time(t) and GetMobAction(Peg_Powler) == 0) then if (math.random((1),(25)) == 5) then UpdateNMSpawnPoint(Peg_Powler); GetMobByID(Peg_Powler):setRespawnTime(GetMobRespawnTime(mob)); SetServerVariable("[PH]Peg_Powler", mob); DeterMob(mob, true); end end end; end;
gpl-3.0
kitala1/darkstar
scripts/zones/Windurst_Woods/npcs/Anillah.lua
53
1829
----------------------------------- -- Area: Windurst Woods -- NPC: Anillah -- Type: Clothcraft Image Support -- @pos -34.800 -2.25 -119.950 241 ----------------------------------- package.loaded["scripts/zones/Windurst_Woods/TextIDs"] = nil; ----------------------------------- require("scripts/globals/status"); require("scripts/globals/crafting"); require("scripts/zones/Windurst_Woods/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local guildMember = isGuildMember(player,3); local SkillCap = getCraftSkillCap(player,SKILL_CLOTHCRAFT); local SkillLevel = player:getSkillLevel(SKILL_CLOTHCRAFT); if (guildMember == 1) then if (player:hasStatusEffect(EFFECT_CLOTHCRAFT_IMAGERY) == false) then player:startEvent(0x271F,SkillCap,SkillLevel,2,511,player:getGil(),0,0,0); -- p1 = skill level else player:startEvent(0x271F,SkillCap,SkillLevel,2,511,player:getGil(),7108,0,0); end else player:startEvent(0x271F); -- Standard Dialogue end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x271F and option == 1) then player:messageSpecial(IMAGE_SUPPORT,0,4,2); player:addStatusEffect(EFFECT_CLOTHCRAFT_IMAGERY,1,0,120); end end;
gpl-3.0
hanxi/cocos2d-x-v3.1
frameworks/cocos2d-x/cocos/scripting/lua-bindings/auto/api/ProgressTimer.lua
3
3148
-------------------------------- -- @module ProgressTimer -- @extend Node -------------------------------- -- @function [parent=#ProgressTimer] isReverseDirection -- @param self -- @return bool#bool ret (return value: bool) -------------------------------- -- @function [parent=#ProgressTimer] setBarChangeRate -- @param self -- @param #cc.Vec2 vec2 -------------------------------- -- @function [parent=#ProgressTimer] getPercentage -- @param self -- @return float#float ret (return value: float) -------------------------------- -- @function [parent=#ProgressTimer] setSprite -- @param self -- @param #cc.Sprite sprite -------------------------------- -- @function [parent=#ProgressTimer] getType -- @param self -- @return ProgressTimer::Type#ProgressTimer::Type ret (return value: cc.ProgressTimer::Type) -------------------------------- -- @function [parent=#ProgressTimer] getSprite -- @param self -- @return Sprite#Sprite ret (return value: cc.Sprite) -------------------------------- -- @function [parent=#ProgressTimer] setMidpoint -- @param self -- @param #cc.Vec2 vec2 -------------------------------- -- @function [parent=#ProgressTimer] getBarChangeRate -- @param self -- @return Vec2#Vec2 ret (return value: cc.Vec2) -------------------------------- -- overload function: setReverseDirection(bool) -- -- overload function: setReverseDirection(bool) -- -- @function [parent=#ProgressTimer] setReverseDirection -- @param self -- @param #bool bool -------------------------------- -- @function [parent=#ProgressTimer] getMidpoint -- @param self -- @return Vec2#Vec2 ret (return value: cc.Vec2) -------------------------------- -- @function [parent=#ProgressTimer] setPercentage -- @param self -- @param #float float -------------------------------- -- @function [parent=#ProgressTimer] setType -- @param self -- @param #cc.ProgressTimer::Type type -------------------------------- -- @function [parent=#ProgressTimer] create -- @param self -- @param #cc.Sprite sprite -- @return ProgressTimer#ProgressTimer ret (return value: cc.ProgressTimer) -------------------------------- -- @function [parent=#ProgressTimer] setAnchorPoint -- @param self -- @param #cc.Vec2 vec2 -------------------------------- -- @function [parent=#ProgressTimer] draw -- @param self -- @param #cc.Renderer renderer -- @param #cc.Mat4 mat4 -- @param #bool bool -------------------------------- -- @function [parent=#ProgressTimer] setColor -- @param self -- @param #color3b_table color3b -------------------------------- -- @function [parent=#ProgressTimer] getColor -- @param self -- @return color3b_table#color3b_table ret (return value: color3b_table) -------------------------------- -- @function [parent=#ProgressTimer] setOpacity -- @param self -- @param #unsigned char char -------------------------------- -- @function [parent=#ProgressTimer] getOpacity -- @param self -- @return unsigned char#unsigned char ret (return value: unsigned char) return nil
mit
Roblox/Core-Scripts
CoreScriptsRoot/Modules/Server/ClientChat/MessageLabelCreator.lua
2
4172
-- // FileName: MessageLabelCreator.lua -- // Written by: Xsitsu -- // Description: Module to handle taking text and creating stylized GUI objects for display in ChatWindow. local OBJECT_POOL_SIZE = 50 local module = {} --////////////////////////////// Include --////////////////////////////////////// local Chat = game:GetService("Chat") local clientChatModules = Chat:WaitForChild("ClientChatModules") local messageCreatorModules = clientChatModules:WaitForChild("MessageCreatorModules") local messageCreatorUtil = require(messageCreatorModules:WaitForChild("Util")) local modulesFolder = script.Parent local ChatSettings = require(clientChatModules:WaitForChild("ChatSettings")) local moduleObjectPool = require(modulesFolder:WaitForChild("ObjectPool")) local MessageSender = require(modulesFolder:WaitForChild("MessageSender")) --////////////////////////////// Methods --////////////////////////////////////// local methods = {} methods.__index = methods function ReturnToObjectPoolRecursive(instance, objectPool) local children = instance:GetChildren() for i = 1, #children do ReturnToObjectPoolRecursive(children[i], objectPool) end instance.Parent = nil objectPool:ReturnInstance(instance) end function GetMessageCreators() local typeToFunction = {} local creators = messageCreatorModules:GetChildren() for i = 1, #creators do if creators[i]:IsA("ModuleScript") then if creators[i].Name ~= "Util" then local creator = require(creators[i]) typeToFunction[creator[messageCreatorUtil.KEY_MESSAGE_TYPE]] = creator[messageCreatorUtil.KEY_CREATOR_FUNCTION] end end end return typeToFunction end function methods:WrapIntoMessageObject(messageData, createdMessageObject) local BaseFrame = createdMessageObject[messageCreatorUtil.KEY_BASE_FRAME] local BaseMessage = nil if messageCreatorUtil.KEY_BASE_MESSAGE then BaseMessage = createdMessageObject[messageCreatorUtil.KEY_BASE_MESSAGE] end local UpdateTextFunction = createdMessageObject[messageCreatorUtil.KEY_UPDATE_TEXT_FUNC] local GetHeightFunction = createdMessageObject[messageCreatorUtil.KEY_GET_HEIGHT] local FadeInFunction = createdMessageObject[messageCreatorUtil.KEY_FADE_IN] local FadeOutFunction = createdMessageObject[messageCreatorUtil.KEY_FADE_OUT] local UpdateAnimFunction = createdMessageObject[messageCreatorUtil.KEY_UPDATE_ANIMATION] local obj = {} obj.ID = messageData.ID obj.BaseFrame = BaseFrame obj.BaseMessage = BaseMessage obj.UpdateTextFunction = UpdateTextFunction or function() warn("NO MESSAGE RESIZE FUNCTION") end obj.GetHeightFunction = GetHeightFunction obj.FadeInFunction = FadeInFunction obj.FadeOutFunction = FadeOutFunction obj.UpdateAnimFunction = UpdateAnimFunction obj.ObjectPool = self.ObjectPool obj.Destroyed = false function obj:Destroy() ReturnToObjectPoolRecursive(self.BaseFrame, self.ObjectPool) self.Destroyed = true end return obj end function methods:CreateMessageLabel(messageData, currentChannelName) local messageType = messageData.MessageType if self.MessageCreators[messageType] then local createdMessageObject = self.MessageCreators[messageType](messageData, currentChannelName) if createdMessageObject then return self:WrapIntoMessageObject(messageData, createdMessageObject) end elseif self.DefaultCreatorType then local createdMessageObject = self.MessageCreators[self.DefaultCreatorType](messageData, currentChannelName) if createdMessageObject then return self:WrapIntoMessageObject(messageData, createdMessageObject) end else error("No message creator available for message type: " ..messageType) end end --///////////////////////// Constructors --////////////////////////////////////// function module.new() local obj = setmetatable({}, methods) obj.ObjectPool = moduleObjectPool.new(OBJECT_POOL_SIZE) obj.MessageCreators = GetMessageCreators() obj.DefaultCreatorType = messageCreatorUtil.DEFAULT_MESSAGE_CREATOR messageCreatorUtil:RegisterObjectPool(obj.ObjectPool) return obj end function module:GetStringTextBounds(text, font, textSize, sizeBounds) return messageCreatorUtil:GetStringTextBounds(text, font, textSize, sizeBounds) end return module
apache-2.0
kitala1/darkstar
scripts/globals/items/melon_snowcone.lua
39
1207
----------------------------------------- -- ID: 5712 -- Item: Melon Snowcone -- Food Effect: 5 Min, All Races ----------------------------------------- -- MP % 10 Cap 200 -- HP Healing 3 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) result = 0; if (target:hasStatusEffect(EFFECT_FOOD)) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,300,5712); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_FOOD_MPP, 10); target:addMod(MOD_FOOD_MP_CAP, 200); target:addMod(MOD_HPHEAL, 3); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_FOOD_MPP, 10); target:delMod(MOD_FOOD_MP_CAP, 200); target:delMod(MOD_HPHEAL, 3); end;
gpl-3.0
kitala1/darkstar
scripts/zones/Bhaflau_Thickets/npcs/Hamta-Iramta.lua
19
1811
----------------------------------- -- Area: Bhaflau Thickets -- NPC: Hamta-Iramta -- Type: Alzadaal Undersea Ruins -- @zone: 52 -- @pos -459.942 -20.048 -4.999 -- -- Auto-Script: Requires Verification (Verified by Brawndo) ----------------------------------- package.loaded["scripts/zones/Bhaflau_Thickets/TextIDs"] = nil; ----------------------------------- ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if(trade:getItemCount() == 1 and trade:hasItemQty(2185,1)) then -- Silver player:tradeComplete(); player:setPos(-458,-16,0,189); -- using the pos method until the problem below is fixed -- player:startEvent(0x0087); -- << this CS goes black at the end, never fades in return 1; end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) -- NPC is on a slant which makes this really difficult if(player:getXPos() < -456 and player:getXPos() > -459 and player:getYPos() < -16.079) then player:startEvent(0x0086); elseif(player:getXPos() < -459 and player:getXPos() > -462 and player:getYPos() < -16.070) then player:startEvent(0x0086); elseif(player:getXPos() < -462 and player:getXPos() > -464 and player:getYPos() < -16.071) then player:startEvent(0x0086); else player:startEvent(0x0088); 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
kitala1/darkstar
scripts/zones/Abyssea-Uleguerand/npcs/Cavernous_Maw.lua
12
1246
----------------------------------- -- Area: Abyssea - Uleguerand -- NPC: Cavernous Maw -- @pos -246.000, -40.600, -520.000 253 -- Notes: Teleports Players to Xarcabard ----------------------------------- package.loaded["scripts/zones/Abyssea-Uleguerand/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/zones/Abyssea-Uleguerand/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x00c8); 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 == 0x00c8 and option == 1) then player:setPos(269,-7,-75,192,112); end end;
gpl-3.0
apletnev/koreader
frontend/apps/reader/modules/readerwikipedia.lua
1
21433
local ConfirmBox = require("ui/widget/confirmbox") local DataStorage = require("datastorage") local InfoMessage = require("ui/widget/infomessage") local InputDialog = require("ui/widget/inputdialog") local KeyValuePage = require("ui/widget/keyvaluepage") local LuaData = require("luadata") local NetworkMgr = require("ui/network/manager") local ReaderDictionary = require("apps/reader/modules/readerdictionary") local Trapper = require("ui/trapper") local Translator = require("ui/translator") local UIManager = require("ui/uimanager") local Wikipedia = require("ui/wikipedia") local logger = require("logger") local util = require("util") local _ = require("gettext") local T = require("ffi/util").template local wikipedia_history = nil -- Wikipedia as a special dictionary local ReaderWikipedia = ReaderDictionary:extend{ -- identify itself is_wiki = true, wiki_languages = {}, disable_history = G_reader_settings:isTrue("wikipedia_disable_history"), } function ReaderWikipedia:init() self.ui.menu:registerToMainMenu(self) if not wikipedia_history then wikipedia_history = LuaData:open(DataStorage:getSettingsDir() .. "/wikipedia_history.lua", { name = "WikipediaHistory" }) end end function ReaderWikipedia:lookupInput() self.input_dialog = InputDialog:new{ title = _("Enter words to look up on Wikipedia"), input = "", input_type = "text", buttons = { { { text = _("Cancel"), callback = function() UIManager:close(self.input_dialog) end, }, { text = _("Search Wikipedia"), is_enter_default = true, callback = function() UIManager:close(self.input_dialog) self:onLookupWikipedia(self.input_dialog:getInputText()) end, }, } }, } self.input_dialog:onShowKeyboard() UIManager:show(self.input_dialog) end function ReaderWikipedia:addToMainMenu(menu_items) menu_items.wikipedia_lookup = { text = _("Wikipedia lookup"), callback = function() if NetworkMgr:isOnline() then self:lookupInput() else NetworkMgr:promptWifiOn() end end } menu_items.wikipedia_history = { text = _("Wikipedia history"), enabled_func = function() return wikipedia_history:has("wikipedia_history") end, callback = function() local wikipedia_history_table = wikipedia_history:readSetting("wikipedia_history") local kv_pairs = {} local previous_title self:initLanguages() -- so current lang is set for i = #wikipedia_history_table, 1, -1 do local value = wikipedia_history_table[i] if value.book_title ~= previous_title then table.insert(kv_pairs, { value.book_title..":", "" }) end previous_title = value.book_title local type_s = "▱ " -- lookup: small white parallelogram if value.page then type_s = "▤ " -- full page: large square with lines end local lang_s = "" if value.lang ~= self.wiki_languages[1]:lower() then -- We show item's lang only when different from current lang lang_s = " ["..value.lang:upper().."]" end local text = type_s .. value.word .. lang_s table.insert(kv_pairs, { os.date("%Y-%m-%d %H:%M:%S", value.time), text, callback = function() self:onLookupWikipedia(value.word, nil, value.page, value.lang) end }) end UIManager:show(KeyValuePage:new{ title = _("Wikipedia history"), kv_pairs = kv_pairs, }) end, } menu_items.wikipedia_settings = { text = _("Wikipedia settings"), sub_item_table = { { text = _("Set Wikipedia languages"), callback = function() local wikilang_input local function save_wikilang() local wiki_languages = {} local langs = wikilang_input:getInputText() for lang in langs:gmatch("%S+") do if not lang:match("^[%a-]+$") then UIManager:show(InfoMessage:new{ text = T(_("%1 does not look like a valid Wikipedia language."), lang) }) return end lang = lang:lower() table.insert(wiki_languages, lang) end G_reader_settings:saveSetting("wikipedia_languages", wiki_languages) -- re-init languages self.wiki_languages = {} self:initLanguages() UIManager:close(wikilang_input) end -- Use the list built by initLanguages (even if made from UI -- and document languages) as the initial value self:initLanguages() local curr_languages = table.concat(self.wiki_languages, " ") wikilang_input = InputDialog:new{ title = _("Wikipedia languages"), input = curr_languages, input_hint = "en fr zh", input_type = "text", description = _("Enter one or more Wikipedia language codes (the 2 or 3 letters before .wikipedia.org), in the order you wish to see them available, separated by space(s) (example: en fr zh)\nFull list at https://en.wikipedia.org/wiki/List_of_Wikipedias"), buttons = { { { text = _("Cancel"), callback = function() UIManager:close(wikilang_input) end, }, { text = _("Save"), is_enter_default = true, callback = save_wikilang, }, } }, } wikilang_input:onShowKeyboard() UIManager:show(wikilang_input) end, }, { -- setting used by dictquicklookup text = _("Set Wikipedia 'Save as EPUB' directory"), callback = function() local folder_path_input local function save_folder_path() local folder_path = folder_path_input:getInputText() folder_path = folder_path:gsub("^%s*(.-)%s*$", "%1") -- trim spaces folder_path = folder_path:gsub("^(.-)/*$", "%1") -- remove trailing slash if folder_path == "" then G_reader_settings:delSetting("wikipedia_save_dir", folder_path) else if lfs.attributes(folder_path, "mode") == "directory" then -- existing directory G_reader_settings:saveSetting("wikipedia_save_dir", folder_path) elseif lfs.attributes(folder_path) then -- already exists, but not a directory UIManager:show(InfoMessage:new{ text = _("A path with that name already exists, but is not a directory.") }) return else -- non-existing path, we may create it local parent_dir, sub_dir = util.splitFilePathName(folder_path) -- luacheck: no unused if lfs.attributes(parent_dir, "mode") == "directory" then -- existing directory lfs.mkdir(folder_path) if lfs.attributes(folder_path, "mode") == "directory" then -- existing directory G_reader_settings:saveSetting("wikipedia_save_dir", folder_path) UIManager:show(InfoMessage:new{ text = _("Directory created."), }) else UIManager:show(InfoMessage:new{ text = _("Creating directory failed.") }) return end else -- We don't create more than one directory, in case of bad input UIManager:show(InfoMessage:new{ text = _("Parent directory does not exist. Please create intermediate directories first.") }) return end end end UIManager:close(folder_path_input) end -- for initial value, use the same logic as in dictquicklookup to decide save directory -- suggest to use a "Wikipedia" sub-directory of some directories local default_dir = require("apps/filemanager/filemanagerutil").getDefaultDir() default_dir = default_dir .. "/Wikipedia" local dir = G_reader_settings:readSetting("wikipedia_save_dir") if not dir then dir = G_reader_settings:readSetting("home_dir") if not dir then dir = default_dir end dir = dir:gsub("^(.-)/*$", "%1") -- remove trailing slash dir = dir .. "/Wikipedia" end folder_path_input = InputDialog:new{ title = _("Wikipedia 'Save as EPUB' directory"), input = dir, input_hint = default_dir, input_type = "text", description = _("Enter the full path to a directory"), buttons = { { { text = _("Cancel"), callback = function() UIManager:close(folder_path_input) end, }, { text = _("Save"), is_enter_default = true, callback = save_folder_path, }, } }, } folder_path_input:onShowKeyboard() UIManager:show(folder_path_input) end, separator = true, }, { text = _("Enable Wikipedia history"), checked_func = function() return not self.disable_history end, callback = function() self.disable_history = not self.disable_history G_reader_settings:saveSetting("wikipedia_disable_history", self.disable_history) end, }, { text = _("Clean Wikipedia history"), callback = function() UIManager:show(ConfirmBox:new{ text = _("Clean Wikipedia history?"), ok_text = _("Clean"), ok_callback = function() -- empty data table to replace current one wikipedia_history:reset{} end, }) end, separator = true, }, { -- setting used in wikipedia.lua text = _("Show image in search results"), checked_func = function() return G_reader_settings:nilOrTrue("wikipedia_show_image") end, callback = function() G_reader_settings:flipNilOrTrue("wikipedia_show_image") end, }, { -- setting used in wikipedia.lua text = _("Show more images in full article"), enabled_func = function() return G_reader_settings:nilOrTrue("wikipedia_show_image") end, checked_func = function() return G_reader_settings:nilOrTrue("wikipedia_show_more_images") and G_reader_settings:nilOrTrue("wikipedia_show_image") end, callback = function() G_reader_settings:flipNilOrTrue("wikipedia_show_more_images") end, }, } } end function ReaderWikipedia:initLanguages(word) if #self.wiki_languages > 0 then -- already done return end -- Fill self.wiki_languages with languages to propose local wikipedia_languages = G_reader_settings:readSetting("wikipedia_languages") if type(wikipedia_languages) == "table" and #wikipedia_languages > 0 then -- use this setting, no need to guess self.wiki_languages = wikipedia_languages else -- guess some languages self.seen_lang = {} local addLanguage = function(lang) if lang and lang ~= "" then -- convert "zh-CN" and "zh-TW" to "zh" lang = lang:match("(.*)-") or lang if lang == "C" then lang="en" end lang = lang:lower() if not self.seen_lang[lang] then table.insert(self.wiki_languages, lang) self.seen_lang[lang] = true end end end -- use book and UI languages if self.view then addLanguage(self.view.document:getProps().language) end addLanguage(G_reader_settings:readSetting("language")) if #self.wiki_languages == 0 and word then -- if no language at all, do a translation of selected word local ok_translator, lang ok_translator, lang = pcall(Translator.detect, Translator, word) if ok_translator then addLanguage(lang) end end -- add english anyway, so we have at least one language addLanguage("en") end end function ReaderWikipedia:onLookupWikipedia(word, box, get_fullpage, forced_lang) -- Wrapped through Trapper, as we may be using Trapper:dismissableRunInSubprocess() in it Trapper:wrap(function() self:lookupWikipedia(word, box, get_fullpage, forced_lang) end) return true end function ReaderWikipedia:lookupWikipedia(word, box, get_fullpage, forced_lang) if not NetworkMgr:isOnline() then NetworkMgr:promptWifiOn() return end -- word is the text to query. If get_fullpage is true, it is the -- exact wikipedia page title we want the full page of. self:initLanguages(word) local lang if forced_lang then -- use provided lang (from readerlink when noticing that an external link is a wikipedia url) lang = forced_lang else -- use first lang from self.wiki_languages, which may have been rotated by DictQuickLookup lang = self.wiki_languages[1] end logger.dbg("lookup word:", word, box, get_fullpage) -- no need to clean word if get_fullpage, as it is the exact wikipetia page title if word and not get_fullpage then -- escape quotes and other funny characters in word word = self:cleanSelection(word) -- no need to lower() word with wikipedia search end logger.dbg("stripped word:", word) if word == "" then return end local display_word = word:gsub("_", " ") if not self.disable_history then local book_title = self.ui.doc_settings and self.ui.doc_settings:readSetting("doc_props").title or _("Wikipedia lookup") if book_title == "" then -- no or empty metadata title if self.ui.document and self.ui.document.file then local directory, filename = util.splitFilePathName(self.ui.document.file) -- luacheck: no unused book_title = util.splitFileNameSuffix(filename) end end wikipedia_history:addTableItem("wikipedia_history", { book_title = book_title, time = os.time(), word = display_word, lang = lang:lower(), page = get_fullpage, }) end -- Fix lookup message to include lang and set appropriate error texts local no_result_text, req_failure_text if get_fullpage then self.lookup_msg = T(_("Retrieving Wikipedia %2 article:\n%1"), "%1", lang:upper()) req_failure_text = _("Failed to retrieve Wikipedia article.") no_result_text = _("Wikipedia article not found.") else self.lookup_msg = T(_("Searching Wikipedia %2 for:\n%1"), "%1", lang:upper()) req_failure_text = _("Failed searching Wikipedia.") no_result_text = _("No Wikipedia articles matching search term.") end self:showLookupInfo(display_word) local results = {} local ok, pages local lookup_cancelled = false Wikipedia:setTrapWidget(self.lookup_progress_msg) if get_fullpage then ok, pages = pcall(Wikipedia.getFullPage, Wikipedia, word, lang) else ok, pages = pcall(Wikipedia.searchAndGetIntros, Wikipedia, word, lang) end Wikipedia:resetTrapWidget() if not ok and pages and string.find(pages, Wikipedia.dismissed_error_code) then -- So we can display an alternate dummy result lookup_cancelled = true -- Or we could just not show anything with: -- self:dismissLookupInfo() -- return end if ok and pages then -- sort pages according to 'index' attribute if present (not present -- in fullpage results) local sorted_pages = {} local has_indexes = false for pageid, page in pairs(pages) do if page.index ~= nil then sorted_pages[page.index+1] = page has_indexes = true end end if has_indexes then pages = sorted_pages end for pageid, page in pairs(pages) do local definition = page.extract or no_result_text if page.length then -- we get 'length' only for intro results -- let's append it to definition so we know -- how big/valuable the full page is local fullkb = math.ceil(page.length/1024) local more_factor = math.ceil( page.length / (1+definition:len()) ) -- +1 just in case len()=0 definition = definition .. "\n" .. T(_("(full article : %1 kB, = %2 x this intro length)"), fullkb, more_factor) end local result = { dict = T(_("Wikipedia %1"), lang:upper()), word = page.title, definition = definition, is_fullpage = get_fullpage, lang = lang, images = page.images, } table.insert(results, result) end -- logger.dbg of results will be done by ReaderDictionary:showDict() else -- dummy results local definition if lookup_cancelled then definition = _("Wikipedia request canceled.") elseif ok then definition = no_result_text else definition = req_failure_text logger.dbg("error:", pages) end results = { { dict = T(_("Wikipedia %1"), lang:upper()), word = word, definition = definition, is_fullpage = get_fullpage, lang = lang, } } logger.dbg("dummy result table:", word, results) end self:showDict(word, results, box) end -- override onSaveSettings in ReaderDictionary function ReaderWikipedia:onSaveSettings() end return ReaderWikipedia
agpl-3.0
kitala1/darkstar
scripts/zones/Castle_Zvahl_Keep/Zone.lua
28
4006
----------------------------------- -- -- Zone: Castle_Zvahl_Keep (162) -- ----------------------------------- package.loaded["scripts/zones/Castle_Zvahl_Keep/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/zones/Castle_Zvahl_Keep/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) zone:registerRegion(1, -301,-50,-22, -297,-49,-17); -- central porter on map 3 zone:registerRegion(2, -275,-54,3, -271,-53,7); -- NE porter on map 3 zone:registerRegion(3, -275,-54,-47, -271,-53,-42); -- SE porter on map 3 zone:registerRegion(4, -330,-54,3, -326,-53,7); -- NW porter on map 3 zone:registerRegion(5, -328,-54,-47, -324,-53,-42); -- SW porter on map 3 zone:registerRegion(6, -528,-74,84, -526,-73,89); -- N porter on map 4 zone:registerRegion(7, -528,-74,30, -526,-73,36); -- S porter on map 4 UpdateTreasureSpawnPoint(17441084); end; ----------------------------------- -- onConquestUpdate ----------------------------------- function onConquestUpdate(zone, updatetype) local players = zone:getPlayers(); for name, player in pairs(players) do conquestUpdate(zone, player, updatetype, CONQUEST_BASE); end end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) local cs = -1; if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then player:setPos(-555.996,-71.691,59.989,254); end return cs; end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) switch (region:GetRegionID()): caseof { --------------------------------- [1] = function (x) -- --------------------------------- player:startEvent(0x0000); -- ports player to far NE corner end, --------------------------------- [2] = function (x) -- --------------------------------- player:startEvent(0x0002); -- ports player to end, --------------------------------- [3] = function (x) -- --------------------------------- player:startEvent(0x0001); -- ports player to far SE corner end, --------------------------------- [4] = function (x) -- --------------------------------- player:startEvent(0x0001); -- ports player to far SE corner end, --------------------------------- [5] = function (x) -- --------------------------------- player:startEvent(0x0005); -- ports player to H-7 on map 4 (south or north part, randomly) end, --------------------------------- [6] = function (x) -- --------------------------------- player:startEvent(0x0006); -- ports player to position "A" on map 2 end, --------------------------------- [7] = function (x) -- --------------------------------- player:startEvent(0x0007); -- ports player to position G-8 on map 2 end, default = function (x) -- print("default"); end, } end; ----------------------------------- -- onRegionLeave ----------------------------------- function onRegionLeave(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
fastmailops/prosody
util/helpers.lua
4
2289
-- Prosody IM -- Copyright (C) 2008-2010 Matthew Wild -- Copyright (C) 2008-2010 Waqas Hussain -- -- This project is MIT/X11 licensed. Please see the -- COPYING file in the source package for more information. -- local debug = require "util.debug"; module("helpers", package.seeall); -- Helper functions for debugging local log = require "util.logger".init("util.debug"); function log_host_events(host) return log_events(prosody.hosts[host].events, host); end function revert_log_host_events(host) return revert_log_events(prosody.hosts[host].events); end function log_events(events, name, logger) local f = events.fire_event; if not f then error("Object does not appear to be a util.events object"); end logger = logger or log; name = name or tostring(events); function events.fire_event(event, ...) logger("debug", "%s firing event: %s", name, event); return f(event, ...); end events[events.fire_event] = f; return events; end function revert_log_events(events) events.fire_event, events[events.fire_event] = events[events.fire_event], nil; -- :)) end function show_events(events, specific_event) local event_handlers = events._handlers; local events_array = {}; local event_handler_arrays = {}; for event in pairs(events._event_map) do local handlers = event_handlers[event]; if handlers and (event == specific_event or not specific_event) then table.insert(events_array, event); local handler_strings = {}; for i, handler in ipairs(handlers) do local upvals = debug.string_from_var_table(debug.get_upvalues_table(handler)); handler_strings[i] = " "..i..": "..tostring(handler)..(upvals and ("\n "..upvals) or ""); end event_handler_arrays[event] = handler_strings; end end table.sort(events_array); local i = 1; while i <= #events_array do local handlers = event_handler_arrays[events_array[i]]; for j=#handlers, 1, -1 do table.insert(events_array, i+1, handlers[j]); end if i > 1 then events_array[i] = "\n"..events_array[i]; end i = i + #handlers + 1 end return table.concat(events_array, "\n"); end function get_upvalue(f, get_name) local i, name, value = 0; repeat i = i + 1; name, value = debug.getupvalue(f, i); until name == get_name or name == nil; return value; end return _M;
mit
kitala1/darkstar
scripts/globals/items/hellfire_axe.lua
16
1030
----------------------------------------- -- ID: 16713 -- Item: Hellfire Axe -- Additional Effect: Fire Damage ----------------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------- -- onAdditionalEffect Action ----------------------------------- function onAdditionalEffect(player,target,damage) local chance = 10; if (math.random(0,99) >= chance) then return 0,0,0; else local dmg = math.random(3,10); local params = {}; params.bonusmab = 0; params.includemab = false; dmg = addBonusesAbility(player, ELE_FIRE, target, dmg, params); dmg = dmg * applyResistanceAddEffect(player,target,ELE_FIRE,0); dmg = adjustForTarget(target,dmg,ELE_FIRE); dmg = finalMagicNonSpellAdjustments(player,target,ELE_FIRE,dmg); local message = 163; if (dmg < 0) then message = 167; end return SUBEFFECT_FIRE_DAMAGE,message,dmg; end end;
gpl-3.0
d-o/LUA-LIB
tests/unit/date.lua
2
7278
------------------------------------------------------------------------------- -- Date unit tests. -- @author Pauli -- @copyright 2015 Rinstrum Pty Ltd ------------------------------------------------------------------------------- describe('Date tests #date', function() local dbg = require "rinLibrary.rinDebug" local date = require 'rinLibrary.date' -- test day of week describe('day of week #dow', function() local dowtests = { { res = { 5, 'Friday', 'FRI'}, date = { 2015, 1, 16 } }, { res = { 5, 'Friday', 'FRI'}, date = { 1752, 9, 15 } }, { res = { 2, 'Tuesday', 'TUE'}, date = { 1752, 9, 1 } }, { res = { 2, 'Tuesday', 'TUE'}, date = { '1752', '9', '1' } }, } for i = 1, #dowtests do it('test '..i, function() local r = dowtests[i] assert.same(r.res, { date.dayOfWeek(unpack(r.date)) }) end) end end) -- test lengths of months describe('length of month #monlen', function() local monlengths = { { res = 31, date = { 2015, 1 } }, { res = 28, date = { 1900, 2 } }, { res = 29, date = { 2000, 2 } }, { res = 19, date = { 1752, 9 } }, { res = 29, date = { 1300, 2 } }, { res = 29, date = { 2000, 2 } }, { res = 28, date = { 1900, 2 } }, { res = 28, date = { 1800, 2 } }, { res = 29, date = { 1700, 2 } }, -- Julian Calendar here { res = 29, date = { 1600, 2 } }, { res = 29, date = { 1004, 2 } }, { res = 31, date = { 999, 1 } }, { res = 31, date = { 2000, 3 } }, { res = 30, date = { 1003, 4 } }, { res = 31, date = { 2654, 5 } }, { res = 30, date = { 9999, 6 } }, { res = 31, date = { 1, 7 } }, { res = 31, date = { 1999, 8 } }, { res = 30, date = { 2014, 9 } }, { res = 31, date = { 2015, 10 } }, { res = 30, date = { 2016, 11 } }, { res = 31, date = { 2016, 12 } }, { res = 31, date = { '2016', '12' } }, } for i = 1, #monlengths do it('test '..i, function() local r = monlengths[i] assert.equal(r.res, date.monthLength(unpack(r.date))) end) end end) -- test names of months describe('names of month #monlen', function() local monnames = { { res = { 'April', 'APR' }, m = 4 }, { res = { 'February', 'FEB' }, m = 2 }, { res = { 'December', 'DEC' }, m = 12 }, { res = { 'December', 'DEC' }, m = '12' }, } for i = 1, #monnames do it('test '..i, function() local r = monnames[i] assert.same(r.res, { date.monthName(r.m) }) end) end end) -- test for leap years describe('leap years #leap', function() local leapyears = { { res = true, y = 2000 }, { res = false, y = 1900 }, { res = true, y = 2016 }, { res = false, y = 1800 }, { res = true, y = 1700 }, { res = true, y = '1700' }, } for i = 1, #leapyears do it('test '..i, function() local r = leapyears[i] assert.same(r.res, date.isLeapYear(r.y)) end) end end) -- test for delay days describe('days between dates #days', function() local ddays = { { res = 31, dates = { 1900, 1, 1, 1900, 2, 1 } }, { res = 0, dates = { 1960, 6, 13, 1960, 6, 13 } }, { res = -31, dates = { 1900, 2, 1, 1900, 1, 1 } }, { res = 366, dates = { 2000, 1, 1, 2001, 1, 1 } }, { res = 36524, dates = { 1900, 1, 1, 2000, 1, 1 } }, { res = 36525, dates = { 2000, 1, 1, 2100, 1, 1 } }, { res = 355, dates = { 1752, 1, 1, 1753, 1, 1 } }, { res = 365, dates = { 1582, 1, 1, 1583, 1, 1 } }, { res = 36524, dates = { '1900','1','1', '2000','1','1' } }, } for i = 1, #ddays do it('test '..i, function() local r = ddays[i] assert.same(r.res, date.deltaDays(unpack(r.dates))) end) end end) -- test for addition and subtraction of days describe('add days #add', function() local adays = { { res = { 1950, 3, 7 }, a = { 1950, 3, 1, 6 } }, { res = { 1950, 3, 7 }, a = { 1950, 3, 9, -2 } }, { res = { 2001, 2, 9 }, a = { 2000, 2, 10, 365 } }, { res = { 1901, 2, 9 }, a = { 1900, 2, 9, 365 } }, { res = { 1901, 2, 9 }, a = { '1900','2','9', '365' } }, } for i = 1, #adays do it('test '..i, function() local r = adays[i] assert.same(r.res, { date.addDays(unpack(r.a))}) end) end end) -- test for reformation settings describe('reformation changes #reformation', function() local function yr(n) return { n, 1, 1, n+1, 1, 1 } end local ref = { { res = 355, change = {'british'}, dates = yr(1752) }, { res = 365, change = {'british'}, dates = yr(1582) }, { res = 366, change = {'european'}, dates = yr(1752) }, { res = 355, change = {'european'}, dates = yr(1582) }, { res = 352, change = {'japan'}, dates = yr(1918) }, { res = 354, change = { 1750, 2, 2 }, dates = yr(1750) }, { res = 366, change = {'julian'}, dates = yr(9900) }, { res = 365, change = {'china'}, dates = yr(9900) }, { res = 365, change = {'british'}, dates = yr(2100) }, { res = 365, change = {'british'}, dates = yr('2100') }, } for i = 1, #ref do it('test '..i, function() local r = ref[i] date.setReformation(unpack(r.change)) assert.same(r.res, date.deltaDays(unpack(r.dates))) end) end end) it("format", function() local yr, mo, da = 2022, 1, 2 date.setDateFormat('month', 'day', 'year', 4) assert.is_equal("01/02/2022", date.formatDate(yr, mo, da)) assert.is_same({ "month", "day", "year", 4 }, {date.getDateFormat()}) date.setDateFormat('year', 'month', 'day', 4) assert.is_equal("2022/01/02", date.formatDate(yr, mo, da)) assert.is_same({ "year", "month", "day", 4 }, {date.getDateFormat()}) date.setDateFormat('day', 'month', 'year', 4) assert.is_equal("02/01/2022", date.formatDate(yr, mo, da)) assert.is_same({ "day", "month", "year", 4 }, {date.getDateFormat()}) date.setDateFormat('day', 'month', 'year', 2) assert.is_equal("02/01/22", date.formatDate(yr, mo, da)) assert.is_same({ "day", "month", "year", 2 }, {date.getDateFormat()}) end) end)
gpl-3.0
Teaonly/easyLearning.js
simple_lstm/verify.lua
2
1808
require 'torch' require 'nn' require 'nngraph' local BOX_SIZE = 4 local RNN_SIZE = 196 local LAYER_NUMBER = 2 local box = {} for i = 1, BOX_SIZE do box[i] = {}; for j = 1, BOX_SIZE do box[i][j] = (i-1)*BOX_SIZE + j end end box[BOX_SIZE][BOX_SIZE] = 0 local show_box = function() print("=================================") for y = 1,BOX_SIZE do local line = ""; for x = 1,BOX_SIZE do if ( box[y][x] == 0) then line = line .. ' ' .. ' ' elseif ( box[y][x] > 9) then line = line .. box[y][x] .. ' ' else line = line .. ' ' .. box[y][x] .. ' ' end end print(line) end print("----") end local model = torch.load('./model.bin'); local rnn_state = {} for i = 1, LAYER_NUMBER*2 do rnn_state[i] = torch.ones(1, RNN_SIZE) * 0.05 end local x = BOX_SIZE local y = BOX_SIZE while true do show_box(); print("Please input L/R/U/D "); local nx = x local ny = y local move = -1 local m = io.read() if ( m == 'L' or m == 'l') then move = 2 elseif ( m == 'R' or m == 'r') then move = 0 elseif ( m == 'U' or m == 'u') then move = 3 elseif ( m == 'D' or m == 'd') then move = 1 end if ( move == 0) then nx = nx + 1 elseif ( move == 1) then ny = ny + 1 elseif ( move == 2) then nx = nx - 1 elseif ( move == 3) then ny = ny - 1 end if ( move >= 0 and nx >= 1 and nx <=BOX_SIZE and ny >=1 and ny <= BOX_SIZE) then local xx = torch.zeros(1, 4) xx[1][ move + 1] = 1 local lst = model:forward({xx, unpack(rnn_state)}) for i = 1, #rnn_state do rnn_state[i] = lst[i] end local _, prediction = lst[#lst]:max(2) print("model output ==> " .. prediction[1][1]) box[y][x] = box[ny][nx] box[ny][nx] = 0 x = nx y = ny end end
mit
kitala1/darkstar
scripts/globals/weaponskills/red_lotus_blade.lua
30
1295
----------------------------------- -- Red Lotus Blade -- Sword weapon skill -- Skill Level: 50 -- Deals fire elemental damage to enemy. Damage varies with TP. -- Aligned with the Flame Gorget & Breeze Gorget. -- Aligned with the Flame Belt & Breeze Belt. -- Element: Fire -- Modifiers: STR:40% ; INT:40% -- 100%TP 200%TP 300%TP -- 1.00 2.38 3.75 ----------------------------------- require("scripts/globals/magic"); require("scripts/globals/status"); require("scripts/globals/settings"); require("scripts/globals/weaponskills"); ----------------------------------- function onUseWeaponSkill(player, target, wsID) local params = {}; params.ftp100 = 1; params.ftp200 = 2.38; params.ftp300 = 3; params.str_wsc = 0.3; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.2; params.mnd_wsc = 0.0; params.chr_wsc = 0.0; params.ele = ELE_FIRE; params.skill = SKILL_SWD; params.includemab = true; if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then params.ftp300 = 3.75; params.str_wsc = 0.4; params.int_wsc = 0.4; end local damage, criticalHit, tpHits, extraHits = doMagicWeaponskill(player, target, params); damage = damage * WEAPON_SKILL_POWER return tpHits, extraHits, criticalHit, damage; end
gpl-3.0
kitala1/darkstar
scripts/zones/Valkurm_Dunes/npcs/Fighting_Ant_IM.lua
30
3046
----------------------------------- -- Area: Valkurm Dunes -- NPC: Fighting Ant, I.M. -- Border Conquest Guards -- @pos 908.245 -1.171 -411.504 103 ----------------------------------- package.loaded["scripts/zones/Valkurm_Dunes/TextIDs"] = nil; ----------------------------------- require("scripts/globals/conquest"); require("scripts/zones/Valkurm_Dunes/TextIDs"); local guardnation = BASTOK; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno local guardtype = 4; -- 1: city, 2: foreign, 3: outpost, 4: border local region = ZULKHEIM; 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
ketan-ghumatkar/Canvas-LMS
vendor/plugins/delayed_job/lib/delayed/backend/redis/include.lua
28
6582
-- Keys holds the various functions to map to redis keys -- These are duplicated from job.rb local Keys = {} Keys.job = function(id) return "job/" .. id end Keys.running_jobs = function() return "running_jobs" end Keys.failed_jobs = function() return "failed_jobs" end Keys.queue = function(queue) return "queue/" .. (queue or '') end Keys.future_queue = function(queue) return Keys.queue(queue) .. "/future" end Keys.strand = function(strand_name) if strand_name and string.len(strand_name) > 0 then return "strand/" .. strand_name else return nil end end Keys.tag_counts = function(flavor) return "tag_counts/" .. flavor end Keys.tag = function(tag) return "tag/" .. tag end Keys.waiting_strand_job_priority = function() return 2000000 end -- remove the given job from the various queues local remove_from_queues = function(job_id, queue, strand) local tag = unpack(redis.call('HMGET', Keys.job(job_id), 'tag')) redis.call("SREM", Keys.tag(tag), job_id) local current_delta = -redis.call('ZREM', Keys.queue(queue), job_id) redis.call('ZREM', Keys.running_jobs(), job_id) local future_delta = -redis.call('ZREM', Keys.future_queue(queue), job_id) if current_delta ~= 0 then redis.call('ZINCRBY', Keys.tag_counts('current'), current_delta, tag) end local total_delta = current_delta + future_delta if total_delta ~= 0 then redis.call('ZINCRBY', Keys.tag_counts('all'), total_delta, tag) end local strand_key = Keys.strand(strand) if strand_key then redis.call('LREM', strand_key, 1, job_id) end end -- returns the id for the first job on the strand, or nil if none local strand_next_job_id = function(strand) local strand_key = Keys.strand(strand) if not strand_key then return nil end return redis.call('LRANGE', strand_key, 0, 0)[1] end -- returns next_in_strand -- whether this added job is at the front of the strand local add_to_strand = function(job_id, strand) local strand_key = Keys.strand(strand) if not strand_key then return end redis.call('RPUSH', strand_key, job_id) -- add to strand list local next_id = strand_next_job_id(strand) return next_id == job_id end -- add this given job to the correct queues based on its state and the current time -- also updates the tag counts and tag job lists local add_to_queues = function(job_id, queue, now) local run_at, priority, tag, strand = unpack(redis.call('HMGET', Keys.job(job_id), 'run_at', 'priority', 'tag', 'strand')) redis.call("SADD", Keys.tag(tag), job_id) if strand then local next_job_id = strand_next_job_id(strand) if next_job_id and next_job_id ~= job_id then priority = Keys.waiting_strand_job_priority() end end local current_delta = 0 local future_delta = 0 if run_at > now then future_delta = future_delta + redis.call('ZADD', Keys.future_queue(queue), run_at, job_id) current_delta = current_delta - redis.call('ZREM', Keys.queue(queue), job_id) else -- floor the run_at so we don't have a float in our float local sort_key = priority .. '.' .. math.floor(run_at) current_delta = current_delta + redis.call('ZADD', Keys.queue(queue), sort_key, job_id) future_delta = future_delta - redis.call('ZREM', Keys.future_queue(queue), job_id) end if current_delta ~= 0 then redis.call('ZINCRBY', Keys.tag_counts('current'), current_delta, tag) end local total_delta = current_delta + future_delta if total_delta ~= 0 then redis.call('ZINCRBY', Keys.tag_counts('all'), total_delta, tag) end end local job_exists = function(job_id) return job_id and redis.call('HGET', Keys.job(job_id), 'id') end -- find jobs available for running -- checks the future queue too, and moves and now-ready jobs -- into the current queue local find_available = function(queue, limit, offset, min_priority, max_priority, now) local ready_future_jobs = redis.call('ZRANGEBYSCORE', Keys.future_queue(queue), 0, now, 'limit', 0, limit) for i, job_id in ipairs(ready_future_jobs) do add_to_queues(job_id, queue, now) end if not min_priority or min_priority == '' then min_priority = '0' end if not max_priority or max_priority == '' then max_priority = "+inf" else max_priority = "(" .. (max_priority + 1) end local job_ids = redis.call('ZRANGEBYSCORE', Keys.queue(queue), min_priority, max_priority, 'limit', offset, limit) for idx = table.getn(job_ids), 1, -1 do local job_id = job_ids[idx] if not job_exists(job_id) then table.remove(job_ids, idx) redis.call('ZREM', Keys.queue(queue), job_id) end end return job_ids end -- "tickle" the strand, removing the given job_id and setting the job at the -- front of the strand as eligible to run, if it's not already local tickle_strand = function(job_id, strand, now) local strand_key = Keys.strand(strand) -- this LREM could be (relatively) slow if the strand is very large and this -- job isn't near the front. however, in normal usage, we only delete from the -- front. also the linked list is in memory, so even with thousands of jobs on -- the strand it'll be quite fast. -- -- alternatively we could make strands sorted sets, which would avoid a -- linear search to delete this job. jobs need to be sorted on insertion -- order though, and we're using GUIDs for keys here rather than an -- incrementing integer, so we'd have to use an artificial counter as the -- sort key (through `incrby strand_name` probably). redis.call('LREM', strand_key, 1, job_id) -- normally this loop will only run once, but we loop so that if there's any -- job ids on the strand that don't actually exist anymore, we'll throw them -- out and keep searching until we find a legit job or the strand is empty while true do local next_id = redis.call('LRANGE', strand_key, 0, 0)[1] if next_id == nil then break elseif job_exists(next_id) then -- technically jobs on the same strand can be in different queues, -- though that functionality isn't currently used local queue = redis.call('HGET', Keys.job(next_id), 'queue') add_to_queues(next_id, queue, now) break else redis.call('LPOP', strand_key) end end end local destroy_job = function(job_id, now) local queue, strand = unpack(redis.call('HMGET', Keys.job(job_id), 'queue', 'strand')) remove_from_queues(job_id, queue, strand) if Keys.strand(strand) then tickle_strand(job_id, strand, now) end redis.call('ZREM', Keys.failed_jobs(), job_id) redis.call('DEL', Keys.job(job_id)) end
agpl-3.0
lvdmaaten/nn
Replicate.lua
43
1690
local Replicate, parent = torch.class('nn.Replicate','nn.Module') function Replicate:__init(nf, dim, ndim) parent.__init(self) self.nfeatures = nf self.dim = dim or 1 self.ndim = ndim assert(self.dim > 0, "Can only replicate across positive integer dimensions.") end function Replicate:updateOutput(input) self.dim = self.dim or 1 --backwards compatible assert( self.dim <= input:dim()+1, "Not enough input dimensions to replicate along dimension " .. tostring(self.dim) .. ".") local batchOffset = self.ndim and input:dim() > self.ndim and 1 or 0 local rdim = self.dim + batchOffset local sz = torch.LongStorage(input:dim()+1) sz[rdim] = self.nfeatures for i = 1,input:dim() do local offset = 0 if i >= rdim then offset = 1 end sz[i+offset] = input:size(i) end local st = torch.LongStorage(input:dim()+1) st[rdim] = 0 for i = 1,input:dim() do local offset = 0 if i >= rdim then offset = 1 end st[i+offset] = input:stride(i) end self.output = input.new(input:storage(),input:storageOffset(),sz,st) return self.output end function Replicate:updateGradInput(input, gradOutput) self.gradInput:resizeAs(input):zero() local batchOffset = self.ndim and input:dim() > self.ndim and 1 or 0 local rdim = self.dim + batchOffset local sz = torch.LongStorage(input:dim()+1) sz[rdim] = 1 for i = 1,input:dim() do local offset = 0 if i >= rdim then offset = 1 end sz[i+offset] = input:size(i) end local gradInput = self.gradInput:view(sz) gradInput:sum(gradOutput, rdim) return self.gradInput end
bsd-3-clause
selaselah/thrift
test/lua/test_basic_server.lua
57
5557
-- Licensed to the Apache Software Foundation (ASF) under one -- or more contributor license agreements. See the NOTICE file -- distributed with this work for additional information -- regarding copyright ownership. The ASF licenses this file -- to you under the Apache License, Version 2.0 (the -- "License"); you may not use this file except in compliance -- with the License. You may obtain a copy of the License at -- http://www.apache.org/licenses/LICENSE-2.0 -- Unless required by applicable law or agreed to in writing, -- software distributed under the License is distributed on an -- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -- KIND, either express or implied. See the License for the -- specific language governing permissions and limitations -- under the License. require('ThriftTest_ThriftTest') require('TSocket') require('TFramedTransport') require('TBinaryProtocol') require('TServer') require('liblualongnumber') -------------------------------------------------------------------------------- -- Handler TestHandler = ThriftTestIface:new{} -- Stops the server function TestHandler:testVoid() self.__server:stop() end function TestHandler:testString(str) return str end function TestHandler:testByte(byte) return byte end function TestHandler:testI32(i32) return i32 end function TestHandler:testI64(i64) return i64 end function TestHandler:testDouble(d) return d end function TestHandler:testBinary(by) return by end function TestHandler:testStruct(thing) return thing end -------------------------------------------------------------------------------- -- Test local server function teardown() if server then server:close() end end function testBasicServer() -- Handler & Processor local handler = TestHandler:new{} assert(handler, 'Failed to create handler') local processor = ThriftTestProcessor:new{ handler = handler } assert(processor, 'Failed to create processor') -- Server Socket local socket = TServerSocket:new{ port = 9090 } assert(socket, 'Failed to create server socket') -- Transport & Factory local trans_factory = TFramedTransportFactory:new{} assert(trans_factory, 'Failed to create framed transport factory') local prot_factory = TBinaryProtocolFactory:new{} assert(prot_factory, 'Failed to create binary protocol factory') -- Simple Server server = TSimpleServer:new{ processor = processor, serverTransport = socket, transportFactory = trans_factory, protocolFactory = prot_factory } assert(server, 'Failed to create server') -- Serve server:serve() server = nil end testBasicServer() teardown()
apache-2.0
Sean-Der/thrift
test/lua/test_basic_server.lua
57
5557
-- Licensed to the Apache Software Foundation (ASF) under one -- or more contributor license agreements. See the NOTICE file -- distributed with this work for additional information -- regarding copyright ownership. The ASF licenses this file -- to you under the Apache License, Version 2.0 (the -- "License"); you may not use this file except in compliance -- with the License. You may obtain a copy of the License at -- http://www.apache.org/licenses/LICENSE-2.0 -- Unless required by applicable law or agreed to in writing, -- software distributed under the License is distributed on an -- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -- KIND, either express or implied. See the License for the -- specific language governing permissions and limitations -- under the License. require('ThriftTest_ThriftTest') require('TSocket') require('TFramedTransport') require('TBinaryProtocol') require('TServer') require('liblualongnumber') -------------------------------------------------------------------------------- -- Handler TestHandler = ThriftTestIface:new{} -- Stops the server function TestHandler:testVoid() self.__server:stop() end function TestHandler:testString(str) return str end function TestHandler:testByte(byte) return byte end function TestHandler:testI32(i32) return i32 end function TestHandler:testI64(i64) return i64 end function TestHandler:testDouble(d) return d end function TestHandler:testBinary(by) return by end function TestHandler:testStruct(thing) return thing end -------------------------------------------------------------------------------- -- Test local server function teardown() if server then server:close() end end function testBasicServer() -- Handler & Processor local handler = TestHandler:new{} assert(handler, 'Failed to create handler') local processor = ThriftTestProcessor:new{ handler = handler } assert(processor, 'Failed to create processor') -- Server Socket local socket = TServerSocket:new{ port = 9090 } assert(socket, 'Failed to create server socket') -- Transport & Factory local trans_factory = TFramedTransportFactory:new{} assert(trans_factory, 'Failed to create framed transport factory') local prot_factory = TBinaryProtocolFactory:new{} assert(prot_factory, 'Failed to create binary protocol factory') -- Simple Server server = TSimpleServer:new{ processor = processor, serverTransport = socket, transportFactory = trans_factory, protocolFactory = prot_factory } assert(server, 'Failed to create server') -- Serve server:serve() server = nil end testBasicServer() teardown()
apache-2.0
kitala1/darkstar
scripts/zones/Southern_San_dOria_[S]/npcs/HomePoint#1.lua
12
1260
----------------------------------- -- Area: Southern_San_dOria_[S] -- NPC: HomePoint#1 -- @pos ----------------------------------- package.loaded["scripts/zones/Southern_San_dOria_[S]/TextIDs"] = nil; require("scripts/globals/settings"); require("scripts/zones/Southern_San_dOria_[S]/TextIDs"); require("scripts/globals/homepoint"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) homepointMenu( player, 0x21fc, 68); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); if(csid == 0x21fc) then if (option == 1) then player:setHomePoint(); player:messageSpecial(HOMEPOINT_SET); else hpTeleport( player, option); end end end;
gpl-3.0
kitala1/darkstar
scripts/globals/items/bowl_of_witch_stew.lua
35
1461
----------------------------------------- -- ID: 4344 -- Item: witch_stew -- Food Effect: 4hours, All Races ----------------------------------------- -- Magic Points 45 -- Strength -1 -- Mind 4 -- MP Recovered While Healing 4 -- Enmity -4 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,14400,4344); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_MP, 45); target:addMod(MOD_STR, -1); target:addMod(MOD_MND, 4); target:addMod(MOD_MPHEAL, 4); target:addMod(MOD_ENMITY, -4); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_MP, 45); target:delMod(MOD_STR, -1); target:delMod(MOD_MND, 4); target:delMod(MOD_MPHEAL, 4); target:delMod(MOD_ENMITY, -4); end;
gpl-3.0
kitala1/darkstar
scripts/zones/Lower_Delkfutts_Tower/Zone.lua
13
3674
----------------------------------- -- -- Zone: Lower_Delkfutts_Tower (184) -- ----------------------------------- package.loaded["scripts/zones/Lower_Delkfutts_Tower/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/zone"); require("scripts/globals/missions"); require("scripts/zones/Lower_Delkfutts_Tower/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) local tomes = {17531228,17531229,17531230}; SetGroundsTome(tomes); zone:registerRegion(1, 403, -34, 83, 409, -33, 89); -- Third Floor G-6 porter to Middle Delkfutt's Tower zone:registerRegion(2, 390, -34, -49, 397, -33, -43); -- Third Floor F-10 porter to Middle Delkfutt's Tower "1" end; ----------------------------------- -- onConquestUpdate ----------------------------------- function onConquestUpdate(zone, updatetype) local players = zone:getPlayers(); for name, player in pairs(players) do conquestUpdate(zone, player, updatetype, CONQUEST_BASE); end end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) local cs = -1; if((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then player:setPos(460.022,-1.77,-103.442,188); end if(player:getCurrentMission(ZILART) == RETURN_TO_DELKFUTTS_TOWER and player:getVar("ZilartStatus") <= 1) then cs = 0x000f; elseif(ENABLE_COP == 1 and prevZone == 126 and player:getCurrentMission(COP) == ANCIENT_FLAMES_BECKON) then cs = 0x0016; elseif(player:getCurrentMission(ACP) == BORN_OF_HER_NIGHTMARES and prevZone == 126) then cs = 0x0022; end return cs; end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) switch (region:GetRegionID()): caseof { [1] = function (x) player:setVar("option",1); player:startEvent(4); end, [2] = function (x) player:setVar("option",2); player:startEvent(4); end, } end; ----------------------------------- -- onRegionLeave ----------------------------------- function onRegionLeave(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if(csid == 0x000f) then player:setVar("ZilartStatus",2); elseif(csid == 0x0004 and option == 1) then if(player:getVar("option") == 1) then player:setPos(-28, -48, 80, 111, 157); else player:setPos(-51, -48, -40, 246, 157); end player:setVar("option",0); elseif(csid == 0x0004 and (option == 0 or option >= 3)) then player:setVar("option",0); elseif(csid == 0x0016) then player:startEvent(0x0024); elseif(csid == 0x0022) then player:completeMission(ACP,BORN_OF_HER_NIGHTMARES); player:addMission(ACP,BANISHING_THE_ECHO); elseif(csid == 0x0024) then player:startEvent(0x0025); elseif(csid == 0x0025) then player:startEvent(0x0026); elseif(csid == 0x0026) then player:startEvent(0x0027); elseif(csid == 0x0027) then player:completeMission(COP,ANCIENT_FLAMES_BECKON); player:addMission(COP,THE_RITES_OF_LIFE); player:setVar("COP1",1); end end;
gpl-3.0
kitala1/darkstar
scripts/zones/Windurst_Waters_[S]/npcs/Pebul-Tabul.lua
38
1048
----------------------------------- -- Area: Windurst Waters (S) -- NPC: Pebul-Tabul -- Type: Standard NPC -- @zone: 94 -- @pos -68.500 -4.5 3.694 -- -- 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(0x0195); 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
apletnev/koreader
frontend/apps/filemanager/filemanager.lua
1
29391
local Blitbuffer = require("ffi/blitbuffer") local Button = require("ui/widget/button") local ButtonDialogTitle = require("ui/widget/buttondialogtitle") local CenterContainer = require("ui/widget/container/centercontainer") local ConfirmBox = require("ui/widget/confirmbox") local Device = require("device") local DocSettings = require("docsettings") local DocumentRegistry = require("document/documentregistry") local Event = require("ui/event") local FileChooser = require("ui/widget/filechooser") local FileManagerBookInfo = require("apps/filemanager/filemanagerbookinfo") local FileManagerConverter = require("apps/filemanager/filemanagerconverter") local FileManagerHistory = require("apps/filemanager/filemanagerhistory") local FileManagerMenu = require("apps/filemanager/filemanagermenu") local Font = require("ui/font") local FrameContainer = require("ui/widget/container/framecontainer") local HorizontalGroup = require("ui/widget/horizontalgroup") local IconButton = require("ui/widget/iconbutton") local InfoMessage = require("ui/widget/infomessage") local InputContainer = require("ui/widget/container/inputcontainer") local InputDialog = require("ui/widget/inputdialog") local PluginLoader = require("pluginloader") local ReaderDictionary = require("apps/reader/modules/readerdictionary") local ReaderUI = require("apps/reader/readerui") local ReaderWikipedia = require("apps/reader/modules/readerwikipedia") local RenderText = require("ui/rendertext") local Screenshoter = require("ui/widget/screenshoter") local Size = require("ui/size") local TextWidget = require("ui/widget/textwidget") local VerticalGroup = require("ui/widget/verticalgroup") local VerticalSpan = require("ui/widget/verticalspan") local UIManager = require("ui/uimanager") local filemanagerutil = require("apps/filemanager/filemanagerutil") local lfs = require("libs/libkoreader-lfs") local logger = require("logger") local util = require("ffi/util") local _ = require("gettext") local Screen = Device.screen local T = require("ffi/util").template local function restoreScreenMode() local screen_mode = G_reader_settings:readSetting("fm_screen_mode") if Screen:getScreenMode() ~= screen_mode then Screen:setScreenMode(screen_mode or "portrait") end end local function truncatePath(text) local screen_width = Screen:getWidth() local face = Font:getFace("xx_smallinfofont") -- we want to truncate text on the left, so work with the reverse of text (which is fine as we don't use kerning) local reversed_text = require("util").utf8Reverse(text) local txt_width = RenderText:sizeUtf8Text(0, screen_width, face, reversed_text, false, false).x if screen_width - 2 * Size.padding.small < txt_width then reversed_text = RenderText:truncateTextByWidth(reversed_text, face, screen_width - 2 * Size.padding.small, false, false) text = require("util").utf8Reverse(reversed_text) end return text end local FileManager = InputContainer:extend{ title = _("KOReader File Browser"), root_path = lfs.currentdir(), onExit = function() end, mv_bin = Device:isAndroid() and "/system/bin/mv" or "/bin/mv", cp_bin = Device:isAndroid() and "/system/bin/cp" or "/bin/cp", mkdir_bin = Device:isAndroid() and "/system/bin/mkdir" or "/bin/mkdir", } function FileManager:init() self.show_parent = self.show_parent or self local icon_size = Screen:scaleBySize(35) local home_button = IconButton:new{ icon_file = "resources/icons/appbar.home.png", scale_for_dpi = false, width = icon_size, height = icon_size, padding = Size.padding.default, padding_left = Size.padding.large, padding_right = Size.padding.large, padding_bottom = 0, callback = function() self:goHome() end, hold_callback = function() self:setHome() end, } local plus_button = IconButton:new{ icon_file = "resources/icons/appbar.plus.png", scale_for_dpi = false, width = icon_size, height = icon_size, padding = Size.padding.default, padding_left = Size.padding.large, padding_right = Size.padding.large, padding_bottom = 0, callback = function() self:tapPlus() end, } self.path_text = TextWidget:new{ face = Font:getFace("xx_smallinfofont"), text = truncatePath(filemanagerutil.abbreviate(self.root_path)), } self.banner = FrameContainer:new{ padding = 0, bordersize = 0, VerticalGroup:new { CenterContainer:new { dimen = { w = Screen:getWidth(), h = nil }, HorizontalGroup:new { home_button, VerticalGroup:new { Button:new { readonly = true, bordersize = 0, padding = 0, text_font_bold = false, text_font_face = "smalltfont", text_font_size = 24, text = self.title, width = Screen:getWidth() - 2 * icon_size - 4 * Size.padding.large, }, }, plus_button, } }, CenterContainer:new{ dimen = { w = Screen:getWidth(), h = nil }, self.path_text, }, VerticalSpan:new{ width = Screen:scaleBySize(5) }, } } local g_show_hidden = G_reader_settings:readSetting("show_hidden") local show_hidden = g_show_hidden == nil and DSHOWHIDDENFILES or g_show_hidden local file_chooser = FileChooser:new{ -- remeber to adjust the height when new item is added to the group path = self.root_path, focused_path = self.focused_file, collate = G_reader_settings:readSetting("collate") or "strcoll", reverse_collate = G_reader_settings:isTrue("reverse_collate"), show_parent = self.show_parent, show_hidden = show_hidden, width = Screen:getWidth(), height = Screen:getHeight() - self.banner:getSize().h, is_popout = false, is_borderless = true, has_close_button = true, perpage = G_reader_settings:readSetting("items_per_page"), file_filter = function(filename) if DocumentRegistry:hasProvider(filename) then return true end end, close_callback = function() return self:onClose() end, } self.file_chooser = file_chooser self.focused_file = nil -- use it only once function file_chooser:onPathChanged(path) -- luacheck: ignore FileManager.instance.path_text:setText(truncatePath(filemanagerutil.abbreviate(path))) UIManager:setDirty(FileManager.instance, function() return "ui", FileManager.instance.path_text.dimen end) return true end function file_chooser:onFileSelect(file) -- luacheck: ignore FileManager.instance:onClose() ReaderUI:showReader(file) return true end local copyFile = function(file) self:copyFile(file) end local pasteHere = function(file) self:pasteHere(file) end local cutFile = function(file) self:cutFile(file) end local deleteFile = function(file) self:deleteFile(file) end local renameFile = function(file) self:renameFile(file) end local setHome = function(path) self:setHome(path) end local fileManager = self function file_chooser:onFileHold(file) -- luacheck: ignore local buttons = { { { text = _("Copy"), callback = function() copyFile(file) UIManager:close(self.file_dialog) end, }, { text = _("Paste"), enabled = fileManager.clipboard and true or false, callback = function() pasteHere(file) UIManager:close(self.file_dialog) end, }, { text = _("Purge .sdr"), enabled = DocSettings:hasSidecarFile(util.realpath(file)), callback = function() UIManager:show(ConfirmBox:new{ text = util.template(_("Purge .sdr to reset settings for this document?\n\n%1"), self.file_dialog.title), ok_text = _("Purge"), ok_callback = function() filemanagerutil.purgeSettings(file) filemanagerutil.removeFileFromHistoryIfWanted(file) self:refreshPath() UIManager:close(self.file_dialog) end, }) end, }, }, { { text = _("Cut"), callback = function() cutFile(file) UIManager:close(self.file_dialog) end, }, { text = _("Delete"), callback = function() UIManager:show(ConfirmBox:new{ text = _("Are you sure that you want to delete this file?\n") .. file .. ("\n") .. _("If you delete a file, it is permanently lost."), ok_text = _("Delete"), ok_callback = function() deleteFile(file) filemanagerutil.removeFileFromHistoryIfWanted(file) self:refreshPath() UIManager:close(self.file_dialog) end, }) end, }, { text = _("Rename"), callback = function() UIManager:close(self.file_dialog) fileManager.rename_dialog = InputDialog:new{ title = _("Rename file"), input = util.basename(file), buttons = {{ { text = _("Cancel"), enabled = true, callback = function() UIManager:close(fileManager.rename_dialog) end, }, { text = _("Rename"), enabled = true, callback = function() renameFile(file) self:refreshPath() UIManager:close(fileManager.rename_dialog) end, }, }}, } fileManager.rename_dialog:onShowKeyboard() UIManager:show(fileManager.rename_dialog) end, } }, -- a little hack to get visual functionality grouping {}, { { text = _("Open with…"), enabled = lfs.attributes(file, "mode") == "file" and #(DocumentRegistry:getProviders(file)) > 1, callback = function() UIManager:close(self.file_dialog) DocumentRegistry:showSetProviderButtons(file, FileManager.instance, self, ReaderUI) end, }, { text = _("Convert"), enabled = lfs.attributes(file, "mode") == "file" and FileManagerConverter:isSupported(file), callback = function() UIManager:close(self.file_dialog) FileManagerConverter:showConvertButtons(file, self) end, }, { text = _("Book information"), enabled = FileManagerBookInfo:isSupported(file), callback = function() FileManagerBookInfo:show(file) UIManager:close(self.file_dialog) end, }, }, } if lfs.attributes(file, "mode") == "directory" then local realpath = util.realpath(file) table.insert(buttons, { { text = _("Set as HOME directory"), callback = function() setHome(realpath) UIManager:close(self.file_dialog) end } }) end self.file_dialog = ButtonDialogTitle:new{ title = file:match("([^/]+)$"), title_align = "center", buttons = buttons, } UIManager:show(self.file_dialog) return true end self.layout = VerticalGroup:new{ self.banner, file_chooser, } local fm_ui = FrameContainer:new{ padding = 0, bordersize = 0, background = Blitbuffer.COLOR_WHITE, self.layout, } self[1] = fm_ui self.menu = FileManagerMenu:new{ ui = self } self.active_widgets = { Screenshoter:new{ prefix = 'FileManager' } } table.insert(self, self.menu) table.insert(self, FileManagerHistory:new{ ui = self, }) table.insert(self, ReaderDictionary:new{ ui = self }) table.insert(self, ReaderWikipedia:new{ ui = self }) -- koreader plugins for _,plugin_module in ipairs(PluginLoader:loadPlugins()) do if not plugin_module.is_doc_only then local ok, plugin_or_err = PluginLoader:createPluginInstance( plugin_module, { ui = self, }) -- Keep references to the modules which do not register into menu. if ok then table.insert(self, plugin_or_err) logger.info("FM loaded plugin", plugin_module.name, "at", plugin_module.path) end end end if Device:hasKeys() then self.key_events.Close = { {"Home"}, doc = "Close file manager" } end self:handleEvent(Event:new("SetDimensions", self.dimen)) end function FileManager:tapPlus() local buttons = { { { text = _("New folder"), callback = function() UIManager:close(self.file_dialog) self.input_dialog = InputDialog:new{ title = _("Create new folder"), input_type = "text", buttons = { { { text = _("Cancel"), callback = function() self:closeInputDialog() end, }, { text = _("Create"), callback = function() self:closeInputDialog() local new_folder = self.input_dialog:getInputText() if new_folder and new_folder ~= "" then self:createFolder(self.file_chooser.path, new_folder) end end, }, } }, } self.input_dialog:onShowKeyboard() UIManager:show(self.input_dialog) end, }, }, { { text = _("Paste"), enabled = self.clipboard and true or false, callback = function() self:pasteHere(self.file_chooser.path) self:onRefresh() UIManager:close(self.file_dialog) end, }, }, { { text = _("Set as HOME directory"), callback = function() self:setHome(self.file_chooser.path) UIManager:close(self.file_dialog) end } }, { { text = _("Go to HOME directory"), callback = function() self:goHome() UIManager:close(self.file_dialog) end } } } self.file_dialog = ButtonDialogTitle:new{ title = filemanagerutil.abbreviate(self.file_chooser.path), title_align = "center", buttons = buttons, } UIManager:show(self.file_dialog) end function FileManager:reinit(path, focused_file) self.dimen = Screen:getSize() -- backup the root path and path items self.root_path = path or self.file_chooser.path local path_items_backup = {} for k, v in pairs(self.file_chooser.path_items) do path_items_backup[k] = v end -- reinit filemanager self.focused_file = focused_file self:init() self.file_chooser.path_items = path_items_backup -- self:init() has already done file_chooser:refreshPath(), so this one -- looks like not necessary (cheap with classic mode, less cheap with -- CoverBrowser plugin's cover image renderings) -- self:onRefresh() end function FileManager:toggleHiddenFiles() self.file_chooser:toggleHiddenFiles() G_reader_settings:saveSetting("show_hidden", self.file_chooser.show_hidden) end function FileManager:setCollate(collate) self.file_chooser:setCollate(collate) G_reader_settings:saveSetting("collate", self.file_chooser.collate) end function FileManager:toggleReverseCollate() self.file_chooser:toggleReverseCollate() G_reader_settings:saveSetting("reverse_collate", self.file_chooser.reverse_collate) end function FileManager:onClose() logger.dbg("close filemanager") G_reader_settings:flush() UIManager:close(self) if self.onExit then self:onExit() end return true end function FileManager:onRefresh() self.file_chooser:refreshPath() return true end function FileManager:goHome() local home_dir = G_reader_settings:readSetting("home_dir") if home_dir then self.file_chooser:changeToPath(home_dir) else self:setHome() end return true end function FileManager:setHome(path) path = path or self.file_chooser.path UIManager:show(ConfirmBox:new{ text = util.template(_("Set '%1' as HOME directory?"), path), ok_text = _("Set as HOME"), ok_callback = function() G_reader_settings:saveSetting("home_dir", path) end, }) return true end function FileManager:copyFile(file) self.cutfile = false self.clipboard = file end function FileManager:cutFile(file) self.cutfile = true self.clipboard = file end function FileManager:pasteHere(file) if self.clipboard then file = util.realpath(file) local orig = util.realpath(self.clipboard) local dest = lfs.attributes(file, "mode") == "directory" and file or file:match("(.*/)") local function infoCopyFile() -- if we copy a file, also copy its sidecar directory if DocSettings:hasSidecarFile(orig) then util.execute(self.cp_bin, "-r", DocSettings:getSidecarDir(orig), dest) end if util.execute(self.cp_bin, "-r", orig, dest) == 0 then UIManager:show(InfoMessage:new { text = T(_("Copied to: %1"), dest), timeout = 2, }) else UIManager:show(InfoMessage:new { text = T(_("An error occurred while trying to copy %1"), orig), timeout = 2, }) end end local function infoMoveFile() -- if we move a file, also move its sidecar directory if DocSettings:hasSidecarFile(orig) then self:moveFile(DocSettings:getSidecarDir(orig), dest) -- dest is always a directory end if self:moveFile(orig, dest) then --update history local dest_file = string.format("%s/%s", dest, util.basename(orig)) require("readhistory"):updateItemByPath(orig, dest_file) --update last open file if G_reader_settings:readSetting("lastfile") == orig then G_reader_settings:saveSetting("lastfile", dest_file) end UIManager:show(InfoMessage:new { text = T(_("Moved to: %1"), dest), timeout = 2, }) else UIManager:show(InfoMessage:new { text = T(_("An error occurred while trying to move %1"), orig), timeout = 2, }) end util.execute(self.cp_bin, "-r", orig, dest) end local info_file if self.cutfile then info_file = infoMoveFile else info_file = infoCopyFile end local basename = util.basename(self.clipboard) local mode = lfs.attributes(string.format("%s/%s", dest, basename), "mode") if mode == "file" or mode == "directory" then local text if mode == "file" then text = T(_("The file %1 already exists. Do you want to overwrite it?"), basename) else text = T(_("The directory %1 already exists. Do you want to overwrite it?"), basename) end UIManager:show(ConfirmBox:new { text = text, ok_text = _("Overwrite"), ok_callback = function() info_file() self:onRefresh() end, }) else info_file() self:onRefresh() end end end function FileManager:createFolder(curr_folder, new_folder) local folder = string.format("%s/%s", curr_folder, new_folder) local code = util.execute(self.mkdir_bin, folder) local text if code == 0 then self:onRefresh() text = T(_("Folder created:\n%1"), new_folder) else text = _("The folder has not been created.") end UIManager:show(InfoMessage:new{ text = text, timeout = 2, }) end function FileManager:deleteFile(file) local ok, err local file_abs_path = util.realpath(file) if file_abs_path == nil then UIManager:show(InfoMessage:new{ text = util.template(_("File %1 not found"), file), }) return end local is_doc = DocumentRegistry:hasProvider(file_abs_path) if lfs.attributes(file_abs_path, "mode") == "file" then ok, err = os.remove(file_abs_path) else ok, err = util.purgeDir(file_abs_path) end if ok and not err then if is_doc then DocSettings:open(file):purge() end UIManager:show(InfoMessage:new{ text = util.template(_("Deleted %1"), file), timeout = 2, }) else UIManager:show(InfoMessage:new{ text = util.template(_("An error occurred while trying to delete %1"), file), }) end end function FileManager:renameFile(file) if util.basename(file) ~= self.rename_dialog:getInputText() then local dest = util.joinPath(util.dirname(file), self.rename_dialog:getInputText()) if self:moveFile(file, dest) then if lfs.attributes(dest, "mode") == "file" then local doc = require("docsettings") local move_history = true; if lfs.attributes(doc:getHistoryPath(file), "mode") == "file" and not self:moveFile(doc:getHistoryPath(file), doc:getHistoryPath(dest)) then move_history = false end if lfs.attributes(doc:getSidecarDir(file), "mode") == "directory" and not self:moveFile(doc:getSidecarDir(file), doc:getSidecarDir(dest)) then move_history = false end if move_history then UIManager:show(InfoMessage:new{ text = util.template(_("Renamed from %1 to %2"), file, dest), timeout = 2, }) else UIManager:show(InfoMessage:new{ text = util.template( _("Failed to move history data of %1 to %2.\nThe reading history may be lost."), file, dest), }) end end else UIManager:show(InfoMessage:new{ text = util.template( _("Failed to rename from %1 to %2"), file, dest), }) end end end function FileManager:getSortingMenuTable() local fm = self local collates = { strcoll = {_("title"), _("Sort by title")}, access = {_("date read"), _("Sort by last read date")}, change = {_("date added"), _("Sort by date added")}, modification = {_("date modified"), _("Sort by date modified")}, size = {_("size"), _("Sort by size")}, type = {_("type"), _("Sort by type")}, percent_unopened_first = {_("percent - unopened first"), _("Sort by percent - unopened first")}, percent_unopened_last = {_("percent - unopened last"), _("Sort by percent - unopened last")}, } local set_collate_table = function(collate) return { text = collates[collate][2], checked_func = function() return fm.file_chooser.collate == collate end, callback = function() fm:setCollate(collate) end, } end return { text_func = function() return util.template( _("Sort by: %1"), collates[fm.file_chooser.collate][1] ) end, sub_item_table = { set_collate_table("strcoll"), set_collate_table("access"), set_collate_table("change"), set_collate_table("modification"), set_collate_table("size"), set_collate_table("type"), set_collate_table("percent_unopened_first"), set_collate_table("percent_unopened_last"), } } end function FileManager:getStartWithMenuTable() local start_with_setting = G_reader_settings:readSetting("start_with") or "filemanager" local start_withs = { filemanager = {_("file browser"), _("Start with file browser")}, history = {_("history"), _("Start with history")}, last = {_("last file"), _("Start with last file")}, } local set_sw_table = function(start_with) return { text = start_withs[start_with][2], checked_func = function() return start_with_setting == start_with end, callback = function() start_with_setting = start_with G_reader_settings:saveSetting("start_with", start_with) end, } end return { text_func = function() return util.template( _("Start with: %1"), start_withs[start_with_setting][1] ) end, sub_item_table = { set_sw_table("filemanager"), set_sw_table("history"), set_sw_table("last"), } } end function FileManager:showFiles(path, focused_file) path = path or G_reader_settings:readSetting("lastdir") or filemanagerutil.getDefaultDir() G_reader_settings:saveSetting("lastdir", path) restoreScreenMode() local file_manager = FileManager:new{ dimen = Screen:getSize(), root_path = path, focused_file = focused_file, onExit = function() self.instance = nil end } UIManager:show(file_manager) self.instance = file_manager end --[[ A shortcut to execute mv command (self.mv_bin) with from and to as parameters. Returns a boolean value to indicate the result of mv command. --]] function FileManager:moveFile(from, to) return util.execute(self.mv_bin, from, to) == 0 end return FileManager
agpl-3.0
kitala1/darkstar
scripts/zones/North_Gustaberg_[S]/npcs/Barricade.lua
10
1107
----------------------------------- -- Area: North Gustaberg (S) (I-6) -- NPC: Barricade -- Involved in Quests: The Fighting Fourth ----------------------------------- package.loaded["scripts/zones/North_Gustaberg_[S]/TextIDs"] = nil; package.loaded["scripts/globals/quests"] = nil; ----------------------------------- require("scripts/globals/quests"); require("scripts/zones/North_Gustaberg_[S]/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:getQuestStatus(CRYSTAL_WAR,THE_FIGHTING_FOURTH) == QUEST_ACCEPTED and player:getVar("THE_FIGHTING_FOURTH") == 2) then player:startEvent(0x006A) end end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); if(csid == 0x006A) then player:setVar("THE_FIGHTING_FOURTH",3); end end;
gpl-3.0
ioiasff/erq
plugins/invite.lua
1111
1195
do local function callbackres(extra, success, result) -- Callback for res_user in line 27 local user = 'user#id'..result.id local chat = 'chat#id'..extra.chatid if is_banned(result.id, extra.chatid) then -- Ignore bans send_large_msg(chat, 'User is banned.') elseif is_gbanned(result.id) then -- Ignore globall bans send_large_msg(chat, 'User is globaly banned.') else chat_add_user(chat, user, ok_cb, false) -- Add user on chat end end function run(msg, matches) local data = load_data(_config.moderation.data) if not is_realm(msg) then if data[tostring(msg.to.id)]['settings']['lock_member'] == 'yes' and not is_admin(msg) then return 'Group is private.' end end if msg.to.type ~= 'chat' then return end if not is_momod(msg) then return end --if not is_admin(msg) then -- For admins only ! --return 'Only admins can invite.' --end local cbres_extra = {chatid = msg.to.id} local username = matches[1] local username = username:gsub("@","") res_user(username, callbackres, cbres_extra) end return { patterns = { "^[!/]invite (.*)$" }, run = run } end
gpl-2.0
kitala1/darkstar
scripts/zones/Heavens_Tower/npcs/Kupipi.lua
6
6505
----------------------------------- -- Area: Heaven's Tower -- NPC: Kupipi -- Involved in Mission 2-3 -- Involved in Quest: Riding on the Clouds -- @pos 2 0.1 30 242 ----------------------------------- package.loaded["scripts/zones/Heavens_Tower/TextIDs"] = nil; ----------------------------------- require("scripts/globals/keyitems"); require("scripts/globals/quests"); require("scripts/globals/missions"); require("scripts/zones/Heavens_Tower/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if(player:getQuestStatus(JEUNO,RIDING_ON_THE_CLOUDS) == QUEST_ACCEPTED and player:getVar("ridingOnTheClouds_4") == 8) then if(trade:hasItemQty(1127,1) and trade:getItemCount() == 1) then -- Trade Kindred seal player:setVar("ridingOnTheClouds_4",0); player:tradeComplete(); player:addKeyItem(SPIRITED_STONE); player:messageSpecial(KEYITEM_OBTAINED,SPIRITED_STONE); end end if(trade:hasItemQty(4365,1) and trade:getItemCount() == 1 and player:getNation() == WINDURST and player:getRank() >= 2 and player:hasKeyItem(PORTAL_CHARM) == false) then -- Trade Rolanberry if(player:hasCompletedMission(WINDURST,WRITTEN_IN_THE_STARS)) then player:startEvent(0x0123); -- Qualifies for the reward immediately else player:startEvent(0x0124); -- Kupipi owes you the portal charm later end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local pNation = player:getNation(); local currentMission = player:getCurrentMission(pNation); local MissionStatus = player:getVar("MissionStatus"); if(pNation == SANDORIA) then -- San d'Oria Mission 2-3 Part I - Windurst > Bastok if(currentMission == JOURNEY_TO_WINDURST) then if(MissionStatus == 4) then player:startEvent(0x00ee,1,1,1,1,pNation); elseif(MissionStatus == 5) then player:startEvent(0x00f0); elseif(MissionStatus == 6) then player:startEvent(0x00f1); end -- San d'Oria Mission 2-3 Part II - Bastok > Windurst elseif(currentMission == JOURNEY_TO_WINDURST2) then if(MissionStatus == 7) then player:startEvent(0x00f2,1,1,1,1,0); elseif(MissionStatus == 8) then player:startEvent(0x00f3); elseif(MissionStatus == 9) then player:startEvent(0x00f6); elseif(MissionStatus == 10) then player:startEvent(0x00f7); end else player:startEvent(0x00fb); end elseif(pNation == BASTOK) then -- Bastok Mission 2-3 Part I - Windurst > San d'Oria if(currentMission == THE_EMISSARY_WINDURST) then if(MissionStatus == 3) then player:startEvent(0x00ee,1,1,1,1,pNation); elseif(MissionStatus <= 5) then player:startEvent(0x00f0); elseif(MissionStatus == 6) then player:startEvent(0x00f1); end -- Bastok Mission 2-3 Part II - San d'Oria > Windurst elseif(currentMission == THE_EMISSARY_WINDURST2) then if(MissionStatus == 7) then player:startEvent(0x00f2,1,1,1,1,pNation); elseif(MissionStatus == 8) then player:startEvent(0x00f3); elseif(MissionStatus == 9) then player:startEvent(0x00f4); elseif(MissionStatus == 10) then player:startEvent(0x00f5); end else player:startEvent(0x00fb); end elseif(pNation == WINDURST) then if(currentMission == THE_THREE_KINGDOMS and MissionStatus == 0) then player:startEvent(0x005F,0,0,0,LETTER_TO_THE_CONSULS_WINDURST); elseif(currentMission == THE_THREE_KINGDOMS and MissionStatus == 11) then player:startEvent(0x0065,0,0,ADVENTURERS_CERTIFICATE); elseif(currentMission == THE_THREE_KINGDOMS) then player:startEvent(0x0061); elseif(currentMission == TO_EACH_HIS_OWN_RIGHT and MissionStatus == 0) then player:startEvent(0x0067,0,0,STARWAY_STAIRWAY_BAUBLE); elseif(currentMission == TO_EACH_HIS_OWN_RIGHT and MissionStatus == 1) then player:startEvent(0x0068); elseif(player:getCurrentMission(WINDURST) == THE_JESTER_WHO_D_BE_KING and MissionStatus == 3) then player:startEvent(0x0146); elseif(player:hasCompletedMission(WINDURST,WRITTEN_IN_THE_STARS) and player:getVar("OwesPortalCharm") == 1) then player:startEvent(0x0125); -- Kupipi repays your favor else player:startEvent(0x00fb); end else player:startEvent(0x00fb); 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 == 0x00ee) then if(player:getNation() == BASTOK) then player:setVar("MissionStatus",4); player:addKeyItem(SWORD_OFFERING); player:messageSpecial(KEYITEM_OBTAINED,SWORD_OFFERING); else player:setVar("MissionStatus",5); player:addKeyItem(SHIELD_OFFERING); player:messageSpecial(KEYITEM_OBTAINED,SHIELD_OFFERING); end elseif(csid == 0x00f4 or csid == 0x00f6) then player:setVar("MissionStatus",10); elseif(csid == 0x00f2) then player:addKeyItem(DARK_KEY); player:messageSpecial(KEYITEM_OBTAINED,DARK_KEY); player:setVar("MissionStatus",8); elseif(csid == 0x005F) then player:setVar("MissionStatus",1); player:addKeyItem(LETTER_TO_THE_CONSULS_WINDURST); player:messageSpecial(KEYITEM_OBTAINED,LETTER_TO_THE_CONSULS_WINDURST); elseif(csid == 0x0067) then player:setVar("MissionStatus",1); player:addKeyItem(STARWAY_STAIRWAY_BAUBLE); player:messageSpecial(KEYITEM_OBTAINED,STARWAY_STAIRWAY_BAUBLE); elseif(csid == 0x0065) then finishMissionTimeline(player,1,csid,option); elseif(csid == 0x0123) then -- All condition met, grant Portal Charm player:tradeComplete(); player:addKeyItem(PORTAL_CHARM); player:messageSpecial(KEYITEM_OBTAINED,PORTAL_CHARM); elseif(csid == 0x0124) then -- Traded rolanberry, but not all conditions met player:tradeComplete(); player:setVar("OwesPortalCharm",1); elseif(csid == 0x0125) then -- Traded rolanberry before, and all conditions are now met player:setVar("OwesPortalCharm",0); player:addKeyItem(PORTAL_CHARM); player:messageSpecial(KEYITEM_OBTAINED,PORTAL_CHARM); elseif(csid == 0x0146) then player:setVar("MissionStatus",4); end end;
gpl-3.0
kitala1/darkstar
scripts/zones/Batallia_Downs/npcs/Cavernous_Maw.lua
13
2359
----------------------------------- -- Area: Batallia Downs -- NPC: Cavernous Maw -- @pos -48 0.1 435 105 -- Teleports Players to Batallia Downs [S] ----------------------------------- package.loaded["scripts/zones/Batallia_Downs/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/teleports"); require("scripts/globals/missions"); require("scripts/globals/campaign"); require("scripts/zones/Batallia_Downs/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (ENABLE_WOTG == 1 and player:hasKeyItem(PURE_WHITE_FEATHER) == false) then player:startEvent(0x01f4,0); elseif (ENABLE_WOTG == 1 and hasMawActivated(player,0)) then player:startEvent(0x038e); else player:messageSpecial(NOTHING_HAPPENS); 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 == 0x01f4) then local r = math.random(1,3); player:addKeyItem(PURE_WHITE_FEATHER); player:messageSpecial(KEYITEM_OBTAINED,PURE_WHITE_FEATHER); player:completeMission(WOTG,CAVERNOUS_MAWS); player:addMission(WOTG,BACK_TO_THE_BEGINNING); if (r == 1) then player:addNationTeleport(MAW,1); toMaw(player,1); -- go to Batallia_Downs[S] elseif (r == 2) then player:addNationTeleport(MAW,2); toMaw(player,3); -- go to Rolanberry_Fields_[S] elseif (r == 3) then player:addNationTeleport(MAW,4); toMaw(player,5); -- go to Sauromugue_Champaign_[S] end; elseif (csid == 0x038e and option == 1) then toMaw(player,1); -- go to Batallia_Downs[S] end; end;
gpl-3.0
JavidTeam/TeleJavid
plugins/plugins.lua
1
7843
do -- #Begin plugins.lua by @Javid_Team -- Returns the key (index) in the config.enabled_plugins table local function plugin_enabled( name ) for k,v in pairs(_config.enabled_plugins) do if name == v then return k end end -- If not found return false end -- Returns true if file exists in plugins folder local function plugin_exists( name ) for k,v in pairs(plugins_names()) do if name..'.lua' == v then return true end end return false end local function list_all_plugins(only_enabled, msg) local tmp = '\n'..msg_caption local text = '' local nsum = 0 for k, v in pairs( plugins_names( )) do -- ✔ enabled, ❌ disabled local status = '|✖️|>' nsum = nsum+1 nact = 0 -- Check if is enabled for k2, v2 in pairs(_config.enabled_plugins) do if v == v2..'.lua' then status = '|✔|>' end nact = nact+1 end if not only_enabled or status == '|✔|>'then -- get the name v = string.match (v, "(.*)%.lua") text = text..nsum..'.'..status..' '..v..' \n' end end text = '<code>'..text..'</code>\n\n'..nsum..' <b>📂plugins installed</b>\n\n'..nact..' <i>✔️plugins enabled</i>\n\n'..nsum-nact..' <i>❌plugins disabled</i>'..tmp tdcli.sendMessage(msg.to.id, msg.id_, 1, text, 1, 'html') end local function list_plugins(only_enabled, msg) local text = '' local nsum = 0 for k, v in pairs( plugins_names( )) do -- ✔ enabled, ❌ disabled local status = '*|✖️|>*' nsum = nsum+1 nact = 0 -- Check if is enabled for k2, v2 in pairs(_config.enabled_plugins) do if v == v2..'.lua' then status = '*|✔|>*' end nact = nact+1 end if not only_enabled or status == '*|✔|>*'then -- get the name v = string.match (v, "(.*)%.lua") -- text = text..v..' '..status..'\n' end end text = "\n_🔃All Plugins Reloaded_\n\n"..nact.." *✔️Plugins Enabled*\n"..nsum.." *📂Plugins Installed*\n"..msg_caption tdcli.sendMessage(msg.to.id, msg.id_, 1, text, 1, 'md') end local function reload_plugins(checks, msg) plugins = {} load_plugins() return list_plugins(true, msg) end local function enable_plugin( plugin_name, msg ) print('checking if '..plugin_name..' exists') -- Check if plugin is enabled if plugin_enabled(plugin_name) then local text = '<b>'..plugin_name..'</b> <i>is enabled.</i>' tdcli.sendMessage(msg.to.id, msg.id_, 1, text, 1, 'html') return end -- Checks if plugin exists if plugin_exists(plugin_name) then -- Add to the config table table.insert(_config.enabled_plugins, plugin_name) print(plugin_name..' added to _config table') save_config() -- Reload the plugins return reload_plugins(true, msg) else local text = '<b>'..plugin_name..'</b> <i>does not exists.</i>' tdcli.sendMessage(msg.to.id, msg.id_, 1, text, 1, 'html') end end local function disable_plugin( name, msg ) local k = plugin_enabled(name) -- Check if plugin is enabled if not k then local text = '<b>'..name..'</b> <i>not enabled.</i>' tdcli.sendMessage(msg.to.id, msg.id_, 1, text, 1, 'html') return end -- Check if plugins exists if not plugin_exists(name) then local text = '<b>'..name..'</b> <i>does not exists.</i>' tdcli.sendMessage(msg.to.id, msg.id_, 1, text, 1, 'html') else -- Disable and reload table.remove(_config.enabled_plugins, k) save_config( ) return reload_plugins(true, msg) end end local function disable_plugin_on_chat(receiver, plugin, msg) if not plugin_exists(plugin) then return "_Plugin doesn't exists_" end if not _config.disabled_plugin_on_chat then _config.disabled_plugin_on_chat = {} end if not _config.disabled_plugin_on_chat[receiver] then _config.disabled_plugin_on_chat[receiver] = {} end _config.disabled_plugin_on_chat[receiver][plugin] = true save_config() local text = '<b>'..plugin..'</b> <i>disabled on this chat.</i>' tdcli.sendMessage(msg.to.id, msg.id_, 1, text, 1, 'html') end local function reenable_plugin_on_chat(receiver, plugin, msg) if not _config.disabled_plugin_on_chat then return 'There aren\'t any disabled plugins' end if not _config.disabled_plugin_on_chat[receiver] then return 'There aren\'t any disabled plugins for this chat' end if not _config.disabled_plugin_on_chat[receiver][plugin] then return '_This plugin is not disabled_' end _config.disabled_plugin_on_chat[receiver][plugin] = false save_config() local text = '<b>'..plugin..'</b> <i>is enabled again.</i>' tdcli.sendMessage(msg.to.id, msg.id_, 1, text, 1, 'html') end local function run(msg, matches) local Chash = "cmd_lang:"..msg.to.id local Clang = redis:get(Chash) -- Show the available plugins if is_sudo(msg) then if (matches[1]:lower() == 'plist' and not Clang) or (matches[1]:lower() == 'لیست پلاگین' and Clang) then --after changed to moderator mode, set only sudo return list_all_plugins(false, msg) end end -- Re-enable a plugin for this chat if (matches[1]:lower() == 'pl' and not Clang) or (matches[1]:lower() == 'پلاگین' and Clang) then if matches[2] == '+' and ((matches[4] == 'chat' and not Clang) or (matches[4] == 'گروه' and not Clang)) then if is_mod(msg) then local receiver = msg.chat_id_ local plugin = matches[3] print("enable "..plugin..' on this chat') return reenable_plugin_on_chat(receiver, plugin, msg) end end -- Enable a plugin if matches[2] == '+' and is_sudo(msg) then --after changed to moderator mode, set only sudo local plugin_name = matches[3] print("enable: "..matches[3]) return enable_plugin(plugin_name, msg) end -- Disable a plugin on a chat if matches[2] == '-' and ((matches[4] == 'chat' and not Clang) or (matches[4] == 'گروه' and not Clang)) then if is_mod(msg) then local plugin = matches[3] local receiver = msg.chat_id_ print("disable "..plugin..' on this chat') return disable_plugin_on_chat(receiver, plugin, msg) end end -- Disable a plugin if matches[2] == '-' and is_sudo(msg) then --after changed to moderator mode, set only sudo if matches[3] == 'plugins' then return 'This plugin can\'t be disabled' end print("disable: "..matches[3]) return disable_plugin(matches[3], msg) end -- Reload all the plugins! if matches[2] == '*' and is_sudo(msg) then --after changed to moderator mode, set only sudo return reload_plugins(true, msg) end end if (matches[1]:lower() == 'reload' and not Clang) or (matches[1]:lower() == 'بارگذاری' and Clang) and is_sudo(msg) then --after changed to moderator mode, set only sudo return reload_plugins(true, msg) end end return { description = "Plugin to manage other plugins. Enable, disable or reload.", usage = { moderator = { "!pl - [plugin] chat : disable plugin only this chat.", "!pl + [plugin] chat : enable plugin only this chat.", }, sudo = { "!plist : list all plugins.", "!pl + [plugin] : enable plugin.", "!pl - [plugin] : disable plugin.", "!pl * : reloads all plugins." }, }, patterns = { "^([Pp]list)$", "^([Pp]l) (+) ([%w_%.%-]+)$", "^([Pp]l) (-) ([%w_%.%-]+)$", "^([Pp]l) (+) ([%w_%.%-]+) (chat)", "^([Pp]l) (-) ([%w_%.%-]+) (chat)", "^([Pp]l) (*)$", "^([Rr]eload)$", "^(لیست پلاگین)$", "^(پلاگین) (+) ([%w_%.%-]+)$", "^(پلاگین) (-) ([%w_%.%-]+)$", "^(پلاگین) (+) ([%w_%.%-]+) (گروه)", "^(پلاگین) (-) ([%w_%.%-]+) (گروه)", "^(پلاگین) (*)$", "^(بارگذاری)$", }, run = run, moderated = true, -- set to moderator mode privileged = true } end
gpl-3.0
Aeprox/ESPLogger
src/init.lua
1
1740
print("Aeprox ESP8266 datalogger V1.1 (Compatible with NodeMCU 0.9.6 build 20150627) ") -- variables sensorValues = {} dofile("usersettings.lua") local thingspeak = require("thingspeak") local wifiattempts = 0 local function dologger() if wifiattempts >= 5 then print("Wifi connection failed. Retrying next update interval") wifiattempts = 0 gotosleep() else if wifi.sta.status() < 5 then wifiattempts = wifiattempts + 1 print("Wifi connection failed. Retrying in 5 seconds...") tmr.alarm(2,5000,0,dologger) else wifiattempts = 0 dofile("readsensors.lc") thingspeak.send(APIkey, sensorValues, gotosleep) end end end local function initlogger() -- always make sure we're in station mode if(wifi.getmode() ~= wifi.STATION) then wifi.setmode(wifi.STATION) end -- check if current config != config in usersettings conf_ssid, conf_password = wifi.sta.getconfig() if((conf_ssid~=SSID) or (conf_password~=password)) then wifi.sta.config(SSID,password,0) end -- read Vdd before wifi starts if readV then Vdd = adc.readvdd33() end -- enable wifi wifi.sta.connect() tmr.alarm(1,3000,0,dologger) end tmr.alarm(0,2000,0,initlogger) -- never remove this during dev function gotosleep() if(serialOut and sleepEnabled) then print("Taking a "..APIdelay.." second nap") end if(serialOut and not sleepEnabled) then print("Waiting "..APIdelay.." second before updating") end wifi.sta.disconnect() if sleepEnabled then node.dsleep(APIdelay*1000000) else tmr.alarm(3,APIdelay*1000,0,initlogger) end end
mit
kitala1/darkstar
scripts/zones/San_dOria-Jeuno_Airship/npcs/Ricaldo.lua
12
2056
----------------------------------- -- Area: San d'Oria-Jeuno Airship -- NPC: Ricaldo -- Standard Info NPC ----------------------------------- package.loaded["scripts/zones/San_dOria-Jeuno_Airship/TextIDs"] = nil; require("scripts/zones/San_dOria-Jeuno_Airship/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local vHour = VanadielHour(); local vMin = VanadielMinute(); while vHour >= 3 do vHour = vHour - 6; end local message = WILL_REACH_SANDORIA; if (vHour == -3) then if (vMin >= 10) then vHour = 3; message = WILL_REACH_JEUNO; else vHour = 0; end elseif (vHour == -2) then vHour = 2; message = WILL_REACH_JEUNO; elseif (vHour == -1) then vHour = 1; message = WILL_REACH_JEUNO; elseif (vHour == 0) then if (vMin <= 11) then vHour = 0; message = WILL_REACH_JEUNO; else vHour = 3; end elseif (vHour == 1) then vHour = 2; elseif (vHour == 2) then vHour = 1; end local vMinutes = 0; if (message == WILL_REACH_JEUNO) then vMinutes = (vHour * 60) + 11 - vMin; else -- WILL_REACH_SANDORIA vMinutes = (vHour * 60) + 10 - vMin; end if (vMinutes <= 30) then if( message == WILL_REACH_SANDORIA) then message = IN_SANDORIA_MOMENTARILY; else -- WILL_REACH_JEUNO message = IN_JEUNO_MOMENTARILY; end elseif (vMinutes < 60) then vHour = 0; end player:messageSpecial( message, math.floor((2.4 * vMinutes) / 60), math.floor( vMinutes / 60 + 0.5)); 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
kitala1/darkstar
scripts/zones/Eastern_Altepa_Desert/mobs/Cactrot_Rapido.lua
12
12211
----------------------------------- -- Area: Eastern Altepa Desert -- NM: Cactrot Rapido ----------------------------------- require("scripts/globals/titles"); local path = { -45.214237, 0.059482, -204.244873, -46.114422, 0.104212, -203.765884, -47.013275, 0.149004, -203.285812, -47.911877, 0.193759, -202.805313, -58.443733, 0.767810, -197.319977, -61.495697, 0.477824, -195.851227, -64.869675, 0.109868, -194.287720, -75.073441, 0.254733, -189.665695, -81.320366, 0.495319, -186.993607, -91.067123, 0.288822, -183.020676, -97.377228, -0.392546, -180.579071, -99.247047, -0.895448, -179.936798, -100.800270, -1.393698, -179.434647, -102.352448, -1.900111, -178.961166, -103.899933, -2.504567, -178.528854, -105.126732, -3.031813, -178.190872, -106.367256, -3.527977, -177.907257, -107.613914, -4.023795, -177.639709, -108.867058, -4.500517, -177.388947, -110.153046, -4.924853, -177.183960, -111.440956, -5.322861, -177.007553, -112.735832, -5.956526, -176.851334, -114.710777, -5.139105, -176.495575, -116.667969, -4.440962, -176.081223, -117.885887, -3.910276, -175.532532, -119.009041, -3.591512, -174.816345, -120.015816, -3.243386, -173.936310, -120.987274, -2.875988, -173.018311, -121.980667, -2.569070, -172.122421, -122.732048, -2.157357, -171.448853, -125.173172, -0.957143, -169.194305, -125.936897, -0.534065, -168.118042, -126.509903, -0.232718, -167.291153, -127.278130, 0.155391, -166.201279, -128.056259, 0.507568, -165.116730, -128.636505, 0.869508, -164.300949, -136.568512, 3.083321, -153.014694, -136.977478, 3.211246, -152.089355, -137.378784, 3.349919, -151.163742, -137.792618, 3.493883, -150.238480, -138.222778, 3.588699, -149.317413, -139.789780, 4.143739, -145.951996, -140.113312, 4.375872, -144.993851, -140.287079, 4.543484, -143.998215, -140.466980, 4.650395, -142.999802, -140.650879, 4.757523, -142.002258, -140.834824, 4.864695, -141.004730, -141.029587, 4.938367, -140.006378, -141.407669, 5.135919, -138.010376, -141.643478, 5.328803, -136.341202, -141.718018, 5.393569, -135.328995, -141.813690, 5.423491, -134.313965, -141.928970, 5.490732, -132.961258, -142.095245, 5.603091, -130.931778, -142.253555, 5.573742, -129.240341, -142.852249, 5.496122, -123.503990, -143.283661, 5.484383, -119.451439, -143.331360, 5.500263, -118.093521, -143.367279, 5.357600, -117.080986, -143.595398, 4.682551, -114.444756, -143.761444, 4.288168, -113.153831, -143.944153, 3.851855, -111.863541, -144.114670, 3.081480, -110.600967, -144.374863, 2.389771, -109.383690, -144.561234, 1.352810, -107.876305, -144.406784, 0.635471, -106.733185, -144.221008, -0.194526, -105.556168, -143.877808, -0.956815, -104.450096, -143.333038, -1.686279, -103.367638, -142.964157, -2.185963, -102.417923, -142.580856, -1.692963, -101.476410, -142.176361, -1.494776, -100.551079, -141.584686, -1.078624, -99.351585, -141.150131, -0.753439, -98.444046, -140.304092, -0.076350, -96.605209, -138.948074, 0.686977, -93.901413, -138.008743, 1.152010, -92.116440, -136.429688, 1.963583, -89.143188, -134.031357, 2.365622, -84.672249, -133.287766, 2.253940, -83.149849, -131.816559, 1.901823, -80.109253, -129.684540, 1.223290, -75.525696, -126.872261, 0.516513, -69.392265, -124.933060, 0.570506, -65.425987, -122.093231, 0.971921, -59.642326, -121.642838, 0.935626, -58.728325, -109.254097, -0.174285, -33.826805, -107.579643, -0.704243, -30.530849, -104.290489, -2.292845, -24.004328, -103.340012, -2.798456, -22.273823, -101.417862, -3.851769, -18.828547, -97.400208, -5.963912, -11.658532, -96.157463, -6.415525, -9.279702, -94.492889, -7.087772, -6.000663, -87.445793, -8.721937, 8.182076, -82.627701, -10.710227, 17.341963, -78.738350, -12.969520, 24.556398, -77.843742, -12.820852, 24.081251, -76.622406, -12.841505, 24.162075, -75.760681, -13.003385, 24.680101, -74.814415, -13.116152, 25.040958, -73.821739, -13.185088, 25.261553, -72.808220, -13.145959, 25.357367, -71.794624, -13.038998, 25.335396, -70.787224, -12.916903, 25.232685, -69.777863, -12.797923, 25.146303, -68.767639, -12.701465, 25.068045, -67.753258, -12.639880, 24.988928, -66.398720, -12.608677, 24.871193, -63.693352, -12.663887, 24.614614, -61.332371, -12.802485, 24.348162, -50.877781, -13.008631, 23.174417, -49.525688, -12.897259, 23.080366, -44.121357, -12.405771, 22.702574, -41.750877, -12.331022, 22.526335, -31.591017, -12.228968, 21.767466, -30.574598, -12.240875, 21.682938, -28.892553, -12.373736, 21.497755, -26.193161, -12.326892, 21.279018, -25.180489, -12.211316, 21.241808, -23.829905, -12.058004, 21.196482, -18.073771, -11.557770, 20.988880, -15.020272, -11.416804, 20.876867, -10.272671, -11.514080, 20.625463, -5.530938, -11.567481, 20.363932, -2.144115, -11.611256, 20.183678, 1.250314, -11.545613, 20.013973, 4.980156, -11.624237, 19.813007, 6.658255, -11.886693, 19.655684, 7.651558, -12.083179, 19.533247, 8.947555, -12.524771, 19.332045, 10.214692, -12.953741, 19.087330, 11.502657, -13.320731, 18.860584, 12.780280, -13.754982, 18.569122, 14.030073, -14.196076, 18.227663, 15.295671, -14.636890, 17.897783, 16.523689, -15.021481, 17.490923, 18.113350, -15.462179, 17.026085, 19.330448, -16.081728, 16.884964, 20.436007, -16.775909, 16.924559, 21.711395, -17.273441, 16.566978, 23.008286, -17.863113, 16.240875, 25.600761, -16.349407, 15.708939, 27.885015, -14.547360, 15.286979, 29.175026, -13.795184, 15.093222, 31.474035, -12.003471, 14.741585, 32.733868, -11.282872, 14.418842, 34.007584, -10.686451, 14.024928, 35.271973, -10.187914, 13.686438, 36.557934, -9.658462, 13.328313, 38.519291, -9.480738, 12.813184, 42.436985, -9.212695, 11.718233, 43.381554, -9.141721, 11.339855, 44.327057, -9.046030, 10.973053, 45.586422, -8.833047, 10.505932, 53.230701, -8.530454, 7.711083, 55.138641, -8.453061, 6.993709, 59.573353, -7.617370, 5.394830, 69.459343, -7.685488, 1.939287, 72.022415, -7.802935, 1.038878, 72.933075, -7.848290, 0.582272, 73.840149, -7.893467, 0.117998, 74.749786, -7.938770, -0.341271, 75.661224, -7.972084, -0.797652, 76.574295, -7.968478, -1.252196, 83.864113, -7.963341, -4.913532, 85.353340, -7.848778, -5.726798, 92.465195, -7.863905, -9.688751, 93.283051, -7.853431, -10.298190, 94.106422, -7.894407, -10.898237, 94.932503, -7.953709, -11.493578, 95.759720, -8.025735, -12.087400, 102.684669, -8.555371, -16.980604, 103.452599, -8.716061, -17.633831, 104.192497, -8.917103, -18.314260, 105.165489, -9.238935, -19.207094, 106.146698, -9.576337, -20.094185, 107.875641, -10.310707, -21.564810, 110.510101, -11.774194, -23.772697, 112.850891, -11.348615, -25.616978, 113.918427, -10.971118, -26.418327, 114.921410, -10.609308, -27.303473, 115.544731, -10.389357, -28.099230, 116.108887, -10.155023, -28.928883, 116.677101, -9.907154, -29.764107, 117.259628, -9.660060, -30.577936, 117.841934, -9.415455, -31.403658, 118.628448, -9.101988, -32.489857, 119.226006, -8.906536, -33.291828, 121.370842, -8.177029, -36.269379, 121.892303, -8.089925, -37.141682, 122.419975, -8.003403, -38.010284, 123.126312, -8.000000, -39.172443, 124.321335, -7.985068, -41.228336, 124.715233, -7.965429, -42.168995, 125.117836, -7.945378, -43.105942, 125.524841, -7.925108, -44.041027, 125.932388, -7.857445, -44.973671, 126.477409, -7.837416, -46.216499, 128.163406, -7.896171, -50.290894, 128.435196, -7.838074, -51.272820, 128.713623, -7.837389, -52.253597, 129.000900, -7.732649, -53.228714, 129.289841, -7.648998, -54.203396, 129.763367, -7.580074, -56.180931, 129.849594, -7.588713, -57.197235, 129.947464, -7.598557, -58.212494, 130.050140, -7.608885, -59.227268, 130.154587, -7.632762, -60.241852, 130.148819, -7.683857, -61.259670, 129.995834, -7.740675, -62.266739, 129.800461, -7.810890, -63.265373, 129.614334, -7.882718, -64.265656, 129.431046, -7.955023, -65.266464, 129.248032, -8.027370, -66.267303, 128.941101, -8.148669, -67.934982, 128.592590, -8.226739, -69.244926, 128.169174, -8.255370, -70.171631, 127.624290, -8.259485, -71.033081, 127.052391, -8.258126, -71.877647, 126.489380, -8.258752, -72.728165, 125.929886, -8.260109, -73.581032, 125.371674, -8.261738, -74.434708, 124.246277, -8.290220, -76.135551, 123.706482, -8.174309, -76.993515, 122.960106, -8.099961, -78.127975, 121.970772, -8.000000, -79.504745, 121.232613, -8.000000, -80.207413, 120.399490, -8.000000, -80.794556, 119.492821, -8.000000, -81.260330, 118.549973, -8.000000, -81.649460, 117.614258, -8.000000, -82.055428, 116.680702, -8.000000, -82.466354, 115.746910, -8.000000, -82.876801, 114.813171, -7.956547, -83.285782, 113.566681, -7.910290, -83.827690, 111.362625, -7.895653, -84.719353, 110.370857, -7.837558, -84.951813, 109.379196, -7.779317, -85.183273, 108.389091, -7.722087, -85.421638, 107.398117, -7.713781, -85.657982, 106.404572, -7.742430, -85.887161, 100.443123, -7.914205, -87.261345, 78.931618, -9.066314, -92.160812, 78.006859, -9.174266, -92.574493, 77.191170, -9.243567, -93.175354, 76.518112, -9.365136, -93.929840, 75.956619, -9.517926, -94.767433, 75.396698, -9.684797, -95.603516, 74.836777, -9.851719, -96.439613, 74.276855, -10.018639, -97.275703, 73.716927, -10.185554, -98.111778, 73.157005, -10.352473, -98.947868, 72.037186, -10.691887, -100.619995, 65.185234, -12.325055, -110.974182, 64.502304, -12.210523, -112.137856, 63.758068, -12.309777, -113.272629, 60.121979, -12.452700, -119.008751, 57.324074, -12.271764, -123.665543, 54.016415, -11.951966, -129.203384, 51.480064, -12.026159, -133.225754, 50.535629, -12.216867, -134.627289, 49.575897, -12.556334, -136.002838, 48.761570, -12.911916, -137.027985, 47.980934, -13.217538, -138.086014, 45.906788, -14.359197, -140.978027, 45.197201, -13.630539, -142.093567, 44.498314, -12.896272, -143.199234, 43.958618, -12.095625, -144.064774, 42.670326, -11.275743, -146.004883, 36.821983, -8.478559, -154.982544, 33.769165, -7.889951, -159.845291, 28.914276, -7.639688, -167.631866, 22.451923, -4.734315, -177.783630, 20.719790, -3.657952, -180.643219, 20.171061, -3.421347, -181.483154, 19.586971, -3.203986, -182.310669, 18.478239, -2.926458, -182.771957, 17.234682, -2.637700, -182.976196, 16.290546, -2.427790, -183.316666, 15.309304, -2.271078, -183.548950, 14.327208, -2.134478, -183.788116, 13.344822, -1.998021, -184.026215, 12.361718, -1.863053, -184.263077, 8.079593, -1.926340, -185.327988, 2.468133, -1.674941, -186.621872, 0.478332, -1.519862, -187.029205, -5.183570, -1.168827, -188.135437, -10.524970, -0.787942, -189.075882, -11.111217, -0.629007, -189.894958, -12.298127, -0.580679, -190.385666, -13.245046, -0.599274, -190.750412, -14.188004, -0.496885, -191.123428, -15.131532, -0.387342, -191.495163, -16.076939, -0.359143, -191.862503, -18.904144, 0.286367, -192.923462, -19.298399, 0.512927, -193.844086, -20.236032, 0.637131, -194.226257, -21.165127, 0.763740, -194.627731, -22.089966, 0.795228, -195.051437, -23.013824, 0.792700, -195.483749, -23.938154, 0.790050, -195.915085, -25.589787, 0.636639, -196.951553, -26.508005, 0.544279, -197.385910, -27.422697, 0.452274, -197.827805, -28.337297, 0.380589, -198.272293, -29.254520, 0.334919, -198.716125, -31.397188, 0.228204, -199.746597, -36.625172, 0.000000, -202.187897, -37.873020, 0.000000, -202.493210, -39.119324, 0.000000, -203.037552, -40.370975, 0.000000, -203.569611 }; ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) onMobRoam(mob); end; function onPath(mob) pathfind.patrol(mob, path, PATHFLAG_RUN); end; function onMobRoam(mob) -- move to start position if not moving if(mob:isFollowingPath() == false) then mob:pathThrough(pathfind.first(path), PATHFLAG_RUN); end end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob, killer) killer:addTitle(CACTROT_DESACELERADOR); -- Set Cactrot Rapido's spawnpoint and respawn time (24-72 hours) UpdateNMSpawnPoint(mob:getID()); mob:setRespawnTime(math.random((86400),(259200))); end;
gpl-3.0
kitala1/darkstar
scripts/zones/Dynamis-Xarcabard/npcs/qm1.lua
19
1356
----------------------------------- -- Area: Dynamis Xarcabard -- NPC: ??? (Spawn when mega is defeated) ----------------------------------- package.loaded["scripts/zones/Dynamis-Xarcabard/TextIDs"] = nil; ----------------------------------- require("scripts/globals/titles"); require("scripts/globals/keyitems"); require("scripts/zones/Dynamis-Xarcabard/TextIDs"); ----------------------------------- -- onTrade ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger ----------------------------------- function onTrigger(player,npc) player:addTitle(DYNAMISXARCABARD_INTERLOPER); -- Add title if(player:hasKeyItem(HYDRA_CORPS_BATTLE_STANDARD) == false)then player:setVar("DynaXarcabard_Win",1); player:addKeyItem(HYDRA_CORPS_BATTLE_STANDARD); player:messageSpecial(KEYITEM_OBTAINED,HYDRA_CORPS_BATTLE_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); end;
gpl-3.0
kitala1/darkstar
scripts/zones/The_Eldieme_Necropolis/npcs/_5fk.lua
34
1105
----------------------------------- -- Area: The Eldieme Necropolis -- NPC: Titan's Gate -- @pos 100 -34 88 195 ----------------------------------- package.loaded["scripts/zones/The_Eldieme_Necropolis/TextIDs"] = nil; ----------------------------------- require("scripts/zones/The_Eldieme_Necropolis/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (npc:getAnimation() == 9) then player:messageSpecial(SOLID_STONE); end return 0; end; -- ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
kitala1/darkstar
scripts/zones/Selbina/npcs/Aleria.lua
34
1076
----------------------------------- -- Area: Selbina -- NPC: Aleria -- Standard Info NPC ----------------------------------- package.loaded["scripts/zones/Selbina/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Selbina/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:getZPos() < -28.750) then player:startEvent(0x00df); else player:startEvent(0x00e4); 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
fqrouter/luci
applications/luci-ahcp/luasrc/controller/ahcp.lua
76
1533
--[[ LuCI - Lua Configuration Interface Copyright 2011 Jo-Philipp Wich <xm@subsignal.org> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 $Id: init.lua 6731 2011-01-14 19:44:03Z soma $ ]]-- module("luci.controller.ahcp", package.seeall) function index() if not nixio.fs.access("/etc/config/ahcpd") then return end entry({"admin", "network", "ahcpd"}, cbi("ahcp"), _("AHCP Server"), 90) entry({"admin", "network", "ahcpd", "status"}, call("ahcp_status")) end function ahcp_status() local nfs = require "nixio.fs" local uci = require "luci.model.uci".cursor() local lsd = uci:get_first("ahcpd", "ahcpd", "lease_dir") or "/var/lib/leases" local idf = uci:get_first("ahcpd", "ahcpd", "id_file") or "/var/lib/ahcpd-unique-id" local rv = { uid = "00:00:00:00:00:00:00:00", leases = { } } idf = nfs.readfile(idf) if idf and #idf == 8 then rv.uid = "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X" %{ idf:byte(1, 8) } end local itr = nfs.dir(lsd) if itr then local addr for addr in itr do if addr:match("^%d+%.%d+%.%d+%.%d+$") then local s = nfs.stat(lsd .. "/" .. addr) rv.leases[#rv.leases+1] = { addr = addr, age = s and (os.time() - s.mtime) or 0 } end end end table.sort(rv.leases, function(a, b) return a.age < b.age end) luci.http.prepare_content("application/json") luci.http.write_json(rv) end
apache-2.0
kitala1/darkstar
scripts/zones/PsoXja/npcs/_09b.lua
8
1608
----------------------------------- -- Area: Pso'Xja -- NPC: _09b (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 <= 278)then if(GetMobAction(16814092) == 0) then local Rand = math.random(1,10); if (Rand <=9) then -- Spawn Gargoyle player:messageSpecial(TRAP_ACTIVATED); SpawnMob(16814092,120):updateClaim(player); -- Gargoyle else player:messageSpecial(TRAP_FAILS); npc:openDoor(30); end else player:messageSpecial(DOOR_LOCKED); end elseif(X >= 279)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
kitala1/darkstar
scripts/zones/Sauromugue_Champaign_[S]/Zone.lua
12
1346
----------------------------------- -- -- Zone: Sauromugue_Champaign_[S] (98) -- ----------------------------------- package.loaded["scripts/zones/Sauromugue_Champaign_[S]/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/zones/Sauromugue_Champaign_[S]/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) local cs = -1; if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then player:setPos(-104,-25.36,-410,195); 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
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/object/mobile/dressed_commoner_old_twilek_male_01.lua
3
2256
--Copyright (C) 2010 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version object_mobile_dressed_commoner_old_twilek_male_01 = object_mobile_shared_dressed_commoner_old_twilek_male_01:new { } ObjectTemplates:addTemplate(object_mobile_dressed_commoner_old_twilek_male_01, "object/mobile/dressed_commoner_old_twilek_male_01.iff")
agpl-3.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/object/static/item/item_container_organic_hide.lua
3
2244
--Copyright (C) 2010 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version object_static_item_item_container_organic_hide = object_static_item_shared_item_container_organic_hide:new { } ObjectTemplates:addTemplate(object_static_item_item_container_organic_hide, "object/static/item/item_container_organic_hide.iff")
agpl-3.0
gamelost/glc-client
util/clock.lua
2
1634
-- clock.lua -- -- For timers, tweening, scheduling, etc. local timers = {} local nextTimer = love.timer.getTime() + 1000000.0 local function runTimers(now) nextTimer = now + 100000.0 for k, v in pairs(timers) do if v.time <= now then v.cb() if v.freq == 1 then timers[k] = nil else if v.freq > 0 then v.freq = v.freq - 1 end v.time = now + v.step if v.time < nextTimer then nextTimer = v.time end end else -- make sure that slower-speed timers keep on ticking. probably -- best to have a priority queue here. local nextInterval = v.time - now if nextInterval < nextTimer then nextTimer = v.time end end end end local function update() local now = love.timer.getTime() if nextTimer and nextTimer <= now then runTimers(now) end end local function addTimer(t) if t.time < nextTimer then nextTimer = t.time end timers[t.name] = t end local timerCounter = 0 local function schedule(secs, cb, name) if not name then name = 'auto.' .. timerCounter timerCounter = timerCounter + 1 end local t = { time = love.timer.getTime() + secs, cb = cb, freq = 1, name = name } addTimer(t) end local function every(secs, cb, name) assert(name) local t = { time = love.timer.getTime(), -- start an iteration now cb = cb, step = secs, freq = -1, name = name } addTimer(t) end local function cancel(name) timers[name] = nil end return { update = update, schedule = schedule, every = every, cancel = cancel }
apache-2.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/object/static/item/item_binoculars.lua
3
2196
--Copyright (C) 2010 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version object_static_item_item_binoculars = object_static_item_shared_item_binoculars:new { } ObjectTemplates:addTemplate(object_static_item_item_binoculars, "object/static/item/item_binoculars.iff")
agpl-3.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/object/draft_schematic/furniture/furniture_couch_modern.lua
2
3174
--Copyright (C) 2010 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version object_draft_schematic_furniture_furniture_couch_modern = object_draft_schematic_furniture_shared_furniture_couch_modern:new { templateType = DRAFTSCHEMATIC, customObjectName = "Couch", craftingToolTab = 512, -- (See DraftSchemticImplementation.h) complexity = 34, size = 3, xpType = "crafting_structure_general", xp = 760, assemblySkill = "structure_assembly", experimentingSkill = "structure_experimentation", customizationSkill = "structure_customization", customizationOptions = {}, customizationStringNames = {}, customizationDefaults = {}, ingredientTemplateNames = {"craft_furniture_ingredients_n", "craft_furniture_ingredients_n"}, ingredientTitleNames = {"frame", "cushions"}, ingredientSlotType = {0, 0}, resourceTypes = {"metal_ferrous", "hide_wooly"}, resourceQuantities = {180, 200}, contribution = {100, 100}, targetTemplate = "object/tangible/furniture/modern/couch_modern_style_01.iff", additionalTemplates = { } } ObjectTemplates:addTemplate(object_draft_schematic_furniture_furniture_couch_modern, "object/draft_schematic/furniture/furniture_couch_modern.iff")
agpl-3.0
larrybotha/dotfiles
.config/nvim/lua/modules/telescope.lua
1
1780
local M = {} local actions = require("telescope.actions") local action_state = require("telescope.actions.state") local custom_actions = {} function custom_actions.fzf_multi_select(prompt_bufnr) local picker = action_state.get_current_picker(prompt_bufnr) local num_selections = table.getn(picker:get_multi_selection()) if num_selections > 1 then -- actions.file_edit throws -- see https://github.com/nvim-telescope/telescope.nvim/issues/416#issuecomment-841692272 --actions.file_edit(prompt_bufnr) actions.send_selected_to_qflist(prompt_bufnr) actions.open_qflist() else actions.file_edit(prompt_bufnr) end end require("telescope").setup { defaults = { mappings = { i = { ["<cr>"] = custom_actions.fzf_multi_select }, n = { ["<cr>"] = custom_actions.fzf_multi_select } }, vimgrep_arguments = { "rg", "--color=never", "--hidden", "--no-heading", "--with-filename", "--line-number", "--column", "--smart-case" } }, extensions = { fzf = { fuzzy = true, override_generic_sorter = true, -- override the generic sorter override_file_sorter = true, -- override the file sorter case_mode = "smart_case" -- or "ignore_case" or "respect_case" } } } require("telescope").load_extension("fzf") require("telescope").load_extension("asynctasks") M.custom_find_files = function(opts) opts = opts or {} -- add hidden files to find_files opts.hidden = true require "telescope.builtin".find_files(opts) end return M
mit
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/commands/findObject.lua
4
2123
--Copyright (C) 2007 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. --true = 1, false = 0 FindObjectCommand = { name = "findobject", } AddCommand(FindObjectCommand)
agpl-3.0
DailyShana/ygopro-scripts
c50263751.lua
3
1401
--グリード・クエーサー function c50263751.initial_effect(c) --base attack local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_SET_BASE_ATTACK) e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e1:SetRange(LOCATION_MZONE) e1:SetValue(c50263751.atkval) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EFFECT_SET_BASE_DEFENCE) c:RegisterEffect(e2) --lvup local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e2:SetCode(EVENT_BATTLE_DESTROYING) e2:SetCondition(c50263751.condition) e2:SetOperation(c50263751.operation) c:RegisterEffect(e2) end function c50263751.atkval(e,c) return c:GetLevel()*300 end function c50263751.condition(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsRelateToBattle() and e:GetHandler():IsFaceup() end function c50263751.operation(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local bc=c:GetBattleTarget() local lv=bc:GetLevel() if lv>0 then if c:GetFlagEffect(50263751)==0 then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_LEVEL) e1:SetValue(lv) e1:SetReset(RESET_EVENT+0x1ff0000) c:RegisterEffect(e1) c:RegisterFlagEffect(50263751,RESET_EVENT+0x1ff0000,0,0) e:SetLabelObject(e1) e:SetLabel(lv) else local pe=e:GetLabelObject() local ct=e:GetLabel()+lv e:SetLabel(ct) pe:SetValue(ct) end end end
gpl-2.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/mobile/dungeon/geonosian_bio_lab/imperial_observer.lua
2
1458
imperial_observer = Creature:new { objectName = "@mob/creature_names:geonosian_imperial_observer", randomNameType = NAME_GENERIC_TAG, socialGroup = "imperial", faction = "imperial", level = 53, chanceHit = 0.54, damageMin = 415, damageMax = 540, baseXp = 5190, baseHAM = 11000, baseHAMmax = 13000, armor = 1, resists = {5,5,5,5,5,5,5,5,-1}, meatType = "", meatAmount = 0, hideType = "", hideAmount = 0, boneType = "", boneAmount = 0, milk = 0, tamingChance = 0, ferocity = 0, pvpBitmask = ATTACKABLE, creatureBitmask = PACK + KILLER, optionsBitmask = 128, diet = HERBIVORE, templates = { "object/mobile/dressed_imperial_officer_m.iff", "object/mobile/dressed_imperial_officer_m_2.iff", "object/mobile/dressed_imperial_officer_m_3.iff", "object/mobile/dressed_imperial_officer_m_4.iff", "object/mobile/dressed_imperial_officer_m_5.iff", "object/mobile/dressed_imperial_officer_m_6.iff"}, lootGroups = { { groups = { {group = "clothing_attachments", chance = 350000}, {group = "armor_attachments", chance = 350000}, {group = "geonosian_hard", chance = 900000}, {group = "geonosian_common", chance = 4200000}, {group = "geonosian_relic", chance = 4200000} } } }, weapons = {"imperial_weapons_heavy"}, conversationTemplate = "", attacks = merge(brawlermaster,marksmanmaster,riflemanmaster,carbineermaster) } CreatureTemplates:addCreatureTemplate(imperial_observer, "imperial_observer")
agpl-3.0
Whitechaser/darkstar
scripts/zones/Port_San_dOria/npcs/Meuxtajean.lua
5
1073
----------------------------------- -- Area: Port San d'Oria -- NPC: Meuxtajean -- Standard Info NPC ----------------------------------- package.loaded["scripts/zones/Port_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Port_San_dOria/TextIDs"); require("scripts/globals/quests"); ----------------------------------- function onTrade(player,npc,trade) -- "Flyers for Regine" conditional script local FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE); if (FlyerForRegine == 1) then local count = trade:getItemCount(); local MagicFlyer = trade:hasItemQty(532,1); if (MagicFlyer == true and count == 1) then player:messageSpecial(FLYER_REFUSED); end end end; function onTrigger(player,npc) player:startEvent(582); end; function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
DailyShana/ygopro-scripts
c59463312.lua
3
2760
--冥帝従騎エイドス function c59463312.initial_effect(c) --summon local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(59463312,0)) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e1:SetCode(EVENT_SUMMON_SUCCESS) e1:SetOperation(c59463312.sumop) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EVENT_SPSUMMON_SUCCESS) c:RegisterEffect(e2) --spsummon local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(59463312,1)) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetProperty(EFFECT_FLAG_CARD_TARGET) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetRange(LOCATION_GRAVE) e3:SetCountLimit(1,59463312) e3:SetCost(c59463312.cost) e3:SetTarget(c59463312.target) e3:SetOperation(c59463312.operation) c:RegisterEffect(e3) end function c59463312.sumop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetFlagEffect(tp,59463312)~=0 then return end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetTargetRange(LOCATION_HAND,0) e1:SetCode(EFFECT_EXTRA_SUMMON_COUNT) e1:SetValue(0x1) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) local e2=e1:Clone() e2:SetCode(EFFECT_EXTRA_SET_COUNT) Duel.RegisterEffect(e2,tp) Duel.RegisterFlagEffect(tp,59463312,RESET_PHASE+PHASE_END,0,1) end function c59463312.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST) end function c59463312.filter(c,e,tp) return c:GetAttack()==800 and c:GetDefence()==1000 and not c:IsCode(59463312) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c59463312.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and c59463312.filter(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingTarget(c59463312.filter,tp,LOCATION_GRAVE,0,1,e:GetHandler(),e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectTarget(tp,c59463312.filter,tp,LOCATION_GRAVE,0,1,1,e:GetHandler(),e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0) end function c59463312.operation(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)>0 then local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP_DEFENCE) end end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e1:SetReset(RESET_PHASE+PHASE_END) e1:SetTargetRange(1,0) e1:SetTarget(c59463312.splimit) Duel.RegisterEffect(e1,tp) end function c59463312.splimit(e,c,sump,sumtype,sumpos,targetp,se) return c:IsLocation(LOCATION_EXTRA) end
gpl-2.0
Whitechaser/darkstar
scripts/globals/items/fuscina.lua
7
1060
----------------------------------------- -- ID: 18104 -- Item: Fuscina -- Additional Effect: Lightning Damage ----------------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); require("scripts/globals/msg"); ----------------------------------- function onAdditionalEffect(player,target,damage) local chance = 5; if (math.random(0,99) >= chance) then return 0,0,0; else local dmg = math.random(3,10); local params = {}; params.bonusmab = 0; params.includemab = false; dmg = addBonusesAbility(player, ELE_LIGHTNING, target, dmg, params); dmg = dmg * applyResistanceAddEffect(player,target,ELE_LIGHTNING,0); dmg = adjustForTarget(target,dmg,ELE_LIGHTNING); dmg = finalMagicNonSpellAdjustments(player,target,ELE_LIGHTNING,dmg); local message = msgBasic.ADD_EFFECT_DMG; if (dmg < 0) then message = msgBasic.ADD_EFFECT_HEAL; end return SUBEFFECT_LIGHTNING_DAMAGE,message,dmg; end end;
gpl-3.0
DailyShana/ygopro-scripts
c57902193.lua
5
1313
--苦渋の転生 function c57902193.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1) e1:SetTarget(c57902193.target) e1:SetOperation(c57902193.activate) c:RegisterEffect(e1) end function c57902193.filter(c) return c:IsType(TYPE_MONSTER) and c:IsAbleToHand() end function c57902193.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c57902193.filter,tp,LOCATION_GRAVE,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_GRAVE) end function c57902193.activate(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,1-tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(1-tp,c57902193.filter,tp,LOCATION_GRAVE,0,1,1,nil) local tc=g:GetFirst() if tc then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_PHASE+PHASE_END) e1:SetRange(LOCATION_GRAVE) e1:SetCountLimit(1) e1:SetOperation(c57902193.thop) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) tc:RegisterEffect(e1) end end function c57902193.thop(e,tp,eg,ep,ev,re,r,rp) if Duel.SendtoHand(e:GetHandler(),nil,REASON_EFFECT)~=0 then Duel.ConfirmCards(1-tp,e:GetHandler()) end end
gpl-2.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/object/static/structure/general/poi_nboo_corral_half_64x64_s04.lua
3
2308
--Copyright (C) 2010 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version object_static_structure_general_poi_nboo_corral_half_64x64_s04 = object_static_structure_general_shared_poi_nboo_corral_half_64x64_s04:new { } ObjectTemplates:addTemplate(object_static_structure_general_poi_nboo_corral_half_64x64_s04, "object/static/structure/general/poi_nboo_corral_half_64x64_s04.iff")
agpl-3.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/commands/confusionShot.lua
2
2703
--Copyright (C) 2007 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. --true = 1, false = 0 ConfusionShotCommand = { name = "confusionshot", damageMultiplier = 3.0, speedMultiplier = 2.3, healthCostMultiplier = 1, actionCostMultiplier = 1, mindCostMultiplier = 1, stateEffects = { StateEffect( DIZZY_EFFECT, {}, { "dizzy_defense", "resistance_states" }, { "jedi_state_defense" }, 100, 0, 10 ), StateEffect( STUN_EFFECT, {}, { "stun_defense", "resistance_states" }, { "jedi_state_defense" }, 100, 0, 10 ) }, animationCRC = hashCode("fire_5_special_single_medium_face"), combatSpam = "confusionshot", weaponType = CARBINEWEAPON, range = -1 } AddCommand(ConfusionShotCommand)
agpl-3.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/object/tangible/component/droid/merchant_barker.lua
2
2827
--Copyright (C) 2010 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version object_tangible_component_droid_merchant_barker = object_tangible_component_droid_shared_merchant_barker:new { dataObjectComponent = "DroidMerchantModuleDataComponent", numberExperimentalProperties = {1, 1, 2, 1, 2}, experimentalProperties = {"XX", "XX", "CD", "OQ", "XX", "CD", "OQ"}, experimentalWeights = {1, 1, 1, 1, 1, 1, 1}, experimentalGroupTitles = {"null", "null", "exp_durability", "null", "exp_effectiveness"}, experimentalSubGroupTitles = {"null", "null", "decayrate", "hitpoints", "mechanism_quality"}, experimentalMin = {0, 0, 5, 1000, -10}, experimentalMax = {0, 0, 15, 1000, 15}, experimentalPrecision = {0, 0, 0, 0, 0}, experimentalCombineType = {0, 0, 1, 4, 1}, } ObjectTemplates:addTemplate(object_tangible_component_droid_merchant_barker, "object/tangible/component/droid/merchant_barker.iff")
agpl-3.0
KingRaptor/Zero-K
gamedata/modularcomms/weapons/lparticlebeam.lua
2
1066
local name = "commweapon_lparticlebeam" local weaponDef = { name = [[Light Particle Beam]], beamDecay = 0.85, beamTime = 1/30, beamttl = 45, coreThickness = 0.5, craterBoost = 0, craterMult = 0, customParams = { slot = [[5]], light_color = [[0.9 0.22 0.22]], light_radius = 80, }, damage = { default = 55, subs = 3, }, explosionGenerator = [[custom:flash1red]], fireStarter = 100, impactOnly = true, impulseFactor = 0, interceptedByShieldType = 1, laserFlareSize = 4.5, minIntensity = 1, range = 310, reloadtime = 10/30, rgbColor = [[1 0 0]], soundStart = [[weapon/laser/mini_laser]], soundStartVolume = 5, thickness = 4, tolerance = 8192, turret = true, weaponType = [[BeamLaser]], } return name, weaponDef
gpl-2.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/object/building/faction_perk/base/factional_building_base.lua
3
2288
--Copyright (C) 2010 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version object_building_faction_perk_base_factional_building_base = object_building_faction_perk_base_shared_factional_building_base:new { } ObjectTemplates:addTemplate(object_building_faction_perk_base_factional_building_base, "object/building/faction_perk/base/factional_building_base.iff")
agpl-3.0
njligames/NJLIGameEngine
projects/YappyBirds/_archive/scripts_9.16.2016/worlds/states/YappyBirdWorldEntityState.lua
2
2342
local WorldEntityState = require "njli.ui.worldentitystate" local YappyBirdWorldEntityState = {} YappyBirdWorldEntityState.__index = YappyBirdWorldEntityState local json = require('json') setmetatable(YappyBirdWorldEntityState, { __index = WorldEntityState, __call = function (cls, ...) local self = setmetatable({}, cls) WorldEntityState.create(self, ...) self:create(...) return self end, }) function YappyBirdWorldEntityState:className() return "YappyBirdWorldEntityState" end function YappyBirdWorldEntityState:class() return self end function YappyBirdWorldEntityState:superClass() return WorldEntityState end function YappyBirdWorldEntityState:destroy() YappyBirdWorldEntityState.__gc(self) WorldEntityState.destroy(self) end function YappyBirdWorldEntityState:create(init) WorldEntityState.create(self, init) end function YappyBirdWorldEntityState:__gc() end function YappyBirdWorldEntityState:__tostring() return json:stringify(self) end local init = { name = "name", entityOwner = nil } function YappyBirdWorldEntityState:create(init) WorldEntityState.create(self, init) end function YappyBirdWorldEntityState:__gc() self:unLoad() end function YappyBirdWorldEntityState:__tostring() return json:stringify(self) end function YappyBirdWorldEntityState:load() WorldEntityState.load(self) end function YappyBirdWorldEntityState:unLoad() WorldEntityState.unLoad(self) end function YappyBirdWorldEntityState:enter() end function YappyBirdWorldEntityState:update(timeStep) end function YappyBirdWorldEntityState:exit() end function YappyBirdWorldEntityState:onMessage(message) end function YappyBirdWorldEntityState:touchDown(touches) end function YappyBirdWorldEntityState:touchUp(touches) end function YappyBirdWorldEntityState:touchMove(touches) end function YappyBirdWorldEntityState:touchCancelled(touches) end function YappyBirdWorldEntityState:renderHUD() end function YappyBirdWorldEntityState:keyboardShow() end function YappyBirdWorldEntityState:keyboardCancel() end function YappyBirdWorldEntityState:keyboardReturn(text) end function YappyBirdWorldEntityState:receivedMemoryWarning() end function YappyBirdWorldEntityState:pause() end function YappyBirdWorldEntityState:unPause() end return YappyBirdWorldEntityState
mit
Whitechaser/darkstar
scripts/zones/Norg/TextIDs.lua
5
2427
-- Variable TextID Description text -- General Texts ITEM_CANNOT_BE_OBTAINED = 6402; -- You cannot obtain the item <item>. Come back after sorting your inventory. ITEM_OBTAINED = 6408; -- Obtained: <item>. GIL_OBTAINED = 6409; -- Obtained <number> gil. KEYITEM_OBTAINED = 6411; -- Obtained key item: <keyitem>. FISHING_MESSAGE_OFFSET = 6656; -- You can't fish here. HOMEPOINT_SET = 2; -- Home point set! DOOR_IS_LOCKED = 10353; -- The door is locked tight. -- Other Texts SPASIJA_DELIVERY_DIALOG = 10347; -- Hiya! I can deliver packages to anybody, anywhere, anytime. What do you say? PALEILLE_DELIVERY_DIALOG = 10348; -- We can deliver parcels to any residence in Vana'diel. -- Quest Dialog YOU_CAN_NOW_BECOME_A_SAMURAI = 10196; -- You can now become a samurai. CARRYING_TOO_MUCH_ALREADY = 10197; -- I wish to give you your reward, but you seem to be carrying too much already. Come back when you have more room in your pack. SPASIJA_DIALOG = 10347; -- Hiya! I can deliver packages to anybody, anywhere, anytime. What do you say? PALEILLE_DIALOG = 10348; -- We can deliver parcels to any residence in Vana'diel. AVATAR_UNLOCKED = 10467; -- You are now able to summon NOMAD_MOOGLE_DIALOG = 10535; -- I'm a traveling moogle, kupo. I help adventurers in the Outlands access items they have stored in a Mog House elsewhere, kupo. FOUIVA_DIALOG = 10559; -- Oi 'av naw business wi' de likes av you. -- Shop Texts JIROKICHI_SHOP_DIALOG = 10343; -- Heh-heh-heh. Feast your eyes on these beauties. You won't find stuff like this anywhere! VULIAIE_SHOP_DIALOG = 10344; -- Please, stay and have a look. You may find something you can only buy here. ACHIKA_SHOP_DIALOG = 10345; -- Can I interest you in some armor forged in the surrounding regions? CHIYO_SHOP_DIALOG = 10346; -- Magic scrolls! Magic scrolls! We've got parchment hot off the sheep! SOLBYMAHOLBY_SHOP_DIALOG = 10573; -- Hiya! My name's Solby-Maholby! I'm new here, so they put me on tooty-fruity shop duty. I'll give you a super-duper deal on unwanted items! -- conquest Base CONQUEST_BASE = 6497; -- Tallying conquest results... -- Porter Moogle RETRIEVE_DIALOG_ID = 11274; -- You retrieve$ from the porter moogle's care.
gpl-3.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/object/tangible/speaker/speaker.lua
3
2184
--Copyright (C) 2010 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version object_tangible_speaker_speaker = object_tangible_speaker_shared_speaker:new { } ObjectTemplates:addTemplate(object_tangible_speaker_speaker, "object/tangible/speaker/speaker.iff")
agpl-3.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/object/creature/npc/theme_park/objects.lua
3
19186
--Copyright (C) 2009 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. object_creature_npc_theme_park_shared_event_transport = SharedCreatureObjectTemplate:new { clientTemplateFileName = "object/creature/npc/theme_park/shared_event_transport.iff" --Data below here is deprecated and loaded from the tres, keeping for easy lookups --[[ acceleration = {6,2}, animationMapFilename = "all_male.map", appearanceFilename = "appearance/player_event_transport.sat", arrangementDescriptorFilename = "", cameraHeight = 0, certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "clientdata/client_shared_player_transport.cdf", clientGameObjectType = 1025, collisionActionBlockFlags = 0, collisionActionFlags = 255, collisionActionPassFlags = 0, collisionHeight = 1.8, collisionLength = 1.5, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, collisionOffsetX = 0, collisionOffsetZ = 0, collisionRadius = 0.5, containerType = 1, containerVolumeLimit = 0, customizationVariableMapping = {}, detailedDescription = "", gameObjectType = 1025, gender = 1, locationReservationRadius = 0, lookAtText = "@theme_park_lookat:transport", movementDatatable = "datatables/movement/movement_human.iff", niche = 5, noBuildRadius = 0, objectName = "@theme_park_name:transport", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", postureAlignToTerrain = {0,0,1,0,0,1,0,1,0,0,0,0,1,1,1}, race = 0, rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slopeModAngle = 15, slopeModPercent = 0.1, slotDescriptorFilename = "abstract/slot/descriptor/hack_transport.iff", snapToTerrain = 1, socketDestinations = {}, species = 1, speed = {6,2}, stepHeight = 0.5, structureFootprintFileName = "", surfaceType = 0, swimHeight = 1, targetable = 1, totalCellNumber = 0, turnRate = {90,180}, useStructureFootprintOutline = 0, warpTolerance = 17, waterModPercent = 0.5, clientObjectCRC = 1686537229, derivedFromTemplates = {"object/object/base/shared_base_object.iff", "object/tangible/base/shared_tangible_base.iff", "object/creature/base/shared_base_creature.iff", "object/creature/npc/base/shared_base_npc.iff", "object/creature/npc/base/shared_base_npc_theme_park.iff"} ]] } ObjectTemplates:addClientTemplate(object_creature_npc_theme_park_shared_event_transport, "object/creature/npc/theme_park/shared_event_transport.iff") object_creature_npc_theme_park_shared_event_transport_theed_hangar = SharedCreatureObjectTemplate:new { clientTemplateFileName = "object/creature/npc/theme_park/shared_event_transport_theed_hangar.iff" --Data below here is deprecated and loaded from the tres, keeping for easy lookups --[[ acceleration = {6,2}, animationMapFilename = "all_male.map", appearanceFilename = "appearance/player_event_transport.sat", arrangementDescriptorFilename = "", cameraHeight = 0, certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "clientdata/client_shared_player_transport.cdf", clientGameObjectType = 1025, collisionActionBlockFlags = 0, collisionActionFlags = 255, collisionActionPassFlags = 0, collisionHeight = 1.8, collisionLength = 1.5, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, collisionOffsetX = 0, collisionOffsetZ = 0, collisionRadius = 0.5, containerType = 1, containerVolumeLimit = 0, customizationVariableMapping = {}, detailedDescription = "", gameObjectType = 1025, gender = 2, locationReservationRadius = 0, lookAtText = "@theme_park_lookat:transport", movementDatatable = "datatables/movement/movement_human.iff", niche = 5, noBuildRadius = 0, objectName = "@theme_park_name:transport", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", postureAlignToTerrain = {0,0,1,0,0,1,0,1,0,0,0,0,1,1,1}, race = 0, rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slopeModAngle = 15, slopeModPercent = 0.1, slotDescriptorFilename = "abstract/slot/descriptor/hack_transport.iff", snapToTerrain = 1, socketDestinations = {}, species = 1, speed = {6,2}, stepHeight = 0.5, structureFootprintFileName = "", surfaceType = 0, swimHeight = 1, targetable = 1, totalCellNumber = 0, turnRate = {90,180}, useStructureFootprintOutline = 0, warpTolerance = 17, waterModPercent = 0.5, clientObjectCRC = 3010351388, derivedFromTemplates = {"object/object/base/shared_base_object.iff", "object/tangible/base/shared_tangible_base.iff", "object/creature/base/shared_base_creature.iff", "object/creature/npc/base/shared_base_npc.iff", "object/creature/npc/base/shared_base_npc_theme_park.iff"} ]] } ObjectTemplates:addClientTemplate(object_creature_npc_theme_park_shared_event_transport_theed_hangar, "object/creature/npc/theme_park/shared_event_transport_theed_hangar.iff") object_creature_npc_theme_park_shared_lambda_shuttle = SharedCreatureObjectTemplate:new { clientTemplateFileName = "object/creature/npc/theme_park/shared_lambda_shuttle.iff" --Data below here is deprecated and loaded from the tres, keeping for easy lookups --[[ acceleration = {6,2}, animationMapFilename = "all_male.map", appearanceFilename = "appearance/lamda_shuttle_faction_perk.sat", arrangementDescriptorFilename = "", cameraHeight = 0, certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "clientdata/client_shared_lambda_shuttle.cdf", clientGameObjectType = 1025, collisionActionBlockFlags = 0, collisionActionFlags = 255, collisionActionPassFlags = 0, collisionHeight = 1.8, collisionLength = 1.5, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, collisionOffsetX = 0, collisionOffsetZ = 0, collisionRadius = 0.5, containerType = 1, containerVolumeLimit = 0, customizationVariableMapping = {}, detailedDescription = "", gameObjectType = 1025, gender = 2, locationReservationRadius = 0, lookAtText = "@theme_park_lookat:shuttle", movementDatatable = "datatables/movement/movement_human.iff", niche = 5, noBuildRadius = 0, objectName = "@theme_park_name:shuttle", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", postureAlignToTerrain = {0,0,1,0,0,1,0,1,0,0,0,0,1,1,1}, race = 0, rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slopeModAngle = 15, slopeModPercent = 0.1, slotDescriptorFilename = "abstract/slot/descriptor/player.iff", snapToTerrain = 1, socketDestinations = {}, species = 1, speed = {6,2}, stepHeight = 0.5, structureFootprintFileName = "", surfaceType = 0, swimHeight = 1, targetable = 1, totalCellNumber = 0, turnRate = {90,180}, useStructureFootprintOutline = 0, warpTolerance = 17, waterModPercent = 0.5, clientObjectCRC = 3752954766, derivedFromTemplates = {"object/object/base/shared_base_object.iff", "object/tangible/base/shared_tangible_base.iff", "object/creature/base/shared_base_creature.iff", "object/creature/npc/base/shared_base_npc.iff", "object/creature/npc/base/shared_base_npc_theme_park.iff"} ]] } ObjectTemplates:addClientTemplate(object_creature_npc_theme_park_shared_lambda_shuttle, "object/creature/npc/theme_park/shared_lambda_shuttle.iff") object_creature_npc_theme_park_shared_lambda_shuttle_faction_perk = SharedCreatureObjectTemplate:new { clientTemplateFileName = "object/creature/npc/theme_park/shared_lambda_shuttle_faction_perk.iff" --Data below here is deprecated and loaded from the tres, keeping for easy lookups --[[ acceleration = {6,2}, animationMapFilename = "all_male.map", appearanceFilename = "appearance/lamda_shuttle_faction_perk.sat", arrangementDescriptorFilename = "", cameraHeight = 0, certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "clientdata/client_shared_lambda_shuttle.cdf", clientGameObjectType = 1025, collisionActionBlockFlags = 0, collisionActionFlags = 255, collisionActionPassFlags = 0, collisionHeight = 1.8, collisionLength = 1.5, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, collisionOffsetX = 0, collisionOffsetZ = 0, collisionRadius = 0.5, containerType = 0, containerVolumeLimit = 0, customizationVariableMapping = {}, detailedDescription = "", gameObjectType = 1025, gender = 2, locationReservationRadius = 0, lookAtText = "@theme_park_lookat:lambda", movementDatatable = "datatables/movement/movement_human.iff", niche = 5, noBuildRadius = 0, objectName = "@theme_park_name:lambda", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", postureAlignToTerrain = {0,0,1,0,0,1,0,1,0,0,0,0,1,1,1}, race = 0, rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slopeModAngle = 15, slopeModPercent = 0.1, slotDescriptorFilename = "", snapToTerrain = 1, socketDestinations = {}, species = 216, speed = {6,2}, stepHeight = 0.5, structureFootprintFileName = "", surfaceType = 0, swimHeight = 1, targetable = 1, totalCellNumber = 0, turnRate = {90,180}, useStructureFootprintOutline = 0, warpTolerance = 17, waterModPercent = 0.5, clientObjectCRC = 3655546204, derivedFromTemplates = {"object/object/base/shared_base_object.iff", "object/tangible/base/shared_tangible_base.iff", "object/creature/base/shared_base_creature.iff", "object/creature/npc/base/shared_base_npc.iff", "object/creature/npc/base/shared_base_npc_theme_park.iff"} ]] } ObjectTemplates:addClientTemplate(object_creature_npc_theme_park_shared_lambda_shuttle_faction_perk, "object/creature/npc/theme_park/shared_lambda_shuttle_faction_perk.iff") object_creature_npc_theme_park_shared_player_shuttle = SharedCreatureObjectTemplate:new { clientTemplateFileName = "object/creature/npc/theme_park/shared_player_shuttle.iff" --Data below here is deprecated and loaded from the tres, keeping for easy lookups --[[ acceleration = {6,2}, animationMapFilename = "all_male.map", appearanceFilename = "appearance/player_shuttle.sat", arrangementDescriptorFilename = "", cameraHeight = 0, certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "clientdata/client_shared_player_shuttle.cdf", clientGameObjectType = 1025, collisionActionBlockFlags = 0, collisionActionFlags = 255, collisionActionPassFlags = 0, collisionHeight = 1.8, collisionLength = 1.5, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, collisionOffsetX = 0, collisionOffsetZ = 0, collisionRadius = 0.5, containerType = 1, containerVolumeLimit = 0, customizationVariableMapping = {}, detailedDescription = "", gameObjectType = 1025, gender = 2, locationReservationRadius = 0, lookAtText = "@theme_park_lookat:shuttle", movementDatatable = "datatables/movement/movement_human.iff", niche = 5, noBuildRadius = 0, objectName = "@theme_park_name:shuttle", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", postureAlignToTerrain = {0,0,1,0,0,1,0,1,0,0,0,0,1,1,1}, race = 0, rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slopeModAngle = 15, slopeModPercent = 0.1, slotDescriptorFilename = "abstract/slot/descriptor/hack_transport.iff", snapToTerrain = 1, socketDestinations = {}, species = 1, speed = {6,2}, stepHeight = 0.5, structureFootprintFileName = "", surfaceType = 0, swimHeight = 1, targetable = 1, totalCellNumber = 0, turnRate = {90,180}, useStructureFootprintOutline = 0, warpTolerance = 17, waterModPercent = 0.5, clientObjectCRC = 1984806965, derivedFromTemplates = {"object/object/base/shared_base_object.iff", "object/tangible/base/shared_tangible_base.iff", "object/creature/base/shared_base_creature.iff", "object/creature/npc/base/shared_base_npc.iff", "object/creature/npc/base/shared_base_npc_theme_park.iff"} ]] } ObjectTemplates:addClientTemplate(object_creature_npc_theme_park_shared_player_shuttle, "object/creature/npc/theme_park/shared_player_shuttle.iff") object_creature_npc_theme_park_shared_player_transport = SharedCreatureObjectTemplate:new { clientTemplateFileName = "object/creature/npc/theme_park/shared_player_transport.iff" --Data below here is deprecated and loaded from the tres, keeping for easy lookups --[[ acceleration = {6,2}, animationMapFilename = "all_male.map", appearanceFilename = "appearance/player_transport.sat", arrangementDescriptorFilename = "", cameraHeight = 0, certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "clientdata/client_shared_player_transport.cdf", clientGameObjectType = 1025, collisionActionBlockFlags = 0, collisionActionFlags = 255, collisionActionPassFlags = 0, collisionHeight = 1.8, collisionLength = 1.5, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, collisionOffsetX = 0, collisionOffsetZ = 0, collisionRadius = 0.5, containerType = 1, containerVolumeLimit = 0, customizationVariableMapping = {}, detailedDescription = "", gameObjectType = 1025, gender = 1, locationReservationRadius = 0, lookAtText = "@theme_park_lookat:transport", movementDatatable = "datatables/movement/movement_human.iff", niche = 5, noBuildRadius = 0, objectName = "@theme_park_name:transport", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", postureAlignToTerrain = {0,0,1,0,0,1,0,1,0,0,0,0,1,1,1}, race = 0, rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slopeModAngle = 15, slopeModPercent = 0.1, slotDescriptorFilename = "abstract/slot/descriptor/hack_transport.iff", snapToTerrain = 1, socketDestinations = {}, species = 1, speed = {6,2}, stepHeight = 0.5, structureFootprintFileName = "", surfaceType = 0, swimHeight = 1, targetable = 1, totalCellNumber = 0, turnRate = {90,180}, useStructureFootprintOutline = 0, warpTolerance = 17, waterModPercent = 0.5, clientObjectCRC = 1196401137, derivedFromTemplates = {"object/object/base/shared_base_object.iff", "object/tangible/base/shared_tangible_base.iff", "object/creature/base/shared_base_creature.iff", "object/creature/npc/base/shared_base_npc.iff", "object/creature/npc/base/shared_base_npc_theme_park.iff"} ]] } ObjectTemplates:addClientTemplate(object_creature_npc_theme_park_shared_player_transport, "object/creature/npc/theme_park/shared_player_transport.iff") object_creature_npc_theme_park_shared_player_transport_theed_hangar = SharedCreatureObjectTemplate:new { clientTemplateFileName = "object/creature/npc/theme_park/shared_player_transport_theed_hangar.iff" --Data below here is deprecated and loaded from the tres, keeping for easy lookups --[[ acceleration = {6,2}, animationMapFilename = "all_male.map", appearanceFilename = "appearance/player_transport_theed_hangar.sat", arrangementDescriptorFilename = "", cameraHeight = 0, certificationsRequired = {}, clearFloraRadius = 0, clientDataFile = "clientdata/client_shared_player_transport.cdf", clientGameObjectType = 1025, collisionActionBlockFlags = 0, collisionActionFlags = 255, collisionActionPassFlags = 0, collisionHeight = 1.8, collisionLength = 1.5, collisionMaterialBlockFlags = 0, collisionMaterialFlags = 1, collisionMaterialPassFlags = 0, collisionOffsetX = 0, collisionOffsetZ = 0, collisionRadius = 0.5, containerType = 1, containerVolumeLimit = 0, customizationVariableMapping = {}, detailedDescription = "", gameObjectType = 1025, gender = 2, locationReservationRadius = 0, lookAtText = "@theme_park_lookat:transport", movementDatatable = "datatables/movement/movement_human.iff", niche = 5, noBuildRadius = 0, objectName = "@theme_park_name:transport", onlyVisibleInTools = 0, paletteColorCustomizationVariables = {}, portalLayoutFilename = "", postureAlignToTerrain = {0,0,1,0,0,1,0,1,0,0,0,0,1,1,1}, race = 0, rangedIntCustomizationVariables = {}, scale = 1, scaleThresholdBeforeExtentTest = 0.5, sendToClient = 1, slopeModAngle = 15, slopeModPercent = 0.1, slotDescriptorFilename = "abstract/slot/descriptor/hack_transport.iff", snapToTerrain = 1, socketDestinations = {}, species = 1, speed = {6,2}, stepHeight = 0.5, structureFootprintFileName = "", surfaceType = 0, swimHeight = 1, targetable = 1, totalCellNumber = 0, turnRate = {90,180}, useStructureFootprintOutline = 0, warpTolerance = 17, waterModPercent = 0.5, clientObjectCRC = 773296996, derivedFromTemplates = {"object/object/base/shared_base_object.iff", "object/tangible/base/shared_tangible_base.iff", "object/creature/base/shared_base_creature.iff", "object/creature/npc/base/shared_base_npc.iff", "object/creature/npc/base/shared_base_npc_theme_park.iff"} ]] } ObjectTemplates:addClientTemplate(object_creature_npc_theme_park_shared_player_transport_theed_hangar, "object/creature/npc/theme_park/shared_player_transport_theed_hangar.iff")
agpl-3.0
DailyShana/ygopro-scripts
c68319538.lua
3
2750
--宇宙砦ゴルガー function c68319538.initial_effect(c) --synchro summon aux.AddSynchroProcedure(c,aux.FilterBoolFunction(Card.IsCode,652362),aux.NonTuner(Card.IsSetCard,0xc),1) c:EnableReviveLimit() --to hand local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(68319538,0)) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_COUNTER) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetCountLimit(1) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetRange(LOCATION_MZONE) e1:SetTarget(c68319538.target) e1:SetOperation(c68319538.operation) c:RegisterEffect(e1) --destroy local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(68319538,1)) e2:SetCategory(CATEGORY_DESTROY) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1) e2:SetCost(c68319538.descost) e2:SetTarget(c68319538.destg) e2:SetOperation(c68319538.desop) c:RegisterEffect(e2) end function c68319538.filter(c) return c:IsFaceup() and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToHand() end function c68319538.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsOnField() and c68319538.filter(chkc) end if chk==0 then return Duel.IsExistingTarget(c68319538.filter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND) local eg=Duel.SelectTarget(tp,c68319538.filter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,11,nil) Duel.SetOperationInfo(0,CATEGORY_TOHAND,eg,eg:GetCount(),0,0) end function c68319538.operation(e,tp,eg,ep,ev,re,r,rp) local tg=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS) local rg=tg:Filter(Card.IsRelateToEffect,nil,e) local ct=Duel.SendtoHand(rg,nil,REASON_EFFECT) if ct==0 then return end local g=Duel.GetMatchingGroup(Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,nil) if g:GetCount()==0 then return end for i=1,ct do Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(68319538,2)) local sg=g:Select(tp,1,1,nil) sg:GetFirst():AddCounter(0xe,1) end end function c68319538.descost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsCanRemoveCounter(tp,1,1,0xe,2,REASON_COST) end Duel.RemoveCounter(tp,1,1,0xe,2,REASON_COST) end function c68319538.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsOnField() and chkc:IsControler(1-tp) and chkc:IsDestructable() end if chk==0 then return Duel.IsExistingTarget(Card.IsDestructable,tp,0,LOCATION_ONFIELD,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectTarget(tp,Card.IsDestructable,tp,0,LOCATION_ONFIELD,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0) end function c68319538.desop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.Destroy(tc,REASON_EFFECT) end end
gpl-2.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/object/draft_schematic/furniture/bestine/painting_bestine_ronka.lua
1
3220
--Copyright (C) 2010 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version object_draft_schematic_furniture_bestine_painting_bestine_ronka = object_draft_schematic_furniture_bestine_shared_painting_bestine_ronka:new { templateType = DRAFTSCHEMATIC, customObjectName = "Painting of a Ronka Plant", craftingToolTab = 512, -- (See DraftSchemticImplementation.h) complexity = 15, size = 2, xpType = "crafting_structure_general", xp = 80, assemblySkill = "structure_assembly", experimentingSkill = "structure_experimentation", customizationSkill = "structure_customization", customizationOptions = {}, customizationStringNames = {}, customizationDefaults = {}, ingredientTemplateNames = {"craft_furniture_ingredients_n", "craft_furniture_ingredients_n", "craft_furniture_ingredients_n"}, ingredientTitleNames = {"frame", "canvas", "paints"}, ingredientSlotType = {0, 0, 0}, resourceTypes = {"metal", "hide", "petrochem_inert_polymer"}, resourceQuantities = {50, 50, 40}, contribution = {100, 100, 100}, targetTemplate = "object/tangible/painting/painting_bestine_ronka.iff", additionalTemplates = { } } ObjectTemplates:addTemplate(object_draft_schematic_furniture_bestine_painting_bestine_ronka, "object/draft_schematic/furniture/bestine/painting_bestine_ronka.iff")
agpl-3.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/commands/headShot1.lua
1
2435
--Copyright (C) 2007 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. --true = 1, false = 0 HeadShot1Command = { name = "headshot1", damageMultiplier = 2, speedMultiplier = 1, healthCostMultiplier = 0.5, actionCostMultiplier = 0.75, mindCostMultiplier = 0.5, accuracyBonus = 50, poolsToDamage = HEALTH_ATTRIBUTE, animationCRC = hashCode("fire_1_special_single_medium_face"), combatSpam = "headshot", weaponType = RIFLEWEAPON, range = -1 } AddCommand(HeadShot1Command)
agpl-3.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/mobile/corellia/selonian_healer.lua
2
1638
selonian_healer = Creature:new { objectName = "@mob/creature_names:selonian_healer", randomNameType = NAME_GENERIC_TAG, socialGroup = "selonian", faction = "", level = 7, chanceHit = 0.26, damageMin = 55, damageMax = 65, baseXp = 187, baseHAM = 405, baseHAMmax = 495, armor = 0, resists = {0,0,0,0,0,0,0,-1,-1}, meatType = "", meatAmount = 0, hideType = "", hideAmount = 0, boneType = "", boneAmount = 0, milk = 0, tamingChance = 0, ferocity = 0, pvpBitmask = ATTACKABLE, creatureBitmask = PACK + HEALER, optionsBitmask = 128, diet = HERBIVORE, templates = { "object/mobile/dressed_selonian_f_01.iff", "object/mobile/dressed_selonian_f_02.iff", "object/mobile/dressed_selonian_f_03.iff", "object/mobile/dressed_selonian_f_04.iff", "object/mobile/dressed_selonian_f_05.iff", "object/mobile/dressed_selonian_f_06.iff", "object/mobile/dressed_selonian_f_07.iff", "object/mobile/dressed_selonian_f_08.iff", "object/mobile/dressed_selonian_f_09.iff", "object/mobile/dressed_selonian_f_10.iff", "object/mobile/dressed_selonian_f_11.iff", "object/mobile/dressed_selonian_f_12.iff"}, lootGroups = { { groups = { {group = "junk", chance = 3000000}, {group = "wearables_common", chance = 2000000}, {group = "pistols", chance = 1000000}, {group = "loot_kit_parts", chance = 2500000}, {group = "tailor_components", chance = 1500000} } } }, weapons = {"rebel_weapons_light"}, conversationTemplate = "", reactionStf = "@npc_reaction/fancy", attacks = merge(brawlernovice,marksmannovice) } CreatureTemplates:addCreatureTemplate(selonian_healer, "selonian_healer")
agpl-3.0
Whitechaser/darkstar
scripts/globals/weaponskills/garland_of_bliss.lua
2
1805
----------------------------------- -- Garland Of Bliss -- Staff weapon skill -- Skill level: N/A -- Lowers target's defense. Duration of effect varies with TP. Nirvana: Aftermath effect varies with TP. -- Reduces enemy's defense by 12.5%. -- Available only after completing the Unlocking a Myth (Summoner) quest. -- Aligned with the Flame Gorget, Light Gorget & Aqua Gorget. -- Aligned with the Flame Belt, Light Belt & Aqua Belt. -- Element: Light -- Modifiers: MND:40% -- 100%TP 200%TP 300%TP -- 2.00 2.00 2.00 ----------------------------------- require("scripts/globals/magic"); require("scripts/globals/status"); require("scripts/globals/settings"); require("scripts/globals/weaponskills"); ----------------------------------- function onUseWeaponSkill(player, target, wsID, tp, primary, action, taChar) local params = {}; params.ftp100 = 2; params.ftp200 = 2; params.ftp300 = 2; 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.4; params.chr_wsc = 0.0; params.ele = ELE_LIGHT; params.skill = SKILL_STF; params.includemab = true; if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then params.ftp100 = 2.25; params.ftp200 = 2.25; params.ftp300 = 2.25; params.str_wsc = 0.3; params.mnd_wsc = 0.7; end local damage, criticalHit, tpHits, extraHits = doMagicWeaponskill(player, target, wsID, tp, primary, action, params); if (damage > 0 and target:hasStatusEffect(dsp.effects.DEFENSE_DOWN) == false) then local duration = (30 + (tp/1000 * 30)) * applyResistanceAddEffect(player,target,ELE_WIND,0); target:addStatusEffect(dsp.effects.DEFENSE_DOWN, 12.5, 0, duration); end return tpHits, extraHits, criticalHit, damage; end
gpl-3.0
TWEFF/Luci
applications/luci-radvd/luasrc/model/cbi/radvd/interface.lua
78
7996
--[[ LuCI - Lua Configuration Interface Copyright 2010 Jo-Philipp Wich <xm@subsignal.org> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 $Id$ ]]-- local sid = arg[1] local utl = require "luci.util" m = Map("radvd", translatef("Radvd - Interface %q", "?"), translate("Radvd is a router advertisement daemon for IPv6. " .. "It listens to router solicitations and sends router advertisements " .. "as described in RFC 4861.")) m.redirect = luci.dispatcher.build_url("admin/network/radvd") if m.uci:get("radvd", sid) ~= "interface" then luci.http.redirect(m.redirect) return end m.uci:foreach("radvd", "interface", function(s) if s['.name'] == sid and s.interface then m.title = translatef("Radvd - Interface %q", s.interface) return false end end) s = m:section(NamedSection, sid, "interface", translate("Interface Configuration")) s.addremove = false s:tab("general", translate("General")) s:tab("timing", translate("Timing")) s:tab("mobile", translate("Mobile IPv6")) -- -- General -- o = s:taboption("general", Flag, "ignore", translate("Enable")) o.rmempty = false function o.cfgvalue(...) local v = Flag.cfgvalue(...) return v == "1" and "0" or "1" end function o.write(self, section, value) Flag.write(self, section, value == "1" and "0" or "1") end o = s:taboption("general", Value, "interface", translate("Interface"), translate("Specifies the logical interface name this section belongs to")) o.template = "cbi/network_netlist" o.nocreate = true o.optional = false function o.formvalue(...) return Value.formvalue(...) or "-" end function o.validate(self, value) if value == "-" then return nil, translate("Interface required") end return value end function o.write(self, section, value) m.uci:set("radvd", section, "ignore", 0) m.uci:set("radvd", section, "interface", value) end o = s:taboption("general", DynamicList, "client", translate("Clients"), translate("Restrict communication to specified clients, leave empty to use multicast")) o.rmempty = true o.datatype = "ip6addr" o.placeholder = "any" function o.cfgvalue(...) local v = Value.cfgvalue(...) local l = { } for v in utl.imatch(v) do l[#l+1] = v end return l end o = s:taboption("general", Flag, "AdvSendAdvert", translate("Enable advertisements"), translate("Enables router advertisements and solicitations")) o.rmempty = false function o.write(self, section, value) if value == "1" then m.uci:set("radvd", section, "ignore", 0) m.uci:set("radvd", section, "IgnoreIfMissing", 1) end m.uci:set("radvd", section, "AdvSendAdvert", value) end o = s:taboption("general", Flag, "UnicastOnly", translate("Unicast only"), translate("Indicates that the underlying link is not broadcast capable, prevents unsolicited advertisements from being sent")) o:depends("AdvSendAdvert", "1") o = s:taboption("general", Flag, "AdvManagedFlag", translate("Managed flag"), translate("Enables the additional stateful administered autoconfiguration protocol (RFC2462)")) o:depends("AdvSendAdvert", "1") o = s:taboption("general", Flag, "AdvOtherConfigFlag", translate("Configuration flag"), translate("Enables the autoconfiguration of additional, non address information (RFC2462)")) o:depends("AdvSendAdvert", "1") o = s:taboption("general", Flag, "AdvSourceLLAddress", translate("Source link-layer address"), translate("Includes the link-layer address of the outgoing interface in the RA")) o.rmempty = false o.default = "1" o:depends("AdvSendAdvert", "1") o = s:taboption("general", Value, "AdvLinkMTU", translate("Link MTU"), translate("Advertises the given link MTU in the RA if specified. 0 disables MTU advertisements")) o.datatype = "uinteger" o.placeholder = 0 o:depends("AdvSendAdvert", "1") o = s:taboption("general", Value, "AdvCurHopLimit", translate("Current hop limit"), translate("Advertises the default Hop Count value for outgoing unicast packets in the RA. 0 disables hopcount advertisements")) o.datatype = "uinteger" o.optional = false o.placeholder = 64 o:depends("AdvSendAdvert", "1") o = s:taboption("general", ListValue, "AdvDefaultPreference", translate("Default preference"), translate("Advertises the default router preference")) o.optional = false o.default = "medium" o:value("low", translate("low")) o:value("medium", translate("medium")) o:value("high", translate("high")) o:depends("AdvSendAdvert", "1") -- -- Timing -- o = s:taboption("timing", Value, "MinRtrAdvInterval", translate("Minimum advertisement interval"), translate("The minimum time allowed between sending unsolicited multicast router advertisements from the interface, in seconds")) o.datatype = "uinteger" o.optional = false o.placeholder = 198 o:depends("AdvSendAdvert", "1") o = s:taboption("timing", Value, "MaxRtrAdvInterval", translate("Maximum advertisement interval"), translate("The maximum time allowed between sending unsolicited multicast router advertisements from the interface, in seconds")) o.datatype = "uinteger" o.optional = false o.placeholder = 600 o:depends("AdvSendAdvert", "1") o = s:taboption("timing", Value, "MinDelayBetweenRAs", translate("Minimum advertisement delay"), translate("The minimum time allowed between sending multicast router advertisements from the interface, in seconds")) o.datatype = "uinteger" o.optional = false o.placeholder = 3 o:depends("AdvSendAdvert", "1") o = s:taboption("timing", Value, "AdvReachableTime", translate("Reachable time"), translate("Advertises assumed reachability time in milliseconds of neighbours in the RA if specified. 0 disables reachability advertisements")) o.datatype = "uinteger" o.optional = false o.placeholder = 0 o:depends("AdvSendAdvert", "1") o = s:taboption("timing", Value, "AdvRetransTimer", translate("Retransmit timer"), translate("Advertises wait time in milliseconds between Neighbor Solicitation messages in the RA if specified. 0 disables retransmit advertisements")) o.datatype = "uinteger" o.optional = false o.placeholder = 0 o:depends("AdvSendAdvert", "1") o = s:taboption("timing", Value, "AdvDefaultLifetime", translate("Default lifetime"), translate("Advertises the lifetime of the default router in seconds. 0 indicates that the node is no default router")) o.datatype = "uinteger" o.optional = false o.placeholder = 1800 o:depends("AdvSendAdvert", "1") -- -- Mobile -- o = s:taboption("mobile", Flag, "AdvHomeAgentFlag", translate("Advertise Home Agent flag"), translate("Advertises Mobile IPv6 Home Agent capability (RFC3775)")) o:depends("AdvSendAdvert", "1") o = s:taboption("mobile", Flag, "AdvIntervalOpt", translate("Mobile IPv6 interval option"), translate("Include Mobile IPv6 Advertisement Interval option to RA")) o:depends({AdvHomeAgentFlag = "1", AdvSendAdvert = "1"}) o = s:taboption("mobile", Flag, "AdvHomeAgentInfo", translate("Home Agent information"), translate("Include Home Agent Information in the RA")) o:depends({AdvHomeAgentFlag = "1", AdvSendAdvert = "1"}) o = s:taboption("mobile", Flag, "AdvMobRtrSupportFlag", translate("Mobile IPv6 router registration"), translate("Advertises Mobile Router registration capability (NEMO Basic)")) o:depends({AdvHomeAgentInfo = "1", AdvSendAdvert = "1"}) o = s:taboption("mobile", Value, "HomeAgentLifetime", translate("Home Agent lifetime"), translate("Advertises the time in seconds the router is offering Mobile IPv6 Home Agent services")) o.datatype = "uinteger" o.optional = false o.placeholder = 1800 o:depends({AdvHomeAgentInfo = "1", AdvSendAdvert = "1"}) o = s:taboption("mobile", Value, "HomeAgentPreference", translate("Home Agent preference"), translate("The preference for the Home Agent sending this RA")) o.datatype = "uinteger" o.optional = false o.placeholder = 0 o:depends({AdvHomeAgentInfo = "1", AdvSendAdvert = "1"}) return m
apache-2.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/object/tangible/ship/components/reactor/rct_slayn_vortex_mk1.lua
3
2300
--Copyright (C) 2010 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version object_tangible_ship_components_reactor_rct_slayn_vortex_mk1 = object_tangible_ship_components_reactor_shared_rct_slayn_vortex_mk1:new { } ObjectTemplates:addTemplate(object_tangible_ship_components_reactor_rct_slayn_vortex_mk1, "object/tangible/ship/components/reactor/rct_slayn_vortex_mk1.iff")
agpl-3.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/object/mobile/dressed_nym_brawler_nikto_m.lua
3
2224
--Copyright (C) 2010 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version object_mobile_dressed_nym_brawler_nikto_m = object_mobile_shared_dressed_nym_brawler_nikto_m:new { } ObjectTemplates:addTemplate(object_mobile_dressed_nym_brawler_nikto_m, "object/mobile/dressed_nym_brawler_nikto_m.iff")
agpl-3.0
Whitechaser/darkstar
scripts/globals/mobskills/trample.lua
2
1064
--------------------------------------------------- -- Trample -- Family: Bahamut -- Description: Deals physical damage to enemies in an area of effect. Additional effect: Knockback + Bind -- Type: Physical -- Utsusemi/Blink absorb: 2-3 shadows -- Range: -- Notes: --------------------------------------------------- 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 typeEffect = dsp.effects.BIND; local duration = 30; MobPhysicalStatusEffectMove(mob, target, skill, typeEffect, 1, 0, duration); local numhits = 1; local accmod = 1; local dmgmod = 3; local info = MobPhysicalMove(mob,target,skill,numhits,accmod,dmgmod,TP_NO_EFFECT); local dmg = MobFinalAdjustments(info.dmg,mob,skill,target,MOBSKILL_PHYSICAL,MOBPARAM_SLASH,MOBPARAM_3_SHADOW); target:delHP(dmg); return dmg; end;
gpl-3.0
sjznxd/lc-20130116
modules/niu/luasrc/model/cbi/niu/network/ddns1.lua
37
1993
--[[ LuCI - Lua Configuration Interface Copyright 2008 Steven Barth <steven@midlink.org> Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 $Id$ ]]-- local nxo = require "nixio" m = Map("ddns", translate("Dynamic DNS"), translate("Dynamic DNS allows that this device can be reached with a fixed hostname while having a dynamically changing IP-Address.")) s = m:section(TypedSection, "service", "") s:depends("enabled", "1") s.addremove = true s.defaults.enabled = "1" s.defaults.ip_network = "wan" s.defaults.ip_url = "http://checkip.dyndns.org http://www.whatismyip.com/automation/n09230945.asp" s:tab("general", translate("General Settings")) svc = s:taboption("general", ListValue, "service_name", translate("Service")) svc:value("dyndns.org") svc:value("no-ip.com") svc:value("changeip.com") svc:value("zoneedit.com") s:taboption("general", Value, "username", translate("Username")) pw = s:taboption("general", Value, "password", translate("Password")) pw.password = true local dom = s:taboption("general", Value, "domain", translate("Hostname")) local current = s:taboption("general", DummyValue, "_current", "Current IP-Address") function current.render(self, section, ...) if dom:cfgvalue(section) then return DummyValue.render(self, section, ...) end end function current.value(self, section) local dns = nxo.getaddrinfo(dom:cfgvalue(section)) if dns then for _, v in ipairs(dns) do if v.family == "inet" then return v.address end end end return "" end s:tab("expert", translate("Expert Settings")) local src = s:taboption("expert", ListValue, "ip_source", "External IP Determination") src.default = "web" src:value("web", "CheckIP / WhatIsMyIP webservice") src:value("network", "External Address as seen locally") return m
apache-2.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/object/mobile/space_comm_station_rori.lua
3
2208
--Copyright (C) 2010 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version object_mobile_space_comm_station_rori = object_mobile_shared_space_comm_station_rori:new { } ObjectTemplates:addTemplate(object_mobile_space_comm_station_rori, "object/mobile/space_comm_station_rori.iff")
agpl-3.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/commands/legShot2.lua
2
2571
--Copyright (C) 2007 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version --which carries forward this exception. --true = 1, false = 0 LegShot2Command = { name = "legshot2", damageMultiplier = 2, speedMultiplier = 2, healthCostMultiplier = 0.5, actionCostMultiplier = 1.5, mindCostMultiplier = 1.5, accuracyBonus = 25, stateEffects = { StateEffect( STUN_EFFECT, {}, { "stun_defense", "resistance_states" }, { "jedi_state_defense" }, 85, 0, 45 ) }, poolsToDamage = ACTION_ATTRIBUTE, animationCRC = hashCode("test_homing"), combatSpam = "legshot", weaponType = CARBINEWEAPON, range = -1 } AddCommand(LegShot2Command)
agpl-3.0
KingRaptor/Zero-K
LuaUI/Widgets/unit_auto_reclaim_heal_assist.lua
7
2977
----------------------------------- -- Author: Johan Hanssen Seferidis -- -- Comments: Sets all idle units that are not selected to fight. That has as effect to reclaim if there is low metal -- , repair nearby units and assist in building if they have the possibility. -- If you select the unit while it is being idle the widget is not going to take effect on the selected unit. -- ------------------------------------------------------------------------------------- function widget:GetInfo() return { name = "Auto Reclaim/Heal/Assist", desc = "Makes idle unselected builders/rez/com/nanos to reclaim metal if metal bar is not full, repair nearby units and assist in building", author = "Pithikos", date = "Nov 21, 2010", --Nov 7, 2013 license = "GPLv3", layer = 0, enabled = false } end -------------------------------------------------------------------------------------- local echo = Spring.Echo local getUnitPos = Spring.GetUnitPosition local orderUnit = Spring.GiveOrderToUnit local getUnitTeam = Spring.GetUnitTeam local isUnitSelected = Spring.IsUnitSelected local gameInSecs = 0 local lastOrderGivenInSecs= 0 local idleReclaimers={} --reclaimers because they all can reclaim myTeamID=-1; -------------------------------------------------------------------------------------- --Initializer function widget:Initialize() --disable widget if I am a spec local _, _, spec = Spring.GetPlayerInfo(Spring.GetMyPlayerID()) if spec then widgetHandler:RemoveWidget() return false end myTeamID = Spring.GetMyTeamID() --get my team ID end --Give reclaimers the FIGHT command every second function widget:GameFrame(n) if n%30 == 0 then if WG.Cutscene and WG.Cutscene.IsInCutscene() then return end for unitID in pairs(idleReclaimers) do local x, y, z = getUnitPos(unitID) --get unit's position if (not isUnitSelected(unitID)) then --if unit is not selected orderUnit(unitID, CMD.FIGHT, { x, y, z }, {}) --command unit to reclaim end end end end --Add reclaimer to the register function widget:UnitIdle(unitID, unitDefID, unitTeam) if (myTeamID==getUnitTeam(unitID)) then --check if unit is mine local factoryType = UnitDefs[unitDefID].isFactory --*** if factoryType then return end --no factories *** if (UnitDefs[unitDefID]["canReclaim"]) then --check if unit can reclaim idleReclaimers[unitID]=true --add unit to register --echo("<auto_reclaim_heal_assist>: registering unit "..unitID.." as idle") end end end --Unregister reclaimer once it is given a command function widget:UnitCommand(unitID) --echo("<auto_reclaim_heal_assist>: unit "..unitID.." got a command") --¤debug for reclaimerID in pairs(idleReclaimers) do if (reclaimerID==unitID) then idleReclaimers[reclaimerID]=nil --echo("<auto_reclaim_heal_assist>: unregistering unit "..reclaimerID.." as idle") end end end
gpl-2.0
Whitechaser/darkstar
scripts/zones/Konschtat_Highlands/Zone.lua
4
2668
----------------------------------- -- -- Zone: Konschtat_Highlands (108) -- ----------------------------------- package.loaded["scripts/zones/Konschtat_Highlands/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Konschtat_Highlands/TextIDs"); require("scripts/globals/icanheararainbow"); require("scripts/globals/chocobo_digging"); require("scripts/globals/conquest"); require("scripts/globals/missions"); local itemMap = { -- itemid, abundance, requirement { 847, 13, DIGREQ_NONE }, { 880, 165, DIGREQ_NONE }, { 690, 68, DIGREQ_NONE }, { 864, 80, DIGREQ_NONE }, { 768, 90, DIGREQ_NONE }, { 869, 63, DIGREQ_NONE }, { 749, 14, DIGREQ_NONE }, { 17296, 214, DIGREQ_NONE }, { 844, 14, DIGREQ_NONE }, { 868, 45, DIGREQ_NONE }, { 642, 71, DIGREQ_NONE }, { 4096, 100, DIGREQ_NONE }, -- all crystals { 845, 28, DIGREQ_BORE }, { 842, 27, DIGREQ_BORE }, { 843, 23, DIGREQ_BORE }, { 1845, 22, DIGREQ_BORE }, { 838, 19, DIGREQ_BORE }, { 4570, 10, DIGREQ_MODIFIER }, { 4487, 11, DIGREQ_MODIFIER }, { 4409, 12, DIGREQ_MODIFIER }, { 1188, 10, DIGREQ_MODIFIER }, { 4532, 12, DIGREQ_MODIFIER }, }; local messageArray = { DIG_THROW_AWAY, FIND_NOTHING, ITEM_OBTAINED }; function onChocoboDig(player, precheck) return chocoboDig(player, itemMap, precheck, messageArray); end; function onInitialize(zone) end; function onZoneIn( player, prevZone) local cs = -1; if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then player:setPos( 521.922, 28.361, 747.85, 45); end if (triggerLightCutscene(player)) then -- Quest: I Can Hear A Rainbow cs = 104; elseif (player:getCurrentMission(WINDURST) == VAIN and player:getVar("MissionStatus") ==1) then cs = 106; end return cs; end; function onConquestUpdate(zone, updatetype) local players = zone:getPlayers(); for name, player in pairs(players) do conquestUpdate(zone, player, updatetype, CONQUEST_BASE); end end; function onRegionEnter( player, region) end; function onEventUpdate( player, csid, option) if (csid == 104) then lightCutsceneUpdate(player); -- Quest: I Can Hear A Rainbow elseif (csid == 106) then if (player:getZPos() > 855) then player:updateEvent(0,0,0,0,0,2); elseif (player:getXPos() > 32 and player:getXPos() < 370) then player:updateEvent(0,0,0,0,0,1); end end end; function onEventFinish( player, csid, option) if (csid == 104) then lightCutsceneFinish(player); -- Quest: I Can Hear A Rainbow end end;
gpl-3.0
major/lxc
src/lua-lxc/lxc.lua
26
10159
-- -- lua lxc module -- -- Copyright © 2012 Oracle. -- -- Authors: -- Dwight Engen <dwight.engen@oracle.com> -- -- This library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public -- License as published by the Free Software Foundation; either -- version 2.1 of the License, or (at your option) any later version. -- -- This library 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 -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this library; if not, write to the Free Software -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -- local core = require("lxc.core") local lfs = require("lfs") local table = require("table") local string = require("string") local io = require("io") module("lxc", package.seeall) local lxc_path local log_level = 3 -- lua 5.1 compat if table.unpack == nil then table.unpack = unpack end -- the following two functions can be useful for debugging function printf(...) local function wrapper(...) io.write(string.format(...)) end local status, result = pcall(wrapper, ...) if not status then error(result, 2) end end function log(level, ...) if (log_level >= level) then printf(os.date("%Y-%m-%d %T ")) printf(...) end end function string:split(delim, max_cols) local cols = {} local start = 1 local nextc repeat nextc = string.find(self, delim, start) if (nextc and #cols ~= max_cols - 1) then table.insert(cols, string.sub(self, start, nextc-1)) start = nextc + #delim else table.insert(cols, string.sub(self, start, string.len(self))) nextc = nil end until nextc == nil or start > #self return cols end -- container class container = {} container_mt = {} container_mt.__index = container function container:new(lname, config) local lcore local lnetcfg = {} local lstats = {} if lname then if config then lcore = core.container_new(lname, config) else lcore = core.container_new(lname) end end return setmetatable({ctname = lname, core = lcore, netcfg = lnetcfg, stats = lstats}, container_mt) end -- methods interfacing to core functionality function container:attach(what, ...) return self.core:attach(what, ...) end function container:config_file_name() return self.core:config_file_name() end function container:defined() return self.core:defined() end function container:init_pid() return self.core:init_pid() end function container:name() return self.core:name() end function container:start() return self.core:start() end function container:stop() return self.core:stop() end function container:shutdown(timeout) return self.core:shutdown(timeout) end function container:wait(state, timeout) return self.core:wait(state, timeout) end function container:freeze() return self.core:freeze() end function container:unfreeze() return self.core:unfreeze() end function container:running() return self.core:running() end function container:state() return self.core:state() end function container:create(template, ...) return self.core:create(template, ...) end function container:destroy() return self.core:destroy() end function container:get_config_path() return self.core:get_config_path() end function container:set_config_path(path) return self.core:set_config_path(path) end function container:append_config_item(key, value) return self.core:set_config_item(key, value) end function container:clear_config_item(key) return self.core:clear_config_item(key) end function container:get_cgroup_item(key) return self.core:get_cgroup_item(key) end function container:get_config_item(key) local value local vals = {} value = self.core:get_config_item(key) -- check if it is a single item if (not value or not string.find(value, "\n")) then return value end -- it must be a list type item, make a table of it vals = value:split("\n", 1000) -- make it a "mixed" table, ie both dictionary and list for ease of use for _,v in ipairs(vals) do vals[v] = true end return vals end function container:set_cgroup_item(key, value) return self.core:set_cgroup_item(key, value) end function container:set_config_item(key, value) return self.core:set_config_item(key, value) end function container:get_keys(base) local ktab = {} local keys if (base) then keys = self.core:get_keys(base) base = base .. "." else keys = self.core:get_keys() base = "" end if (keys == nil) then return nil end keys = keys:split("\n", 1000) for _,v in ipairs(keys) do local config_item = base .. v ktab[v] = self.core:get_config_item(config_item) end return ktab end function container:load_config(alt_path) if (alt_path) then return self.core:load_config(alt_path) else return self.core:load_config() end end function container:save_config(alt_path) if (alt_path) then return self.core:save_config(alt_path) else return self.core:save_config() end end -- methods for stats collection from various cgroup files -- read integers at given coordinates from a cgroup file function container:stat_get_ints(item, coords) local lines = {} local result = {} local flines = self:get_cgroup_item(item) if (flines == nil) then for k,c in ipairs(coords) do table.insert(result, 0) end else for line in flines:gmatch("[^\r\n]+") do table.insert(lines, line) end for k,c in ipairs(coords) do local col col = lines[c[1]]:split(" ", 80) local val = tonumber(col[c[2]]) table.insert(result, val) end end return table.unpack(result) end -- read an integer from a cgroup file function container:stat_get_int(item) local line = self:get_cgroup_item(item) -- if line is nil (on an error like Operation not supported because -- CONFIG_MEMCG_SWAP_ENABLED isn't enabled) return 0 return tonumber(line) or 0 end function container:stat_match_get_int(item, match, column) local val local lines = self:get_cgroup_item(item) if (lines == nil) then return 0 end for line in lines:gmatch("[^\r\n]+") do if (string.find(line, match)) then local col col = line:split(" ", 80) val = tonumber(col[column]) or 0 end end return val end function container:stats_get(total) local stat = {} stat.mem_used = self:stat_get_int("memory.usage_in_bytes") stat.mem_limit = self:stat_get_int("memory.limit_in_bytes") stat.memsw_used = self:stat_get_int("memory.memsw.usage_in_bytes") stat.memsw_limit = self:stat_get_int("memory.memsw.limit_in_bytes") stat.kmem_used = self:stat_get_int("memory.kmem.usage_in_bytes") stat.kmem_limit = self:stat_get_int("memory.kmem.limit_in_bytes") stat.cpu_use_nanos = self:stat_get_int("cpuacct.usage") stat.cpu_use_user, stat.cpu_use_sys = self:stat_get_ints("cpuacct.stat", {{1, 2}, {2, 2}}) stat.blkio = self:stat_match_get_int("blkio.throttle.io_service_bytes", "Total", 2) if (total) then total.mem_used = total.mem_used + stat.mem_used total.mem_limit = total.mem_limit + stat.mem_limit total.memsw_used = total.memsw_used + stat.memsw_used total.memsw_limit = total.memsw_limit + stat.memsw_limit total.kmem_used = total.kmem_used + stat.kmem_used total.kmem_limit = total.kmem_limit + stat.kmem_limit total.cpu_use_nanos = total.cpu_use_nanos + stat.cpu_use_nanos total.cpu_use_user = total.cpu_use_user + stat.cpu_use_user total.cpu_use_sys = total.cpu_use_sys + stat.cpu_use_sys total.blkio = total.blkio + stat.blkio end return stat end local M = { container = container } function M.stats_clear(stat) stat.mem_used = 0 stat.mem_limit = 0 stat.memsw_used = 0 stat.memsw_limit = 0 stat.kmem_used = 0 stat.kmem_limit = 0 stat.cpu_use_nanos = 0 stat.cpu_use_user = 0 stat.cpu_use_sys = 0 stat.blkio = 0 end -- return configured containers found in LXC_PATH directory function M.containers_configured(names_only) local containers = {} for dir in lfs.dir(lxc_path) do if (dir ~= "." and dir ~= "..") then local cfgfile = lxc_path .. "/" .. dir .. "/config" local cfgattr = lfs.attributes(cfgfile) if (cfgattr and cfgattr.mode == "file") then if (names_only) then -- note, this is a "mixed" table, ie both dictionary and list containers[dir] = true table.insert(containers, dir) else local ct = container:new(dir) -- note, this is a "mixed" table, ie both dictionary and list containers[dir] = ct table.insert(containers, dir) end end end end table.sort(containers, function (a,b) return (a < b) end) return containers end -- return running containers found in cgroup fs function M.containers_running(names_only) local containers = {} local names = M.containers_configured(true) for _,name in ipairs(names) do local ct = container:new(name) if ct:running() then -- note, this is a "mixed" table, ie both dictionary and list table.insert(containers, name) if (names_only) then containers[name] = true ct = nil else containers[name] = ct end end end table.sort(containers, function (a,b) return (a < b) end) return containers end function M.version_get() return core.version_get() end function M.default_config_path_get() return core.default_config_path_get() end function M.cmd_get_config_item(name, item, lxcpath) if (lxcpath) then return core.cmd_get_config_item(name, item, lxcpath) else return core.cmd_get_config_item(name, item) end end lxc_path = core.default_config_path_get() return M
lgpl-2.1
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/object/ship/hutt_transport_tier1.lua
3
2188
--Copyright (C) 2010 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version object_ship_hutt_transport_tier1 = object_ship_shared_hutt_transport_tier1:new { } ObjectTemplates:addTemplate(object_ship_hutt_transport_tier1, "object/ship/hutt_transport_tier1.iff")
agpl-3.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/object/static/structure/general/campfire_fresh.lua
3
2244
--Copyright (C) 2010 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version object_static_structure_general_campfire_fresh = object_static_structure_general_shared_campfire_fresh:new { } ObjectTemplates:addTemplate(object_static_structure_general_campfire_fresh, "object/static/structure/general/campfire_fresh.iff")
agpl-3.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/mobile/rori/rorgungan_warrior.lua
1
1117
rorgungan_warrior = Creature:new { objectName = "@mob/creature_names:rorgungan_warrior", randomNameType = NAME_GENERIC_TAG, socialGroup = "rorgungan", faction = "rorgungan", level = 17, chanceHit = 0.31, damageMin = 170, damageMax = 180, baseXp = 1102, baseHAM = 2900, baseHAMmax = 3500, armor = 0, resists = {15,15,0,-1,30,0,0,-1,-1}, meatType = "", meatAmount = 0, hideType = "", hideAmount = 0, boneType = "", boneAmount = 0, milk = 0, tamingChance = 0, ferocity = 0, pvpBitmask = ATTACKABLE, creatureBitmask = PACK + HERD, diet = HERBIVORE, templates = {"object/mobile/gungan_male.iff"}, lootGroups = { { groups = { {group = "junk", chance = 5500000}, {group = "gungan_common", chance = 2000000}, {group = "tailor_components", chance = 500000}, {group = "loot_kit_parts", chance = 1500000}, {group = "color_crystals", chance = 250000}, {group = "crystals_poor", chance = 250000} } } }, weapons = {"rebel_weapons_heavy"}, attacks = merge(brawlermaster,marksmanmaster) } CreatureTemplates:addCreatureTemplate(rorgungan_warrior, "rorgungan_warrior")
agpl-3.0
DailyShana/ygopro-scripts
c64160836.lua
3
1361
--エーリアン・キッズ function c64160836.initial_effect(c) --counter local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetRange(LOCATION_MZONE) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetOperation(c64160836.ctop) c:RegisterEffect(e1) --atk def local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e2:SetCode(EVENT_DAMAGE_CALCULATING) e2:SetRange(LOCATION_MZONE) e2:SetOperation(c64160836.adval) c:RegisterEffect(e2) end function c64160836.ctop(e,tp,eg,ep,ev,re,r,rp) local tc=eg:GetFirst() while tc do if tc:IsFaceup() and tc:IsControler(1-tp) then tc:AddCounter(0xe,1) end tc=eg:GetNext() end end function c64160836.addown(c,e) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetReset(RESET_PHASE+RESET_DAMAGE_CAL) e1:SetValue(c:GetCounter(0xe)*-300) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EFFECT_UPDATE_DEFENCE) c:RegisterEffect(e2) end function c64160836.adval(e,tp,eg,ep,ev,re,r,rp) local a=Duel.GetAttacker() local d=Duel.GetAttackTarget() if not d then return end if a:GetCounter(0xe)>0 and d:IsSetCard(0xc) then c64160836.addown(a,e) end if d:GetCounter(0xe)>0 and a:IsSetCard(0xc) then c64160836.addown(d,e) end end
gpl-2.0
lasko2112/legend-of-hondo
MMOCoreORB/bin/scripts/object/intangible/vehicle/vehicle_pcd_base.lua
3
2228
--Copyright (C) 2010 <SWGEmu> --This File is part of Core3. --This program is free software; you can redistribute --it and/or modify it under the terms of the GNU Lesser --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 Lesser General Public License for --more details. --You should have received a copy of the GNU Lesser General --Public License along with this program; if not, write to --the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --Linking Engine3 statically or dynamically with other modules --is making a combined work based on Engine3. --Thus, the terms and conditions of the GNU Lesser General Public License --cover the whole combination. --In addition, as a special exception, the copyright holders of Engine3 --give you permission to combine Engine3 program with free software --programs or libraries that are released under the GNU LGPL and with --code included in the standard release of Core3 under the GNU LGPL --license (or modified versions of such code, with unchanged license). --You may copy and distribute such a system following the terms of the --GNU LGPL for Engine3 and the licenses of the other code concerned, --provided that you include the source code of that other code when --and as the GNU LGPL requires distribution of source code. --Note that people who make modified versions of Engine3 are not obligated --to grant this special exception for their modified versions; --it is their choice whether to do so. The GNU Lesser General Public License --gives permission to release a modified version without this exception; --this exception also makes it possible to release a modified version object_intangible_vehicle_vehicle_pcd_base = object_intangible_vehicle_shared_vehicle_pcd_base:new { } ObjectTemplates:addTemplate(object_intangible_vehicle_vehicle_pcd_base, "object/intangible/vehicle/vehicle_pcd_base.iff")
agpl-3.0