text:
---
--- Programmatically generated uniques live here.
--- Some uniques have to be generated because the amount of variable mods makes it infeasible to implement them manually.
--- As a result, they are forward compatible to some extent as changes to the variable mods are picked up automatically.
---

data.uniques.generated = { }

local parseVeiledModName = function(string)
	return (string:
	gsub("%JunMasterVeiled", ""):
	gsub("%Local", ""):
	gsub("%Display", ""):
	gsub("%Crafted", ""):
	gsub("(%d)h", ""):
	gsub("%_", ""):
	gsub("(%l)(%u)", "%1 %2"):
	gsub("(%d)", " %1 "))
end

local veiledModIsActive = function(mod, baseType, specificType)
	local baseIndex = isValueInTable(mod.weightKey, baseType)
	local typeIndex = isValueInTable(mod.weightKey, specificType)
	return (typeIndex and mod.weightVal[typeIndex] > 0) or (not typeIndex and baseIndex and mod.weightVal[baseIndex] > 0)
end

local getVeiledMods = function (baseType, specificType, canHaveCatarinaMod)
	local veiledMods = { }
	for veiledModIndex, veiledMod in pairs(data.veiledMods) do
		if veiledModIsActive(veiledMod, baseType, specificType) then
			local veiledName = parseVeiledModName(veiledModIndex)

			veiledName = "("..veiledMod.type..") "..veiledName

			local veiled = { veiledName = veiledName, veiledLines = { } }
			for line, value in ipairs(veiledMod) do
				veiled.veiledLines[line] = value
			end

			if (canHaveCatarinaMod or (veiledMod.affix ~= "Catarina's" and veiledMod.affix ~= "Haku's")) then
				table.insert(veiledMods, veiled)
			end
		end
	end
    table.sort(veiledMods, function (m1, m2) return m1.veiledName < m2.veiledName end )
	return veiledMods
end

local paradoxicaMods = getVeiledMods("weapon", "one_hand_weapon", false)
local paradoxica = {
	"Paradoxica",
	"Vaal Rapier",
	"League: Betrayal",
	"Has Alt Variant: true",
	"Selected Variant: 1",
	"Selected Alt Variant: 20"
}

for index, mod in pairs(paradoxicaMods) do
	if (mod.veiledName ~= "(Suffix) Double Damage Chance") then
		table.insert(paradoxica, "Variant: "..mod.veiledName)
	end
end

table.insert(paradoxica, "Source: Drops from Bosses in Safehouse")
table.insert(paradoxica, "Requires Level 66, 212 Dex")
table.insert(paradoxica, "Implicits: 1")
table.insert(paradoxica, "+25% to Global Critical Strike Multiplier")

for index, mod in pairs(paradoxicaMods) do
	if (mod.veiledName ~= "(Suffix) Double Damage Chance") then
		for _, value in pairs(mod.veiledLines) do
			table.insert(paradoxica, "{variant:"..index.."}"..value.."")
		end
	end
end

table.insert(paradoxica, "Attacks with this Weapon deal Double Damage")
table.insert(data.uniques.generated, table.concat(paradoxica, "\n"))

local caneOfKulemakMods = getVeiledMods("weapon", "staff", true)
local caneOfKulemak = {
	"Cane of Kulemak",
	"Serpentine Staff",
	"Has Alt Variant: true",
	"Has Alt Variant Two: true",
	"Selected Variant: 1",
	"Selected Alt Variant: 20"
}

for index, mod in pairs(caneOfKulemakMods) do
	table.insert(caneOfKulemak, "Variant: "..mod.veiledName)
end

table.insert(caneOfKulemak, "Requires Level 68, 85 Str, 85 Int")
table.insert(caneOfKulemak, "Implicits: 1")
table.insert(caneOfKulemak, "+20% Chance to Block Attack Damage while wielding a Staff")
table.insert(caneOfKulemak, "(60-90)% increased Unveiled Modifier magnitudes")

for index, mod in pairs(caneOfKulemakMods) do
	for _, value in pairs(mod.veiledLines) do
		table.insert(caneOfKulemak, "{variant:"..index.."}"..value.."")
	end
end

table.insert(data.uniques.generated, table.concat(caneOfKulemak, "\n"))

local replicaParadoxicaMods = getVeiledMods("weapon", "one_hand_weapon", true)
local replicaParadoxica = {
	"Replica Paradoxica",
	"Vaal Rapier",
	"League: Heist",
	"Has Alt Variant: true",
	"Has Alt Variant Two: true",
	"Has Alt Variant Three: true",
	"Has Alt Variant Four: true",
	"Has Alt Variant Five: true",
	"Selected Variant: 1",
	"Selected Alt Variant: 2",
	"Selected Alt Variant Two: 3",
	"Selected Alt Variant Three: 25",
	"Selected Alt Variant Four: 27",
	"Selected Alt Variant Five: 34"
}

for index, mod in pairs(replicaParadoxicaMods) do
	table.insert(replicaParadoxica, "Variant: "..mod.veiledName)
end

table.insert(replicaParadoxica, "Requires Level 66, 212 Dex")
table.insert(replicaParadoxica, "Implicits: 1")
table.insert(replicaParadoxica, "+25% to Global Critical Strike Multiplier")

for index, mod in pairs(replicaParadoxicaMods) do
	for _, value in pairs(mod.veiledLines) do
		table.insert(replicaParadoxica, "{variant:"..index.."}"..value.."")
	end
end

table.insert(data.uniques.generated, table.concat(replicaParadoxica, "\n"))

local queensHungerMods = getVeiledMods("body_armour", "int_armour", false)
local queensHunger = {
	"The Queen's Hunger",
	"Vaal Regalia",
	"League: Betrayal",
	"Has Alt Variant: true",
	"Selected Variant: 1",
	"Selected Alt Variant: 24"
}

for index, mod in pairs(queensHungerMods) do
	table.insert(queensHunger, "Variant: "..mod.veiledName)
end

table.insert(queensHunger, "Requires Level 68, 194 Int")
table.insert(queensHunger, "Trigger Level 20 Bone Offering, Flesh Offering or Spirit Offering every 5 seconds")
table.insert(queensHunger, "Offering Skills Triggered this way also affect you")
table.insert(queensHunger, "(5-10)% increased Cast Speed")
table.insert(queensHunger, "(100-130)% increased Energy Shield")
table.insert(queensHunger, "(6-10)% increased maximum Life")

for index, mod in pairs(queensHungerMods) do
	for _, value in pairs(mod.veiledLines) do
		table.insert(queensHunger, "{variant:"..index.."}"..value.."")
	end
end

table.insert(data.uniques.generated, table.concat(queensHunger, "\n"))

local megalomaniac = {
	"Megalomaniac",
	"Medium Cluster Jewel",
	"League: Delirium",
	"Source: Drops from the Simulacrum Encounter",
	"Has Alt Variant: true",
	"Has Alt Variant Two: true",
	"Adds 4 Passive Skills",
	"Added Small Passive Skills grant Nothing",
}
local notables = { }
for name in pairs(data.clusterJewels.notableSortOrder) do
	table.insert(notables, name)
end
table.sort(notables)
for index, name in ipairs(notables) do
	table.insert(megalomaniac, "Variant: "..name)
	table.insert(megalomaniac, "{variant:"..index.."}1 Added Passive Skill is "..name)
end
table.insert(data.uniques.generated, table.concat(megalomaniac, "\n"))

local forbiddenShako = {
	"Forbidden Shako",
	"Great Crown",
	"League: Harvest",
	"Source: Drops from unique{Avatar of the Grove}",
	"Requires Level 68, 59 Str, 59 Int",
	"Has Alt Variant: true"
}
local replicaForbiddenShako = {
	"Replica Forbidden Shako",
	"Great Crown",
	"League: Heist",
	"Source: Steal from a unique{Curio Display} during a Grand Heist",
	"Requires Level 68, 59 Str, 59 Int",
	"Has Alt Variant: true"
}
local excludedGems = {
	"Block Chance Reduction",
	"Empower",
	"Enhance",
	"Enlighten",
	"Item Quantity",
}
local gems = { }
for _, gemData in pairs(data.gems) do
	local grantedEffect = gemData.grantedEffect
	if grantedEffect.support and not (grantedEffect.plusVersionOf) and not isValueInArray(excludedGems, grantedEffect.name) then
		table.insert(gems, grantedEffect.name)
	end
end
table.sort(gems)
for index, name in ipairs(gems) do
	table.insert(forbiddenShako, "Variant: "..name.. " (Low Level)")
	table.insert(forbiddenShako, "{variant:"..(index * 2 - 1).."}Socketed Gems are Supported by Level (1-10) "..name)
	table.insert(forbiddenShako, "Variant: "..name.. " (High Level)")
	table.insert(forbiddenShako, "{variant:"..(index * 2).."}Socketed Gems are Supported by Level (25-35) "..name)
	table.insert(replicaForbiddenShako, "Variant: "..name.. " (Low Level)")
	table.insert(replicaForbiddenShako, "{variant:"..(index * 2 - 1).."}Socketed Gems are Supported by Level (1-10) "..name)
	table.insert(replicaForbiddenShako, "Variant: "..name.. " (High Level)")
	table.insert(replicaForbiddenShako, "{variant:"..(index * 2).."}Socketed Gems are Supported by Level (25-35) "..name)
end
table.insert(forbiddenShako, "+(25-30) to all Attributes")
table.insert(replicaForbiddenShako, "+(25-30) to all Attributes")
table.insert(data.uniques.generated, table.concat(forbiddenShako, "\n"))
table.insert(data.uniques.generated, table.concat(replicaForbiddenShako, "\n"))

local enduranceChargeMods = {
	[3] = {
		["Up to Max."] = "15% chance that if you would gain Endurance Charges, you instead gain up to your maximum number of Endurance Charges",
		["Duration"] = "(20-40)% increased Endurance Charge Duration",
		["Movement Speed"] = "1% increased Movement Speed per Endurance Charge",
		["Armour"] = "6% increased Armour per Endurance Charge",
		["Add Fire Damage"] = "(7-9) to (13-14) Fire Damage per Endurance Charge",
		["Inc. Damage"] = "5% increased Damage per Endurance Charge",
		["On Kill"] = "10% chance to gain an Endurance Charge on Kill",
	},
	[2] = {
		["Block Attacks"] = "1% Chance to Block Attack Damage per Endurance Charge",
		["Spell Suppression"] = "1% chance to Suppress Spell Damage per Endurance Charge",
		["Chaos Res"] = "+4% to Chaos Resistance per Endurance Charge",
		["Fire as Chaos"] = "Gain 1% of Fire Damage as Extra Chaos Damage per Endurance Charge",
		["Attack and Cast Speed"] = "1% increased Attack and Cast Speed per Endurance Charge",
		["Regen. Life"] = "Regenerate 0.3% of Life per second per Endurance Charge",
		["Inc. Critical Strike Chance"] = "6% increased Critical Strike Chance per Endurance Charge",
	},
	[1] = {
		["Gain every second"] = "Gain an Endurance Charge every second if you've been Hit Recently",
		["+1 Maximum"] = "+1 to Maximum Endurance Charges",
		["Cannot be Stunned"] = "You cannot be Stunned while at maximum Endurance Charges",
		["Vaal Pact"] = "You have Vaal Pact while at maximum Endurance Charges",
		["Intimidate"] = "Intimidate Enemies for 4 seconds on Hit with Attacks while at maximum Endurance Charges",
	},
}

local frenzyChargeMods = {
	[3] = {
		["Up to Max."] = "15% chance that if you would gain Frenzy Charges, you instead gain up to your maximum number of Frenzy Charges",
		["Duration"] = "(20-40)% increased Frenzy Charge Duration",
		["Movement Speed"] = "1% increased Movement Speed per Frenzy Charge",
		["Evasion"] = "8% increased Evasion Rating per Frenzy Charge",
		["Add Cold Damage"] = "(6-8) to (12-13) Cold Damage per Frenzy Charge",
		["Inc. Damage"] = "5% increased Damage per Frenzy Charge",
		["On Kill"] = "10% chance to gain an Frenzy Charge on Kill",
	},
	[2] = {
		["Block Attacks"] = "1% Chance to Block Attack Damage per Frenzy Charge",
		["Spell Suppression"] = "1% chance to Suppress Spell Damage per Frenzy Charge",
		["Accuracy Rating"] = "10% increased Accuracy Rating per Frenzy Charge",
		["Cold as Chaos"] = "Gain 1% of Cold Damage as Extra Chaos Damage per Frenzy Charge",
		["Attack and Cast Speed"] = "1% increased Attack and Cast Speed per Frenzy Charge",
		["Regen. Life"] = "Regenerate 0.3% of Life per second per Frenzy Charge",
		["Inc. Critical Strike Chance"] = "6% increased Critical Strike Chance per Frenzy Charge",
	},
	[1] = {
		["Gain on Hit"] = "10% chance to gain a Frenzy Charge on Hit",
		["+1 Maximum"] = "+1 to Maximum Frenzy Charges",
		["Flask Charge on Crit"] = "Gain a Flask Charge when you deal a Critical Strike while at maximum Frenzy Charges*",
		["Iron Reflexes"] = "You have Iron Reflexes while at maximum Frenzy Charges",
		["Onslaught"] = "Gain Onslaught for 4 seconds on Hit while at maximum Frenzy Charges*",
	},
}

local powerChargeMods = {
	[3] = {
		["Up to Max."] = "15% chance that if you would gain Power Charges, you instead gain up to your maximum number of Power Charges",
		["Duration"] = "(20-40)% increased Power Charge Duration",
		["Movement Speed"] = "1% increased Movement Speed per Power Charge",
		["Energy Shield"] = "3% increased Energy Shield per Power Charge",
		["Add Lightning Damage"] = "(1-2) to (18-20) Lightning Damage per Power Charge",
		["Inc. Damage"] = "5% increased Damage per Power Charge",
		["On Kill"] = "10% chance to gain an Power Charge on Kill",
	},
	[2] = {
		["Block Attacks"] = "1% Chance to Block Attack Damage per Power Charge",
		["Spell Suppression"] = "1% chance to Suppress Spell Damage per Power Charge",
		["Phys. Damage Red."] = "1% additional Physical Damage Reduction per Power Charge",
		["Lightning as Chaos"] = "Gain 1% of Lightning Damage as Extra Chaos Damage per Power Charge",
		["Attack and Cast Speed"] = "1% increased Attack and Cast Speed per Power Charge",
		["Regen. Life"] = "Regenerate 0.3% of Life per second per Power Charge",
		["Crit Strike Multi"] = "+3% to Critical Strike Multiplier per Power Charge",
	},
	[1] = {
		["Gain on Crit"] = "20% chance to gain a Power Charge on Critical Strike",
		["+1 Maximum"] = "+1 to Maximum Power Charges",
		["Arcane Surge with Spells"] = "Gain Arcane Surge on Hit with Spells while at maximum Power Charges",
		["Mind over Matter"] = "You have Mind over Matter while at maximum Power Charges",
		["Additional Curse"] = "You can apply an additional Curse while at maximum Power Charges",
	},
}

local precursorsEmblem = {
[[Precursor's Emblem
League: Delve
Variant: Topaz Ring
Variant: Sapphire Ring
Variant: Ruby Ring
Variant: Two-Stone Ring (Cold/Lightning)
Variant: Two-Stone Ring (Fire/Lightning)
Variant: Two-Stone Ring (Fire/Cold)
Variant: Prismatic Ring]]
}

for _, type in ipairs({ { prefix = "Endurance - ", mods = enduranceChargeMods }, { prefix = "Frenzy - ", mods = frenzyChargeMods }, { prefix = "Power - ", mods = powerChargeMods } }) do
	for tier, mods in ipairs(type.mods) do
		for desc, mod in pairs(mods) do
			table.insert(precursorsEmblem, "Variant: " .. type.prefix .. desc)
		end
	end
end
table.insert(precursorsEmblem, [[Selected Variant: 1
{variant:1}Topaz Ring
{variant:2}Sapphire Ring
{variant:3}Ruby Ring
{variant:4}Two-Stone Ring (Cold/Lightning)
{variant:5}Two-Stone Ring (Fire/Lightning)
{variant:6}Two-Stone Ring (Fire/Cold)
{variant:7}Prismatic Ring
Has Alt Variant: true
Has Alt Variant Two: true
Has Alt Variant Three: true
LevelReq: 49
Implicits: 7
{tags:jewellery_resistance}{variant:1}+(20-30)% to Lightning Resistance
{tags:jewellery_resistance}{variant:2}+(20-30)% to Cold Resistance
{tags:jewellery_resistance}{variant:3}+(20-30)% to Fire Resistance
{tags:jewellery_resistance}{variant:4}+(12-16)% to Cold and Lightning Resistances
{tags:jewellery_resistance}{variant:5}+(12-16)% to Fire and Lightning Resistances
{tags:jewellery_resistance}{variant:6}+(12-16)% to Fire and Cold Resistances
{tags:jewellery_resistance}{variant:7}+(8-10)% to all Elemental Resistances
{tags:jewellery_attribute}{variant:1}+20 to Intelligence
{tags:jewellery_attribute}{variant:2}+20 to Dexterity
{tags:jewellery_attribute}{variant:3}+20 to Strength
{tags:jewellery_attribute}{variant:4}+20 to Strength and Intelligence
{tags:jewellery_attribute}{variant:5}+20 to Dexterity and Intelligence
{tags:jewellery_attribute}{variant:6}+20 to Strength and Dexterity
{tags:jewellery_attribute}{variant:7}+20 to all Attributes
{tags:jewellery_defense}5% increased maximum Energy Shield
{tags:life}5% increased maximum Life]])

local index = 8
for _, type in ipairs({ enduranceChargeMods, frenzyChargeMods, powerChargeMods }) do
	for tier, mods in ipairs(type) do
		for desc, mod in pairs(mods) do
			if mod:match("[%+%-]?[%d%.]*%d+%%") then
				mod = mod:gsub("([%d%.]*%d+)", function(num) return "(" .. num .. "-" .. tonumber(num) * tier .. ")" end)
			elseif mod:match("%(%-?[%d%.]+%-[%d%.]+%)%%") then
				mod = mod:gsub("(%(%-?[%d%.]+%-)([%d%.]+)%)", function(preceeding, higher) return preceeding .. tonumber(higher) * tier .. ")" end)
			elseif mod:match("%(%d+%-%d+%) to %(%d+%-%d+%)") then
				mod = mod:gsub("(%(%d+%-)(%d+)(%) to %(%d+%-)(%d+)%)", function(preceeding, higher1, middle, higher2) return preceeding .. higher1 * tier .. middle .. higher2 * tier .. ")" end)
			end
			table.insert(precursorsEmblem, "{variant:" .. index .. "}{range:0}" .. mod)
			index = index + 1
		end
	end
end
table.insert(data.uniques.generated, table.concat(precursorsEmblem, "\n"))

local skinOfTheLords = {
	"Skin of the Lords",
	"Simple Robe",
	"League: Breach",
	"Source: Upgraded from unique{Skin of the Loyal} using currency{Blessing of Chayula}",
}
local excludedKeystones = {
	"Chaos Inoculation", -- to prevent infinite loop
	"Corrupted Soul", -- exclusive to specific unique
	"Divine Flesh", -- exclusive to specific unique
	"Hollow Palm Technique", -- exclusive to specific unique
	"Immortal Ambition", -- exclusive to specific unique
	"Necromantic Aegis", -- to prevent infinite loop
	"Secrets of Suffering", -- exclusive to specific items
}
local keystones = {}
for _, name in ipairs(data.keystones) do
	if not isValueInArray(excludedKeystones, name) then
		table.insert(keystones, name)
	end
end
for _, name in ipairs(keystones) do
	table.insert(skinOfTheLords, "Variant: "..name)
end
table.insert(skinOfTheLords, "Implicits: 0")
table.insert(skinOfTheLords, "Sockets cannot be modified")
table.insert(skinOfTheLords, "+2 to Level of Socketed Gems")
table.insert(skinOfTheLords, "100% increased Global Defences")
table.insert(skinOfTheLords, "You can only Socket Corrupted Gems in this item")
for index, name in ipairs(keystones) do
	table.insert(skinOfTheLords, "{variant:"..index.."}"..name)
end
table.insert(skinOfTheLords, "Corrupted")
table.insert(data.uniques.generated, table.concat(skinOfTheLords, "\n"))

--[[ 3 scenarios exist for legacy mods
	- Mod changed, but kept the same mod Id
		-- Has legacyMod
	- Mod removed, or changed with a new mod Id
		-- Has only a version when it changed
	- Mod changed/removed, but isn't legacy
		-- Has empty table to exclude it from the list
]]
local watchersEyeLegacyMods = {
	["ClarityManaAddedAsEnergyShield"] = {
		["version"] = "3.12.0",
		["legacyMod"] = function(currentMod) return (currentMod:gsub("%(.*%)", "(12-18)")) end,
	},
	["ClarityReducedManaCost"] = {
		["version"] = "3.8.0",
	},
	["ClarityManaRecoveryRate"] = {
		["version"] = "3.12.0",
		["legacyMod"] = function(currentMod) return (currentMod:gsub("%(.*%)", "(20-30)")) end,
	},
	["DisciplineEnergyShieldRecoveryRate"] = {
		["version"] = "3.12.0",
		["legacyMod"] = function(currentMod) return (currentMod:gsub("%(.*%)", "(20-30)")) end,
	},
	["MalevolenceDamageOverTimeMultiplier"] = {
		["version"] = "3.8.0",
		["legacyMod"] = function(currentMod) return (currentMod:gsub("%(.*%)", "(36-44)")) end,
	},
	["MalevolenceLifeAndEnergyShieldRecoveryRate"] = {
		["version"] = "3.12.0",
		["legacyMod"] = function(currentMod) return (currentMod:gsub("%(.*%)", "(15-20)")) end,
	},
	["PrecisionIncreasedCriticalStrikeMultiplier"] = {
		["version"] = "3.12.0",
		["legacyMod"] = function(currentMod) return (currentMod:gsub("%(.*%)", "(30-50)")) end,
	},
	["VitalityDamageLifeLeech"] = {
		["version"] = "3.12.0",
		["legacyMod"] = function(currentMod) return (currentMod:gsub("%(.*%)", "(1-1.5)")) end,
	},
	["VitalityFlatLifeRegen"] = {
		["version"] = "3.12.0",
	},
	["VitalityLifeRecoveryRate"] = {
		["version"] = "3.12.0",
		["legacyMod"] = function(currentMod) return (currentMod:gsub("%(.*%)", "(20-30)")) end,
	},
	["WrathLightningDamageManaLeech"] = {
		["version"] = "3.8.0",
	},
	["PurityOfFireReducedReflectedFireDamage"] = { },
	["PurityOfIceReducedReflectedColdDamage"] = { },
	["PurityOfLightningReducedReflectedLightningDamage"] = { },
	["MalevolenceSkillEffectDuration"] = { },
	["ZealotryMaximumEnergyShieldPerSecondToMaximumEnergyShieldLeechRate"] = { },
	["MalevolenceColdDamageOverTimeMultiplier"] = { },
	["MalevolenceChaosNonAilmentDamageOverTimeMultiplier"] = { },
}

local watchersEye = {
[[
Watcher's Eye
Prismatic Jewel
Source: Drops from unique{The Elder}
Has Alt Variant: true
Has Alt Variant Two: true
]]
}

local abbreviateModId = function(string)
	return (string:
	gsub("Increased", "Inc"):
	gsub("Reduced", "Red."):
	gsub("Critical", "Crit"):
	gsub("Physical", "Phys"):
	gsub("Elemental", "Ele"):
	gsub("Multiplier", "Mult"):
	gsub("EnergyShield", "ES"))
end

for _, mod in ipairs(data.uniqueMods["Watcher's Eye"]) do
	local variantName = abbreviateModId(mod.Id):gsub("^[Purity Of ]*%u%l+", "%1:"):gsub("New", ""):gsub("[%u%d]", " %1"):gsub("_", ""):gsub("E S", "ES")


text:
--- Turbo.lua signalfd example
--
-- Copyright 2014 John Abrahamsen
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

local turbo = require("turbo")
local io = turbo.ioloop.instance()

print("Press CTRL-C 3 times to exit")

io:add_callback(function ()
    local times = 0
    io:add_signal_handler(turbo.signal.SIGINT, function (signum, info)
        print(string.format("\nReceived signal SIGINT (%d)", signum))
        times = times + 1
        if times == 3 then
            io:close()
        end
    end)
end)
io:start()

domain: lua


text:
-- appM environment keybindings. Bundle `id` is prefered, but application `name` will be ok.
hsapp_list = {
    {key = 'a', name = 'Atom'},
    {key = 'c', id = 'com.google.Chrome'},
    {key = 'd', name = 'ShadowsocksX'},
    {key = 'e', name = 'Emacs'},
    {key = 'f', name = 'Finder'},
    {key = 'i', name = 'iTerm'},
    {key = 'k', name = 'KeyCastr'},
    {key = 'l', name = 'Sublime Text'},
    {key = 'm', name = 'MacVim'},
    {key = 'o', name = 'LibreOffice'},
    {key = 'p', name = 'mpv'},
    {key = 'r', name = 'VimR'},
    {key = 's', name = 'Safari'},
    {key = 't', name = 'Terminal'},
    {key = 'v', id = 'com.apple.ActivityMonitor'},
    {key = 'w', name = 'Mweb'},
    {key = 'y', id = 'com.apple.systempreferences'},
}

obj = {}
function obj.reKey1()
    print("this Is rekey1")

----------------------------------------------------------------------------------------------------
-- appM modal environment
spoon.ModalMgr:new("appM")
local cmodal = spoon.ModalMgr.modal_list["appM"]
cmodal:bind('', 'escape', 'Deactivate appM', function() spoon.ModalMgr:deactivate({"appM"}) end)
cmodal:bind('', 'Q', 'Deactivate appM', function() spoon.ModalMgr:deactivate({"appM"}) end)
cmodal:bind('', 'tab', 'Toggle Cheatsheet', function() spoon.ModalMgr:toggleCheatsheet() end)
if not hsapp_list then
    print('aaaaaaa')
  hsapp_list = {
        {key = 'f', name = 'Finder'},
        {key = 's', name = 'Safari'},
        {key = 't', name = 'Terminal'},
        {key = 'v', id = 'com.apple.ActivityMonitor'},
        {key = 'y', id = 'com.apple.systempreferences'},
    }
end
for _, v in ipairs(hsapp_list) do
    if v.id then
        local located_name = hs.application.nameForBundleID(v.id)
        if located_name then
            cmodal:bind('', v.key, located_name, function()
                hs.application.launchOrFocusByBundleID(v.id)
                spoon.ModalMgr:deactivate({"appM"})
            end)
        end
    elseif v.name then
        cmodal:bind('', v.key, v.name, function()
            hs.application.launchOrFocus(v.name)
            spoon.ModalMgr:deactivate({"appM"})
        end)
    end
end

----------------------------------------------------------------------------------------------------
-- Then we create/register all kinds of modal keybindings environments.
----------------------------------------------------------------------------------------------------
-- Register windowHints (Register a keybinding which is NOT modal environment with modal supervisor)
hswhints_keys = hswhints_keys or {"alt", "tab"}
if string.len(hswhints_keys[2]) > 0 then
    spoon.ModalMgr.supervisor:bind(hswhints_keys[1], hswhints_keys[2], 'Show Window Hints', function()
        spoon.ModalMgr:deactivateAll()
        hs.hints.windowHints()
    end)
end

------ Then we register some keybindings with modal supervisor
hsappM_keys = hsappM_keys or {"alt", "A"}
if string.len(hsappM_keys[2]) > 0 then
    print("this is keyboard")
    spoon.ModalMgr.supervisor:bind(hsappM_keys[1], hsappM_keys[2], "Enter AppM Environment", function()
        spoon.ModalMgr:deactivateAll()
        -- Show the keybindings cheatsheet once appM is activated
        spoon.ModalMgr:activate({"appM"}, "#FFBD2E", true)
    end)
end
end
return obj

--k-- Modal supervisor keybinding, which can be used to temporarily disable ALL modal environments.
--khsupervisor_keys = {{"cmd", "shift", "ctrl"}, "Q"}
--k
--k-- Reload Hammerspoon configuration
--khsreload_keys = {{"cmd", "shift", "ctrl"}, "R"}
--k
--k-- Toggle help panel of this configuration.
--khshelp_keys = {{"alt", "shift"}, "/"}
--k
--k-- aria2 RPC host address
--khsaria2_host = "http://localhost:6800/jsonrpc"
--k-- aria2 RPC host secret
--khsaria2_secret = "token"
--k
--k----------------------------------------------------------------------------------------------------
--k-- Those keybindings below could be disabled by setting to {"", ""} or {{}, ""}
--k
--k-- Window hints keybinding: Focuse to any window you want
--khswhints_keys = {"alt", "tab"}
--k
--k-- appM environment keybinding: Application Launcher
--khsappM_keys = {"alt", "A"}
--k
--k-- clipshowM environment keybinding: System clipboard reader
--khsclipsM_keys = {"alt", "C"}
--k
--k-- Toggle the display of aria2 frontend
--khsaria2_keys = {"alt", "D"}
--k
--k-- Launch Hammerspoon Search
--khsearch_keys = {"alt", "G"}
--k
--k-- Read Hammerspoon and Spoons API manual in default browser
--khsman_keys = {"alt", "H"}
--k
--k-- countdownM environment keybinding: Visual countdown
--khscountdM_keys = {"alt", "I"}
--k
--k-- Lock computer's screen
--khslock_keys = {"alt", "L"}
--k
--k-- resizeM environment keybinding: Windows manipulation
--khsresizeM_keys = {"alt", "R"}
--k
--k-- cheatsheetM environment keybinding: Cheatsheet copycat
--khscheats_keys = {"alt", "S"}
--k
--k-- Show digital clock above all windows
--khsaclock_keys = {"alt", "T"}
--k
--k-- Type the URL and title of the frontmost web page open in Google Chrome or Safari.
--khstype_keys = {"alt", "V"}
--k
--k-- Toggle Hammerspoon console
--khsconsole_keys = {"alt", "Z"}
--k
--


text:
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")

include("shared.lua")

function ENT:Initialize()
	self:SetModel( "models/props_trainstation/trainstation_clock001.mdl" )
	self:PhysicsInit( SOLID_VPHYSICS )      -- Make us work with physics,
	self:SetMoveType( MOVETYPE_VPHYSICS )   -- after all, gmod is a physics
	self:SetSolid( SOLID_VPHYSICS )         -- Toolbox

	self.RenderMode = 1

	self:SetRenderMode(RENDERMODE_TRANSALPHA)
	self:SetUseType( SIMPLE_USE )
	if WireAddon then
		self.Outputs = Wire_CreateOutputs(self, {
			"Clock_24 [STRING]",
			"Clock_12 [STRING]",
			"Clock_raw"
		})
		Wire_TriggerOutput(self, "Clock_raw", StormFox.GetTime(true))
		Wire_TriggerOutput(self, "Clock_24", StormFox.GetRealTime(nil))
		Wire_TriggerOutput(self, "Clock_12", StormFox.GetRealTime(nil,true))
	end

	self:SetKeyValue("fademindist", 1500)
	self:SetKeyValue("fademaxdist", 1500)
end

local function SetWire(self,data,value)
	if self.Outputs[data].Value != value then
		Wire_TriggerOutput(self, data, value)
	end
end

local l = 0
function ENT:Think()
	if not WireAddon then return end
	if l > SysTime() then return end
		l = SysTime() + 1
	SetWire(self, "Clock_raw", StormFox.GetTime(true))
	SetWire(self, "Clock_24", StormFox.GetRealTime(nil))
	SetWire(self, "Clock_12", StormFox.GetRealTime(nil,true))
end

function ENT:SpawnFunction( ply, tr, ClassName )

	if ( !tr.Hit ) then return end

	local SpawnPos = tr.HitPos + tr.HitNormal * 16

	local ent = ents.Create( ClassName )
	ent:SetPos( SpawnPos )
	ent:SetAngles(Angle(0,ply:EyeAngles().y + 180,0))
	ent:Spawn()
	ent:Activate()

	return ent

end


text:
local igwin = require"imgui.window"
--local win = igwin:SDL(800,400, "widgets")
local win = igwin:GLFW(800,400, "widgets")

local ffi = require"ffi"
local val = ffi.new("float[1]")
local padval = ffi.new("float[2]")
local curve = win.ig.Curve("mycurve",12,100)
local Quat = ffi.new("quat",{1,0,0,0})
local v3 = ffi.new("G3Dvec3",{1,0,0})
local mat4 = win.ig.mat4_cast(Quat)

function win:draw(ig)

	if ig.Begin("widgets",nil, ig.lib.ImGuiWindowFlags_AlwaysAutoResize) then
		if ig.TreeNode"dial" then
			ig.dial("turns",val,nil,0.5/math.pi)
			ig.SameLine()
			ig.dial("radians",val)
			ig.TreePop();
			ig.Separator();
		end
		if ig.TreeNode"pad" then
			ig.pad("mypad", padval)
			ig.InputFloat2("vals",padval)
			ig.TreePop();
			ig.Separator();
		end
		if ig.TreeNode"curve" then
			if curve:draw(ig.ImVec2(400,300)) then
			--do something with curve.LUT array of 100 floats
			end
			ig.InputFloat2("first two",curve.LUT, nil, ig.lib.ImGuiInputTextFlags_ReadOnly)
			ig.TreePop();
			ig.Separator();
		end
		if ig.TreeNode"gizmoquat" then

			if ig.gizmo3D("###guizmo0",v3,Quat,150) then
				mat4 = ig.mat4_pos_cast(Quat,v3)
			end

			ig.SameLine()
			ig.BeginGroup()
			ig.InputFloat4("##1",mat4.f, nil, ig.lib.ImGuiInputTextFlags_ReadOnly)
			ig.InputFloat4("##2",mat4.f+4, nil, ig.lib.ImGuiInputTextFlags_ReadOnly)
			ig.InputFloat4("##3",mat4.f+8, nil, ig.lib.ImGuiInputTextFlags_ReadOnly)
			ig.InputFloat4("##4",mat4.f+12, nil, ig.lib.ImGuiInputTextFlags_ReadOnly)
			ig.EndGroup()
			ig.imguiGizmo_setDirectionColor(ig.ImVec4(1,0,0,1))
			ig.gizmo3D("guizmo3",v3,150)
			ig.imguiGizmo_restoreDirectionColor()
			ig.InputFloat3("dir",ffi.new("float[3]",{v3.x,v3.y,v3.z}), nil, ig.lib.ImGuiInputTextFlags_ReadOnly)
			ig.TreePop();
			ig.Separator();
		end
	end
	ig.End()
end

win:start()


text:
local cmp = require("cmp")
local lspkind = require("lspkind")

local has_words_before = function()
	local line, col = unpack(vim.api.nvim_win_get_cursor(0))
	return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end

local feedkey = function(key, mode)
	vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
end

cmp.setup({
	formatting = {
		format = lspkind.cmp_format({
			with_text = true,
			menu = {
				buffer = "[Buffer]",
				nvim_lsp = "[LSP]",
				nvim_lua = "[Lua]",
			},
		}),
	},
	experimental = {
		ghost_text = false,
		native_menu = false,
	},
	snippet = {
		-- REQUIRED - you must specify a snippet engine
		expand = function(args)
			vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
		end,
	},
	mapping = {
		["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }),
		["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }),
		["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
		["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
		["<C-e>"] = cmp.mapping({
			i = cmp.mapping.abort(),
			c = cmp.mapping.close(),
		}),
		["<CR>"] = cmp.mapping.confirm({ select = true }),
		["<Tab>"] = cmp.mapping(function(fallback)
			if cmp.visible() then
				cmp.select_next_item()
			elseif vim.fn["vsnip#available"](1) == 1 then
				feedkey("<Plug>(vsnip-expand-or-jump)", "")
			elseif has_words_before() then
				cmp.complete()
			else
				fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
			end
		end, { "i", "s" }),

		["<S-Tab>"] = cmp.mapping(function()
			if cmp.visible() then
				cmp.select_prev_item()
			elseif vim.fn["vsnip#jumpable"](-1) == 1 then
				feedkey("<Plug>(vsnip-jump-prev)", "")
			end
		end, { "i", "s" }),
	},
	sources = cmp.config.sources({
		{ name = "nvim_lsp" },
		{ name = "vsnip" },
		{ name = "buffer" },
		{ name = "buffer" },
	}),
	documentation = {
		border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
	},
})

-- TODO: Enable this and make it work?

-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
-- cmp.setup.cmdline('/', {
--     sources = {
--         { name = 'buffer' }
--     }
-- })

-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
-- cmp.setup.cmdline(':', {
--     sources = cmp.config.sources(
--         {
--             { name = 'path' }
--         },
--         {
--             { name = 'cmdline' }
--         }
--     )
-- })


text:
local m = require("api")

-- client: path, password, if create
local wallet = client.new("keystore.dat", "123", false)

-- account
local addr = wallet:get_address()
local pubkey = wallet:get_publickey()
print(addr)
print(pubkey)

-- asset_id
local asset_id = m.get_asset_id()

-- fee
local fee = 0.001

-- deposit params
local own_publickey = "034f3a7d2f33ac7f4e30876080d359ce5f314c9eabddbaaca637676377f655e16c"
local node_publickey = "03c77af162438d4b7140f8544ad6523b9734cca9c7a62476d54ed5d1bddc7a39c3"
local nick_name = "ela_test1"
local url = "ela_test1.org"
local location = "112212"
local host_address = "10.10.0.2"

-- update producer payload: publickey, nickname, url, local, host, wallet
local up_payload = updateproducer.new(own_publickey, node_publickey, nick_name, url, location, host_address, wallet)
print(up_payload:get())

-- transaction: version, txType, payloadVersion, payload, locktime
local tx = transaction.new(9, 0x0b, 0, up_payload, 0)

-- input: from, amount + fee
local charge = tx:appendenough(addr, fee * 100000000)
print(charge)

-- outputpayload
local default_output = defaultoutput.new()

-- output: asset_id, value, recipient, output_paload_type, outputpaload
local charge_output = output.new(asset_id, charge, addr, 0, default_output)
tx:appendtxout(charge_output)
-- print(charge_output:get())

-- sign
tx:sign(wallet)
print(tx:get())

-- send
local hash = tx:hash()
local res = m.send_tx(tx)

print("sending " .. hash)

if (res ~= hash)
then
    print(res)
else
    print("tx send success")
end


text:
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")

include("shared.lua")

AccessorFunc(ENT, "m_eIndicator", "Indicator")

------------------------------------------------
--
------------------------------------------------

function ENT:Initialize()
	self:DrawShadow(false)

	local id = self:GetID()
	local doors = ents.FindByClass("func_door")

	self.doors = {}

	for k, door in pairs(doors) do
		if (door.id == id) then
			table.insert(self.doors, door)
		end
	end
end

------------------------------------------------
--
------------------------------------------------

function ENT:KeyValue(key, value)
	if (key == "hammerid") then
		self:SetID(value)
	end
end

------------------------------------------------
--
------------------------------------------------

function ENT:UpdateTransmitState()
	return TRANSMIT_ALWAYS
end

------------------------------------------------
--
------------------------------------------------

function ENT:OpenDoors()
	for i = 1, #self.doors do
		local door = self.doors[i]

		door:Fire("Unlock", nil, 0)
		door:Fire("Open", nil, 0)

		local indicator = self:GetIndicator()

		indicator:SetGreen()
	end
end

------------------------------------------------
--
------------------------------------------------

function ENT:CloseDoors()
	for i = 1, #self.doors do
		local door = self.doors[i]

		door:Fire("Close", nil, 0)

		local indicator = self:GetIndicator()

		indicator:SetRed()
	end
end


text:
local cinnabar_0 = DoorSlot("cinnabar","0")
local cinnabar_0_hub = DoorSlotHub("cinnabar","0",cinnabar_0)
cinnabar_0:setHubIcon(cinnabar_0_hub)
local cinnabar_1 = DoorSlot("cinnabar","1")
local cinnabar_1_hub = DoorSlotHub("cinnabar","1",cinnabar_1)
cinnabar_1:setHubIcon(cinnabar_1_hub)
local cinnabar_2 = DoorSlot("cinnabar","2")
local cinnabar_2_hub = DoorSlotHub("cinnabar","2",cinnabar_2)
cinnabar_2:setHubIcon(cinnabar_2_hub)
local cinnabar_3 = DoorSlot("cinnabar","3")
local cinnabar_3_hub = DoorSlotHub("cinnabar","3",cinnabar_3)
cinnabar_3:setHubIcon(cinnabar_3_hub)
local cinnabar_4 = DoorSlot("cinnabar","4")
local cinnabar_4_hub = DoorSlotHub("cinnabar","4",cinnabar_4)
cinnabar_4:setHubIcon(cinnabar_4_hub)
local cinnabar_5 = DoorSlot("cinnabar","5")
local cinnabar_5_hub = DoorSlotHub("cinnabar","5",cinnabar_5)
cinnabar_5:setHubIcon(cinnabar_5_hub)
local cinnabar_6 = DoorSlot("cinnabar","6")
local cinnabar_6_hub = DoorSlotHub("cinnabar","6",cinnabar_6)
cinnabar_6:setHubIcon(cinnabar_6_hub)
local cinnabar_7 = DoorSlot("cinnabar","7")
local cinnabar_7_hub = DoorSlotHub("cinnabar","7",cinnabar_7)
cinnabar_7:setHubIcon(cinnabar_7_hub)
local cinnabar_8 = DoorSlot("cinnabar","8")
local cinnabar_8_hub = DoorSlotHub("cinnabar","8",cinnabar_8)
cinnabar_8:setHubIcon(cinnabar_8_hub)


text:
--REAL CS BASE
--sorry for no comments to show what everything does im too lazy to do it LOL!

if (SERVER) then

	AddCSLuaFile("shared.lua")
	SWEP.Weight				= 5

end

if (CLIENT) then
	SWEP.PrintName			= "Laser Pistol"
	SWEP.Author				= "kurozael"
	SWEP.SlotPos			= 2
	SWEP.IconLetter			= "a"
	SWEP.Slot				= 1
	SWEP.NameOfSWEP			= "cw_laserpistol" --always make this the name of the folder the SWEP is in.
	killicon.AddFont(SWEP.NameOfSWEP, "CSKillIcons", SWEP.IconLetter, Color(255, 80, 0, 255))
end

SWEP.Category				= "RealCS"
SWEP.Base					= "rcs_base_pistol"

SWEP.Spawnable				= true
SWEP.AdminSpawnable			= true
SWEP.Tracer = 1;
SWEP.ViewModel				= "models/weapons/v_pist_p228.mdl"
SWEP.WorldModel				= "models/weapons/w_pist_p228.mdl"
	SWEP.HoldType			= "pistol"
SWEP.Weight					= 5
SWEP.AutoSwitchTo			= false
SWEP.AutoSwitchFrom			= false
SWEP.TracerName = "cw_lasertracer"

SWEP.Primary.Sound			= Sound("weapons/LaserPistol_Fire.wav")
SWEP.Primary.EmptyWepSound	= Sound("weapons/LaserPistol_NoAmmo.wav")

SWEP.Primary.Recoil			= 0.25
SWEP.Primary.Damage			= 32
SWEP.Primary.NumShots		= 1
SWEP.Primary.Cone			= 0.0001 --starting cone, it WILL increase to something higher, so keep it low
SWEP.Primary.ClipSize		= 13
SWEP.Primary.Delay			= 0.1
SWEP.Primary.DefaultClip	= 0
SWEP.Primary.MaxReserve		= 65
SWEP.Primary.Automatic		= false
SWEP.Primary.Ammo			= "ar2altfire"

SWEP.Primary.MaxSpread		= 0.15 --the maximum amount the spread can go by, best left at 0.20 or lower
SWEP.Primary.Handle			= 0.5 --how many seconds you have to wait between each shot before the spread is at its best
SWEP.Primary.SpreadIncrease	= 0.21/15 --how much you add to the cone after each shot

SWEP.MoveSpread				= 6 --multiplier for spread when you are moving
SWEP.JumpSpread				= 10 --multiplier for spread when you are jumping
SWEP.CrouchSpread			= 0.5 --multiplier for spread when you are crouching

SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic	= false
SWEP.Secondary.Ammo			= "none"

SWEP.IronSightsPos = Vector (4.7567, 0, 2.8329)
SWEP.IronSightsAng = Vector (0, 0, 0)

function SWEP:DoImpactEffect( tr, dmgtype )

    // having the impact effect on the sky looks strange, ditch it
    if( tr.Hit && !tr.HitSky ) then

        local effect = EffectData();
            effect:SetOrigin( tr.HitPos );
            effect:SetNormal( tr.HitNormal );
        util.Effect( "cw_laserimpact", effect );

    end

    return true;

end

function SWEP:OnMuzzleFlash()
    local effect = EffectData();
        effect:SetOrigin( self.Owner:GetShootPos() );
        effect:SetEntity( self.Weapon );
        effect:SetAttachment( 1 );
    util.Effect( "cw_lasermuzzle", effect );
end

function SWEP:GetTracerOrigin()

	local pos, ang = Clockwork.entity:GetMuzzlePos( self );
	return pos;

end


text:
--[[
LuCI - System library

Description:
Utilities for interaction with the Linux system

FileId:
$Id$

License:
Copyright 2008 Steven Barth <steven@midlink.org>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

]]--

local io    = require "io"
local os    = require "os"
local table = require "table"
local nixio = require "nixio"
local fs    = require "nixio.fs"

local luci  = {}
luci.util   = require "luci.util"
luci.ip     = require "luci.ip"

local tonumber, ipairs, pairs, pcall, type, next =
	tonumber, ipairs, pairs, pcall, type, next

--- LuCI Linux and POSIX system utilities.
module "luci.sys"

--- Execute a given shell command and return the error code
-- @class		function
-- @name		call
-- @param 		...		Command to call
-- @return		Error code of the command
function call(...)
	return os.execute(...) / 256
end

--- Execute a given shell command and capture its standard output
-- @class		function
-- @name		exec
-- @param command	Command to call
-- @return			String containg the return the output of the command
exec = luci.util.exec

--- Invoke the luci-flash executable to write an image to the flash memory.
-- @param image		Local path or URL to image file
-- @param kpattern	Pattern of files to keep over flash process
-- @return			Return value of os.execute()
function flash(image, kpattern)
	local cmd = "luci-flash "
	if kpattern then
		cmd = cmd .. "-k '" .. kpattern:gsub("'", "") .. "' "
	end
	cmd = cmd .. "'" .. image:gsub("'", "") .. "' >/dev/null 2>&1"

	return os.execute(cmd)
end

--- Retrieve information about currently mounted file systems.
-- @return 	Table containing mount information
function mounts()
	local data = {}
	local k = {"fs", "blocks", "used", "available", "percent", "mountpoint"}
	local ps = luci.util.execi("df")

	if not ps then
		return
	else
		ps()
	end

	for line in ps do
		local row = {}

		local j = 1
		for value in line:gmatch("[^%s]+") do
			row[k[j]] = value
			j = j + 1
		end

		if row[k[1]] then

			-- this is a rather ugly workaround to cope with wrapped lines in
			-- the df output:
			--
			--	/dev/scsi/host0/bus0/target0/lun0/part3
			--                   114382024  93566472  15005244  86% /mnt/usb
			--

			if not row[k[2]] then
				j = 2
				line = ps()
				for value in line:gmatch("[^%s]+") do
					row[k[j]] = value
					j = j + 1
				end
			end

			table.insert(data, row)
		end
	end

	return data
end

--- Retrieve environment variables. If no variable is given then a table
-- containing the whole environment is returned otherwise this function returns
-- the corresponding string value for the given name or nil if no such variable
-- exists.
-- @class		function
-- @name		getenv
-- @param var	Name of the environment variable to retrieve (optional)
-- @return		String containg the value of the specified variable
-- @return		Table containing all variables if no variable name is given
getenv = nixio.getenv

--- Get or set the current hostname.
-- @param		String containing a new hostname to set (optional)
-- @return		String containing the system hostname
function hostname(newname)
	if type(newname) == "string" and #newname > 0 then
		fs.writefile( "/proc/sys/kernel/hostname", newname )
		return newname
	else
		return nixio.uname().nodename
	end
end

--- Returns the contents of a documented referred by an URL.
-- @param url	 The URL to retrieve
-- @param stream Return a stream instead of a buffer
-- @param target Directly write to target file name
-- @return		String containing the contents of given the URL
function httpget(url, stream, target)
	if not target then
		local source = stream and io.popen or luci.util.exec
		return source("wget -qO- '"..url:gsub("'", "").."'")
	else
		return os.execute("wget -qO '%s' '%s'" %
			{target:gsub("'", ""), url:gsub("'", "")})
	end
end

--- Returns the system load average values.
-- @return	String containing the average load value 1 minute ago
-- @return	String containing the average load value 5 minutes ago
-- @return	String containing the average load value 15 minutes ago
function loadavg()
	local info = nixio.sysinfo()
	return info.loads[1], info.loads[2], info.loads[3]
end

--- Initiate a system reboot.
-- @return	Return value of os.execute()
function reboot()
	return os.execute("reboot >/dev/null 2>&1")
end

--- Returns the system type, cpu name and installed physical memory.
-- @return	String containing the system or platform identifier
-- @return	String containing hardware model information
-- @return	String containing the total memory amount in kB
-- @return	String containing the memory used for caching in kB
-- @return	String containing the memory used for buffering in kB
-- @return	String containing the free memory amount in kB
function sysinfo()
	local cpuinfo = fs.readfile("/proc/cpuinfo")
	local meminfo = fs.readfile("/proc/meminfo")

	local system = cpuinfo:match("system typ.-:%s*([^\n]+)")
	local model = ""
	local memtotal = tonumber(meminfo:match("MemTotal:%s*(%d+)"))
	local memcached = tonumber(meminfo:match("\nCached:%s*(%d+)"))
	local memfree = tonumber(meminfo:match("MemFree:%s*(%d+)"))
	local membuffers = tonumber(meminfo:match("Buffers:%s*(%d+)"))

	if not system then
		system = nixio.uname().machine
		model = cpuinfo:match("model name.-:%s*([^\n]+)")
		if not model then
			model = cpuinfo:match("Processor.-:%s*([^\n]+)")
		end
	else
		model = cpuinfo:match("cpu model.-:%s*([^\n]+)")
	end

	return system, model, memtotal, memcached, membuffers, memfree
end

--- Retrieves the output of the "logread" command.
-- @return	String containing the current log buffer
function syslog()
	return luci.util.exec("logread")
end

--- Retrieves the output of the "dmesg" command.
-- @return	String containing the current log buffer
function dmesg()
	return luci.util.exec("dmesg")
end

--- Generates a random id with specified length.
-- @param bytes	Number of bytes for the unique id
-- @return		String containing hex encoded id
function uniqueid(bytes)
	local rand = fs.readfile("/dev/urandom", bytes)
	return rand and nixio.bin.hexlify(rand)
end

--- Returns the current system uptime stats.
-- @return	String containing total uptime in seconds
function uptime()
	return nixio.sysinfo().uptime
end

--- LuCI system utilities / network related functions.
-- @class	module
-- @name	luci.sys.net
net = {}

--- Returns the current arp-table entries as two-dimensional table.
-- @return	Table of table containing the current arp entries.
--			The following fields are defined for arp entry objects:
--			{ "IP address", "HW address", "HW type", "Flags", "Mask", "Device" }
function net.arptable(callback)
	return _parse_delimited_table(io.lines("/proc/net/arp"), "%s%s+", callback)
end

--- Returns conntrack information
-- @return	Table with the currently tracked IP connections
function net.conntrack(callback)
	local connt = {}
	if fs.access("/proc/net/nf_conntrack", "r") then
		for line in io.lines("/proc/net/nf_conntrack") do
			line = line:match "^(.-( [^ =]+=).-)%2"
			local entry, flags = _parse_mixed_record(line, " +")
			entry.layer3 = flags[1]
			entry.layer4 = flags[3]
			for i=1, #entry do
				entry[i] = nil
			end

			if callback then
				callback(entry)
			else
				connt[#connt+1] = entry
			end
		end
	elseif fs.access("/proc/net/ip_conntrack", "r") then
		for line in io.lines("/proc/net/ip_conntrack") do
			line = line:match "^(.-( [^ =]+=).-)%2"
			local entry, flags = _parse_mixed_record(line, " +")
			entry.layer3 = "ipv4"
			entry.layer4 = flags[1]
			for i=1, #entry do
				entry[i] = nil
			end

			if callback then
				callback(entry)
			else
				connt[#connt+1] = entry
			end
		end
	else
		return nil
	end
	return connt
end

--- Determine the current IPv4 default route. If multiple default routes exist,
-- return the one with the lowest metric.
-- @return	Table with the properties of the current default route.
--			The following fields are defined:
--			{ "dest", "gateway", "metric", "refcount", "usecount", "irtt",
--			  "flags", "device" }
function net.defaultroute()
	local route

	net.routes(function(rt)
		if rt.dest:prefix() == 0 and (not route or route.metric > rt.metric) then
			route = rt
		end
	end)

	return route
end

--- Determine the current IPv6 default route. If multiple default routes exist,
-- return the one with the lowest metric.
-- @return	Table with the properties of the current default route.
--			The following fields are defined:
--			{ "source", "dest", "nexthop", "metric", "refcount", "usecount",
--			  "flags", "device" }
function net.defaultroute6()
	local route

	net.routes6(function(rt)
		if rt.dest:prefix() == 0 and (not route or route.metric > rt.metric) then
			route = rt
		end
	end)

	return route
end

--- Determine the names of available network interfaces.
-- @return	Table containing all current interface names
function net.devices()
	local devs = {}
	for k, v in ipairs(nixio.getifaddrs()) do
		if v.family == "packet" then
			devs[#devs+1] = v.name
		end
	end
	return devs
end

--- Return information about available network interfaces.
-- @return	Table containing all current interface names and their information
function net.deviceinfo()
	local devs = {}
	for k, v in ipairs(nixio.getifaddrs()) do
		if v.family == "packet" then
			local d = v.data
			d[1] = d.rx_bytes
			d[2] = d.rx_packets
			d[3] = d.rx_errors
			d[4] = d.rx_dropped
			d[5] = 0
			d[6] = 0
			d[7] = 0
			d[8] = d.multicast
			d[9] = d.tx_bytes
			d[10] = d.tx_packets
			d[11] = d.tx_errors
			d[12] = d.tx_dropped
			d[13] = 0
			d[14] = d.collisions
			d[15] = 0
			d[16] = 0
			devs[v.name] = d
		end
	end
	return devs
end

-- Determine the MAC address belonging to the given IP address.
-- @param ip	IPv4 address
-- @return		String containing the MAC address or nil if it cannot be found
function net.ip4mac(ip)
	local mac = nil
	net.arptable(function(e)
		if e["IP address"] == ip then
			mac = e["HW address"]
		end
	end)
	return mac
end

--- Returns the current kernel routing table entries.
-- @return	Table of tables with properties of the corresponding routes.
--			The following fields are defined for route entry tables:
--			{ "dest", "gateway", "metric", "refcount", "usecount", "irtt",
--			  "flags", "device" }
function net.routes(callback)
	local routes = { }

	for line in io.lines("/proc/net/route") do

		local dev, dst_ip, gateway, flags, refcnt, usecnt, metric,
			  dst_mask, mtu, win, irtt = line:match(
			"([^%s]+)\t([A-F0-9]+)\t([A-F0-9]+)\t([A-F0-9]+)\t" ..
			"(%d+)\t(%d+)\t(%d+)\t([A-F0-9]+)\t(%d+)\t(%d+)\t(%d+)"
		)

		if dev then
			gateway  = luci.ip.Hex( gateway,  32, luci.ip.FAMILY_INET4 )
			dst_mask = luci.ip.Hex( dst_mask, 32, luci.ip.FAMILY_INET4 )
			dst_ip   = luci.ip.Hex(
				dst_ip, dst_mask:prefix(dst_mask), luci.ip.FAMILY_INET4
			)

			local rt = {
				dest     = dst_ip,
				gateway  = gateway,
				metric   = tonumber(metric),
				refcount = tonumber(refcnt),
				usecount = tonumber(usecnt),
				mtu      = tonumber(mtu),
				window   = tonumber(window),
				irtt     = tonumber(irtt),
				flags    = tonumber(flags, 16),
				device   = dev
			}

			if callback then
				callback(rt)
			else
				routes[#routes+1] = rt
			end
		end
	end

	return routes
end

--- Returns the current ipv6 kernel routing table entries.
-- @return	Table of tables with properties of the corresponding routes.
--			The following fields are defined for route entry tables:
--			{ "source", "dest", "nexthop", "metric", "refcount", "usecount",
--			  "flags", "device" }
function net.routes6(callback)
	if fs.access("/proc/net/ipv6_route", "r") then
		local routes = { }

		for line in io.lines("/proc/net/ipv6_route") do

			local dst_ip, dst_prefix, src_ip, src_prefix, nexthop,
				  metric, refcnt, usecnt, flags, dev = line:match(
				"([a-f0-9]+) ([a-f0-9]+) " ..
				"([a-f0-9]+) ([a-f0-9]+) " ..
				"([a-f0-9]+) ([a-f0-9]+) " ..
				"([a-f0-9]+) ([a-f0-9]+) " ..
				"([a-f0-9]+) +([^%s]+)"
			)

			src_ip = luci.ip.Hex(
				src_ip, tonumber(src_prefix, 16), luci.ip.FAMILY_INET6, false
			)

			dst_ip = luci.ip.Hex(
				dst_ip, tonumber(dst_prefix, 16), luci.ip.FAMILY_INET6, false
			)

			nexthop = luci.ip.Hex( nexthop, 128, luci.ip.FAMILY_INET6, false )

			local rt = {
				source   = src_ip,
				dest     = dst_ip,
				nexthop  = nexthop,
				metric   = tonumber(metric, 16),
				refcount = tonumber(refcnt, 16),
				usecount = tonumber(usecnt, 16),
				flags    = tonumber(flags, 16),
				device   = dev,

				-- lua number is too small for storing the metric
				-- add a metric_raw field with the original content
				metric_raw = metric
			}

			if callback then
				callback(rt)
			else
				routes[#routes+1] = rt
			end
		end

		return routes
	end
end

--- Tests whether the given host responds to ping probes.
-- @param host	String containing a hostname or IPv4 address
-- @return		Number containing 0 on success and >= 1 on error
function net.pingtest(host)
	return os.execute("ping -c1 '"..host:gsub("'", '').."' >/dev/null 2>&1")
end

--- LuCI system utilities / process related functions.
-- @class	module
-- @name	luci.sys.process
process = {}

--- Get the current process id.
-- @class function
-- @name  process.info
-- @return	Number containing the current pid
function process.info(key)
	local s = {uid = nixio.getuid(), gid = nixio.getgid()}
	return not key and s or s[key]
end

--- Retrieve information about currently running processes.
-- @return 	Table containing process information
function process.list()
	local data = {}
	local k
	local ps = luci.util.execi("top -bn1")

	if not ps then
		return
	end

	while true do
		local line = ps()
		if not line then
			return
		end

		k = luci.util.split(luci.util.trim(line), "%s+", nil, true)
		if k[1] == "PID" then
			break
		end
	end

	for line in ps do
		local row = {}

		line = luci.util.trim(line)
		for i, value in ipairs(luci.util.split(line, "%s+", #k-1, true)) do
			row[k[i]] = value
		end

		local pid = tonumber(row[k[1]])
		if pid then
			data[pid] = row
		end
	end

	return data
end

--- Set the gid of a process identified by given pid.
-- @param gid	Number containing the Unix group id
-- @return		Boolean indicating successful operation
-- @return		String containing the error message if failed
-- @return		Number containing the error code if failed
function process.setgroup(gid)
	return nixio.setgid(gid)
end

--- Set the uid of a process identified by given pid.
-- @param uid	Number containing the Unix user id
-- @return		Boolean indicating successful operation
-- @return		String containing the error message if failed
-- @return		Number containing the error code if failed
function process.setuser(uid)
	return nixio.setuid(uid)
end

--- Send a signal to a process identified by given pid.
-- @class function
-- @name  process.signal
-- @param pid	Number containing the process id
-- @param sig	Signal to send (default: 15 [SIGTERM])
-- @return		Boolean indicating successful operation
-- @return		Number containing the error code if failed
process.signal = nixio.kill

--- LuCI system utilities / user related functions.
-- @class	module
-- @name	luci.sys.user
user = {}

--- Retrieve user informations for given uid.
-- @class		function
-- @name		getuser
-- @param uid	Number containing the Unix user id
-- @return		Table containing the following fields:
--				{ "uid", "gid", "name", "passwd", "dir", "shell", "gecos" }
user.getuser = nixio.getpw

--- Test whether given string matches the password of a given system user.
-- @param username	String containing the Unix user name
-- @param pass		String containing the password to compare
-- @return			Boolean indicating wheather the passwords are equal
function user.checkpasswd(username, pass)
	local pwe = nixio.getsp and nixio.getsp(username) or nixio.getpw(username)
	local pwh = pwe and (pwe.pwdp or pwe.passwd)
	if not pwh or #pwh < 1 or pwh ~= "!" and nixio.crypt(pass, pwh) ~= pwh then
		return false
	else
		return true
	end
end

--- Change the password of given user.
-- @param username	String containing the Unix user name
-- @param password	String containing the password to compare
-- @return			Number containing 0 on success and >= 1 on error
function user.setpasswd(username, password)
	if password then
		password = password:gsub("'", "")
	end

	if username then
		username = username:gsub("'", "")
	end

	local cmd = "(echo '"..password.."';sleep 1;echo '"..password.."')|"
	cmd = cmd .. "passwd '"..username.."' >/dev/null 2>&1"
	return os.execute(cmd)
end

--- LuCI system utilities / wifi related functions.
-- @class	module
-- @name	luci.sys.wifi
wifi = {}

--- Get iwconfig output for all wireless devices.
-- @return	Table of tables containing the iwconfing output for each wifi device
function wifi.getiwconfig()
	local cnt = luci.util.exec("PATH=/sbin:/usr/sbin iwconfig 2>/dev/null")
	local iwc = {}

	for i, l in pairs(luci.util.split(luci.util.trim(cnt), "\n\n")) do
		local k = l:match("^(.-) ")
		l = l:gsub("^(.-) +", "", 1)
		if k then
			local entry, flags = _parse_mixed_record(l)
			if entry then
				entry.flags = flags
			end
			iwc[k] = entry
		end
	end

	return iwc
end

--- Get iwlist scan output from all wireless devices.
-- @return	Table of tables contaiing all scan results
function wifi.iwscan(iface)
	local siface = iface or ""
	local cnt = luci.util.exec("iwlist "..siface.." scan 2>/dev/null")
	local iws = {}

	for i, l in pairs(luci.util.split(luci.util.trim(cnt), "\n\n")) do
		local k = l:match("^(.-) ")
		l = l:gsub("^[^\n]+", "", 1)
		l = luci.util.trim(l)
		if k then
			iws[k] = {}
			for j, c in pairs(luci.util.split(l, "\n          Cell")) do
				c = c:gsub("^(.-)- ", "", 1)
				c = luci.util.split(c, "\n", 7)
				c = table.concat(c, "\n", 1)
				local entry, flags = _parse_mixed_record(c)
				if entry then
					entry.flags = flags
				end
				table.insert(iws[k], entry)
			end
		end
	end

	return iface and (iws[iface] or {}) or iws
end

--- Get available channels from given wireless iface.
-- @param iface	Wireless interface (optional)
-- @return		Table of available channels
function wifi.channels(iface)
	local cmd = "iwlist " .. ( iface or "" ) .. " freq 2>/dev/null"
	local cns = { }

	local fd = io.popen(cmd)
	if fd then
		local ln, c, f
		while true do
			ln = fd:read("*l")
			if not ln then break end
			c, f = ln:match("Channel (%d+) : (%d+%.%d+) GHz")
			if c and f then
				cns[tonumber(c)] = tonumber(f)
			end
		end
		fd:close()
	end

	if not next(cns) then
		cns = {
			2.412, 2.417, 2.422, 2.427, 2.432, 2.437,
			2.442, 2.447, 2.452, 2.457, 2.462
		}
	end

	return cns
end

--- LuCI system utilities / init related functions.
-- @class	module
-- @name	luci.sys.init
init = {}
init.dir = "/etc/init.d/"

--- Get the names of all installed init scripts
-- @return	Table containing the names of all inistalled init scripts
function init.names()
	local names = { }
	for name in fs.glob(init.dir.."*") do
		names[#names+1] = fs.basename(name)
	end
	return names
end

--- Test whether the given init script is enabled
-- @param name	Name of the init script
-- @return		Boolean indicating whether init is enabled
function init.enabled(name)
	if fs.access(init.dir..name) then
		return ( call(init.dir..name.." enabled") == 0 )
	end
	return false
end

--- Get the index of he given init script
-- @param name	Name of the init script
-- @return		Numeric index value
function init.index(name)
	if fs.access(init.dir..name) then
		return call("source "..init.dir..name.." enabled; exit $START")
	end
end

--- Enable the given init script
-- @param name	Name of the init script
-- @return		Boolean indicating success


text:
ConfigGarage = {

	DrawDistance = 30,

	Locale = "en",

	Price = 10,

	-- This is the multiplier of price to pay when the car is damaged
	-- 100% damaged means 1000 * Multiplier
	-- 50% damaged means 500 * Multiplier
	-- Etc.
	RepairMultiplier = 0.25,

	BlipInfos = {
		Sprite = 290,
		Color = 38
	},

	BlipPound = {
		Sprite = 67,
		Color = 64
	}
}

ConfigGarage.Garages = {

	Garage_Centre = {
		Pos = {x=215.800, y=-810.057, z=29.727},
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x=229.700, y= -800.1149, z= 29.5722},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Heading=157.84,
			Marker = 1
		},
		DeletePoint = {
			Pos = {x=215.124, y=-791.377, z=29.646},
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1,

		},
		MunicipalPoundPoint = {
			Pos = {x=482.896, y=-1316.557, z=28.301},
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x=490.942, y=-1313.067, z=27.964},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1,
			Heading=299.42
		},
	},

	Garage_Centre2 = {
		Pos = {x=-285.75, y=-887.82, z=30.1},
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x=-285.75, y=-887.82, z=30.1},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Heading=157.84,
			Marker = 1
		},
		DeletePoint = {
			Pos = {x=-298.34, y=-899.76, z=30.59},
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1,

		},
		MunicipalPoundPoint = {
			Pos = {x=482.896, y=-1316.557, z=-28.301},
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x=490.942, y=-1313.067, z=-27.964},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1,
			Heading=299.42
		},
	},

	Garage_Centre3 = {
		Pos = {x=464.35, y=-1122.57, z=28.1},
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x=464.35, y=-1122.57, z=28.1},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Heading=157.84,
			Marker = 1
		},
		DeletePoint = {
			Pos = {x=479.98, y=-1123.177, z=28.84},
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1,

		},
		MunicipalPoundPoint = {
			Pos = {x=482.896, y=-1316.557, z=-28.301},
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x=490.942, y=-1313.067, z=-27.964},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1,
			Heading=299.42
		},
	},

	Garage_Centre4 = {
		Pos = {x=-67.57, y=-1836.23, z=26.39},
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x=-67.57, y=-1836.23, z=26.39},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Heading=157.84,
			Marker = 1
		},
		DeletePoint = {
			Pos = {x=-51.75, y=-1849.39, z=25.77},
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1,

		},
		MunicipalPoundPoint = {
			Pos = {x=482.896, y=-1316.557, z=-28.301},
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x=490.942, y=-1313.067, z=-27.964},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1,
			Heading=299.42
		},
	},

	Garage_Centre5 = {
		Pos = {x=-1119.159, y=-2015.04, z=12.09},
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x=-1119.159, y=-2015.04, z=12.09},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Heading=157.84,
			Marker = 1
		},
		DeletePoint = {
			Pos = {x=-1131.16, y=-2001.71, z=12.0},
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1,

		},
		MunicipalPoundPoint = {
			Pos = {x=482.896, y=-1316.557, z=-28.301},
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x=490.942, y=-1313.067, z=-27.964},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1,
			Heading=299.42
		},
	},

	Garage_Centre6 = {
		Pos = {x=852.923, y=-2179.88, z=29.3},
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x=852.923, y=-2179.88, z=29.3},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Heading=157.84,
			Marker = 1
		},
		DeletePoint = {
			Pos = {x=844.11, y=-2178.96, z=29.3},
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1,

		},
		MunicipalPoundPoint = {
			Pos = {x=482.896, y=-1316.557, z=-28.301},
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x=490.942, y=-1313.067, z=-27.964},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1,
			Heading=299.42
		},
	},

	Garage_Centre7 = {
		Pos = {x=1160.59, y=-1375.33, z=33.8},
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x=1160.59, y=-1375.33, z=33.8},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Heading=157.84,
			Marker = 1
		},
		DeletePoint = {
			Pos = {x=1168.80, y=-1382.64, z=33.8},
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1,

		},
		MunicipalPoundPoint = {
			Pos = {x=482.896, y=-1316.557, z=-28.301},
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x=490.942, y=-1313.067, z=-27.964},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1,
			Heading=299.42
		},
	},

	Garage_Centre8 = {
		Pos = {x=374.29, y=283.80, z=101.8},
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x=374.29, y=283.80, z=101.8},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Heading=157.84,
			Marker = 1
		},
		DeletePoint = {
			Pos = {x=358.40, y=286.50, z=102.0},
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1,

		},
		MunicipalPoundPoint = {
			Pos = {x=482.896, y=-1316.557, z=-28.301},
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x=490.942, y=-1313.067, z=-27.964},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1,
			Heading=299.42
		},
	},

	Garage_Centre9 = {
		Pos = {x=-1059.30, y=-1426.36, z=4.3},
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x=-1059.30, y=-1426.36, z=4.3},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Heading=157.84,
			Marker = 1
		},
		DeletePoint = {
			Pos = {x=-1057.70, y=-1436.211, z=4.3},
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1,

		},
		MunicipalPoundPoint = {
			Pos = {x=482.896, y=-1316.557, z=-28.301},
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x=490.942, y=-1313.067, z=-27.964},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1,
			Heading=299.42
		},
	},

	Garage_Centre10 = {
		Pos = {x=-532.12, y=-35.669, z=43.3},
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x=-532.11, y=-30.37, z=43.3},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Heading=157.84,
			Marker = 1
		},
		DeletePoint = {
			Pos = {x=-539.81, y=-39.73, z=41.7},
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1,

		},
		MunicipalPoundPoint = {
			Pos = {x=482.896, y=-1316.557, z=-28.301},
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x=490.942, y=-1313.067, z=-27.964},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 3.0},
			Marker = 1,
			Heading=299.42
		},
	},

	Garage_Paleto = {
		Pos = {x=190.00, y=6624.61, z=30.8565},
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x=182.58, y= 6627.51, z= 30.25},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		DeletePoint = {
			Pos = {x=198.46, y=6626.13, z=30.25},
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		MunicipalPoundPoint = {
			Pos = {x=-185.187, y=6272.027, z=30.580},
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x=-199.160, y=6274.180, z=30.580},
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
	},

	Garage_Poissoniers = {
		Pos = {x = -1511.6556396484,y = 5009.875,z = 61.800533294678 },
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x = -1511.6556396484,y = 5009.875,z = 61.800533294678 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		DeletePoint = {
			Pos = {x = -1524.1857910156,y = 4997.2885742188,z = 61.598690032959 },
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		MunicipalPoundPoint = {
			Pos = {x = -2211.8347167969,y = 4241.1069335938,z = 46.61901473999 },
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x = -2205.4594726563,y = 4247.3603515625,z = 46.639003753662 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
	},

	Garage_SandyShore = {
		Pos = {x = 1501.2,y = 3762.19,z = 33.0 },
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x = 1497.15,y = 3761.37,z = 32.8 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		DeletePoint = {
			Pos = {x = 1504.1,y = 3765.55,z = 32.8 },
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		MunicipalPoundPoint = {
			Pos = {x = 1561.6000976563,y = 3522.8583984375,z = 34.789356231689 },
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x = 1551.8347167969,y = 3518.1003417969,z = 34.988235473633 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
	},

		Garage_Aeroport = {
		Pos = {x = -977.21661376953,y = -2710.3798828125,z = 12.853487014771 },
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x = -977.21661376953,y = -2710.3798828125,z = 12.853487014771 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		DeletePoint = {
			Pos = {x = -966.88208007813,y = -2709.9028320313,z = 12.83367729187 },
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		MunicipalPoundPoint = {
			Pos = {x = -1041.4571533203,y = -2676.3471679688,z = 12.830760002136 },
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x = -1048.3468017578,y = -2669.771484375,z = 12.830758094788 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
	},

	Garage_Neil = {
		Pos = {x = 2399.62,y = 4977.34,z = 45.23 },
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x = 2399.62,y = 4977.34,z = 44.0 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		DeletePoint = {
			Pos = {x = 2413.59,y = 4991.16,z = 45.0 },
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		MunicipalPoundPoint = {
			Pos = {x = 2314.43,y = 4898.45,z = 40.80 },
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x = 2302.36,y = 4887.12,z = 40.80 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
	},

    Garage_Bahamas = {
		Pos = {x = -3049.48,y = 172.47,z = 11.60 },
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x = -3047.53,y = 158.51,z = 10.5 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		DeletePoint = {
			Pos = {x = -3048.53,y = 170.79,z = 10.5 },
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
        },
		MunicipalPoundPoint = {
			Pos = {x = -2348.08,y = 297.53,z = 168.46 },
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x = -2340.25,y = 280.40,z = 168.46 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
        },
	},

	Garage_MilieuMap = {
		Pos = {x = 816.21,y = 2181.98,z = 52.29 },
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x = 820.19,y = 2195.34,z = 51.0 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		DeletePoint = {
			Pos = {x = 808.83,y = 2180.19,z = 51.0 },
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
        },
		MunicipalPoundPoint = {
			Pos = {x = 1205.62,y = 1858.72,z = 77.9 },
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x = 1218.06,y = 1872.65,z = 77.7 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
        },
	},

	Garage_Vigneron = {
		Pos = {x = -1898.10,y = 2000.44,z = 141.77 },
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x = -1898.10,y = 2000.44,z = 140.67 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		DeletePoint = {
			Pos = {x = -1896.35,y = 2020.10,z = 139.80 },
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
        },
		MunicipalPoundPoint = {
			Pos = {x = -319.19,y = 2732.00,z = 67.50 },
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x = -313.22,y = 2743.71,z = 66.20 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
        },
	},

        Garage_Bateaux = {
		Pos = {x = -241.36,y = 6691.74,z = -0.35 },
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x = -241.36,y = 6691.74,z = -0.35 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		DeletePoint = {
			Pos = {x = -249.61,y = 6678.68,z = -0.40 },
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
        },
		MunicipalPoundPoint = {
			Pos = {x = -198.46,y = 6741.24,z = 2.40 },
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x = -204.47,y = 6732.98,z = -0.25 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
        },
	},

        Garage_Russe = {
		Pos = {x = -587.56,y = -1637.99,z = 19.85 },
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x = -587.56,y = -1637.99,z = 18.85 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		DeletePoint = {
			Pos = {x = -570.87,y = -1638.91,z = 18.41 },
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
        },
		MunicipalPoundPoint = {
			Pos = {x = -638.01,y = -1779.51,z = 23.20 },
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x = -632.76,y = -1785.91,z = 22.70 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
        },
	},

         Garage_Bloods = {
		Pos = {x = 1266.86,y = -1739.62,z = 49.52 },
		Size  = {x = 3.0, y = 3.0, z = 1.0},
		Color = {r = 204, g = 204, b = 0},
		Marker = 1,
		SpawnPoint = {
			Pos = {x = 1266.86,y = -1739.62,z = 49.52 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		DeletePoint = {
			Pos = {x = 1289.69,y = -1729.20,z = 52.34 },
			Color = {r=255,g=0,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
        },
		MunicipalPoundPoint = {
			Pos = {x = 1454.56,y = -1683.01,z = 65.04 },
			Color = {r=25,g=25,b=112},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
		},
		SpawnMunicipalPoundPoint = {
			Pos = {x = 1450.26,y = -1690.68,z = 64.95 },
			Color = {r=0,g=255,b=0},
			Size  = {x = 3.0, y = 3.0, z = 1.0},
			Marker = 1
        },
	},

}


text:
-- Copyright 2016-2020 Alejandro Baez (https://keybase.io/baez). See LICENSE.
-- PICO-8 lexer.
-- http://www.lexaloffle.com/pico-8.php

local lexer = require('lexer')
local token, word_match = lexer.token, lexer.word_match
local P, S = lpeg.P, lpeg.S

local lex = lexer.new('pico8')

-- Whitespace
lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1))

-- Keywords
lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[
  __lua__ __gfx__ __gff__ __map__ __sfx__ __music__
]]))

-- Identifiers
lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word))

-- Comments
lex:add_rule('comment', token(lexer.COMMENT, lexer.to_eol('//', true)))

-- Numbers
lex:add_rule('number', token(lexer.NUMBER, lexer.integer))

-- Operators
lex:add_rule('operator', token(lexer.OPERATOR, S('_')))

-- Embed Lua into PICO-8.
local lua = lexer.load('lua')

local lua_start_rule = token('pico8_tag', '__lua__')
local lua_end_rule = token('pico8_tag', '__gfx__' )
lex:embed(lua, lua_start_rule, lua_end_rule)
lex:add_style('pico8_tag', lexer.styles.embedded)

return lex


text:
local MENU_OPTIONS = {}

MENU_OPTIONS["EN"] = {"New Game", "Options","Credits","Exit"}
MENU_OPTIONS["ES"] = { "Juego nuevo","Opciones","Creditos","Salir" }

function MainMenu()
    local self = Escena()
    local menuengine = require "menuengine"
    local mainmenu = nil
    local bg_music = nil
    local bg_ima = nil

    local john_imagen = nil
    local john_frame_list = nil
    local john_anim = nil

    function self.loadCortinilla()
        bg_music:stop()
        local init_scene =  love.filesystem.load("creditos.lua")()
        ESCENA_MANAGER.push(init_scene)
    end

    function self.loadLevel()
        bg_music:stop()
        INITIAL_SCORE = 0
        SCORE = 0
        --local init_scene =  love.filesystem.load("level.lua")()
        --ESCENA_MANAGER.replace(init_scene,LEVEL_LIST[CURRENT_LEVEL])
        local new_scene = love.filesystem.load("intro.lua")()
        ESCENA_MANAGER.replace(new_scene)
    end

    function self.load()
        love.graphics.setFont(FONT)

        menuengine.settings.symbolSelectedBegin = ''
        menuengine.settings.symbolSelectedEnd = ''
        menuengine.settings.normalSelectedBegin = ''
        menuengine.settings.normalSelectedBegin = ''
        menuengine.settings.colorSelected  = {0.1,0.1,0.9}
        menuengine.settings.colorNormal  = {1,1,1}
        menuengine.settings.sndMove = love.audio.newSource("rsc/sounds/pick.wav", "static")
        menuengine.settings.sndSuccess = love.audio.newSource("rsc/sounds/accept.wav", "static")

        mainmenu = menuengine.new(154,250,300)
        mainmenu:addEntry('option1',self.loadLevel)
        mainmenu:addEntry('option3',self.loadOptionsMenu)
        mainmenu:addEntry('option4',self.loadCortinilla)
        mainmenu:addEntry('option5',love.event.quit)

        --mainmenu:addEntry("Quit Game", quit_game)

        bg_ima = love.graphics.newImage("rsc/menu_bg.png")
        john_imagen = love.graphics.newImage("rsc/sprites/john_huesos.png")
        john_frame_list = simpleQuadsImagenAnchoAlto(120,128,24,24)
        john_anim = Animation({16,16,16,16,17})
        john_anim.periodo = 0.25
        bg_music = love.audio.newSource("rsc/music/greenochrome_by_neurosys.xm",'stream')
        bg_music:setLooping(true)
        bg_music:play()
    end

    function self.update(dt)
        mainmenu:update()

        local i = 1
        while  mainmenu.entries[i] do
            mainmenu.entries[i].text = MENU_OPTIONS[LANG][i]
            mainmenu.entries[i].font = FONT
            i=i+1
        end
        mainmenu.entries[mainmenu.cursor].font = FONT_BOLD
        --mainmenu.entries[i-1].font = FONT_BOLD
    end

    function self.draw()

        love.graphics.clear(0.2,0.2,0.2)
        love.graphics.draw(bg_ima,0,0,0,4,4)
        local frame = john_anim.getFrameActual()
        love.graphics.draw(john_imagen,john_frame_list[frame],197*4,228,0,4,4)
        love.graphics.setFont(FONT)

        mainmenu:draw()
    end

    function self.loadOptionsMenu()
        --bg_music:stop()
        local init_scene =  love.filesystem.load("optionsMenu.lua")()
        ESCENA_MANAGER.push(init_scene)
    end

    function self.keyreleased( key, scancode )
    end

    function self.keypressed(key,scancode)
        menuengine.keypressed(scancode)
    end

    function self.mousemoved(x, y, dx, dy, istouch)
        menuengine.mousemoved(x, y)
    end

    return self
end

return MainMenu()


text:
local objGateb = createObject(3089, 228.2837677002, 115.20336151123, 1010.5583496094, 0, 0, 90)
exports.pool:allocateElement(objGateb)
setElementInterior(objGateb, 10)
setElementDimension(objGateb, 9001)

local open = false

-- Gate code
function useImpoundDoorb(thePlayer)
	local team = getPlayerTeam(thePlayer)

	if (team==getTeamFromName("Best's Towing and Recovery")) then
		local x, y, z = getElementPosition(thePlayer)
		local distance = getDistanceBetweenPoints3D(228.2837677002, 115.20336151123, 1010.5583496094, x, y, z)

		if (distance<=3) and (open==false) then
			open = true
			outputChatBox("The Main Impound Door is now Open!", thePlayer, 0, 255, 0)
			moveObject(objGateb, 1000, 228.2837677002, 115.20336151123, 1010.5583496094, 0, 0, -90)
			setTimer(closeImpoundDoorb, 5000, 1, thePlayer)
		end
	end
end
addCommandHandler("gate", useImpoundDoorb)

function closeImpoundDoorb(thePlayer)
	if (getElementType(thePlayer)) then
		outputChatBox("The Main Impound Door is now Closed!", thePlayer, 255, 0, 0)
	end

	moveObject(objGateb, 1000, 228.2837677002, 115.20336151123, 1010.5583496094, 0, 0, 90)

	setTimer(resetState1b, 1000, 1)
end

function resetState1b()
	open = false
end


text:
require "classes.constants.screen"
require "classes.samples.System.LocalNotifications"

DataSystemList={}

function DataSystemList:new()
    local this = {
                      {img = "", title = "LocalNotifications", isList = false, execute=function() return LocalNotifications:new() end},
                 }
    local public = this
    local private = {}

    function private.DataSystemList()

        this.isList = true
        this.hasBackButton = true

    end

    function public.goCurrent()
        return DataSystemList:new()
    end

    function public.goBack()
        return DataAllTopicList:new()
    end

    function public:destroy()
        this:removeSelf()
        this = nil
    end

    private.DataSystemList()
    return this
end
return DataSystemList


text:
return {
	{
		effect_list = {
			{
				type = "BattleSkillFire",
				casterAniEffect = "",
				target_choise = "TargetNil",
				targetAniEffect = "",
				arg_list = {
					weapon_id = 73231,
					emitter = "BattleBulletEmitter"
				}
			}
		}
	},
	uiEffect = "",
	name = "全弹发射",
	cd = 0,
	painting = 1,
	id = 23231,
	picture = "0",
	desc = "全弹发射",
	aniEffect = {
		effect = "jineng",
		offset = {
			0,
			-2,
			0
		}
	},
	effect_list = {
		{
			type = "BattleSkillFire",
			casterAniEffect = "",
			target_choise = "TargetNil",
			targetAniEffect = "",
			arg_list = {
				weapon_id = 73231,
				emitter = "BattleBulletEmitter"
			}
		}
	}
}


text:
-- The Computer Language Benchmarks Game
-- https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
-- contributed by Mike Pall
-- modified by Sebastian Engel to be parallel, derived from mandelbrot-lua-6

-- called with the following arguments on the command line;
-- 1: Initial depth of the tree
-- 2: number of children to spawn (defaults to 6, which works well on 4-way)
-- If this is a child, then there will be additional parameters;
-- 3: current tree depth
-- 4: chunk start
-- 5: chunk end

local N          = tonumber(arg and arg[1]) or 0
local children   = tonumber(arg and arg[2]) or 4
local cdepth     = tonumber(arg and arg[3])
local chunkstart = tonumber(arg and arg[4])
local chunkend   = tonumber(arg and arg[5])

local write = io.write

local function BottomUpTree(depth)
    if depth > 0 then
        depth = depth - 1
        local left, right = BottomUpTree(depth), BottomUpTree(depth)
        return { left, right }
    else
        return { }
    end
end

local function ItemCheck(tree)
    if tree[1]  then
        return 1 + ItemCheck(tree[1]) + ItemCheck(tree[2])
    else
        return 1
    end
end

if not chunkstart then
    -- we are the parent process.
    -- emit the header, and then spawn children

    local mindepth = 4
    local maxdepth = mindepth + 2
    if maxdepth < N then maxdepth = N end

    do
        local stretchdepth = maxdepth + 1
        local stretchtree = BottomUpTree(stretchdepth)
        write(string.format("stretch tree of depth %d\t check: %d\n",
                stretchdepth, ItemCheck(stretchtree)))
    end

    local longlivedtree = BottomUpTree(maxdepth)

    for depth=mindepth,maxdepth,2 do
        local iterations = 2 ^ (maxdepth - depth + mindepth)
        local check = 0

        local workunit = math.floor(iterations / children )
        local handles = { }

        for i = 1,children do
            local cs, ce

            if i == 1 then
                cs = 1
                ce = workunit
            elseif i == children then
                cs = (workunit * (i-1)) + 1
                ce = iterations
            else
                cs = (workunit * (i-1)) + 1
                ce = cs + workunit - 1
            end

            handles[i+1] = io.popen(("%s %s %d %d %d %d %d"):format(
            arg[-1], arg[0], N, children, depth, cs, ce))
        end

        -- collect answers, and emit
        for i = 1, children do
            check = check + (handles[i+1]:read "*a")
        end

        write(string.format("%d\t trees of depth %d\t check: %d\n",
                iterations, depth, check))
    end

    write(string.format("long lived tree of depth %d\t check: %d\n",
            maxdepth, ItemCheck(longlivedtree)))

else
    -- we are a child process.
    -- do the work allocated to us.
    local partialcheck = 0

    for i=chunkstart,chunkend do
        partialcheck = partialcheck + ItemCheck(BottomUpTree(cdepth))
    end

    write(partialcheck)
end