repo_name
stringlengths
6
69
path
stringlengths
6
178
copies
stringclasses
278 values
size
stringlengths
4
7
content
stringlengths
671
917k
license
stringclasses
15 values
UnfortunateFruit/darkstar
scripts/globals/weaponskills/spinning_axe.lua
30
1364
----------------------------------- -- Spinning Axe -- Axe weapon skill -- Skill level: 150 -- Single-hit attack. Damage varies with TP. -- Will stack with Sneak Attack. -- Aligned with the Flame Gorget, Soil Gorget & Thunder Gorget. -- Aligned with the Flame Belt, Soil Belt & Thunder Belt. -- Element: None -- Modifiers: STR:60% -- 100%TP 200%TP 300%TP -- 2.00 2.50 3.00 ----------------------------------- require("scripts/globals/status"); require("scripts/globals/settings"); require("scripts/globals/weaponskills"); ----------------------------------- function onUseWeaponSkill(player, target, wsID) local params = {}; params.numHits = 1; params.ftp100 = 2; params.ftp200 = 2.5; params.ftp300 = 3; params.str_wsc = 0.35; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.0; params.mnd_wsc = 0.0; params.chr_wsc = 0.0; params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0; params.canCrit = false; params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0; params.atkmulti = 1; if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then params.str_wsc = 0.6; end local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, params); damage = damage * WEAPON_SKILL_POWER return tpHits, extraHits, criticalHit, damage; end
gpl-3.0
nesstea/darkstar
scripts/globals/abilities/meditate.lua
12
1277
----------------------------------- -- Ability: Meditate -- Gradually charges TP. -- Obtained: Samurai Level 30 -- Recast Time: 3:00 (Can be reduced to 2:30 using Merit Points) -- Duration: 15 seconds ----------------------------------- require("scripts/globals/status"); ----------------------------------- -- onAbilityCheck ----------------------------------- function onAbilityCheck(player,target,ability) return 0,0; end; ----------------------------------- -- onUseAbility ----------------------------------- function onUseAbility(player,target,ability) local amount = 12; if (player:getMainJob()==12) then amount = 20; end local tick = 15; local extratick = 0; local sHands = target:getEquipID(SLOT_HANDS); local sHead = target:getEquipID(SLOT_HEAD); -- Todo: change these item checks into a modifier. if (sHands == 15113 or sHands == 14920) then extratick = 1; end if (sHead == 13868 or sHead == 15236) then extratick = extratick + 1; end if (extratick == 1) then extratick = math.random(1,2); elseif (extratick == 2) then extratick = math.random(2,3); end tick = tick + (extratick * 3); player:addStatusEffectEx(EFFECT_MEDITATE,0,amount,3,tick); end;
gpl-3.0
nesstea/darkstar
scripts/globals/items/block_of_rock_cheese.lua
18
1312
----------------------------------------- -- ID: 4593 -- Item: Block of Rock Cheese -- Food Effect: 30Min, All Races ----------------------------------------- -- Health % 5.5 -- Health Cap 45 -- HP Recovered while healing 1 ----------------------------------------- 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,1800,4593); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_FOOD_HPP, 5.5); target:addMod(MOD_FOOD_HP_CAP, 45); target:addMod(MOD_HPHEAL, 1); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_FOOD_HPP, 5.5); target:delMod(MOD_FOOD_HP_CAP, 45); target:delMod(MOD_HPHEAL, 1); end;
gpl-3.0
MetSystem/skynet
lualib/skynet/debug.lua
42
1723
local io = io local table = table local debug = debug return function (skynet, export) local internal_info_func function skynet.info_func(func) internal_info_func = func end local dbgcmd local function init_dbgcmd() dbgcmd = {} function dbgcmd.MEM() local kb, bytes = collectgarbage "count" skynet.ret(skynet.pack(kb,bytes)) end function dbgcmd.GC() export.clear() collectgarbage "collect" end function dbgcmd.STAT() local stat = {} stat.mqlen = skynet.mqlen() stat.task = skynet.task() skynet.ret(skynet.pack(stat)) end function dbgcmd.TASK() local task = {} skynet.task(task) skynet.ret(skynet.pack(task)) end function dbgcmd.INFO() if internal_info_func then skynet.ret(skynet.pack(internal_info_func())) else skynet.ret(skynet.pack(nil)) end end function dbgcmd.EXIT() skynet.exit() end function dbgcmd.RUN(source, filename) local inject = require "skynet.inject" local output = inject(skynet, source, filename , export.dispatch, skynet.register_protocol) collectgarbage "collect" skynet.ret(skynet.pack(table.concat(output, "\n"))) end function dbgcmd.TERM(service) skynet.term(service) end function dbgcmd.REMOTEDEBUG(...) local remotedebug = require "skynet.remotedebug" remotedebug.start(export, ...) end function dbgcmd.SUPPORT(pname) return skynet.ret(skynet.pack(skynet.dispatch(pname) ~= nil)) end return dbgcmd end -- function init_dbgcmd local function _debug_dispatch(session, address, cmd, ...) local f = (dbgcmd or init_dbgcmd())[cmd] -- lazy init dbgcmd assert(f, cmd) f(...) end skynet.register_protocol { name = "debug", id = assert(skynet.PTYPE_DEBUG), pack = assert(skynet.pack), unpack = assert(skynet.unpack), dispatch = _debug_dispatch, } end
mit
UnfortunateFruit/darkstar
scripts/zones/Apollyon/bcnms/CS_Apollyon.lua
13
1259
----------------------------------- -- Area: Appolyon -- Name: ----------------------------------- require("scripts/globals/limbus"); require("scripts/globals/keyitems"); -- After registering the BCNM via bcnmRegister(bcnmid) function onBcnmRegister(player,instance) SetServerVariable("[CS_Apollyon]UniqueID",GenerateLimbusKey()); HideArmouryCrates(GetInstanceRegion(1294),APPOLLYON_SE_NE); SetServerVariable("[CS_Apollyon]Already_Received",0); GetNPCByID(16933245):setAnimation(8); GetNPCByID(16933246):setAnimation(8); GetNPCByID(16933247):setAnimation(8); despawnLimbusCS(); player:setVar("Limbus_Trade_Item",0); end; -- Physically entering the BCNM via bcnmEnter(bcnmid) function onBcnmEnter(player,instance) player:setVar("limbusbitmap",0); player:setVar("characterLimbusKey",GetServerVariable("[CS_Apollyon]UniqueID")); player:setVar("LimbusID",1294); player:delKeyItem(COSMOCLEANSE); end; -- Leaving the by every mean possible, given by the LeaveCode -- 3=Disconnected or warped out (if dyna is empty: launch 4 after 3) -- 4=Finish function onBcnmLeave(player,instance,leavecode) --print("leave code "..leavecode); if(leavecode == 4) then player:setPos(-668,0.1,-666); ResetPlayerLimbusVariable(player) end end;
gpl-3.0
trilastiko/keys
VSCOKeys.lrdevplugin/Logging.lua
11
1228
--[[---------------------------------------------------------------------------- VSCO Keys for Adobe Lightroom Copyright (C) 2015 Visual Supply Company Licensed under GNU GPLv2 (or any later version). This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ------------------------------------------------------------------------------]] local LrLogger = import 'LrLogger' local logging = { myLogger = LrLogger( 'VSCOKeys' ) } logging.myLogger:enable( "logfile" ) -- Pass either a string or a table of actions. function logging:log( message ) self.myLogger:trace( message ) end return logging
gpl-2.0
ymauray/Skym_PetCodex
Lib/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua
1
3171
-- Copyright (c) 2014 Yannick Mauray. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License along -- with this program; if not, write to the Free Software Foundation, Inc., -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. --[[----------------------------------------------------------------------------- Heading Widget -------------------------------------------------------------------------------]] local Type, Version = "Heading", 20 local AceGUI = LibStub and LibStub("AceGUI-3.0", true) if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end -- Lua APIs local pairs = pairs -- WoW APIs local CreateFrame, UIParent = CreateFrame, UIParent --[[----------------------------------------------------------------------------- Methods -------------------------------------------------------------------------------]] local methods = { ["OnAcquire"] = function(self) self:SetText() self:SetFullWidth() self:SetHeight(18) end, -- ["OnRelease"] = nil, ["SetText"] = function(self, text) self.label:SetText(text or "") if text and text ~= "" then self.left:SetPoint("RIGHT", self.label, "LEFT", -5, 0) self.right:Show() else self.left:SetPoint("RIGHT", -3, 0) self.right:Hide() end end } --[[----------------------------------------------------------------------------- Constructor -------------------------------------------------------------------------------]] local function Constructor() local frame = CreateFrame("Frame", nil, UIParent) frame:Hide() local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontNormal") label:SetPoint("TOP") label:SetPoint("BOTTOM") label:SetJustifyH("CENTER") local left = frame:CreateTexture(nil, "BACKGROUND") left:SetHeight(8) left:SetPoint("LEFT", 3, 0) left:SetPoint("RIGHT", label, "LEFT", -5, 0) left:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") left:SetTexCoord(0.81, 0.94, 0.5, 1) local right = frame:CreateTexture(nil, "BACKGROUND") right:SetHeight(8) right:SetPoint("RIGHT", -3, 0) right:SetPoint("LEFT", label, "RIGHT", 5, 0) right:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") right:SetTexCoord(0.81, 0.94, 0.5, 1) local widget = { label = label, left = left, right = right, frame = frame, type = Type } for method, func in pairs(methods) do widget[method] = func end return AceGUI:RegisterAsWidget(widget) end AceGUI:RegisterWidgetType(Type, Constructor, Version)
gpl-2.0
nesstea/darkstar
scripts/globals/items/bowl_of_witch_soup.lua
18
1366
----------------------------------------- -- ID: 4333 -- Item: witch_soup -- Food Effect: 4hours, All Races ----------------------------------------- -- Magic Points 25 -- Strength -1 -- Mind 2 -- MP Recovered While Healing 1 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,14400,4333); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_MP, 25); target:addMod(MOD_STR, -1); target:addMod(MOD_MND, 2); target:addMod(MOD_MPHEAL, 1); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_MP, 25); target:delMod(MOD_STR, -1); target:delMod(MOD_MND, 2); target:delMod(MOD_MPHEAL, 1); end;
gpl-3.0
UnfortunateFruit/darkstar
scripts/globals/items/sweet_baked_apple.lua
35
1318
----------------------------------------- -- ID: 4336 -- Item: sweet_baked_apple -- Food Effect: 1hour, All Races ----------------------------------------- -- Magic Points 25 -- Intelligence 4 -- MP Recovered While Healing 2 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,3600,4336); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_MP, 25); target:addMod(MOD_INT, 4); target:addMod(MOD_MPHEAL, 2); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_MP, 25); target:delMod(MOD_INT, 4); target:delMod(MOD_MPHEAL, 2); end;
gpl-3.0
dpino/snabbswitch
src/program/wall/spy/spy.lua
9
6255
-- Use of this source code is governed by the Apache 2.0 license; see COPYING. module(..., package.seeall) local lib = require("core.lib") local now = require("core.app").now local timer = require("core.timer") local ipv4 = require("lib.protocol.ipv4") local ipv6 = require("lib.protocol.ipv6") local util = require("apps.wall.util") local scan = require("apps.wall.scanner") local const = require("apps.wall.constants") local proto = require("ndpi").protocol local comm = require("program.wall.common") local ntohs = lib.ntohs local long_opts = { help = "h", live = "l", stats = "s", duration = "D", } local function printf(fmt, ...) io.write(fmt:format(...)) end local function report_flow(scanner, flow) local lo_addr, hi_addr = "<unknown>", "<unknown>" local eth_type = flow.key:eth_type() if eth_type == const.ETH_TYPE_IPv4 then lo_addr = ipv4:ntop(flow.key.lo_addr) hi_addr = ipv4:ntop(flow.key.hi_addr) elseif eth_type == const.ETH_TYPE_IPv6 then lo_addr = ipv6:ntop(flow.key.lo_addr) hi_addr = ipv6:ntop(flow.key.hi_addr) end if flow.proto_master ~= proto.PROTOCOL_UNKNOWN then printf("%#010x %4dp %15s:%-5d - %15s:%-5d %s:%s\n", flow.key:hash(), flow.packets, lo_addr, ntohs(flow.key.lo_port), hi_addr, ntohs(flow.key.hi_port), scanner:protocol_name(flow.protocol), scanner:protocol_name(flow.proto_master)) else printf("%#010x %4dp %15s:%-5d - %15s:%-5d %s\n", flow.key:hash(), flow.packets, lo_addr, ntohs(flow.key.lo_port), hi_addr, ntohs(flow.key.hi_port), scanner:protocol_name(flow.protocol)) end end local function report_summary(scanner) for flow in scanner:flows() do report_flow(scanner, flow) end end local LiveReporter = setmetatable({}, util.SouthAndNorth) LiveReporter.__index = LiveReporter function LiveReporter:new (scanner) return setmetatable({ scanner = scanner }, self) end function LiveReporter:on_northbound_packet (p) local flow = self.scanner:get_flow(p) if flow and not flow.reported then local proto = self.scanner:protocol_name(flow.protocol) if proto:lower() ~= "unknown" then report_flow(self.scanner, flow) flow.reported = true end end return p end LiveReporter.on_southbound_packet = LiveReporter.on_northbound_packet local StatsReporter = setmetatable({}, util.SouthAndNorth) StatsReporter .__index = StatsReporter function StatsReporter:new (opts) local app = setmetatable({ scanner = opts.scanner, file = opts.output or io.stdout, start_time = now(), packets = 0, bytes = 0, timer = false, }, self) if opts.period then app.timer = timer.new("stats_reporter", function () app:report_stats() end, opts.period * 1e9) timer.activate(app.timer) end return app end function StatsReporter:stop () -- Avoid timer being re-armed in the next call to :on_timer_tick() self.timer = false end function StatsReporter:on_northbound_packet (p) self.packets = self.packets + 1 self.bytes = self.bytes + p.length return p end StatsReporter.on_southbound_packet = StatsReporter.on_northbound_packet local stats_format = "=== %s === %d Bytes, %d packets, %.3f B/s, %.3f PPS\n" function StatsReporter:report_stats () local cur_time = now() local elapsed = cur_time - self.start_time self.file:write(stats_format:format(os.date("%Y-%m-%dT%H:%M:%S%z"), self.bytes, self.packets, self.bytes / elapsed, self.packets / elapsed)) self.file:flush() -- Reset counters. self.packets, self.bytes, self.start_time = 0, 0, cur_time -- Re-arm timer. if self.timer then timer.activate(self.timer) end end local function setup_input(c, input_spec) local kind, arg = input_spec_pattern:match(input_spec) if not kind then kind, arg = "pcap", input_spec end if not comm.inputs[kind] then return nil, "No such input kind: " .. kind end return comm.inputs[kind](kind, arg) end function run (args) local live, stats = false, false local duration local opt = { l = function (arg) live = true end, s = function (arg) stats = true end, h = function (arg) print(require("program.wall.spy.README_inc")) main.exit(0) end, D = function (arg) duration = tonumber(arg) end } args = lib.dogetopt(args, opt, "hlsD:", long_opts) if #args ~= 2 then print(require("program.wall.spy.README_inc")) main.exit(1) end if not comm.inputs[args[1]] then io.stderr:write("No such input available: ", args[1], "\n") main.exit(1) end local source_link_name, app = comm.inputs[args[1]](args[1], args[2]) if not source_link_name then io.stderr:write(app, "\n") main.exit(1) end -- FIXME: When multiple scanners are available, allow selecting others. local s = require("apps.wall.scanner.ndpi"):new() local c = config.new() config.app(c, "source", unpack(app)) config.app(c, "l7spy", require("apps.wall.l7spy").L7Spy, { scanner = s }) config.link(c, "source." .. source_link_name .. " -> l7spy.south") local last_app_name = "l7spy" if stats then config.app(c, "stats", StatsReporter, { scanner = s, period = live and 2.0 or false }) config.link(c, last_app_name .. ".north -> stats.south") last_app_name = "stats" end if live then config.app(c, "report", LiveReporter, s) config.link(c, last_app_name .. ".north -> report.south") last_app_name = "report" end local done if not duration then done = function () return engine.app_table.source.done end end engine.configure(c) engine.busywait = true engine.main { duration = duration, done = done } if not live then report_summary(s) end if stats then engine.app_table.stats:report_stats() end end
apache-2.0
UnfortunateFruit/darkstar
scripts/zones/Balgas_Dais/mobs/Maat.lua
27
1127
----------------------------------- -- Area: Balga Dais -- NPC: Maat -- Genkai 5 Fight ----------------------------------- package.loaded["scripts/zones/Balgas_Dais/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Balgas_Dais/TextIDs"); ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) end; ----------------------------------- -- onMobEngaged Action ----------------------------------- function onMobEngaged(mob,target) -- target:showText(mob,YOU_DECIDED_TO_SHOW_UP); printf("Maat Balga Dais works"); -- When he take damage: target:showText(mob,THAT_LL_HURT_IN_THE_MORNING); -- He use dragon kick or tackle: target:showText(mob,TAKE_THAT_YOU_WHIPPERSNAPPER); -- He use spining attack: target:showText(mob,TEACH_YOU_TO_RESPECT_ELDERS); -- If you dying: target:showText(mob,LOOKS_LIKE_YOU_WERENT_READY); end; ----------------------------------- -- onMobDeath Action ----------------------------------- function onMobDeath(mob,killer) killer:showText(mob,YOUVE_COME_A_LONG_WAY); end;
gpl-3.0
nesstea/darkstar
scripts/zones/Southern_San_dOria/Zone.lua
26
2786
----------------------------------- -- -- Zone: Southern_San_dOria (230) -- ----------------------------------- package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/events/harvest_festivals"); require("scripts/globals/zone"); require("scripts/globals/settings"); require("scripts/zones/Southern_San_dOria/TextIDs"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) zone:registerRegion(1, -292,-10,90 ,-258,10,105); applyHalloweenNpcCostumes(zone:getID()) end; ----------------------------------- -- onZoneIn ----------------------------------- function onZoneIn(player,prevZone) local cs = -1; -- FIRST LOGIN (START CS) if (player:getPlaytime(false) == 0) then if (OPENING_CUTSCENE_ENABLE == 1) then cs = 0x1f7; end player:setPos(-96,1,-40,224); player:setHomePoint(); end -- MOG HOUSE EXIT if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then player:setPos(161,-2,161,94); if (player:getMainJob() ~= player:getVar("PlayerMainJob")) then cs = 0x7534; end player:setVar("PlayerMainJob",0); end return cs; end; ----------------------------------- -- onConquestUpdate ----------------------------------- function onConquestUpdate(zone, updatetype) local players = zone:getPlayers(); for name, player in pairs(players) do conquestUpdate(zone, player, updatetype, CONQUEST_BASE); end end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) local regionID =region:GetRegionID(); if (regionID==1 and player:getCurrentMission(COP) == DAWN and player:getVar("COP_louverance_story")== 2) then player:startEvent(0x02F6); 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 == 0x1f7) then player:messageSpecial(ITEM_OBTAINED,0x218); elseif (csid == 0x7534 and option == 0) then player:setHomePoint(); player:messageSpecial(HOMEPOINT_SET); elseif (csid == 0x02F6) then player:setVar("COP_louverance_story",3); end end;
gpl-3.0
nesstea/darkstar
scripts/globals/items/fuscina.lua
41
1095
----------------------------------------- -- ID: 18104 -- Item: Fuscina -- Additional Effect: Lightning Damage ----------------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------- -- onAdditionalEffect Action ----------------------------------- 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
nesstea/darkstar
scripts/globals/campaign.lua
35
4763
----------------------------------------------------------------- -- Variable for getNationTeleport and getPoint ----------------------------------------------------------------- ALLIED_NOTES = 11; MAW = 4; PAST_SANDORIA = 5; PAST_BASTOK = 6; PAST_WINDURST = 7; -- ------------------------------------------------------------------- -- getMedalRank() -- Returns the numerical Campaign Medal of the player. -- ------------------------------------------------------------------- function getMedalRank(player) local rank = 0; local medals = { 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0, 0x03A1, 0x03A2, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF } while (player:hasKeyItem(medals[rank + 1]) == true) do rank = rank + 1; end; return rank; end; -- ------------------------------------------------------------------- -- get[nation]NotesItem() -- Returns the item ID and cost of the Allied Notes indexed item -- (the same value as that used by the vendor event) -- Format: -- ListName_AN_item[optionID] = itemID; -- ItemName -- ListName_AN_price[optionID] = cost; -- ItemName -- ------------------------------------------------------------------- function getSandOriaNotesItem(i) local SandOria_AN = { [2] = {id = 15754, price = 980}, -- Sprinter's Shoes [258] = {id = 5428, price = 10}, -- Scroll of Instant Retrace [514] = {id = 14584, price = 1500}, -- Iron Ram jack coat [770] = {id = 14587, price = 1500}, -- Pilgrim Tunica [1026] = {id = 16172, price = 4500}, -- Iron Ram Shield [1282] = {id = 15841, price = 5000}, -- Recall Ring: Jugner [1538] = {id = 15842, price = 5000}, -- Recall Ring: Pashow [1794] = {id = 15843, price = 5000}, -- Recall Ring: Meriphataud [2050] = {id = 10116, price = 2000} -- Cipher: Valaineral } local item = SandOria_AN[i]; return item.id, item.price; end; function getBastokNotesItem(i) local Bastok_AN = { [2] = {id = 15754, price = 980}, -- Sprinter's Shoes [258] = {id = 5428, price = 10}, -- Scroll of Instant Retrace -- [514] = {id = ?, price = ?}, -- -- [770] = {id = ?, price = ?}, -- -- [1026] = {id = ?, price = ?}, -- [1282] = {id = 15841, price = 5000}, -- Recall Ring: Jugner [1538] = {id = 15842, price = 5000}, -- Recall Ring: Pashow [1794] = {id = 15843, price = 5000}, -- Recall Ring: Meriphataud [2050] = {id = 10116, price = 2000} -- Cipher: Valaineral } local item = Bastok_AN[i]; return item.id, item.price; end; function getWindurstNotesItem(i) local Windurst_AN = { [2] = {id = 15754, price = 980}, -- Sprinter's Shoes [258] = {id = 5428, price = 10}, -- Scroll of Instant Retrace -- [514] = {id = ?, price = ?}, -- -- [770] = {id = ?, price = ?}, -- -- [1026] = {id = ?, price = ?}, -- [1282] = {id = 15841, price = 5000}, -- Recall Ring: Jugner [1538] = {id = 15842, price = 5000}, -- Recall Ring: Pashow [1794] = {id = 15843, price = 5000}, -- Recall Ring: Meriphataud [2050] = {id = 10116, price = 2000} -- Cipher: Valaineral } local item = Windurst_AN[i]; return item.id, item.price; end; -- ------------------------------------------------------------------- -- getSigilTimeStamp(player) -- This is for the time-stamp telling player what day/time the -- effect will last until, NOT the actual status effect duration. -- ------------------------------------------------------------------- function getSigilTimeStamp(player) local timeStamp = 0; -- zero'd till math is done. -- TODO: calculate time stamp for menu display of when it wears off return timeStamp; end; ----------------------------------- -- hasMawActivated Action ----------------------------------- -- 1st number for hasMawActivated() -- 2nd number for player:addNationTeleport(); -- 0 1 Batallia Downs (S) (H-5) -- 1 2 Rolanberry Fields (S) (H-6) -- 2 4 Sauromugue Champaign (S) (K-9) -- 3 8 Jugner Forest (S) (H-11) -- 4 16 Pashhow Marshlands (S) (K-8) -- 5 32 Meriphataud Mountains (S) (K-6) -- 6 64 East Ronfaure (S) (H-5) -- 7 128 North Gustaberg (S) (K-7) -- 8 256 West Sarutabaruta (S) (H-9) function hasMawActivated(player,portal) local mawActivated = player:getNationTeleport(MAW); local bit = {}; for i = 8,0,-1 do twop = 2^i if (mawActivated >= twop) then bit[i]=true; mawActivated = mawActivated - twop; else bit[i]=false; end end; return bit[portal]; end; -- TODO: -- Past nation teleport
gpl-3.0
booyaa/FromAtoBree
utils/TR_Data.lua
1
73800
-- Database for Travel locations -- coding: utf-8 'ä -- Loc. keys: d=destinations(nil if no stable), z=zone, a=area, l=location -- t=milestone time, ml=minimum level (milestone) -- Dest. keys: c=cost, s=ST cost, l=min level(+ if ST only), r=requires, t=time, st=ST time Max_lvl = 115 Locs = { -- Ered Luin starts here ["Thorin's Gate"] = { t=41, d={ ["Combe"] = { s=1, st=24 }, ["West Bree"] = { s=1, st=28, S0=true }, ["Celondim"] = { s=1, st=24, S0=true }, ["Duillond"] = { c=1, t=307 }, ["Gondamon"] = { c=1, t=180 }, ["Noglond"] = { c=1, t=114 }, ["Ettenmoors"] = { s=1, l=40, st=30, r="s1", S0=true }, ["Michel Delving"] = { s=1, st=24, S0=true }, }, z="Ered Luin", r=1, a="Thorin's Gate", td="R9", l="15.0s,103.6w" }, ["Noglond"] = { d={ -- ["Thorin's Gate"] = { c=1, t=114 }, ["Gondamon"] = { c=1, t=84 }, }, z="Ered Luin", r=1, td="R9", l="19.4s,100.6w" }, ["Gondamon"] = { t=7, d={ ["Thorin's Gate"] = { c=1, t=180 }, ["Duillond"] = { c=1, t=154 }, ["Noglond"] = { c=1, t=84 }, ["Thrasi's Lodge"] = { c=1, t=90 }, }, z="Ered Luin", r=1, td="R9", l="20.4s,97.1w" }, ["Thrasi's Lodge"] = { d={ -- ["Gondamon"] = { c=1, t=90 }, ["Duillond"] = { c=1, t=84 }, }, z="Ered Luin", r=1, l="21.6s,94.1w" }, ["Duillond"] = { t=1, d={ ["Needlehole"] = { c=5, t=150 }, ["Gondamon"] = { c=1, t=154 }, ["Thorin's Gate"] = { c=1, t=307 }, ["Celondim"] = { c=1, t=79 }, ["Falathlorn Homesteads"] = { c=5, t=100 }, ["Thrasi's Lodge"] = { c=1, t=84 }, }, z="Ered Luin", r=1, l="24.4s,93.2w" }, ["Celondim"] = { t=11, d={ ["Combe"] = { s=1, st=18 }, ["West Bree"] = { s=1, st=20, S0=true }, ["Duillond"] = { c=1, t=79 }, ["Thorin's Gate"] = { s=1, st=24, S0=true }, ["Michel Delving"] = { s=1, st=19, S0=true }, }, z="Ered Luin", r=1, l="28.1s,92.4w" }, ["Falathlorn Homesteads"] = { z="Ered Luin", l="24.7s,90.2w" }, -- the Shire starts here ["Michel Delving"] = { t=18, d={ ["Hobbiton"] = { c=1, t=102 }, ["Celondim"] = { s=1, st=19, S0=true }, ["Thorin's Gate"] = { s=1, st=24, S0=true }, ["West Bree"] = { s=1, st=22, S0=true }, ["Ettenmoors"] = { s=100, l=40, st=30, r="s1" }, ["Shire Homesteads"] = { c=5, t=112 }, ["Combe"] = { s=1, st=19 }, ["Tinnudir"] = { s=35, st=38 }, }, z="the Shire", r=1, td="R10", l="34.2s,75.5w" }, ["Hobbiton"] = { t=3, d={ ["West Bree"] = { c=5, t=337 }, ["Michel Delving"] = { c=1, t=102 }, ["Brockenborings"] = { c=1, t=104 }, ["Needlehole"] = { c=1, t=166 }, ["Stock"] = { c=1, t=131 }, }, z="the Shire", r=1, td="R10", l="31.5s,71.2w" }, ["Needlehole"] = { d={ -- ["Hobbiton"] = { c=1, t=166 }, ["Duillond"] = { c=5, t=150 }, }, z="the Shire", r=1, td="R10", l="27.9s,76.1w" }, ["Stock"] = { d={ -- ["Hobbiton"] = { c=1, t=131 }, ["Buckland"] = { c=1, t=69 }, ["Brockenborings"] = { c=1, t=128 }, }, z="the Shire", r=1, td="R10", l="32.1s,64.1w" }, ["Brockenborings"] = { t=14, d={ ["Hobbiton"] = { c=1, t=104 }, ["Stock"] = { c=1, t=128 }, ["Oatbarton"] = { c=15, t=77, s=25, st=15 }, }, z="the Shire", r=1, l="27.4s,68.1w" }, ["Shire Homesteads"] = { z="the Shire", r=1, l="36.4s,72.8w" }, -- Bree-land starts here ["Combe"] = { t=5, d={ ["South Bree"] = { c=1, t=90 }, ["Celondim"] = { s=1, st=18 }, ["Thorin's Gate"] = { s=1, st=24 }, ["Michel Delving"] = { s=1, st=19 }, }, z="Bree-land", r=1, l="28.6s,49.5w" }, ["West Bree"] = { t=31, d={ ["Adso's Camp"] = { c=1, t=67 }, ["Buckland"] = { c=1, t=211 }, ["Hengstacer Farm"] = { c=1, t=160 }, ["South Bree"] = { mt=75, s=1, st=18 }, ["Celondim"] = { s=1, st=20, S0=true }, ["Thorin's Gate"] = { s=1, st=28, S0=true }, ["Ost Forod"] = { s=35, l=30, st=36 }, ["Tinnudir"] = { s=35, st=40 }, ["Suri-kyla"] = { s=35, l=40, st=39, r="R3" }, ["Esteldin"] = { s=35, l=30, st=33 }, ["Trestlebridge"] = { c=5, t=209 }, ["Hobbiton"] = { c=5, t=337 }, ["Michel Delving"] = { s=1, st=22, S0=true }, }, z="Bree-land", r=1, a="Bree", td="R11", l="29.5s,52.6w" }, ["South Bree"] = { t=8, d={ ["a-b Osgiliath"] = { l=90, s=122, st=18 }, ["Bree-land Homesteads"] = { c=5, t=97 }, ["Combe"] = { c=1, t=90 }, ["West Bree"] = { mt=75, s=1, st=18 }, ["Galtrev"] = { s=45, l=65, st=22 }, ["Lhanuch"] = { s=45, l=50, st=28, r="D6" }, ["Celondim"] = { s=1, st=25 }, ["Thorin's Gate"] = { s=1, st=24 }, ["Stangard"] = { s=45, l=70, st=20 }, ["Magh Ashtu"] = { l=90, s=122, st=25 }, ["Minas Tirith"] = { s=115, l=90, st=30 }, ["Snowbourn"] = { l=75, s=71.5, st=42 }, ["Aldburg"] = { l=85, s=71.5, st=24 }, ["Helm's Deep"] = { l=85, s=71.5, st=19 }, ["Forlaw"] = { l=75, s=71.5, st=19 }, ["Dale"] = { l=90, s=122, st=18 }, ["Lake-town"] = { l=90, s=122, st=17 }, ["Ettenmoors"] = { s=1, l=20, st=30, r="s1", S0=true }, ["Ost Guruth"] = { s=20, l=15, st=24 }, ["The Forsaken Inn"] = { c=5, t=190 }, ["Michel Delving"] = { s=1, st=24 }, ["Rivendell"] = { s=35, l=40, st=21 }, ["Dol Amroth"] = { l=90, s=115, st=24 }, }, z="Bree-land", r=1, a="Bree", td="R11", l="31.9s,50.4w" }, ["Adso's Camp"] = { d={ -- ["Buckland"] = { c=1, t=144 }, ["West Bree"] = { c=1, t=67 }, }, z="Bree-land", r=1, td="R11", l="29.2s,56.6w" }, ["Buckland"] = { t=22, d={ ["West Bree"] = { c=1, t=211 }, ["Stock"] = { c=1, t=69 }, ["Adso's Camp"] = { c=1, t=144 }, }, z="Bree-land", r=1, l="29.2s,56.6w" }, ["Bree-land Homesteads"] = { z="Bree-land", l="34.2s,45.7w" }, ["Hengstacer Farm"] = { d={ -- ["Trestlebridge"] = { c=1, t=140 }, ["West Bree"] = { c=1, t=160 }, }, z="Bree-land", r=1, td="R11", l="22.3s,52.3w" }, -- Lone-lands starts here ["The Forsaken Inn"] = { t=12, d={ ["Ost Guruth"] = { c=15, t=203 }, ["South Bree"] = { c=5, t=190 }, }, z="Lone-lands", r=1, l="34.4s,40.6w" }, ["Ost Guruth"] = { t=26, d={ ["The Forsaken Inn"] = { c=15, t=203 }, ["Thorenhad"] = { c=15, t=310, t=310 }, ["Rivendell"] = { c=15, t=609, s=25, st=24 }, ["South Bree"] = { s=25, l=15, st=24 }, }, z="Lone-lands", r=1, td="R13", l="32.1s,29.8w" }, -- North Downs starts here ["Trestlebridge"] = { t=3, d={ ["West Bree"] = { c=15, t=209 }, ["Amon Raith"] = { c=15, t=142 }, ["Esteldin"] = { c=15, t=320 }, ["Tinnudir"] = { c=15, t=363 }, ["Ost Forod"] = { c=15, t=373 }, ["Hengstacer Farm"] = { c=1, t=160 }, }, z="North Downs", r=1, td="R12", l="18.0s,53.6w" }, ["Amon Raith"] = { d={ -- ["Trestlebridge"] = { c=15, t=142 }, ["Esteldin"] = { c=15, t=190 }, }, z="North Downs", r=1, td="R12", l="12.3s,52.5w" }, ["Meluinen"] = { d={ -- ["Esteldin"] = { c=15, t=120 }, ["Othrikar"] = { c=15, t=130 }, }, z="North Downs", r=1, l="13.6s,44.5w" }, ["Othrikar"] = { d={ -- ["Meluinen"] = { c=15, t=130 }, ["Esteldin"] = { c=15, t=100 }, }, z="North Downs", r=1, l="6.9s,45.0w" }, ["Esteldin"] = { t=2, d={ ["Trestlebridge"] = { c=15, t=320 }, ["Aughaire"] = { c=25, t=220 }, ["Amon Raith"] = { c=15, t=190 }, ["Othrikar"] = { c=15, t=100 }, ["Meluinen"] = { c=15, t=120 }, ["West Bree"] = { s=35, l=30, st=33 }, ["Rivendell"] = { s=20, l=40, st=41 }, ["Tinnudir"] = { c=15, t=510, s=35, l=30, st=50 }, ["Gath Forthnir"] = { s=35, l=40, st=40, r="Q1R4" }, }, z="North Downs", r=1, td="R12", l="9.6s,42.1w" }, -- Trollshaws starts here ["Barachen's Camp"] = { d={ ["Echad Candelleth"] = { s=25, st=23, S0=true }, ["North Trollshaws"] = { s=25, st=13, S0=true }, ["Thorenhad"] = { s=25, st=13 }, }, z="Trollshaws", r=1, td="R7", l="28.2s,15.3w" }, ["North Trollshaws"] = { d={ ["Barachen's Camp"] = { s=25, st=13, S0=true }, }, z="Trollshaws", r=1, td="R7", l="28.6s,19.4w" }, ["Thorenhad"] = { t=1, ml=15, d={ ["Barachen's Camp"] = { s=25, st=23, S0=true }, ["Ost Guruth"] = { c=25, t=310 }, ["Nan Tornaeth"] = { s=25, st=13, S0=true }, ["Echad Candelleth"] = { c=15, l=35, t=207, s=25, st=22, S0=true }, ["Rivendell"] = { c=15, t=405, s=25, st=15, S0=true }, }, z="Trollshaws", r=1, td="R7", l="31.7s,15.0w" }, ["Nan Tornaeth"] = { d={ ["Thorenhad"] = { s=25, st=13, S0=true }, }, z="Trollshaws", r=1, td="R7", l="28.2s,15.3w" }, ["Echad Candelleth"] = { t=20, d={ ["Barachen's Camp"] = { s=25, st=23, S0=true }, ["Rivendell"] = { c=15, cl=40, t=392, s=25, st=23, S0=true }, ["Thorenhad"] = { c=15, l=35, t=206, s=25, st=22, S0=true }, ["Gwingris"] = { c=25, l=40, t=162 }, ["Echad Eregion"] = { c=25, l=35, t=265 }, }, z="Trollshaws", r=1, td="R7", l="36.8s,14.2w" }, ["Rivendell"] = { t=55, d={ ["Gath Forthnir"] = { s=35, l=40, st=33, r="Q1R4" }, ["South Bree"] = { s=25, l=40, st=28 }, ["Lhanuch"] = { s=45, l=50, st=27, r="D6" }, ["Echad Dunann"] = { c=25, t=712, l=-45, s=35, st=22, r="D3" }, ["Echad Eregion"] = { c=25, t=532, l=-40, s=35, st=21, r="D2" }, ["Echad Mirobel"] = { c=25, t=762, l=-45, s=35, st=48, r="D4" }, ["Gwingris"] = { c=25, t=543, l=-40, s=35, st=38, r="D1" }, ["Suri-kyla"] = { s=35, l=40, st=37, r="R3" }, ["Ettenmoors"] = { s=1, l=20, st=30, r="s1" }, ["Ost Guruth"] = { c=15, t=609, s=25, st=26 }, ["Gloin's Camp"] = { c=15, t=150, s=35, st=18 }, ["Hrimbarg"] = { s=35, st=24 }, ["Esteldin"] = { s=20, l=40, st=41 }, ["Echad Candelleth"] = { c=25, l=35, t=392, s=25, st=23, S0=true }, ["Thorenhad"] = { c=25, t=405, s=25, st=15, S0=true }, }, z="Trollshaws", r=1, a="Rivendell", td="R7", l="29.3s,6.7w" }, -- Evendim starts here ["Oatbarton"] = { t=7, ml=10, d={ ["Brockenborings"] = { c=15, t=77 }, ["Dwaling"] = { c=15, t=68, s=25, st=10 }, ["High King's Crossing"] = { c=15, t=244, s=25, st=11 }, ["Tinnudir"] = { c=15, t=358, s=25, st=32 }, ["Ost Forod"] = { c=15, t=363, s=25, st=25 }, }, z="Evendim", r=1, td="R10", l="23.4s,67.4w" }, ["Dwaling"] = { t=14, ml=10, d={ ["Oatbarton"] = { c=15, t=68, s=25, st=10 }, ["High King's Crossing"] = { c=15, t=174, s=25, st=11 }, ["Tinnudir"] = { c=15, t=288, s=25, st=32 }, ["Ost Forod"] = { c=15, t=300, s=25, st=21 }, }, z="Evendim", r=1, td="R10", l="20.8s,64.7w" }, ["High King's Crossing"] = { t=3, ml=15, d={ ["Oatbarton"] = { c=15, t=244, s=25, st=12 }, ["Dwaling"] = { c=15, t=174, s=25, st=11 }, ["Tinnudir"] = { c=15, t=118, s=25, st=31 }, ["Ost Forod"] = { c=15, t=127, s=25, st=21 }, }, z="Evendim", r=1, l="13.8s,64.1w" }, ["Tinnudir"] = { t=10, ml=15, d={ ["Oatbarton"] = { c=15, t=358, s=25, st=32 }, ["Dwaling"] = { c=15, t=288, s=25, st=32 }, ["High King's Crossing"] = { c=15, t=118, s=25, st=31 }, ["Ost Forod"] = { c=15, t=111, s=25, st=41 }, ["Trestlebridge"] = { c=15, t=363 }, ["Esteldin"] = { c=15, t=510, s=35, l=30, st=50 }, ["West Bree"] = { s=35, st=40 }, ["Michel Delving"] = { s=35, st=38 }, ["Annuminas"] = { s=20, l=35, st=40, r="R6" }, ["Tinnudir - Boat"] = { m=15 }, }, z="Evendim", r=1, td="R6", l="12.4s,67.2w" }, ["Ost Forod"] = { t=25, ml=15, d={ ["Oatbarton"] = { c=15, t=363, s=25, st=25 }, ["Dwaling"] = { c=15, t=300, s=25, st=21 }, ["High King's Crossing"] = { c=15, t=127, s=25, st=21 }, ["Tinnudir"] = { c=15, t=111, s=25, st=41 }, ["Trestlebridge"] = { c=15, t=373 }, ["West Bree"] = { s=35, l=30, st=36 }, ["Kauppa-kohta"] = { c=25, l=40, t=300, s=25, st=70 }, ["Pynti-peldot"] = { c=25, t=625, l=-40, s=25, st=48, r="R3" }, ["Suri-kyla"] = { s=25, l=40, st=72, r="R3" }, }, z="Evendim", r=1, l="8.2s,64.3w" }, ["Annuminas"] = { t=6, ms=35, d={ ["Tinnudir"] = { s=20, l=35, st=40, r="R6" }, }, z="Evendim", r=1, a="Annuminas", td="R6", l="19.1s,70.9w" }, -- Boat travel on Lake Evendim ["Tinnudir - Boat"] = { d={ ["The Eavespires - Boat"] = { c=25, t=6 }, ["Men Erain - Boat"] = { c=25, t=4 }, ["Tyl Ruinen - Boat"] = { c=25, t=6 }, ["Tinnudir"] = { m=15 }, }, z="Evendim", r=-1, td="R6", l="12.6s,67.5w" }, ["The Eavespires - Boat"] = { d={ ["Tinnudir - Boat"] = { c=25, t=6 }, ["Men Erain - Boat"] = { c=25, t=6 }, ["Tyl Ruinen - Boat"] = { c=25, t=6 }, }, z="Evendim", r=-1, l="6.0s,71.8w" }, ["Men Erain - Boat"] = { d={ ["Tinnudir - Boat"] = { c=25, t=4 }, ["The Eavespires - Boat"] = { c=25, t=6 }, ["Tyl Ruinen - Boat"] = { c=25, t=4 }, }, z="Evendim", r=-1, td="R6", l="15.4s,66.3w" }, ["Tyl Ruinen - Boat"] = { d={ ["Tinnudir - Boat"] = { c=25, t=6 }, ["The Eavespires - Boat"] = { c=25, t=6 }, ["Men Erain - Boat"] = { c=25, t=4 }, }, z="Evendim", r=-1, td="R6", l="12.9s,70.7w" }, -- Forochel ["Kauppa-kohta"] = { t=14, ml=29, d={ ["Ost Forod"] = { c=25, l=40, t=300, s=35, st=70 }, ["Pynti-peldot"] = { c=25, l=40, t=326 }, }, z="Forochel", r=1, td="R14", l="2.6n,58.0w" }, ["Pynti-peldot"] = { t=11, ml=29, d={ ["Ost Forod"] = { c=25, t=625, l=-40, s=25, st=56, r="R3" }, ["Kauppa-kohta"] = { c=25, l=40, t=326 }, ["Zigilgund"] = { c=25, l=40, t=248 }, ["Suri-kyla"] = { c=25, l=40, t=303 }, }, z="Forochel", r=1, td="R14", l="11.3n,69.4w" }, ["Zigilgund"] = { t=9, l=29, d={ ["Pynti-peldot"] = { c=25, l=40, t=248 }, ["Suri-kyla"] = { c=25, t=538, l=-40, s=25, st=55, r="R3" }, }, z="Forochel", r=1, td="R14", l="9.6n,81.1w" }, ["Suri-kyla"] = { t=4, ml=29, d={ ["Ost Forod"] = { s=25, l=40, st=72 }, ["Pynti-peldot"] = { c=25, l=40, t=303 }, ["Zigilgund"] = { c=25, t=538, l=-40, s=25, st=55, r="R3" }, ["Kuru-leiri"] = { s=25, l=40, st=35, r="Q2" }, ["West Bree"] = { s=35, l=40, st=38, r="R1" }, ["Gath Forthnir"] = { s=35, l=40, st=45, r="Q1R4" }, ["Rivendell"] = { s=35, l=40, st=37, r="R2" }, }, z="Forochel", r=1, td="R14", l="19.1n,70.8w" }, ["Kuru-leiri"] = { d={ ["Suri-kyla"] = { s=25, l=40, st=35, r="Q2" }, }, z="Forochel", r=1, td="R14", l="9.6n,81.1w" }, -- Angmar ["Aughaire"] = { t=20, ml=15, d={ ["Esteldin"] = { c=25, t=220 }, ["Gabilshathur"] = { s=25, st=35, r="Q1" }, ["Gath Forthnir"] = { s=25, st=29, r="Q1R4" }, ["Iorelen's Camp"] = { s=25, st=24, r="Q1R4" }, }, z="Angmar", r=1, l="0.2s,39.3w" }, ["Gabilshathur"] = { t=3, ml=25, d={ ["Aughaire"] = { s=25, st=35, r="Q1" }, ["Gath Forthnir"] = { s=25, st=35, r="Q1R4" }, ["Iorelen's Camp"] = { s=25, st=26, r="Q1R4" }, }, z="Angmar", r=1, l="3.6s,26.6w" }, ["Gath Forthnir"] = { t=23, d={ ["Aughaire"] = { s=25, st=29, r="Q1R4" }, ["Esteldin"] = { s=35, l=40, st=39, r="R5" }, ["Gabilshathur"] = { s=25, st=35, r="Q1R4" }, ["Iorelen's Camp"] = { s=25, st=27, r="Q1R4" }, ["Rivendell"] = { s=35, l=40, st=33, r="Q1R2" }, ["Suri-kyla"] = { s=35, l=40, st=45, r="Q1R3" }, }, z="Angmar", r=1, td="R15", l="10.4n,24.0w" }, ["Iorelen's Camp"] = { t=2, ml=35, d={ ["Aughaire"] = { s=25, st=22, r="Q1R4" }, ["Gabilshathur"] = { s=25, st=26, r="Q1R4" }, ["Gath Forthnir"] = { s=25, st=27, r="Q1R4" } }, z="Angmar", r=1, l="10.6n,15.5w" }, -- Misty Mountains ["Gloin's Camp"] = { t=4, ml=20, d={ ["Rivendell"] = { c=15, t=150, s=35, st=18 }, ["Hrimbarg"] = { s=25, st=23 }, ["High Crag"] = { s=25, st=15 }, ["Vindurhal"] = { s=25, st=15 }, }, z="Misty Mountains", r=1, l="24.9s,4.0w" }, ["High Crag"] = { d={ -- ["Gloin's Camp"] = { s=25, st=15 }, ["Hrimbarg"] = { s=25, st=15 }, ["Vindurhal"] = { s=25, st=11 }, }, z="Misty Mountains", r=1, l="24.6s,1.3e" }, ["Hrimbarg"] = { d={ -- ["Rivendell"] = { s=35, st=23 }, ["Gloin's Camp"] = { s=25, st=23 }, ["High Crag"] = { s=25, st=15 }, ["Vindurhal"] = { s=25, st=11 }, }, z="Misty Mountains", r=1, l="24.4s,7.0e" }, ["Vindurhal"] = { t=2, ml=25, d={ -- ["Gloin's Camp"] = { s=25, st=15 }, ["High Crag"] = { s=25, st=11 }, ["Hrimbarg"] = { s=25, st=11 }, }, z="Misty Mountains", r=1, l="23.3s,4.3e" }, -- ["Glan Vraig"] = { d={ ["Rivendell"] = { s=35, st=30 }, ["South Bree"] = { s=35, st=30 }, ["Michel Delving"] = { s=35, st=30 }, ["Thorin's Gate"] = { s=35, st=30 }, }, z="Ettenmoors", l="21.1s,13.4w" }, ["Ettenmoors"] = { z="Ettenmoors", r=1, n="Glan Vraig" }, -- Eregion starts here ["Gwingris"] = { t=7, ml=33, d={ ["Echad Candelleth"] = { t=22, c=25, t=162, l=40 }, ["Rivendell"] = { c=25, t=543, l=-40, s=35, st=38, r="D1" }, ["Echad Eregion"] = { c=25, t=150, l=-40, s=35, st=40, r="D2" }, ["Echad Dunann"] = { c=25, t=327, l=-45, s=35, st=40, r="D3" }, ["Echad Mirobel"] = { c=25, t=378, l=-45, s=35, st=62, r="D4" }, }, z="Eregion", r=1, l="40.2s,16.0w" }, ["Echad Eregion"] = { t=4, ml=34, d={ ["Rivendell"] = { c=25, t=532, l=-40, s=35, st=21, r="D2" }, ["Echad Candelleth"] = { c=25, l=35, t=265 }, ["Gwingris"] = { c=25, t=150, s=35, st=40, r="D1" }, ["Echad Dunann"] = { c=25, t=180, l=-45, s=35, st=22, r="D3" }, ["Echad Mirobel"] = { c=25, t=228, l=-45, s=35, st=40, r="D4" }, }, z="Eregion", r=1, l="47.0s,12.6w" }, ["Echad Dunann"] = { t=4, ml=35, d={ ["Rivendell"] = { c=25, t=712, l=-45, s=35, st=22, r="D3" }, ["Gwingris"] = { c=25, t=327, l=-45, s=35, st=40, r="D1" }, ["Echad Eregion"] = { c=25, t=180, l=-45, s=35, st=22, r="D2" }, ["Echad Mirobel"] = { c=25, t=210, l=-45, s=35, st=48, r="D4" }, ["Echad Dagoras"] = { c=25, t=242, l=-50, s=35, st=28 }, ["Durin's Threshold"] = { mt=180 }, }, z="Eregion", r=1, l="50.6s,7.8w" }, ["Echad Mirobel"] = { t=24, ml=35, d={ ["Rivendell"] = { c=25, t=762, l=-45, s=35, st=48, r="D4" }, ["Gwingris"] = { c=25, t=378, l=-45, s=35, st=62, r="D1" }, ["Echad Eregion"] = { c=25, t=228, l=-45, s=35, st=40, r="D2" }, ["Echad Dunann"] = { c=25, t=210, l=-45, s=35, st=48, r="D3" }, ["Echad Dagoras"] = { c=25, t=292, l=-50, s=35, st=42 }, }, z="Eregion", r=1, l="52.3s,17.0w" }, -- Moria locations start here ["Durin's Threshold"] = { t=5, ml=35, d={ ["Dolven-view"] = { c=35, l=-45, t=120 }, ["Chamber of the Crossroads"] = { c=35, l=-45, t=215 }, ["The Deep Descent"] = { c=35, l=-45, t=148 }, ["Echad Dunann"] = { mt=180 }, }, z="Moria", r=2, td="R17", a="the Great Delving", l="7.9s,116.1w" }, ["Dolven-view"] = { t=6, ml=35, d={ ["Durin's Threshold"] = { c=35, l=-45, t=120 }, ["Chamber of the Crossroads"] = { c=35, l=-45, t=94 }, ["The Deep Descent"] = { c=35, l=-45, t=34 }, ["Twenty-first Hall"] = { c=35, l=-45, t=254, s=45, st=15 }, ["First Hall"] = { c=35, l=-45, t=413, s=45, st=47 }, ["The Orc-watch"] = { c=35, l=-45, t=436 }, ["Anazarmekhem"] = { c=35, l=-45, t=256 }, }, z="Moria", r=2, td="R17", a="the Great Delving", l="8.4s,112.4w" }, ["The Deep Descent"] = { t=8, ml=37, d={ ["Durin's Threshold"] = { c=35, l=-45, t=148 }, ["The Rotting Cellar"] = { c=35, l=-45, t=180 }, ["Dolven-view"] = { c=35, l=-45, t=34 }, }, z="Moria", r=2, td="R17", a="the Silvertine Lodes", l="9.8s,112.5w" }, ["The Rotting Cellar"] = { t=4, ml=39, d={ ["The Orc-watch"] = { c=35, l=-45, t=244 }, ["Anazarmekhem"] = { c=35, l=-45, t=164 }, ["The Deep Descent"] = { c=35, l=-45, t=180 }, ["The Vile Maw"] = { c=35, l=-45, t=148 }, }, z="Moria", r=2, td="R17", a="the Water-works", l="15.1s,111.9w" }, ["The Vile Maw"] = { d={ -- ["The Rotting Cellar"] = { c=35, l=-45, t=148 }, }, z="Moria", r=2, td="R17", a="the Silvertine Lodes", l="17.6s,116.9w" }, ["Chamber of the Crossroads"] = { t=5, ml=36, d={ -- ["Durin's Threshold"] = { c=35, l=-45, t=215 }, ["Dolven-view"] = { c=35, l=-45, t=94 }, ["Twenty-first Hall"] = { c=35, l=-45, t=190, s=35, st=20, r="Q4" }, }, z="Moria", r=2, td="R17", a="Durin's Way", l="5.2s,112.1w" }, ["Zirakzigil"] = { d={ -- ["Jazargund"] = { c=35, l=-45, t=98 }, }, z="Moria", r=2, td="R17", a="Durin's Way", l="2.9s,110.8w" }, ["Tharakh Bazan"] = { d={ -- ["Twenty-first Hall"] = { s=35, l=-45, st=14 }, }, z="Moria", r=2, td="R17", a="Durin's Way", l="3.2s,108.6w" }, ["Jazargund"] = { t=9, ml=36, d={ ["Twenty-first Hall"] = { c=35, l=-45, t=48 }, ["Zirakzigil"] = { c=35, l=-45, t=98 }, }, z="Moria", r=2, td="R17", a="Durin's Way", l="3.7s,106.0w" }, ["Twenty-first Hall"] = { t=5, ml=39, d={ ["a-b Osgiliath"] = { l=90, s=122, st=19 }, ["Galtrev"] = { s=45, l=65, st=20 }, ["Stangard"] = { s=45, l=70, st=32 }, ["Inner Caras Galadhon"] = { s=25, l=50, st=17, r="Q3" }, ["Magh Ashtu"] = { l=90, s=122, st=26 }, ["Anazarmekhem"] = { c=35, l=-45, t=306 }, ["Chamber of the Crossroads"] = { c=35, l=-45, t=190, s=35, st=20, r="Q5" }, ["Dolven-view"] = { c=35, l=-45, t=254, s=45, st=15 }, ["First Hall"] = { c=35, l=-45, t=345, s=45, st=46 }, ["Jazargund"] = { c=35, l=-45, t=48 }, ["Shadowed Refuge"] = { c=35, l=-45, t=366, s=45, st=31 }, ["Tharakh Bazan"] = { s=35, l=45, st=14 }, ["The Fanged Pit"] = { s=35, l=45, st=13 }, ["The Orc-watch"] = { c=35, l=-45, t=306 }, ["Minas Tirith"] = { s=115, l=90, st=30 }, ["Snowbourn"] = { l=-75, s=71.5, st=40 }, ["Aldburg"] = { l=85, s=71.5, st=28 }, ["Helm's Deep"] = { l=85, s=71.5, st=23 }, ["Forlaw"] = { l=75, s=71.5, st=18 }, ["Dale"] = { l=90, s=122, st=18 }, ["Dol Amroth"] = { l=90, s=115, st=23 }, }, z="Moria", r=2, td="R17", a="Zelem-melek", l="5.7s,105.3w" }, ["The Fanged Pit"] = { t=1, ml=42, d={ ["Twenty-first Hall"] = { s=35, l=-45, st=13 }, }, z="Moria", r=2, td="R17", a="Durin's Way", l="3.5s,103.3w" }, ["The Orc-watch"] = { t=9, ml=39, d={ ["Twenty-first Hall"] = { c=35, l=-45, t=306 }, ["Anazarmekhem"] = { c=35, l=-45, t=83 }, ["Shadowed Refuge"] = { c=35, l=-45, t=182 }, ["Dolven-view"] = { c=35, l=-45, t=436 }, ["The Rotting Cellar"] = { c=35, l=-45, t=244 }, }, z="Moria", r=2, td="R17", a="Redhorn Lodes", l="11.1s,106.9w" }, ["Anazarmekhem"] = { t=3, ml=41, d={ ["The Orc-watch"] = { c=35, l=-45, t=83 }, ["The Rotting Cellar"] = { c=35, l=-45, t=164 }, ["Twenty-first Hall"] = { c=35, l=-45, t=306 }, ["Dolven-view"] = { c=35, l=-45, t=256 }, }, z="Moria", r=2, td="R17", a="The Flaming Deeps", l="13.2s,108.2w" }, ["Shadowed Refuge"] = { t=14, ml=43, d={ ["The Orc-watch"] = { c=35, l=-45, t=182 }, ["Twenty-first Hall"] = { c=35, l=-45, t=366, s=45, st=31 }, ["First Hall"] = { c=35, l=-45, t=344, s=45, st=57 }, }, z="Moria", r=2, td="R17", a="Foundations of Stone", l="13.1s,101.2w" }, ["First Hall"] = { d={ -- no ms ["Shadowed Refuge"] = { c=35, l=-45, t=344, s=45, st=57 }, ["Twenty-first Hall"] = { c=35, l=-45, t=345, s=45, st=46 }, ["Dolven-view"] = { c=35, l=-45, t=413, s=45, st=47 }, ["Mekhem-bizru"] = { mt=38 }, }, z="Moria", r=2, td="R17", a="Nud-Melek", l="8.0s,95.3w" }, -- Lothlorien locations start here ["Mekhem-bizru"] = { t=8, ml=39, d={ -- ["Echad Andestel"] = { c=25, t=133, l=-50, s=25, st=24, r="D13" }, ["Cerin Amroth"] = { c=25, t=238, l=-50, s=25, st=12, r="D14" }, ["Caras Galadhon"] = { c=25, t=255, l=-50, s=25, st=16, r="D14" }, ["The Vinyards of Lorien"] = { c=25, t=278, l=-50, s=25, st=12, r="D15" }, ["First Hall"] = { mt=38 }, }, z="Lothlorien", r=2, td="R8", l="11.5s,78.6w" }, ["Echad Andestel"] = { t=8, ml=39, d={ ["Mekhem-bizru"] = { c=25, t=133, l=-50, s=35, st=24 }, ["Cerin Amroth"] = { c=25, t=140, l=-50, s=35, st=24, r="D14" }, ["The Vinyards of Lorien"] = { c=25, t=182, l=-50, s=35, st=24, r="D15" }, ["Caras Galadhon"] = { c=25, t=258, l=-50, s=35, st=24, r="D14" }, }, z="Lothlorien", r=2, td="R8", l="14.4s,73.1w" }, ["Cerin Amroth"] = { d={ -- ["Mekhem-bizru"] = { c=25, t=238, l=-50, s=35, st=12 }, ["Echad Andestel"] = { c=25, t=140, l=-50, s=35, st=24, r="D13" }, ["Caras Galadhon"] = { c=25, t=133, l=-50, s=35, st=12, r="D14" }, ["The Vinyards of Lorien"] = { c=25, t=190, l=-50, s=35, st=14, r="D15" }, }, z="Lothlorien", r=2, td="R8", l="11.7s,69.1w" }, ["Caras Galadhon"] = { d={ -- ["Mekhem-bizru"] = { c=25, t=255, l=-50, s=35, st=16 }, ["Echad Andestel"] = { c=25, t=258, l=-50, s=35, st=24, r="D13" }, ["The Vinyards of Lorien"] = { c=25, t=68, l=-50, s=35, st=12, r="D15" }, ["Cerin Amroth"] = { c=25, l=-50, t=133, s=35, st=12, r="D14" }, ["Inner Caras Galadhon"] = { mt=65, r="Q3" }, }, z="Lothlorien", r=2, td="R8", l="16.7s,67.5w" }, ["Inner Caras Galadhon"] = { t=30, d={ ["Twenty-first Hall"] = { l=50, s=25, st=17, r="Q3" }, ["Rivendell"] = { s=45, l=50, st=17, r="R7Q3" }, ["Ost Galadh"] = { s=25, l=50, st=27 }, ["Lhanuch"] = { s=45, l=50, st=28, r="R8D6" }, ["Galtrev"] = { s=45, l=65, st=20 }, ["Stangard"] = { s=45, l=70, st=20 }, ["Snowbourn"] = { l=-75, s=71.5, st=17 }, ["Caras Galadhon"] = { mt=65 }, }, z="Lothlorien", r=2, td="R8", a="Caras Galadhon", l="15.1s,68.2w" }, ["The Vinyards of Lorien"] = { t=31, ml=39, d={ ["Mekhem-bizru"] = { c=25, t=278, l=-50, s=35, st=12 }, ["Echad Andestel"] = { c=25, t=182, l=-50, s=35, st=24, r="D13" }, ["Caras Galadhon"] = { c=25, t=68, l=-50, s=35, st=12, r="D14" }, ["Cerin Amroth"] = { c=25, t=190, l=-50, s=35, st=14, r="D14" }, ["Thinglad"] = { c=25, t=70, l=70, s=35, st=20 }, ["Echad Sirion"] = { mt=50 }, }, z="Lothlorien", r=2, td="R8", l="18.3s,64.2w" }, -- Mirkwood locations start here ["Echad Sirion"] = { t=1, ml=37, d={ ["The Haunted Inn"] = { c=25, t=110, l=-50, s=35, st=28, r="D16" }, ["Ost Galadh"] = { c=25, t=200, l=-50, s=35, st=18, r="D17" }, ["Estolad Mernael"] = { c=25, t=223, l=-50, s=35, st=12, r="D17" }, ["Thangulhad"] = { c=25, t=340, l=-50, s=35, st=31, r="D18" }, ["Mithechad"] = { c=25, t=279, l=-50, s=35, st=12, r="D18" }, ["Helethir"] = { c=25, t=385, l=-50, s=35, st=12, r="D18" }, ["The Vinyards of Lorien"] = { mt=50 }, }, z="Mirkwood", r=2, td="R19", l="15.3s,61.3w" }, ["The Haunted Inn"] = { t=5, ml=37, d={ ["Echad Sirion"] = { c=25, t=110, l=-50, s=35, st=28 }, ["Ost Galadh"] = { c=25, t=126, l=-50, s=35, st=35, r="D17" }, ["Estolad Mernael"] = { c=25, t=150, l=-50, s=35, st=30, r="D18" }, ["Thangulhad"] = { c=25, t=274, l=-50, s=35, st=40, r="D18" }, ["Mithechad"] = { c=25, t=214, l=-50, s=35, st=27, r="D18" }, ["Helethir"] = { c=25, t=330, l=-50, s=35, st=30, r="D18" }, }, z="Mirkwood", r=2, td="R19", l="13.4s,56.2w" }, ["Ost Galadh"] = { t=0, ml=37, d={ ["Inner Caras Galadhon"] = { s=35, l=50, st=27, r="Q3" }, ["Echad Sirion"] = { c=25, t=200, l=-50, s=35, st=18 }, ["Estolad Mernael"] = { c=25, t=130, l=-50, s=35, st=18, r="D17" }, ["Helethir"] = { c=25, t=192, l=-50, s=35, st=23, r="D18" }, ["Mithechad"] = { c=25, t=87, l=-50, s=35, st=17, r="D18" }, ["Thangulhad"] = { c=25, t=148, l=-50, s=35, st=36, r="D18" }, ["The Haunted Inn"] = { c=25, t=126, l=-50, s=35, st=35, r="D16" }, ["Tham Taerdol"] = { l=90, s=122, st=18 }, }, z="Mirkwood", r=2, td="R19", l="14.3s,51.2w" }, ["Estolad Mernael"] = { t=16, ml=37, d={ ["Echad Sirion"] = { c=25, t=223, l=-50, s=35, st=12 }, ["The Haunted Inn"] = { c=25, t=150, l=-50, s=35, st=30, r="D16" }, ["Ost Galadh"] = { c=25, t=130, l=-50, s=35, st=18, r="D17" }, ["Thangulhad"] = { c=25, t=280, l=-50, s=35, st=27, r="D18" }, ["Mithechad"] = { c=25, t=123, l=-50, s=35, st=14, r="D18" }, ["Helethir"] = { c=25, t=326, l=-50, s=35, st=41, r="D18" }, }, z="Mirkwood", r=2, td="R19", l="16.8s,54.6w" }, ["Mithechad"] = { t=3, ml=37, d={ ["Echad Sirion"] = { c=25, t=279, l=-50, s=28, st=12 }, ["The Haunted Inn"] = { c=25, t=214, l=-50, s=35, st=27, r="D16" }, ["Ost Galadh"] = { c=25, t=87, l=-50, s=35, st=17, r="D17" }, ["Estolad Mernael"] = { c=25, t=123, l=-50, s=35, st=15, r="D17" }, ["Thangulhad"] = { c=25, t=230, l=-50, s=35, st=26, r="D18" }, ["Helethir"] = { c=25, t=277, l=-50, s=35, st=14, r="D18" }, }, z="Mirkwood", r=2, td="R19", l="17.6s,48.3w" }, ["Thangulhad"] = { t=6, ml=37, d={ ["Echad Sirion"] = { c=25, t=340, l=-50, s=35, st=31 }, ["Estolad Mernael"] = { c=25, t=280, l=-50, s=35, st=27, r="D17" }, ["Helethir"] = { c=25, t=82, l=-50, s=35, st=26, r="D18" }, ["Mithechad"] = { c=25, t=230, l=-50, s=35, st=26, r="D18" }, ["Ost Galadh"] = { c=25, t=148, l=-50, s=35, st=36, r="D17" }, ["The Haunted Inn"] = { c=25, t=274, l=-50, s=35, st=40, r="D16" }, ["Tham Taerdol"] = { l=90, s=122, st=25 }, }, z="Mirkwood", r=2, td="R19", l="12.8s,46.1w" }, ["Helethir"] = { d={ -- ["Echad Sirion"] = { c=25, t=385, l=-50, s=35, st=12 }, ["The Haunted Inn"] = { c=25, t=330, l=-50, s=35, st=30, r="D16" }, ["Ost Galadh"] = { c=25, t=192, l=-50, s=35, st=23, r="D17" }, ["Estolad Mernael"] = { c=25, t=326, l=-50, s=35, st=41, r="D17" }, ["Thangulhad"] = { c=25, t=82, l=-50, s=35, st=26, r="D18" }, ["Mithechad"] = { c=25, t=277, l=-50, s=35, st=14, r="D18" }, }, z="Mirkwood", r=2, td="R19", l="16.1s,44.6w" }, -- Enedwaith locations start here ["Echad Dagoras"] = { t=2, ml=40, d={ ["Maur Tulhau"] = { c=25, t=305, l=-50, s=35, st=28, r="D5" }, ["Lhanuch"] = { c=25, t=244, l=-50, s=35, st=25, r="D6" }, ["Harndirion"] = { c=25, t=303, l=-50, s=35, st=17, r="D7" }, ["Echad Daervunn"] = { c=25, t=288, l=-50, s=35, st=12, r="D6" }, ["Echad Mirobel"] = { c=25, t=292, l=-50, s=35, st=42 }, ["Echad Dunann"] = { c=25, t=242, l=-50, s=35, st=28 }, }, z="Enedwaith", r=1, td="R16", l="58.5s,14.5w" }, ["Maur Tulhau"] = { t=19, ml=40, d={ ["Echad Dagoras"] = { c=25, t=305, l=-50, s=35, st=28 }, ["Lhanuch"] = { c=25, t=214, l=-50, s=35, st=32, r="D6" }, ["Harndirion"] = { c=25, t=270, l=-50, s=35, st=20, r="D7" }, ["Echad Daervunn"] = { c=25, t=90, l=-50, s=35, st=15, r="D6" }, }, z="Enedwaith", r=1, l="62.9s,23.2w" }, ["Echad Daervunn"] = { t=0, ml=40, d={ ["Echad Dagoras"] = { c=25, t=288, l=50, s=35, st=12 }, ["Maur Tulhau"] = { c=25, t=90, l=-50, s=35, st=16, r="D5" }, ["Lhanuch"] = { c=25, t=132, l=-50, s=35, st=22, r="D6" }, ["Harndirion"] = { c=25, t=189, l=-50, s=35, st=12, r="D7" }, ["Lhan Tarren"] = { c=25, t=178, l=65, s=35, st=12 }, }, z="Enedwaith", r=1, td="R16", l="66.6s,21.5w" }, ["Lhanuch"] = { t=19, ml=40, d={ ["Echad Dagoras"] = { c=25, t=244, l=-50, s=35, st=25 }, ["Maur Tulhau"] = { c=25, t=214, l=-50, s=35, st=32, r="D5" }, ["Harndirion"] = { c=25, t=83, l=-50, s=35, st=25, r="D7" }, ["Echad Daervunn"] = { c=25, t=132, l=-50, s=35, st=22, r="D6" }, ["Rivendell"] = { s=45, l=50, st=27, r="R7" }, ["South Bree"] = { s=45, l=50, st=28 }, ["Inner Caras Galadhon"] = { s=45, l=50, st=28, r="Q3R8" }, ["Galtrev"] = { s=45, st=24, l=-50 }, }, z="Enedwaith", r=1, td="R21", l="66.9s,16.9w" }, ["Harndirion"] = { t=1, ml=40, d={ ["Echad Dagoras"] = { c=25, t=303, l=-50, s=35, st=17 }, ["Maur Tulhau"] = { c=25, t=270, l=-50, s=35, st=20, r="D5" }, ["Lhanuch"] = { c=25, t=83, l=-50, s=35, st=25, r="D6" }, ["Echad Daervunn"] = { c=25, t=189, l=-50, s=35, st=12, r="D6" }, ["Echad Naeglanc"] = { c=25, t=250, l=65, s=35, st=19 }, }, z="Enedwaith", r=1, td="R16", l="69.4s,13.7w" }, -- Dunland locations start here ["Echad Naeglanc"] = { t=5, ml=46, d={ ["Lhan Tarren"] = { c=25, t=165, l=6-5, s=35, st=15 }, ["Galtrev"] = { c=25, t=190, l=-65, s=35, st=15 }, ["Harndirion"] = { c=25, t=250, l=-65, s=35, st=19 }, }, z="Dunland", r=1, td="R20", l="77.3s,15.8w" }, ["Lhan Tarren"] = { t=4, ml=46, d={ ["Echad Naeglanc"] = { c=25, t=165, l=-65, s=35, st=15 }, ["Galtrev"] = { c=25, t=190, l=-65, s=35, st=17 }, ["Echad Daervunn"] = { c=25, t=178, l=-65, s=35, st=12 }, }, z="Dunland", r=1, td="R20", l="75.3s,22.4w" }, ["Galtrev"] = { t=7, ml=47, d={ ["a-b Osgiliath"] = { l=90, s=122, st=22 }, ["South Bree"] = { s=45, st=22, l=-65 }, ["Avardin"] = { c=25, t=123, l=-65, s=35, st=16 }, ["Barnavon"] = { c=25, t=158, l=-65, s=35, st=18 }, ["Dagoras' Camp"] = { c=25, t=396, l=-65, s=35, st=20 }, ["Echad Naeglanc"] = { c=25, t=190, l=-65, s=35, st=15 }, ["Forthbrond"] = { c=25, t=270, l=-65, s=35, st=16 }, ["Grimbold's Camp"] = { c=25, t=348, l=-65, s=35, st=18 }, ["Lhan Rhos"] = { c=25, t=214, l=-65, s=35, st=16 }, ["Lhan Tarren"] = { c=25, t=190, l=-65, s=35, st=17 }, ["Rohirrim Scout-camp"] = { c=25, t=160, l=-65, s=35, st=20 }, ["Tal Methedras Gate"] = { c=25, t=112, l=-65, s=35, st=21 }, ["Lhanuch"] = { s=45, st=24, l=-65 }, ["Inner Caras Galadhon"] = { s=45, st=18, l=-65 }, ["Magh Ashtu"] = { l=90, s=122, st=30 }, ["Twenty-first Hall"] = { s=45, st=20, l=-65 }, ["Dale"] = { l=90, s=122, st=16 }, }, z="Dunland", r=1, td="R20", a="Galtrev", l="79.9s,16.7w" }, ["Tal Methedras Gate"] = { t=32, ml=48, d={ ["Galtrev"] = { c=25, t=112, l=-65, s=35, st=21 }, }, z="Dunland", r=1, td="R20", l="78.3s,11.2w" }, ["Rohirrim Scout-camp"] = { t=1, ml=48, d={ ["Forthbrond"] = { c=25, t=70, l=-65, s=35, st=18 }, ["Galtrev"] = { c=25, t=160, l=-65, s=35, st=20 }, ["Barnavon"] = { c=25, t=156, l=-65, s=35, st=16 }, }, z="Dunland", r=1, td="R22", l="80.9s,10.6w" }, ["Barnavon"] = { t=15, ml=48, d={ ["Lhan Rhos"] = { c=25, t=162, l=-65, s=35, st=12 }, ["Galtrev"] = { c=25, st=158, l=-65, s=35, st=18 }, ["Rohirrim Scout-camp"] = { c=25, t=156, l=-65, s=35, st=16 }, }, z="Dunland", r=1, td="R20", l="84.7s,16.3w" }, ["Avardin"] = { t=12, ml=47, d={ ["Galtrev"] = { c=25, t=123, l=-65, s=35, st=16 }, ["Lhan Rhos"] = { c=25, t=103, l=-65, s=35, st=10 }, }, z="Dunland", r=1, td="R20", l="83.5s,20.5w" }, ["Lhan Rhos"] = { t=16, ml=55, d={ ["Avardin"] = { c=25, t=103, l=-65, s=35, st=10 }, ["Galtrev"] = { c=25, t=214, l=-65, s=35, st=16 }, ["Barnavon"] = { c=25, t=162, l=-65, s=35, st=12 }, }, z="Dunland", r=1, td="R20", l="86.8s,23.0w" }, ["Wulf's Cleft Overlook"] = { d={ ["Barnavon"] = { s=0, l=65, st=12 }, }, z="Gap of Rohan", r=1, l="87.7s,16.2w" }, ["Forthbrond"] = { t=3, ml=49, d={ ["Rohirrim Scout-camp"] = { c=25, t=70, l=-65, s=35, st=18 }, ["Galtrev"] = { c=25, t=270, l=-65, s=35, st=16 }, ["Grimbold's Camp"] = { c=25, t=80, l=-65, s=35, st=15 }, }, z="Gap of Rohan", r=1, l="86.9s,7.6w" }, ["Grimbold's Camp"] = { t=2, ml=49, d={ ["Forthbrond"] = { c=25, t=80, l=-65, s=35, st=15 }, ["Galtrev"] = { c=25, t=348, l=-65, s=35, st=18 }, ["Dagoras' Camp"] = { c=25, t=67, l=-65, s=35, st=15 }, }, z="Gap of Rohan", r=1, l="87.8s,3.9w" }, ["Dagoras' Camp"] = { t=0, ml=50, d={ ["Grimbold's Camp"] = { c=25, t=67, l=-65, s=35, st=15 }, ["Galtrev"] = { c=25, t=396, l=-65, s=35, st=20 }, }, z="Nan Curunir", r=1, l="84.9s,3.5w" }, -- the Great River locations start here ["Thinglad"] = { t=2, ml=50, td="R8", d={ ["The Vinyards of Lorien"] = { c=25, t=70, l=-70, s=35, st=20 }, ["Stangard"] = { c=25, t=80, l=-70, s=35, st=20 }, ["Wailing Hills"] = { s=35, l=70, st=13 }, ["Parth Celebrant"] = { s=35, l=70, st=20 }, ["Rushgore"] = { s=35, l=70, st=15 }, ["Brown Lands"] = { s=35, l=70, st=20 }, }, z="Great River", r=2, l="21.4s,63.4w" }, ["Stangard"] = { t=35, ml=50, td="R26", d={ ["Thinglad"] = { c=25, t=80, l=-70, s=35, st=20 }, ["Wailing Hills"] = { c=25, t=78, l=-70, s=35, st=16 }, ["Parth Celebrant"] = { c=25, t=95, l=-70, s=35, st=16 }, ["Rushgore"] = { c=25, t=166, l=-70, s=35, st=23 }, ["Brown Lands"] = { c=25, t=240, l=-70, s=35, st=18 }, ["South Bree"] = { s=45, l=70, st=20 }, ["Twenty-first Hall"] = { s=45, l=70, st=32 }, ["Inner Caras Galadhon"] = { s=45, l=70, st=20 }, ["Harwick"] = { c=66, t=315, l=-75, s=71.5, st=25 }, ["Snowbourn"] = { l=-75, s=71.5, st=19 }, }, z="Great River", r=2, l="25.6s,62.9w" }, ["Wailing Hills"] = { td="R26", d={ -- ["Stangard"] = { c=25, t=78, l=-70, s=35, st=16 }, ["Parth Celebrant"] = { c=25, t=172, l=-70, s=35, st=10 }, ["Thinglad"] = { s=35, l=70, st=13 }, ["Rushgore"] = { s=35, l=70, st=10 }, ["Brown Lands"] = { s=35, l=70, st=11 }, }, z="Great River", r=2, l="25.6s,67.0w" }, ["Parth Celebrant"] = { t=1, ml=50, td="R26", d={ ["Rushgore"] = { c=25, t=140, l=-70, s=35, st=10 }, ["Wailing Hills"] = { c=25, t=172, l=-70, s=35, st=10 }, ["Stangard"] = { c=25, t=95, l=-70, s=35, st=16 }, ["Thinglad"] = { s=35, l=70, st=20 }, ["Brown Lands"] = { s=35, l=70, st=11 }, }, z="Great River", r=2, l="26.6s,58.3w" }, ["Rushgore"] = { t=2, ml=50, td="R26", d={ ["Brown Lands"] = { c=25, t=133, s=35, l=70, st=14 }, ["Parth Celebrant"] = { c=25, t=140, l=-70, s=35, st=10 }, ["Stangard"] = { c=25, t=166, l=-70, s=35, st=23 }, ["Thinglad"] = { s=35, l=70, st=15 }, ["Wailing Hills"] = { s=35, l=70, st=10 }, }, z="Great River", r=2, l="29.2s,55.2w" }, ["Brown Lands"] = { t=7, ml=50, td="R26", d={ ["Rushgore"] = { c=25, t=133, l=-70, s=35, st=14 }, ["Stangard"] = { c=25, t=240, l=-70, s=35, st=18 }, ["Thinglad"] = { s=35, l=70, st=20 }, ["Wailing Hills"] = { s=35, l=70, st=11 }, ["Parth Celebrant"] = { s=35, l=70, st=11 }, }, z="Great River", r=2, l="31.2s,52.0w" }, -- the East Rohan locations start here ["Langhold"] = { t=9, ml=60, d={ ["Floodwend"] = { c=60, t=220, l=-75, s=66, st=42 }, ["Stangard"] = { c=60, t=255, l=-75, s=66, st=26 }, ["Harwick"] = { c=60, t=70, l=-75, s=66, st=41 }, ["Rushgore"] = { l=-75, s=66, st=19 }, }, z="East Rohan", r=2, a="the Wold", l="35.9s,53.9w" }, ["Harwick"] = { t=7, ml=60, td="R23", d={ ["Cliving"] = { c=60, t=238, l=-75, s=66, st=40 }, ["Eaworth"] = { c=60, t=380, l=-75, s=66, st=25 }, ["Elthengels"] = { c=60, t=269, l=-75, s=66, st=44 }, ["Floodwend"] = { c=60, t=178, l=-75, s=66, st=30 }, ["Hytbold"] = { c=65, t=492, l=-84, s=71.5, st=42, r="R28,Q6" }, ["Stangard"] = { c=60, t=315, l=-75, s=71.5, st=25 }, ["Parth Galen"] = { c=60, t=492, l=-75, s=66, st=28 }, ["Snowbourn"] = { c=60, t=546, l=-75, s=66, st=24 }, ["Forlaw"] = { l=-75, s=71.5, st=25 }, ["Writhendowns"] = { c=60, t=221, l=-75, s=71.5, st=22 }, }, z="East Rohan", r=2, a="the Wold", l="39.0s,52.3w" }, ["Floodwend"] = { t=5, ml=60, td="R23", d={ ["Elthengels"] = { c=60, t=127, l=-75, s=66, st=45 }, ["Harwick"] = { c=60, t=178, l=-75, s=66, st=30 }, ["Mansig's Encampment"] = { c=60, t=173, l=-75, s=66, st=39 }, ["Parth Galen"] = { c=60, t=345, l=-75, s=66, st=29 }, }, z="East Rohan", r=2, a="the Wold", l="45.3s,48.2w" }, ["Mansig's Encampment"] = { t=7, ml=60, d={ ["Elthengels"] = { c=60, t=214, l=-75, s=66, st=53 }, ["Floodwend"] = { c=60, t=173, l=-75, s=66, st=39 }, ["Parth Galen"] = { c=60, t=215, l=-75, s=66, st=35 }, }, z="East Rohan", r=2, a="the East Wall", l="52.2s,51.3w" }, ["Parth Galen"] = { t=3, ml=60, d={ ["Cliving"] = { c=60, t=502, l=-75, s=66, st=37 }, ["Eaworth"] = { c=60, t=644, l=-75, s=66, st=22 }, ["Elthengels"] = { c=60, t=390, l=-75, s=66, st=42 }, ["Floodwend"] = { c=60, t=345, l=-75, s=66, st=29 }, ["Harwick"] = { c=60, t=492, l=-75, s=66, st=28 }, ["Mansig's Encampment"] = { c=60, t=215, l=-75, s=66, st=35 }, ["Snowbourn"] = { c=60, t=327, l=-75, s=66, st=22 }, ["Walstow"] = { c=60, t=194, l=-75, s=66, st=19 }, }, z="East Rohan", r=2, a="the East Wall", l="58.7s,47.8w" }, ["Cliving"] = { t=3, ml=60, td="R24", d={ ["Eaworth"] = { c=60, t=181, l=-75, s=66, st=32 }, ["Elthengels"] = { c=60, t=144, l=-75, s=66, st=35 }, ["Faldham"] = { c=60, t=226, l=-75, s=66, st=33 }, ["Harwick"] = { c=60, t=238, l=-75, s=66, st=40 }, ["Hytbold"] = { c=65, t=300, l=-84, s=71.5, st=48, r="R29,Q6" }, ["Parth Galen"] = { c=60, t=502, l=-75, s=66, st=37 }, ["Snowbourn"] = { c=60, t=354, l=-75, s=66, st=33 }, }, z="East Rohan", r=2, a="Norcrofts", l="54.8s,57.2w" }, ["Elthengels"] = { t=36, ml=60, td="R24", d={ ["Cliving"] = { c=60, t=144, l=-75, s=66, st=35 }, ["Faldham"] = { c=60, t=176, l=-75, s=66, st=25 }, ["Floodwend"] = { c=60, t=127, l=-75, s=66, st=45 }, ["Harwick"] = { c=60, t=269, l=-75, s=66, st=44 }, ["Hytbold"] = { c=65, t=248, l=-84, s=71.5, st=39, r="R29,Q6" }, ["Mansig's Encampment"] = { c=60, t=214, l=-75, s=66, st=53 }, ["Parth Galen"] = { c=60, t=390, l=-75, s=66, st=42 }, }, z="East Rohan", r=2, a="Norcrofts", l="48.9s,52.9w" }, ["Faldham"] = { t=12, ml=60, td="R24", d={ ["Cliving"] = { c=60, t=226, l=-75, s=66, st=33 }, ["Elthengels"] = { c=60, t=176, l=-75, s=66, st=24 }, ["Garsfeld"] = { c=60, t=92, l=-75, s=66, st=31 }, ["Hytbold"] = { c=65, t=76, l=-84, s=71.5, st=41, r="R29,Q6" }, ["Snowbourn"] = { c=60, t=128, l=-75, s=66, st=22 }, ["Walstow"] = { c=60, t=146, l=-75, s=66, st=20 }, }, z="East Rohan", r=2, a="Norcrofts", l="54.8s,57.2w" }, ["Eaworth"] = { t=11, ml=60, td="R27", d={ ["Cliving"] = { c=60, t=181, l=-75, s=66, st=32 }, ["Garsfeld"] = { c=60, t=130, l=-75, s=66, st=34 }, ["Harwick"] = { c=60, t=380, l=-75, s=66, st=25 }, ["Hytbold"] = { c=65, t=292, l=-84, s=71.5, st=44, r="R31,Q6" }, ["Parth Galen"] = { c=60, t=644, l=-75, s=66, st=22 }, ["Snowbourn"] = { c=60, t=244, l=-75, s=66, st=48 }, ["Thornhope"] = { c=60, t=117, l=-75, s=66, st=27 }, }, z="East Rohan", r=2, a="Entwash Vale", l="47.7s,63.6w" }, ["Thornhope"] = { t=0, ml=60, td="R27", d={ ["Eaworth"] = { c=60, t=117, l=-75, s=66, st=27 }, }, z="East Rohan", r=2, a="Entwash Vale", l="47.7s,63.6w" }, ["Garsfeld"] = { t=4, ml=60, td="R25", d={ ["Eaworth"] = { c=60, t=130, l=-75, s=66, st=34 }, ["Faldham"] = { c=60, t=92, l=-75, s=66, st=31 }, ["Hytbold"] = { c=65, t=166, l=-84, s=71.5, st=42, r="R30,Q6" }, ["Snowbourn"] = { c=60, t=116, l=-75, s=66, st=46 }, ["Walstow"] = { c=60, t=288, l=-75, s=66, st=24 }, }, z="East Rohan", r=2, a="Sutcrofts", l="54.7s,61.8w" }, ["Hytbold"] = { t=1, ml=60, td="R25", d={ ["Cliving"] = { c=65, t=300, l=-84, s=71.5, st=48, r="R29,Q6" }, ["Elthengels"] = { c=65, t=248, l=-84, s=71.5, st=39, r="R29,Q6" }, ["Eaworth"] = { c=65, t=292, l=-84, s=71.5, st=44, r="R31,Q6" }, ["Faldham"] = { c=65, t=76, l=-84, s=71.5, st=41, r="R29,Q6" }, ["Garsfeld"] = { c=65, t=166, l=-84, s=71.5, st=42, r="R30,Q6" }, ["Harwick"] = { c=65, t=492, l=-84, s=71.5, st=42, r="R28,Q6" }, ["Snowbourn"] = { c=65, t=200, l=-84, s=71.5, st=34, r="R30,Q6" }, ["Walstow"] = { c=65, t=120, l=-84, s=71.5, st=34, r="R30,Q6" }, }, z="East Rohan", r=2, a="Sutcrofts", l="57.3s,55.4w" }, ["Snowbourn"] = { t=12, ml=60, td="R25", d={ ["Cliving"] = { c=60, t=354, l=-75, s=66, st=33 }, ["Eaworth"] = { c=60, t=246, l=-75, s=66, st=48 }, ["Faldham"] = { c=60, t=128, l=-75, s=66, st=22 }, ["Garsfeld"] = { c=60, t=116, l=-75, s=66, st=46 }, ["Harwick"] = { c=60, t=546, l=-75, s=66, st=24 }, ["Hytbold"] = { c=65, t=200, l=-84, s=71.5, st=34, r="R30,Q6" }, ["Parth Galen"] = { c=60, t=327, l=-75, s=66, st=22 }, ["Walstow"] = { c=60, t=143, l=-75, s=66, st=14 }, ["Stangard"] = { l=-75, s=71.5, st=19 }, ["Inner Caras Galadhon"] = { l=-75, s=71.5, st=40 }, ["South Bree"] = { l=-75, s=71.5, st=42 }, ["Twenty-first Hall"] = { l=-75, s=71.5, st=40 }, ["Forlaw"] = { l=-75, s=71.5, st=40 }, ["Entwade"] = { c=60, t=128, l=-85, s=66, st=38 }, }, z="East Rohan", r=2, a="Sutcrofts", l="60.5s,61.3w" }, ["Walstow"] = { t=20, ml=60, td="R25", d={ ["Faldham"] = { c=60, t=146, l=-75, s=66, st=20 }, ["Garsfeld"] = { c=60, t=288, l=-75, s=66, st=24 }, ["Hytbold"] = { c=65, t=120, l=-84, s=71.5, st=34, r="R30,Q6" }, ["Parth Galen"] = { c=60, t=194, l=-75, s=66, st=19 }, ["Snowbourn"] = { c=60, t=143, l=-75, s=66, st=14 }, }, z="East Rohan", r=2, a="Sutcrofts", l="61.9s,54.4w" }, -- the Wildermore locations start here ["Balewood"] = { n="Cerdic's Camp", t=4, ml=70, d={ -- td="R32" ["Forlaw"] = { c=60, t=190, l=-75, s=66, st=21 }, ["High Knolls"] = { c=60, t=150, l=-75, s=66, st=20 }, ["Whitshaws"] = { c=60, t=160, l=-75, s=66, st=20 }, }, z="Wildermore", r=2, l="35.4s,69.9w" }, ["Forlaw"] = { t=3, ml=70, d={ -- td="R32" ["South Bree"] = { l=-75, s=71.5, st=19 }, ["Twenty-first Hall"] = { l=-75, s=71.5, st=16 }, ["Harwick"] = { l=-75, s=71.5, st=25 }, ["Snowbourn"] = { l=-75, s=71.5, st=40 }, ["Balewood"] = { c=60, t=190, l=-75, s=66, st=21 }, ["High Knolls"] = { c=60, t=174, l=-75, s=66, st=11 }, ["Whitshaws"] = { c=60, t=125, l=-75, s=66, st=13 }, ["Writhendowns"] = { c=60, t=142, l=-75, s=66, st=15 }, }, z="Wildermore", r=2, l="39.4s,60.9w" }, ["High Knolls"] = { n="Byre Tor", td="R32", d={ ["Balewood"] = { c=60, t=150, l=-75, s=66, st=20 }, ["Forlaw"] = { c=60, t=174, l=-75, s=66, st=11 }, ["Whitshaws"] = { c=60, t=160, l=-75, s=66, st=12 }, }, z="Wildermore", r=2, l="33.0s,66.6w" }, ["Whitshaws"] = { n="Dunfast's Refugees", td="R32", d={ ["Balewood"] = { c=60, t=160, l=-75, s=66, st=20 }, ["Forlaw"] = { c=60, t=125, l=-75, s=66, st=13 }, ["High Knolls"] = { c=60, t=160, l=-75, s=66, st=12 }, }, z="Wildermore", r=2, l="38.7s,67.2w" }, ["Writhendowns"] = { n="Scylfig", t=5, ml=70, d={ -- td="R32" ["Harwick"] = { c=60, t=221, l=-75, s=71.5, st=22 }, ["Forlaw"] = { c=60, t=142, l=-75, s=66, st=15 }, }, z="Wildermore", r=2, l="33.7s,60.2w" }, -- West Rohan starts here ["Aldburg"] = { t=1, ml=70, td="R33", d={ ["a-b Osgiliath"] = { l=90, s=122, st=22 }, ["South Bree"] = { l=75, s=71.5, st=24 }, ["Ost Rimmon"] = { l=85, s=115, st=35 }, ["Magh Ashtu"] = { l=90, s=122, st=35 }, ["Twenty-first Hall"] = { l=75, s=71.5, st=29 }, ["Minas Tirith"] = { s=115, l=90, st=30 }, ["Beaconwatch"] = { c=60, t=302, l=-85, s=66, st=30 }, ["Edoras"] = { c=60, t=331, l=-85, s=66, st=25 }, ["Fenmarch"] = { c=60, t=156, l=-85, s=66, st=33 }, ["Helm's Deep"] = { c=60, t=631, l=-85, s=66, st=28 }, ["Isengard"] = { l=85, s=66, st=21 }, ["Stoke"] = { c=60, t=492, l=-85, s=66, st=26 }, ["Woodhurst"] = { c=60, t=572, l=-85, s=66, st=21 }, ["Dale"] = { l=90, s=122, st=24 }, ["Dol Amroth"] = { l=90, s=115, st=30 }, }, z="West Rohan", r=2, a="Eastfold", l="68.7s,63.9w" }, ["Beaconwatch"] = { t=10, ml=70, td="R33", d={-- ["Aldburg"] = { c=60, t=302, l=-85, s=66, st=30 }, ["Fenmarch"] = { c=60, t=87, l=-85, s=66, st=36 }, }, z="West Rohan", r=2, a="Eastfold", l="69.6s,57.4w" }, ["Brockbridge"] = { t=1, ml=70, td="R34", d={-- ["Gapholt"] = { c=60, t=211, l=-85, s=66, st=18 }, ["Woodhurst"] = { c=60, t=62, l=-85, s=66, st=17 }, }, z="West Rohan", r=2, a="Stonedeans", l="50.8s,77.7w" }, ["Derndingle"] = { d={-- ["Woodhurst"] = { mt=180 }, }, z="West Rohan", r=2, a="Entwood", l="42.1s,79.1w" }, ["Edoras"] = { t=4, ml=70, td="R33", d={-- ["Aldburg"] = { c=60, t=331, l=-85, s=66, st=25 }, ["Entwade"] = { c=60, t=236, l=-85, s=66, st=25 }, ["Helm's Deep"] = { c=60, t=319, l=-85, s=66, st=27 }, ["Middlemead"] = { c=60, t=343, l=-85, s=66, st=21 }, ["Stoke"] = { c=60, t=421, l=-85, s=66, st=22 }, ["Underharrow"] = { c=60, t=143, l=-85, s=66, st=20 }, ["Woodhurst"] = { c=60, t=337, l=-85, s=66, st=19 }, }, z="West Rohan", r=2, a="Kingstead", l="60.8s,74.3w" }, ["Entwade"] = { t=4, ml=70, td="R33", d={-- ["Edoras"] = { c=60, t=236, l=-85, s=66, st=25 }, ["Middlemead"] = { c=60, t=132, l=-85, s=66, st=24 }, ["Underharrow"] = { c=60, t=354, l=-85, s=66, st=23 }, ["Snowbourn"] = { c=60, t=128, l=75, s=66, st=38 }, }, z="West Rohan", r=2, a="Kingstead", l="56.0s,65.8w" }, ["Fenmarch"] = { t=13, ml=70, td="R33", d={-- ["Aldburg"] = { c=60, t=156, l=-85, s=66, st=33 }, ["Beaconwatch"] = { c=60, t=87, l=-85, s=66, st=36 }, }, z="West Rohan", r=2, a="Eastfold", l="66.5s,57.8w" }, ["Gapholt"] = { t=13, ml=70, td="R34", d={-- ["Brockbridge"] = { c=60, t=211, l=-85, s=66, st=18 }, ["Woodhurst"] = { c=60, t=150, l=-85, s=66, st=19 }, }, z="West Rohan", r=2, a="Stonedeans", l="53.7s,83.7w" }, ["Grimslade"] = { t=5, ml=70, td="R34", d={-- ["Helm's Deep"] = { c=60, t=250, l=-85, s=66, st=13 }, }, z="West Rohan", r=2, a="Westfold", l="62.3s,82.0w" }, ["Helm's Deep"] = { t=48, ml=70, td="R34", d={-- ["South Bree"] = { l=75, s=71.5, st=19 }, ["Twenty-first Hall"] = { l=-85, s=71.5, st=23 }, ["Aldburg"] = { c=60, t=631, l=-85, s=66, st=28 }, ["Edoras"] = { c=60, t=319, l=-85, s=66, st=27 }, ["Grimslade"] = { c=60, t=250, l=-85, s=66, st=13 }, ["Isengard"] = { l=-85, s=66, st=16 }, ["Stoke"] = { c=60, t=547, l=-85, s=66, st=23 }, ["Woodhurst"] = { c=60, t=285, l=-85, s=66, st=15 }, }, z="West Rohan", r=2, a="Helm's Deep", l="61.4s,88.8w" }, ["Isengard"] = { t=0, ml=70, td="R34", d={-- ["Aldburg"] = { l=85, s=66, st=21 }, ["Helm's Deep"] = { l=85, s=66, st=16 }, }, z="West Rohan", r=2, a="Nan Curunir", l="47.7s,89.7w" }, ["Middlemead"] = { t=13, ml=70, td="R33", d={-- ["Edoras"] = { c=60, t=343, l=-85, s=66, st=21 }, ["Entwade"] = { c=60, t=132, l=-85, s=66, st=24 }, ["Underharrow"] = { c=60, t=463, l=-85, s=66, st=18 }, }, z="West Rohan", r=2, a="Kingstead", l="53.7s,72.5w" }, ["Oserly"] = { t=21, ml=70, td="R33", d={-- ["Stoke"] = { c=60, t=77, l=-85, s=66, st=17 }, }, z="West Rohan", r=2, a="Broadacres", l="45.9s,67.0w" }, ["Stoke"] = { t=6, ml=70, td="R33", d={-- ["Aldburg"] = { c=60, t=492, l=-85, s=66, st=26 }, ["Edoras"] = { c=60, t=421, l=-85, s=66, st=22 }, ["Helm's Deep"] = { c=60, t=547, l=-85, s=66, st=23 }, ["Oserly"] = { c=60, t=77, l=-85, s=66, st=17 }, ["Woodhurst"] = { c=60, t=200, l=-85, s=66, st=18 }, }, z="West Rohan", r=2, a="Broadacres", l="49.3s,69.6w" }, ["Underharrow"] = { t=1, ml=70, td="R33", d={ ["Edoras"] = { c=60, t=143, l=-85, s=66, st=20 }, ["Entwade"] = { c=60, t=354, l=-85, s=66, st=23 }, ["Middlemead"] = { c=60, t=463, l=-85, s=66, st=18 }, ["Morlad"] = { l=90, s=115, st=20 }, }, z="West Rohan", r=2, a="Kingstead", l="67.3s,73.7w" }, ["Woodhurst"] = { t=1, ml=70, td="R34", d={ -- ["Aldburg"] = { c=60, t=572, l=-85, s=66, st=21 }, ["Brockbridge"] = { c=60, t=62, l=-85, s=66, st=17 }, ["Derndingle"] = { mt=180 }, ["Edoras"] = { c=60, t=337, l=-85, s=66, st=19 }, ["Gapholt"] = { c=60, t=150, l=-85, s=66, st=19 }, ["Helm's Deep"] = { c=60, t=285, l=-85, s=66, st=15 }, ["Stoke"] = { c=60, t=200, l=-85, s=66, st=18 }, }, z="West Rohan", r=2, a="Stonedeans", l="47.6s,79.1w" }, -- Strongholds of the North ["Dale"] = { t=30, ml=90, d={ ["South Bree"] = { l=90, s=122, st=17 }, ["Galtrev"] = { l=90, s=122, st=16 }, ["Twenty-first Hall"] = { l=90, s=122, st=18 }, ["Minas Tirith"] = { l=90, s=122, st=24 }, ["Aldburg"] = { l=90, s=122, st=24 }, ["Erebor"] = { c=85, t=116, l=-90, s=93.5, st=16 }, ["Felegoth"] = { c=85, t=426, l=-90, s=93.5, st=11 }, ["Lake-town"] = { c=85, t=127, l=-90, s=93.5, st=12 }, ["Tham Taedol"] = { c=85, t=636, l=-90, s=93.5, st=11 }, ["Dol Amroth"] = { l=90, s=122, st=22 }, }, z="Strongholds", r=2, a="The Dale-lands", l="24.0n,26.1w" }, ["Erebor"] = { t=1, ml=90, d={ ["Dale"] = { c=85, t=116, l=-90, s=93.5, st=16 }, ["Felegoth"] = { c=85, t=518, l=-90, s=93.5, st=12 }, ["Lake-town"] = { c=85, t=237, l=-90, s=93.5, st=13 }, ["Tham Taedol"] = { c=85, t=746, l=-90, s=93.5, st=12 }, }, z="Strongholds", r=2, a="The Dale-lands", l="29.0n,25.7w" }, ["Felegoth"] = { t=3, ml=90, d={ ["Dale"] = { c=85, t=426, l=-90, s=93.5, st=11 }, ["Erebor"] = { c=85, t=518, l=-90, s=93.5, st=12 }, ["Lake-town"] = { c=85, t=290, l=-90, s=93.5, st=12 }, ["Tham Taedol"] = { c=85, t=344, l=-90, s=93.5, st=12 }, }, z="Strongholds", r=2, a="Eryn Lasgalen", l="20.3n,36.9w" }, ["Lake-town"] = { t=14, ml=90, d={ ["South Bree"] = { l=90, s=122, st=18 }, ["Dale"] = { c=85, t=127, l=-90, s=93.5, st=12 }, ["Erebor"] = { c=85, t=237, l=-90, s=93.5, st=13 }, ["Felegoth"] = { c=85, t=290, l=-90, s=93.5, st=12 }, ["Tham Taedol"] = { c=85, t=520, l=-90, s=93.5, st=11 }, }, z="Strongholds", r=2, a="The Dale-lands", l="17.2n,27.9w" }, ["Tham Taedol"] = { t=3, ml=90, d={ ["Ost Galadh"] = { s=122, l=90, st=18 }, ["Thangulhad"] = { s=122, l=90, st=25 }, ["Dale"] = { c=85, t=636, l=-90, s=93.5, st=11 }, ["Erebor"] = { c=85, t=746, l=-90, s=93.5, st=12 }, ["Felegoth"] = { c=85, t=344, l=-90, s=93.5, st=12 }, ["Lake-town"] = { c=85, t=520, l=-90, s=93.5, st=11 }, }, z="Strongholds", r=2, a="Eryn Lasgalen", l="12.1n,46.1w" }, -- West Gondor starts here ["Calembel"] = { t=35, ml=85, td="R35", d={ ["Ethring"] = { c=97.7, t=170, l=-90, s=122, st=25 }, ["Minas Tirith"] = { s=122, l=90, st=28 }, ["Dol Amroth"] = { c=80, t=395, l=-90, s=88, st=25 }, ["Morlad"] = { c=80, t=310, l=-90, s=88, st=19 }, ["Tadrent"] = { c=80, t=245, l=-90, s=88, st=24 }, }, z="West Gondor", r=3, a="The Wastes", l="67.2s,55.1w" }, ["Dol Amroth"] = { t=10, ml=85, td="R35", d={ ["a-b Osgiliath"] = { l=90, s=122, st=22 }, ["South Bree"] = { l=90, s=115, st=24 }, ["East Pelargir"] = { l=90, s=122, st=30 }, ["Ethring"] = { l=90, s=122, st=28 }, ["Linhir"] = { l=90, s=122, st=24 }, ["Ost Anglebed"] = { l=90, s=93.5, st=26 }, ["West Pelargir"] = { l=90, s=122, st=24 }, ["Arnach"] = { l=90, s=122, st=26 }, ["Bar Hurin"] = { l=90, s=122, st=28 }, ["Faramir's Lookout"] = { l=90, s=122, st=26 }, ["Glaniath"] = { l=90, s=122, st=28 }, ["Magh Ashtu"] = { l=90, s=122, st=32 }, ["Twenty-first Hall"] = { l=90, s=115, st=23 }, ["Minas Tirith"] = { s=122, l=90, st=30 }, ["North-Gate"] = { s=122, l=90, st=28 }, ["Aldburg"] = { l=90, s=115, st=30 }, ["Dale"] = { l=90, s=122, st=22 }, ["Calembel"] = { c=80, t=395, l=-90, s=88, st=24 }, ["Morlad"] = { c=80, t=676, l=-90, s=88, st=24 }, ["Tadrent"] = { c=80, t=234, l=-90, s=88, st=26 }, }, z="West Gondor", r=3, a="The Wastes", l="75.5s,72.5w" }, ["Morlad"] = { t=1, ml=85, td="R35", d={ ["Minas Tirith"] = { s=122, l=90, st=29 }, ["Underharrow"] = { l=90, s=115, st=20 }, ["Calembel"] = { c=80, t=310, l=-90, s=88, st=19 }, ["Dol Amroth"] = { c=80, t=676, l=-90, s=88, st=24 }, ["Tadrent"] = { c=80, t=472, l=-90, s=88, st=23 }, }, z="West Gondor", r=3, a="The Wastes", l="56.9s,67.5w" }, ["Tadrent"] = { t=1, ml=85, td="R35", d={ ["Minas Tirith"] = { s=122, l=90, st=34 }, ["Calembel"] = { c=80, t=245, l=-90, s=88, st=24 }, ["Dol Amroth"] = { c=80, t=234, l=-90, s=88, st=26 }, ["Morlad"] = { c=80, t=472, l=-90, s=88, st=23 }, }, z="West Gondor", r=3, a="The Wastes", l="74.0s,62.4w" }, -- Central Gondor starts here ["Ethring"] = { t=7, ml=85, td="R36", d={ ["Ost Anglebed"] = { c=85, t=437, l=-90, s=93.5, st=22 }, ["West Pelargir"] = { c=85, t=426, l=-90, s=93.5, st=19 }, ["Minas Tirith"] = { s=122, l=90, st=29 }, ["Calembel"] = { c=97.7, t=170, l=-90, s=122, st=25 }, ["Dol Amroth"] = { l=90, s=122, st=28 }, ["Linhir"] = { c=85, t=216, l=-90, s=93.5, st=22 }, }, z="Central Gondor", r=3, a="Ringlo Vale", l="72.2s,50.1w" }, ["Linhir"] = { t=4, ml=85, td="R36", d={ ["Ethring"] = { c=85, t=216, l=-90, s=93.5, st=22 }, ["Ost Anglebed"] = { c=85, t=218, l=-90, s=93.5, st=22 }, ["West Pelargir"] = { c=85, t=212, l=-90, s=93.5, st=19 }, ["Minas Tirith"] = { s=122, l=90, st=29 }, ["Dol Amroth"] = { l=90, s=122, st=24 }, }, z="Central Gondor", r=3, a="Dor-en-ernil", l="80.8s,45.8w" }, ["Ost Anglebed"] = { t=4, ml=85, td="R36", d={ ["Ethring"] = { c=85, t=437, l=-90, s=93.5, st=22 }, ["Linhir"] = { c=85, t=218, l=-90, s=93.5, st=22 }, ["West Pelargir"] = { c=85, t=165, l=-90, s=93.5, st=20 }, ["Minas Tirith"] = { s=122, l=90, st=26 }, ["Dol Amroth"] = { l=90, s=122, st=26 }, }, z="Central Gondor", r=3, a="Lebennin", l="79.1s,39.0w" }, ["West Pelargir"] = { t=32, ml=85, td="R36", d={ ["East Pelargir"] = { c=10, t=108, l=-90, s=50, st=26 }, ["Ethring"] = { c=85, t=426, l=-90, s=93.5, st=19 }, ["Linhir"] = { c=85, t=212, l=-90, s=93.5, st=19 }, ["Ost Anglebed"] = { c=85, t=165, l=-90, s=93.5, st=20 }, ["Minas Tirith"] = { s=122, l=90, st=25 }, ["Calembel"] = { l=90, s=122, st=22 }, ["Dol Amroth"] = { l=90, s=122, st=24 }, ["Morlad"] = { l=90, s=122, st=22 }, ["Tadrent"] = { l=90, s=122, st=25 }, }, z="Central Gondor", r=3, a="Lebennin", l="83.0s,34.8w" }, ["East Pelargir"] = { t=65, ml=85, td="R36", d={ ["West Pelargir"] = { c=10, t=108, l=-90, s=50, st=28 }, ["Arnach"] = { c=85, t=208, l=-90, s=93.5, st=22 }, ["Bar Hurin"] = { l=90, s=93.5, st=24 }, ["Faramir's Lookout"] = { l=90, s=93.5, st=23 }, ["Glaniath"] = { c=85, t=54, l=-90, s=93.5, st=20 }, ["Dol Amroth"] = { l=90, s=122, st=30 }, ["Minas Tirith"] = { l=90, s=122, st=30 }, ["North-Gate"] = { l=90, s=122, st=24 }, }, z="Central Gondor", r=3, a="Lebennin", l="83.0s,34.8w" }, -- East Gondor starts here ["Arnach"] = { t=10, ml=85, td="R37", d={ ["Dol Amroth"] = { l=90, s=122, st=26 }, ["East Pelargir"] = { c=85, t=208, l=-90, s=93.5, st=22 }, ["Bar Hurin"] = { l=90, s=93.5, st=25 }, ["Faramir's Lookout"] = { l=90, s=93.5, st=23 }, ["Glaniath"] = { c=85, t=174, l=-90, s=93.5, st=23 }, ["Minas Tirith"] = { l=90, s=122, st=26 }, }, z="East Gondor", r=3, a="Upper Lebennin", l="81.0s,29.8w" }, ["Bar Hurin"] = { t=4, ml=85, td="R37", d={ ["East Pelargir"] = { l=90, s=93.5, st=24 }, ["Arnach"] = { l=90, s=93.5, st=25 }, ["Faramir's Lookout"] = { c=85, t=260, l=-90, s=93.5, st=25 }, ["Glaniath"] = { l=90, s=93.5, st=24 }, ["Minas Tirith"] = { s=122, l=90, st=29 }, ["Dol Amroth"] = { l=90, s=122, st=28 }, }, z="East Gondor", r=3, a="South Ithilien", l="73.5s,12.2w" }, ["Faramir's Lookout"] = { t=2, ml=85, td="R37", d={ ["East Pelargir"] = { l=90, s=93.5, st=23 }, ["Arnach"] = { l=90, s=93.5, st=23 }, ["Bar Hurin"] = { c=85, t=260, l=-90, s=93.5, st=25 }, ["Glaniath"] = { l=90, s=93.5, st=22 }, ["Minas Tirith"] = { s=122, l=90, st=34 }, ["Dol Amroth"] = { l=90, s=122, st=26 }, }, z="East Gondor", r=3, a="South Ithilien", l="65.0s,6.1w" }, ["Glaniath"] = { t=5, ml=85, td="R37", d={ ["East Pelargir"] = { c=85, t=54, l=-90, s=93.5, st=20 }, ["Arnach"] = { c=85, t=174, l=-90, s=93.5, st=23 }, ["Bar Hurin"] = { l=90, s=93.5, st=24 }, ["Faramir's Lookout"] = { l=90, s=93.5, st=22 }, ["Minas Tirith"] = { s=122, l=90, st=30 }, ["Dol Amroth"] = { l=90, s=122, st=28 }, }, z="East Gondor", r=3, a="Upper Lebennin", l="81.0s,29.8w" }, -- Anorien starts here ["Minas Tirith"] = { t=11, ml=85, td="R38", d={ ["a-b Osgiliath"] = { l=90, s=122, st=30 }, ["South Bree"] = { l=90, s=115, st=30 }, ["East Pelargir"] = { l=90, s=122, st=30 }, ["Ethring"] = { l=90, s=122, st=29 }, ["Linhir"] = { l=90, s=122, st=29 }, ["Ost Anglebed"] = { l=90, s=122, st=26 }, ["West Pelargir"] = { l=90, s=122, st=25 }, ["Arnach"] = { l=90, s=122, st=26 }, ["Bar Hurin"] = { l=90, s=122, st=29 }, ["Faramir's Lookout"] = { l=90, s=122, st=34 }, ["Glaniath"] = { l=90, s=122, st=29 }, ["Ost Rimmon"] = { l=90, s=122.5, st=40 }, ["W-s King's Men"] = { l=90, s=122, st=34 }, ["Magh Ashtu"] = { l=90, s=122, st=25 }, ["Twenty-first Hall"] = { l=90, s=115, st=30 }, ["Crithost"] = { c=85, t=221, l=-90, s=93.5, st=36 }, ["North-Gate"] = { c=85, t=128, l=-90, s=93.5, st=25 }, ["Aldburg"] = { l=90, s=115, st=30 }, ["Dale"] = { l=90, s=122, st=24 }, ["Calembel"] = { l=90, s=122, st=28 }, ["Dol Amroth"] = { l=90, s=122, st=30 }, ["Morlad"] = { l=90, s=122, st=29 }, ["Tadrent"] = { l=90, s=122, st=34 }, }, z="Old Anorien", r=3, a="Pelenner", l="65.8s,16.8w" }, ["North-Gate"] = { td="R38", d={ ["East Pelargir"] = { l=90, s=122, st=24 }, ["Crithost"] = { c=85, t=92, l=-90, s=93.5, st=38 }, ["Minas Tirith"] = { c=85, t=128, l=-90, s=93.5, st=25 }, ["Dol Amroth"] = { l=90, s=122, st=28 }, }, z="Old Anorien", r=3, a="Pelenner", l="59.5s,17.5w" }, ["Crithost"] = { t=12, ml=85, td="R38", d={ ["Minas Tirith"] = { c=85, t=221, l=-90, s=93.5, st=36 }, ["North-Gate"] = { c=85, t=92, l=-90, s=93.5, st=38 }, }, z="Old Anorien", r=3, a="Pelenner", l="54.7s,16.1w" }, ["W-s King's Men"] = { t=38, ml=85, td="R39", d={ ["Ost Rimmon"] = { c=85, t=148, l=-90, s=93.5, st=45 }, ["Minas Tirith"] = { l=-90, s=93.5, st=34 }, }, z="Far Anorien", r=3, a="Taur Druadan", l="45.1s,29.2w" }, ["Ost Rimmon"] = { t=34, ml=85, td="R39", d={ ["W-s King's Men"] = { c=85, t=148, l=-90, s=93.5, st=45 }, ["Minas Tirith"] = { l=90, s=122, st=40 }, ["Aldburg"] = { l=85, s=115, st=36 }, }, z="Far Anorien", r=3, a="Beacon Hills", l="46.8s,36.4w" }, -- Mordor starts here ["a-b Osgiliath"] = { t=16, ml=85, td="R40", d={ ["Aragorn's Pavilion"] = { c=85, t=170, l=90, s=93.5, st=21 }, ["a-b Minas Tirith"] = { c=85, t=185, l=90, s=93.5, st=22 }, ["South Bree"] = { l=90, s=122, st=18 }, ["Galtrev"] = { l=90, s=122, st=22 }, ["Camp of the Host"] = { c=85, t=475, l=90, s=93.5, st=19 }, ["Henneth Annun"] = { c=85, t=307, l=90, s=93.5, st=26 }, ["Twenty-first Hall"] = { l=90, s=122, st=19 }, ["Minas Tirith"] = { l=90, s=122, st=30 }, ["Aldburg"] = { l=90, s=122, st=22 }, ["Dol Amroth"] = { l=90, s=122, st=22 }, }, z="March of the King", r=4, a="Osgiliath", l="63.0s,6.5w" }, ["a-b Minas Tirith"] = { t=3, ml=35, td="R40", d={ ["Aragorn's Pavilion"] = { c=85, t=68, l=90, s=93.5, st=22 }, ["a-b Osgiliath"] = { c=85, t=185, l=90, s=93.5, st=22 }, ["Camp of the Host"] = { c=85, t=654, l=90, s=93.5, st=24 }, ["Henneth Annun"] = { c=85, t=489, l=90, s=93.5, st=30 }, }, z="March of the King", r=4, a="Pelennor", l="65.6s,16.9w" }, ["Aragorn's Pavilion"] = { t=35, ml=85, td="R40", d={ ["Henneth Annun"] = { c=85, t=473, l=90, s=93.5, st=22 }, ["a-b Minas Tirith"] = { c=85, t=68, l=90, s=93.5, st=22 }, ["a-b Osgiliath"] = { c=85, t=170, l=90, s=93.5, st=21 }, ["Camp of the Host"] = { c=85, t=638, l=90, s=93.5, st=15 }, }, z="March of the King", r=4, a="Pelennor", l="65.6s,14.8w" }, ["Henneth Annun"] = { t=35, ml=85, td="R40", d={ ["Aragorn's Pavilion"] = { c=85, t=473, l=90, s=93.5, st=22 }, ["a-b Minas Tirith"] = { c=85, t=489, l=90, s=93.5, st=30 }, ["a-b Osgiliath"] = { c=85, t=307, l=90, s=93.5, st=26 }, ["Camp of the Host"] = { c=85, t=195, l=90, s=93.5, st=22 }, }, z="March of the King", r=4, a="North Ithilien", l="48.3s,6.9w" }, ["Camp of the Host"] = { t=3, ml=85, td="R40", d={ ["Aragorn's Pavilion"] = { c=85, t=638, l=90, s=93.5, st=15 }, ["a-b Minas Tirith"] = { c=85, t=654, l=90, s=93.5, st=24 }, ["a-b Osgiliath"] = { c=85, t=475, l=90, s=93.5, st=19 }, ["Henneth Annun"] = { c=85, t=195, l=90, s=93.5, st=22 }, ["The Slag-hills"] = { c=85, t=215, l=90, s=93.5, st=24 }, }, z="March of the King", r=4, a="North Ithilien", l="41.0s,10.5w" }, ["The Slag-hills"] = { t=1, ml=90, td="R40", d={ ["Camp of the Host"] = { c=85, t=215, l=90, s=93.5, st=24 }, ["a-b Osgiliath"] = { c=85, t=685, l=90, s=93.5, st=23 }, ["Udub Foothold"] = { c=85, t=190, l=-90, s=93.5, st=21, r=",Q7" }, }, z="the Wastes", r=4, l="34.4s,3.5w" }, ["Udub Foothold"] = { t=1, ml=90, td="R40", d={ ["Agarnaith Ranger Camp"] = { c=85, t=692, l=-90, s=93.5, st=23 }, ["Magh Ashtu"] = { c=85, t=302, l=-90, s=93.5, st=16 }, ["Ruins of Dingarth"] = { c=85, t=209, l=-90, s=93.5, st=18 }, ["The Slag-hills"] = { c=85, t=190, l=-90, s=93.5, st=21, r=",Q7" }, }, z="Gorgoroth", r=4, l="41.2s,0.5w" }, ["Ruins of Dingarth"] = { t=12, ml=85, td="R40", d={ ["Agarnaith Ranger Camp"] = { c=85, t=480, l=-90, s=93.5, st=17 }, ["Magh Ashtu"] = { c=85, t=96, l=-90, s=93.5, st=15 }, ["Udub Foothold"] = { c=85, t=209, l=-90, s=93.5, st=18 }, }, z="Gorgoroth", r=4, l="48.0s,8.7e" }, ["Magh Ashtu"] = { t=12, ml=85, td="R40", d={ ["South Bree"] = { l=90, s=122, st=25 }, ["Galtrev"] = { l=90, s=122, st=30 }, ["Agarnaith Ranger Camp"] = { c=85, t=406, l=-90, s=93.5, st=19 }, ["Ruins of Dingarth"] = { c=85, t=96, l=-90, s=93.5, st=15 }, ["Udub Foothold"] = { c=85, t=302, l=-90, s=93.5, st=16 }, ["Twenty-first Hall"] = { l=90, s=122, st=26 }, ["Minas Tirith"] = { l=90, s=122, st=35 }, ["Aldburg"] = { l=90, s=122, st=35 }, ["Dol Amroth"] = { l=90, s=122, st=32 }, }, z="Gorgoroth", r=4, l="53.1s,10.5e" }, ["Agarnaith Ranger Camp"] = { t=12, ml=85, td="R40", d={ ["Magh Ashtu"] = { c=85, t=406, l=-90, s=93.5, st=19 }, ["Ruins of Dingarth"] = { c=85, t=480, l=-90, s=93.5, st=17 }, ["Udub Foothold"] = { c=85, t=692, l=-90, s=93.5, st=23 }, }, z="Gorgoroth", r=4, l="56.6s,26.9e" }, } Region = { Eriador=1, Rhovanion=2, Gondor=3, Mordor=4 } rType = { D="Deed", Q="Quest", R="Rep", S="Req" } Reqs = { D1 = "Silent and Restless", D2 = "Silent and Restless (Intermediate)", D3 = "Silent and Restless (Advanced)", D4 = "Silent and Restless (Final)", D5 = "Mysteries of Enedwaith", D6 = "Mysteries of Enedwaith (Intermediate)", D7 = "Mysteries of Enedwaith (Advanced)", -- D8 = "Defender of the Upper Levels", D13= "Ally of Lothlorien", D14= "Defender of Lothlorien", D15= "Warrior of Lothlorien", D16= "Into the Black and Twisted Forest", D17= "Into the Black and Twisted Forest (Int.)", D18= "Into the Black and Twisted Forest (Adv.)", Q1 = "V1;B6;Ch 6: Challenging the Stone", Q2 = "The Frozen War", Q3 = "The Paths of Caras Galadhon", Q4 = "V2;B4;Ch 5: Into the Fire", Q5 = "V2;B2;Ch 8: The Twenty-first Hall", Q6 = "The Stable: Rebuild", Q7 = "V4;B9;Ch 2: The Eagles are Coming", R1 = "Acq. with Men of Bree", R2 = "Acq. with Elves of Rivendell", R3 = "Acq. with Lossoth of Forochel", R4 = "Acq. with Council of the North", R5 = "Acq. with Rangers of Esteldin", R6 = "Friend with Wardens of Annuminas", R7 = "Friend with Elves of Rivendell", R8 = "Friend with Galadhrim", R9 = "Friend with Thorin's Hall", R10= "Friend with Mathom Society", R11= "Friend with Men of Bree", R12= "Friend with Rangers of Esteldin", R13= "Friend with The Eglain", R14= "Friend with Lossoth of Forochel", R15= "Friend with Council of the North", R16= "Friend with The Grey Company", R17= "Friend with Iron Garrison Guards", R18= "Friend with Iron Garrison Miners", R19= "Friend with Malledhrim", R20= "Friend with Men of Dunland", R21= "Friend with Algraig", R22= "Friend with Theodred's Riders", R23= "Friend with Men of the Wold", R24= "Friend with Men of the Norcrofts", R25= "Friend with Men of the Sutcrofts", R26= "Friend with Riders of Stangard", R27= "Friend with Men of Entwash Vale", R28= "Ally with Men of the Wold", R29= "Ally with Men of the Norcrofts", R30= "Ally with Men of the Sutcrofts", R31= "Ally with Men of Entwash Vale", R32= "Friend with People of Wildermore", R33= "Ally with The Eorlingas", R34= "Ally with The Helmingas", R35= "Ally with Dol Amroth", R36= "Ally with Pelargir", R37= "Ally with Rangers of Ithilien", R38= "Ally with Defenders of Minas Tirith", R39= "Ally with Riders of Rohan", R40= "Ally with Host of the West", S0 = "Current or past subscriber", S1 = "Requires VIP account", S2 = "Writ of Passage/Founder's discount", } Reqs_list = { "S0","S2","R4","R2","R3","R1","R5","R7","R6","R8","R28","R29", "R31","R30","Q1","Q2","Q3","Q4","Q5","Q6","Q7","D1","D2","D3", "D4","D5","D6","D7","D13","D14","D15","D16","D17","D18" } TD_list = { "R9","R10","R11","R12","R13","R7","R6","R14","R15","R17", "R18","R8","R16","R21","R19","R20","R22","R26","R23","R24","R25", "R27","R32","R33","R34","R35","R36","R37","R38","R39","R40" } TD25 = { R23=true, R24=true, R25=true, R27=true, R33=true, R34=true } -- "Return to" list Return = { nm = "Return to", tb="RT", ["Thorin's Gate"] = { r=Turbine.Gameplay.Race.Dwarf, rd="06346", t=45, d="1BF91", tl=10, id="1BF8D" }, ["the Shire"] = { r=Turbine.Gameplay.Race.Hobbit, rd="062C8", t=15, d="23262", tl=10, l="Michel Delving" }, ["Bree"] = { r=Turbine.Gameplay.Race.Man, rd="062F6", t=15, d="1BF90", tl=10, l="West Bree", id="1BF8C" }, ["Lalia's Market"] = { t=60, d="364B1", tl=5, l="South Bree", id="364B0" }, ["Rivendell"] = { r=Turbine.Gameplay.Race.Elf, rd="0631F", t=70, d="23263", tl=10 }, ["Ost Guruth"] = { t=3, d="20441", tl=10 }, ["Mirkwood"] = { t=20, d="1F374", tl=51, l="Ost Galadh", id="1F372" }, ["Enedwaith"] = { t=14, d="21FA2", tl=50, l="Lhanuch", id="2238E" }, ["Galtrev"] = { t=17, d="2C647", tl=70, id="2C64A" }, ["Stangard"] = { t=28, d="2C65D", tl=70, id="2C65E" }, ["Snowbourn"] = { t=22, d="31A46", tl=80, id="31A42" }, ["Forlaw"] = { t=14, d="36B5E", tl=85, id="36B4A" }, ["Aldburg"] = { t=5, d="3DC81", tl=85, id="3DC7B" }, ["Helm's Deep"] = { t=1, d="3DC82", tl=85, id="3DC7E" }, ["Derndingle"] = { t=26, d="4128F", tl=85, id="41290" }, ["Dol Amroth"] = { t=32, d="411AC", tl=95, id="411AD" }, ["Arnach"] = { t=17, d="43A6A", tl=100, id="43A6B" }, ["Minas Tirith"] = { t=9, d="4497E", tl=100, id="4497F" }, ["the War-stead"] = { t=9, d="459A9", tl=100, id="459A6" }, ["a-b Minas Tirith"] = { t=9, d="46CC0", tl=100, id="46CBA" }, ["a-b Osgiliath"] = { t=9, d="4707D", tl=100, id="47092" }, ["Henneth Annun"] = { t=9, d="47080", tl=100, id="47091" }, ["Undun Foothold"] = { t=9, d="4AE1D", tl=100, id="4AE22" }, ["Dale"] = { t=9, d="4D738", tl=115, id="4D73E" }, } -- "Guide to" list Guide = { nm = "Guide to", tb="GT", ["Michel Delving"] = { t=30, d="0A2C3", tl=22, id="0A2C3" }, ["Thorin's Hall"] = { t=45, d="03F41", tl=24, l="Thorin's Gate", id="03F41" }, ["Bree"] = { t=20, d="03F42", tl=32, l="West Bree", id="03F42" }, ["Ost Guruth"] = { t=33, d="0A2C2", tl=26, id="0A2C2" }, ["Esteldin"] = { t=15, d="03F43", tl=34, id="03F43" }, ["Evendim"] = { t=20, d="0A2C4", tl=36, l="Tinnudir", id="0A2C4" }, ["Rivendell"] = { t=80, d="03F44", tl=46, id="03F44" }, ["Misty Mountains"] = { t=13, d="2E756", tl=40, l="Hrimbarg", id="2E757" }, ["West Angmar"] = { t=40, d="0A2C5", tl=44, l="Aughaire", id="0A2C5" }, ["East Angmar"] = { t=15, d="0A2C6", tl=48, l="Gath Forthnir", id="0A2C6" }, ["Suri-kyla"] = { t=27, d="17C82", tl=48, id="17C7C" }, ["Echad Dunann"] = { t=17, d="17C81", tl=50, id="17C7B" }, ["Twenty-first Hall"] = { t=17, d="17C7A", tl=56, id="17C7D" }, ["Caras Galadhon"] = { t=51, d="2E754", tl=60, l="Inner Caras Galadhon", id="2E755" }, ["Mirk-eaves"] = { t=14, d="1F459", tl=62, l="Echad Sirion", id="1F45B" }, ["Harndirion"] = { t=36, d="235EF", tl=62, id="235F0" }, ["Galtrev"] = { t=20, d="2A93F", tl=70, id="2A93E" }, ["Stangard"] = { t=35, d="2C62C", tl=75, id="2C648" }, ["Snowbourn"] = { t=14, d="3198E", tl=80, id="31A43" }, ["Forlaw"] = { t=14, d="36B5D", tl=85, id="36B4B" }, ["Aldburg"] = { t=5, d="3DC71", tl=95, id="3DC7C" }, ["Helm's Deep"] = { t=1, d="3DC72", tl=95, id="3DC80" }, ["Dol Amroth"] = { t=32, d="41197", tl=95, id="41194" }, ["Arnach"] = { t=17, d="43A63", tl=100, id="43A65" }, ["Minas Tirith"] = { t=9, d="44985", tl=100, id="44986" }, ["the War-stead"] = { t=9, d="459AF", tl=100, id="459AE" }, ["a-b Minas Tirith"] = { t=9, d="46CBB", tl=100, id="46CC9" }, ["a-b Osgiliath"] = { t=9, d="47074", tl=100, id="4707E" }, ["Henneth Annun"] = { t=9, d="47077", tl=100, id="4707F" }, ["Undun Foothold"] = { t=9, d="4AE1E", tl=100, id="4AE20" }, ["Dale"] = { t=9, d="4D73B", tl=115, id="4D73F" }, } -- "Muster in" list Muster = { nm = "Muster in", tb="MT", ["Ost Guruth"] = { t=33, d="14786", tl=26, id="14786" }, ["Esteldin"] = { t=15, d="14798", tl=32, id="14798" }, ["Evendim"] = { t=20, d="1478E", tl=40, l="Tinnudir", id="1478E" }, ["Rivendell"] = { t=80, d="14791", tl=44, id="14791" }, ["Misty Mountains"] = { t=13, d="303DD", tl=40, l="Hrimbarg", id="303DB" }, ["Suri-kyla"] = { t=27, d="237D4", tl=48, id="237D5" }, ["Twenty-first Hall"] = { t=17, d="1819E", tl=56, id="1819F" }, ["Caras Galadhon"] = { t=51, d="303DF", tl=60, l="Inner Caras Galadhon", id="303E0" }, ["Mirk-eaves"] = { t=14, d="1F45C", tl=62, l="Echad Sirion", id="1F45D" }, ["Harndirion"] = { t=36, d="235EB", tl=62, id="235EE" }, ["Galtrev"] = { t=20, d="2A90A", tl=70, id="2A90B" }, ["Stangard"] = { t=35, d="2C646", tl=75, id="2C649" }, ["Snowbourn"] = { t=14, d="3198D", tl=80, id="31A44" }, ["Forlaw"] = { t=14, d="36B5B", tl=85, id="36B60" }, ["Aldburg"] = { t=5, d="3DC7A", tl=95, id="3DC7D" }, ["Helm's Deep"] = { t=1, d="3DC79", tl=95, id="3DC7F" }, ["Dol Amroth"] = { t=32, d="41198", tl=95, id="41195" }, ["Arnach"] = { t=17, d="43A66", tl=100, id="43A64" }, ["Minas Tirith"] = { t=9, d="44982", tl=100, id="44987" }, ["the War-stead"] = { t=9, d="459AA", tl=100, id="459AD" }, ["a-b Minas Tirith"] = { t=9, d="46CBF", tl=100, id="46CC6" }, ["a-b Osgiliath"] = { t=9, d="47076", tl=100, id="47083" }, ["Henneth Annun"] = { t=9, d="47075", tl=100, id="47082" }, ["Undun Foothold"] = { t=9, d="4AE1F", tl=100, id="4AE23" }, ["Dale"] = { t=9, d="4D73A", tl=115, id="4D73D" }, } -- Milestone action codes Miles = {"256BA","25792","25793","25794","25795","25796", "2FF5E","2FF5F","2FF60","2FF61","2FF62","2FF63"} Zones = { } for n,t in pairs(Locs) do if t.d then local z = t.z if Zones[z] then Zones[z] = Zones[z]+1 else Zones[z] = 1 end end end zones = { } for name in pairs(Zones) do table.insert(zones,name) end table.sort(zones) Areas = { } for n,t in pairs(Locs) do if t.a then Areas[t.a] = t.z end end
apache-2.0
focusworld/aabb
plugins/remind.lua
362
1875
local filename='data/remind.lua' local cronned = load_from_file(filename) local function save_cron(msg, text,date) local origin = get_receiver(msg) if not cronned[date] then cronned[date] = {} end local arr = { origin, text } ; table.insert(cronned[date], arr) serialize_to_file(cronned, filename) return 'Saved!' end local function delete_cron(date) for k,v in pairs(cronned) do if k == date then cronned[k]=nil end end serialize_to_file(cronned, filename) end local function cron() for date, values in pairs(cronned) do if date < os.time() then --time's up send_msg(values[1][1], "Time's up:\n"..values[1][2], ok_cb, false) delete_cron(date) --TODO: Maybe check for something else? Like user end end end local function actually_run(msg, delay,text) if (not delay or not text) then return "Usage: !remind [delay: 2h3m1s] text" end save_cron(msg, text,delay) return "I'll remind you on " .. os.date("%x at %H:%M:%S",delay) .. " about '" .. text .. "'" end local function run(msg, matches) local sum = 0 for i = 1, #matches-1 do local b,_ = string.gsub(matches[i],"[a-zA-Z]","") if string.find(matches[i], "s") then sum=sum+b end if string.find(matches[i], "m") then sum=sum+b*60 end if string.find(matches[i], "h") then sum=sum+b*3600 end end local date=sum+os.time() local text = matches[#matches] local text = actually_run(msg, date, text) return text end return { description = "remind plugin", usage = { "!remind [delay: 2hms] text", "!remind [delay: 2h3m] text", "!remind [delay: 2h3m1s] text" }, patterns = { "^!remind ([0-9]+[hmsdHMSD]) (.+)$", "^!remind ([0-9]+[hmsdHMSD])([0-9]+[hmsdHMSD]) (.+)$", "^!remind ([0-9]+[hmsdHMSD])([0-9]+[hmsdHMSD])([0-9]+[hmsdHMSD]) (.+)$" }, run = run, cron = cron }
gpl-2.0
hamed9898/maxbot
plugins/remind.lua
362
1875
local filename='data/remind.lua' local cronned = load_from_file(filename) local function save_cron(msg, text,date) local origin = get_receiver(msg) if not cronned[date] then cronned[date] = {} end local arr = { origin, text } ; table.insert(cronned[date], arr) serialize_to_file(cronned, filename) return 'Saved!' end local function delete_cron(date) for k,v in pairs(cronned) do if k == date then cronned[k]=nil end end serialize_to_file(cronned, filename) end local function cron() for date, values in pairs(cronned) do if date < os.time() then --time's up send_msg(values[1][1], "Time's up:\n"..values[1][2], ok_cb, false) delete_cron(date) --TODO: Maybe check for something else? Like user end end end local function actually_run(msg, delay,text) if (not delay or not text) then return "Usage: !remind [delay: 2h3m1s] text" end save_cron(msg, text,delay) return "I'll remind you on " .. os.date("%x at %H:%M:%S",delay) .. " about '" .. text .. "'" end local function run(msg, matches) local sum = 0 for i = 1, #matches-1 do local b,_ = string.gsub(matches[i],"[a-zA-Z]","") if string.find(matches[i], "s") then sum=sum+b end if string.find(matches[i], "m") then sum=sum+b*60 end if string.find(matches[i], "h") then sum=sum+b*3600 end end local date=sum+os.time() local text = matches[#matches] local text = actually_run(msg, date, text) return text end return { description = "remind plugin", usage = { "!remind [delay: 2hms] text", "!remind [delay: 2h3m] text", "!remind [delay: 2h3m1s] text" }, patterns = { "^!remind ([0-9]+[hmsdHMSD]) (.+)$", "^!remind ([0-9]+[hmsdHMSD])([0-9]+[hmsdHMSD]) (.+)$", "^!remind ([0-9]+[hmsdHMSD])([0-9]+[hmsdHMSD])([0-9]+[hmsdHMSD]) (.+)$" }, run = run, cron = cron }
gpl-2.0
Cyumus/NutScript
plugins/mapscene.lua
5
5134
PLUGIN.name = "Map Scenes" PLUGIN.author = "Chessnut" PLUGIN.desc = "Adds areas of the map that are visible during character selection." PLUGIN.scenes = PLUGIN.scenes or {} local x3, y3 = 0, 0 local realOrigin = Vector(0, 0, 0) local realAngles = Angle(0, 0, 0) local view = {} if (CLIENT) then PLUGIN.ordered = PLUGIN.ordered or {} function PLUGIN:CalcView(client, origin, angles, fov) local scenes = self.scenes if (IsValid(nut.gui.char) and table.Count(scenes) > 0) then local key = self.index local value = scenes[self.index] if (!self.index or !value) then value, key = table.Random(scenes) self.index = key end if (self.orderedIndex or type(key) == "Vector") then local curTime = CurTime() self.orderedIndex = self.orderedIndex or 1 local ordered = self.ordered[self.orderedIndex] if (ordered) then key = ordered[1] value = ordered[2] end if (!self.startTime) then self.startTime = curTime self.finishTime = curTime + 30 end local fraction = math.min(math.TimeFraction(self.startTime, self.finishTime, CurTime()), 1) if (value) then realOrigin = LerpVector(fraction, key, value[1]) realAngles = LerpAngle(fraction, value[2], value[3]) end if (fraction >= 1) then self.startTime = curTime self.finishTime = curTime + 30 if (ordered) then self.orderedIndex = self.orderedIndex + 1 if (self.orderedIndex > #self.ordered) then self.orderedIndex = 1 end else local keys = {} for k, v in pairs(scenes) do if (type(k) == "Vector") then keys[#keys + 1] = k end end self.index = table.Random(keys) end end elseif (value) then realOrigin = value[1] realAngles = value[2] end local x, y = gui.MousePos() local x2, y2 = surface.ScreenWidth() * 0.5, surface.ScreenHeight() * 0.5 local frameTime = FrameTime() * 0.5 y3 = Lerp(frameTime, y3, math.Clamp((y - y2) / y2, -1, 1) * -6) x3 = Lerp(frameTime, x3, math.Clamp((x - x2) / x2, -1, 1) * 6) view.origin = realOrigin + realAngles:Up()*y3 + realAngles:Right()*x3 view.angles = realAngles + Angle(y3 * -0.5, x3 * -0.5, 0) return view end end local HIDE_WEAPON = Vector(0, 0, -100000) local HIDE_ANGLE = Angle(0, 0, 0) function PLUGIN:CalcViewModelView(weapon, viewModel, oldEyePos, oldEyeAngles, eyePos, eyeAngles) local scenes = self.scenes if (IsValid(nut.gui.char)) then return HIDE_WEAPON, HIDE_ANGLE end end local PLUGIN = PLUGIN netstream.Hook("mapScn", function(data, origin) if (type(origin) == "Vector") then PLUGIN.scenes[origin] = data table.insert(PLUGIN.ordered, {origin, data}) else PLUGIN.scenes[#PLUGIN.scenes + 1] = data end end) netstream.Hook("mapScnDel", function(key) PLUGIN.scenes[key] = nil for k, v in ipairs(PLUGIN.ordered) do if (v[1] == key) then table.remove(PLUGIN.ordered, k) break end end end) netstream.Hook("mapScnInit", function(scenes) PLUGIN.scenes = scenes for k, v in pairs(scenes) do if (type(k) == "Vector") then table.insert(PLUGIN.ordered, {k, v}) end end end) else function PLUGIN:SaveScenes() self:setData(self.scenes) end function PLUGIN:LoadData() self.scenes = self:getData() or {} end function PLUGIN:PlayerInitialSpawn(client) netstream.Start(client, "mapScnInit", self.scenes) end function PLUGIN:addScene(position, angles, position2, angles2) local data if (position2) then data = {position2, angles, angles2} self.scenes[position] = data else data = {position, angles} self.scenes[#self.scenes + 1] = data end netstream.Start(nil, "mapScn", data, position2 and position or nil) self:SaveScenes() end end local PLUGIN = PLUGIN nut.command.add("mapsceneadd", { adminOnly = true, syntax = "[bool isPair]", onRun = function(client, arguments) local position, angles = client:EyePos(), client:EyeAngles() -- This scene is in a pair for moving scenes. if (util.tobool(arguments[1]) and !client.nutScnPair) then client.nutScnPair = {position, angles} return L("mapRepeat", client) else if (client.nutScnPair) then PLUGIN:addScene(client.nutScnPair[1], client.nutScnPair[2], position, angles) client.nutScnPair = nil else PLUGIN:addScene(position, angles) end return L("mapAdd", client) end end }) nut.command.add("mapsceneremove", { adminOnly = true, syntax = "[number radius]", onRun = function(client, arguments) local radius = tonumber(arguments[1]) or 280 local position = client:GetPos() local i = 0 for k, v in pairs(PLUGIN.scenes) do local delete = false if (type(k) == "Vector") then if (k:Distance(position) <= radius or v[1]:Distance(position) <= radius) then delete = true end elseif (v[1]:Distance(position) <= radius) then delete = true end if (delete) then netstream.Start(nil, "mapScnDel", k) PLUGIN.scenes[k] = nil i = i + 1 end end if (i > 0) then PLUGIN:SaveScenes() end return L("mapDel", client, i) end })
mit
nesstea/darkstar
scripts/zones/Western_Altepa_Desert/npcs/relic.lua
13
1872
----------------------------------- -- Area: Western Altepa Desert -- NPC: <this space intentionally left blank> -- @pos -152 -16 20 125 ----------------------------------- package.loaded["scripts/zones/Western_Altepa_Desert/TextIDs"] = nil; ----------------------------------- require("scripts/zones/Western_Altepa_Desert/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- Working on correct relic, 4 items, Stage 4 item, Shard, Necropsyche, currencypiece if (player:getVar("RELIC_IN_PROGRESS") == 18287 and trade:getItemCount() == 4 and trade:hasItemQty(18287,1) and trade:hasItemQty(1575,1) and trade:hasItemQty(1589,1) and trade:hasItemQty(1451,1)) then player:startEvent(205,18288); end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:messageSpecial(NOTHING_OUT_OF_ORDINARY); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); if (csid == 205) then if (player:getFreeSlotsCount() < 2) then player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,18288); player:messageSpecial(FULL_INVENTORY_AFTER_TRADE,1450); else player:tradeComplete(); player:addItem(18288); player:addItem(1450,30); player:messageSpecial(ITEM_OBTAINED,18288); player:messageSpecial(ITEMS_OBTAINED,1450,30); player:setVar("RELIC_IN_PROGRESS",0); end end end;
gpl-3.0
dpino/snabbswitch
src/program/snabbnfv/neutron_sync_master/neutron_sync_master.lua
10
2393
-- Use of this source code is governed by the Apache 2.0 license; see COPYING. module(..., package.seeall) local lib = require("core.lib") local syscall = require("syscall") local usage = require("program.snabbnfv.neutron_sync_master.README_inc") local script = require("program.snabbnfv.neutron_sync_master.neutron_sync_master_sh_inc") local long_opts = { user = "u", password = "p", ["mysql-host"] = "m", ["mysql-port"] = "M", ["neutron-database"] = "D", ["dump-path"] = "d", tables = "t", ["listen-address"] = "l", ["listen-port"] = "L", interval = "i", help = "h" } function run (args) local conf = { ["DB_USER"] = os.getenv("DB_USER"), ["DB_PASSWORD"] = os.getenv("DB_PASSWORD"), ["DB_DUMP_PATH"] = os.getenv("DB_DUMP_PATH"), ["DB_HOST"] = os.getenv("DB_HOST") or "localhost", ["DB_PORT"] = os.getenv("DB_PORT") or "3306", ["DB_NEUTRON"] = os.getenv("DB_NEUTRON") or "neutron_ml2", ["DB_NEUTRON_TABLES"] = os.getenv("DB_NEUTRON_TABLES") or "networks ports ml2_network_segments ml2_port_bindings securitygroups securitygrouprules securitygroupportbindings", ["SYNC_LISTEN_HOST"] = os.getenv("SYNC_LISTEN_HOST") or "127.0.0.1", ["SYNC_LISTEN_PORT"] = os.getenv("SYNC_LISTEN_PORT") or "9418", ["SYNC_INTERVAL"] = os.getenv("SYNC_INTERVAL") or "1" } local opt = {} function opt.u (arg) conf["DB_USER"] = arg end function opt.p (arg) conf["DB_PASSWORD"] = arg end function opt.d (arg) conf["DB_DUMP_PATH"] = arg end function opt.t (arg) conf["DB_NEUTRON_TABLES"] = arg end function opt.D (arg) conf["DB_NEUTRON"] = arg end function opt.m (arg) conf["DB_HOST"] = arg end function opt.M (arg) conf["DB_PORT"] = arg end function opt.l (arg) conf["SYNC_LISTEN_HOST"] = arg end function opt.L (arg) conf["SYNC_LISTEN_PORT"] = arg end function opt.i (arg) conf["SYNC_INTERVAL"] = arg end function opt.h (arg) print(usage) main.exit(1) end args = lib.dogetopt(args, opt, "u:p:t:i:d:m:M:l:L:D:h", long_opts) for key, value in pairs(conf) do S.setenv(key, value, true) end lib.execv("/bin/bash", {"/bin/bash", "-c", script}) end
apache-2.0
vonflynee/opencomputersserver
world/opencomputers/4f2775bd-9dcb-42e6-8318-1837ede27e76/lib/internet.lua
7
2908
local buffer = require("buffer") local component = require("component") local event = require("event") local internet = {} ------------------------------------------------------------------------------- function internet.request(url, data) checkArg(1, url, "string") checkArg(2, data, "string", "table", "nil") local inet = component.internet if not inet then error("no primary internet card found", 2) end local post if type(data) == "string" then post = data elseif type(data) == "table" then for k, v in pairs(data) do post = post and (post .. "&") or "" post = post .. tostring(k) .. "=" .. tostring(v) end end local request, reason = inet.request(url, post) if not request then error(reason, 2) end return function() while true do local data, reason = request.read() if not data then request.close() if reason then error(reason, 2) else return nil -- eof end elseif #data > 0 then return data end -- else: no data, block os.sleep(0) end end end ------------------------------------------------------------------------------- local socketStream = {} function socketStream:close() if self.socket then self.socket.close() self.socket = nil end end function socketStream:seek() return nil, "bad file descriptor" end function socketStream:read(n) if not self.socket then return nil, "connection is closed" end return self.socket.read(n) end function socketStream:write(value) if not self.socket then return nil, "connection is closed" end while #value > 0 do local written, reason = self.socket.write(value) if not written then return nil, reason end value = string.sub(value, written + 1) end return true end function internet.socket(address, port) checkArg(1, address, "string") checkArg(2, port, "number", "nil") if port then address = address .. ":" .. port end local inet = component.internet local socket, reason = inet.connect(address) if not socket then return nil, reason end local stream = {inet = inet, socket = socket} -- stream:close does a syscall, which yields, and that's not possible in -- the __gc metamethod. So we start a timer to do the yield/cleanup. local function cleanup(self) if not self.socket then return end pcall(self.socket.close) end local metatable = {__index = socketStream, __gc = cleanup, __metatable = "socketstream"} return setmetatable(stream, metatable) end function internet.open(address, port) local stream, reason = internet.socket(address, port) if not stream then return nil, reason end return buffer.new("rwb", stream) end ------------------------------------------------------------------------------- return internet
mit
nesstea/darkstar
scripts/zones/Batallia_Downs/npcs/Field_Manual.lua
29
1048
----------------------------------- -- Field Manual -- Area: Batallia Downs ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/fieldsofvalor"); ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) startFov(FOV_EVENT_BATALLIA,player); end; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onEventSelection ----------------------------------- function onEventUpdate(player,csid,menuchoice) updateFov(player,csid,menuchoice,15,72,73,74,75); end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) finishFov(player,csid,option,15,72,73,74,75,FOV_MSG_BATALLIA); end;
gpl-3.0
nesstea/darkstar
scripts/zones/Windurst_Woods/npcs/Amimi.lua
25
1980
----------------------------------- -- Area: Windurst Woods -- NPC: Amimi -- Type: Chocobo Renter ----------------------------------- require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); require("scripts/globals/settings"); require("scripts/globals/status"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local level = player:getMainLvl(); local gil = player:getGil(); if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then local price = getChocoboPrice(player); player:setLocalVar("chocoboPriceOffer",price); if (level >= 20) then level = 0; end player:startEvent(0x2714,price,gil,level); else player:startEvent(0x2717); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish Action ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); local price = player:getLocalVar("chocoboPriceOffer"); if (csid == 0x2714 and option == 0) then if (player:delGil(price)) then updateChocoboPrice(player, price); if (player:getMainLvl() >= 20) then local duration = 1800 + (player:getMod(MOD_CHOCOBO_RIDING_TIME) * 60) player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,duration,true); else player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); end player:setPos(-122,-4,-520,0,0x74); end end end;
gpl-3.0
UnfortunateFruit/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
nesstea/darkstar
scripts/globals/spells/slow.lua
21
1465
----------------------------------------- -- Spell: Slow -- Spell accuracy is most highly affected by Enfeebling Magic Skill, Magic Accuracy, and MND. -- Slow's potency is calculated with the formula (150 + dMND*2)/1024, and caps at 300/1024 (~29.3%). -- And MND of 75 is neccessary to reach the hardcap of Slow. ----------------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) local dMND = (caster:getStat(MOD_MND) - target:getStat(MOD_MND)); --Power. local power = 150 + dMND * 2; if (power > 300) then power = 300; end if (caster:hasStatusEffect(EFFECT_SABOTEUR)) then power = power * 2; end --Duration, including resistance. local duration = 120 * applyResistanceEffect(caster,spell,target,dMND,35,0,EFFECT_SLOW); if (duration >= 60) then --Do it! if (caster:hasStatusEffect(EFFECT_SABOTEUR)) then duration = duration * 2; end caster:delStatusEffect(EFFECT_SABOTEUR); if (target:addStatusEffect(EFFECT_SLOW,power,0,duration, 0, 1)) then spell:setMsg(236); else spell:setMsg(75); end else spell:setMsg(85); end return EFFECT_SLOW; end;
gpl-3.0
nesstea/darkstar
scripts/zones/Southern_San_dOria_[S]/npcs/Loillie.lua
13
1613
----------------------------------- -- Area: Southern SandOria [S] -- NPC: Loillie -- @zone 80 -- @pos 78 -8 -23 ----------------------------------- package.loaded["scripts/zones/Southern_San_dOria_[S]/TextIDs"] = nil; require("scripts/zones/Southern_San_dOria_[S]/TextIDs"); require("scripts/globals/quests"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) if (player:getQuestStatus(CRYSTAL_WAR,GIFTS_OF_THE_GRIFFON) == QUEST_ACCEPTED and player:getVar("GiftsOfGriffonProg") == 2) then local mask = player:getVar("GiftsOfGriffonPlumes"); if (trade:hasItemQty(2528,1) and trade:getItemCount() == 1 and not player:getMaskBit(mask,6)) then player:startEvent(0x01D) -- Gifts of Griffon Trade end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x0265); -- Default Dialogue 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 == 0x01D) then -- Gifts Of Griffon Trade player:tradeComplete(); local mask = player:getVar("GiftsOfGriffonPlumes"); player:setMaskBit(mask,"GiftsOfGriffonPlumes",6,true); end end;
gpl-3.0
UnfortunateFruit/darkstar
scripts/zones/Qulun_Dome/mobs/Diamond_Quadav.lua
27
1447
----------------------------------- -- Area: Qulun_Dome -- NM: Diamond_Quadav -- Note: PH for Za Dha Adamantking PH ----------------------------------- require("scripts/zones/Qulun_Dome/TextIDs"); ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) end; ----------------------------------- -- onMobEngaged ----------------------------------- function onMobEngaged(mob,target) mob:showText(mob,DIAMOND_QUADAV_ENGAGE); end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob,killer) local Diamond_Quadav = mob:getID(); local Za_Dha_Adamantking = 17383443; local ToD = GetServerVariable("[POP]Za_Dha_Adamantking"); DeterMob(Diamond_Quadav, true); mob:showText(mob,DIAMOND_QUADAV_DEATH); if (ToD <= os.time(t) + 172800 and GetMobAction(Za_Dha_Adamantking) == 0) then -- -- From wikia: A 3-5 day spawn; however it can spawn as early as 2 days from previous kill or as late as 10 days. if (math.random((1),(5)) == 3 or os.time(t) >= 777600) then UpdateNMSpawnPoint(Za_Dha_Adamantking); GetMobByID(Za_Dha_Adamantking):setRespawnTime(math.random((75600),(86400))); -- 21 to 24 hours end else UpdateNMSpawnPoint(Diamond_Quadav); mob:setRespawnTime(math.random((75600),(86400))); end end;
gpl-3.0
nesstea/darkstar
scripts/zones/Southern_San_dOria/npcs/Endracion.lua
13
6376
----------------------------------- -- Area: Northern San d'Oria -- NPC: Endracion -- @pos -110 1 -34 230 ----------------------------------- package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/missions"); require("scripts/zones/Southern_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) CurrentMission = player:getCurrentMission(SANDORIA); OrcishScoutCompleted = player:hasCompletedMission(SANDORIA,SMASH_THE_ORCISH_SCOUTS); BatHuntCompleted = player:hasCompletedMission(SANDORIA,BAT_HUNT); TheCSpringCompleted = player:hasCompletedMission(SANDORIA,THE_CRYSTAL_SPRING); MissionStatus = player:getVar("MissionStatus"); Count = trade:getItemCount(); if (CurrentMission ~= 255) then if (CurrentMission == SMASH_THE_ORCISH_SCOUTS and trade:hasItemQty(16656,1) and Count == 1 and OrcishScoutCompleted == false) then -- Trade Orcish Axe player:startEvent(0x03fc); -- Finish Mission "Smash the Orcish scouts" (First Time) elseif (CurrentMission == SMASH_THE_ORCISH_SCOUTS and trade:hasItemQty(16656,1) and Count == 1) then -- Trade Orcish Axe player:startEvent(0x03ea); -- Finish Mission "Smash the Orcish scouts" (Repeat) elseif (CurrentMission == BAT_HUNT and trade:hasItemQty(1112,1) and Count == 1 and BatHuntCompleted == false and MissionStatus == 2) then -- Trade Orcish Mail Scales player:startEvent(0x03ff); -- Finish Mission "Bat Hunt" elseif (CurrentMission == BAT_HUNT and trade:hasItemQty(891,1) and Count == 1 and BatHuntCompleted == true) then -- Trade Bat Fang player:startEvent(0x03eb); -- Finish Mission "Bat Hunt" (repeat) elseif (CurrentMission == THE_CRYSTAL_SPRING and trade:hasItemQty(4528,1) and Count == 1 and TheCSpringCompleted == false) then -- Trade Crystal Bass player:startEvent(0x0406); -- Dialog During Mission "The Crystal Spring" elseif (CurrentMission == THE_CRYSTAL_SPRING and trade:hasItemQty(4528,1) and Count == 1 and TheCSpringCompleted) then -- Trade Crystal Bass player:startEvent(0x03f5); -- Finish Mission "The Crystal Spring" (repeat) else player:startEvent(0x03f0); -- Wrong Item end else player:startEvent(0x03f2); -- Mission not activated end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local PresOfPapsqueCompleted = player:hasCompletedMission(SANDORIA,PRESTIGE_OF_THE_PAPSQUE); if (player:getNation() ~= SANDORIA) then player:startEvent(0x03F3); -- for Non-San d'Orians else CurrentMission = player:getCurrentMission(SANDORIA); MissionStatus = player:getVar("MissionStatus"); pRank = player:getRank(); cs, p, offset = getMissionOffset(player,1,CurrentMission,MissionStatus); if (CurrentMission <= 15 and (cs ~= 0 or offset ~= 0 or (CurrentMission == 0 and offset == 0))) then if (cs == 0) then player:showText(npc,ORIGINAL_MISSION_OFFSET + offset); -- dialog after accepting mission else player:startEvent(cs,p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8]); end elseif (pRank == 1 and player:hasCompletedMission(SANDORIA,SMASH_THE_ORCISH_SCOUTS) == false) then player:startEvent(0x03e8); -- Start First Mission "Smash the Orcish scouts" elseif (player:hasKeyItem(ANCIENT_SANDORIAN_BOOK)) then player:startEvent(0x040b); elseif (CurrentMission == RANPERRE_S_FINAL_REST and player:getVar("MissionStatus",4) and tonumber(os.date("%j")) == player:getVar("Wait1DayForRanperre_date")) then player:startEvent(0x040d); elseif (CurrentMission == RANPERRE_S_FINAL_REST and player:getVar("MissionStatus") == 4 and tonumber(os.date("%j")) ~= player:getVar("Wait1DayForRanperre_date")) then -- Ready now. player:startEvent(0x040f); elseif (CurrentMission == RANPERRE_S_FINAL_REST and player:getVar("MissionStatus") == 6) then player:startEvent(0x040f); elseif (CurrentMission == RANPERRE_S_FINAL_REST and player:getVar("MissionStatus") == 9) then player:startEvent(0x0409); elseif (CurrentMission ~= THE_SECRET_WEAPON and pRank == 7 and PresOfPapsqueCompleted == true and getMissionRankPoints(player,19) == 1 and player:getVar("SecretWeaponStatus") == 0) then player:startEvent(0x003d); elseif (CurrentMission == THE_SECRET_WEAPON and player:getVar("SecretWeaponStatus") == 3) then player:startEvent(0x0413); elseif ((CurrentMission ~= 255) and not (player:getVar("MissionStatus") == 8)) then player:startEvent(0x03e9); -- Have mission already activated else mission_mask, repeat_mask = getMissionMask(player); player:startEvent(0x03f1,mission_mask, 0, 0 ,0 ,0 ,repeat_mask); -- Mission List end end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("onUpdateCSID: %u",csid); --printf("onUpdateOPTION: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("onFinishCSID: %u",csid); --printf("onFinishOPTION: %u",option); finishMissionTimeline(player,1,csid,option); if (csid == 0x040b) then player:setVar("MissionStatus",4); player:delKeyItem(ANCIENT_SANDORIAN_BOOK); player:setVar("Wait1DayForRanperre_date", os.date("%j")); elseif (csid == 0x040d) then player:setVar("MissionStatus",6); elseif (csid == 0x040f) then player:setVar("MissionStatus",7); player:setVar("Wait1DayForRanperre_date",0); elseif (csid == 0x0409) then finishMissionTimeline(player,2,csid,option); elseif (csid == 0x003d) then player:setVar("SecretWeaponStatus",1); elseif (csid == 0x0413) then finishMissionTimeline(player,2,csid,option); end end;
gpl-3.0
nesstea/darkstar
scripts/zones/Dynamis-Xarcabard/npcs/qm1.lua
13
1344
----------------------------------- -- 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
UnfortunateFruit/darkstar
scripts/zones/Dynamis-Qufim/mobs/Antaeus.lua
17
2116
----------------------------------- -- Area: Dynamis Qufim -- NPC: Antaeus ----------------------------------- package.loaded["scripts/zones/Dynamis-Qufim/TextIDs"] = nil; ----------------------------------- require("scripts/globals/dynamis"); require("scripts/zones/Dynamis-Qufim/TextIDs"); require("scripts/globals/keyitems"); require("scripts/globals/titles"); ----------------------------------- -- onMobSpawn Action ----------------------------------- function onMobSpawn(mob) end; ----------------------------------- -- onMobEngaged ----------------------------------- function onMobEngaged(mob,target) if(GetServerVariable("[DynaQufim]Boss_Trigger")==0)then --spwan additional mob : for Nightmare_Stirge = 16945407, 16945420, 1 do SpawnMob(Nightmare_Stirge); end for Nightmare_Diremite = 16945422, 16945430, 1 do SpawnMob(Nightmare_Diremite); end for Nightmare_Gaylas = 16945431, 16945442, 1 do SpawnMob(Nightmare_Gaylas); end for Nightmare_Kraken = 16945443, 16945456, 1 do SpawnMob(Nightmare_Kraken); end for Nightmare_Snoll = 16945458, 16945469, 1 do SpawnMob(Nightmare_Snoll); end for Nightmare_Tiger = 16945510, 16945521, 1 do SpawnMob(Nightmare_Tiger); end for Nightmare_Weapon = 16945549, 16945558, 1 do SpawnMob(Nightmare_Weapon); end for Nightmare_Raptor = 16945589, 16945598, 1 do SpawnMob(Nightmare_Raptor); end SetServerVariable("[DynaQufim]Boss_Trigger",1); end end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob,killer) if(killer:hasKeyItem(DYNAMIS_QUFIM_SLIVER ) == false)then killer:addKeyItem(DYNAMIS_QUFIM_SLIVER); killer:messageSpecial(KEYITEM_OBTAINED,DYNAMIS_QUFIM_SLIVER); end killer:addTitle(DYNAMISQUFIM_INTERLOPER); end;
gpl-3.0
jshackley/darkstar
scripts/globals/items/tropical_clam.lua
18
1267
----------------------------------------- -- ID: 5124 -- Item: Tropical Clam -- Food Effect: 5Min, Mithra only ----------------------------------------- -- Vitality 4 -- Dexterity -5 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) result = 0 if (target:getRace() ~= 7) then result = 247; end if (target:getMod(MOD_EAT_RAW_FISH) == 1) then result = 0; end if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,300,5124); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_VIT, 4); target:addMod(MOD_DEX, -5); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_VIT, 4); target:delMod(MOD_DEX, -5); end;
gpl-3.0
jshackley/darkstar
scripts/globals/spells/bluemagic/terror_touch.lua
18
2034
----------------------------------------- -- Spell: Terror Touch -- Additional effect: Weakens attacks. Accuracy varies with TP -- Spell cost: 62 MP -- Monster Type: Undead -- Spell Type: Physical (Blunt) -- Blue Magic Points: 3 -- Stat Bonus: HP-5 MP+10 -- Level: 40 -- Casting Time: 3.25 seconds -- Recast Time: 21 seconds -- Duration: 60~ seconds -- Skillchain Element(s): Dark (Primary) and Water (Secondary) - (can open Transfixion, Detonation, Impaction, or Induration; can close Compression, Reverberation, or Gravitation) -- Combos: Defense Bonus ----------------------------------------- require("scripts/globals/magic"); require("scripts/globals/status"); require("scripts/globals/bluemagic"); ----------------------------------------- -- OnMagicCastingCheck ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; ----------------------------------------- -- OnSpellCast ----------------------------------------- function onSpellCast(caster,target,spell) local params = {}; -- This data should match information on http://wiki.ffxiclopedia.org/wiki/Calculating_Blue_Magic_Damage params.tpmod = TPMOD_ACC; params.dmgtype = DMGTYPE_H2H; params.scattr = SC_COMPRESSION; params.numhits = 1; params.multiplier = 1.5; params.tp150 = 1.5; params.tp300 = 1.5; params.azuretp = 1.5; params.duppercap = 41; params.str_wsc = 0.0; params.dex_wsc = 0.2; 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; damage = BluePhysicalSpell(caster, target, spell, params); damage = BlueFinalAdjustments(caster, target, spell, damage, params); if (target:hasStatusEffect(EFFECT_ATTACK_DOWN)) then spell:setMsg(75); -- no effect else target:addStatusEffect(EFFECT_ATTACK_DOWN,15,0,20); end return damage; end;
gpl-3.0
Ombridride/minetest-minetestforfun-server
mods/homedecor_modpack/homedecor/electrics.lua
14
1838
homedecor.register("power_outlet", { description = "Power Outlet", tiles = { "homedecor_outlet_edges.png", "homedecor_outlet_edges.png", "homedecor_outlet_edges.png", "homedecor_outlet_edges.png", "homedecor_outlet_back.png", "homedecor_outlet_edges.png" }, inventory_image = "homedecor_outlet_inv.png", node_box = { type = "fixed", fixed = { { -0.125, -0.3125, 0.4375, 0.125, 0, 0.5}, } }, selection_box = { type = "fixed", fixed = { { -0.1875, -0.375, 0.375, 0.1875, 0.0625, 0.5}, } }, groups = {cracky=3,dig_immediate=2}, walkable = false }) homedecor.register("light_switch", { description = "Light switch", tiles = { "homedecor_light_switch_edges.png", "homedecor_light_switch_edges.png", "homedecor_light_switch_edges.png", "homedecor_light_switch_edges.png", "homedecor_light_switch_back.png", "homedecor_light_switch_front.png" }, inventory_image = "homedecor_light_switch_inv.png", node_box = { type = "fixed", fixed = { { -0.125, -0.5, 0.4375, 0.125, -0.1875, 0.5 }, { -0.03125, -0.3125, 0.40625, 0.03125, -0.25, 0.5 }, } }, selection_box = { type = "fixed", fixed = { { -0.1875, -0.5625, 0.375, 0.1875, -0.1250, 0.5 }, } }, groups = {cracky=3,dig_immediate=2}, walkable = false }) homedecor.register("doorbell", { tiles = { "homedecor_doorbell.png" }, inventory_image = "homedecor_doorbell_inv.png", description = "Doorbell", groups = {snappy=3}, walkable = false, node_box = { type = "fixed", fixed = { {-0.0625, 0, 0.46875, 0.0625, 0.1875, 0.5}, -- NodeBox1 {-0.03125, 0.0625, 0.45, 0.03125, 0.125, 0.4675}, -- NodeBox2 } }, on_punch = function(pos, node, puncher, pointed_thing) minetest.sound_play("homedecor_doorbell", { pos = pos, gain = 1.0, max_hear_distance = 15 }) end })
unlicense
Victek/wrt1900ac-aa
veriksystems/luci-0.11/protocols/relay/luasrc/model/cbi/admin_network/proto_relay.lua
86
2148
--[[ 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 ]]-- local map, section, net = ... local ipaddr, network local forward_bcast, forward_dhcp, gateway, expiry, retry, table ipaddr = section:taboption("general", Value, "ipaddr", translate("Local IPv4 address"), translate("Address to access local relay bridge")) ipaddr.datatype = "ip4addr" network = s:taboption("general", DynamicList, "network", translate("Relay between networks")) network.widget = "checkbox" network.exclude = arg[1] network.template = "cbi/network_netlist" network.nocreate = true network.nobridges = true network.novirtual = true network:depends("proto", "relay") forward_bcast = section:taboption("advanced", Flag, "forward_bcast", translate("Forward broadcast traffic")) forward_bcast.default = forward_bcast.enabled forward_dhcp = section:taboption("advanced", Flag, "forward_dhcp", translate("Forward DHCP traffic")) forward_dhcp.default = forward_dhcp.enabled gateway = section:taboption("advanced", Value, "gateway", translate("Use DHCP gateway"), translate("Override the gateway in DHCP responses")) gateway.datatype = "ip4addr" gateway:depends("forward_dhcp", forward_dhcp.enabled) expiry = section:taboption("advanced", Value, "expiry", translate("Host expiry timeout"), translate("Specifies the maximum amount of seconds after which hosts are presumed to be dead")) expiry.placeholder = "30" expiry.datatype = "min(1)" retry = section:taboption("advanced", Value, "retry", translate("ARP retry threshold"), translate("Specifies the maximum amount of failed ARP requests until hosts are presumed to be dead")) retry.placeholder = "5" retry.datatype = "min(1)" table = section:taboption("advanced", Value, "table", translate("Use routing table"), translate("Override the table used for internal routes")) table.placeholder = "16800" table.datatype = "range(0,65535)"
gpl-2.0
jshackley/darkstar
scripts/globals/items/cone_calamary.lua
18
1262
----------------------------------------- -- ID: 5128 -- Item: Cone Calamary -- Food Effect: 5Min, Mithra only ----------------------------------------- -- Dexterity 3 -- Mind -5 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) result = 0 if (target:getRace() ~= 7) then result = 247; end if (target:getMod(MOD_EAT_RAW_FISH) == 1) then result = 0; end if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,300,5128); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_DEX, 3); target:addMod(MOD_MND, -5); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_DEX, 3); target:delMod(MOD_MND, -5); end;
gpl-3.0
Mpstark/DynamicCam
UiHideModule.lua
1
34984
local _, Addon = ... -- TODO: What happens if a raid member joins (CompactRaidFrame is created) while the UI is hidden and the player is in combat? -- 1x [ADDON_ACTION_BLOCKED] AddOn 'DynamicCam' tried to call the protected function 'CompactRaidFrame1:Show()'. -- For debugging: -- local debugFrameName = "StatusTrackingBarManager" -- Flag to remember if the UI is currently faded out. Addon.uiHiddenTime = 0 -- TODO: How are you going to handle it, if several addons make use of this module? -- You have to store uiHiddenTime and currentConfig globally... local currentConfig = nil -- Call Addon.HideUI(fadeOutTime, config) to hide UI keeping configured frames. -- Call Addon.ShowUI(fadeInTime, true) when entering combat while UI is hidden. -- This will show the actually hidden frames, that cannot be shown during combat, -- but the fade out state will remain. You only see tooltips of faded-out frames. -- Call Addon.ShowUI(fadeInTime, false) to show UI. -- Accepted options for config argument of HideUI(): -- config.hideFrameRate -- config.keepAlertFrames -- config.keepMinimap -- config.keepTooltip -- config.keepChatFrame -- config.keepTrackingBar -- config.UIParentAlpha (while faded out) -- Lua API local _G = _G local tonumber = tonumber local tinsert = tinsert local string_find = string.find local string_match = string.match local GetTime = _G.GetTime local InCombatLockdown = _G.InCombatLockdown local UnitInParty = _G.UnitInParty local CompactRaidFrameContainer = _G.CompactRaidFrameContainer -- We need a function to change a frame's alpha without automatically showing the frame -- (as done by the original UIFrameFade() defined in UIParent.lua). if not ludius_FADEFRAMES then ludius_FADEFRAMES = {} end local frameFadeManager = CreateFrame("FRAME") local function UIFrameFadeRemoveFrame(frame) tDeleteItem(ludius_FADEFRAMES, frame) end -- Changed this to work with GetTime() instead of "elapsed" argument. -- Because the first elapsed after login is always very long and we want -- to be able to start a smooth fade out beginning at the first update. local lastUpdate local function UIFrameFade_OnUpdate(self) local elapsed = 0 if lastUpdate then elapsed = GetTime() - lastUpdate end lastUpdate = GetTime() local index = 1 local frame, fadeInfo while ludius_FADEFRAMES[index] do frame = ludius_FADEFRAMES[index] fadeInfo = ludius_FADEFRAMES[index].fadeInfo -- Reset the timer if there isn't one, this is just an internal counter if not fadeInfo.fadeTimer then fadeInfo.fadeTimer = 0 end fadeInfo.fadeTimer = fadeInfo.fadeTimer + elapsed -- If the fadeTimer is less then the desired fade time then set the alpha otherwise hold the fade state, call the finished function, or just finish the fade if fadeInfo.fadeTimer < fadeInfo.timeToFade then if fadeInfo.mode == "IN" then frame:SetAlpha((fadeInfo.fadeTimer / fadeInfo.timeToFade) * (fadeInfo.endAlpha - fadeInfo.startAlpha) + fadeInfo.startAlpha) elseif fadeInfo.mode == "OUT" then frame:SetAlpha(((fadeInfo.timeToFade - fadeInfo.fadeTimer) / fadeInfo.timeToFade) * (fadeInfo.startAlpha - fadeInfo.endAlpha) + fadeInfo.endAlpha) end else frame:SetAlpha(fadeInfo.endAlpha) -- Complete the fade and call the finished function if there is one UIFrameFadeRemoveFrame(frame) if fadeInfo.finishedFunc then fadeInfo.finishedFunc(fadeInfo.finishedArg1, fadeInfo.finishedArg2, fadeInfo.finishedArg3, fadeInfo.finishedArg4) fadeInfo.finishedFunc = nil end end index = index + 1 end if #ludius_FADEFRAMES == 0 then self:SetScript("OnUpdate", nil) lastUpdate = nil end end local function UIFrameFade(frame, fadeInfo) if not frame then return end -- We make sure that we always call this with mode, startAlpha and endAlpha. assert(fadeInfo.mode) assert(fadeInfo.startAlpha) assert(fadeInfo.endAlpha) -- if frame:GetName() == debugFrameName then print("UIFrameFade", frame:GetName(), fadeInfo.mode, fadeInfo.startAlpha, fadeInfo.endAlpha) end frame.fadeInfo = fadeInfo frame:SetAlpha(fadeInfo.startAlpha) local index = 1 while ludius_FADEFRAMES[index] do -- If frame is already set to fade then return if ludius_FADEFRAMES[index] == frame then return end index = index + 1 end tinsert(ludius_FADEFRAMES, frame) frameFadeManager:SetScript("OnUpdate", UIFrameFade_OnUpdate) end -- A function to set a frame's alpha depending on mouse over and -- whether we are fading/faded out or not. local function SetMouseOverAlpha(frame) -- Only do something to frames for which the hovering was activated. if frame.ludius_mouseOver == nil then return end -- Fading or faded out. if frame.ludius_fadeout then -- If the mouse is hovering over the status bar, show it with alpha 1. if frame.ludius_mouseOver then -- In case we are currently fading out, -- interrupt the fade out in progress. UIFrameFadeRemoveFrame(frame) frame:SetAlpha(1) -- Otherwise use the faded out alpha. else frame:SetAlpha(frame.ludius_alphaAfterFadeOut) end end end local function SetMouseOverFading(barManager) for _, frame in pairs(barManager.bars) do frame:HookScript("OnEnter", function() barManager.ludius_mouseOver = true SetMouseOverAlpha(barManager) end) frame:HookScript("OnLeave", function() barManager.ludius_mouseOver = false SetMouseOverAlpha(barManager) end) end end if Bartender4 then hooksecurefunc(Bartender4:GetModule("StatusTrackingBar"), "OnEnable", function() SetMouseOverFading(BT4StatusBarTrackingManager) end) else hooksecurefunc(StatusTrackingBarManager, "AddBarFromTemplate", SetMouseOverFading) end if IsAddOnLoaded("GW2_UI") then -- GW2_UI seems to offer no way of hooking any of its functions. -- So we have to do it like this. local enterWorldFrame = CreateFrame("Frame") enterWorldFrame:RegisterEvent("PLAYER_ENTERING_WORLD") enterWorldFrame:SetScript("OnEvent", function() if GwExperienceFrame then GwExperienceFrame:HookScript("OnEnter", function() GwExperienceFrame.ludius_mouseOver = true SetMouseOverAlpha(GwExperienceFrame) end) GwExperienceFrame:HookScript("OnLeave", function() GwExperienceFrame.ludius_mouseOver = false SetMouseOverAlpha(GwExperienceFrame) end) end end) end -- To hide the tooltip of bag items. -- (While we are actually hiding other frames to suppress their tooltips, -- this is not practical for the bag, as openning my cause a slight lag.) local function GameTooltipHider(self) if Addon.uiHiddenTime == 0 or not self then return end local ownerName = nil if self:GetOwner() then ownerName = self:GetOwner():GetName() end if ownerName == nil then return end if string_find(ownerName, "^ContainerFrame") or ownerName == "ChatFrameChannelButton" then self:Hide() -- else -- print(ownerName) end end GameTooltip:HookScript("OnTooltipSetDefaultAnchor", GameTooltipHider) GameTooltip:HookScript("OnTooltipSetItem", GameTooltipHider) GameTooltip:HookScript("OnShow", GameTooltipHider) local function ConditionalHide(frame) if not frame then return end -- if frame:GetName() == debugFrameName then print("ConditionalHide", frame:GetName(), frame:GetParent():GetName(), frame:IsIgnoringParentAlpha()) end -- Checking for combat lockdown is not this function's concern. -- Functions calling it must make sure, it is not called in combat lockdown. -- TODO: What if the combat started while the fade out was already happening??? if frame:IsProtected() and InCombatLockdown() then print("ERROR: Should not try to hide", frame:GetName(), "in combat lockdown!") end if frame.ludius_shownBeforeFadeOut == nil then -- if frame:GetName() == debugFrameName then print("Remember it was shown") end frame.ludius_shownBeforeFadeOut = frame:IsShown() end if frame:IsShown() then frame:Hide() end end local function ConditionalShow(frame) if not frame or frame.ludius_shownBeforeFadeOut == nil then return end -- if frame:GetName() == debugFrameName then print("ConditionalShow", frame:GetName(), frame.ludius_shownBeforeFadeOut) end if frame:IsProtected() and InCombatLockdown() then print("ERROR: Should not try to show", frame:GetName(), "in combat lockdown!") end -- If the frame is already shown, we leave it be. if not frame:IsShown() then -- For party and raid member frames, we cannot rely on ludius_shownBeforeFadeOut, -- so some more complex checks are necessary. -- Party member frames. if string_find(frame:GetName(), "^PartyMemberFrame") then -- The NotPresentIcon is taken care of by PartyMemberFrame_UpdateNotPresentIcon below. -- So we only handle the actual PartyMemberFrame and do nothing otherwise. if string_find(frame:GetName(), "^PartyMemberFrame(%d+)$") then -- Only show the party member frames, if we are in a party that is not a raid. -- (Use CompactRaidFrameContainer:IsShown() instead of UnitInRaid("player") because people might use -- an addon like SoloRaidFrame to show the raid frame even while not in raid.) if UnitInParty("player") and not CompactRaidFrameContainer:IsShown() then -- Only for as many frames as there are party members. local numGroupMembers = GetNumGroupMembers() local frameNumber = tonumber(string_match(frame:GetName(), "^PartyMemberFrame(%d+)")) if frameNumber < numGroupMembers then frame:Show() PartyMemberFrame_UpdateNotPresentIcon(frame) -- The above functions set the alpha, but we want to do the fade in ourselves. frame:SetAlpha(0) frame.notPresentIcon:SetAlpha(0) end end end elseif string_find(frame:GetName(), "^CompactRaidFrame") then -- Use CompactRaidFrameContainer:IsShown() instead of UnitInRaid("player") because people might use -- an addon like SoloRaidFrame to show the raid frame even while not in raid. if CompactRaidFrameContainer:IsShown() then -- The actual unit frame is only shown, if it has still a unit. -- This prevents that we show frames of raid members that have already left. if string_find(frame:GetName(), "^CompactRaidFrame(%d+)$") then if frame.unitExists then frame:Show() end -- The other frames can be shown, because they are children of CompactRaidFrame. else frame:Show() end end elseif frame.ludius_shownBeforeFadeOut then -- if frame:GetName() == debugFrameName then print("Have to show it again!") end frame:Show() end end frame.ludius_shownBeforeFadeOut = nil end -- Normally we do not change the IgnoreParentAlpha for frames that are -- not children of UIParent. But for some, we have to make an exception. local allowedNonUIParentChildren = { StatusTrackingBarManager = true, BT4StatusBarTrackingManager = true, GwExperienceFrame = true, } -- To restore frames to their pre-hide ignore-parent-alpha state, -- we remember it in the ludius_ignoreParentAlphaBeforeFadeOut variable. local function ConditionalSetIgnoreParentAlpha(frame, ignoreParentAlpha) -- Only do this to direct children of UIParent. if not frame or (frame:GetParent() ~= UIParent and not allowedNonUIParentChildren[frame:GetName()]) then return end if frame.ludius_ignoreParentAlphaBeforeFadeOut == nil then frame.ludius_ignoreParentAlphaBeforeFadeOut = frame:IsIgnoringParentAlpha() end if frame:IsIgnoringParentAlpha() ~= ignoreParentAlpha then frame:SetIgnoreParentAlpha(ignoreParentAlpha) end end local function ConditionalResetIgnoreParentAlpha(frame) if not frame or frame.ludius_ignoreParentAlphaBeforeFadeOut == nil then return end if frame:IsIgnoringParentAlpha() ~= frame.ludius_ignoreParentAlphaBeforeFadeOut then frame:SetIgnoreParentAlpha(frame.ludius_ignoreParentAlphaBeforeFadeOut) end frame.ludius_ignoreParentAlphaBeforeFadeOut = nil end -- The alert frames have to be dealt with as they are created. -- https://www.wowinterface.com/forums/showthread.php?p=337803 -- For testing: -- /run UIParent:SetAlpha(0.5) -- /run NewMountAlertSystem:ShowAlert("123") NewMountAlertSystem:ShowAlert("123") -- /run CovenantRenownToast:ShowRenownLevelUpToast(C_Covenants.GetActiveCovenantID(), 40) -- Collect alert frames that are created. local collectedAlertFrames = {} -- A flag for alert frames that are created/collected while the UI is hidden. local currentAlertFramesIgnoreParentAlpha = false local function AlertFramesSetIgnoreParentAlpha(ignoreParentAlpha) currentAlertFramesIgnoreParentAlpha = ignoreParentAlpha for _, v in pairs(collectedAlertFrames) do ConditionalSetIgnoreParentAlpha(v, ignoreParentAlpha) end end local function AlertFramesResetIgnoreParentAlpha() currentAlertFramesIgnoreParentAlpha = false for _, v in pairs(collectedAlertFrames) do ConditionalResetIgnoreParentAlpha(v) end end local function CollectAlertFrame(_, frame) if frame and not frame.ludius_collected then tinsert(collectedAlertFrames, frame) frame.ludius_collected = true if currentAlertFramesIgnoreParentAlpha then ConditionalSetIgnoreParentAlpha(frame, currentAlertFramesIgnoreParentAlpha) end end end for _, subSystem in pairs(AlertFrame.alertFrameSubSystems) do local pool = type(subSystem) == 'table' and subSystem.alertFramePool if type(pool) == 'table' and type(pool.resetterFunc) == 'function' then hooksecurefunc(pool, "resetterFunc", CollectAlertFrame) end end -- If targetIgnoreParentAlpha == true, targetAlpha is the frame's alpha. -- If targetIgnoreParentAlpha == false, targetAlpha is the UIParent's alpha. -- -- If targetIgnoreParentAlpha == nil, we are ignoring this frame! -- FadeInFrame() will automatically ignore this as well as it will not find our ludius_ flags. local function FadeOutFrame(frame, duration, targetIgnoreParentAlpha, targetAlpha) if not frame or targetIgnoreParentAlpha == nil then return end -- Prevent callback functions of currently active timers. UIFrameFadeRemoveFrame(frame) -- if frame:GetName() == debugFrameName then print("FadeOutFrame", frame:GetName(), targetIgnoreParentAlpha, targetAlpha) end -- ludius_alphaBeforeFadeOut is only set, if this is a fresh FadeOutFrame(). -- It is set to nil after a FadeOutFrame is completed. -- Otherwise, we might falsely asume a wrong ludius_alphaBeforeFadeOut -- value while a fadein is still in progress. if frame.ludius_alphaBeforeFadeOut == nil then frame.ludius_alphaBeforeFadeOut = frame:GetAlpha() end -- To use UIFrameFade() which is the same as UIFrameFadeOut, but with a callback function. local fadeInfo = {} fadeInfo.mode = "OUT" fadeInfo.timeToFade = duration fadeInfo.finishedArg1 = frame fadeInfo.finishedFunc = function(finishedArg1) -- if finishedArg1:GetName() == debugFrameName then print("Fade out finished", finishedArg1:GetName(), targetAlpha) end if targetAlpha == 0 then -- if finishedArg1:GetName() == debugFrameName then print("...and hiding!", targetAlpha) end if not finishedArg1:IsProtected() or not InCombatLockdown() then ConditionalHide(finishedArg1) end end end -- Frame should henceforth ignore parent alpha. if targetIgnoreParentAlpha then -- This is to let SetMouseOverAlpha() know whether we are -- currently fading/faded in or fading/faded out. -- Notice that we cannot use ludius_alphaBeforeFadeOut or ludius_alphaAfterFadeOut as this flag, -- because ludius_fadeout is unset at the beginning of a fade out -- and ludius_alphaBeforeFadeOut is unset at the end of a fade out. -- For an OnEnable/OnLeave during fade out, we do not want the alpha to change. frame.ludius_fadeout = true -- This is to let SetMouseOverAlpha() know which -- alpha to go back to OnLeave while the frame is faded or fading out. frame.ludius_alphaAfterFadeOut = targetAlpha SetMouseOverAlpha(frame) -- Frame was adhering to parent alpha before. -- Start the fade with UIParent's current alpha. if not frame:IsIgnoringParentAlpha() then fadeInfo.startAlpha = UIParent:GetAlpha() -- Frame was already ignoring parent alpha before. else fadeInfo.startAlpha = frame:GetAlpha() end fadeInfo.endAlpha = targetAlpha ConditionalSetIgnoreParentAlpha(frame, true) -- Frame should henceforth adhere to parent alpha. else -- Frame was ignoring parent alpha before. -- Start the fade with the frame's alpha, fade to UIParent's target alpha -- and only then unset ignore parent alpha. -- Notice that the frame's alpha is not overriden by parent alpha but combined. -- So we have to set the child's alpha to 1 at the same time as we stop ignoring -- parent alpha. if frame:IsIgnoringParentAlpha() then fadeInfo.startAlpha = frame:GetAlpha() fadeInfo.endAlpha = targetAlpha fadeInfo.finishedFunc = function(finishedArg1) -- if finishedArg1:GetName() == debugFrameName then print("Fade out finished", finishedArg1:GetName(), targetAlpha) end frame:SetAlpha(1) ConditionalSetIgnoreParentAlpha(finishedArg1, false) if targetAlpha == 0 then ConditionalHide(finishedArg1) end end -- Frame was already adhering to parent alpha. -- We are not changing it. else fadeInfo.startAlpha = frame:GetAlpha() fadeInfo.endAlpha = frame:GetAlpha() end end -- Cannot rely on UIFrameFade to finish within the same frame. if duration == 0 then frame:SetAlpha(fadeInfo.endAlpha) fadeInfo.finishedFunc(fadeInfo.finishedArg1) else -- if frame:GetName() == debugFrameName then print("Starting fade with", fadeInfo.startAlpha, fadeInfo.endAlpha, fadeInfo.mode, fadeInfo.timeToFade) end UIFrameFade(frame, fadeInfo) end end local function FadeInFrame(frame, duration, enteringCombat) if not frame then return end -- Prevent callback functions of currently active timers. UIFrameFadeRemoveFrame(frame) -- Only do something if we have touched this frame before. if frame.ludius_shownBeforeFadeOut == nil and frame.ludius_alphaBeforeFadeOut == nil and frame.ludius_ignoreParentAlphaBeforeFadeOut == nil then return end -- if frame:GetName() == debugFrameName then print("FadeInFrame", frame:GetName()) end if enteringCombat then -- When entering combat we have to show protected frames, which cannot be shown any more during combat. if frame:IsProtected() then ConditionalShow(frame) end -- But we do not yet do the fade in. return else ConditionalShow(frame) end -- To use UIFrameFade() which is the same as UIFrameFadeOut, but with a callback function. local fadeInfo = {} fadeInfo.mode = "IN" fadeInfo.timeToFade = duration fadeInfo.finishedArg1 = frame fadeInfo.finishedFunc = function(finishedArg1) finishedArg1.ludius_alphaBeforeFadeOut = nil finishedArg1.ludius_alphaAfterFadeOut = nil end -- Frame should henceforth ignore parent alpha. if frame.ludius_ignoreParentAlphaBeforeFadeOut == true then -- Frame was adhering to parent alpha before. -- Start the fade with UIParent's current alpha. if not frame:IsIgnoringParentAlpha() then fadeInfo.startAlpha = UIParent:GetAlpha() -- Frame was already ignoring parent alpha before. else fadeInfo.startAlpha = frame:GetAlpha() end fadeInfo.endAlpha = frame.ludius_alphaBeforeFadeOut ConditionalResetIgnoreParentAlpha(frame) -- Frame should henceforth adhere to parent alpha. elseif frame.ludius_ignoreParentAlphaBeforeFadeOut == false then -- Frame was ignoring parent alpha before. -- Start the fade with the frame's alpha, fade to UIParent's target alpha -- (which is always 1 when we fade the UI back in) and only then unset -- ignore parent alpha. if frame:IsIgnoringParentAlpha() then fadeInfo.startAlpha = frame:GetAlpha() fadeInfo.endAlpha = 1 fadeInfo.finishedFunc = function(finishedArg1) ConditionalResetIgnoreParentAlpha(finishedArg1) finishedArg1.ludius_alphaBeforeFadeOut = nil finishedArg1.ludius_alphaAfterFadeOut = nil end -- Frame was already adhering to parent alpha. -- We are not changing it. else fadeInfo.startAlpha = frame:GetAlpha() fadeInfo.endAlpha = frame:GetAlpha() end -- No stored value in ludius_ignoreParentAlphaBeforeFadeOut. else fadeInfo.startAlpha = frame:GetAlpha() fadeInfo.endAlpha = frame.ludius_alphaBeforeFadeOut or frame:GetAlpha() end -- if frame:GetName() == debugFrameName then print("Starting fade with", fadeInfo.startAlpha, fadeInfo.endAlpha, fadeInfo.mode) end -- Cannot rely on UIFrameFade to finish within the same frame. if duration == 0 then frame:SetAlpha(fadeInfo.endAlpha) fadeInfo.finishedFunc(fadeInfo.finishedArg1) else UIFrameFade(frame, fadeInfo) end -- We can do this always when fading in. frame.ludius_fadeout = nil SetMouseOverAlpha(frame) end Addon.HideUI = function(fadeOutTime, config) -- print("HideUI", fadeOutTime) -- Remember that the UI is faded. Addon.uiHiddenTime = GetTime() currentConfig = config if config.hideFrameRate then -- The framerate label is a child of WorldFrame, while we just fade UIParent. -- That's why we have to set targetIgnoreParentAlpha to true. FadeOutFrame(FramerateLabel, fadeOutTime, true, config.UIParentAlpha) FadeOutFrame(FramerateText, fadeOutTime, true, config.UIParentAlpha) end AlertFramesSetIgnoreParentAlpha(config.keepAlertFrames) FadeOutFrame(CovenantRenownToast, fadeOutTime, config.keepAlertFrames, config.keepAlertFrames and 1 or config.UIParentAlpha) FadeOutFrame(MinimapCluster, fadeOutTime, config.keepMinimap, config.keepMinimap and 1 or config.UIParentAlpha) FadeOutFrame(GameTooltip, fadeOutTime, config.keepTooltip, config.keepTooltip and 1 or config.UIParentAlpha) FadeOutFrame(AceGUITooltip, fadeOutTime, config.keepTooltip, config.keepTooltip and 1 or config.UIParentAlpha) FadeOutFrame(AceConfigDialogTooltip, fadeOutTime, config.keepTooltip, config.keepTooltip and 1 or config.UIParentAlpha) FadeOutFrame(ChatFrame1, fadeOutTime, config.keepChatFrame, config.keepChatFrame and 1 or config.UIParentAlpha) FadeOutFrame(ChatFrame1Tab, fadeOutTime, config.keepChatFrame, config.keepChatFrame and 1 or config.UIParentAlpha) FadeOutFrame(ChatFrame1EditBox, fadeOutTime, config.keepChatFrame, config.keepChatFrame and 1 or config.UIParentAlpha) if GwChatContainer1 then FadeOutFrame(GwChatContainer1, fadeOutTime, config.keepChatFrame, config.keepChatFrame and 1 or config.UIParentAlpha) end if BT4StatusBarTrackingManager then FadeOutFrame(BT4StatusBarTrackingManager, fadeOutTime, config.keepTrackingBar, config.keepTrackingBar and config.trackingBarAlpha or config.UIParentAlpha) else FadeOutFrame(StatusTrackingBarManager, fadeOutTime, config.keepTrackingBar, config.keepTrackingBar and config.trackingBarAlpha or config.UIParentAlpha) end if GwExperienceFrame then FadeOutFrame(GwExperienceFrame, fadeOutTime, config.keepTrackingBar, config.keepTrackingBar and config.trackingBarAlpha or config.UIParentAlpha) end for i = 1, 4, 1 do if _G["PartyMemberFrame" .. i] then -- This frame is by default ignoring its parent's alpha. So we have to fade it manually. FadeOutFrame(_G["PartyMemberFrame" .. i .. "NotPresentIcon"], fadeOutTime, true, config.UIParentAlpha) -- This frame does adhere to its parent's alpha, but we want to hide it. FadeOutFrame(_G["PartyMemberFrame" .. i], fadeOutTime, false, config.UIParentAlpha) end end -- Do not use GetNumGroupMembers() here, because as people join and leave the raid the frame numbers get mixed up. for i = 1, 40, 1 do if _G["CompactRaidFrame" .. i] then -- These frames are by default ignoring their parent's alpha. So we have to fade them out manually. FadeOutFrame(_G["CompactRaidFrame" .. i .. "Background"], fadeOutTime, true, config.UIParentAlpha) FadeOutFrame(_G["CompactRaidFrame" .. i .. "HorizTopBorder"], fadeOutTime, true, config.UIParentAlpha) FadeOutFrame(_G["CompactRaidFrame" .. i .. "HorizBottomBorder"], fadeOutTime, true, config.UIParentAlpha) FadeOutFrame(_G["CompactRaidFrame" .. i .. "VertLeftBorder"], fadeOutTime, true, config.UIParentAlpha) FadeOutFrame(_G["CompactRaidFrame" .. i .. "VertRightBorder"], fadeOutTime, true, config.UIParentAlpha) -- This frame does adhere to its parent's alpha, but we want to hide it. FadeOutFrame(_G["CompactRaidFrame" .. i], fadeOutTime, false, config.UIParentAlpha) end end -- Non-configurable frames that we just want to hide in case UIParentAlpha is 0. FadeOutFrame(QuickJoinToastButton, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(PlayerFrame, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(PetFrame, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(TargetFrame, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(BuffFrame, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(DebuffFrame, fadeOutTime, false, config.UIParentAlpha) if Bartender4 then FadeOutFrame(BT4Bar1, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(BT4Bar2, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(BT4Bar3, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(BT4Bar4, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(BT4Bar5, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(BT4Bar6, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(BT4Bar7, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(BT4Bar8, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(BT4Bar9, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(BT4Bar10, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(BT4BarBagBar, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(BT4BarMicroMenu, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(BT4BarStanceBar, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(BT4BarPetBar, fadeOutTime, false, config.UIParentAlpha) else FadeOutFrame(ExtraActionBarFrame, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(MainMenuBarArtFrame, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(MainMenuBarVehicleLeaveButton, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(MicroButtonAndBagsBar, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(MultiCastActionBarFrame, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(PetActionBarFrame, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(PossessBarFrame, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(StanceBarFrame, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(MultiBarRight, fadeOutTime, false, config.UIParentAlpha) FadeOutFrame(MultiBarLeft, fadeOutTime, false, config.UIParentAlpha) end if Addon.frameShowTimer then LibStub("AceTimer-3.0"):CancelTimer(Addon.frameShowTimer) end end -- If enteringCombat we only show the hidden frames (which cannot be shown -- during combat lockdown). But we skip the SetIgnoreParentAlpha(false). -- This can be done when the intended ShowUI() is called. Addon.ShowUI = function(fadeInTime, enteringCombat) -- print("ShowUI", fadeInTime, enteringCombat) -- Only do something once per closing. if Addon.uiHiddenTime == 0 then return end if not enteringCombat then Addon.uiHiddenTime = 0 currentConfig = nil end FadeInFrame(FramerateLabel, fadeInTime, enteringCombat) FadeInFrame(FramerateText, fadeInTime, enteringCombat) for i = 1, 4, 1 do if _G["PartyMemberFrame" .. i] then FadeInFrame(_G["PartyMemberFrame" .. i], fadeInTime, enteringCombat) FadeInFrame(_G["PartyMemberFrame" .. i .. "NotPresentIcon"], fadeInTime, enteringCombat) end end -- Do not use GetNumGroupMembers() here, because as people join and leave the raid, the frame numbers get mixed up. for i = 1, 40, 1 do if _G["CompactRaidFrame" .. i] then FadeInFrame(_G["CompactRaidFrame" .. i], fadeInTime, enteringCombat) FadeInFrame(_G["CompactRaidFrame" .. i .. "Background"], fadeInTime, enteringCombat) FadeInFrame(_G["CompactRaidFrame" .. i .. "HorizTopBorder"], fadeInTime, enteringCombat) FadeInFrame(_G["CompactRaidFrame" .. i .. "HorizBottomBorder"], fadeInTime, enteringCombat) FadeInFrame(_G["CompactRaidFrame" .. i .. "VertLeftBorder"], fadeInTime, enteringCombat) FadeInFrame(_G["CompactRaidFrame" .. i .. "VertRightBorder"], fadeInTime, enteringCombat) end end FadeInFrame(QuickJoinToastButton, fadeInTime, enteringCombat) FadeInFrame(PlayerFrame, fadeInTime, enteringCombat) FadeInFrame(PetFrame, fadeInTime, enteringCombat) FadeInFrame(TargetFrame, fadeInTime, enteringCombat) FadeInFrame(BuffFrame, fadeInTime, enteringCombat) FadeInFrame(DebuffFrame, fadeInTime, enteringCombat) if Bartender4 then FadeInFrame(BT4Bar1, fadeInTime, enteringCombat) FadeInFrame(BT4Bar2, fadeInTime, enteringCombat) FadeInFrame(BT4Bar3, fadeInTime, enteringCombat) FadeInFrame(BT4Bar4, fadeInTime, enteringCombat) FadeInFrame(BT4Bar5, fadeInTime, enteringCombat) FadeInFrame(BT4Bar6, fadeInTime, enteringCombat) FadeInFrame(BT4Bar7, fadeInTime, enteringCombat) FadeInFrame(BT4Bar8, fadeInTime, enteringCombat) FadeInFrame(BT4Bar9, fadeInTime, enteringCombat) FadeInFrame(BT4Bar10, fadeInTime, enteringCombat) FadeInFrame(BT4BarBagBar, fadeInTime, enteringCombat) FadeInFrame(BT4BarMicroMenu, fadeInTime, enteringCombat) FadeInFrame(BT4BarStanceBar, fadeInTime, enteringCombat) FadeInFrame(BT4BarPetBar, fadeInTime, enteringCombat) -- Fade in the (possibly only partially) faded status bar. FadeInFrame(BT4StatusBarTrackingManager, fadeInTime, enteringCombat) else FadeInFrame(ExtraActionBarFrame, fadeInTime, enteringCombat) FadeInFrame(MainMenuBarArtFrame, fadeInTime, enteringCombat) FadeInFrame(MainMenuBarVehicleLeaveButton, fadeInTime, enteringCombat) FadeInFrame(MicroButtonAndBagsBar, fadeInTime, enteringCombat) FadeInFrame(MultiCastActionBarFrame, fadeInTime, enteringCombat) FadeInFrame(PetActionBarFrame, fadeInTime, enteringCombat) FadeInFrame(PossessBarFrame, fadeInTime, enteringCombat) FadeInFrame(StanceBarFrame, fadeInTime, enteringCombat) FadeInFrame(MultiBarRight, fadeInTime, enteringCombat) FadeInFrame(MultiBarLeft, fadeInTime, enteringCombat) -- Fade in the (possibly only partially) faded status bar. FadeInFrame(StatusTrackingBarManager, fadeInTime, enteringCombat) end if GwExperienceFrame then -- Fade in the (possibly only partially) faded status bar. FadeInFrame(GwExperienceFrame, fadeInTime, enteringCombat) end FadeInFrame(CovenantRenownToast, fadeInTime, enteringCombat) FadeInFrame(MinimapCluster, fadeInTime, enteringCombat) FadeInFrame(GameTooltip, fadeInTime, enteringCombat) FadeInFrame(AceGUITooltip, fadeInTime, enteringCombat) FadeInFrame(AceConfigDialogTooltip, fadeInTime, enteringCombat) FadeInFrame(ChatFrame1, fadeInTime, enteringCombat) FadeInFrame(ChatFrame1Tab, fadeInTime, enteringCombat) FadeInFrame(ChatFrame1EditBox, fadeInTime, enteringCombat) if GwChatContainer1 then FadeInFrame(GwChatContainer1, fadeInTime, enteringCombat) end -- Cancel timers that may still be in progress. if Addon.frameShowTimer then LibStub("AceTimer-3.0"):CancelTimer(Addon.frameShowTimer) end if not enteringCombat then -- Reset the IgnoreParentAlpha after the UI fade-in is finished. Addon.frameShowTimer = LibStub("AceTimer-3.0"):ScheduleTimer(function() AlertFramesResetIgnoreParentAlpha() end, fadeInTime) end end -- If party/raid members join/leave while the UI is faded, we prevent the frames from being shown again. -- This code is similar to the respective part of HideUI(), see comments there. -- We have to do the OnShow hook, because the GROUP_ROSTER_UPDATE event comes too late. for i = 1, 4, 1 do if _G["PartyMemberFrame" .. i] then _G["PartyMemberFrame" .. i]:HookScript("OnShow", function() if Addon.uiHiddenTime == 0 then return end FadeOutFrame(_G["PartyMemberFrame" .. i .. "NotPresentIcon"], 0, true, currentConfig.UIParentAlpha) FadeOutFrame(_G["PartyMemberFrame" .. i], 0, false, currentConfig.UIParentAlpha) end) end end -- Unlike party member frames, the raid member frames are not there from the start. -- So we have to do the onShow hook, when new ones arrive. hooksecurefunc("CompactRaidFrameContainer_AddUnitFrame", function(_, unit, frameType) for i = 1, 40, 1 do -- Only look at those, which we have not hooked yet. if _G["CompactRaidFrame" .. i] and not _G["CompactRaidFrame" .. i].ludius_hooked then -- If it is a new frame and the UI is currently hidden, we may have to also hide the new frame. if Addon.uiHiddenTime ~= 0 then FadeOutFrame(_G["CompactRaidFrame" .. i .. "Background"], 0, true, currentConfig.UIParentAlpha) FadeOutFrame(_G["CompactRaidFrame" .. i .. "HorizTopBorder"], 0, true, currentConfig.UIParentAlpha) FadeOutFrame(_G["CompactRaidFrame" .. i .. "HorizBottomBorder"], 0, true, currentConfig.UIParentAlpha) FadeOutFrame(_G["CompactRaidFrame" .. i .. "VertLeftBorder"], 0, true, currentConfig.UIParentAlpha) FadeOutFrame(_G["CompactRaidFrame" .. i .. "VertRightBorder"], 0, true, currentConfig.UIParentAlpha) FadeOutFrame(_G["CompactRaidFrame" .. i], 0, false, currentConfig.UIParentAlpha) end -- Do the hook. _G["CompactRaidFrame" .. i]:HookScript("OnShow", function() if Addon.uiHiddenTime == 0 then return end FadeOutFrame(_G["CompactRaidFrame" .. i .. "Background"], 0, true, currentConfig.UIParentAlpha) FadeOutFrame(_G["CompactRaidFrame" .. i .. "HorizTopBorder"], 0, true, currentConfig.UIParentAlpha) FadeOutFrame(_G["CompactRaidFrame" .. i .. "HorizBottomBorder"], 0, true, currentConfig.UIParentAlpha) FadeOutFrame(_G["CompactRaidFrame" .. i .. "VertLeftBorder"], 0, true, currentConfig.UIParentAlpha) FadeOutFrame(_G["CompactRaidFrame" .. i .. "VertRightBorder"], 0, true, currentConfig.UIParentAlpha) FadeOutFrame(_G["CompactRaidFrame" .. i], 0, false, currentConfig.UIParentAlpha) end) -- Remember that you hooked it. _G["CompactRaidFrame" .. i].ludius_hooked = true end end end)
mit
bsmr-games/OpenRA
mods/ra/maps/soviet-05/reinforcements_teams.lua
38
5887
SovietStartReinf = { "e2", "e2" } SovietStartToBasePath = { StartPoint.Location, SovietBasePoint.Location } SovietMCVReinf = { "mcv", "3tnk", "3tnk", "e1", "e1" } SovExpansionPointGuard = { "2tnk", "2tnk", "e3", "e3", "e3" } if Map.Difficulty == "Easy" then ArmorReinfGreece = { "jeep", "1tnk", "1tnk" } else ArmorReinfGreece = { "jeep", "jeep", "1tnk", "1tnk", "1tnk" } end InfantryReinfGreece = { "e1", "e1", "e1", "e1", "e1" } CrossroadsReinfPath = { ReinfRoadPoint.Location } ArtyReinf = { "e3", "e3", "e3", "arty", "arty" } CoastGuardReinf = { "e1", "e1", "e3", "e1", "e3" } DDPatrol1 = { "dd", "dd", "dd" } DDPatrol1Path = { EIslandPoint.Location, WIslandPoint.Location, DDAttackPoint.Location, SReinfPathPoint4.Location, DDAttackPoint.Location, WIslandPoint.Location, EIslandPoint.Location, NearDockPoint.Location } DDPatrol2 = { "dd", "dd" } DDPatrol2Path = { NReinfPathPoint1.Location, SReinfPathPoint1.Location, SReinfPathPoint2.Location, SReinfPathPoint1.Location, NReinfPathPoint1.Location, NearDockPoint.Location } ShipArrivePath = { ReinfNorthPoint.Location, NearDockPoint.Location } AlliedInfantryTypes = { "e1", "e3" } AlliedTankTypes = { "jeep", "1tnk" } AlliedAttackPath = { GreeceBaseEPoint.Location, CrossroadPoint.Location, NWOrefieldPoint.Location, AtUSSRBasePoint.Location } AlliedCrossroadsToRadarPath = { ReinfRoadPoint.Location, CrossroadPoint.Location, GreeceBaseEPoint.Location, GreeceBasePoint.Location } SouthReinfPath = { ReinfEastPoint.Location, SReinfPathPoint1.Location, SReinfPathPoint2.Location, SReinfPathPoint3.Location, SReinfPathPoint4.Location, USSRlstPoint.Location } NorthReinfPath = { ReinfEastPoint.Location, NReinfPathPoint1.Location, GGUnloadPoint.Location } GoodGuyOrefieldPatrolPath = { PatrolPoint1.Location, PatrolPoint2.Location, PatrolPoint3.Location, PatrolPoint4.Location } Ships = { } GreeceInfAttack = { } GGInfAttack = { } TankAttackGG = { } ShipWaypoints = { EIslandPoint, WIslandPoint, DDAttackPoint } InfantryWaypoints = { CrossroadPoint, NWOrefieldPoint, AtUSSRBasePoint, SovietBasePoint } InfantryGGWaypoints = { PatrolPoint2, BetweenBasesPoint, PrepGGArmyPoint } TanksGGWaypoints = { PatrolPoint2, BetweenBasesPoint, PrepGGArmyPoint } Para = function() local powerproxy = Actor.Create("powerproxy.paratroopers", false, { Owner = player }) local units = powerproxy.SendParatroopers(ParaPoint.CenterPosition, false, 28) powerproxy.Destroy() end Para2 = function() local powerproxy = Actor.Create("powerproxy.paratroopers", false, { Owner = player }) local units = powerproxy.SendParatroopers(USSRExpansionPoint.CenterPosition, false, 28) powerproxy.Destroy() end ReinfInf = function() Reinforcements.Reinforce(Greece, InfantryReinfGreece, CrossroadsReinfPath, 0, function(soldier) soldier.Hunt() end) end ReinfArmor = function() RCheck = false Reinforcements.Reinforce(Greece, ArmorReinfGreece, CrossroadsReinfPath, 0, function(soldier) soldier.Hunt() end) end IslandTroops1 = function() local units = Reinforcements.ReinforceWithTransport(GoodGuy, "lst", CoastGuardReinf, { ReinfEastPoint.Location, NReinfPathPoint1.Location, GGUnloadPoint.Location }, { ReinfEastPoint.Location })[2] Utils.Do(units, function(unit) Trigger.OnIdle(unit, function(coastguard) coastguard.AttackMove(CoastGuardPoint.Location) end) end) if not CheckForCYard() then return elseif Map.Difficulty == "Easy" then return else Trigger.OnAllKilled(units, function() if Map.Difficulty == "Hard" then Trigger.AfterDelay(DateTime.Minutes(3), IslandTroops1) else Trigger.AfterDelay(DateTime.Minutes(5), IslandTroops1) end end) end end IslandTroops2 = function() local units = Reinforcements.ReinforceWithTransport(GoodGuy, "lst", ArmorReinfGreece, NorthReinfPath, { ReinfEastPoint.Location })[2] Utils.Do(units, function(unit) Trigger.OnIdle(unit, function(patrols) patrols.Patrol(GoodGuyOrefieldPatrolPath, true, 150) end) end) if not CheckForCYard() then return elseif Map.Difficulty == "Easy" then return else Trigger.OnAllKilled(units, function() if Map.Difficulty == "Hard" then Trigger.AfterDelay(DateTime.Minutes(3), IslandTroops2) else Trigger.AfterDelay(DateTime.Minutes(5), IslandTroops2) end end) end end IslandTroops3 = function() local units = Reinforcements.ReinforceWithTransport(GoodGuy, "lst", SovExpansionPointGuard, SouthReinfPath, { ReinfEastPoint.Location })[2] Utils.Do(units, function(unit) Trigger.OnIdle(unit, function(guards) guards.AttackMove(USSRExpansionPoint.Location) end) end) if not CheckForCYard() then return elseif Map.Difficulty == "Easy" then return else Trigger.OnAllKilled(units, function() if Map.Difficulty == "Hard" then Trigger.AfterDelay(DateTime.Minutes(3), IslandTroops3) else Trigger.AfterDelay(DateTime.Minutes(5), IslandTroops3) end end) end end BringDDPatrol1 = function() local units = Reinforcements.Reinforce(Greece, DDPatrol1, ShipArrivePath, 0) Utils.Do(units, function(unit) Trigger.OnIdle(unit, function(patrols) patrols.Patrol(DDPatrol1Path, true, 250) end) end) if not CheckForCYard() then return else Trigger.OnAllKilled(units, function() if Map.Difficulty == "Hard" then Trigger.AfterDelay(DateTime.Minutes(4), BringDDPatrol1) else Trigger.AfterDelay(DateTime.Minutes(7), BringDDPatrol1) end end) end end BringDDPatrol2 = function() local units = Reinforcements.Reinforce(Greece, DDPatrol2, ShipArrivePath, 0) Utils.Do(units, function(unit) Trigger.OnIdle(unit, function(patrols) patrols.Patrol(DDPatrol2Path, true, 250) end) end) if not CheckForCYard() then return else Trigger.OnAllKilled(units, function() if Map.Difficulty == "Hard" then Trigger.AfterDelay(DateTime.Minutes(4), BringDDPatrol2) else Trigger.AfterDelay(DateTime.Minutes(7), BringDDPatrol2) end end) end end
gpl-3.0
LiberatorUSA/GUCEF
apps/gucefPATCHERAPP/premake4.lua
1
2489
-------------------------------------------------------------------- -- This file was automatically generated by ProjectGenerator -- which is tooling part the build system designed for GUCEF -- (Galaxy Unlimited Framework) -- For the latest info, see http://www.VanvelzenSoftware.com/ -- -- The contents of this file are placed in the public domain. Feel -- free to make use of it in any way you like. -------------------------------------------------------------------- -- -- Configuration for module: gucefPATCHERAPP project( "gucefPATCHERAPP" ) configuration( {} ) location( os.getenv( "PM4OUTPUTDIR" ) ) configuration( {} ) targetdir( os.getenv( "PM4TARGETDIR" ) ) configuration( {} ) language( "C++" ) configuration( {} ) kind( "SharedLib" ) configuration( {} ) links( { "gucefCOM", "gucefCOMCORE", "gucefCORE", "gucefGUI", "gucefIMAGE", "gucefINPUT", "gucefMT", "gucefPATCHER" } ) links( { "gucefCOM", "gucefCOMCORE", "gucefCORE", "gucefGUI", "gucefIMAGE", "gucefINPUT", "gucefMT", "gucefPATCHER" } ) configuration( {} ) defines( { "GUCEF_PATCHERAPP_BUILD_MODULE" } ) configuration( {} ) vpaths { ["Headers"] = { "**.h", "**.hpp", "**.hxx" } } files( { "include/gucefPATCHERAPP_CMainPatcherAppLogic.h", "include/gucefPATCHERAPP_config.h", "include/gucefPATCHERAPP_CPatcherAppConfig.h", "include/gucefPATCHERAPP_CPatcherAppGlobal.h", "include/gucefPATCHERAPP_macros.h", "include/gucefPATCHERAPP_main.h", "include/gucefPATCHERAPP_SimpleTypes.h" } ) configuration( {} ) vpaths { ["Source"] = { "**.c", "**.cpp", "**.cs", "**.asm" } } files( { "src/gucefPATCHERAPP_CMainPatcherAppLogic.cpp", "src/gucefPATCHERAPP_CPatcherAppConfig.cpp", "src/gucefPATCHERAPP_CPatcherAppGlobal.cpp", "src/gucefPATCHERAPP_main.cpp" } ) configuration( {} ) includedirs( { "../../common/include", "../../gucefCOM/include", "../../gucefCOMCORE/include", "../../gucefCORE/include", "../../gucefGUI/include", "../../gucefIMAGE/include", "../../gucefINPUT/include", "../../gucefMT/include", "../../gucefPATCHER/include", "../../gucefVFS/include", "include" } ) configuration( { "ANDROID" } ) includedirs( { "../../gucefCORE/include/android" } ) configuration( { "LINUX" } ) includedirs( { "../../gucefCORE/include/linux" } ) configuration( { "WIN32" } ) includedirs( { "../../gucefCOMCORE/include/mswin", "../../gucefCORE/include/mswin" } ) configuration( { "WIN64" } ) includedirs( { "../../gucefCOMCORE/include/mswin", "../../gucefCORE/include/mswin" } )
apache-2.0
Keithenneu/Dota2-FullOverwrite
modes/defendlane.lua
1
4405
------------------------------------------------------------------------------- --- AUTHOR: Keithen --- GITHUB REPO: https://github.com/Nostrademous/Dota2-FullOverwrite ------------------------------------------------------------------------------- BotsInit = require( "game/botsinit" ) local X = BotsInit.CreateGeneric() local gHeroVar = require( GetScriptDirectory().."/global_hero_data" ) local utils = require( GetScriptDirectory().."/utility" ) require( GetScriptDirectory().."/buildings_status" ) local function setHeroVar(var, value) gHeroVar.SetVar(GetBot():GetPlayerID(), var, value) end local function getHeroVar(var) return gHeroVar.GetVar(GetBot():GetPlayerID(), var) end function X:GetName() return "defendlane" end function X:OnStart(myBot) local bot = GetBot() bot.defendingLane = true end function X:OnEnd() local bot = GetBot() bot.defendingLane = false end function X:Desire(bot) local defInfo = getHeroVar("DoDefendLane") local building = defInfo[2] local hBuilding = buildings_status.GetHandle(GetTeam(), building) if #defInfo > 0 then if hBuilding == nil then -- if building falls, don't stick around and defend area return BOT_MODE_DESIRE_NONE else return BOT_MODE_DESIRE_VERYHIGH end end -- if we are defending the lane, stay until all enemy -- creep is pushed back and enemies are not nearby local me = getHeroVar("Self") if me:getCurrentMode():GetName() == "defendlane" and (#gHeroVar.GetNearbyEnemyCreep(bot, 1500) > 0 or #gHeroVar.GetNearbyEnemies(bot, 1500)) and hBuilding ~= nil and GetUnitToUnitDistance(bot, hBuilding) < 900 then return me:getCurrentModeValue() end return BOT_MODE_DESIRE_NONE end function X:DefendTower(bot, hBuilding) -- TODO: all of this should use the fighting system. local enemies = gHeroVar.GetNearbyEnemies(bot, 1500) local allies = gHeroVar.GetNearbyAllies(bot, 1500) local eCreep = gHeroVar.GetNearbyEnemyCreep(bot, 1200) if #enemies > 0 and #allies >= #enemies then -- we are good to go gHeroVar.HeroAttackUnit(bot, enemies[1], true) -- Charge! at the closes enemy else -- stay back local closestEnemyDist = 10000 if #enemies > 0 then closestEnemyDist = GetUnitToUnitDistance(bot, enemies[1]) if closestEnemyDist < 900 then -- they are too close gHeroVar.HeroMoveToLocation(bot, utils.VectorAway(bot:GetLocation(), enemies[1]:GetLocation(), 950-closestEnemyDist)) return end end if #eCreep > 0 then local weakestCreep, _ = utils.GetWeakestCreep(eCreep) if weakestCreep and GetUnitToUnitDistance(bot, weakestCreep) < closestEnemyDist then gHeroVar.HeroAttackUnit(bot, weakestCreep, true) return end end end end function X:Think(bot) if utils.IsBusy(bot) then return end if utils.IsCrowdControlled(bot) then return end local defInfo = getHeroVar("DoDefendLane") -- TEAM has made the decision. -- TODO: unpack function?? local lane = defInfo[1] local building = defInfo[2] local numEnemies = defInfo[3] local hBuilding = buildings_status.GetHandle(GetTeam(), building) if hBuilding == nil then setHeroVar("DoDefendLane", {}) return end local distFromBuilding = GetUnitToUnitDistance(bot, hBuilding) local timeToReachBuilding = distFromBuilding/bot:GetCurrentMovementSpeed() if timeToReachBuilding <= 5.0 then X:DefendTower(bot, hBuilding) else if utils.IsBusy(bot) then return end local tp = utils.GetTeleportationAbility(bot) if tp == nil then X:DefendTower(bot, hBuilding) else -- calculate position for a defensive teleport -- TODO: consider hiding in trees, position of enemy -- TODO: is there, should there be a utils function for this? local pos = hBuilding:GetLocation() local vec = utils.Fountain(GetTeam()) - pos vec = vec * 575 / #vec -- resize to 575 units (max tp range from tower) pos = pos + vec gHeroVar.HeroUseAbilityOnLocation(bot, tp, pos) end end return end return X
gpl-3.0
jshackley/darkstar
scripts/zones/Cape_Teriggan/npcs/Bright_Moon.lua
17
1865
----------------------------------- -- Area: Cape Teriggan -- NPC: Bright Moon -- Type: Outpost Vendor -- @pos -185 7 -63 113 ----------------------------------- package.loaded["scripts/zones/Cape_Teriggan/TextIDs"] = nil; ----------------------------------- require("scripts/globals/shop"); require("scripts/globals/conquest"); require("scripts/zones/Cape_Teriggan/TextIDs"); local region = VOLLBOW; local csid = 0x7ff4; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local owner = GetRegionOwner(region); local arg1 = getArg1(owner,player); if (owner == player:getNation()) then nation = 1; elseif (arg1 < 1792) then nation = 2; else nation = 0; end player:startEvent(csid,nation,OP_TeleFee(player,region),0,OP_TeleFee(player,region),player:getCP(),0,0,0); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("OPTION: %u",option); player:updateEvent(player:getGil(),OP_TeleFee(player,region),0,OP_TeleFee(player,region),player:getCP()); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("OPTION: %u",option); if (option == 1) then ShowOPVendorShop(player); elseif (option == 2) then if (player:delGil(OP_TeleFee(player,region))) then toHomeNation(player); end elseif (option == 6) then player:delCP(OP_TeleFee(player,region)); toHomeNation(player); end end;
gpl-3.0
Ombridride/minetest-minetestforfun-server
mods/mesecons/mesecons/oldwires.lua
8
1257
minetest.register_node("mesecons:mesecon_off", { drawtype = "raillike", tiles = {"jeija_mesecon_off.png", "jeija_mesecon_curved_off.png", "jeija_mesecon_t_junction_off.png", "jeija_mesecon_crossing_off.png"}, inventory_image = "jeija_mesecon_off.png", wield_image = "jeija_mesecon_off.png", paramtype = "light", is_ground_content = true, walkable = false, selection_box = { type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5}, }, groups = {dig_immediate=2, mesecon=1, mesecon_conductor_craftable=1}, --MFF description="Mesecons", mesecons = {conductor={ state = mesecon.state.off, onstate = "mesecons:mesecon_on" }} }) minetest.register_node("mesecons:mesecon_on", { drawtype = "raillike", tiles = {"jeija_mesecon_on.png", "jeija_mesecon_curved_on.png", "jeija_mesecon_t_junction_on.png", "jeija_mesecon_crossing_on.png"}, paramtype = "light", is_ground_content = true, walkable = false, selection_box = { type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5}, }, groups = {dig_immediate=2, not_in_creaive_inventory=1, mesecon=1}, --MFF drop = "mesecons:mesecon_off 1", light_source = default.LIGHT_MAX-11, mesecons = {conductor={ state = mesecon.state.on, offstate = "mesecons:mesecon_off" }} })
unlicense
Ombridride/minetest-minetestforfun-server
mods/homedecor_modpack/homedecor/books.lua
10
5854
local S = homedecor.gettext local bookcolors = { { "red", "#c00000:150" }, { "green", "#008000:150" }, { "blue", "#4040c0:150" }, { "violet", "#600070:150" }, { "grey", "#202020:150" }, { "brown", "#603010:175" } } local BOOK_FORMNAME = "homedecor:book_form" local player_current_book = { } for c in ipairs(bookcolors) do local color = bookcolors[c][1] local color_d = S(bookcolors[c][1]) local hue = bookcolors[c][2] local function book_dig(pos, node, digger) if minetest.is_protected(pos, digger:get_player_name()) then return end local meta = minetest.get_meta(pos) local data = minetest.serialize({ title = meta:get_string("title") or "", text = meta:get_string("text") or "", owner = meta:get_string("owner") or "", _recover = meta:get_string("_recover") or "", }) local stack = ItemStack({ name = "homedecor:book_"..color, metadata = data, }) stack = digger:get_inventory():add_item("main", stack) if not stack:is_empty() then minetest.item_drop(stack, digger, pos) end minetest.remove_node(pos) end local inv_img = "homedecor_book_inv.png^[colorize:"..hue.."^homedecor_book_trim_inv.png" homedecor.register("book_"..color, { description = S("Writable Book (%s)"):format(color_d), mesh = "homedecor_book.obj", tiles = { "(homedecor_book_cover.png^[colorize:"..hue..")^homedecor_book_cover_trim.png", "homedecor_book_edges.png" }, inventory_image = inv_img, wield_image = inv_img, groups = { snappy=3, oddly_breakable_by_hand=3, book=1 }, walkable = false, stack_max = 1, on_punch = function(pos, node, puncher, pointed_thing) local fdir = node.param2 minetest.swap_node(pos, { name = "homedecor:book_open_"..color, param2 = fdir }) end, on_place = function(itemstack, placer, pointed_thing) local plname = placer:get_player_name() local pos = pointed_thing.under local node = minetest.get_node_or_nil(pos) local def = node and minetest.registered_nodes[node.name] if not def or not def.buildable_to then pos = pointed_thing.above node = minetest.get_node_or_nil(pos) def = node and minetest.registered_nodes[node.name] if not def or not def.buildable_to then return itemstack end end if minetest.is_protected(pos, plname) then return itemstack end local fdir = minetest.dir_to_facedir(placer:get_look_dir()) minetest.set_node(pos, { name = "homedecor:book_"..color, param2 = fdir, }) local text = itemstack:get_metadata() or "" local meta = minetest.get_meta(pos) local data = minetest.deserialize(text) or {} if type(data) ~= "table" then data = {} -- Store raw metadata in case some data is lost by the -- transition to the new meta format, so it is not lost -- and can be recovered if needed. meta:set_string("_recover", text) end meta:set_string("title", data.title or "") meta:set_string("text", data.text or "") meta:set_string("owner", data.owner or "") if data.title and data.title ~= "" then meta:set_string("infotext", data.title) end if not homedecor.expect_infinite_stacks then itemstack:take_item() end return itemstack end, on_dig = book_dig, selection_box = { type = "fixed", fixed = {-0.2, -0.5, -0.25, 0.2, -0.35, 0.25} } }) homedecor.register("book_open_"..color, { mesh = "homedecor_book_open.obj", tiles = { "(homedecor_book_cover.png^[colorize:"..hue..")^homedecor_book_cover_trim.png", "homedecor_book_edges.png", "homedecor_book_pages.png" }, groups = { snappy=3, oddly_breakable_by_hand=3, not_in_creative_inventory=1 }, drop = "homedecor:book_"..color, walkable = false, on_dig = book_dig, on_rightclick = function(pos, node, clicker) local meta = minetest.get_meta(pos) local player_name = clicker:get_player_name() local title = meta:get_string("title") or "" local text = meta:get_string("text") or "" local owner = meta:get_string("owner") or "" local formspec if owner == "" or owner == player_name then formspec = "size[8,8]"..default.gui_bg..default.gui_bg_img.. "field[0.5,1;7.5,0;title;Book title :;".. minetest.formspec_escape(title).."]".. "textarea[0.5,1.5;7.5,7;text;Book content :;".. minetest.formspec_escape(text).."]".. "button_exit[2.5,7.5;3,1;save;Save]" else formspec = "size[8,8]"..default.gui_bg.. "button_exit[7,0.25;1,0.5;close;X]".. default.gui_bg_img.. "label[0.5,0.5;by "..owner.."]".. "label[0.5,0;"..minetest.formspec_escape(title).."]".. "textarea[0.5,1.5;7.5,7;;"..minetest.formspec_escape(text)..";]" end player_current_book[player_name] = pos minetest.show_formspec(player_name, BOOK_FORMNAME, formspec) end, on_punch = function(pos, node, puncher, pointed_thing) local fdir = node.param2 minetest.swap_node(pos, { name = "homedecor:book_"..color, param2 = fdir }) minetest.sound_play("homedecor_book_close", { pos=pos, max_hear_distance = 3, gain = 2, }) end, selection_box = { type = "fixed", fixed = {-0.35, -0.5, -0.25, 0.35, -0.4, 0.25} } }) end minetest.register_on_player_receive_fields(function(player, form_name, fields) if form_name ~= BOOK_FORMNAME or not fields.save then return end local player_name = player:get_player_name() local pos = player_current_book[player_name] if not pos then return end local meta = minetest.get_meta(pos) meta:set_string("title", fields.title or "") meta:set_string("text", fields.text or "") meta:set_string("owner", player_name) if (fields.title or "") ~= "" then meta:set_string("infotext", fields.title) end minetest.log("action", player:get_player_name().." has written in a book (title: \""..fields.title.."\"): \""..fields.text.. "\" at location: "..minetest.pos_to_string(player:getpos())) end)
unlicense
Ombridride/minetest-minetestforfun-server
mods/mobs/sandmonster.lua
7
1825
-- Sand Monster by PilzAdam mobs:register_mob("mobs:sand_monster", { -- animal, monster, npc, barbarian type = "monster", -- aggressive, deals 5 damage to player when hit passive = false, attack_type = "dogfight", pathfinding = false, reach = 2, damage = 2, -- health & armor hp_min = 10, hp_max = 15, armor = 100, -- textures and model collisionbox = {-0.4, -1, -0.4, 0.4, 0.8, 0.4}, visual = "mesh", mesh = "mobs_sand_monster.b3d", textures = { {"mobs_sand_monster.png"}, }, blood_texture = "default_sand.png", -- sounds makes_footstep_sound = true, sounds = { random = "mobs_sandmonster", }, -- speed and jump, sinks in water walk_velocity = 2, run_velocity = 4, view_range = 16, jump = true, floats = 0, -- drops desert sand when dead drops = { {name = "default:desert_sand", chance = 1, min = 3, max = 5,}, {name = "maptools:silver_coin", chance = 10, min = 1, max = 1,}, }, -- damaged by water_damage = 3, lava_damage = 4, light_damage = 0, fear_height = 4, -- model animation animation = { speed_normal = 15, speed_run = 15, stand_start = 0, stand_end = 39, walk_start = 41, walk_end = 72, run_start = 74, run_end = 105, punch_start = 74, punch_end = 105, }, }) -- spawns on desert sand between -1 and 20 light, 1 in 25000 chance, 1 sand monster in area up to 31000 in height mobs:spawn_specific("mobs:sand_monster", {"default:desert_sand", "default:sand"}, {"air"}, -1, 20, 30, 25000, 1, -31000, 31000, false) -- register spawn egg mobs:register_egg("mobs:sand_monster", "Sand Monster", "mobs_sand_monster_inv.png", 1) minetest.register_craft({ output = "mobs:sand_monster", recipe = { {"group:sand", "group:sand", "group:sand"}, {"group:sand", "default:nyancat_rainbow", "group:sand"}, {"group:sand", "group:sand", "group:sand"} } })
unlicense
jshackley/darkstar
scripts/zones/Cloister_of_Storms/bcnms/sugar-coated_directive.lua
19
1711
---------------------------------------- -- Area: Cloister of Storms -- BCNM: Sugar Coated Directive (ASA-4) ---------------------------------------- package.loaded["scripts/zones/Cloister_of_Storms/TextIDs"] = nil; ---------------------------------------- require("scripts/globals/keyitems"); require("scripts/globals/quests"); require("scripts/zones/Cloister_of_Storms/TextIDs"); ---------------------------------------- -- After registering the BCNM via bcnmRegister(bcnmid) function onBcnmRegister(player,instance) end; -- Physically entering the BCNM via bcnmEnter(bcnmid) function onBcnmEnter(player,instance) end; -- Leaving the BCNM by every mean possible, given by the LeaveCode -- 1=Select Exit on circle -- 2=Winning the BC -- 3=Disconnected or warped out -- 4=Losing the BC -- via bcnmLeave(1) or bcnmLeave(2). LeaveCodes 3 and 4 are called -- from the core when a player disconnects or the time limit is up, etc function onBcnmLeave(player,instance,leavecode) -- print("leave code "..leavecode); if (leavecode == 2) then -- play end CS. Need time and battle id for record keeping + storage if (player:hasCompletedMission(ASA,SUGAR_COATED_DIRECTIVE)) then player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,4,1); else player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,4,0); end elseif (leavecode == 4) then player:startEvent(0x7d02); end end; function onEventUpdate(player,csid,option) -- print("bc update csid "..csid.." and option "..option); end; function onEventFinish(player,csid,option) -- print("bc finish csid "..csid.." and option "..option); if (csid == 0x7d01) then player:addExp(400); player:setVar("ASA4_Violet","1"); end end;
gpl-3.0
jshackley/darkstar
scripts/globals/items/dish_of_spaghetti_tonno_rosso_+1.lua
36
1340
----------------------------------------- -- ID: 5624 -- Item: Dish of Spaghetti Tonno Rosso +1 -- Food Effect: 60 Mins, All Races ----------------------------------------- -- Health % 13 -- Health Cap 185 -- Dexterity 2 -- Vitality 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,7200,5624); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_FOOD_HPP, 13); target:addMod(MOD_FOOD_HP_CAP, 185); target:addMod(MOD_DEX, 2); target:addMod(MOD_VIT, 3); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_FOOD_HPP, 13); target:delMod(MOD_FOOD_HP_CAP, 185); target:delMod(MOD_DEX, 2); target:delMod(MOD_VIT, 3); end;
gpl-3.0
jwyang/stnbhwd
demo/demo_mnist.lua
4
2137
-- wget 'http://torch7.s3-website-us-east-1.amazonaws.com/data/mnist.t7.tgz' -- tar -xf mnist.t7.tgz require 'cunn' require 'cudnn' require 'image' require 'optim' paths.dofile('Optim.lua') use_stn = true -- distorted mnist dataset paths.dofile('distort_mnist.lua') datasetTrain, datasetVal = createDatasetsDistorted() -- model model = nn.Sequential() model:add(nn.View(32*32)) model:add(nn.Linear(32*32, 128)) model:add(cudnn.ReLU(true)) model:add(nn.Linear(128, 128)) model:add(cudnn.ReLU(true)) model:add(nn.Linear(128, 10)) model:add(nn.LogSoftMax()) if use_stn then require 'stn' paths.dofile('spatial_transformer.lua') model:insert(spanet,1) end model:cuda() criterion = nn.ClassNLLCriterion():cuda() optimState = {learningRate = 0.01, momentum = 0.9, weightDecay = 5e-4} optimizer = nn.Optim(model, optimState) local w1,w2 for epoch=1,30 do model:training() local trainError = 0 for batchidx = 1, datasetTrain:getNumBatches() do local inputs, labels = datasetTrain:getBatch(batchidx) err = optimizer:optimize(optim.sgd, inputs:cuda(), labels:cuda(), criterion) --print('epoch : ', epoch, 'batch : ', batchidx, 'train error : ', err) trainError = trainError + err end print('epoch : ', epoch, 'trainError : ', trainError / datasetTrain:getNumBatches()) model:evaluate() local valError = 0 local correct = 0 local all = 0 for batchidx = 1, datasetVal:getNumBatches() do local inputs, labels = datasetVal:getBatch(batchidx) local pred = model:forward(inputs:cuda()) valError = valError + criterion:forward(pred, labels:cuda()) _, preds = pred:max(2) correct = correct + preds:eq(labels:cuda()):sum() all = all + preds:size(1) end print('validation error : ', valError / datasetVal:getNumBatches()) print('accuracy % : ', correct / all * 100) print('') if use_stn then w1=image.display({image=spanet.output, nrow=16, legend='STN-transformed inputs, epoch : '..epoch, win=w1}) w2=image.display({image=tranet:get(1).output, nrow=16, legend='Inputs, epoch : '..epoch, win=w2}) end end
mit
josetaas/YokiRaidCursor
Libs/Ace3/AceEvent-3.0/AceEvent-3.0.lua
14
4898
--- AceEvent-3.0 provides event registration and secure dispatching. -- All dispatching is done using **CallbackHandler-1.0**. AceEvent is a simple wrapper around -- CallbackHandler, and dispatches all game events or addon message to the registrees. -- -- **AceEvent-3.0** can be embeded into your addon, either explicitly by calling AceEvent:Embed(MyAddon) or by -- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object -- and can be accessed directly, without having to explicitly call AceEvent itself.\\ -- It is recommended to embed AceEvent, otherwise you'll have to specify a custom `self` on all calls you -- make into AceEvent. -- @class file -- @name AceEvent-3.0 -- @release $Id: AceEvent-3.0.lua 975 2010-10-23 11:26:18Z nevcairiel $ local MAJOR, MINOR = "AceEvent-3.0", 3 local AceEvent = LibStub:NewLibrary(MAJOR, MINOR) if not AceEvent then return end -- Lua APIs local pairs = pairs local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0") AceEvent.frame = AceEvent.frame or CreateFrame("Frame", "AceEvent30Frame") -- our event frame AceEvent.embeds = AceEvent.embeds or {} -- what objects embed this lib -- APIs and registry for blizzard events, using CallbackHandler lib if not AceEvent.events then AceEvent.events = CallbackHandler:New(AceEvent, "RegisterEvent", "UnregisterEvent", "UnregisterAllEvents") end function AceEvent.events:OnUsed(target, eventname) AceEvent.frame:RegisterEvent(eventname) end function AceEvent.events:OnUnused(target, eventname) AceEvent.frame:UnregisterEvent(eventname) end -- APIs and registry for IPC messages, using CallbackHandler lib if not AceEvent.messages then AceEvent.messages = CallbackHandler:New(AceEvent, "RegisterMessage", "UnregisterMessage", "UnregisterAllMessages" ) AceEvent.SendMessage = AceEvent.messages.Fire end --- embedding and embed handling local mixins = { "RegisterEvent", "UnregisterEvent", "RegisterMessage", "UnregisterMessage", "SendMessage", "UnregisterAllEvents", "UnregisterAllMessages", } --- Register for a Blizzard Event. -- The callback will be called with the optional `arg` as the first argument (if supplied), and the event name as the second (or first, if no arg was supplied) -- Any arguments to the event will be passed on after that. -- @name AceEvent:RegisterEvent -- @class function -- @paramsig event[, callback [, arg]] -- @param event The event to register for -- @param callback The callback function to call when the event is triggered (funcref or method, defaults to a method with the event name) -- @param arg An optional argument to pass to the callback function --- Unregister an event. -- @name AceEvent:UnregisterEvent -- @class function -- @paramsig event -- @param event The event to unregister --- Register for a custom AceEvent-internal message. -- The callback will be called with the optional `arg` as the first argument (if supplied), and the event name as the second (or first, if no arg was supplied) -- Any arguments to the event will be passed on after that. -- @name AceEvent:RegisterMessage -- @class function -- @paramsig message[, callback [, arg]] -- @param message The message to register for -- @param callback The callback function to call when the message is triggered (funcref or method, defaults to a method with the event name) -- @param arg An optional argument to pass to the callback function --- Unregister a message -- @name AceEvent:UnregisterMessage -- @class function -- @paramsig message -- @param message The message to unregister --- Send a message over the AceEvent-3.0 internal message system to other addons registered for this message. -- @name AceEvent:SendMessage -- @class function -- @paramsig message, ... -- @param message The message to send -- @param ... Any arguments to the message -- Embeds AceEvent into the target object making the functions from the mixins list available on target:.. -- @param target target object to embed AceEvent in function AceEvent:Embed(target) for k, v in pairs(mixins) do target[v] = self[v] end self.embeds[target] = true return target end -- AceEvent:OnEmbedDisable( target ) -- target (object) - target object that is being disabled -- -- Unregister all events messages etc when the target disables. -- this method should be called by the target manually or by an addon framework function AceEvent:OnEmbedDisable(target) target:UnregisterAllEvents() target:UnregisterAllMessages() end -- Script to fire blizzard events into the event listeners local events = AceEvent.events AceEvent.frame:SetScript("OnEvent", function(this, event, ...) events:Fire(event, ...) end) --- Finally: upgrade our old embeds for target, v in pairs(AceEvent.embeds) do AceEvent:Embed(target) end
mit
jshackley/darkstar
scripts/globals/items/serving_of_bavarois_+1.lua
36
1169
----------------------------------------- -- ID: 5730 -- Item: Serving of Bavarois +1 -- Food Effect: 4 Hrs, All Races ----------------------------------------- -- HP 25 -- Intelligence 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,5730); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_HP, 25); target:addMod(MOD_INT, 4); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_HP, 25); target:delMod(MOD_INT, 4); end;
gpl-3.0
jshackley/darkstar
scripts/zones/Kazham/npcs/Popopp.lua
15
3438
----------------------------------- -- Area: Kazham -- NPC: Popopp -- Standard Info NPC ----------------------------------- package.loaded["scripts/zones/Kazham/TextIDs"] = nil; require("scripts/zones/Kazham/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- -- item IDs -- 483 Broken Mithran Fishing Rod -- 22 Workbench -- 1008 Ten of Coins -- 1157 Sands of Silence -- 1158 Wandering Bulb -- 904 Giant Fish Bones -- 4599 Blackened Toad -- 905 Wyvern Skull -- 1147 Ancient Salt -- 4600 Lucky Egg function onTrade(player,npc,trade) local OpoOpoAndIStatus = player:getQuestStatus(OUTLANDS, THE_OPO_OPO_AND_I); local progress = player:getVar("OPO_OPO_PROGRESS"); local failed = player:getVar("OPO_OPO_FAILED"); local goodtrade = trade:hasItemQty(1158,1); local badtrade = (trade:hasItemQty(483,1) or trade:hasItemQty(22,1) or trade:hasItemQty(1008,1) or trade:hasItemQty(1157,1) or trade:hasItemQty(904,1) or trade:hasItemQty(4599,1) or trade:hasItemQty(905,1) or trade:hasItemQty(1147,1) or trade:hasItemQty(4600,1)); if (OpoOpoAndIStatus == QUEST_ACCEPTED) then if progress == 4 or failed == 5 then if goodtrade then player:startEvent(0x00DF); elseif badtrade then player:startEvent(0x00E9); end end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local OpoOpoAndIStatus = player:getQuestStatus(OUTLANDS, THE_OPO_OPO_AND_I); local progress = player:getVar("OPO_OPO_PROGRESS"); local failed = player:getVar("OPO_OPO_FAILED"); local retry = player:getVar("OPO_OPO_RETRY"); if (OpoOpoAndIStatus == QUEST_ACCEPTED) then if retry >= 1 then -- has failed on future npc so disregard previous successful trade player:startEvent(0x00C9); elseif (progress == 4 or failed == 5) then player:startEvent(0x00D2); -- asking for wandering bulb elseif (progress >= 5 or failed >= 6) then player:startEvent(0x00F6); -- happy with wandering bulb end else player:startEvent(0x00C9); 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 == 0x00DF) then -- correct trade, onto next opo if player:getVar("OPO_OPO_PROGRESS") == 4 then player:tradeComplete(); player:setVar("OPO_OPO_PROGRESS",5); player:setVar("OPO_OPO_FAILED",0); else player:setVar("OPO_OPO_FAILED",6); end elseif (csid == 0x00E9) then -- wrong trade, restart at first opo player:setVar("OPO_OPO_FAILED",1); player:setVar("OPO_OPO_RETRY",5); end end;
gpl-3.0
jshackley/darkstar
scripts/globals/items/galkan_sausage.lua
35
2059
----------------------------------------- -- ID: 4395 -- Item: galkan_sausage -- Food Effect: 30Min, All Races ----------------------------------------- -- Multi-Race Effects -- Galka -- Strength 3 -- Intelligence -3 -- Attack % 25 -- Attack Cap 30 -- Ranged ATT % 25 -- Ranged ATT Cap 30 -- -- Other -- Strength 3 -- Intelligence -4 -- Attack 9 -- Ranged ATT 9 ----------------------------------------- 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,4395); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) if (target:getRace() ~= 8) then target:addMod(MOD_STR, 3); target:addMod(MOD_INT, -4); target:addMod(MOD_ATT, 9); target:addMod(MOD_RATT, 9); else target:addMod(MOD_STR, 3); target:addMod(MOD_INT, -1); target:addMod(MOD_FOOD_ATTP, 25); target:addMod(MOD_FOOD_ATT_CAP, 30); target:addMod(MOD_FOOD_RATTP, 25); target:addMod(MOD_FOOD_RATT_CAP, 30); end end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) if (target:getRace() ~= 8) then target:addMod(MOD_STR, 3); target:addMod(MOD_INT, -4); target:addMod(MOD_ATT, 9); target:addMod(MOD_RATT, 9); else target:delMod(MOD_STR, 3); target:delMod(MOD_INT, -1); target:delMod(MOD_FOOD_ATTP, 25); target:delMod(MOD_FOOD_ATT_CAP, 30); target:delMod(MOD_FOOD_RATTP, 25); target:delMod(MOD_FOOD_RATT_CAP, 30); end end;
gpl-3.0
jshackley/darkstar
scripts/globals/spells/poison_iii.lua
18
1094
----------------------------------------- -- Spell: Poison ----------------------------------------- require("scripts/globals/status"); require("scripts/globals/magic"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) local effect = EFFECT_POISON; local duration = 180; local pINT = caster:getStat(MOD_INT); local mINT = target:getStat(MOD_INT); local dINT = (pINT - mINT); local power = caster:getSkillLevel(ENFEEBLING_MAGIC_SKILL) / 15 + 1; if power > 25 then power = 25; end local resist = applyResistanceEffect(caster,spell,target,dINT,ENFEEBLING_MAGIC_SKILL,0,effect); if (resist == 1 or resist == 0.5) then -- effect taken duration = duration * resist; if (target:addStatusEffect(effect,power,3,duration)) then spell:setMsg(236); else spell:setMsg(75); end else -- resist entirely. spell:setMsg(85); end return effect; end;
gpl-3.0
Ombridride/minetest-minetestforfun-server
mods/coloredwood/init.lua
9
2973
-- Colored Wood mod by Vanessa Ezekowitz -- based on my unifieddyes template. -- -- License: WTFPL -- -- This mod provides 89 colors of wood, fences, and sticks, and enough -- cross-compatible recipes to make everything fit together naturally. -- -- Colored wood is crafted by putting two regular wood blocks into the -- grid along with one dye color, in any order and position. The result -- is two colored wood blocks. -- -- Colored sticks are crafted from colored wood blocks only - one colored -- wood block in any position yields 4 colored sticks as usual. -- -- Uncolored sticks cannot be dyed separately, but they can still be used -- to build colored wooden fences. These are crafted either by placing six -- plain, uncolored sticks into the crafting grid in the usual manner, plus -- one portion of dye in the upper-left corner of the grid -- (D = dye, S = uncolored stick): -- -- D - - -- S S S -- S S S -- -- You can also craft a colored fence by using colored sticks derived from -- colored wood. Just place six of them in the same manner as with plain -- fences (CS = colored stick): -- -- -- -- -- -- CS CS CS -- CS CS CS -- -- If you find yourself with too many colors of sticks and not enough, -- ladders, you can use any color (as long as they"re all the same) to -- create a ladder, but it"ll always result in a plain, uncolored ladder. -- This practice isn"t recommended of course, since it wastes dye. -- -- All materials are flammable and can be used as fuel. -- Hues are on a 30 degree spacing starting at red = 0 degrees. -- "s50" in a file/item name means "saturation: 50%". -- Texture brightness levels for the colors are 100%, 66% ("medium"), -- and 33% ("dark"). coloredwood = {} coloredwood.shades = { "dark_", "medium_", "" -- represents "no special shade name", e.g. full. } coloredwood.shades2 = { "Dark ", "Medium ", "" -- represents "no special shade name", e.g. full. } coloredwood.default_hues = { "white", "grey", "dark_grey", "black", "violet", "blue", "cyan", "dark_green", "green", "yellow", "orange", "red", "magenta" } coloredwood.hues = { "red", "orange", "yellow", "lime", "green", "aqua", "cyan", "skyblue", "blue", "violet", "magenta", "redviolet" } coloredwood.hues2 = { "Red ", "Orange ", "Yellow ", "Lime ", "Green ", "Aqua ", "Cyan ", "Sky Blue ", "Blue ", "Violet ", "Magenta ", "Red-violet " } coloredwood.greys = { "black", "darkgrey", "grey", "lightgrey", "white" } coloredwood.greys2 = { "Black ", "Dark Grey ", "Medium Grey ", "Light Grey ", "White " } coloredwood.greys3 = { "dye:black", "dye:dark_grey", "dye:grey", "dye:light_grey", "dye:white" } -- All of the actual code is contained in separate lua files: dofile(minetest.get_modpath("coloredwood").."/wood.lua") dofile(minetest.get_modpath("coloredwood").."/fence.lua") dofile(minetest.get_modpath("coloredwood").."/stick.lua") minetest.log("action", "[Colored Wood] Loaded!")
unlicense
sugiartocokrowibowo/Algorithm-Implementations
Gauss_Seidel_Algorithm/Lua/Yonaba/gauss_seidel.lua
26
1261
-- Gauss Seidel algorithm implementation -- See : http://en.wikipedia.org/wiki/Gauss%E2%80%93Seidel_method -- Creates a vector of values local function vector(len, v) local x = {} for i = 1, len do x[i] = v end return x end -- Computes the norm of a given vector local function norm(v) local n = 0 for i, _v in ipairs(v) do n = n + (_v * _v) end return math.sqrt(n) end -- Solves the given matrix using Gauss-Seidel algorithm -- m : a matrix A in [A][x] = [b] -- b : the result vector in [A][x] = [b] -- w : the relaxation parameter, defaults to 1.86 -- eps : the convergence criterion, defaults to 1e-6 -- maxiter : the maximum number of iterations, defaults to 1e4 -- return : a solution vector local function gauss_seidel(m, b, w, eps, maxiter) local n = #m local x = vector(n, 0) local q, p, sum local t = 0 w = w or 1.86 eps = eps or 1e-6 maxiter = maxiter or 1e4 repeat t = t + 1 q = norm(x) for i = 1, n do sum = 0 for j = 1, n do if (i ~= j) then sum = sum + m[i][j] * x[j] end end x[i] = (1 / m[i][i]) * (b[i] - sum) end p = norm(x) until (math.abs(p - q) < eps) or (t >= maxiter) return x end return gauss_seidel
mit
jshackley/darkstar
scripts/zones/Mount_Zhayolm/npcs/Waudeen.lua
17
2070
----------------------------------- -- Area: Mount_Zhayolm -- NPC: Waudeen -- Type: Assault -- @pos 673.882 -23.995 367.604 61 ----------------------------------- package.loaded["scripts/zones/Mount_Zhayolm/TextIDs"] = nil; ----------------------------------- require("scripts/globals/missions"); require("scripts/globals/keyitems"); require("scripts/zones/Mount_Zhayolm/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local IPpoint = player:getCurrency("imperial_standing"); if (player:getCurrentMission(TOAU) == IMMORTAL_SENTRIES) then if (player:hasKeyItem(SUPPLIES_PACKAGE)) then player:startEvent(0x0004); elseif (player:getVar("TOAUM2") == 1) then player:startEvent(0x0005); end elseif (player:getCurrentMission(TOAU) >= PRESIDENT_SALAHEEM) then if (player:hasKeyItem(LEBROS_ASSAULT_ORDERS) and player:hasKeyItem(ASSAULT_ARMBAND) == false) then player:startEvent(0x00d1,50,IPpoint); else player:startEvent(0x0006); -- player:delKeyItem(ASSAULT_ARMBAND); end else player:startEvent(0x0003); 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 == 0x00d1 and option == 1) then player:delCurrency("imperial_standing", 50); player:addKeyItem(ASSAULT_ARMBAND); player:messageSpecial(KEYITEM_OBTAINED,ASSAULT_ARMBAND); elseif (csid == 0x0004 and option == 1) then player:delKeyItem(SUPPLIES_PACKAGE); player:setVar("TOAUM2",1); end end;
gpl-3.0
Shrike78/Shilke2D
Shilke2D/Display/Stage.lua
1
5307
--[[--- Stage is a particular DisplayObjContainer, root node of the displayList tree. It's initialized by Shilke2D and only object connected to it are rendered. A stage cannot be geometrically transformed or moved, so all the related method are override and raise errors if called. --]] Stage = class(DisplayObjContainer) --[[--- Called from Shilke2D, it sets the viewport for the scene, the renderTable and initializes the 'debug' drawCallback used to show bounding boxes of objects in the displayList @param viewport the viewport of the scene --]] function Stage:init(viewport) DisplayObjContainer.init(self) self._prop:setViewport(viewport) self._debugDeck = MOAIScriptDeck.new () self._debugDeck:setDrawCallback ( function() if self._showAABounds then self:drawAABounds(false) end if self._showOrientedBounds then self:drawOrientedBounds() end end ) self._debugProp = MOAIProp.new () self._debugProp:setDeck ( self._debugDeck ) self._bkgColor = {0,0,0,1} self._rt = {self._renderTable} end ---Stage prop is a MOAILayer, not a generic MOAIProp like all the others displayObjs function Stage:_createProp() return MOAILayer.new() end ---Debug function. Used to show bounding box while rendering. --@tparam[opt=true] bool showOrientedBounds --@tparam[opt=false] bool showAABounds boolean function Stage:showDebugLines(showOrientedBounds,showAABounds) self._showOrientedBounds = showOrientedBounds ~= false self._showAABounds = showAABounds == true local showDebug = self._showOrientedBounds or self._showAABounds if showDebug and not self._rt[2] then self._rt[2] = self._debugProp end if not showDebug and self._rt[2] then self._rt[2] = nil end end --[[--- Inner method. With moai 1.4 clearColor function has been moved to frameBuffer and removed from GfxDevice. The call checks which method is available and make the proper moai call. @tparam number r (0,1) @tparam number g (0,1) @tparam number b (0,1) @tparam number a (0,1) --]] local function __setClearColor(r,g,b,a) if MOAIGfxDevice.getFrameBuffer then MOAIGfxDevice.getFrameBuffer():setClearColor(r,g,b,a) else MOAIGfxDevice.setClearColor(r,g,b,a) end end --[[--- Set background color. @param r (0,255) value or Color object or hex string or int32 color @param g (0,255) value or nil @param b (0,255) value or nil @param a[opt=nil] (0,255) value or nil --]] function Stage:setBackgroundColor(r,g,b,a) local r,g,b,a = Color._toNormalizedRGBA(r,g,b,a) local c = self._bkgColor c[1],c[2],c[3],c[4] = r,g,b,a __setClearColor(r,g,b,a) end --[[--- Get background color. @treturn Color --]] function Stage:getBackgroundColor() return Color.fromNormalizedValues(unpack(self._bkgColor)) end ---Raise error if called because stage cannot be added as child to other containers function Stage:_setParent(parent) error("Stage cannot be child of another DisplayObjContainer") end ---Raise error if called because stage cannot be geometrically trasnformed function Stage:setPivot(x,y) error("It's not possible to set geometric properties of a Stage") end ---Raise error if called because stage cannot be geometrically trasnformed function Stage:setPivotX(x) error("It's not possible to set geometric properties of a Stage") end ---Raise error if called because stage cannot be geometrically trasnformed function Stage:setPivotY(y) error("It's not possible to set geometric properties of a Stage") end ---Raise error if called because stage cannot be geometrically trasnformed function Stage:setPosition(x,y) error("It's not possible to set geometric properties of a Stage") end ---Raise error if called because stage cannot be geometrically trasnformed function Stage:setPositionX(x) error("It's not possible to set geometric properties of a Stage") end ---Raise error if called because stage cannot be geometrically trasnformed function Stage:setPositionY(y) error("It's not possible to set geometric properties of a Stage") end ---Raise error if called because stage cannot be geometrically trasnformed function Stage:translate(x,y) error("It's not possible to set geometric properties of a Stage") end ---Raise error if called because stage cannot be geometrically trasnformed function Stage:setRotation(r) error("It's not possible to set geometric properties of a Stage") end ---Raise error if called because stage cannot be geometrically trasnformed function Stage:setScale(x,y) error("It's not possible to set geometric properties of a Stage") end ---Raise error if called because stage cannot be geometrically trasnformed function Stage:setScaleX(s) error("It's not possible to set geometric properties of a Stage") end ---Raise error if called because stage cannot be geometrically trasnformed function Stage:setScaleY(s) error("It's not possible to set geometric properties of a Stage") end ---Raise error if called because stage cannot be geometrically trasnformed function Stage:setGlobalPosition(x,y,targetSpace) error("It's not possible to set geometric properties of a Stage") end ---Raise error if called because stage cannot be geometrically trasnformed function Stage:globalTranslate(dx,dy,targetSpace) error("It's not possible to set geometric properties of a Stage") end
mit
jshackley/darkstar
scripts/zones/Northern_San_dOria/npcs/Esqualea.lua
36
1427
----------------------------------- -- Area: Northern San d'Oria -- NPC: Esqualea -- Standard Info NPC ----------------------------------- package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/quests"); require("scripts/zones/Northern_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- "Flyers for Regine" conditional script FlyerForRegine = player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE); if (FlyerForRegine == 1) then count = trade:getItemCount(); MagicFlyer = trade:hasItemQty(532,1); if (MagicFlyer == true and count == 1) then player:messageSpecial(FLYER_REFUSED); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:startEvent(0x029e); 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
10sa/Advanced-Nutscript
nutscript/gamemode/libs/external/sh_netstream2.lua
1
3720
--[[ NetStream - 2.0.0 Alexander Grist-Hucker http://www.revotech.org Credits to: thelastpenguin for pON. https://github.com/thelastpenguin/gLUA-Library/tree/master/pON --]] local type, error, pcall, pairs, _player = type, error, pcall, pairs, player; if (!pon) then nut.util.Include("sh_pon.lua"); end; AddCSLuaFile(); netstream = netstream or {}; netstream.stored = netstream.stored or {}; -- A function to split data for a data stream. function netstream.Split(data) local index = 1; local result = {}; local buffer = {}; for i = 0, string.len(data) do buffer[#buffer + 1] = string.sub(data, i, i); if (#buffer == 32768) then result[#result + 1] = table.concat(buffer); index = index + 1; buffer = {}; end; end; result[#result + 1] = table.concat(buffer); return result; end; -- A function to hook a data stream. function netstream.Hook(name, Callback) netstream.stored[name] = Callback; end; if (SERVER) then util.AddNetworkString("NetStreamDS"); -- A function to start a net stream. function netstream.Start(player, name, ...) local recipients = {}; local bShouldSend = false; if (type(player) != "table") then if (!player) then player = _player.GetAll(); else player = {player}; end; end; for k, v in pairs(player) do if (type(v) == "Player") then recipients[#recipients + 1] = v; bShouldSend = true; elseif (type(k) == "Player") then recipients[#recipients + 1] = k; bShouldSend = true; end; end; local dataTable = {...}; local encodedData = pon.encode(dataTable); if (encodedData and #encodedData > 0 and bShouldSend) then net.Start("NetStreamDS"); net.WriteString(name); net.WriteUInt(#encodedData, 32); net.WriteData(encodedData, #encodedData); net.Send(recipients); end; end; net.Receive("NetStreamDS", function(length, player) local NS_DS_NAME = net.ReadString(); local NS_DS_LENGTH = net.ReadUInt(32); local NS_DS_DATA = net.ReadData(NS_DS_LENGTH); if (NS_DS_NAME and NS_DS_DATA and NS_DS_LENGTH) then player.nsDataStreamName = NS_DS_NAME; player.nsDataStreamData = ""; if (player.nsDataStreamName and player.nsDataStreamData) then player.nsDataStreamData = NS_DS_DATA; if (netstream.stored[player.nsDataStreamName]) then local bStatus, value = pcall(pon.decode, player.nsDataStreamData); if (bStatus) then netstream.stored[player.nsDataStreamName](player, unpack(value)); else ErrorNoHalt("NetStream: '"..NS_DS_NAME.."'\n"..value.."\n"); end; end; player.nsDataStreamName = nil; player.nsDataStreamData = nil; end; end; NS_DS_NAME, NS_DS_DATA, NS_DS_LENGTH = nil, nil, nil; end); else -- A function to start a net stream. function netstream.Start(name, ...) local dataTable = {...}; local encodedData = pon.encode(dataTable); if (encodedData and #encodedData > 0) then net.Start("NetStreamDS"); net.WriteString(name); net.WriteUInt(#encodedData, 32); net.WriteData(encodedData, #encodedData); net.SendToServer(); end; end; net.Receive("NetStreamDS", function(length) local NS_DS_NAME = net.ReadString(); local NS_DS_LENGTH = net.ReadUInt(32); local NS_DS_DATA = net.ReadData(NS_DS_LENGTH); if (NS_DS_NAME and NS_DS_DATA and NS_DS_LENGTH) then if (netstream.stored[NS_DS_NAME]) then local bStatus, value = pcall(pon.decode, NS_DS_DATA); if (bStatus) then netstream.stored[NS_DS_NAME](unpack(value)); else ErrorNoHalt("NetStream: '"..NS_DS_NAME.."'\n"..value.."\n"); end; end; end; NS_DS_NAME, NS_DS_DATA, NS_DS_LENGTH = nil, nil, nil; end); end;
mit
Victek/wrt1900ac-aa
veriksystems/luci-0.11/applications/luci-statistics/luasrc/model/cbi/luci_statistics/network.lua
11
3046
--[[ Luci configuration model for statistics - collectd network plugin configuration (c) 2008 Freifunk Leipzig / 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: network.lua 6060 2010-04-13 20:42:26Z jow $ ]]-- m = Map("luci_statistics", translate("Network Plugin Configuration"), translate( "The network plugin provides network based communication between " .. "different collectd instances. Collectd can operate both in client " .. "and server mode. In client mode locally collected date is " .. "transferred to a collectd server instance, in server mode the " .. "local instance receives data from other hosts." )) -- collectd_network config section s = m:section( NamedSection, "collectd_network", "luci_statistics" ) -- collectd_network.enable enable = s:option( Flag, "enable", translate("Enable this plugin") ) enable.default = 0 -- collectd_network_listen config section (Listen) listen = m:section( TypedSection, "collectd_network_listen", translate("Listener interfaces"), translate( "This section defines on which interfaces collectd will wait " .. "for incoming connections." )) listen.addremove = true listen.anonymous = true -- collectd_network_listen.host listen_host = listen:option( Value, "host", translate("Listen host") ) listen_host.default = "0.0.0.0" -- collectd_network_listen.port listen_port = listen:option( Value, "port", translate("Listen port") ) listen_port.default = 25826 listen_port.isinteger = true listen_port.optional = true -- collectd_network_server config section (Server) server = m:section( TypedSection, "collectd_network_server", translate("server interfaces"), translate( "This section defines to which servers the locally collected " .. "data is sent to." )) server.addremove = true server.anonymous = true -- collectd_network_server.host server_host = server:option( Value, "host", translate("Server host") ) server_host.default = "0.0.0.0" -- collectd_network_server.port server_port = server:option( Value, "port", translate("Server port") ) server_port.default = 25826 server_port.isinteger = true server_port.optional = true -- collectd_network.timetolive (TimeToLive) ttl = s:option( Value, "TimeToLive", translate("TTL for network packets") ) ttl.default = 128 ttl.isinteger = true ttl.optional = true ttl:depends( "enable", 1 ) -- collectd_network.forward (Forward) forward = s:option( Flag, "Forward", translate("Forwarding between listen and server addresses") ) forward.default = 0 forward.optional = true forward:depends( "enable", 1 ) -- collectd_network.cacheflush (CacheFlush) cacheflush = s:option( Value, "CacheFlush", translate("Cache flush interval"), translate("Seconds") ) cacheflush.default = 86400 cacheflush.isinteger = true cacheflush.optional = true cacheflush:depends( "enable", 1 ) return m
gpl-2.0
jshackley/darkstar
scripts/globals/weaponskills/requiescat.lua
30
1321
----------------------------------- -- Requiescat -- Sword weapon skill -- Skill level: MERIT -- Delivers a five-hit attack. Attack power varies with TP. -- Element: None -- Modifiers: MND:73~85% -- 100%TP 200%TP 300%TP -- ALL 1.0 ----------------------------------- require("scripts/globals/status"); require("scripts/globals/settings"); require("scripts/globals/weaponskills"); ----------------------------------- function onUseWeaponSkill(player, target, wsID) local params = {}; params.numHits = 5; params.ftp100 = 1; params.ftp200 = 1; params.ftp300 = 1; 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.85 + (player:getMerit(MERIT_REQUIESCAT) / 100); params.chr_wsc = 0.0; params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0; params.canCrit = false; params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0; params.atkmulti = 0.7 + player:getTP()/1000; if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then params.mnd_wsc = 0.7 + (player:getMerit(MERIT_REQUIESCAT) / 100); end local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, params); damage = damage * WEAPON_SKILL_POWER return tpHits, extraHits, criticalHit, damage; end
gpl-3.0
jshackley/darkstar
scripts/zones/Port_Bastok/npcs/Latifah.lua
34
1288
----------------------------------- -- Area: Port Bastok -- NPC: Latifah -- Involved in Quest: Stamp Hunt ----------------------------------- require("scripts/globals/quests"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local StampHunt = player:getQuestStatus(BASTOK,STAMP_HUNT); if (StampHunt == QUEST_ACCEPTED and player:getMaskBit(player:getVar("StampHunt_Mask"),6) == false) then player:startEvent(0x0078); else player:startEvent(0x000d); 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 == 0x0078) then player:setMaskBit(player:getVar("StampHunt_Mask"),"StampHunt_Mask",6,true); end end;
gpl-3.0
elbamos/nn
Euclidean.lua
19
5750
local Euclidean, parent = torch.class('nn.Euclidean', 'nn.Module') function Euclidean:__init(inputSize,outputSize) parent.__init(self) self.weight = torch.Tensor(inputSize,outputSize) self.gradWeight = torch.Tensor(inputSize,outputSize) -- state self.gradInput:resize(inputSize) self.output:resize(outputSize) self.fastBackward = true self:reset() end function Euclidean:reset(stdv) if stdv then stdv = stdv * math.sqrt(3) else stdv = 1./math.sqrt(self.weight:size(1)) end if nn.oldSeed then for i=1,self.weight:size(2) do self.weight:select(2, i):apply(function() return torch.uniform(-stdv, stdv) end) end else self.weight:uniform(-stdv, stdv) end end local function view(res, src, ...) local args = {...} if src:isContiguous() then res:view(src, table.unpack(args)) else res:reshape(src, table.unpack(args)) end end function Euclidean:updateOutput(input) -- lazy initialize buffers self._input = self._input or input.new() self._weight = self._weight or self.weight.new() self._expand = self._expand or self.output.new() self._expand2 = self._expand2 or self.output.new() self._repeat = self._repeat or self.output.new() self._repeat2 = self._repeat2 or self.output.new() local inputSize, outputSize = self.weight:size(1), self.weight:size(2) -- y_j = || w_j - x || = || x - w_j || if input:dim() == 1 then view(self._input, input, inputSize, 1) self._expand:expandAs(self._input, self.weight) self._repeat:resizeAs(self._expand):copy(self._expand) self._repeat:add(-1, self.weight) self.output:norm(self._repeat, 2, 1) self.output:resize(outputSize) elseif input:dim() == 2 then local batchSize = input:size(1) view(self._input, input, batchSize, inputSize, 1) self._expand:expand(self._input, batchSize, inputSize, outputSize) -- make the expanded tensor contiguous (requires lots of memory) self._repeat:resizeAs(self._expand):copy(self._expand) self._weight:view(self.weight, 1, inputSize, outputSize) self._expand2:expandAs(self._weight, self._repeat) if torch.type(input) == 'torch.CudaTensor' then -- requires lots of memory, but minimizes cudaMallocs and loops self._repeat2:resizeAs(self._expand2):copy(self._expand2) self._repeat:add(-1, self._repeat2) else self._repeat:add(-1, self._expand2) end self.output:norm(self._repeat, 2, 2) self.output:resize(batchSize, outputSize) else error"1D or 2D input expected" end return self.output end function Euclidean:updateGradInput(input, gradOutput) if not self.gradInput then return end self._div = self._div or input.new() self._output = self._output or self.output.new() self._gradOutput = self._gradOutput or input.new() self._expand3 = self._expand3 or input.new() if not self.fastBackward then self:updateOutput(input) end local inputSize, outputSize = self.weight:size(1), self.weight:size(2) --[[ dy_j -2 * (w_j - x) x - w_j ---- = --------------- = ------- dx 2 || w_j - x || y_j --]] -- to prevent div by zero (NaN) bugs self._output:resizeAs(self.output):copy(self.output):add(0.0000001) view(self._gradOutput, gradOutput, gradOutput:size()) self._div:cdiv(gradOutput, self._output) if input:dim() == 1 then self._div:resize(1, outputSize) self._expand3:expandAs(self._div, self.weight) if torch.type(input) == 'torch.CudaTensor' then self._repeat2:resizeAs(self._expand3):copy(self._expand3) self._repeat2:cmul(self._repeat) else self._repeat2:cmul(self._repeat, self._expand3) end self.gradInput:sum(self._repeat2, 2) self.gradInput:resizeAs(input) elseif input:dim() == 2 then local batchSize = input:size(1) self._div:resize(batchSize, 1, outputSize) self._expand3:expand(self._div, batchSize, inputSize, outputSize) if torch.type(input) == 'torch.CudaTensor' then self._repeat2:resizeAs(self._expand3):copy(self._expand3) self._repeat2:cmul(self._repeat) else self._repeat2:cmul(self._repeat, self._expand3) end self.gradInput:sum(self._repeat2, 3) self.gradInput:resizeAs(input) else error"1D or 2D input expected" end return self.gradInput end function Euclidean:accGradParameters(input, gradOutput, scale) local inputSize, outputSize = self.weight:size(1), self.weight:size(2) scale = scale or 1 --[[ dy_j 2 * (w_j - x) w_j - x ---- = --------------- = ------- dw_j 2 || w_j - x || y_j --]] -- assumes a preceding call to updateGradInput if input:dim() == 1 then self.gradWeight:add(-scale, self._repeat2) elseif input:dim() == 2 then self._sum = self._sum or input.new() self._sum:sum(self._repeat2, 1) self._sum:resize(inputSize, outputSize) self.gradWeight:add(-scale, self._sum) else error"1D or 2D input expected" end end function Euclidean:type(type, tensorCache) if type then -- prevent premature memory allocations self:clearState() end return parent.type(self, type, tensorCache) end function Euclidean:clearState() nn.utils.clear(self, { '_input', '_output', '_gradOutput', '_weight', '_div', '_sum', '_expand', '_expand2', '_expand3', '_repeat', '_repeat2', }) return parent.clearState(self) end
bsd-3-clause
LiberatorUSA/GUCEF
dependencies/MyGui/Platforms/Ogre/OgrePlatform/premake4.lua
1
3545
-------------------------------------------------------------------- -- This file was automatically generated by ProjectGenerator -- which is tooling part the build system designed for GUCEF -- (Galaxy Unlimited Framework) -- For the latest info, see http://www.VanvelzenSoftware.com/ -- -- The contents of this file are placed in the public domain. Feel -- free to make use of it in any way you like. -------------------------------------------------------------------- -- -- Configuration for module: MyGUI.OgrePlatform configuration( { "LINUX" } ) project( "MyGUI.OgrePlatform" ) configuration( { "WIN32" } ) project( "MyGUI.OgrePlatform" ) configuration( {} ) location( os.getenv( "PM4OUTPUTDIR" ) ) configuration( {} ) targetdir( os.getenv( "PM4TARGETDIR" ) ) configuration( {} ) language( "C" ) configuration( { "LINUX" } ) language( "C++" ) configuration( { "WIN32" } ) language( "C++" ) configuration( { "LINUX" } ) configuration( { LINUX } ) kind( "SharedLib" ) configuration( { "WIN32" } ) configuration( { WIN32 } ) kind( "SharedLib" ) configuration( { LINUX } ) links( { "MyGUI.Engine", "OgreMain" } ) links( { "MyGUI.Engine", "OgreMain" } ) configuration( { WIN32 } ) links( { "MyGUI.Engine", "OgreMain" } ) links( { "MyGUI.Engine", "OgreMain" } ) configuration( { "LINUX" } ) vpaths { ["Platform Headers"] = { "**.h", "**.hpp", "**.hxx" } } files( { "../../../Common/FileSystemInfo/FileSystemInfo.h", "include/MyGUI_LastHeader.h", "include/MyGUI_OgreDataManager.h", "include/MyGUI_OgreDataStream.h", "include/MyGUI_OgreDiagnostic.h", "include/MyGUI_OgrePlatform.h", "include/MyGUI_OgreRenderManager.h", "include/MyGUI_OgreRTTexture.h", "include/MyGUI_OgreTexture.h", "include/MyGUI_OgreVertexBuffer.h" } ) vpaths { ["Platform Source"] = { "**.c", "**.cpp", "**.cs", "**.asm" } } files( { "src/MyGUI_OgreDataManager.cpp", "src/MyGUI_OgreDataStream.cpp", "src/MyGUI_OgreRenderManager.cpp", "src/MyGUI_OgreRTTexture.cpp", "src/MyGUI_OgreTexture.cpp", "src/MyGUI_OgreVertexBuffer.cpp" } ) configuration( { "WIN32" } ) vpaths { ["Platform Headers"] = { "**.h", "**.hpp", "**.hxx" } } files( { "../../../Common/FileSystemInfo/FileSystemInfo.h", "include/MyGUI_LastHeader.h", "include/MyGUI_OgreDataManager.h", "include/MyGUI_OgreDataStream.h", "include/MyGUI_OgreDiagnostic.h", "include/MyGUI_OgrePlatform.h", "include/MyGUI_OgreRenderManager.h", "include/MyGUI_OgreRTTexture.h", "include/MyGUI_OgreTexture.h", "include/MyGUI_OgreVertexBuffer.h" } ) vpaths { ["Platform Source"] = { "**.c", "**.cpp", "**.cs", "**.asm" } } files( { "src/MyGUI_OgreDataManager.cpp", "src/MyGUI_OgreDataStream.cpp", "src/MyGUI_OgreRenderManager.cpp", "src/MyGUI_OgreRTTexture.cpp", "src/MyGUI_OgreTexture.cpp", "src/MyGUI_OgreVertexBuffer.cpp" } ) configuration( {} ) includedirs( { "../../../../freetype/include", "../../../../freetype/include/freetype", "../../../../freetype/include/freetype/config", "../../../../freetype/include/freetype/internal", "../../../../freetype/include/freetype/internal/services", "../../../../freetype/src/winfonts", "../../../MyGUIEngine/include" } ) configuration( { "LINUX" } ) includedirs( { "../../../Common/FileSystemInfo", "include" } ) configuration( { "WIN32" } ) includedirs( { "../../../Common/FileSystemInfo", "include" } )
apache-2.0
jshackley/darkstar
scripts/zones/Bastok_Mines/npcs/Medicine_Eagle.lua
17
1476
----------------------------------- -- Area: Bastok Mines -- NPC: Medicine Eagle -- Involved in Mission: Bastok 6-1, 8-1 -- @pos -40 0 38 234 ----------------------------------- package.loaded["scripts/zones/Bastok_Markets/TextIDs"] = nil; ----------------------------------- require("scripts/globals/missions"); require("scripts/zones/Bastok_Markets/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (player:getCurrentMission(BASTOK) == RETURN_OF_THE_TALEKEEPER and player:getVar("MissionStatus") == 0) then player:startEvent(0x00b4); else player:startEvent(0x0019); end end; -- if Bastok Mission 8-1 -- 0x00b0 -- player:startEvent(0x00b4); -- player:startEvent(0x00b5); --0x0001 0x0019 0x00b0 0x00b5 0x00b4 ----------------------------------- -- 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 == 0x00b4) then player:setVar("MissionStatus",1); end end;
gpl-3.0
dani-sj/mahan
libs/dkjson.lua
3282
26558
-- Module options: local always_try_using_lpeg = true local register_global_module_table = false local global_module_name = 'json' --[==[ David Kolf's JSON module for Lua 5.1/5.2 ======================================== *Version 2.4* In the default configuration this module writes no global values, not even the module table. Import it using json = require ("dkjson") In environments where `require` or a similiar function are not available and you cannot receive the return value of the module, you can set the option `register_global_module_table` to `true`. The module table will then be saved in the global variable with the name given by the option `global_module_name`. Exported functions and values: `json.encode (object [, state])` -------------------------------- Create a string representing the object. `Object` can be a table, a string, a number, a boolean, `nil`, `json.null` or any object with a function `__tojson` in its metatable. A table can only use strings and numbers as keys and its values have to be valid objects as well. It raises an error for any invalid data types or reference cycles. `state` is an optional table with the following fields: - `indent` When `indent` (a boolean) is set, the created string will contain newlines and indentations. Otherwise it will be one long line. - `keyorder` `keyorder` is an array to specify the ordering of keys in the encoded output. If an object has keys which are not in this array they are written after the sorted keys. - `level` This is the initial level of indentation used when `indent` is set. For each level two spaces are added. When absent it is set to 0. - `buffer` `buffer` is an array to store the strings for the result so they can be concatenated at once. When it isn't given, the encode function will create it temporary and will return the concatenated result. - `bufferlen` When `bufferlen` is set, it has to be the index of the last element of `buffer`. - `tables` `tables` is a set to detect reference cycles. It is created temporary when absent. Every table that is currently processed is used as key, the value is `true`. When `state.buffer` was set, the return value will be `true` on success. Without `state.buffer` the return value will be a string. `json.decode (string [, position [, null]])` -------------------------------------------- Decode `string` starting at `position` or at 1 if `position` was omitted. `null` is an optional value to be returned for null values. The default is `nil`, but you could set it to `json.null` or any other value. The return values are the object or `nil`, the position of the next character that doesn't belong to the object, and in case of errors an error message. Two metatables are created. Every array or object that is decoded gets a metatable with the `__jsontype` field set to either `array` or `object`. If you want to provide your own metatables use the syntax json.decode (string, position, null, objectmeta, arraymeta) To prevent the assigning of metatables pass `nil`: json.decode (string, position, null, nil) `<metatable>.__jsonorder` ------------------------- `__jsonorder` can overwrite the `keyorder` for a specific table. `<metatable>.__jsontype` ------------------------ `__jsontype` can be either `"array"` or `"object"`. This value is only checked for empty tables. (The default for empty tables is `"array"`). `<metatable>.__tojson (self, state)` ------------------------------------ You can provide your own `__tojson` function in a metatable. In this function you can either add directly to the buffer and return true, or you can return a string. On errors nil and a message should be returned. `json.null` ----------- You can use this value for setting explicit `null` values. `json.version` -------------- Set to `"dkjson 2.4"`. `json.quotestring (string)` --------------------------- Quote a UTF-8 string and escape critical characters using JSON escape sequences. This function is only necessary when you build your own `__tojson` functions. `json.addnewline (state)` ------------------------- When `state.indent` is set, add a newline to `state.buffer` and spaces according to `state.level`. LPeg support ------------ When the local configuration variable `always_try_using_lpeg` is set, this module tries to load LPeg to replace the `decode` function. The speed increase is significant. You can get the LPeg module at <http://www.inf.puc-rio.br/~roberto/lpeg/>. When LPeg couldn't be loaded, the pure Lua functions stay active. In case you don't want this module to require LPeg on its own, disable the option `always_try_using_lpeg` in the options section at the top of the module. In this case you can later load LPeg support using ### `json.use_lpeg ()` Require the LPeg module and replace the functions `quotestring` and and `decode` with functions that use LPeg patterns. This function returns the module table, so you can load the module using: json = require "dkjson".use_lpeg() Alternatively you can use `pcall` so the JSON module still works when LPeg isn't found. json = require "dkjson" pcall (json.use_lpeg) ### `json.using_lpeg` This variable is set to `true` when LPeg was loaded successfully. --------------------------------------------------------------------- Contact ------- You can contact the author by sending an e-mail to 'david' at the domain 'dkolf.de'. --------------------------------------------------------------------- *Copyright (C) 2010-2013 David Heiko Kolf* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. <!-- This documentation can be parsed using Markdown to generate HTML. The source code is enclosed in a HTML comment so it won't be displayed by browsers, but it should be removed from the final HTML file as it isn't a valid HTML comment (and wastes space). --> <!--]==] -- global dependencies: local pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset = pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset local error, require, pcall, select = error, require, pcall, select local floor, huge = math.floor, math.huge local strrep, gsub, strsub, strbyte, strchar, strfind, strlen, strformat = string.rep, string.gsub, string.sub, string.byte, string.char, string.find, string.len, string.format local strmatch = string.match local concat = table.concat local json = { version = "dkjson 2.4" } if register_global_module_table then _G[global_module_name] = json end local _ENV = nil -- blocking globals in Lua 5.2 pcall (function() -- Enable access to blocked metatables. -- Don't worry, this module doesn't change anything in them. local debmeta = require "debug".getmetatable if debmeta then getmetatable = debmeta end end) json.null = setmetatable ({}, { __tojson = function () return "null" end }) local function isarray (tbl) local max, n, arraylen = 0, 0, 0 for k,v in pairs (tbl) do if k == 'n' and type(v) == 'number' then arraylen = v if v > max then max = v end else if type(k) ~= 'number' or k < 1 or floor(k) ~= k then return false end if k > max then max = k end n = n + 1 end end if max > 10 and max > arraylen and max > n * 2 then return false -- don't create an array with too many holes end return true, max end local escapecodes = { ["\""] = "\\\"", ["\\"] = "\\\\", ["\b"] = "\\b", ["\f"] = "\\f", ["\n"] = "\\n", ["\r"] = "\\r", ["\t"] = "\\t" } local function escapeutf8 (uchar) local value = escapecodes[uchar] if value then return value end local a, b, c, d = strbyte (uchar, 1, 4) a, b, c, d = a or 0, b or 0, c or 0, d or 0 if a <= 0x7f then value = a elseif 0xc0 <= a and a <= 0xdf and b >= 0x80 then value = (a - 0xc0) * 0x40 + b - 0x80 elseif 0xe0 <= a and a <= 0xef and b >= 0x80 and c >= 0x80 then value = ((a - 0xe0) * 0x40 + b - 0x80) * 0x40 + c - 0x80 elseif 0xf0 <= a and a <= 0xf7 and b >= 0x80 and c >= 0x80 and d >= 0x80 then value = (((a - 0xf0) * 0x40 + b - 0x80) * 0x40 + c - 0x80) * 0x40 + d - 0x80 else return "" end if value <= 0xffff then return strformat ("\\u%.4x", value) elseif value <= 0x10ffff then -- encode as UTF-16 surrogate pair value = value - 0x10000 local highsur, lowsur = 0xD800 + floor (value/0x400), 0xDC00 + (value % 0x400) return strformat ("\\u%.4x\\u%.4x", highsur, lowsur) else return "" end end local function fsub (str, pattern, repl) -- gsub always builds a new string in a buffer, even when no match -- exists. First using find should be more efficient when most strings -- don't contain the pattern. if strfind (str, pattern) then return gsub (str, pattern, repl) else return str end end local function quotestring (value) -- based on the regexp "escapable" in https://github.com/douglascrockford/JSON-js value = fsub (value, "[%z\1-\31\"\\\127]", escapeutf8) if strfind (value, "[\194\216\220\225\226\239]") then value = fsub (value, "\194[\128-\159\173]", escapeutf8) value = fsub (value, "\216[\128-\132]", escapeutf8) value = fsub (value, "\220\143", escapeutf8) value = fsub (value, "\225\158[\180\181]", escapeutf8) value = fsub (value, "\226\128[\140-\143\168-\175]", escapeutf8) value = fsub (value, "\226\129[\160-\175]", escapeutf8) value = fsub (value, "\239\187\191", escapeutf8) value = fsub (value, "\239\191[\176-\191]", escapeutf8) end return "\"" .. value .. "\"" end json.quotestring = quotestring local function replace(str, o, n) local i, j = strfind (str, o, 1, true) if i then return strsub(str, 1, i-1) .. n .. strsub(str, j+1, -1) else return str end end -- locale independent num2str and str2num functions local decpoint, numfilter local function updatedecpoint () decpoint = strmatch(tostring(0.5), "([^05+])") -- build a filter that can be used to remove group separators numfilter = "[^0-9%-%+eE" .. gsub(decpoint, "[%^%$%(%)%%%.%[%]%*%+%-%?]", "%%%0") .. "]+" end updatedecpoint() local function num2str (num) return replace(fsub(tostring(num), numfilter, ""), decpoint, ".") end local function str2num (str) local num = tonumber(replace(str, ".", decpoint)) if not num then updatedecpoint() num = tonumber(replace(str, ".", decpoint)) end return num end local function addnewline2 (level, buffer, buflen) buffer[buflen+1] = "\n" buffer[buflen+2] = strrep (" ", level) buflen = buflen + 2 return buflen end function json.addnewline (state) if state.indent then state.bufferlen = addnewline2 (state.level or 0, state.buffer, state.bufferlen or #(state.buffer)) end end local encode2 -- forward declaration local function addpair (key, value, prev, indent, level, buffer, buflen, tables, globalorder) local kt = type (key) if kt ~= 'string' and kt ~= 'number' then return nil, "type '" .. kt .. "' is not supported as a key by JSON." end if prev then buflen = buflen + 1 buffer[buflen] = "," end if indent then buflen = addnewline2 (level, buffer, buflen) end buffer[buflen+1] = quotestring (key) buffer[buflen+2] = ":" return encode2 (value, indent, level, buffer, buflen + 2, tables, globalorder) end encode2 = function (value, indent, level, buffer, buflen, tables, globalorder) local valtype = type (value) local valmeta = getmetatable (value) valmeta = type (valmeta) == 'table' and valmeta -- only tables local valtojson = valmeta and valmeta.__tojson if valtojson then if tables[value] then return nil, "reference cycle" end tables[value] = true local state = { indent = indent, level = level, buffer = buffer, bufferlen = buflen, tables = tables, keyorder = globalorder } local ret, msg = valtojson (value, state) if not ret then return nil, msg end tables[value] = nil buflen = state.bufferlen if type (ret) == 'string' then buflen = buflen + 1 buffer[buflen] = ret end elseif value == nil then buflen = buflen + 1 buffer[buflen] = "null" elseif valtype == 'number' then local s if value ~= value or value >= huge or -value >= huge then -- This is the behaviour of the original JSON implementation. s = "null" else s = num2str (value) end buflen = buflen + 1 buffer[buflen] = s elseif valtype == 'boolean' then buflen = buflen + 1 buffer[buflen] = value and "true" or "false" elseif valtype == 'string' then buflen = buflen + 1 buffer[buflen] = quotestring (value) elseif valtype == 'table' then if tables[value] then return nil, "reference cycle" end tables[value] = true level = level + 1 local isa, n = isarray (value) if n == 0 and valmeta and valmeta.__jsontype == 'object' then isa = false end local msg if isa then -- JSON array buflen = buflen + 1 buffer[buflen] = "[" for i = 1, n do buflen, msg = encode2 (value[i], indent, level, buffer, buflen, tables, globalorder) if not buflen then return nil, msg end if i < n then buflen = buflen + 1 buffer[buflen] = "," end end buflen = buflen + 1 buffer[buflen] = "]" else -- JSON object local prev = false buflen = buflen + 1 buffer[buflen] = "{" local order = valmeta and valmeta.__jsonorder or globalorder if order then local used = {} n = #order for i = 1, n do local k = order[i] local v = value[k] if v then used[k] = true buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder) prev = true -- add a seperator before the next element end end for k,v in pairs (value) do if not used[k] then buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder) if not buflen then return nil, msg end prev = true -- add a seperator before the next element end end else -- unordered for k,v in pairs (value) do buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder) if not buflen then return nil, msg end prev = true -- add a seperator before the next element end end if indent then buflen = addnewline2 (level - 1, buffer, buflen) end buflen = buflen + 1 buffer[buflen] = "}" end tables[value] = nil else return nil, "type '" .. valtype .. "' is not supported by JSON." end return buflen end function json.encode (value, state) state = state or {} local oldbuffer = state.buffer local buffer = oldbuffer or {} updatedecpoint() local ret, msg = encode2 (value, state.indent, state.level or 0, buffer, state.bufferlen or 0, state.tables or {}, state.keyorder) if not ret then error (msg, 2) elseif oldbuffer then state.bufferlen = ret return true else return concat (buffer) end end local function loc (str, where) local line, pos, linepos = 1, 1, 0 while true do pos = strfind (str, "\n", pos, true) if pos and pos < where then line = line + 1 linepos = pos pos = pos + 1 else break end end return "line " .. line .. ", column " .. (where - linepos) end local function unterminated (str, what, where) return nil, strlen (str) + 1, "unterminated " .. what .. " at " .. loc (str, where) end local function scanwhite (str, pos) while true do pos = strfind (str, "%S", pos) if not pos then return nil end if strsub (str, pos, pos + 2) == "\239\187\191" then -- UTF-8 Byte Order Mark pos = pos + 3 else return pos end end end local escapechars = { ["\""] = "\"", ["\\"] = "\\", ["/"] = "/", ["b"] = "\b", ["f"] = "\f", ["n"] = "\n", ["r"] = "\r", ["t"] = "\t" } local function unichar (value) if value < 0 then return nil elseif value <= 0x007f then return strchar (value) elseif value <= 0x07ff then return strchar (0xc0 + floor(value/0x40), 0x80 + (floor(value) % 0x40)) elseif value <= 0xffff then return strchar (0xe0 + floor(value/0x1000), 0x80 + (floor(value/0x40) % 0x40), 0x80 + (floor(value) % 0x40)) elseif value <= 0x10ffff then return strchar (0xf0 + floor(value/0x40000), 0x80 + (floor(value/0x1000) % 0x40), 0x80 + (floor(value/0x40) % 0x40), 0x80 + (floor(value) % 0x40)) else return nil end end local function scanstring (str, pos) local lastpos = pos + 1 local buffer, n = {}, 0 while true do local nextpos = strfind (str, "[\"\\]", lastpos) if not nextpos then return unterminated (str, "string", pos) end if nextpos > lastpos then n = n + 1 buffer[n] = strsub (str, lastpos, nextpos - 1) end if strsub (str, nextpos, nextpos) == "\"" then lastpos = nextpos + 1 break else local escchar = strsub (str, nextpos + 1, nextpos + 1) local value if escchar == "u" then value = tonumber (strsub (str, nextpos + 2, nextpos + 5), 16) if value then local value2 if 0xD800 <= value and value <= 0xDBff then -- we have the high surrogate of UTF-16. Check if there is a -- low surrogate escaped nearby to combine them. if strsub (str, nextpos + 6, nextpos + 7) == "\\u" then value2 = tonumber (strsub (str, nextpos + 8, nextpos + 11), 16) if value2 and 0xDC00 <= value2 and value2 <= 0xDFFF then value = (value - 0xD800) * 0x400 + (value2 - 0xDC00) + 0x10000 else value2 = nil -- in case it was out of range for a low surrogate end end end value = value and unichar (value) if value then if value2 then lastpos = nextpos + 12 else lastpos = nextpos + 6 end end end end if not value then value = escapechars[escchar] or escchar lastpos = nextpos + 2 end n = n + 1 buffer[n] = value end end if n == 1 then return buffer[1], lastpos elseif n > 1 then return concat (buffer), lastpos else return "", lastpos end end local scanvalue -- forward declaration local function scantable (what, closechar, str, startpos, nullval, objectmeta, arraymeta) local len = strlen (str) local tbl, n = {}, 0 local pos = startpos + 1 if what == 'object' then setmetatable (tbl, objectmeta) else setmetatable (tbl, arraymeta) end while true do pos = scanwhite (str, pos) if not pos then return unterminated (str, what, startpos) end local char = strsub (str, pos, pos) if char == closechar then return tbl, pos + 1 end local val1, err val1, pos, err = scanvalue (str, pos, nullval, objectmeta, arraymeta) if err then return nil, pos, err end pos = scanwhite (str, pos) if not pos then return unterminated (str, what, startpos) end char = strsub (str, pos, pos) if char == ":" then if val1 == nil then return nil, pos, "cannot use nil as table index (at " .. loc (str, pos) .. ")" end pos = scanwhite (str, pos + 1) if not pos then return unterminated (str, what, startpos) end local val2 val2, pos, err = scanvalue (str, pos, nullval, objectmeta, arraymeta) if err then return nil, pos, err end tbl[val1] = val2 pos = scanwhite (str, pos) if not pos then return unterminated (str, what, startpos) end char = strsub (str, pos, pos) else n = n + 1 tbl[n] = val1 end if char == "," then pos = pos + 1 end end end scanvalue = function (str, pos, nullval, objectmeta, arraymeta) pos = pos or 1 pos = scanwhite (str, pos) if not pos then return nil, strlen (str) + 1, "no valid JSON value (reached the end)" end local char = strsub (str, pos, pos) if char == "{" then return scantable ('object', "}", str, pos, nullval, objectmeta, arraymeta) elseif char == "[" then return scantable ('array', "]", str, pos, nullval, objectmeta, arraymeta) elseif char == "\"" then return scanstring (str, pos) else local pstart, pend = strfind (str, "^%-?[%d%.]+[eE]?[%+%-]?%d*", pos) if pstart then local number = str2num (strsub (str, pstart, pend)) if number then return number, pend + 1 end end pstart, pend = strfind (str, "^%a%w*", pos) if pstart then local name = strsub (str, pstart, pend) if name == "true" then return true, pend + 1 elseif name == "false" then return false, pend + 1 elseif name == "null" then return nullval, pend + 1 end end return nil, pos, "no valid JSON value at " .. loc (str, pos) end end local function optionalmetatables(...) if select("#", ...) > 0 then return ... else return {__jsontype = 'object'}, {__jsontype = 'array'} end end function json.decode (str, pos, nullval, ...) local objectmeta, arraymeta = optionalmetatables(...) return scanvalue (str, pos, nullval, objectmeta, arraymeta) end function json.use_lpeg () local g = require ("lpeg") if g.version() == "0.11" then error "due to a bug in LPeg 0.11, it cannot be used for JSON matching" end local pegmatch = g.match local P, S, R = g.P, g.S, g.R local function ErrorCall (str, pos, msg, state) if not state.msg then state.msg = msg .. " at " .. loc (str, pos) state.pos = pos end return false end local function Err (msg) return g.Cmt (g.Cc (msg) * g.Carg (2), ErrorCall) end local Space = (S" \n\r\t" + P"\239\187\191")^0 local PlainChar = 1 - S"\"\\\n\r" local EscapeSequence = (P"\\" * g.C (S"\"\\/bfnrt" + Err "unsupported escape sequence")) / escapechars local HexDigit = R("09", "af", "AF") local function UTF16Surrogate (match, pos, high, low) high, low = tonumber (high, 16), tonumber (low, 16) if 0xD800 <= high and high <= 0xDBff and 0xDC00 <= low and low <= 0xDFFF then return true, unichar ((high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000) else return false end end local function UTF16BMP (hex) return unichar (tonumber (hex, 16)) end local U16Sequence = (P"\\u" * g.C (HexDigit * HexDigit * HexDigit * HexDigit)) local UnicodeEscape = g.Cmt (U16Sequence * U16Sequence, UTF16Surrogate) + U16Sequence/UTF16BMP local Char = UnicodeEscape + EscapeSequence + PlainChar local String = P"\"" * g.Cs (Char ^ 0) * (P"\"" + Err "unterminated string") local Integer = P"-"^(-1) * (P"0" + (R"19" * R"09"^0)) local Fractal = P"." * R"09"^0 local Exponent = (S"eE") * (S"+-")^(-1) * R"09"^1 local Number = (Integer * Fractal^(-1) * Exponent^(-1))/str2num local Constant = P"true" * g.Cc (true) + P"false" * g.Cc (false) + P"null" * g.Carg (1) local SimpleValue = Number + String + Constant local ArrayContent, ObjectContent -- The functions parsearray and parseobject parse only a single value/pair -- at a time and store them directly to avoid hitting the LPeg limits. local function parsearray (str, pos, nullval, state) local obj, cont local npos local t, nt = {}, 0 repeat obj, cont, npos = pegmatch (ArrayContent, str, pos, nullval, state) if not npos then break end pos = npos nt = nt + 1 t[nt] = obj until cont == 'last' return pos, setmetatable (t, state.arraymeta) end local function parseobject (str, pos, nullval, state) local obj, key, cont local npos local t = {} repeat key, obj, cont, npos = pegmatch (ObjectContent, str, pos, nullval, state) if not npos then break end pos = npos t[key] = obj until cont == 'last' return pos, setmetatable (t, state.objectmeta) end local Array = P"[" * g.Cmt (g.Carg(1) * g.Carg(2), parsearray) * Space * (P"]" + Err "']' expected") local Object = P"{" * g.Cmt (g.Carg(1) * g.Carg(2), parseobject) * Space * (P"}" + Err "'}' expected") local Value = Space * (Array + Object + SimpleValue) local ExpectedValue = Value + Space * Err "value expected" ArrayContent = Value * Space * (P"," * g.Cc'cont' + g.Cc'last') * g.Cp() local Pair = g.Cg (Space * String * Space * (P":" + Err "colon expected") * ExpectedValue) ObjectContent = Pair * Space * (P"," * g.Cc'cont' + g.Cc'last') * g.Cp() local DecodeValue = ExpectedValue * g.Cp () function json.decode (str, pos, nullval, ...) local state = {} state.objectmeta, state.arraymeta = optionalmetatables(...) local obj, retpos = pegmatch (DecodeValue, str, pos, nullval, state) if state.msg then return nil, state.pos, state.msg else return obj, retpos end end -- use this function only once: json.use_lpeg = function () return json end json.using_lpeg = true return json -- so you can get the module using json = require "dkjson".use_lpeg() end if always_try_using_lpeg then pcall (json.use_lpeg) end return json -->
gpl-2.0
jshackley/darkstar
scripts/zones/Abyssea-Vunkerl/npcs/qm22.lua
17
1746
----------------------------------- -- Zone: Abyssea-Vunkeral -- NPC: ??? -- Spawns: Durinn ----------------------------------- require("scripts/globals/status"); require("scripts/globals/keyitems"); ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) --[[ if (GetMobAction(17666501) == ACTION_NONE) then -- NM not already spawned from this if (player:hasKeyItem(DECAYED_DVERGR_TOOTH) and player:hasKeyItem(PULSATING_SOULFLAYER_BEARD) and player:hasKeyItem(CHIPPED_IMPS_OLIFANT)) then -- I broke it into 3 lines at the 'and' because it was so long. player:startEvent(1015, DECAYED_DVERGR_TOOTH, PULSATING_SOULFLAYER_BEARD, CHIPPED_IMPS_OLIFANT); -- Ask if player wants to use KIs else player:startEvent(1120, DECAYED_DVERGR_TOOTH, PULSATING_SOULFLAYER_BEARD, CHIPPED_IMPS_OLIFANT); -- Do not ask, because player is missing at least 1. end end ]] end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID2: %u",csid); -- printf("RESULT2: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 1015 and option == 1) then SpawnMob(17666501):updateClaim(player); -- Spawn NM, Despawn after inactive for 5 minutes (pt has to reclaim within 5 of a wipe) player:delKeyItem(DECAYED_DVERGR_TOOTH); player:delKeyItem(PULSATING_SOULFLAYER_BEARD); player:delKeyItem(CHIPPED_IMPS_OLIFANT); end end;
gpl-3.0
LiberatorUSA/GUCEF
tests/gucefCORE_TestApp/premake5.lua
1
5187
-------------------------------------------------------------------- -- This file was automatically generated by ProjectGenerator -- which is tooling part the build system designed for GUCEF -- (Galaxy Unlimited Framework) -- For the latest info, see http://www.VanvelzenSoftware.com/ -- -- The contents of this file are placed in the public domain. Feel -- free to make use of it in any way you like. -------------------------------------------------------------------- -- -- Configuration for module: gucefCORE_TestApp configuration( { "LINUX32" } ) project( "gucefCORE_TestApp" ) configuration( { "LINUX64" } ) project( "gucefCORE_TestApp" ) configuration( { "WIN32" } ) project( "gucefCORE_TestApp" ) configuration( { "WIN64" } ) project( "gucefCORE_TestApp" ) configuration( {} ) location( os.getenv( "PM5OUTPUTDIR" ) ) configuration( {} ) targetdir( os.getenv( "PM5TARGETDIR" ) ) configuration( {} ) language( "C" ) configuration( { "LINUX32" } ) language( "C++" ) configuration( { "LINUX64" } ) language( "C++" ) configuration( { "WIN32" } ) language( "C++" ) configuration( { "WIN64" } ) language( "C++" ) configuration( { "LINUX32" } ) configuration( { LINUX32 } ) kind( "ConsoleApp" ) configuration( { "LINUX64" } ) configuration( { LINUX64 } ) kind( "ConsoleApp" ) configuration( { "WIN32" } ) configuration( { WIN32 } ) kind( "WindowedApp" ) configuration( { "WIN64" } ) configuration( { WIN64 } ) kind( "WindowedApp" ) configuration( { LINUX32 } ) links( { "gucefCORE", "gucefMT" } ) links( { "gucefCORE", "gucefMT" } ) configuration( { LINUX32 } ) defines( { "GUCEF_CORE_TESTAPP_BUILD_MODULE" } ) configuration( { LINUX64 } ) links( { "gucefCORE", "gucefMT" } ) links( { "gucefCORE", "gucefMT" } ) configuration( { LINUX64 } ) defines( { "GUCEF_CORE_TESTAPP_BUILD_MODULE" } ) configuration( { WIN32 } ) links( { "gucefCORE", "gucefMT" } ) links( { "gucefCORE", "gucefMT" } ) configuration( { WIN32 } ) defines( { "GUCEF_CORE_TESTAPP_BUILD_MODULE" } ) configuration( { WIN64 } ) links( { "gucefCORE", "gucefMT" } ) links( { "gucefCORE", "gucefMT" } ) configuration( { WIN64 } ) defines( { "GUCEF_CORE_TESTAPP_BUILD_MODULE" } ) configuration( { "LINUX32" } ) vpaths { ["Platform Headers"] = { "**.h", "**.hpp", "**.hxx" } } files( { "include/TestCyclicDynamicBuffer.h", "include/TestIniParser.h", "include/TestNotifierObserver.h", "include/TestSharedPtr.h", "include/TestString.h" } ) vpaths { ["Platform Source"] = { "**.c", "**.cpp", "**.cs", "**.asm" } } files( { "src/TestCyclicDynamicBuffer.cpp", "src/TestIniParser.cpp", "src/TestNotifierObserver.cpp", "src/TestSharedPtr.cpp", "src/TestString.cpp", "src/gucefCORE_TestApp_main.cpp" } ) configuration( { "LINUX64" } ) vpaths { ["Platform Headers"] = { "**.h", "**.hpp", "**.hxx" } } files( { "include/TestCyclicDynamicBuffer.h", "include/TestIniParser.h", "include/TestNotifierObserver.h", "include/TestSharedPtr.h", "include/TestString.h" } ) vpaths { ["Platform Source"] = { "**.c", "**.cpp", "**.cs", "**.asm" } } files( { "src/TestCyclicDynamicBuffer.cpp", "src/TestIniParser.cpp", "src/TestNotifierObserver.cpp", "src/TestSharedPtr.cpp", "src/TestString.cpp", "src/gucefCORE_TestApp_main.cpp" } ) configuration( { "WIN32" } ) vpaths { ["Platform Headers"] = { "**.h", "**.hpp", "**.hxx" } } files( { "include/TestCyclicDynamicBuffer.h", "include/TestIniParser.h", "include/TestNotifierObserver.h", "include/TestSharedPtr.h", "include/TestString.h" } ) vpaths { ["Platform Source"] = { "**.c", "**.cpp", "**.cs", "**.asm" } } files( { "src/TestCyclicDynamicBuffer.cpp", "src/TestIniParser.cpp", "src/TestNotifierObserver.cpp", "src/TestSharedPtr.cpp", "src/TestString.cpp", "src/gucefCORE_TestApp_main.cpp" } ) configuration( { "WIN64" } ) vpaths { ["Platform Headers"] = { "**.h", "**.hpp", "**.hxx" } } files( { "include/TestCyclicDynamicBuffer.h", "include/TestIniParser.h", "include/TestNotifierObserver.h", "include/TestSharedPtr.h", "include/TestString.h" } ) vpaths { ["Platform Source"] = { "**.c", "**.cpp", "**.cs", "**.asm" } } files( { "src/TestCyclicDynamicBuffer.cpp", "src/TestIniParser.cpp", "src/TestNotifierObserver.cpp", "src/TestSharedPtr.cpp", "src/TestString.cpp", "src/gucefCORE_TestApp_main.cpp" } ) configuration( {} ) includedirs( { "../../common/include", "../../platform/gucefCORE/include", "../../platform/gucefMT/include" } ) configuration( { "LINUX32" } ) includedirs( { "../../platform/gucefCORE/include/linux", "include" } ) configuration( { "LINUX64" } ) includedirs( { "../../platform/gucefCORE/include/linux", "include" } ) configuration( { "WIN32" } ) includedirs( { "../../platform/gucefCORE/include/mswin", "include" } ) configuration( { "WIN64" } ) includedirs( { "../../platform/gucefCORE/include/mswin", "include" } )
apache-2.0
Victek/wrt1900ac-aa
veriksystems/luci-0.11/applications/luci-statistics/luasrc/model/cbi/luci_statistics/olsrd.lua
70
1672
--[[ LuCI - Lua Configuration Interface Copyright 2011 Manuel Munz <freifunk at somakoma dot de> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 ]]-- m = Map("luci_statistics", translate("OLSRd Plugin Configuration"), translate("The OLSRd plugin reads information about meshed networks from the txtinfo plugin of OLSRd.")) s = m:section(NamedSection, "collectd_olsrd", "luci_statistics" ) enable = s:option(Flag, "enable", translate("Enable this plugin")) enable.default = 0 host = s:option(Value, "Host", translate("Host"), translate("IP or hostname where to get the txtinfo output from")) host.placeholder = "127.0.0.1" host.datatype = "host" host.rmempty = true port = s:option(Value, "Port", translate("Port")) port.placeholder = "2006" port.datatype = "range(0,65535)" port.rmempty = true port.cast = "string" cl = s:option(ListValue, "CollectLinks", translate("CollectLinks"), translate("Specifies what information to collect about links.")) cl:value("No") cl:value("Summary") cl:value("Detail") cl.default = "Detail" cr = s:option(ListValue, "CollectRoutes", translate("CollectRoutes"), translate("Specifies what information to collect about routes.")) cr:value("No") cr:value("Summary") cr:value("Detail") cr.default = "Summary" ct = s:option(ListValue, "CollectTopology", translate("CollectTopology"), translate("Specifies what information to collect about the global topology.")) ct:value("No") ct:value("Summary") ct:value("Detail") ct.default = "Summary" return m
gpl-2.0
botmohammad12344888/bot-888338888
libs/dkjson.lua
3282
26558
-- Module options: local always_try_using_lpeg = true local register_global_module_table = false local global_module_name = 'json' --[==[ David Kolf's JSON module for Lua 5.1/5.2 ======================================== *Version 2.4* In the default configuration this module writes no global values, not even the module table. Import it using json = require ("dkjson") In environments where `require` or a similiar function are not available and you cannot receive the return value of the module, you can set the option `register_global_module_table` to `true`. The module table will then be saved in the global variable with the name given by the option `global_module_name`. Exported functions and values: `json.encode (object [, state])` -------------------------------- Create a string representing the object. `Object` can be a table, a string, a number, a boolean, `nil`, `json.null` or any object with a function `__tojson` in its metatable. A table can only use strings and numbers as keys and its values have to be valid objects as well. It raises an error for any invalid data types or reference cycles. `state` is an optional table with the following fields: - `indent` When `indent` (a boolean) is set, the created string will contain newlines and indentations. Otherwise it will be one long line. - `keyorder` `keyorder` is an array to specify the ordering of keys in the encoded output. If an object has keys which are not in this array they are written after the sorted keys. - `level` This is the initial level of indentation used when `indent` is set. For each level two spaces are added. When absent it is set to 0. - `buffer` `buffer` is an array to store the strings for the result so they can be concatenated at once. When it isn't given, the encode function will create it temporary and will return the concatenated result. - `bufferlen` When `bufferlen` is set, it has to be the index of the last element of `buffer`. - `tables` `tables` is a set to detect reference cycles. It is created temporary when absent. Every table that is currently processed is used as key, the value is `true`. When `state.buffer` was set, the return value will be `true` on success. Without `state.buffer` the return value will be a string. `json.decode (string [, position [, null]])` -------------------------------------------- Decode `string` starting at `position` or at 1 if `position` was omitted. `null` is an optional value to be returned for null values. The default is `nil`, but you could set it to `json.null` or any other value. The return values are the object or `nil`, the position of the next character that doesn't belong to the object, and in case of errors an error message. Two metatables are created. Every array or object that is decoded gets a metatable with the `__jsontype` field set to either `array` or `object`. If you want to provide your own metatables use the syntax json.decode (string, position, null, objectmeta, arraymeta) To prevent the assigning of metatables pass `nil`: json.decode (string, position, null, nil) `<metatable>.__jsonorder` ------------------------- `__jsonorder` can overwrite the `keyorder` for a specific table. `<metatable>.__jsontype` ------------------------ `__jsontype` can be either `"array"` or `"object"`. This value is only checked for empty tables. (The default for empty tables is `"array"`). `<metatable>.__tojson (self, state)` ------------------------------------ You can provide your own `__tojson` function in a metatable. In this function you can either add directly to the buffer and return true, or you can return a string. On errors nil and a message should be returned. `json.null` ----------- You can use this value for setting explicit `null` values. `json.version` -------------- Set to `"dkjson 2.4"`. `json.quotestring (string)` --------------------------- Quote a UTF-8 string and escape critical characters using JSON escape sequences. This function is only necessary when you build your own `__tojson` functions. `json.addnewline (state)` ------------------------- When `state.indent` is set, add a newline to `state.buffer` and spaces according to `state.level`. LPeg support ------------ When the local configuration variable `always_try_using_lpeg` is set, this module tries to load LPeg to replace the `decode` function. The speed increase is significant. You can get the LPeg module at <http://www.inf.puc-rio.br/~roberto/lpeg/>. When LPeg couldn't be loaded, the pure Lua functions stay active. In case you don't want this module to require LPeg on its own, disable the option `always_try_using_lpeg` in the options section at the top of the module. In this case you can later load LPeg support using ### `json.use_lpeg ()` Require the LPeg module and replace the functions `quotestring` and and `decode` with functions that use LPeg patterns. This function returns the module table, so you can load the module using: json = require "dkjson".use_lpeg() Alternatively you can use `pcall` so the JSON module still works when LPeg isn't found. json = require "dkjson" pcall (json.use_lpeg) ### `json.using_lpeg` This variable is set to `true` when LPeg was loaded successfully. --------------------------------------------------------------------- Contact ------- You can contact the author by sending an e-mail to 'david' at the domain 'dkolf.de'. --------------------------------------------------------------------- *Copyright (C) 2010-2013 David Heiko Kolf* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. <!-- This documentation can be parsed using Markdown to generate HTML. The source code is enclosed in a HTML comment so it won't be displayed by browsers, but it should be removed from the final HTML file as it isn't a valid HTML comment (and wastes space). --> <!--]==] -- global dependencies: local pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset = pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset local error, require, pcall, select = error, require, pcall, select local floor, huge = math.floor, math.huge local strrep, gsub, strsub, strbyte, strchar, strfind, strlen, strformat = string.rep, string.gsub, string.sub, string.byte, string.char, string.find, string.len, string.format local strmatch = string.match local concat = table.concat local json = { version = "dkjson 2.4" } if register_global_module_table then _G[global_module_name] = json end local _ENV = nil -- blocking globals in Lua 5.2 pcall (function() -- Enable access to blocked metatables. -- Don't worry, this module doesn't change anything in them. local debmeta = require "debug".getmetatable if debmeta then getmetatable = debmeta end end) json.null = setmetatable ({}, { __tojson = function () return "null" end }) local function isarray (tbl) local max, n, arraylen = 0, 0, 0 for k,v in pairs (tbl) do if k == 'n' and type(v) == 'number' then arraylen = v if v > max then max = v end else if type(k) ~= 'number' or k < 1 or floor(k) ~= k then return false end if k > max then max = k end n = n + 1 end end if max > 10 and max > arraylen and max > n * 2 then return false -- don't create an array with too many holes end return true, max end local escapecodes = { ["\""] = "\\\"", ["\\"] = "\\\\", ["\b"] = "\\b", ["\f"] = "\\f", ["\n"] = "\\n", ["\r"] = "\\r", ["\t"] = "\\t" } local function escapeutf8 (uchar) local value = escapecodes[uchar] if value then return value end local a, b, c, d = strbyte (uchar, 1, 4) a, b, c, d = a or 0, b or 0, c or 0, d or 0 if a <= 0x7f then value = a elseif 0xc0 <= a and a <= 0xdf and b >= 0x80 then value = (a - 0xc0) * 0x40 + b - 0x80 elseif 0xe0 <= a and a <= 0xef and b >= 0x80 and c >= 0x80 then value = ((a - 0xe0) * 0x40 + b - 0x80) * 0x40 + c - 0x80 elseif 0xf0 <= a and a <= 0xf7 and b >= 0x80 and c >= 0x80 and d >= 0x80 then value = (((a - 0xf0) * 0x40 + b - 0x80) * 0x40 + c - 0x80) * 0x40 + d - 0x80 else return "" end if value <= 0xffff then return strformat ("\\u%.4x", value) elseif value <= 0x10ffff then -- encode as UTF-16 surrogate pair value = value - 0x10000 local highsur, lowsur = 0xD800 + floor (value/0x400), 0xDC00 + (value % 0x400) return strformat ("\\u%.4x\\u%.4x", highsur, lowsur) else return "" end end local function fsub (str, pattern, repl) -- gsub always builds a new string in a buffer, even when no match -- exists. First using find should be more efficient when most strings -- don't contain the pattern. if strfind (str, pattern) then return gsub (str, pattern, repl) else return str end end local function quotestring (value) -- based on the regexp "escapable" in https://github.com/douglascrockford/JSON-js value = fsub (value, "[%z\1-\31\"\\\127]", escapeutf8) if strfind (value, "[\194\216\220\225\226\239]") then value = fsub (value, "\194[\128-\159\173]", escapeutf8) value = fsub (value, "\216[\128-\132]", escapeutf8) value = fsub (value, "\220\143", escapeutf8) value = fsub (value, "\225\158[\180\181]", escapeutf8) value = fsub (value, "\226\128[\140-\143\168-\175]", escapeutf8) value = fsub (value, "\226\129[\160-\175]", escapeutf8) value = fsub (value, "\239\187\191", escapeutf8) value = fsub (value, "\239\191[\176-\191]", escapeutf8) end return "\"" .. value .. "\"" end json.quotestring = quotestring local function replace(str, o, n) local i, j = strfind (str, o, 1, true) if i then return strsub(str, 1, i-1) .. n .. strsub(str, j+1, -1) else return str end end -- locale independent num2str and str2num functions local decpoint, numfilter local function updatedecpoint () decpoint = strmatch(tostring(0.5), "([^05+])") -- build a filter that can be used to remove group separators numfilter = "[^0-9%-%+eE" .. gsub(decpoint, "[%^%$%(%)%%%.%[%]%*%+%-%?]", "%%%0") .. "]+" end updatedecpoint() local function num2str (num) return replace(fsub(tostring(num), numfilter, ""), decpoint, ".") end local function str2num (str) local num = tonumber(replace(str, ".", decpoint)) if not num then updatedecpoint() num = tonumber(replace(str, ".", decpoint)) end return num end local function addnewline2 (level, buffer, buflen) buffer[buflen+1] = "\n" buffer[buflen+2] = strrep (" ", level) buflen = buflen + 2 return buflen end function json.addnewline (state) if state.indent then state.bufferlen = addnewline2 (state.level or 0, state.buffer, state.bufferlen or #(state.buffer)) end end local encode2 -- forward declaration local function addpair (key, value, prev, indent, level, buffer, buflen, tables, globalorder) local kt = type (key) if kt ~= 'string' and kt ~= 'number' then return nil, "type '" .. kt .. "' is not supported as a key by JSON." end if prev then buflen = buflen + 1 buffer[buflen] = "," end if indent then buflen = addnewline2 (level, buffer, buflen) end buffer[buflen+1] = quotestring (key) buffer[buflen+2] = ":" return encode2 (value, indent, level, buffer, buflen + 2, tables, globalorder) end encode2 = function (value, indent, level, buffer, buflen, tables, globalorder) local valtype = type (value) local valmeta = getmetatable (value) valmeta = type (valmeta) == 'table' and valmeta -- only tables local valtojson = valmeta and valmeta.__tojson if valtojson then if tables[value] then return nil, "reference cycle" end tables[value] = true local state = { indent = indent, level = level, buffer = buffer, bufferlen = buflen, tables = tables, keyorder = globalorder } local ret, msg = valtojson (value, state) if not ret then return nil, msg end tables[value] = nil buflen = state.bufferlen if type (ret) == 'string' then buflen = buflen + 1 buffer[buflen] = ret end elseif value == nil then buflen = buflen + 1 buffer[buflen] = "null" elseif valtype == 'number' then local s if value ~= value or value >= huge or -value >= huge then -- This is the behaviour of the original JSON implementation. s = "null" else s = num2str (value) end buflen = buflen + 1 buffer[buflen] = s elseif valtype == 'boolean' then buflen = buflen + 1 buffer[buflen] = value and "true" or "false" elseif valtype == 'string' then buflen = buflen + 1 buffer[buflen] = quotestring (value) elseif valtype == 'table' then if tables[value] then return nil, "reference cycle" end tables[value] = true level = level + 1 local isa, n = isarray (value) if n == 0 and valmeta and valmeta.__jsontype == 'object' then isa = false end local msg if isa then -- JSON array buflen = buflen + 1 buffer[buflen] = "[" for i = 1, n do buflen, msg = encode2 (value[i], indent, level, buffer, buflen, tables, globalorder) if not buflen then return nil, msg end if i < n then buflen = buflen + 1 buffer[buflen] = "," end end buflen = buflen + 1 buffer[buflen] = "]" else -- JSON object local prev = false buflen = buflen + 1 buffer[buflen] = "{" local order = valmeta and valmeta.__jsonorder or globalorder if order then local used = {} n = #order for i = 1, n do local k = order[i] local v = value[k] if v then used[k] = true buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder) prev = true -- add a seperator before the next element end end for k,v in pairs (value) do if not used[k] then buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder) if not buflen then return nil, msg end prev = true -- add a seperator before the next element end end else -- unordered for k,v in pairs (value) do buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder) if not buflen then return nil, msg end prev = true -- add a seperator before the next element end end if indent then buflen = addnewline2 (level - 1, buffer, buflen) end buflen = buflen + 1 buffer[buflen] = "}" end tables[value] = nil else return nil, "type '" .. valtype .. "' is not supported by JSON." end return buflen end function json.encode (value, state) state = state or {} local oldbuffer = state.buffer local buffer = oldbuffer or {} updatedecpoint() local ret, msg = encode2 (value, state.indent, state.level or 0, buffer, state.bufferlen or 0, state.tables or {}, state.keyorder) if not ret then error (msg, 2) elseif oldbuffer then state.bufferlen = ret return true else return concat (buffer) end end local function loc (str, where) local line, pos, linepos = 1, 1, 0 while true do pos = strfind (str, "\n", pos, true) if pos and pos < where then line = line + 1 linepos = pos pos = pos + 1 else break end end return "line " .. line .. ", column " .. (where - linepos) end local function unterminated (str, what, where) return nil, strlen (str) + 1, "unterminated " .. what .. " at " .. loc (str, where) end local function scanwhite (str, pos) while true do pos = strfind (str, "%S", pos) if not pos then return nil end if strsub (str, pos, pos + 2) == "\239\187\191" then -- UTF-8 Byte Order Mark pos = pos + 3 else return pos end end end local escapechars = { ["\""] = "\"", ["\\"] = "\\", ["/"] = "/", ["b"] = "\b", ["f"] = "\f", ["n"] = "\n", ["r"] = "\r", ["t"] = "\t" } local function unichar (value) if value < 0 then return nil elseif value <= 0x007f then return strchar (value) elseif value <= 0x07ff then return strchar (0xc0 + floor(value/0x40), 0x80 + (floor(value) % 0x40)) elseif value <= 0xffff then return strchar (0xe0 + floor(value/0x1000), 0x80 + (floor(value/0x40) % 0x40), 0x80 + (floor(value) % 0x40)) elseif value <= 0x10ffff then return strchar (0xf0 + floor(value/0x40000), 0x80 + (floor(value/0x1000) % 0x40), 0x80 + (floor(value/0x40) % 0x40), 0x80 + (floor(value) % 0x40)) else return nil end end local function scanstring (str, pos) local lastpos = pos + 1 local buffer, n = {}, 0 while true do local nextpos = strfind (str, "[\"\\]", lastpos) if not nextpos then return unterminated (str, "string", pos) end if nextpos > lastpos then n = n + 1 buffer[n] = strsub (str, lastpos, nextpos - 1) end if strsub (str, nextpos, nextpos) == "\"" then lastpos = nextpos + 1 break else local escchar = strsub (str, nextpos + 1, nextpos + 1) local value if escchar == "u" then value = tonumber (strsub (str, nextpos + 2, nextpos + 5), 16) if value then local value2 if 0xD800 <= value and value <= 0xDBff then -- we have the high surrogate of UTF-16. Check if there is a -- low surrogate escaped nearby to combine them. if strsub (str, nextpos + 6, nextpos + 7) == "\\u" then value2 = tonumber (strsub (str, nextpos + 8, nextpos + 11), 16) if value2 and 0xDC00 <= value2 and value2 <= 0xDFFF then value = (value - 0xD800) * 0x400 + (value2 - 0xDC00) + 0x10000 else value2 = nil -- in case it was out of range for a low surrogate end end end value = value and unichar (value) if value then if value2 then lastpos = nextpos + 12 else lastpos = nextpos + 6 end end end end if not value then value = escapechars[escchar] or escchar lastpos = nextpos + 2 end n = n + 1 buffer[n] = value end end if n == 1 then return buffer[1], lastpos elseif n > 1 then return concat (buffer), lastpos else return "", lastpos end end local scanvalue -- forward declaration local function scantable (what, closechar, str, startpos, nullval, objectmeta, arraymeta) local len = strlen (str) local tbl, n = {}, 0 local pos = startpos + 1 if what == 'object' then setmetatable (tbl, objectmeta) else setmetatable (tbl, arraymeta) end while true do pos = scanwhite (str, pos) if not pos then return unterminated (str, what, startpos) end local char = strsub (str, pos, pos) if char == closechar then return tbl, pos + 1 end local val1, err val1, pos, err = scanvalue (str, pos, nullval, objectmeta, arraymeta) if err then return nil, pos, err end pos = scanwhite (str, pos) if not pos then return unterminated (str, what, startpos) end char = strsub (str, pos, pos) if char == ":" then if val1 == nil then return nil, pos, "cannot use nil as table index (at " .. loc (str, pos) .. ")" end pos = scanwhite (str, pos + 1) if not pos then return unterminated (str, what, startpos) end local val2 val2, pos, err = scanvalue (str, pos, nullval, objectmeta, arraymeta) if err then return nil, pos, err end tbl[val1] = val2 pos = scanwhite (str, pos) if not pos then return unterminated (str, what, startpos) end char = strsub (str, pos, pos) else n = n + 1 tbl[n] = val1 end if char == "," then pos = pos + 1 end end end scanvalue = function (str, pos, nullval, objectmeta, arraymeta) pos = pos or 1 pos = scanwhite (str, pos) if not pos then return nil, strlen (str) + 1, "no valid JSON value (reached the end)" end local char = strsub (str, pos, pos) if char == "{" then return scantable ('object', "}", str, pos, nullval, objectmeta, arraymeta) elseif char == "[" then return scantable ('array', "]", str, pos, nullval, objectmeta, arraymeta) elseif char == "\"" then return scanstring (str, pos) else local pstart, pend = strfind (str, "^%-?[%d%.]+[eE]?[%+%-]?%d*", pos) if pstart then local number = str2num (strsub (str, pstart, pend)) if number then return number, pend + 1 end end pstart, pend = strfind (str, "^%a%w*", pos) if pstart then local name = strsub (str, pstart, pend) if name == "true" then return true, pend + 1 elseif name == "false" then return false, pend + 1 elseif name == "null" then return nullval, pend + 1 end end return nil, pos, "no valid JSON value at " .. loc (str, pos) end end local function optionalmetatables(...) if select("#", ...) > 0 then return ... else return {__jsontype = 'object'}, {__jsontype = 'array'} end end function json.decode (str, pos, nullval, ...) local objectmeta, arraymeta = optionalmetatables(...) return scanvalue (str, pos, nullval, objectmeta, arraymeta) end function json.use_lpeg () local g = require ("lpeg") if g.version() == "0.11" then error "due to a bug in LPeg 0.11, it cannot be used for JSON matching" end local pegmatch = g.match local P, S, R = g.P, g.S, g.R local function ErrorCall (str, pos, msg, state) if not state.msg then state.msg = msg .. " at " .. loc (str, pos) state.pos = pos end return false end local function Err (msg) return g.Cmt (g.Cc (msg) * g.Carg (2), ErrorCall) end local Space = (S" \n\r\t" + P"\239\187\191")^0 local PlainChar = 1 - S"\"\\\n\r" local EscapeSequence = (P"\\" * g.C (S"\"\\/bfnrt" + Err "unsupported escape sequence")) / escapechars local HexDigit = R("09", "af", "AF") local function UTF16Surrogate (match, pos, high, low) high, low = tonumber (high, 16), tonumber (low, 16) if 0xD800 <= high and high <= 0xDBff and 0xDC00 <= low and low <= 0xDFFF then return true, unichar ((high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000) else return false end end local function UTF16BMP (hex) return unichar (tonumber (hex, 16)) end local U16Sequence = (P"\\u" * g.C (HexDigit * HexDigit * HexDigit * HexDigit)) local UnicodeEscape = g.Cmt (U16Sequence * U16Sequence, UTF16Surrogate) + U16Sequence/UTF16BMP local Char = UnicodeEscape + EscapeSequence + PlainChar local String = P"\"" * g.Cs (Char ^ 0) * (P"\"" + Err "unterminated string") local Integer = P"-"^(-1) * (P"0" + (R"19" * R"09"^0)) local Fractal = P"." * R"09"^0 local Exponent = (S"eE") * (S"+-")^(-1) * R"09"^1 local Number = (Integer * Fractal^(-1) * Exponent^(-1))/str2num local Constant = P"true" * g.Cc (true) + P"false" * g.Cc (false) + P"null" * g.Carg (1) local SimpleValue = Number + String + Constant local ArrayContent, ObjectContent -- The functions parsearray and parseobject parse only a single value/pair -- at a time and store them directly to avoid hitting the LPeg limits. local function parsearray (str, pos, nullval, state) local obj, cont local npos local t, nt = {}, 0 repeat obj, cont, npos = pegmatch (ArrayContent, str, pos, nullval, state) if not npos then break end pos = npos nt = nt + 1 t[nt] = obj until cont == 'last' return pos, setmetatable (t, state.arraymeta) end local function parseobject (str, pos, nullval, state) local obj, key, cont local npos local t = {} repeat key, obj, cont, npos = pegmatch (ObjectContent, str, pos, nullval, state) if not npos then break end pos = npos t[key] = obj until cont == 'last' return pos, setmetatable (t, state.objectmeta) end local Array = P"[" * g.Cmt (g.Carg(1) * g.Carg(2), parsearray) * Space * (P"]" + Err "']' expected") local Object = P"{" * g.Cmt (g.Carg(1) * g.Carg(2), parseobject) * Space * (P"}" + Err "'}' expected") local Value = Space * (Array + Object + SimpleValue) local ExpectedValue = Value + Space * Err "value expected" ArrayContent = Value * Space * (P"," * g.Cc'cont' + g.Cc'last') * g.Cp() local Pair = g.Cg (Space * String * Space * (P":" + Err "colon expected") * ExpectedValue) ObjectContent = Pair * Space * (P"," * g.Cc'cont' + g.Cc'last') * g.Cp() local DecodeValue = ExpectedValue * g.Cp () function json.decode (str, pos, nullval, ...) local state = {} state.objectmeta, state.arraymeta = optionalmetatables(...) local obj, retpos = pegmatch (DecodeValue, str, pos, nullval, state) if state.msg then return nil, state.pos, state.msg else return obj, retpos end end -- use this function only once: json.use_lpeg = function () return json end json.using_lpeg = true return json -- so you can get the module using json = require "dkjson".use_lpeg() end if always_try_using_lpeg then pcall (json.use_lpeg) end return json -->
gpl-2.0
jshackley/darkstar
scripts/zones/Windurst_Walls/npcs/Ambrosius.lua
36
4204
----------------------------------- -- Area: Windurst Walls -- NPC: Ambrosius -- -- Quest NPC for "The Postman Always KOs Twice" ----------------------------------- package.loaded["scripts/zones/Windurst_Walls/TextIDs"] = nil; ----------------------------------- require("scripts/globals/quests"); require("scripts/globals/settings"); require("scripts/zones/Windurst_Walls/TextIDs"); ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) QuestStatus = player:getQuestStatus(WINDURST,THE_POSTMAN_ALWAYS_KO_S_TWICE); if (QuestStatus == QUEST_AVAILABLE) then player:startEvent(0x0030); elseif (QuestStatus == QUEST_ACCEPTED) then player:startEvent(0x0031); elseif (QuestStatus == QUEST_COMPLETED) then player:startEvent(0x0038); end end; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) QuestStatus = player:getQuestStatus(WINDURST,THE_POSTMAN_ALWAYS_KO_S_TWICE); if (QuestStatus ~= QUEST_AVAILABLE) then reward = 0; if (trade:hasItemQty(584,1)) then reward = reward+1 end; if (trade:hasItemQty(585,1)) then reward = reward+1 end; if (trade:hasItemQty(586,1)) then reward = reward+1 end; if (trade:hasItemQty(587,1)) then reward = reward+1 end; if (trade:getItemCount() == reward) then if (reward == 1) then if (QuestStatus == QUEST_ACCEPTED) then player:startEvent(0x0034,GIL_RATE*50); elseif (QuestStatus == QUEST_COMPLETED) then player:startEvent(0x0039,GIL_RATE*50); end elseif (reward == 2) then if (QuestStatus == QUEST_ACCEPTED) then player:startEvent(0x0035,GIL_RATE*150,2); elseif (QuestStatus == QUEST_COMPLETED) then player:startEvent(0x003a,GIL_RATE*150,2); end elseif (reward == 3) then if (QuestStatus == QUEST_ACCEPTED) then player:startEvent(0x0036,GIL_RATE*250,3); elseif (QuestStatus == QUEST_COMPLETED) then player:startEvent(0x003b,GIL_RATE*250,3); end elseif (reward == 4) then if (QuestStatus == QUEST_ACCEPTED) then player:startEvent(0x0037,GIL_RATE*500,4); elseif (QuestStatus == QUEST_COMPLETED) then player:startEvent(0x003c,GIL_RATE*500,4); end end end end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("Update CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("Finish CSID: %u",csid); --printf("RESULT: %u",option); if (csid == 0x0030 and option == 0) then player:addQuest(WINDURST,THE_POSTMAN_ALWAYS_KO_S_TWICE); elseif (csid == 0x0034) then player:tradeComplete(); player:addGil(GIL_RATE*50); player:addFame(WINDURST,WIN_FAME*80); player:completeQuest(WINDURST,THE_POSTMAN_ALWAYS_KO_S_TWICE); elseif (csid == 0x0035) then player:tradeComplete(); player:addGil(GIL_RATE*150); player:addFame(WINDURST,WIN_FAME*80); player:completeQuest(WINDURST,THE_POSTMAN_ALWAYS_KO_S_TWICE); elseif (csid == 0x0036) then player:tradeComplete(); player:addGil(GIL_RATE*250); player:addFame(WINDURST,WIN_FAME*80); player:completeQuest(WINDURST,THE_POSTMAN_ALWAYS_KO_S_TWICE); elseif (csid == 0x0037) then player:tradeComplete(); player:addGil(GIL_RATE*500); player:addFame(WINDURST,WIN_FAME*80); player:completeQuest(WINDURST,THE_POSTMAN_ALWAYS_KO_S_TWICE); elseif (csid == 0x0039) then player:tradeComplete(); player:addGil(GIL_RATE*50); player:addFame(WINDURST,WIN_FAME*5); elseif (csid == 0x003a) then player:tradeComplete(); player:addGil(GIL_RATE*150); player:addFame(WINDURST,WIN_FAME*15); elseif (csid == 0x003b) then player:tradeComplete(); player:addGil(GIL_RATE*250); player:addFame(WINDURST,WIN_FAME*25); elseif (csid == 0x003c) then player:tradeComplete(); player:addGil(GIL_RATE*500); player:addFame(WINDURST,WIN_FAME*50); end end;
gpl-3.0
Th2Evil/SuperPlus
libs/dkjson.lua
3282
26558
-- Module options: local always_try_using_lpeg = true local register_global_module_table = false local global_module_name = 'json' --[==[ David Kolf's JSON module for Lua 5.1/5.2 ======================================== *Version 2.4* In the default configuration this module writes no global values, not even the module table. Import it using json = require ("dkjson") In environments where `require` or a similiar function are not available and you cannot receive the return value of the module, you can set the option `register_global_module_table` to `true`. The module table will then be saved in the global variable with the name given by the option `global_module_name`. Exported functions and values: `json.encode (object [, state])` -------------------------------- Create a string representing the object. `Object` can be a table, a string, a number, a boolean, `nil`, `json.null` or any object with a function `__tojson` in its metatable. A table can only use strings and numbers as keys and its values have to be valid objects as well. It raises an error for any invalid data types or reference cycles. `state` is an optional table with the following fields: - `indent` When `indent` (a boolean) is set, the created string will contain newlines and indentations. Otherwise it will be one long line. - `keyorder` `keyorder` is an array to specify the ordering of keys in the encoded output. If an object has keys which are not in this array they are written after the sorted keys. - `level` This is the initial level of indentation used when `indent` is set. For each level two spaces are added. When absent it is set to 0. - `buffer` `buffer` is an array to store the strings for the result so they can be concatenated at once. When it isn't given, the encode function will create it temporary and will return the concatenated result. - `bufferlen` When `bufferlen` is set, it has to be the index of the last element of `buffer`. - `tables` `tables` is a set to detect reference cycles. It is created temporary when absent. Every table that is currently processed is used as key, the value is `true`. When `state.buffer` was set, the return value will be `true` on success. Without `state.buffer` the return value will be a string. `json.decode (string [, position [, null]])` -------------------------------------------- Decode `string` starting at `position` or at 1 if `position` was omitted. `null` is an optional value to be returned for null values. The default is `nil`, but you could set it to `json.null` or any other value. The return values are the object or `nil`, the position of the next character that doesn't belong to the object, and in case of errors an error message. Two metatables are created. Every array or object that is decoded gets a metatable with the `__jsontype` field set to either `array` or `object`. If you want to provide your own metatables use the syntax json.decode (string, position, null, objectmeta, arraymeta) To prevent the assigning of metatables pass `nil`: json.decode (string, position, null, nil) `<metatable>.__jsonorder` ------------------------- `__jsonorder` can overwrite the `keyorder` for a specific table. `<metatable>.__jsontype` ------------------------ `__jsontype` can be either `"array"` or `"object"`. This value is only checked for empty tables. (The default for empty tables is `"array"`). `<metatable>.__tojson (self, state)` ------------------------------------ You can provide your own `__tojson` function in a metatable. In this function you can either add directly to the buffer and return true, or you can return a string. On errors nil and a message should be returned. `json.null` ----------- You can use this value for setting explicit `null` values. `json.version` -------------- Set to `"dkjson 2.4"`. `json.quotestring (string)` --------------------------- Quote a UTF-8 string and escape critical characters using JSON escape sequences. This function is only necessary when you build your own `__tojson` functions. `json.addnewline (state)` ------------------------- When `state.indent` is set, add a newline to `state.buffer` and spaces according to `state.level`. LPeg support ------------ When the local configuration variable `always_try_using_lpeg` is set, this module tries to load LPeg to replace the `decode` function. The speed increase is significant. You can get the LPeg module at <http://www.inf.puc-rio.br/~roberto/lpeg/>. When LPeg couldn't be loaded, the pure Lua functions stay active. In case you don't want this module to require LPeg on its own, disable the option `always_try_using_lpeg` in the options section at the top of the module. In this case you can later load LPeg support using ### `json.use_lpeg ()` Require the LPeg module and replace the functions `quotestring` and and `decode` with functions that use LPeg patterns. This function returns the module table, so you can load the module using: json = require "dkjson".use_lpeg() Alternatively you can use `pcall` so the JSON module still works when LPeg isn't found. json = require "dkjson" pcall (json.use_lpeg) ### `json.using_lpeg` This variable is set to `true` when LPeg was loaded successfully. --------------------------------------------------------------------- Contact ------- You can contact the author by sending an e-mail to 'david' at the domain 'dkolf.de'. --------------------------------------------------------------------- *Copyright (C) 2010-2013 David Heiko Kolf* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. <!-- This documentation can be parsed using Markdown to generate HTML. The source code is enclosed in a HTML comment so it won't be displayed by browsers, but it should be removed from the final HTML file as it isn't a valid HTML comment (and wastes space). --> <!--]==] -- global dependencies: local pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset = pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset local error, require, pcall, select = error, require, pcall, select local floor, huge = math.floor, math.huge local strrep, gsub, strsub, strbyte, strchar, strfind, strlen, strformat = string.rep, string.gsub, string.sub, string.byte, string.char, string.find, string.len, string.format local strmatch = string.match local concat = table.concat local json = { version = "dkjson 2.4" } if register_global_module_table then _G[global_module_name] = json end local _ENV = nil -- blocking globals in Lua 5.2 pcall (function() -- Enable access to blocked metatables. -- Don't worry, this module doesn't change anything in them. local debmeta = require "debug".getmetatable if debmeta then getmetatable = debmeta end end) json.null = setmetatable ({}, { __tojson = function () return "null" end }) local function isarray (tbl) local max, n, arraylen = 0, 0, 0 for k,v in pairs (tbl) do if k == 'n' and type(v) == 'number' then arraylen = v if v > max then max = v end else if type(k) ~= 'number' or k < 1 or floor(k) ~= k then return false end if k > max then max = k end n = n + 1 end end if max > 10 and max > arraylen and max > n * 2 then return false -- don't create an array with too many holes end return true, max end local escapecodes = { ["\""] = "\\\"", ["\\"] = "\\\\", ["\b"] = "\\b", ["\f"] = "\\f", ["\n"] = "\\n", ["\r"] = "\\r", ["\t"] = "\\t" } local function escapeutf8 (uchar) local value = escapecodes[uchar] if value then return value end local a, b, c, d = strbyte (uchar, 1, 4) a, b, c, d = a or 0, b or 0, c or 0, d or 0 if a <= 0x7f then value = a elseif 0xc0 <= a and a <= 0xdf and b >= 0x80 then value = (a - 0xc0) * 0x40 + b - 0x80 elseif 0xe0 <= a and a <= 0xef and b >= 0x80 and c >= 0x80 then value = ((a - 0xe0) * 0x40 + b - 0x80) * 0x40 + c - 0x80 elseif 0xf0 <= a and a <= 0xf7 and b >= 0x80 and c >= 0x80 and d >= 0x80 then value = (((a - 0xf0) * 0x40 + b - 0x80) * 0x40 + c - 0x80) * 0x40 + d - 0x80 else return "" end if value <= 0xffff then return strformat ("\\u%.4x", value) elseif value <= 0x10ffff then -- encode as UTF-16 surrogate pair value = value - 0x10000 local highsur, lowsur = 0xD800 + floor (value/0x400), 0xDC00 + (value % 0x400) return strformat ("\\u%.4x\\u%.4x", highsur, lowsur) else return "" end end local function fsub (str, pattern, repl) -- gsub always builds a new string in a buffer, even when no match -- exists. First using find should be more efficient when most strings -- don't contain the pattern. if strfind (str, pattern) then return gsub (str, pattern, repl) else return str end end local function quotestring (value) -- based on the regexp "escapable" in https://github.com/douglascrockford/JSON-js value = fsub (value, "[%z\1-\31\"\\\127]", escapeutf8) if strfind (value, "[\194\216\220\225\226\239]") then value = fsub (value, "\194[\128-\159\173]", escapeutf8) value = fsub (value, "\216[\128-\132]", escapeutf8) value = fsub (value, "\220\143", escapeutf8) value = fsub (value, "\225\158[\180\181]", escapeutf8) value = fsub (value, "\226\128[\140-\143\168-\175]", escapeutf8) value = fsub (value, "\226\129[\160-\175]", escapeutf8) value = fsub (value, "\239\187\191", escapeutf8) value = fsub (value, "\239\191[\176-\191]", escapeutf8) end return "\"" .. value .. "\"" end json.quotestring = quotestring local function replace(str, o, n) local i, j = strfind (str, o, 1, true) if i then return strsub(str, 1, i-1) .. n .. strsub(str, j+1, -1) else return str end end -- locale independent num2str and str2num functions local decpoint, numfilter local function updatedecpoint () decpoint = strmatch(tostring(0.5), "([^05+])") -- build a filter that can be used to remove group separators numfilter = "[^0-9%-%+eE" .. gsub(decpoint, "[%^%$%(%)%%%.%[%]%*%+%-%?]", "%%%0") .. "]+" end updatedecpoint() local function num2str (num) return replace(fsub(tostring(num), numfilter, ""), decpoint, ".") end local function str2num (str) local num = tonumber(replace(str, ".", decpoint)) if not num then updatedecpoint() num = tonumber(replace(str, ".", decpoint)) end return num end local function addnewline2 (level, buffer, buflen) buffer[buflen+1] = "\n" buffer[buflen+2] = strrep (" ", level) buflen = buflen + 2 return buflen end function json.addnewline (state) if state.indent then state.bufferlen = addnewline2 (state.level or 0, state.buffer, state.bufferlen or #(state.buffer)) end end local encode2 -- forward declaration local function addpair (key, value, prev, indent, level, buffer, buflen, tables, globalorder) local kt = type (key) if kt ~= 'string' and kt ~= 'number' then return nil, "type '" .. kt .. "' is not supported as a key by JSON." end if prev then buflen = buflen + 1 buffer[buflen] = "," end if indent then buflen = addnewline2 (level, buffer, buflen) end buffer[buflen+1] = quotestring (key) buffer[buflen+2] = ":" return encode2 (value, indent, level, buffer, buflen + 2, tables, globalorder) end encode2 = function (value, indent, level, buffer, buflen, tables, globalorder) local valtype = type (value) local valmeta = getmetatable (value) valmeta = type (valmeta) == 'table' and valmeta -- only tables local valtojson = valmeta and valmeta.__tojson if valtojson then if tables[value] then return nil, "reference cycle" end tables[value] = true local state = { indent = indent, level = level, buffer = buffer, bufferlen = buflen, tables = tables, keyorder = globalorder } local ret, msg = valtojson (value, state) if not ret then return nil, msg end tables[value] = nil buflen = state.bufferlen if type (ret) == 'string' then buflen = buflen + 1 buffer[buflen] = ret end elseif value == nil then buflen = buflen + 1 buffer[buflen] = "null" elseif valtype == 'number' then local s if value ~= value or value >= huge or -value >= huge then -- This is the behaviour of the original JSON implementation. s = "null" else s = num2str (value) end buflen = buflen + 1 buffer[buflen] = s elseif valtype == 'boolean' then buflen = buflen + 1 buffer[buflen] = value and "true" or "false" elseif valtype == 'string' then buflen = buflen + 1 buffer[buflen] = quotestring (value) elseif valtype == 'table' then if tables[value] then return nil, "reference cycle" end tables[value] = true level = level + 1 local isa, n = isarray (value) if n == 0 and valmeta and valmeta.__jsontype == 'object' then isa = false end local msg if isa then -- JSON array buflen = buflen + 1 buffer[buflen] = "[" for i = 1, n do buflen, msg = encode2 (value[i], indent, level, buffer, buflen, tables, globalorder) if not buflen then return nil, msg end if i < n then buflen = buflen + 1 buffer[buflen] = "," end end buflen = buflen + 1 buffer[buflen] = "]" else -- JSON object local prev = false buflen = buflen + 1 buffer[buflen] = "{" local order = valmeta and valmeta.__jsonorder or globalorder if order then local used = {} n = #order for i = 1, n do local k = order[i] local v = value[k] if v then used[k] = true buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder) prev = true -- add a seperator before the next element end end for k,v in pairs (value) do if not used[k] then buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder) if not buflen then return nil, msg end prev = true -- add a seperator before the next element end end else -- unordered for k,v in pairs (value) do buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder) if not buflen then return nil, msg end prev = true -- add a seperator before the next element end end if indent then buflen = addnewline2 (level - 1, buffer, buflen) end buflen = buflen + 1 buffer[buflen] = "}" end tables[value] = nil else return nil, "type '" .. valtype .. "' is not supported by JSON." end return buflen end function json.encode (value, state) state = state or {} local oldbuffer = state.buffer local buffer = oldbuffer or {} updatedecpoint() local ret, msg = encode2 (value, state.indent, state.level or 0, buffer, state.bufferlen or 0, state.tables or {}, state.keyorder) if not ret then error (msg, 2) elseif oldbuffer then state.bufferlen = ret return true else return concat (buffer) end end local function loc (str, where) local line, pos, linepos = 1, 1, 0 while true do pos = strfind (str, "\n", pos, true) if pos and pos < where then line = line + 1 linepos = pos pos = pos + 1 else break end end return "line " .. line .. ", column " .. (where - linepos) end local function unterminated (str, what, where) return nil, strlen (str) + 1, "unterminated " .. what .. " at " .. loc (str, where) end local function scanwhite (str, pos) while true do pos = strfind (str, "%S", pos) if not pos then return nil end if strsub (str, pos, pos + 2) == "\239\187\191" then -- UTF-8 Byte Order Mark pos = pos + 3 else return pos end end end local escapechars = { ["\""] = "\"", ["\\"] = "\\", ["/"] = "/", ["b"] = "\b", ["f"] = "\f", ["n"] = "\n", ["r"] = "\r", ["t"] = "\t" } local function unichar (value) if value < 0 then return nil elseif value <= 0x007f then return strchar (value) elseif value <= 0x07ff then return strchar (0xc0 + floor(value/0x40), 0x80 + (floor(value) % 0x40)) elseif value <= 0xffff then return strchar (0xe0 + floor(value/0x1000), 0x80 + (floor(value/0x40) % 0x40), 0x80 + (floor(value) % 0x40)) elseif value <= 0x10ffff then return strchar (0xf0 + floor(value/0x40000), 0x80 + (floor(value/0x1000) % 0x40), 0x80 + (floor(value/0x40) % 0x40), 0x80 + (floor(value) % 0x40)) else return nil end end local function scanstring (str, pos) local lastpos = pos + 1 local buffer, n = {}, 0 while true do local nextpos = strfind (str, "[\"\\]", lastpos) if not nextpos then return unterminated (str, "string", pos) end if nextpos > lastpos then n = n + 1 buffer[n] = strsub (str, lastpos, nextpos - 1) end if strsub (str, nextpos, nextpos) == "\"" then lastpos = nextpos + 1 break else local escchar = strsub (str, nextpos + 1, nextpos + 1) local value if escchar == "u" then value = tonumber (strsub (str, nextpos + 2, nextpos + 5), 16) if value then local value2 if 0xD800 <= value and value <= 0xDBff then -- we have the high surrogate of UTF-16. Check if there is a -- low surrogate escaped nearby to combine them. if strsub (str, nextpos + 6, nextpos + 7) == "\\u" then value2 = tonumber (strsub (str, nextpos + 8, nextpos + 11), 16) if value2 and 0xDC00 <= value2 and value2 <= 0xDFFF then value = (value - 0xD800) * 0x400 + (value2 - 0xDC00) + 0x10000 else value2 = nil -- in case it was out of range for a low surrogate end end end value = value and unichar (value) if value then if value2 then lastpos = nextpos + 12 else lastpos = nextpos + 6 end end end end if not value then value = escapechars[escchar] or escchar lastpos = nextpos + 2 end n = n + 1 buffer[n] = value end end if n == 1 then return buffer[1], lastpos elseif n > 1 then return concat (buffer), lastpos else return "", lastpos end end local scanvalue -- forward declaration local function scantable (what, closechar, str, startpos, nullval, objectmeta, arraymeta) local len = strlen (str) local tbl, n = {}, 0 local pos = startpos + 1 if what == 'object' then setmetatable (tbl, objectmeta) else setmetatable (tbl, arraymeta) end while true do pos = scanwhite (str, pos) if not pos then return unterminated (str, what, startpos) end local char = strsub (str, pos, pos) if char == closechar then return tbl, pos + 1 end local val1, err val1, pos, err = scanvalue (str, pos, nullval, objectmeta, arraymeta) if err then return nil, pos, err end pos = scanwhite (str, pos) if not pos then return unterminated (str, what, startpos) end char = strsub (str, pos, pos) if char == ":" then if val1 == nil then return nil, pos, "cannot use nil as table index (at " .. loc (str, pos) .. ")" end pos = scanwhite (str, pos + 1) if not pos then return unterminated (str, what, startpos) end local val2 val2, pos, err = scanvalue (str, pos, nullval, objectmeta, arraymeta) if err then return nil, pos, err end tbl[val1] = val2 pos = scanwhite (str, pos) if not pos then return unterminated (str, what, startpos) end char = strsub (str, pos, pos) else n = n + 1 tbl[n] = val1 end if char == "," then pos = pos + 1 end end end scanvalue = function (str, pos, nullval, objectmeta, arraymeta) pos = pos or 1 pos = scanwhite (str, pos) if not pos then return nil, strlen (str) + 1, "no valid JSON value (reached the end)" end local char = strsub (str, pos, pos) if char == "{" then return scantable ('object', "}", str, pos, nullval, objectmeta, arraymeta) elseif char == "[" then return scantable ('array', "]", str, pos, nullval, objectmeta, arraymeta) elseif char == "\"" then return scanstring (str, pos) else local pstart, pend = strfind (str, "^%-?[%d%.]+[eE]?[%+%-]?%d*", pos) if pstart then local number = str2num (strsub (str, pstart, pend)) if number then return number, pend + 1 end end pstart, pend = strfind (str, "^%a%w*", pos) if pstart then local name = strsub (str, pstart, pend) if name == "true" then return true, pend + 1 elseif name == "false" then return false, pend + 1 elseif name == "null" then return nullval, pend + 1 end end return nil, pos, "no valid JSON value at " .. loc (str, pos) end end local function optionalmetatables(...) if select("#", ...) > 0 then return ... else return {__jsontype = 'object'}, {__jsontype = 'array'} end end function json.decode (str, pos, nullval, ...) local objectmeta, arraymeta = optionalmetatables(...) return scanvalue (str, pos, nullval, objectmeta, arraymeta) end function json.use_lpeg () local g = require ("lpeg") if g.version() == "0.11" then error "due to a bug in LPeg 0.11, it cannot be used for JSON matching" end local pegmatch = g.match local P, S, R = g.P, g.S, g.R local function ErrorCall (str, pos, msg, state) if not state.msg then state.msg = msg .. " at " .. loc (str, pos) state.pos = pos end return false end local function Err (msg) return g.Cmt (g.Cc (msg) * g.Carg (2), ErrorCall) end local Space = (S" \n\r\t" + P"\239\187\191")^0 local PlainChar = 1 - S"\"\\\n\r" local EscapeSequence = (P"\\" * g.C (S"\"\\/bfnrt" + Err "unsupported escape sequence")) / escapechars local HexDigit = R("09", "af", "AF") local function UTF16Surrogate (match, pos, high, low) high, low = tonumber (high, 16), tonumber (low, 16) if 0xD800 <= high and high <= 0xDBff and 0xDC00 <= low and low <= 0xDFFF then return true, unichar ((high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000) else return false end end local function UTF16BMP (hex) return unichar (tonumber (hex, 16)) end local U16Sequence = (P"\\u" * g.C (HexDigit * HexDigit * HexDigit * HexDigit)) local UnicodeEscape = g.Cmt (U16Sequence * U16Sequence, UTF16Surrogate) + U16Sequence/UTF16BMP local Char = UnicodeEscape + EscapeSequence + PlainChar local String = P"\"" * g.Cs (Char ^ 0) * (P"\"" + Err "unterminated string") local Integer = P"-"^(-1) * (P"0" + (R"19" * R"09"^0)) local Fractal = P"." * R"09"^0 local Exponent = (S"eE") * (S"+-")^(-1) * R"09"^1 local Number = (Integer * Fractal^(-1) * Exponent^(-1))/str2num local Constant = P"true" * g.Cc (true) + P"false" * g.Cc (false) + P"null" * g.Carg (1) local SimpleValue = Number + String + Constant local ArrayContent, ObjectContent -- The functions parsearray and parseobject parse only a single value/pair -- at a time and store them directly to avoid hitting the LPeg limits. local function parsearray (str, pos, nullval, state) local obj, cont local npos local t, nt = {}, 0 repeat obj, cont, npos = pegmatch (ArrayContent, str, pos, nullval, state) if not npos then break end pos = npos nt = nt + 1 t[nt] = obj until cont == 'last' return pos, setmetatable (t, state.arraymeta) end local function parseobject (str, pos, nullval, state) local obj, key, cont local npos local t = {} repeat key, obj, cont, npos = pegmatch (ObjectContent, str, pos, nullval, state) if not npos then break end pos = npos t[key] = obj until cont == 'last' return pos, setmetatable (t, state.objectmeta) end local Array = P"[" * g.Cmt (g.Carg(1) * g.Carg(2), parsearray) * Space * (P"]" + Err "']' expected") local Object = P"{" * g.Cmt (g.Carg(1) * g.Carg(2), parseobject) * Space * (P"}" + Err "'}' expected") local Value = Space * (Array + Object + SimpleValue) local ExpectedValue = Value + Space * Err "value expected" ArrayContent = Value * Space * (P"," * g.Cc'cont' + g.Cc'last') * g.Cp() local Pair = g.Cg (Space * String * Space * (P":" + Err "colon expected") * ExpectedValue) ObjectContent = Pair * Space * (P"," * g.Cc'cont' + g.Cc'last') * g.Cp() local DecodeValue = ExpectedValue * g.Cp () function json.decode (str, pos, nullval, ...) local state = {} state.objectmeta, state.arraymeta = optionalmetatables(...) local obj, retpos = pegmatch (DecodeValue, str, pos, nullval, state) if state.msg then return nil, state.pos, state.msg else return obj, retpos end end -- use this function only once: json.use_lpeg = function () return json end json.using_lpeg = true return json -- so you can get the module using json = require "dkjson".use_lpeg() end if always_try_using_lpeg then pcall (json.use_lpeg) end return json -->
gpl-2.0
10sa/Advanced-Nutscript
nutscript/gamemode/cl_config.lua
1
1169
-- Whether or not the money is shown in the side menu. nut.config.Register("showMoney", true, CLIENT); -- Whether or not the time is shown in the side menu. nut.config.Register("showTime", true, CLIENT); -- If set to false, then color correction will not be enabled. nut.config.Register("sadColors", true, CLIENT); -- Whether or not to enable the crosshair. nut.config.Register("crosshair", false, CLIENT); -- The dot size of the crosshair. nut.config.Register("crossSize", 1, CLIENT); -- The amount of spacing beween each crosshair dot in pixels. nut.config.Register("crossSpacing", 6, CLIENT); -- How 'see-through' the crosshair is from 0-255, where 0 is invisible and 255 is fully -- visible. nut.config.Register("crossAlpha", 150, CLIENT); AdvNut.hook.Add("SchemaInitialized", "nut_FontConfig", function() nut.config.Register("targetTall", 0, CLIENT); surface.SetFont("nut_TargetFontSmall"); _, tall = surface.GetTextSize("W"); nut.config.Set("targetTall", tall or 0); if (nut.config.Get("targetTall")) then nut.config.Set("targetTall", nut.config.Get("targetTall") + 2); end nut.config.Set("targetTall", nut.config.Get("targetTall") or 10); end)
mit
jshackley/darkstar
scripts/globals/items/hamsi.lua
18
1254
----------------------------------------- -- ID: 5449 -- Item: Hamsi -- Food Effect: 5Min, Mithra only ----------------------------------------- -- Dexterity 1 -- Mind -3 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) result = 0 if (target:getRace() ~= 7) then result = 247; end if (target:getMod(MOD_EAT_RAW_FISH) == 1) then result = 0; end if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,300,5449); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_DEX, 1); target:addMod(MOD_MND, -3); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_DEX, 1); target:delMod(MOD_MND, -3); end;
gpl-3.0
VincentGong/chess
cocos2d-x/cocos/scripting/lua-bindings/auto/api/PhysicsContact.lua
6
1081
-------------------------------- -- @module PhysicsContact -- @extend EventCustom -------------------------------- -- @function [parent=#PhysicsContact] getContactData -- @param self -- @return PhysicsContactData#PhysicsContactData ret (return value: cc.PhysicsContactData) -------------------------------- -- @function [parent=#PhysicsContact] getEventCode -- @param self -- @return PhysicsContact::EventCode#PhysicsContact::EventCode ret (return value: cc.PhysicsContact::EventCode) -------------------------------- -- @function [parent=#PhysicsContact] getPreContactData -- @param self -- @return PhysicsContactData#PhysicsContactData ret (return value: cc.PhysicsContactData) -------------------------------- -- @function [parent=#PhysicsContact] getShapeA -- @param self -- @return PhysicsShape#PhysicsShape ret (return value: cc.PhysicsShape) -------------------------------- -- @function [parent=#PhysicsContact] getShapeB -- @param self -- @return PhysicsShape#PhysicsShape ret (return value: cc.PhysicsShape) return nil
mit
LuaDist/lua-uri
uri/file.lua
2
1729
local M = { _NAME = "uri.file" } local Util = require "uri._util" local URI = require "uri" Util.subclass_of(M, URI) function M.init (self) if self:userinfo() or self:port() then return nil, "usernames and passwords are not allowed in HTTP URIs" end local host = self:host() local path = self:path() if host then if host:lower() == "localhost" then self:host("") end else if not path:find("^/") then return nil, "file URIs must contain a host, even if it's empty" end self:host("") end if path == "" then self:path("/") end return self end function M.host (self, ...) local old = M._SUPER.host(self) if select('#', ...) > 0 then local new = ... if not new then error("file URIs must have an authority part") end if new:lower() == "localhost" then new = "" end M._SUPER.host(self, new) end return old end function M.path (self, ...) local old = M._SUPER.path(self) if select('#', ...) > 0 then local new = ... if not new or new == "" then new = "/" end M._SUPER.path(self, new) end return old end local function _os_implementation (os) local FileImpl = Util.attempt_require("uri.file." .. os:lower()) if not FileImpl then error("no file URI implementation for operating system " .. os) end return FileImpl end function M.filesystem_path (self, os) return _os_implementation(os).filesystem_path(self) end function M.make_file_uri (path, os) return _os_implementation(os).make_file_uri(path) end Util.uri_part_not_allowed(M, "userinfo") Util.uri_part_not_allowed(M, "port") return M -- vi:ts=4 sw=4 expandtab
mit
jshackley/darkstar
scripts/zones/Aht_Urhgan_Whitegate/npcs/Asrahd.lua
29
2736
----------------------------------- -- Area: Aht Urhgan Whitegate -- NPC: Asrahd -- Type: Imperial Gate Guard -- @pos 0.011 -1 10.587 50 ----------------------------------- package.loaded["scripts/zones/Aht_Urhgan_Whitegate/TextIDs"] = nil; ----------------------------------- require("scripts/globals/status"); require("scripts/globals/besieged"); require("scripts/zones/Aht_Urhgan_Whitegate/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local merc_rank = getMercenaryRank(player) if (merc_rank == 0) then player:startEvent(0x0277,npc) else maps = getMapBitmask(player); if (getAstralCandescence() == 1) then maps = maps + 0x80000000; end x,y,z,w = getImperialDefenseStats(); player:startEvent(0x0276,player:getCurrency("imperial_standing"),maps,merc_rank,0,x,y,z,w); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x0276 and option >= 1 and option <= 2049) then itemid = getISPItem(option) player:updateEvent(0,0,0,canEquip(player,itemid)) end end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); if (csid == 0x276) then if (option == 0 or option == 16 or option == 32 or option == 48) then -- player chose sanction. if (option ~= 0) then player:delCurrency("imperial_standing", 100); end player:delStatusEffect(EFFECT_SIGIL); player:delStatusEffect(EFFECT_SANCTION); player:delStatusEffect(EFFECT_SIGNET); local duration = getSanctionDuration(player); local subPower = 0; -- getImperialDefenseStats() player:addStatusEffect(EFFECT_SANCTION,option / 16,0,duration,subPower); -- effect size 1 = regen, 2 = refresh, 3 = food. player:messageSpecial(SANCTION); elseif (option % 256 == 17) then -- player bought one of the maps id = 1862 + (option - 17) / 256; player:addKeyItem(id); player:messageSpecial(KEYITEM_OBTAINED,id); player:delCurrency("imperial_standing", 1000); elseif (option <= 2049) then -- player bought item item, price = getISPItem(option) if (player:getFreeSlotsCount() > 0) then player:delCurrency("imperial_standing", price); player:addItem(item); player:messageSpecial(ITEM_OBTAINED,item); else player:messageSpecial(ITEM_CANNOT_BE_OBTAINED,item); end end end end;
gpl-3.0
snorecore/spooplights
init.lua
1
1124
-- Copyright (C) 2015 snorecore -- spooplights - init script -- Created: Sun 18th Oct 2015 CONFIG_SCRIPT = "init_config.lua" SCRIPT = "spoopy.lua" USER_BUTTON = 3 -- Utility functions function file_exists(filename) local f = file.open(filename, "r") if f ~= nil then file.close() return true else return false end end pressed = false function run_scripts() if not pressed then -- Check files exist if not file_exists(CONFIG_SCRIPT) then print ("Config script \""..CONFIG_SCRIPT.."\" not found.") else print ("Running config script \""..CONFIG_SCRIPT.."\".") dofile(CONFIG_SCRIPT) end if not file_exists(SCRIPT) then print ("Main Script \""..SCRIPT.."\" not found.") else print ("Running main script \""..SCRIPT.."\".") dofile(SCRIPT) end end end -- Main code -- Setup button interrupt gpio.mode(USER_BUTTON, gpio.INT) gpio.trig(USER_BUTTON, "down", function() pressed = true print("Execution interrupted.") gpio.mode(USER_BUTTON, gpio.FLOAT) end ) -- Run script after delay tmr.alarm(0, 5000, 0, run_scripts)
gpl-2.0
DipColor/mehrabon3
plugins/banhammer.lua
175
5896
local function is_user_whitelisted(id) local hash = 'whitelist:user#id'..id local white = redis:get(hash) or false return white end local function is_chat_whitelisted(id) local hash = 'whitelist:chat#id'..id local white = redis:get(hash) or false return white end local function kick_user(user_id, chat_id) local chat = 'chat#id'..chat_id local user = 'user#id'..user_id if user_id == tostring(our_id) then send_msg(chat, "I won't kick myself!", ok_cb, true) else chat_del_user(chat, user, ok_cb, true) end end local function ban_user(user_id, chat_id) local chat = 'chat#id'..chat_id if user_id == tostring(our_id) then send_msg(chat, "I won't kick myself!", ok_cb, true) else -- Save to redis local hash = 'banned:'..chat_id..':'..user_id redis:set(hash, true) -- Kick from chat kick_user(user_id, chat_id) end end local function is_banned(user_id, chat_id) local hash = 'banned:'..chat_id..':'..user_id local banned = redis:get(hash) return banned or false end local function pre_process(msg) -- SERVICE MESSAGE if msg.action and msg.action.type then local action = msg.action.type -- Check if banned user joins chat if action == 'chat_add_user' or action == 'chat_add_user_link' then local user_id if msg.action.link_issuer then user_id = msg.from.id else user_id = msg.action.user.id end print('Checking invited user '..user_id) local banned = is_banned(user_id, msg.to.id) if banned then print('User is banned!') kick_user(user_id, msg.to.id) end end -- No further checks return msg end -- BANNED USER TALKING if msg.to.type == 'chat' then local user_id = msg.from.id local chat_id = msg.to.id local banned = is_banned(user_id, chat_id) if banned then print('Banned user talking!') ban_user(user_id, chat_id) msg.text = '' end end -- WHITELIST local hash = 'whitelist:enabled' local whitelist = redis:get(hash) local issudo = is_sudo(msg) -- Allow all sudo users even if whitelist is allowed if whitelist and not issudo then print('Whitelist enabled and not sudo') -- Check if user or chat is whitelisted local allowed = is_user_whitelisted(msg.from.id) if not allowed then print('User '..msg.from.id..' not whitelisted') if msg.to.type == 'chat' then allowed = is_chat_whitelisted(msg.to.id) if not allowed then print ('Chat '..msg.to.id..' not whitelisted') else print ('Chat '..msg.to.id..' whitelisted :)') end end else print('User '..msg.from.id..' allowed :)') end if not allowed then msg.text = '' end else print('Whitelist not enabled or is sudo') end return msg end local function run(msg, matches) -- Silent ignore if not is_sudo(msg) then return nil end if matches[1] == 'ban' then local user_id = matches[3] local chat_id = msg.to.id if msg.to.type == 'chat' then if matches[2] == 'user' then ban_user(user_id, chat_id) return 'User '..user_id..' banned' end if matches[2] == 'delete' then local hash = 'banned:'..chat_id..':'..user_id redis:del(hash) return 'User '..user_id..' unbanned' end else return 'This isn\'t a chat group' end end if matches[1] == 'kick' then if msg.to.type == 'chat' then kick_user(matches[2], msg.to.id) else return 'This isn\'t a chat group' end end if matches[1] == 'whitelist' then if matches[2] == 'enable' then local hash = 'whitelist:enabled' redis:set(hash, true) return 'Enabled whitelist' end if matches[2] == 'disable' then local hash = 'whitelist:enabled' redis:del(hash) return 'Disabled whitelist' end if matches[2] == 'user' then local hash = 'whitelist:user#id'..matches[3] redis:set(hash, true) return 'User '..matches[3]..' whitelisted' end if matches[2] == 'chat' then if msg.to.type ~= 'chat' then return 'This isn\'t a chat group' end local hash = 'whitelist:chat#id'..msg.to.id redis:set(hash, true) return 'Chat '..msg.to.id..' whitelisted' end if matches[2] == 'delete' and matches[3] == 'user' then local hash = 'whitelist:user#id'..matches[4] redis:del(hash) return 'User '..matches[4]..' removed from whitelist' end if matches[2] == 'delete' and matches[3] == 'chat' then if msg.to.type ~= 'chat' then return 'This isn\'t a chat group' end local hash = 'whitelist:chat#id'..msg.to.id redis:del(hash) return 'Chat '..msg.to.id..' removed from whitelist' end end end return { description = "Plugin to manage bans, kicks and white/black lists.", usage = { "!whitelist <enable>/<disable>: Enable or disable whitelist mode", "!whitelist user <user_id>: Allow user to use the bot when whitelist mode is enabled", "!whitelist chat: Allow everybody on current chat to use the bot when whitelist mode is enabled", "!whitelist delete user <user_id>: Remove user from whitelist", "!whitelist delete chat: Remove chat from whitelist", "!ban user <user_id>: Kick user from chat and kicks it if joins chat again", "!ban delete <user_id>: Unban user", "!kick <user_id> Kick user from chat group" }, patterns = { "^!(whitelist) (enable)$", "^!(whitelist) (disable)$", "^!(whitelist) (user) (%d+)$", "^!(whitelist) (chat)$", "^!(whitelist) (delete) (user) (%d+)$", "^!(whitelist) (delete) (chat)$", "^!(ban) (user) (%d+)$", "^!(ban) (delete) (%d+)$", "^!(kick) (%d+)$", "^!!tgservice (.+)$", }, run = run, pre_process = pre_process }
gpl-2.0
jshackley/darkstar
scripts/zones/Kazham/npcs/Kukupp.lua
15
5735
----------------------------------- -- Area: Kazham -- NPC: Kukupp -- Standard Info NPC ----------------------------------- package.loaded["scripts/zones/Kazham/TextIDs"] = nil; require("scripts/zones/Kazham/TextIDs"); require("scripts/globals/pathfind"); local path = { 43.067505, -11.000000, -177.214966, 43.583324, -11.000000, -178.104263, 44.581100, -11.000000, -178.253067, 45.459488, -11.000000, -177.616653, 44.988266, -11.000000, -176.728577, 43.920345, -11.000000, -176.549469, 42.843422, -11.000000, -176.469452, 41.840969, -11.000000, -176.413971, 41.849968, -11.000000, -177.460236, 42.699162, -11.000000, -178.046478, 41.800228, -11.000000, -177.440720, 40.896564, -11.000000, -176.834793, 41.800350, -11.000000, -177.440704, 43.494385, -11.000000, -178.577087, 44.525345, -11.000000, -178.332214, 45.382175, -11.000000, -177.664185, 44.612972, -11.000000, -178.457062, 43.574627, -11.000000, -178.455185, 42.603222, -11.000000, -177.950760, 41.747925, -11.000000, -177.402481, 40.826141, -11.000000, -176.787674, 41.709877, -11.000000, -177.380173, 42.570263, -11.000000, -177.957306, 43.600094, -11.000000, -178.648087, 44.603924, -11.000000, -178.268082, 45.453266, -11.000000, -177.590103, 44.892513, -11.000000, -176.698730, 43.765514, -11.000000, -176.532211, 42.616215, -11.000000, -176.454498, 41.549683, -11.000000, -176.399078, 42.671898, -11.000000, -176.463196, 43.670380, -11.000000, -176.518692, 45.595409, -11.000000, -176.626129, 44.485180, -11.000000, -176.564041, 43.398880, -11.000000, -176.503586, 40.778934, -11.000000, -176.357834, 41.781410, -11.000000, -176.413223, 42.799843, -11.000000, -176.469894, 45.758560, -11.000000, -176.782486, 45.296803, -11.000000, -177.683472, 44.568489, -11.000000, -178.516357, 45.321579, -11.000000, -177.759048, 45.199261, -11.000000, -176.765274, 44.072094, -11.000000, -176.558044, 43.054935, -11.000000, -176.482895, 41.952633, -11.000000, -176.421570, 43.014915, -11.000000, -176.482178, 45.664345, -11.000000, -176.790253, 45.225407, -11.000000, -177.712463, 44.465252, -11.000000, -178.519577, 43.388020, -11.000000, -178.364532, 42.406048, -11.000000, -177.838013, 41.515419, -11.000000, -177.255875, 40.609776, -11.000000, -176.645706 }; function onSpawn(npc) npc:initNpcAi(); npc:setPos(pathfind.first(path)); onPath(npc); end; function onPath(npc) pathfind.patrol(npc, path); end; ----------------------------------- -- onTrade Action ----------------------------------- -- item IDs -- 483 Broken Mithran Fishing Rod -- 22 Workbench -- 1008 Ten of Coins -- 1157 Sands of Silence -- 1158 Wandering Bulb -- 904 Giant Fish Bones -- 4599 Blackened Toad -- 905 Wyvern Skull -- 1147 Ancient Salt -- 4600 Lucky Egg function onTrade(player,npc,trade) local OpoOpoAndIStatus = player:getQuestStatus(OUTLANDS, THE_OPO_OPO_AND_I); local progress = player:getVar("OPO_OPO_PROGRESS"); local failed = player:getVar("OPO_OPO_FAILED"); local goodtrade = trade:hasItemQty(22,1); local badtrade = (trade:hasItemQty(483,1) or trade:hasItemQty(1008,1) or trade:hasItemQty(1157,1) or trade:hasItemQty(1158,1) or trade:hasItemQty(904,1) or trade:hasItemQty(4599,1) or trade:hasItemQty(905,1) or trade:hasItemQty(1147,1) or trade:hasItemQty(4600,1)); if (OpoOpoAndIStatus == QUEST_ACCEPTED) then if progress == 1 or failed == 2 then if goodtrade then player:startEvent(0x00DC); elseif badtrade then player:startEvent(0x00E6); end end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local OpoOpoAndIStatus = player:getQuestStatus(OUTLANDS, THE_OPO_OPO_AND_I); local progress = player:getVar("OPO_OPO_PROGRESS"); local failed = player:getVar("OPO_OPO_FAILED"); local retry = player:getVar("OPO_OPO_RETRY"); if (OpoOpoAndIStatus == QUEST_ACCEPTED) then if retry >= 1 then -- has failed on future npc so disregard previous successful trade player:startEvent(0x00C6); npc:wait(-1); elseif (progress == 1 or failed == 2) then player:startEvent(0x00D0); -- asking for workbench elseif (progress >= 2 or failed >= 3) then player:startEvent(0x00F3); -- happy with workbench end else player:startEvent(0x00C6); npc:wait(-1); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option,npc) --printf("CSID: %u",csid); --printf("RESULT: %u",option); if (csid == 0x00DC) then -- correct trade, onto next opo if player:getVar("OPO_OPO_PROGRESS") == 1 then player:tradeComplete(); player:setVar("OPO_OPO_PROGRESS",2); player:setVar("OPO_OPO_FAILED",0); else player:setVar("OPO_OPO_FAILED",3); end elseif (csid == 0x00E6) then -- wrong trade, restart at first opo player:setVar("OPO_OPO_FAILED",1); player:setVar("OPO_OPO_RETRY",2); else npc:wait(0); end end;
gpl-3.0
jshackley/darkstar
scripts/globals/items/wild_onion.lua
35
1193
----------------------------------------- -- ID: 4387 -- Item: wild_onion -- Food Effect: 5Min, All Races ----------------------------------------- -- Agility 4 -- Vitality -6 ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnItemCheck ----------------------------------------- function onItemCheck(target) local result = 0; if (target:hasStatusEffect(EFFECT_FOOD) == true or target:hasStatusEffect(EFFECT_FIELD_SUPPORT_FOOD) == true) then result = 246; end return result; end; ----------------------------------------- -- OnItemUse ----------------------------------------- function onItemUse(target) target:addStatusEffect(EFFECT_FOOD,0,0,300,4387); end; ----------------------------------- -- onEffectGain Action ----------------------------------- function onEffectGain(target,effect) target:addMod(MOD_AGI, 4); target:addMod(MOD_VIT, -6); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_AGI, 4); target:delMod(MOD_VIT, -6); end;
gpl-3.0
jshackley/darkstar
scripts/zones/Pashhow_Marshlands/npcs/Ioupie_RK.lua
30
3064
----------------------------------- -- Area: Pashhow Marshlands -- NPC: Ioupie, R.K. -- Type: Border Conquest Guards -- @pos 536.291 23.517 694.063 109 ----------------------------------- package.loaded["scripts/zones/Pashhow_Marshlands/TextIDs"] = nil; ----------------------------------- require("scripts/globals/conquest"); require("scripts/zones/Pashhow_Marshlands/TextIDs"); local guardnation = SANDORIA; -- SANDORIA, BASTOK, WINDURST, 4 = jeuno local guardtype = 4; -- 1: city, 2: foreign, 3: outpost, 4: border local region = DERFLAND; local csid = 0x7ffa; ----------------------------------- -- 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
JoMiro/arcemu
src/scripts/lua/LuaBridge/Stable Scripts/Outland/Magisters Terrace/UNIT-MagistersTerrace-SunbladeMagister.lua
30
1583
--[[ ******************************** * * * The Moon Project * * * ******************************** This software is provided as free and open source by the staff of The Moon Project, in accordance with the GPL license. This means we provide the software we have created freely and it has been thoroughly tested to work for the developers, but NO GUARANTEE is made it will work for you as well. Please give credit where credit is due, if modifying, redistributing and/or using this software. Thank you. Staff of Moon Project, Feb 2008 ~~End of License Agreement --Moon April 2008]] function SunbladeMagister_OnCombat(Unit, Event) Unit:RegisterAIUpdateEvent(3000) end function SunbladeMagister_Frostbolt(Unit, Event) local plr = Unit:GetRandomPlayer(1) if plr then Unit:FullCastSpellOnTarget(46035,plr) end end function SunbladeMagister_ArcaneNova(Unit) local arcaneflip = math.random(6) local plr = Unit:GetRandomPlayer(7) if arcaneflip == 1 and plr ~= nil then Unit:FullCastSpellOnTarget(46036,plr) else end end function SunbladeMagister_LeaveCombat(Unit) Unit:RemoveEvents() Unit:RemoveAIUpdateEvent() end function SunbladeMagister_Died(Unit) Unit:RemoveEvents() Unit:RemoveAIUpdateEvent() end RegisterUnitEvent(24685, 1, "SunbladeMagister_OnCombat") RegisterUnitEvent(24685, 21,"SunbladeMagister_Frostbolt") RegisterUnitEvent(24685, 21,"SunbladeMagister_ArcaneNova") RegisterUnitEvent(24685, 2, "SunbladeMagister_LeaveCombat") RegisterUnitEvent(24685, 4, "SunbladeMagister_Died")
agpl-3.0
anoidgit/reading-comprehension
deps/PScore.lua
1
2876
local PScore, parent = torch.class('nn.PScore', 'nn.SequenceContainer') function PScore:__init(Calcer) parent.__init(self, Calcer) self.gradP = torch.Tensor() self.gradQ = torch.Tensor() end local function expandT(tin, nexp) local usize = tin:size() local bsize = usize[1] local vsize = usize[2] return tin:reshape(1, bsize, vsize):expand(nexp, bsize, vsize) end function PScore:updateOutput(input) local extpas, question = unpack(input) local plen = extpas:size(1) local qlen = question:size(1) local rsize = torch.LongStorage({plen, qlen}) if not self.output:isSize(rsize) then self.output:resize(rsize) end if not self._qsize then self._qsize = question:size(3) self._sind = self._qsize + 1 self._slen = extpas:size(2) - self._qsize end local _cP = extpas:narrow(2, 1, self._qsize) for _ = 1, qlen do _cP:copy(expandT(question[_], plen)) self.output:select(2, _):copy(self:net(_):updateOutput(extpas)) end return self.output end function PScore:updateGradInput(input, gradOutput) local extpas, question = unpack(input) if not self.gradQ:isSize(question:size()) then self.gradQ:resizeAs(question) end if not self.gradP:isSize(extpas:size()) then self.gradP:resizeAs(extpas):zero() end local plen = extpas:size(1) local _cP = extpas:narrow(2, 1, self._qsize) local _gP = self.gradP:narrow(2, self._sind, self._slen) for _ = 1, question:size(1) do _cP:copy(expandT(question[_], plen)) local _curG = self:net(_):updateGradInput(extpas, gradOutput:narrow(2, _, 1)) self.gradQ[_]:copy(_curG:narrow(2, 1, self._qsize):sum(1)) _gP:add(_curG:narrow(2, self._sind, self._slen)) end self.gradInput = {self.gradP, self.gradQ} return self.gradInput end function PScore:accGradParameters(input, gradOutput, scale) local extpas, question = unpack(input) local plen = extpas:size(1) local _cP = extpas:narrow(2, 1, self._qsize) for _ = 1, question:size(1) do _cP:copy(expandT(question[_], plen)) self:net(_):accGradParameters(extpas, gradOutput:narrow(2, _, 1), scale) end end function PScore:backward(input, gradOutput, scale) local extpas, question = unpack(input) if not self.gradQ:isSize(question:size()) then self.gradQ:resizeAs(question) end if not self.gradP:isSize(extpas:size()) then self.gradP:resizeAs(extpas):zero() end local plen = extpas:size(1) local _cP = extpas:narrow(2, 1, self._qsize) local _gP = self.gradP:narrow(2, self._sind, self._slen) for _ = 1, question:size(1) do _cP:copy(expandT(question[_], plen)) local _curG = self:net(_):backward(extpas, gradOutput:narrow(2, _, 1), scale) self.gradQ[_]:copy(_curG:narrow(2, 1, self._qsize):sum(1)) _gP:add(_curG:narrow(2, self._sind, self._slen)) end self.gradInput = {self.gradP, self.gradQ} return self.gradInput end function PScore:clearState() self.gradP:set() self.gradQ:set() return parent.clearState(self) end
gpl-3.0
jshackley/darkstar
scripts/zones/Rabao/Zone.lua
28
1606
----------------------------------- -- -- Zone: Rabao (247) -- ----------------------------------- package.loaded["scripts/zones/Rabao/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/zones/Rabao/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(-20.052,6.074,-122.408,193); end return cs; end; ----------------------------------- -- onConquestUpdate ----------------------------------- function onConquestUpdate(zone, updatetype) local players = zone:getPlayers(); for name, player in pairs(players) do conquestUpdate(zone, player, updatetype, CONQUEST_BASE); end end; ----------------------------------- -- onRegionEnter ----------------------------------- function onRegionEnter(player,region) end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
jshackley/darkstar
scripts/zones/Ranguemont_Pass/Zone.lua
20
1885
----------------------------------- -- -- Zone: Ranguemont_Pass (166) -- ----------------------------------- package.loaded["scripts/zones/Ranguemont_Pass/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/zones/Ranguemont_Pass/TextIDs"); require("scripts/globals/zone"); ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) local tomes = {17457375,17457376,17457377,17461580}; SetGroundsTome(tomes); local Taisaijin = 17457216; GetMobByID(Taisaijin):setLocalVar("ToD", os.time() + math.random((86400), (259200))); 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(302.778,-68.131,257.759,137); 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
goksie/newfies-dialer
lua/test/send_sms.lua
4
1059
-- -- Newfies-Dialer License -- http://www.newfies-dialer.org -- -- This Source Code Form is subject to the terms of the Mozilla Public -- License, v. 2.0. If a copy of the MPL was not distributed with this file, -- You can obtain one at http://mozilla.org/MPL/2.0/. -- -- Copyright (C) 2011-2014 Star2Billing S.L. -- -- The Initial Developer of the Original Code is -- Arezqui Belaid <info@star2billing.com> -- package.path = package.path .. ";/usr/share/newfies-lua/?.lua"; package.path = package.path .. ";/usr/share/newfies-lua/libs/?.lua"; local oo = require "loop.simple" local database = require "database" -- -- Test Code -- local inspect = require 'inspect' require "debugger" local debugger = Debugger(false) db = Database(debug_mode, debugger) db:connect() -- campaign_id = 152 -- db:load_campaign_info(campaign_id) -- print(inspect(db.campaign_info)) sms_text = 'hello there' survey_id = 121 phonenumber = '845648998' -- db:send_sms(sms_text, survey_id, phonenumber) contact_id = 19143 db:load_contact(contact_id) print(inspect(db.contact))
mpl-2.0
jshackley/darkstar
scripts/zones/The_Shrine_of_RuAvitau/mobs/Defender.lua
2
2630
----------------------------------- -- Area: The Shrine of Ru'Avitau -- MOB: Defender ----------------------------------- ----------------------------------- -- onMobInitialize Action ----------------------------------- function onMobInitialize(mob) end; ----------------------------------- -- onMobSpawn ----------------------------------- function onMobSpawn(mob) local Defender = mob:getID(); GetMobByID(Defender):setLocalVar("1",1); end; ----------------------------------- -- onMobFight ----------------------------------- function onMobFight(mob,target) local Defender = mob:getID(); local AuraGear = Defender + 1; local ExtraVar = GetMobByID(Defender):getLocalVar("1"); -- Summons a Defender every 15 seconds. -- TODO: Casting animation for before summons. When he spawns them isn't exactly retail accurate. -- Defenders can also still spawn the AuraGears while sleeping, etc. if (GetMobAction(AuraGear) == 16) then GetMobByID(AuraGear):updateEnmity(target); end if (ExtraVar <= 6) then -- Maximum number of pets Defender can spawn is 5 if (mob:getBattleTime() % 15 < 3 and mob:getBattleTime() > 3) then if (GetMobAction(AuraGear) == 0) then SpawnMob(AuraGear):updateEnmity(target); GetMobByID(AuraGear):setPos(GetMobByID(Defender):getXPos()+1, GetMobByID(Defender):getYPos(), GetMobByID(Defender):getZPos()+1); -- Set AuraGear x and z position +1 from Defender GetMobByID(Defender):setLocalVar("1",ExtraVar+1); return; end end end end; ----------------------------------- -- onMobDisengage ----------------------------------- function onMobDisengage(mob) local Defender = mob:getID(); local AuraGear = mob:getID() + 1; GetMobByID(Defender):resetLocalVars(); if (GetMobAction(AuraGear) ~= 0) then DespawnMob(AuraGear); end end; ----------------------------------- -- onMobDeath ----------------------------------- function onMobDeath(mob, killer, ally) checkGoVregime(ally,mob,749,1); local Defender = mob:getID(); local AuraGear = mob:getID() + 1; GetMobByID(Defender):resetLocalVars(); if (GetMobAction(AuraGear) ~= 0) then DespawnMob(AuraGear); end end; ----------------------------------- -- OnMobDespawn ----------------------------------- function onMobDespawn( mob ) local Defender = mob:getID(); local AuraGear = mob:getID() + 1; GetMobByID(Defender):resetLocalVars(); if (GetMobAction(AuraGear) ~= 0) then DespawnMob(AuraGear); end end;
gpl-3.0
robertop/pelet
premake4.lua
1
8754
------------------------------------------------------------------- -- This software is released under the terms of the MIT License -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to deal -- in the Software without restriction, including without limitation the rights -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -- THE SOFTWARE. -- -- @copyright 2009-2012 Roberto Perpuly -- @license http://www.opensource.org/licenses/mit-license.php The MIT License ------------------------------------------------------------------- dofile "premake_functions.lua" dofile "premake_action_generate.lua" newoption { trigger = "icu-include", value = "path", description = "Directory Location of the ICU header files. " .. "This option should only be used on Win32 systems" } newoption { trigger = "icu-lib", value = "path", description = "Directory Location of the ICU library shared object files. " .. "This option should only be used on Win32 systems" } newoption { trigger = "icu-config", value = "path", description = "File location of the icu-config binary. If given, " .. "it will be used to get the appropriate compiler and linker flags. " .. "This option should only be used on linux systems" } -- these are the ICU unicode string libraries (in Win32) ICU_LIBS_RELEASE = { "icudt", "icuin", "icuio", "icule", "iculx", "icutu", "icuuc" } -- these are the ICU unicode string libraries (in Win32) ICU_LIBS_DEBUG = { "icudt", "icuind", "icuiod", "iculed", "iculxd", "icutud", "icuucd" } -- this configuration uses the command line options to get the ICU header & library locations function icuconfiguration(config, action) if config == "Debug" and _OPTIONS['icu-include'] then includedirs { _OPTIONS['icu-include'] } libdirs { _OPTIONS['icu-lib'] } links { ICU_LIBS_DEBUG } elseif config == "Release" and _OPTIONS['icu-include'] then includedirs { _OPTIONS['icu-include'] } libdirs { _OPTIONS['icu-lib'] } links { ICU_LIBS_RELEASE } elseif _OPTIONS['icu-config'] then -- use the execution operator '``' because the icu-config program -- will be used to generate the correct compile and linker flags buildoptions { "`" .. _OPTIONS['icu-config'] .. " --cppflags`" } linkoptions { "`" .. _OPTIONS['icu-config'] .. " --ldflags --ldflags-icuio`" } end end function pickywarnings(action) if action == "vs2008" then flags { "FatalWarnings" } elseif action == "gmake" or action == "codelite" then -- when compiling strict warning checks; also check against variable length arrays -- since Visual Studio is not C99 compliant buildoptions { "-Wall", "-Wvla" } end end if ((not _OPTIONS.help) and (_ACTION ~= 'clean') and (_ACTION ~= 'generate')) then if ((not _OPTIONS['icu-include']) and (not _OPTIONS['icu-config'])) then error("Missing one of --icu-include or --icu-config. See --help for details") end end -- solution directory structure -- the toolset files will be deposited in the build/ directory -- each toolset will have its own directory -- the executable files will be placed in the configuration directory (Debug/ or Release/) -- compile flags will be set to be stricter than normal solution "pelet" if _ACTION then location ("build/" .. _ACTION) end configurations { "Debug", "Release"} configuration "Debug" objdir "Debug" targetdir "Debug" flags { "Symbols" } configuration "Release" objdir "Release" targetdir "Release" configuration { "Debug", "vs2008" } -- prevent "warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library" buildoptions { "/MDd" } project "sample" language "C++" kind "ConsoleApp" files { "sample/sample.cpp" } includedirs { "include" } links { "pelet", "tests" } defines { "PELET_USE_DLL" } configuration "Release" pickywarnings(_ACTION) icuconfiguration("Release", _ACTION) configuration { "Debug", "vs2008" } icuconfiguration("Debug", _ACTION) postbuildcommands { "cd " .. normalizepath("Debug") .. " && tests.exe" } configuration { "Debug", "gmake or codelite" } icuconfiguration("Debug", _ACTION) postbuildcommands { "cd " .. normalizepath("Debug") .. " && ./tests" } configuration { "Release", "vs2008" } icuconfiguration("Debug", _ACTION) postbuildcommands { "cd " .. normalizepath("Release") .. " && tests.exe" } configuration { "Release", "gmake or codelite" } icuconfiguration("Debug", _ACTION) postbuildcommands { "cd " .. normalizepath("Release") .. " && ./tests" } project "pelet" language "C++" kind "SharedLib" files { "src/*", "include/**", "*.lua", "src/**.re", "src/**.y", "README.md", "ChangeLog" } includedirs { "include" } defines { "PELET_MAKING_DLL" } pickywarnings(_ACTION) -- for mac osx, change the shared library ID so that -- it is the full path, that way we can run the executable -- from any location and the lib will always be found -- it becomes painful when running from the command line -- vs. finder vs. the debugger vs. the codelite terminal, -- they all have different working directories and this -- makes relative install names not easy to work with -- when passing arguments to the linker, must replace -- spaces with commas if os.is "macosx" then configuration { "Debug" } linkoptions { "-Wl,-install_name," .. normalizepath("Debug/libpelet.dylib") } configuration { "Release" } linkoptions { "-Wl,-install_name," .. normalizepath("Release/libpelet.dylib") } end configuration "Release" icuconfiguration("Release", _ACTION) configuration { "Debug" } icuconfiguration("Debug", _ACTION) project "tests" language "C++" kind "ConsoleApp" files { "tests/**.cpp", "tests/**.h" } includedirs { "include/", "lib/UnitTest++/src/", "tests/" } links { "pelet", "unit_test++" } defines { "PELET_USE_DLL" } -- dont bother with warnings with using 'unsafe' fopen configuration { "vs2008" } defines { "_CRT_SECURE_NO_WARNINGS" } if os.is "linux" then configuration { "gmake or codelite" } -- make it so that the test executable can find the pelet shared lib linkoptions { "-Wl,-rpath=./" } elseif os.is "macosx" then -- this is a workaround for a premake issue where it will use -- bad compiler flags "-Wl,x" for a workaround that is longer -- needed in GCC, but it just prevents clang from compiling -- see http://industriousone.com/topic/how-remove-flags-ldflags flags { "Symbols" } end configuration "Debug" pickywarnings(_ACTION) icuconfiguration("Debug", _ACTION) configuration "Release" pickywarnings(_ACTION) icuconfiguration("Release", _ACTION) project "unit_test++" language "C++" kind "StaticLib" files { "lib/UnitTest++/src/*.cpp" } -- enable the "Use Unicode Character Set" option under General .. Character Set -- enable Stuctured Exception Handling needed by UnitTest++ flags { "Unicode", "SEH" } -- For this project, no need to differentiate between Debug or Release configuration { "vs2008" } files { "lib/UnitTest++/src/Win32/*.cpp" } -- dont bother with warnings with using 'unsafe' strcopy defines { "_CRT_SECURE_NO_WARNINGS", "_LIB" } configuration { "gmake or codelite" } files { "lib/UnitTest++/src/Posix/*.cpp" } project "unit_test++_test" language "C++" kind "ConsoleApp" links { "unit_test++" } files { "lib/UnitTest++/src/tests/*.cpp" } -- enable Stuctured Exception Handling needed by UnitTest++ flags { "SEH" } -- enable the "Use Unicode Character Set" option under General .. Character Set flags { "Unicode" } configuration { "vs2008" } -- dont bother with warnings with using 'unsafe' strcopy defines { "_CRT_SECURE_NO_WARNINGS" } flags { "WinMain" } -- For this project, no need to differentiate between Debug or Release
mit
jshackley/darkstar
scripts/zones/Southern_San_dOria/npcs/Lotte.lua
36
1431
----------------------------------- -- Area: Southern San d'Oria -- NPC: Lotte -- General Info NPC ------------------------------------- package.loaded["scripts/zones/Southern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/quests"); require("scripts/zones/Southern_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- "Flyers for Regine" conditional script 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(0x234); 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
jshackley/darkstar
scripts/globals/spells/raptor_mazurka.lua
31
1188
----------------------------------------- -- Spell: Raptor Mazurka -- Gives party members enhanced movement ----------------------------------------- require("scripts/globals/status"); ----------------------------------------- -- OnSpellCast ----------------------------------------- function onMagicCastingCheck(caster,target,spell) return 0; end; function onSpellCast(caster,target,spell) local power = 12; local iBoost = caster:getMod(MOD_MAZURKA_EFFECT) + caster:getMod(MOD_ALL_SONGS_EFFECT); local duration = 120; duration = duration * ((iBoost * 0.1) + (caster:getMod(MOD_SONG_DURATION_BONUS)/100) + 1); if (caster:hasStatusEffect(EFFECT_SOUL_VOICE)) then duration = duration * 2; elseif (caster:hasStatusEffect(EFFECT_MARCATO)) then duration = duration * 1.5; end caster:delStatusEffect(EFFECT_MARCATO); if (caster:hasStatusEffect(EFFECT_TROUBADOUR)) then duration = duration * 2; end if not (target:addBardSong(caster,EFFECT_MAZURKA,power,0,duration,caster:getID(), 0, 1)) then spell:setMsg(75); end return EFFECT_MAZURKA; end;
gpl-3.0
yunikkk/omim
3party/osrm/osrm-backend/profile.lua
48
13466
-- Begin of globals --require("lib/access") --function temporarily inlined barrier_whitelist = { ["cattle_grid"] = true, ["border_control"] = true, ["checkpoint"] = true, ["toll_booth"] = true, ["sally_port"] = true, ["gate"] = true, ["lift_gate"] = true, ["no"] = true, ["entrance"] = true } access_tag_whitelist = { ["yes"] = true, ["motorcar"] = true, ["motor_vehicle"] = true, ["vehicle"] = true, ["permissive"] = true, ["designated"] = true } access_tag_blacklist = { ["no"] = true, ["private"] = true, ["agricultural"] = true, ["forestry"] = true, ["emergency"] = true, ["psv"] = true } access_tag_restricted = { ["destination"] = true, ["delivery"] = true } access_tags = { "motorcar", "motor_vehicle", "vehicle" } access_tags_hierachy = { "motorcar", "motor_vehicle", "vehicle", "access" } service_tag_restricted = { ["parking_aisle"] = true } ignore_in_grid = { ["ferry"] = true } restriction_exception_tags = { "motorcar", "motor_vehicle", "vehicle" } speed_profile = { ["motorway"] = 90, ["motorway_link"] = 45, ["trunk"] = 85, ["trunk_link"] = 40, ["primary"] = 65, ["primary_link"] = 30, ["secondary"] = 55, ["secondary_link"] = 25, ["tertiary"] = 40, ["tertiary_link"] = 20, ["unclassified"] = 25, ["residential"] = 25, ["living_street"] = 10, ["service"] = 15, -- ["track"] = 5, ["ferry"] = 5, ["movable"] = 5, ["shuttle_train"] = 10, ["default"] = 10 } -- surface/trackype/smoothness -- values were estimated from looking at the photos at the relevant wiki pages -- max speed for surfaces surface_speeds = { ["asphalt"] = nil, -- nil mean no limit. removing the line has the same effect ["concrete"] = nil, ["concrete:plates"] = nil, ["concrete:lanes"] = nil, ["paved"] = nil, ["cement"] = 80, ["compacted"] = 80, ["fine_gravel"] = 80, ["paving_stones"] = 60, ["metal"] = 60, ["bricks"] = 60, ["grass"] = 40, ["wood"] = 40, ["sett"] = 40, ["grass_paver"] = 40, ["gravel"] = 40, ["unpaved"] = 40, ["ground"] = 40, ["dirt"] = 40, ["pebblestone"] = 40, ["tartan"] = 40, ["cobblestone"] = 30, ["clay"] = 30, ["earth"] = 20, ["stone"] = 20, ["rocky"] = 20, ["sand"] = 20, ["mud"] = 10 } -- max speed for tracktypes tracktype_speeds = { ["grade1"] = 60, ["grade2"] = 40, ["grade3"] = 30, ["grade4"] = 25, ["grade5"] = 20 } -- max speed for smoothnesses smoothness_speeds = { ["intermediate"] = 80, ["bad"] = 40, ["very_bad"] = 20, ["horrible"] = 10, ["very_horrible"] = 5, ["impassable"] = 0 } -- http://wiki.openstreetmap.org/wiki/Speed_limits maxspeed_table_default = { ["urban"] = 50, ["rural"] = 90, ["trunk"] = 110, ["motorway"] = 130 } -- List only exceptions maxspeed_table = { ["ch:rural"] = 80, ["ch:trunk"] = 100, ["ch:motorway"] = 120, ["de:living_street"] = 7, ["ru:living_street"] = 20, ["ru:urban"] = 60, ["ua:urban"] = 60, ["at:rural"] = 100, ["de:rural"] = 100, ["at:trunk"] = 100, ["cz:trunk"] = 0, ["ro:trunk"] = 100, ["cz:motorway"] = 0, ["de:motorway"] = 0, ["ru:motorway"] = 110, ["gb:nsl_single"] = (60*1609)/1000, ["gb:nsl_dual"] = (70*1609)/1000, ["gb:motorway"] = (70*1609)/1000, ["uk:nsl_single"] = (60*1609)/1000, ["uk:nsl_dual"] = (70*1609)/1000, ["uk:motorway"] = (70*1609)/1000, ["nl:rural"] = 80, ["nl:trunk"] = 100, ["nl:motorway"] = 130, ["none"] = 140 } traffic_signal_penalty = 2 use_turn_restrictions = true local take_minimum_of_speeds = false local obey_oneway = true local obey_bollards = true local ignore_areas = true -- future feature local u_turn_penalty = 20 local abs = math.abs local min = math.min local max = math.max local speed_reduction = 0.8 local side_road_speed_multiplier = 0.8 --modes local mode_normal = 1 local mode_ferry = 2 local mode_movable_bridge = 3 local function find_access_tag(source, access_tags_hierachy) for i,v in ipairs(access_tags_hierachy) do local access_tag = source:get_value_by_key(v) if access_tag and "" ~= access_tag then return access_tag end end return "" end function get_exceptions(vector) for i,v in ipairs(restriction_exception_tags) do vector:Add(v) end end local function parse_maxspeed(source) if not source then return 0 end local n = tonumber(source:match("%d*")) if n then if string.match(source, "mph") or string.match(source, "mp/h") then n = (n*1609)/1000; end else -- parse maxspeed like FR:urban source = string.lower(source) n = maxspeed_table[source] if not n then local highway_type = string.match(source, "%a%a:(%a+)") n = maxspeed_table_default[highway_type] if not n then n = 0 end end end return n end -- function turn_function (angle) -- -- print ("called at angle " .. angle ) -- local index = math.abs(math.floor(angle/10+0.5))+1 -- +1 'coz LUA starts as idx 1 -- local penalty = turn_cost_table[index] -- -- print ("index: " .. index .. ", bias: " .. penalty ) -- return penalty -- end function node_function (node, result) -- parse access and barrier tags local access = find_access_tag(node, access_tags_hierachy) if access ~= "" then if access_tag_blacklist[access] then result.barrier = true end else local barrier = node:get_value_by_key("barrier") if barrier and "" ~= barrier then if not barrier_whitelist[barrier] then result.barrier = true end end end -- check if node is a traffic light local tag = node:get_value_by_key("highway") if tag and "traffic_signals" == tag then result.traffic_lights = true; end end function way_function (way, result) local highway = way:get_value_by_key("highway") local route = way:get_value_by_key("route") local bridge = way:get_value_by_key("bridge") if not ((highway and highway ~= "") or (route and route ~= "") or (bridge and bridge ~= "")) then return end -- we dont route over areas local area = way:get_value_by_key("area") if ignore_areas and area and "yes" == area then return end -- check if oneway tag is unsupported local oneway = way:get_value_by_key("oneway") if oneway and "reversible" == oneway then return end local impassable = way:get_value_by_key("impassable") if impassable and "yes" == impassable then return end local status = way:get_value_by_key("status") if status and "impassable" == status then return end local width = math.huge local width_string = way:get_value_by_key("width") if width_string and tonumber(width_string:match("%d*")) then width = tonumber(width_string:match("%d*")) end -- Check if we are allowed to access the way local access = find_access_tag(way, access_tags_hierachy) if access_tag_blacklist[access] then return end -- handling ferries and piers local route_speed = speed_profile[route] if (route_speed and route_speed > 0) then highway = route; local duration = way:get_value_by_key("duration") if duration and durationIsValid(duration) then result.duration = max( parseDuration(duration), 1 ); end result.forward_mode = mode_ferry result.backward_mode = mode_ferry result.forward_speed = route_speed result.backward_speed = route_speed end -- handling movable bridges local bridge_speed = speed_profile[bridge] local capacity_car = way:get_value_by_key("capacity:car") if (bridge_speed and bridge_speed > 0) and (capacity_car ~= 0) then highway = bridge; local duration = way:get_value_by_key("duration") if duration and durationIsValid(duration) then result.duration = max( parseDuration(duration), 1 ); end result.forward_mode = mode_movable_bridge result.backward_mode = mode_movable_bridge result.forward_speed = bridge_speed result.backward_speed = bridge_speed end -- leave early of this way is not accessible if "" == highway then return end if result.forward_speed == -1 then local highway_speed = speed_profile[highway] local max_speed = parse_maxspeed( way:get_value_by_key("maxspeed") ) -- Set the avg speed on the way if it is accessible by road class if highway_speed then if max_speed and max_speed > highway_speed then result.forward_speed = max_speed result.backward_speed = max_speed -- max_speed = math.huge else result.forward_speed = highway_speed result.backward_speed = highway_speed end else -- Set the avg speed on ways that are marked accessible -- OMIM does not support not highway classes -- if access_tag_whitelist[access] and "yes" ~= access then -- result.forward_speed = speed_profile["default"] -- result.backward_speed = speed_profile["default"] --end end if 0 == max_speed then max_speed = math.huge end result.forward_speed = min(result.forward_speed, max_speed) result.backward_speed = min(result.backward_speed, max_speed) end if -1 == result.forward_speed and -1 == result.backward_speed then return end -- reduce speed on special side roads local sideway = way:get_value_by_key("side_road") if "yes" == sideway or "rotary" == sideway then result.forward_speed = result.forward_speed * side_road_speed_multiplier result.backward_speed = result.backward_speed * side_road_speed_multiplier end -- reduce speed on bad surfaces local surface = way:get_value_by_key("surface") local tracktype = way:get_value_by_key("tracktype") local smoothness = way:get_value_by_key("smoothness") if surface and surface_speeds[surface] then result.forward_speed = math.min(surface_speeds[surface], result.forward_speed) result.backward_speed = math.min(surface_speeds[surface], result.backward_speed) end if tracktype and tracktype_speeds[tracktype] then result.forward_speed = math.min(tracktype_speeds[tracktype], result.forward_speed) result.backward_speed = math.min(tracktype_speeds[tracktype], result.backward_speed) end if smoothness and smoothness_speeds[smoothness] then result.forward_speed = math.min(smoothness_speeds[smoothness], result.forward_speed) result.backward_speed = math.min(smoothness_speeds[smoothness], result.backward_speed) end -- parse the remaining tags local name = way:get_value_by_key("name") local ref = way:get_value_by_key("ref") local junction = way:get_value_by_key("junction") -- local barrier = way:get_value_by_key("barrier", "") -- local cycleway = way:get_value_by_key("cycleway", "") local service = way:get_value_by_key("service") -- Set the name that will be used for instructions if ref and "" ~= ref then result.name = ref elseif name and "" ~= name then result.name = name -- else -- result.name = highway -- if no name exists, use way type end if junction and "roundabout" == junction then result.roundabout = true; end -- Set access restriction flag if access is allowed under certain restrictions only if access ~= "" and access_tag_restricted[access] then result.is_access_restricted = true end -- Set access restriction flag if service is allowed under certain restrictions only if service and service ~= "" and service_tag_restricted[service] then result.is_access_restricted = true end -- Set direction according to tags on way if obey_oneway then if oneway == "-1" then result.forward_mode = 0 elseif oneway == "yes" or oneway == "1" or oneway == "true" or junction == "roundabout" or (highway == "motorway_link" and oneway ~="no") or (highway == "motorway" and oneway ~= "no") then result.backward_mode = 0 end end -- Override speed settings if explicit forward/backward maxspeeds are given local maxspeed_forward = parse_maxspeed(way:get_value_by_key( "maxspeed:forward")) local maxspeed_backward = parse_maxspeed(way:get_value_by_key( "maxspeed:backward")) if maxspeed_forward and maxspeed_forward > 0 then if 0 ~= result.forward_mode and 0 ~= result.backward_mode then result.backward_speed = result.forward_speed end result.forward_speed = maxspeed_forward end if maxspeed_backward and maxspeed_backward > 0 then result.backward_speed = maxspeed_backward end -- Override general direction settings of there is a specific one for our mode of travel if ignore_in_grid[highway] then result.ignore_in_grid = true end -- scale speeds to get better avg driving times if result.forward_speed > 0 then local scaled_speed = result.forward_speed*speed_reduction + 11; local penalized_speed = math.huge if width <= 3 then penalized_speed = result.forward_speed / 2; end result.forward_speed = math.min(penalized_speed, scaled_speed) end if result.backward_speed > 0 then local scaled_speed = result.backward_speed*speed_reduction + 11; local penalized_speed = math.huge if width <= 3 then penalized_speed = result.backward_speed / 2; end result.backward_speed = math.min(penalized_speed, scaled_speed) end end -- These are wrappers to parse vectors of nodes and ways and thus to speed up any tracing JIT function node_vector_function(vector) for v in vector.nodes do node_function(v) end end
apache-2.0
jshackley/darkstar
scripts/zones/Northern_San_dOria/npcs/Pellimie.lua
38
1025
----------------------------------- -- Area: Northern San d'Oria -- NPC: Pellimie -- Type: Standard Dialogue NPC -- @zone: 231 -- @pos 145.459 0.000 131.540 -- ----------------------------------- package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil; require("scripts/zones/Northern_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:showText(npc,PELLIMIE_DIALOG); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
gheinrich/lua-pb
bench/bench_media.lua
7
4012
local pb = require"pb" local function encode_new_msg(create, ...) local msg =create(...) return msg:Serialize() end local function decode_new_msg(create, data) local msg =create() return msg:Parse(data) end local bench = require"bench.bench" -- load .proto file. local media = require"protos.media" local MediaContent = media.MediaContent local function create_media() return MediaContent({ media = { uri = "http://javaone.com/keynote.mpg", title = "Javaone Keynote", width = 640, height = 480, format = "video/mpg4", duration = 18000000, -- half hour in milliseconds size = 58982400, -- bitrate * duration in seconds / 8 bits per byte bitrate = 262144, -- 256k person = {"Bill Gates", "Steve Jobs"}, player = 'JAVA', copyright = nil, }, image = { { uri = "http://javaone.com/keynote_large.jpg", title = "Javaone Keynote", width = 1024, height = 768, size = 'LARGE', }, { uri = "http://javaone.com/keynote_small.jpg", title = "Javaone Keynote", width = 320, height = 240, size = 'SMALL', }, }, }) end -- -- Check MediaContent record -- local function check_MediaContent_media(media) assert(media ~= nil) assert(media.uri == "http://javaone.com/keynote.mpg") assert(media.title == "Javaone Keynote") assert(media.width == 640) assert(media.height == 480) assert(media.format == "video/mpg4") assert(media.duration == 18000000) -- half hour in milliseconds assert(media.size == 58982400) -- bitrate * duration in seconds / 8 bits per byte assert(media.bitrate == 262144) -- 256k local person = media.person assert(person[1] == "Bill Gates") assert(person[2] == "Steve Jobs") assert(media.player == 'JAVA') assert(media.copyright == nil) end local function check_MediaContent(content) assert(content ~= nil) -- check media record check_MediaContent_media(content.media) -- check image records. local image = content.image local img img = image[1] assert(img ~= nil) assert(img.uri == "http://javaone.com/keynote_large.jpg") assert(img.title == "Javaone Keynote") assert(img.width == 1024) assert(img.height == 768) assert(img.size == 'LARGE') img = image[2] assert(img ~= nil) assert(img.uri == "http://javaone.com/keynote_small.jpg") assert(img.title == "Javaone Keynote") assert(img.width == 320) assert(img.height == 240) assert(img.size == 'SMALL') end local loop = tonumber(arg[1] or 100000) local msg = create_media() ---[[ check_MediaContent(msg) print("------------ create empty benchmark.") bench.memtest("create empty Media", 100, MediaContent) bench.speedtest("create empty Media", loop, MediaContent) print("Memory usage:", collectgarbage"count") print("------------ create full benchmark.") bench.memtest("create full Media", 100, create_media) bench.speedtest("create full Media", loop, create_media) print("Memory usage:", collectgarbage"count") print("------------ check benchmark.") bench.memtest("check Media", 100, check_MediaContent, msg) bench.speedtest("check Media", loop, check_MediaContent, msg) print("Memory usage:", collectgarbage"count") --]] print("------------ encode same benchmark.") local function encode_msg(msg) return msg:Serialize() end bench.memtest("encode same Media", 100, encode_msg, msg) bench.speedtest("encode same Media", loop, encode_msg, msg) print("Memory usage:", collectgarbage"count") ---[[ print("------------ encode different benchmark.") bench.memtest("encode different Media", 100, encode_new_msg, create_media) bench.speedtest("encode different Media", loop, encode_new_msg, create_media) print("Memory usage:", collectgarbage"count") print("------------ decode benchmark.") local bin = msg:Serialize() local msg1, off = MediaContent():Parse(bin) check_MediaContent(msg1) bench.memtest("decode Media", 100, decode_new_msg, MediaContent, bin) bench.speedtest("decode Media", loop, decode_new_msg, MediaContent, bin) print("Memory usage:", collectgarbage"count") --]]
mit
Ombridride/minetest-minetestforfun-server
mods/worldedge/init.lua
9
4479
-------------- -- TODO: Check for terrain height -- Defines the edge of a world local edge = 30000 -- Radius which should be checked for a good teleportation place local radius = 2 -------------- local count = 0 local waiting_list = {} --[[ Explanation of waiting_list table Index = Player name Value = { player = Player to teleport pos = Destination obj = Attacked entity notified = When the player must wait longer... } ]] local function tick() for k, v in pairs(waiting_list) do if v.player and v.player:is_player() then local pos = get_surface_pos(v.pos) if pos then v.obj:setpos(pos) minetest.after(0.2, function(p, o) p:set_detach() o:remove() end, v.player, v.obj) waiting_list[k] = nil elseif not v.notified then v.notified = true minetest.chat_send_player(k, "Sorry, we have not found a free place yet. Please be patient.") end else v.obj:remove() waiting_list[k] = nil end end local newedge = edge - 5 -- Check if the players are near the edge and teleport them local players = minetest.get_connected_players() for i, player in ipairs(players) do local name = player:get_player_name() if not waiting_list[name] then local pos = vector.round(player:getpos()) -- Sanity check for insane coordinates if pos.x > 31000 or pos.y > 31000 or pos.z > 31000 or pos.x < -31000 or pos.y < -31000 or pos.z < -31000 then -- Move to spawn asap -- The server probably set invalid/insane coordinates. We have not saved the previous ones, -- So we need to teleport the player to the spawn to save them from an endless loop of -- Teleportation. local spawn = minetest.string_to_pos(minetest.setting_get("static_spawnpoint") or "0,0,0") minetest.chat_send_player(player:get_player_name(), "An internal error has occured. Your coordinates were corrupted. You are now teleported to the spawn." .. " Please report it to any staff member.") minetest.log("error", "[WorldEdge] Corrupted position detected for player " .. player:get_player_name()) player:setpos(spawn) else -- Indent skipped, too many lines to change... We'll wait for "continue" to be introduced in Lua5.2 local newpos = nil if pos.x >= edge then newpos = {x = -newedge, y = 10, z = pos.z} elseif pos.x <= -edge then newpos = {x = newedge, y = 10, z = pos.z} end if pos.z >= edge then newpos = {x = pos.x, y = 10, z = -newedge} if get_surface_pos(newpos) then newpos.y = get_surface_pos(newpos).y+1 -- /MFF (Mg|19/05//15) end -- /MFF (Mg|14/07/15) elseif pos.z <= -edge then newpos = {x = pos.x, y = 10, z = newedge} if get_surface_pos(newpos) then newpos.y = get_surface_pos(newpos).y+1 -- /MFF (Mg|19/05/15) end -- /MFF (Mg|14/07/15) end -- Teleport the player if newpos then minetest.chat_send_player(name, "Please wait a few seconds. We will teleport you soon.") local obj = minetest.add_entity(newpos, "worldedge:lock") player:set_attach(obj, "", {x=0, y=0, z=0}, {x=0, y=0, z=0}) waiting_list[name] = { player = player, pos = newpos, obj = obj } obj:setpos(newpos) end end end end minetest.after(3, tick) end tick() function get_surface_pos(pos) local minp = { x = pos.x - radius - 1, y = -10, z = pos.z - radius - 1 } local maxp = { x = pos.x + radius - 1, y = 50, z = pos.z + radius - 1 } local c_air = minetest.get_content_id("air") local c_ignore = minetest.get_content_id("ignore") local vm = minetest.get_voxel_manip() local emin, emax = vm:read_from_map(minp, maxp) local area = VoxelArea:new{MinEdge = emin, MaxEdge = emax} local data = vm:get_data() local seen_air = false local deepest_place = vector.new(pos) deepest_place.y = 50 for x = minp.x, maxp.x do for z = minp.z, maxp.z do local solid = 0 for y = deepest_place.y, -10, -1 do local node = data[area:index(x, y, z)] if y < deepest_place.y and node == c_air then deepest_place = vector.new(x, y, z) seen_air = true end if solid > 5 then -- Do not find caves! break end if node ~= c_air and node ~= c_ignore then solid = solid + 1 end end end end if seen_air then return deepest_place else return false end end minetest.register_entity("worldedge:lock", { initial_properties = { is_visible = false }, on_activate = function(staticdata, dtime_s) --self.object:set_armor_groups({immortal = 1}) end })
unlicense
jshackley/darkstar
scripts/zones/Northern_San_dOria/npcs/Eugballion.lua
17
1647
----------------------------------- -- Area: Northern San d'Oria -- NPC: Eugballion -- Only sells when San d'Oria controlls Qufim Region ----------------------------------- package.loaded["scripts/zones/Northern_San_dOria/TextIDs"] = nil; ----------------------------------- require("scripts/globals/shop"); require("scripts/globals/quests"); require("scripts/globals/conquest"); require("scripts/zones/Northern_San_dOria/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- "Flyers for Regine" conditional script if (player:getQuestStatus(SANDORIA,FLYERS_FOR_REGINE) == QUEST_ACCEPTED) then if (trade:hasItemQty(532,1) and trade:getItemCount() == 1) then player:messageSpecial(FLYER_REFUSED); end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) if (GetRegionOwner(QUFIMISLAND) ~= SANDORIA) then player:showText(npc,EUGBALLION_CLOSED_DIALOG); else player:showText(npc,EUGBALLION_OPEN_DIALOG); stock = {0x03ba,4121} -- Magic Pot Shard showShop(player,SANDORIA,stock); end end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); end;
gpl-3.0
jshackley/darkstar
scripts/zones/Uleguerand_Range/npcs/HomePoint#5.lua
19
1189
----------------------------------- -- Area: Uleguerand_Range -- NPC: HomePoint#5 -- @pos ----------------------------------- package.loaded["scripts/zones/Uleguerand_Range/TextIDs"] = nil; require("scripts/globals/settings"); require("scripts/zones/Uleguerand_Range/TextIDs"); require("scripts/globals/homepoint"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) homepointMenu( player, 0x2200, 80); 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 == 0x2200) then if (option == 1) then player:setHomePoint(); player:messageSpecial(HOMEPOINT_SET); else hpTeleport( player, option); end end end;
gpl-3.0
VincentGong/chess
cocos2d-x/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_physics_auto_api.lua
6
5853
-------------------------------- -- @module cc -------------------------------------------------------- -- the cc PhysicsWorld -- @field [parent=#cc] PhysicsWorld#PhysicsWorld PhysicsWorld preloaded module -------------------------------------------------------- -- the cc PhysicsDebugDraw -- @field [parent=#cc] PhysicsDebugDraw#PhysicsDebugDraw PhysicsDebugDraw preloaded module -------------------------------------------------------- -- the cc PhysicsShape -- @field [parent=#cc] PhysicsShape#PhysicsShape PhysicsShape preloaded module -------------------------------------------------------- -- the cc PhysicsShapeCircle -- @field [parent=#cc] PhysicsShapeCircle#PhysicsShapeCircle PhysicsShapeCircle preloaded module -------------------------------------------------------- -- the cc PhysicsShapeBox -- @field [parent=#cc] PhysicsShapeBox#PhysicsShapeBox PhysicsShapeBox preloaded module -------------------------------------------------------- -- the cc PhysicsShapePolygon -- @field [parent=#cc] PhysicsShapePolygon#PhysicsShapePolygon PhysicsShapePolygon preloaded module -------------------------------------------------------- -- the cc PhysicsShapeEdgeSegment -- @field [parent=#cc] PhysicsShapeEdgeSegment#PhysicsShapeEdgeSegment PhysicsShapeEdgeSegment preloaded module -------------------------------------------------------- -- the cc PhysicsShapeEdgeBox -- @field [parent=#cc] PhysicsShapeEdgeBox#PhysicsShapeEdgeBox PhysicsShapeEdgeBox preloaded module -------------------------------------------------------- -- the cc PhysicsShapeEdgePolygon -- @field [parent=#cc] PhysicsShapeEdgePolygon#PhysicsShapeEdgePolygon PhysicsShapeEdgePolygon preloaded module -------------------------------------------------------- -- the cc PhysicsShapeEdgeChain -- @field [parent=#cc] PhysicsShapeEdgeChain#PhysicsShapeEdgeChain PhysicsShapeEdgeChain preloaded module -------------------------------------------------------- -- the cc PhysicsBody -- @field [parent=#cc] PhysicsBody#PhysicsBody PhysicsBody preloaded module -------------------------------------------------------- -- the cc PhysicsContact -- @field [parent=#cc] PhysicsContact#PhysicsContact PhysicsContact preloaded module -------------------------------------------------------- -- the cc PhysicsContactPreSolve -- @field [parent=#cc] PhysicsContactPreSolve#PhysicsContactPreSolve PhysicsContactPreSolve preloaded module -------------------------------------------------------- -- the cc PhysicsContactPostSolve -- @field [parent=#cc] PhysicsContactPostSolve#PhysicsContactPostSolve PhysicsContactPostSolve preloaded module -------------------------------------------------------- -- the cc EventListenerPhysicsContact -- @field [parent=#cc] EventListenerPhysicsContact#EventListenerPhysicsContact EventListenerPhysicsContact preloaded module -------------------------------------------------------- -- the cc EventListenerPhysicsContactWithBodies -- @field [parent=#cc] EventListenerPhysicsContactWithBodies#EventListenerPhysicsContactWithBodies EventListenerPhysicsContactWithBodies preloaded module -------------------------------------------------------- -- the cc EventListenerPhysicsContactWithShapes -- @field [parent=#cc] EventListenerPhysicsContactWithShapes#EventListenerPhysicsContactWithShapes EventListenerPhysicsContactWithShapes preloaded module -------------------------------------------------------- -- the cc EventListenerPhysicsContactWithGroup -- @field [parent=#cc] EventListenerPhysicsContactWithGroup#EventListenerPhysicsContactWithGroup EventListenerPhysicsContactWithGroup preloaded module -------------------------------------------------------- -- the cc PhysicsJoint -- @field [parent=#cc] PhysicsJoint#PhysicsJoint PhysicsJoint preloaded module -------------------------------------------------------- -- the cc PhysicsJointFixed -- @field [parent=#cc] PhysicsJointFixed#PhysicsJointFixed PhysicsJointFixed preloaded module -------------------------------------------------------- -- the cc PhysicsJointLimit -- @field [parent=#cc] PhysicsJointLimit#PhysicsJointLimit PhysicsJointLimit preloaded module -------------------------------------------------------- -- the cc PhysicsJointPin -- @field [parent=#cc] PhysicsJointPin#PhysicsJointPin PhysicsJointPin preloaded module -------------------------------------------------------- -- the cc PhysicsJointDistance -- @field [parent=#cc] PhysicsJointDistance#PhysicsJointDistance PhysicsJointDistance preloaded module -------------------------------------------------------- -- the cc PhysicsJointSpring -- @field [parent=#cc] PhysicsJointSpring#PhysicsJointSpring PhysicsJointSpring preloaded module -------------------------------------------------------- -- the cc PhysicsJointGroove -- @field [parent=#cc] PhysicsJointGroove#PhysicsJointGroove PhysicsJointGroove preloaded module -------------------------------------------------------- -- the cc PhysicsJointRotarySpring -- @field [parent=#cc] PhysicsJointRotarySpring#PhysicsJointRotarySpring PhysicsJointRotarySpring preloaded module -------------------------------------------------------- -- the cc PhysicsJointRotaryLimit -- @field [parent=#cc] PhysicsJointRotaryLimit#PhysicsJointRotaryLimit PhysicsJointRotaryLimit preloaded module -------------------------------------------------------- -- the cc PhysicsJointRatchet -- @field [parent=#cc] PhysicsJointRatchet#PhysicsJointRatchet PhysicsJointRatchet preloaded module -------------------------------------------------------- -- the cc PhysicsJointGear -- @field [parent=#cc] PhysicsJointGear#PhysicsJointGear PhysicsJointGear preloaded module -------------------------------------------------------- -- the cc PhysicsJointMotor -- @field [parent=#cc] PhysicsJointMotor#PhysicsJointMotor PhysicsJointMotor preloaded module return nil
mit
jshackley/darkstar
scripts/zones/Kuftal_Tunnel/npcs/Treasure_Coffer.lua
17
4419
----------------------------------- -- Area: Kuftal Tunnel -- NPC: Treasure Coffer -- @zone 174 ----------------------------------- package.loaded["scripts/zones/Kuftal_Tunnel/TextIDs"] = nil; ----------------------------------- require("scripts/globals/settings"); require("scripts/globals/keyitems"); require("scripts/globals/treasure"); require("scripts/globals/quests"); require("scripts/zones/Kuftal_Tunnel/TextIDs"); local TreasureType = "Coffer"; local TreasureLvL = 53; local TreasureMinLvL = 43; ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) -- trade:hasItemQty(1051,1); -- Treasure Key -- trade:hasItemQty(1115,1); -- Skeleton Key -- trade:hasItemQty(1023,1); -- Living Key -- trade:hasItemQty(1022,1); -- Thief's Tools local questItemNeeded = 0; -- Player traded a key. if ((trade:hasItemQty(1051,1) or trade:hasItemQty(1115,1) or trade:hasItemQty(1023,1) or trade:hasItemQty(1022,1)) and trade:getItemCount() == 1) then -- IMPORTANT ITEM: AF Keyitems, AF Items, & Map ----------- local mJob = player:getMainJob(); local zone = player:getZoneID(); local AFHandsActivated = player:getVar("BorghertzAlreadyActiveWithJob"); if (AFHandsActivated == 12 and player:hasKeyItem(OLD_GAUNTLETS) == false) then questItemNeeded = 1; elseif (player:getQuestStatus(OUTLANDS,TRUE_WILL) == QUEST_ACCEPTED and player:getVar("trueWillCS") == 2 and player:hasKeyItem(LARGE_TRICK_BOX) == false) then questItemNeeded = 2; elseif (player:getQuestStatus(SANDORIA,KNIGHT_STALKER) == QUEST_ACCEPTED and player:getVar("KnightStalker_Progress") == 1) then questItemNeeded = 3; elseif (player:hasKeyItem(MAP_OF_THE_KUFTAL_TUNNEL) == false) then questItemNeeded = 4; end -------------------------------------- local pack = openChance(player,npc,trade,TreasureType,TreasureLvL,TreasureMinLvL,questItemNeeded); local success = 0; if (pack[2] ~= nil) then player:messageSpecial(pack[2]); success = pack[1]; else success = pack[1]; end if (success ~= -2) then player:tradeComplete(); if (math.random() <= success) then -- Succeded to open the coffer player:messageSpecial(CHEST_UNLOCKED); if (questItemNeeded == 1) then player:addKeyItem(OLD_GAUNTLETS); player:messageSpecial(KEYITEM_OBTAINED,OLD_GAUNTLETS); -- Old Gauntlets (KI) elseif (questItemNeeded == 2) then player:addKeyItem(LARGE_TRICK_BOX); player:messageSpecial(KEYITEM_OBTAINED,LARGE_TRICK_BOX); -- Large Trick Box (KI, NIN AF3) elseif (questItemNeeded == 3) then player:addKeyItem(CHALLENGE_TO_THE_ROYAL_KNIGHTS); -- DRG AF3 (KI) player:messageSpecial(KEYITEM_OBTAINED,CHALLENGE_TO_THE_ROYAL_KNIGHTS); elseif (questItemNeeded == 4) then player:addKeyItem(MAP_OF_THE_KUFTAL_TUNNEL); player:messageSpecial(KEYITEM_OBTAINED,MAP_OF_THE_KUFTAL_TUNNEL); -- Map of the Kuftal Tunnel (KI) else player:setVar("["..zone.."]".."Treasure_"..TreasureType,os.time() + math.random(CHEST_MIN_ILLUSION_TIME,CHEST_MAX_ILLUSION_TIME)); local loot = cofferLoot(zone,npc); -- print("loot array: "); -- debug -- print("[1]", loot[1]); -- debug -- print("[2]", loot[2]); -- debug if (loot[1]=="gil") then player:addGil(loot[2]); player:messageSpecial(GIL_OBTAINED,loot[2]); else -- Item player:addItem(loot[2]); player:messageSpecial(ITEM_OBTAINED,loot[2]); end end UpdateTreasureSpawnPoint(npc:getID()); else player:messageSpecial(CHEST_MIMIC); spawnMimic(zone,npc,player); UpdateTreasureSpawnPoint(npc:getID(), true); end end end end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) player:messageSpecial(CHEST_LOCKED,1051); 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
jshackley/darkstar
scripts/zones/Port_Jeuno/npcs/Jaipal.lua
17
1271
----------------------------------- -- Area: Port Jeuno -- NPC: Jaipal -- Standard Info NPC ----------------------------------- package.loaded["scripts/zones/Port_Jeuno/TextIDs"] = nil; require("scripts/zones/Port_Jeuno/TextIDs"); ----------------------------------- -- onTrade Action ----------------------------------- function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) local vHour = VanadielHour(); local vMin = VanadielMinute(); while vHour >= 4 do vHour = vHour - 6; end if ( vHour == -2) then vHour = 4; elseif ( vHour == -1) then vHour = 5; end local seconds = math.floor(2.4 * ((vHour * 60) + vMin)); player:startEvent( 0x272B, seconds, 0, 0, 0, 0, 0, 0, 0); end; ----------------------------------- -- onEventUpdate ----------------------------------- function onEventUpdate(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end; ----------------------------------- -- onEventFinish ----------------------------------- function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); end;
gpl-3.0
OptimusLime/lua-websockets
test-server/test-server-ev.lua
6
1174
#!/usr/bin/env lua --- lua websocket equivalent to test-server.c from libwebsockets. -- using lua-ev event loop package.path = '../src/?.lua;../src/?/?.lua;'..package.path local ev = require'ev' local loop = ev.Loop.default local websocket = require'websocket' local server = websocket.server.ev.listen { protocols = { ['lws-mirror-protocol'] = function(ws) ws:on_message( function(ws,data,opcode) if opcode == websocket.TEXT then ws:broadcast(data) end end) end, ['dumb-increment-protocol'] = function(ws) local number = 0 local timer = ev.Timer.new( function() ws:send(tostring(number)) number = number + 1 end,0.1,0.1) timer:start(loop) ws:on_message( function(ws,message,opcode) if opcode == websocket.TEXT then if message:match('reset') then number = 0 end end end) ws:on_close( function() timer:stop(loop) end) end }, port = 12345 } print('Open browser:') print('file://'..io.popen('pwd'):read()..'/index.html') loop:loop()
mit
jshackley/darkstar
scripts/globals/items/choco-katana.lua
36
1156
----------------------------------------- -- ID: 5918 -- Item: Choco-katana -- Food Effect: 3 Min, All Races ----------------------------------------- -- Agility 1 -- Speed 12.5% ----------------------------------------- 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,180,5918); end; ----------------------------------------- -- onEffectGain Action ----------------------------------------- function onEffectGain(target,effect) target:addMod(MOD_AGI, 1); target:addMod(MOD_MOVE, 13); end; ----------------------------------------- -- onEffectLose Action ----------------------------------------- function onEffectLose(target,effect) target:delMod(MOD_AGI, 1); target:delMod(MOD_MOVE, 13); end;
gpl-3.0