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 |
|---|---|---|---|---|---|
TheAnswer/FirstTest | bin/scripts/slashcommands/skills/kipUpShot.lua | 1 | 2564 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
--true = 1, false = 0
KipUpShotSlashCommand = {
name = "kipupshot",
alternativeNames = "",
animation = "",
invalidStateMask = 3894805552, --alert, berzerk, tumbling, frozen, swimming, glowingJedi, ridingMount, pilotingShip, shipOperations, shipGunner,
invalidPostures = "3,5,6,7,8,9,10,11,12,13,14,4,",
target = 1,
targeType = 2,
disabled = 0,
maxRangeToTarget = 0,
--adminLevel = 0,
addToCombatQueue = 1,
}
AddKipUpShotSlashCommand(KipUpShotSlashCommand)
| lgpl-3.0 |
weiDDD/WSSParticleSystem | cocos2d/cocos/scripting/lua-bindings/auto/api/Manifest.lua | 1 | 1599 |
--------------------------------
-- @module Manifest
-- @extend Ref
-- @parent_module cc
--------------------------------
-- @brief Gets remote manifest file url.
-- @function [parent=#Manifest] getManifestFileUrl
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @brief Check whether the version informations have been fully loaded
-- @function [parent=#Manifest] isVersionLoaded
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @brief Check whether the manifest have been fully loaded
-- @function [parent=#Manifest] isLoaded
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @brief Gets remote package url.
-- @function [parent=#Manifest] getPackageUrl
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @brief Gets manifest version.
-- @function [parent=#Manifest] getVersion
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @brief Gets remote version file url.
-- @function [parent=#Manifest] getVersionFileUrl
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @brief Get the search paths list related to the Manifest.
-- @function [parent=#Manifest] getSearchPaths
-- @param self
-- @return array_table#array_table ret (return value: array_table)
return nil
| apache-2.0 |
TheAnswer/FirstTest | bin/scripts/creatures/objects/dathomir/npcs/fsVillage/kylaenaHaley.lua | 1 | 4447 | --Copyright (C) 2008 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
kylaenaHaley = Creature:new {
objectName = "kylaenaHaley", -- Lua Object Name
creatureType = "NPC",
faction = "Sith Shadow 0",
gender = "",
speciesName = "kylaena_haley",
stfName = "mob/creature_names",
objectCRC = 3989382798,
socialGroup = "Sith Shadow 0",
level = 103,
combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG + AGGRESSIVE_FLAG,
healthMax = 19400,
healthMin = 15900,
strength = 0,
constitution = 0,
actionMax = 19400,
actionMin = 15900,
quickness = 0,
stamina = 0,
mindMax = 19400,
mindMin = 15900,
focus = 0,
willpower = 0,
height = 1, -- Size of creature
armor = 1, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy
kinetic = 80,
energy = 80,
electricity = 80,
stun = 80,
blast = 80,
heat = 80,
cold = 80,
acid = 80,
lightsaber = 0,
accuracy = 0,
healer = 1,
pack = 1,
herd = 0,
stalker = 0,
killer = 1,
ferocity = 0,
aggressive = 1,
invincible = 0,
attackCreatureOnSight = "", -- Enter socialGroups
weapon = "", -- File path to weapon -> object\xxx\xxx\xx
weaponName = "", -- Name ex. 'a Vibrolance'
weaponTemp = "", -- Weapon Template ex. 'lance_vibrolance'
weaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon'
weaponEquipped = 0,
weaponMinDamage = 0,
weaponMaxDamage = 0,
weaponAttackSpeed = 0,
weaponDamageType = "", -- ELECTRICITY, KINETIC, etc
weaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY
alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx
alternateWeaponName = "", -- Name ex. 'a Vibrolance'
alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance'
alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon'
alternateWeaponEquipped = 0,
alternateWeaponMinDamage = 0,
alternateWeaponMaxDamage = 0,
alternateWeaponAttackSpeed = 0,
alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc
alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY
internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's
lootGroup = "0", -- Group it belongs to for loot
tame = 0,
datapadItemCRC = 0,
mountCRC = 0,
mountSpeed = 0,
mountAcceleration = 0,
milk = 0,
boneType = "",
boneMax = 0,
hideType = "",
hideMax = 0,
meatType = "",
meatMax = 0,
skills = { "villageAttack1" },
respawnTimer = 180,
behaviorScript = "", -- Link to the behavior script for this object
}
Creatures:addCreature(kylaenaHaley, 3989382798) -- Add to Global Table
| lgpl-3.0 |
TheAnswer/FirstTest | bin/scripts/creatures/spawns/dantooine/dungeons/dantariMokkVillage.lua | 1 | 2620 | --Copyright (C) 2008 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
spawnCreature(mokkClanLeader, 1, 5573.08, -635.405)
spawnCreature(mokkWarrior, 1, 5566.81, -644.43)
spawnCreature(mokkHarvester, 1, 5590.45, -614.236)
spawnCreature(mokkHarvester, 1, 5534.22, -692.701)
spawnCreature(mokkSoothsayer, 1, 5595.45, -622.07)
spawnCreature(mokkTribesman, 1, 5592.03, -646.633)
spawnCreature(mokkPrimalist, 1, 5544.92, -682.596)
spawnCreature(mokkPrimalist, 1, 5568.59, -655.277)
spawnCreature(mokkHerbalist, 1, 5527.23, -696.351)
spawnCreature(mokkShaman, 1, 5555.51, -618.376)
spawnCreature(mokkTribesman, 1, 5516.51, -708.176)
spawnCreature(mokkWarrior, 1, 5573.73, -646.79)
| lgpl-3.0 |
Hammerspoon/hammerspoon | extensions/tangent/tangent.lua | 4 | 74064 | --- === hs.tangent ===
---
--- Tangent Control Surface Extension
---
--- **API Version:** TUBE Version 3.2 - TIPC Rev 4 (22nd February 2017)
---
--- This plugin allows Hammerspoon to communicate with Tangent's range of panels, such as their Element, Virtual Element Apps, Wave, Ripple and any future panels.
---
--- The Tangent Unified Bridge Engine (TUBE) is made up of two software elements, the Mapper and the Hub. The Hub communicates with your application via the
--- TUBE Inter Process Communications (TIPC). TIPC is a standardised protocol to allow any application that supports it to communicate with any current and
--- future panels produced by Tangent via the TUBE Hub.
---
--- You can download the Tangent Developer Support Pack & Tangent Hub Installer for Mac [here](http://www.tangentwave.co.uk/developer-support/).
---
--- This extension was thrown together by [Chris Hocking](https://github.com/latenitefilms), then dramatically improved by [David Peterson](https://github.com/randomeizer) for [CommandPost](http://commandpost.io).
local log = require("hs.logger").new("tangent")
local inspect = require("hs.inspect")
local fs = require("hs.fs")
local socket = require("hs.socket")
local timer = require("hs.timer")
local unpack, pack, format = string.unpack, string.pack, string.format
--------------------------------------------------------------------------------
--
-- THE MODULE:
--
--------------------------------------------------------------------------------
local mod = {}
--------------------------------------------------------------------------------
-- MODULE CONSTANTS:
--------------------------------------------------------------------------------
--- hs.tangent.fromHub -> table
--- Constant
--- Definitions for IPC Commands from the HUB to Hammerspoon.
---
--- Notes:
--- * `connected` - a connection is established with the Hub.
--- * `disconnected` - the connection is dropped with the Hub.
--- * `initiateComms` - sent when the Hub wants to initiate communications.
--- * `parameterChange` - a parameter was incremented.
--- * `parameterReset` - a parameter was reset.
--- * `parameterValueRequest` - the Hub wants the current value of the parameter.
--- * `menuChange` - The menu was changed, `+1` or `-1`.
--- * `menuReset` - The menu was reset.
--- * `menuStringRequest` - The application should send a `menuString` with the current value.
--- * `actionOn` - An action button was pressed.
--- * `actionOff` - An action button was released.
--- * `modeChange` - The current mode was changed.
--- * `transport` - The transport.
--- * `unmanagedPanelCapabilities` - Send by the Hub to advertise an unmanaged panel.
--- * `unmanagedButtonDown` - A button on an unmanaged panel was pressed.
--- * `unmanagedButtonUp` - A button on an unmanaged panel was released.
--- * `unmanagedEncoderChange` - An encoder (dial/wheel) on an unmanaged panel changed.
--- * `unmanagedDisplayRefresh` - Triggered when an unmanaged panel's display needs to update.
--- * `panelConnectionState` - A panel's connection state changed.
mod.fromHub = {
--------------------------------------------------------------------------------
-- Custom Notifications:
--------------------------------------------------------------------------------
connected = 0xFF01,
disconnected = 0xFF02,
--------------------------------------------------------------------------------
-- Official Definitions:
--------------------------------------------------------------------------------
initiateComms = 0x01,
parameterChange = 0x02,
parameterReset = 0x03,
parameterValueRequest = 0x04,
menuChange = 0x05,
menuReset = 0x06,
menuStringRequest = 0x07,
actionOn = 0x08,
modeChange = 0x09,
transport = 0x0A,
actionOff = 0x0B,
unmanagedPanelCapabilities = 0x30,
unmanagedButtonDown = 0x31,
unmanagedButtonUp = 0x32,
unmanagedEncoderChange = 0x33,
unmanagedDisplayRefresh = 0x34,
panelConnectionState = 0x35,
}
--- hs.tangent.toHub -> table
--- Constant
--- Definitions for IPC Commands from Hammerspoon to the HUB.
mod.toHub = {
applicationDefinition = 0x81,
parameterValue = 0x82,
menuString = 0x83,
allChange = 0x84,
modeValue = 0x85,
displayText = 0x86,
unmanagedPanelCapabilitiesRequest = 0xA0,
unmanagedDisplayWrite = 0xA1,
renameControl = 0xA2,
highlightControl = 0xA3,
indicateControl = 0xA4,
panelConnectionStatesRequest = 0xA5,
}
mod.reserved = {
--- hs.tangent.reserved.action -> table
--- Constant
--- Definitions for reserved action IDs.
---
--- Notes:
--- * `alt` - toggles the 'ALT' function.
--- * `nextKnobBank` - switches to the next knob bank.
--- * `prevKnobBank` - switches to the previous knob bank.
--- * `nextButtonBank` - switches to the next button bank.
--- * `prevBasketBank` - switches to the previous button bank.
--- * `nextTrackerballBank` - switches to the next trackerball bank.
--- * `prevTrackerballBank` - switches to the previous trackerball bank.
--- * `nextMode` - switches to the next mode.
--- * `prevMode` - switches to the previous mode.
--- * `goToMode` - switches to the specified mode, requiring a Argument with the mode ID.
--- * `toggleJogShuttle` - toggles jog/shuttle mode.
--- * `toggleMouseEmulation` - toggles mouse emulation.
--- * `fakeKeypress` - generates a keypress, requiring an Argument with the key code.
--- * `showHUD` - shows the HUD on screen.
--- * `goToKnobBank` - goes to the specific knob bank, requiring an Argument with the bank number.
--- * `goToButtonBank` - goes to the specific button bank, requiring an Argument with the bank number.
--- * `goToTrackerballBank` - goes to the specific trackerball bank, requiring an Argument with the bank number.
action = {
_ = 0x80000000,
alt = 0x80000001,
nextKnobBank = 0x80000002,
prevKnobBank = 0x80000003,
nextButtonBank = 0x80000004,
prevButtonBank = 0x80000005,
nextTrackerballBank = 0x80000006,
prevTrackerballBank = 0x80000007,
nextMode = 0x80000009,
prevMode = 0x8000000A,
goToMode = 0x8000000B,
toggleJogShuttle = 0x8000000C,
toggleMouseEmulation = 0x8000000D,
fakeKeypress = 0x8000000E,
showHUD = 0x8000000F,
goToKnobBank = 0x80000010,
goToButtonBank = 0x80000011,
goToTrackerballBank = 0x80000012,
},
--- hs.tangent.reserved.parameter -> table
--- Constant
--- A table of reserved parameter IDs.
---
--- Notes:
--- * `transportRing` - transport ring.
--- * `fakeKeypress` - sends a fake keypress.
parameter = {
_ = 0x81000000,
transportRing = 0x81000001,
fakeKeypress = 0x81000002,
},
menu = {
_ = 0x82000000,
}
}
--- hs.tangent.panelType -> table
--- Constant
--- Tangent Panel Types.
mod.panelType = {
[0x03] = "CP200-BK",
[0x04] = "CP200-K",
[0x05] = "CP200-TS",
[0x09] = "CP200-S",
[0x0A] = "Wave",
[0x0C] = "Element-Tk",
[0x0D] = "Element-Mf",
[0x0E] = "Element-Kb",
[0x0F] = "Element-Bt",
[0x11] = "Ripple",
}
-- ERROR_OFFSET -> number
-- Constant
-- Error Offset.
local ERROR_OFFSET = -1
--------------------------------------------------------------------------------
-- HELPER FUNCTIONS:
--------------------------------------------------------------------------------
-- isNumber(value) -> boolean
-- Function
-- Checks to see whether or not `value` is a number.
--
-- Parameters:
-- * value - The value to check.
--
-- Returns:
-- * A boolean.
local function isNumber(value)
return type(value) == "number"
end
-- isNotTable(value) -> boolean
-- Function
-- Checks to see whether or not `value` is not a table.
--
-- Parameters:
-- * value - The value to check.
--
-- Returns:
-- * A boolean.
local function isNotTable(value)
return type(value) ~= "table"
end
-- isNotList(value) -> boolean
-- Function
-- Checks to see whether or not `value` is not a list.
--
-- Parameters:
-- * value - The value to check.
--
-- Returns:
-- * A boolean.
local function isNotList(value)
return isNotTable(value) or #value == 0
end
-- doesDirectoryExist(path) -> string
-- Function
-- Returns whether or not a directory exists.
--
-- Parameters:
-- * path - the path of the directory you want to check as a string.
--
-- Returns:
-- * `true` if the directory exists otherwise `false`
local function doesDirectoryExist(path)
if path then
local attr = fs.attributes(path)
return attr and attr.mode == 'directory'
else
return false
end
end
-- doesFileExist(path) -> boolean
-- Function
-- Returns whether or not a file exists.
--
-- Parameters:
-- * path - Path to the file
--
-- Returns:
-- * `true` if the file exists otherwise `false`
local function doesFileExist(path)
if path == nil then return nil end
local attr = fs.attributes(path)
if type(attr) == "table" then
return true
else
return false
end
end
-- getPanelType(id) -> string
-- Function
-- Returns the Panel Type based on an ID
--
-- Parameters:
-- * id - ID of the Panel Type you want to return
--
-- Returns:
-- * Panel Type as string
local function getPanelType(id)
return mod.panelType[id]
end
-- byteStringToNumber(str, offset, numberOfBytes[, signed]) -> number, number
-- Function
-- Translates a Byte String into a Number
--
-- Parameters:
-- * str - The string you want to translate
-- * offset - An offset
-- * numberOfBytes - Number of bytes
-- * signed - `true` if it's a signed integer otherwise `false`. Defaults to `false`.
--
-- Returns:
-- * A number value
-- * The new offset
local function byteStringToNumber(str, offset, numberOfBytes, signed)
local fmt = (signed and ">i" or ">I") .. tostring(numberOfBytes)
return unpack(fmt, str, offset)
end
-- byteStringToFloat(str, offset) -> number, number
-- Function
-- Translates a Byte String into a Float Number
--
-- Parameters:
-- * str - The string you want to translate
-- * offset - An offset
--
-- Returns:
-- * A number value
-- * The new offset
local function byteStringToFloat(str, offset)
return unpack(">f", str, offset)
end
-- byteStringToBoolean(str, offset, numberOfBytes) -> boolean, number
-- Function
-- Translates a Byte String into a Boolean
--
-- Parameters:
-- * str - The string you want to translate
-- * offset - An offset
-- * numberOfBytes - Number of bytes
--
-- Returns:
-- * A boolean value
-- * The new offset
local function byteStringToBoolean(str, offset, numberOfBytes)
local x = byteStringToNumber(str, offset, numberOfBytes)
return x == 1 or false, offset + numberOfBytes
end
-- numberToByteString(n) -> string
-- Function
-- Translates a number into a byte string.
--
-- Parameters:
-- * n - The number you want to translate
--
-- Returns:
-- * A string
local function numberToByteString(n)
if type(n) ~= "number" then
log.ef("numberToByteString() was fed something other than a number")
return nil
end
return pack(">I4", n)
end
-- floatToByteString(n) -> string
-- Function
-- Translates a float number into a byte string.
--
-- Parameters:
-- * n - The number you want to translate
--
-- Returns:
-- * A string
local function floatToByteString(n)
if type(n) ~= "number" then
log.ef("floatToByteString() was fed something other than a number")
return nil
end
return pack(">f", n)
end
-- booleanToByteString(value) -> string
-- Function
-- Translates a boolean into a byte string.
--
-- Parameters:
-- * value - The boolean you want to translate
--
-- Returns:
-- * A string
local function booleanToByteString(value)
if value == true then
return numberToByteString(1)
else
return numberToByteString(0)
end
end
-- validCallback() -> boolean
-- Function
-- Checks to see if the callback is valid.
--
-- Parameters:
-- * None
--
-- Returns:
-- * `true` if valid otherwise `false`.
local function validCallback()
return type(mod._callback) == "function"
end
-- processCommands(commands) -> none
-- Function
-- Triggers the callback using the contents of the buffer.
--
-- Parameters:
-- * None
--
-- Returns:
-- * None
local function processCommands(commands)
--------------------------------------------------------------------------------
-- Trigger the callback:
--------------------------------------------------------------------------------
if mod._callback then
local success, result = xpcall(function() mod._callback(commands) end, debug.traceback)
if not success then
log.ef("Error in Tangent Callback: %s", result)
end
end
end
-- errorResponse(message) -> nil, number
-- Function
-- Writes an error message to the Hammerspoon Console.
--
-- Parameters:
-- * message - The error message.
--
-- Returns:
-- * `nil`
-- * The error offset number.
local function errorResponse(message)
log.ef(message)
return nil, ERROR_OFFSET
end
-- receiveHandler -> table
-- Variable
-- Collection of handlers for messages received from the Hub.
local receiveHandler = {
--------------------------------------------------------------------------------
-- InitiateComms (0x01)
-- * Initiates communication between the Hub and the application.
-- * Communicates the quantity, type and IDs of the panels which are
-- configured to be connected in the panel-list.xml file. Note that this is
-- not the same as the panels which are actually connected – just those
-- which are expected to be connected.
-- * The length is dictated by the number of panels connected as the details
-- of each panel occupies 5 bytes.
-- * On receipt the application should respond with the
-- ApplicationDefinition (0x81) command.
--
-- Format: 0x01, <protocolRev>, <numPanels>, (<mod.panelType>, <panelID>)...
--
-- protocolRev: The revision number of the protocol (Unsigned Int)
-- numPanels: The number of panels connected (Unsigned Int)
-- panelType: The code for the type of panel connected (Unsigned Int)
-- panelID: The ID of the panel (Unsigned Int)
--------------------------------------------------------------------------------
[mod.fromHub.initiateComms] = function(data, offset)
--------------------------------------------------------------------------------
-- Send Application Definition?
--------------------------------------------------------------------------------
if mod.automaticallySendApplicationDefinition == true then
mod.sendApplicationDefinition()
end
local protocolRev, numberOfPanels
protocolRev, offset = byteStringToNumber(data, offset, 4)
numberOfPanels, offset = byteStringToNumber(data, offset, 4)
--------------------------------------------------------------------------------
-- Trigger callback:
--------------------------------------------------------------------------------
if protocolRev and numberOfPanels and validCallback() then
local panels = {}
for _ = 1,numberOfPanels do
local currentPanelID, currentPanelType
currentPanelType, offset = byteStringToNumber(data, offset, 4)
currentPanelID, offset = byteStringToNumber(data, offset, 4)
table.insert(panels, {
panelID = currentPanelID,
panelType = getPanelType(currentPanelType),
})
end
return {
protocolRev = protocolRev,
numberOfPanels = numberOfPanels,
panels = panels,
}, offset
else
return nil, ERROR_OFFSET
end
end,
--------------------------------------------------------------------------------
-- ParameterChange (0x02)
-- * Requests that the application increment a parameter. The application needs
-- to constrain the value to remain within its maximum and minimum values.
-- * On receipt the application should respond to the Hub with the new
-- absolute parameter value using the ParameterValue (0x82) command,
-- if the value has changed.
--
-- Format: 0x02, <paramID>, <increment>
--
-- paramID: The ID value of the parameter (Unsigned Int)
-- increment: The incremental value which should be applied to the parameter (Float)
--------------------------------------------------------------------------------
[mod.fromHub.parameterChange] = function(data, offset)
local paramID, increment
paramID, offset = byteStringToNumber(data, offset, 4)
increment, offset = byteStringToFloat(data, offset)
if paramID and increment and validCallback() then
return {
paramID = paramID,
increment = increment,
}, offset
else
return errorResponse("Error translating parameterChange.")
end
end,
--------------------------------------------------------------------------------
-- ParameterReset (0x03)
-- * Requests that the application changes a parameter to its reset value.
-- * On receipt the application should respond to the Hub with the new absolute
-- parameter value using the ParameterValue (0x82) command, if the value
-- has changed.
--
-- Format: 0x03, <paramID>
--
-- paramID: The ID value of the parameter (Unsigned Int)
--------------------------------------------------------------------------------
[mod.fromHub.parameterReset] = function(data, offset)
local paramID
paramID, offset = byteStringToNumber(data, offset, 4)
if paramID then
return {
paramID = paramID,
}, offset
else
return errorResponse("Error translating parameterReset.")
end
end,
--------------------------------------------------------------------------------
-- ParameterValueRequest (0x04)
-- * Requests that the application sends a ParameterValue (0x82) command
-- to the Hub.
--
-- Format: 0x04, <paramID>
--
-- paramID: The ID value of the parameter (Unsigned Int)
--------------------------------------------------------------------------------
[mod.fromHub.parameterValueRequest] = function(data, offset)
local paramID
paramID, offset = byteStringToNumber(data, offset, 4)
if paramID then
return {
paramID = paramID,
}, offset
else
return errorResponse("Error translating parameterValueRequest.")
end
end,
--------------------------------------------------------------------------------
-- MenuChange (0x05)
-- * Requests the application change a menu index by +1 or -1.
-- * We recommend that menus that only have two values (e.g. on/off) should
-- toggle their state on receipt of either a +1 or -1 increment value.
-- This will allow a single button to toggle the state of such an item
-- without the need for separate ‘up’ and ‘down’ buttons.
--
-- Format: 0x05, <menuID>, <increment>
--
-- menuID: The ID value of the menu (Unsigned Int)
-- increment: The incremental amount by which the menu index should be changed which will always be an integer value of +1 or -1 (Signed Int)
--------------------------------------------------------------------------------
[mod.fromHub.menuChange] = function(data, offset)
local menuID, increment
menuID, offset = byteStringToNumber(data, offset, 4)
increment, offset = byteStringToNumber(data, offset, 4)
if menuID and increment then
return {
menuID = menuID,
increment = increment,
}, offset
else
return errorResponse("Error translating menuChange.")
end
end,
--------------------------------------------------------------------------------
-- MenuReset (0x06)
-- * Requests that the application sends a MenuString (0x83) command to the Hub.
--
-- Format: 0x06, <menuID>
--
-- menuID: The ID value of the menu (Unsigned Int)
--------------------------------------------------------------------------------
[mod.fromHub.menuReset] = function(data, offset)
local menuID
menuID, offset = byteStringToNumber(data, offset, 4)
if menuID then
return {
menuID = menuID,
}, offset
else
return errorResponse("Error translating menuReset.")
end
end,
--------------------------------------------------------------------------------
-- MenuStringRequest (0x07)
-- * Requests that the application sends a MenuString (0x83) command to the Hub.
-- * On receipt, the application should respond to the Hub with the new menu
-- value using the MenuString (0x83) command, if the menu has changed.
--
-- Format: 0x07, <menuID>
--
-- menuID: The ID value of the menu (Unsigned Int)
--------------------------------------------------------------------------------
[mod.fromHub.menuStringRequest] = function(data, offset)
local menuID
menuID, offset = byteStringToNumber(data, offset, 4)
if menuID then
return {
menuID = menuID,
}, offset
else
return errorResponse("Error translating menuStringRequest.")
end
end,
--------------------------------------------------------------------------------
-- Action On (0x08)
-- * Requests that the application performs the specified action.
--
-- Format: 0x08, <actionID>
--
-- actionID: The ID value of the action (Unsigned Int)
--------------------------------------------------------------------------------
[mod.fromHub.actionOn] = function(data, offset)
local actionID
actionID, offset = byteStringToNumber(data, offset, 4)
if actionID then
return {
actionID = actionID,
}, offset
else
return errorResponse("Error translating actionOn.")
end
end,
--------------------------------------------------------------------------------
-- ModeChange (0x09)
-- * Requests that the application changes to the specified mode.
--
-- Format: 0x09, <modeID>
--
-- modeID: The ID value of the mode (Unsigned Int)
--------------------------------------------------------------------------------
[mod.fromHub.modeChange] = function(data, offset)
local modeID
modeID, offset = byteStringToNumber(data, offset, 4)
if modeID then
return {
modeID = modeID,
}, offset
else
return errorResponse("Error translating modeChange.")
end
end,
--------------------------------------------------------------------------------
-- Transport (0x0A)
-- * Requests the application to move the currently active transport.
-- * jogValue or shuttleValue will never both be set simultaneously
-- * One revolution of the control represents 32 counts by default.
-- The user will be able to adjust the sensitivity of Jog & Shuttle
-- independently in the TUBE Mapper tool to send more or less than
-- 32 counts per revolution.
--
-- Format: 0x0A, <jogValue>, <shuttleValue>
--
-- jogValue: The number of jog steps to move the transport (Signed Int)
-- shuttleValue: An incremental value to add to the shuttle speed (Signed Int)
--------------------------------------------------------------------------------
[mod.fromHub.transport] = function(data, offset)
local jogValue, shuttleValue
jogValue, offset = byteStringToNumber(data, offset, 4, true)
shuttleValue, offset = byteStringToNumber(data, offset, 4, true)
if jogValue and shuttleValue then
return {
jogValue = jogValue,
shuttleValue = shuttleValue,
}, offset
else
return errorResponse("Error translating transport.")
end
end,
--------------------------------------------------------------------------------
-- ActionOff (0x0B)
-- * Requests that the application cancels the specified action.
-- * This is typically sent when a button is released.
--
-- Format: 0x0B, <actionID>
--
-- actionID: The ID value of the action (Unsigned Int)
--------------------------------------------------------------------------------
[mod.fromHub.actionOff] = function(data, offset)
local actionID
actionID, offset = byteStringToNumber(data, offset, 4)
if actionID then
return {
actionID = actionID,
}, offset
else
return errorResponse("Error translating actionOff.")
end
end,
--------------------------------------------------------------------------------
-- UnmanagedPanelCapabilities (0x30)
-- * Only used when working in Unmanaged panel mode.
-- * Sent in response to a UnmanagedPanelCapabilitiesRequest (0xA0) command.
-- * The values returned are those given in the table in Section 18.
-- Panel Data for Unmanaged Mode.
--
-- Format: 0x30, <panelID>, <numButtons>, <numEncoders>, <numDisplays>, <numDisplayLines>, <numDisplayChars>
--
-- panelID: The ID of the panel as reported in the InitiateComms command (Unsigned Int)
-- numButtons: The number of buttons on the panel (Unsigned Int)
-- numEncoders: The number of encoders on the panel (Unsigned Int)
-- numDisplays: The number of displays on the panel (Unsigned Int)
-- numDisplayLines: The number of lines for each display on the panel (Unsigned Int)
-- numDisplayChars: The number of characters on each line of each display on the panel (Unsigned Int)
--------------------------------------------------------------------------------
[mod.fromHub.unmanagedPanelCapabilities] = function(data, offset)
local panelID, numButtons, numEncoders, numDisplays, numDisplayLines, numDisplayChars
panelID, offset = byteStringToNumber(data, offset, 4)
numButtons, offset = byteStringToNumber(data, offset, 4)
numEncoders, offset = byteStringToNumber(data, offset, 4)
numDisplays, offset = byteStringToNumber(data, offset, 4)
numDisplayLines, offset = byteStringToNumber(data, offset, 4)
numDisplayChars, offset = byteStringToNumber(data, offset, 4)
if panelID and numButtons and numEncoders and numDisplays and numDisplayLines and numDisplayChars then
return {
panelID = panelID,
numButtons = numButtons,
numEncoders = numEncoders,
numDisplays = numDisplays,
numDisplayLines = numDisplayLines,
numDisplayChars = numDisplayChars,
}, offset
else
return errorResponse("Error translating unmanagedPanelCapabilities.")
end
end,
--------------------------------------------------------------------------------
-- UnmanagedButtonDown (0x31)
-- * Only used when working in Unmanaged panel mode
-- * Issued when a button has been pressed
--
-- Format: 0x31, <panelID>, <buttonID>
--
-- panelID: The ID of the panel as reported in the InitiateComms command (Unsigned Int)
-- buttonID: The hardware ID of the button (Unsigned Int)
--------------------------------------------------------------------------------
[mod.fromHub.unmanagedButtonDown] = function(data, offset)
local panelID, buttonID
panelID, offset = byteStringToNumber(data, offset, 4)
buttonID, offset = byteStringToNumber(data, offset, 4)
if panelID and buttonID then
return {
panelID = panelID,
buttonID = buttonID,
}, offset
else
return errorResponse("Error translating unmanagedButtonDown.")
end
end,
--------------------------------------------------------------------------------
-- UnmanagedButtonUp (0x32)
-- * Only used when working in Unmanaged panel mode.
-- * Issued when a button has been released
--
-- Format: 0x32, <panelID>, <buttonID>
--
-- panelID: The ID of the panel as reported in the InitiateComms command (Unsigned Int)
-- buttonID: The hardware ID of the button (Unsigned Int)
--------------------------------------------------------------------------------
[mod.fromHub.unmanagedButtonUp] = function(data, offset)
local panelID, buttonID
panelID, offset = byteStringToNumber(data, offset, 4)
buttonID, offset = byteStringToNumber(data, offset, 4)
if panelID and buttonID then
return {
panelID = panelID,
buttonID = buttonID,
}, offset
else
return errorResponse("Error translating unmanagedButtonUp.")
end
end,
--------------------------------------------------------------------------------
-- UnmanagedEncoderChange (0x33)
-- * Only used when working in Unmanaged panel mode.
-- * Issued when an encoder has been moved.
--
-- Format: 0x33, <panelID>, <encoderID>, <increment>
--
-- panelID: The ID of the panel as reported in the InitiateComms command (Unsigned Int)
-- paramID: The hardware ID of the encoder (Unsigned Int)
-- increment: The incremental value (Float)
--------------------------------------------------------------------------------
[mod.fromHub.unmanagedEncoderChange] = function(data, offset)
local panelID, encoderID, increment
panelID, offset = byteStringToNumber(data, offset, 4)
encoderID, offset = byteStringToNumber(data, offset, 4)
increment, offset = byteStringToFloat(data, offset)
if panelID and encoderID and increment then
return {
panelID = panelID,
encoderID = encoderID,
increment = increment,
}, offset
else
return errorResponse("Error translating unmanagedEncoderChange.")
end
end,
--------------------------------------------------------------------------------
-- UnmanagedDisplayRefresh (0x34)
-- * Only used when working in Unmanaged panel mode
-- * Issued when a panel has been connected or the focus of the panel has
-- been returned to your application.
-- * On receipt your application should send all the current information to
-- each display on the panel in question.
--
-- Format: 0x34, <panelID>
--
-- panelID: The ID of the panel as reported in the InitiateComms command (Unsigned Int)
--------------------------------------------------------------------------------
[mod.fromHub.unmanagedDisplayRefresh] = function(data, offset)
local panelID
panelID, offset = byteStringToNumber(data, offset, 4)
if panelID then
return {
panelID = panelID,
}, offset
else
return errorResponse("Error translating unmanagedDisplayRefresh.")
end
end,
--------------------------------------------------------------------------------
-- PanelConnectionState (0x35)
-- * Sent in response to a PanelConnectionStatesRequest (0xA5) command to
-- report the current connected/disconnected status of a configured panel.
--
-- Format: 0x35, <panelID>, <state>
--
-- panelID: The ID of the panel as reported in the InitiateComms command (Unsigned Int)
-- state: The connected state of the panel: 1 if connected, 0 if disconnected (Bool)
--------------------------------------------------------------------------------
[mod.fromHub.panelConnectionState] = function(data, offset)
local panelID, state
panelID, offset = byteStringToNumber(data, offset, 4)
state, offset = byteStringToBoolean(data, offset, 4)
if panelID and state then
return {
panelID = panelID,
state = state,
}, offset
else
return errorResponse("Error translating panelConnectionState.")
end
end,
}
-- processHubCommand(data) -> none
-- Function
-- Processes a single HUB Command.
--
-- Parameters:
-- * data - The raw data from the socket.
--
-- Returns:
-- * None
local function processHubCommand(data, offset)
local id, command
id, offset = byteStringToNumber(data, offset, 4)
-- log.df("Processing command %#010x, offset: %d", id, offset)
local fn = receiveHandler[id]
if fn then
local result
result, offset = fn(data, offset)
if offset == ERROR_OFFSET then
command = {
id = ERROR_OFFSET,
metadata = {
details = format("Error while processing command ID: %#010x", id),
data = data,
offset = offset,
}
}
else
command = {
id = id,
metadata = result
}
end
else
command = {
id = ERROR_OFFSET,
metadata = {
details = format("Unrecognised command ID: %#010x", id),
data = data,
offset = offset,
}
}
end
return command, offset
end
-- processDataFromHub(data) -> none
-- Function
-- Separates multiple Hub Commands for processing.
--
-- Parameters:
-- * data - The raw data from the socket.
--
-- Returns:
-- * None
local function processDataFromHub(data)
if not validCallback() then
--------------------------------------------------------------------------------
-- There's no callback setup, so abort:
--------------------------------------------------------------------------------
return
end
local commands = {}
local len = string.len(data)
local offset = 1
while offset > 0 and offset < len do
local command
command, offset = processHubCommand(data, offset)
if command then
commands[#commands + 1] = command
end
end
--------------------------------------------------------------------------------
-- Process the buffer:
--------------------------------------------------------------------------------
processCommands(commands)
end
--------------------------------------------------------------------------------
-- PRIVATE VARIABLES:
--------------------------------------------------------------------------------
-- hs.tangent._buffer -> table
-- Variable
-- The commands buffer.
mod._buffer = {}
-- hs.tangent._readBytesRemaining -> number
-- Variable
-- Number of read bytes remaining.
mod._readBytesRemaining = 0
-- hs.tangent._applicationName -> number
-- Variable
-- Application name as specified in `hs.tangent.connect()`
mod._applicationName = nil
-- hs.tangent._systemPath -> number
-- Variable
-- A string containing the absolute path of the directory that contains the Controls and Default Map XML files.
mod._systemPath = nil
-- hs.tangent._userPath -> number
-- Variable
-- A string containing the absolute path of the directory that contains the User’s Default Map XML files.
mod._userPath = nil
--------------------------------------------------------------------------------
-- PUBLIC FUNCTIONS & METHODS:
--------------------------------------------------------------------------------
--- hs.tangent.ipAddress -> number
--- Variable
--- IP Address that the Tangent Hub is located at. Defaults to 127.0.0.1.
mod.ipAddress = "127.0.0.1"
--- hs.tangent.port -> number
--- Variable
--- The port that Tangent Hub monitors. Defaults to 64246.
mod.port = 64246
--- hs.tangent.automaticallySendApplicationDefinition -> boolean
--- Variable
--- Automatically send the "Application Definition" response. Defaults to `true`.
mod.automaticallySendApplicationDefinition = true
--- hs.tangent.setLogLevel(loglevel) -> none
--- Function
--- Sets the Log Level.
---
--- Parameters:
--- * loglevel - can be 'nothing', 'error', 'warning', 'info', 'debug', or 'verbose'; or a corresponding number between 0 and 5
---
--- Returns:
--- * None
function mod.setLogLevel(loglevel)
log:setLogLevel(loglevel)
socket.setLogLevel(loglevel)
end
--- hs.tangent.isTangentHubInstalled() -> boolean
--- Function
--- Checks to see whether or not the Tangent Hub software is installed.
---
--- Parameters:
--- * None
---
--- Returns:
--- * `true` if Tangent Hub is installed otherwise `false`.
function mod.isTangentHubInstalled()
if doesFileExist("/Library/Application Support/Tangent/Hub/TangentHub") then
return true
else
return false
end
end
--- hs.tangent.callback() -> boolean
--- Function
--- Sets a callback when new messages are received.
---
--- Parameters:
--- * callbackFn - a function to set as the callback for `hs.tangent`. If the value provided is `nil`, any currently existing callback function is removed.
---
--- Returns:
--- * `true` if successful otherwise `false`
---
--- Notes:
--- * Full documentation for the Tangent API can be downloaded [here](http://www.tangentwave.co.uk/download/developer-support-pack/).
--- * The callback function should expect 1 argument and should not return anything.
--- * The 1 argument will be a table, which can contain one or many commands. Each command is it's own table with the following contents:
--- * id - the message ID of the incoming message
--- * metadata - A table of data for the Tangent command (see below).
--- * The metadata table will return the following, depending on the `id` for the callback:
--- * `connected` - Connection to Tangent Hub successfully established.
--- * `disconnected` - The connection to Tangent Hub was dropped.
--- * `initiateComms` - Initiates communication between the Hub and the application.
--- * `protocolRev` - The revision number of the protocol.
--- * `numPanels` - The number of panels connected.
--- * `panels`
--- * `panelID` - The ID of the panel.
--- * `panelType` - The type of panel connected.
--- * `data` - The raw data from the Tangent Hub
--- * `parameterChange` - Requests that the application increment a parameter.
--- * `paramID` - The ID value of the parameter.
--- * `increment` - The incremental value which should be applied to the parameter.
--- * `parameterReset` - Requests that the application changes a parameter to its reset value.
--- * `paramID` - The ID value of the parameter.
--- * `parameterValueRequest` - Requests that the application sends a `ParameterValue (0x82)` command to the Hub.
--- * `paramID` - The ID value of the parameter.
--- * `menuChange` - Requests the application change a menu index by +1 or -1.
--- * `menuID` - The ID value of the menu.
--- * `increment` - The incremental amount by which the menu index should be changed which will always be an integer value of +1 or -1.
--- * `menuReset` - Requests that the application changes a menu to its reset value.
--- * `menuID` - The ID value of the menu.
--- * `menuStringRequest` - Requests that the application sends a `MenuString (0x83)` command to the Hub.
--- * `menuID` - The ID value of the menu.
--- * `actionOn` - Requests that the application performs the specified action.
--- * `actionID` - The ID value of the action.
--- * `modeChange` - Requests that the application changes to the specified mode.
--- * `modeID` - The ID value of the mode.
--- * `transport` - Requests the application to move the currently active transport.
--- * `jogValue` - The number of jog steps to move the transport.
--- * `shuttleValue` - An incremental value to add to the shuttle speed.
--- * `actionOff` - Requests that the application cancels the specified action.
--- * `actionID` - The ID value of the action.
--- * `unmanagedPanelCapabilities` - Only used when working in Unmanaged panel mode. Sent in response to a `UnmanagedPanelCapabilitiesRequest (0xA0)` command.
--- * `panelID` - The ID of the panel as reported in the `InitiateComms` command.
--- * `numButtons` - The number of buttons on the panel.
--- * `numEncoders` - The number of encoders on the panel.
--- * `numDisplays` - The number of displays on the panel.
--- * `numDisplayLines` - The number of lines for each display on the panel.
--- * `numDisplayChars` - The number of characters on each line of each display on the panel.
--- * `unmanagedButtonDown` - Only used when working in Unmanaged panel mode. Issued when a button has been pressed.
--- * `panelID` - The ID of the panel as reported in the `InitiateComms` command.
--- * `buttonID` - The hardware ID of the button
--- * `unmanagedButtonUp` - Only used when working in Unmanaged panel mode. Issued when a button has been released.
--- * `panelID` - The ID of the panel as reported in the `InitiateComms` command.
--- * `buttonID` - The hardware ID of the button.
--- * `unmanagedEncoderChange` - Only used when working in Unmanaged panel mode. Issued when an encoder has been moved.
--- * `panelID` - The ID of the panel as reported in the `InitiateComms` command.
--- * `paramID` - The hardware ID of the encoder.
--- * `increment` - The incremental value.
--- * `unmanagedDisplayRefresh` - Only used when working in Unmanaged panel mode. Issued when a panel has been connected or the focus of the panel has been returned to your application.
--- * `panelID` - The ID of the panel as reported in the `InitiateComms` command.
--- * `panelConnectionState`
--- * `panelID` - The ID of the panel as reported in the `InitiateComms` command.
--- * `state` - The connected state of the panel, `true` if connected, `false` if disconnected.
function mod.callback(callbackFn)
if type(callbackFn) == "function" then
mod._callback = callbackFn
return true
elseif type(callbackFn) == "nil" then
mod._callback = nil
return true
else
log.ef("Callback recieved an invalid type: %s", type(callbackFn))
return false
end
end
--- hs.tangent.connected() -> boolean
--- Function
--- Checks to see whether or not you're successfully connected to the Tangent Hub.
---
--- Parameters:
--- * None
---
--- Returns:
--- * `true` if connected, otherwise `false`
function mod.connected()
return mod._socket ~= nil and mod._socket:connected()
end
--- hs.tangent.send(byteString) -> boolean, string
--- Function
--- Sends a "bytestring" message to the Tangent Hub.
---
--- Parameters:
--- * byteString - The string of bytes to send to tangent.
---
--- Returns:
--- * success - `true` if connected, otherwise `false`
--- * errorMessage - An error message if an error occurs, as a string
---
--- Notes:
--- * This should be a full encoded string for the command you want to send, withouth the leading 'size' section, which the function will calculate automatically.
--- * In general, you should use the more specific functions that package the command for you, such as `sendParameterValue(...)`. This function can be used to send a message that this API doesn't yet support.
--- * Full documentation for the Tangent API can be downloaded [here](http://www.tangentwave.co.uk/download/developer-support-pack/).
function mod.send(byteString)
if mod.connected() then
if byteString == nil or #byteString == 0 then
return false, "No byte string provided"
end
mod._socket:send(numberToByteString(#byteString)..byteString)
return true
end
return false, "Not connected"
end
--- hs.tangent.sendApplicationDefinition([appName, systemPath, userPath]) -> boolean, string
--- Function
--- Sends the application details to the Tangent Hub.
---
--- Parameters:
--- * appName - The human-readable name of the application.
--- * systemPath - A string containing the absolute path of the directory that contains the Controls and Default Map XML files (Path String)
--- * userPath - A string containing the absolute path of the directory that contains the User’s Default Map XML files (Path String)
---
--- Returns:
--- * `true` if successful, `false` and an error message if there was a problem.
---
--- Notes:
--- * If no details are provided the ones stored in the module are used.
function mod.sendApplicationDefinition(appName, systemPath, userPath)
appName = appName or mod._applicationName
systemPath = systemPath or mod._systemPath
userPath = userPath or mod._userPath
if not appName then
return false, format("Missing or invalid application name: %s", inspect(appName))
end
if not systemPath or doesDirectoryExist(systemPath) == false then
return false, format("Missing or invalid system path: %s", inspect(systemPath))
end
if userPath and doesDirectoryExist(userPath) == false then
return false, format("Missing or invalid userPath: %s", inspect(userPath))
end
--------------------------------------------------------------------------------
-- Format: 0x81, <appStrLen>, < appStr>, <sysDirStrLen>, <sysDirStr>, <userDirStrLen>, <userDirStr>
--
-- appStrLen: The length of appStr (Unsigned Int)
-- appStr: A string containing the name of the application (Character String)
-- sysDirStrLen: The length of sysDirStr (Unsigned Int)
-- sysDirStr: A string containing the absolute path of the directory that contains the Controls and Default Map XML files (Path String)
-- usrDirStrLen: The length of usrDirStr (Unsigned Int)
-- usrDirStr: A string containing the absolute path of the directory that contains the User’s Default Map XML files (Path String)
--------------------------------------------------------------------------------
local byteString = numberToByteString(mod.toHub.applicationDefinition) ..
numberToByteString(#appName) ..
appName ..
numberToByteString(#systemPath) ..
systemPath ..
numberToByteString(userPath and #userPath or 0) ..
(userPath ~= nil and userPath or "")
return mod.send(byteString)
end
--- hs.tangent.sendParameterValue(paramID, value[, atDefault]) -> boolean, string
--- Function
--- Updates the Hub with a parameter value.
---
--- Parameters:
--- * paramID - The ID value of the parameter (Unsigned Int)
--- * value - The current value of the parameter (Float)
--- * atDefault - if `true` the value represents the default. Defaults to `false`.
---
--- Returns:
--- * `true` if successful, or `false` and an error message if not.
---
--- Notes:
--- * The Hub then updates the displays of any panels which are currently showing the parameter value.
function mod.sendParameterValue(paramID, value, atDefault)
--------------------------------------------------------------------------------
-- Format: 0x82, <paramID>, <value>, <atDefault>
--
-- paramID: The ID value of the parameter (Unsigned Int)
-- value: The current value of the parameter (Float)
-- atDefault: True if the value represents the default. Otherwise false (Bool)
--------------------------------------------------------------------------------
if not paramID then
return false, format("Missing or invalid parameter ID: %s", inspect(paramID))
end
if not value or type(value) ~= "number" then
return false, format("Missing or invalid value: %s", inspect(value))
end
atDefault = atDefault == true
local byteString = numberToByteString(mod.toHub.parameterValue) ..
numberToByteString(paramID) ..
floatToByteString(value) ..
booleanToByteString(atDefault)
return mod.send(byteString)
end
--- hs.tangent.sendMenuString(menuID, value[, atDefault]) -> boolean, string
--- Function
--- Updates the Hub with a menu value.
---
--- Parameters:
--- * menuID - The ID value of the menu (Unsigned Int)
--- * value - The current ‘value’ of the parameter represented as a string
--- * atDefault - if `true` the value represents the default. Otherwise `false`.
---
--- Returns:
--- * `true` if successful, or `false` and an error message if not.
---
--- Notes:
--- * The Hub then updates the displays of any panels which are currently showing the menu.
--- * If a value of `nil` is sent then the Hub will not attempt to display a value for the menu. However the `atDefault` flag will still be recognised.
function mod.sendMenuString(menuID, value, atDefault)
--------------------------------------------------------------------------------
-- Format: 0x83, <menuID>, <valueStrLen>, <valueStr>, <atDefault>
--
-- menuID: The ID value of the menu (Unsigned Int)
-- valueStrLen: The length of valueStr (Unsigned Int)
-- valueStr: The current ‘value’ of the parameter represented as a string (Character String)
-- atDefault: True if the value represents the default. Otherwise false (Bool)
--------------------------------------------------------------------------------
if not type(menuID) == "number" then
return false, format("Missing or invalid menuID: %s", inspect(menuID))
end
value = value or ""
atDefault = atDefault == true
local byteString = numberToByteString(mod.toHub.menuString) ..
numberToByteString(menuID) ..
numberToByteString(#value) ..
value ..
booleanToByteString(atDefault)
return mod.send(byteString)
end
--- hs.tangent.sendAllChange() -> boolean, string
--- Function
--- Tells the Hub that a large number of software-controls have changed.
---
--- Parameters:
--- * None
---
--- Returns:
--- * `true` if successful, or `false` and an error message if not.
---
--- Notes:
--- * The Hub responds by requesting all the current values of software-controls it is currently controlling.
function mod.sendAllChange()
--------------------------------------------------------------------------------
-- Format: 0x84
--------------------------------------------------------------------------------
local byteString = numberToByteString(mod.toHub.allChange)
return mod.send(byteString)
end
--- hs.tangent.sendModeValue(modeID) -> boolean, string
--- Function
--- Updates the Hub with a mode value.
---
--- Parameters:
--- * modeID - The ID value of the mode (Unsigned Int)
---
--- Returns:
--- * `true` if successful, or `false` and an error message if not.
---
--- Notes:
--- * The Hub then changes mode and requests all the current values of software-controls it is controlling.
function mod.sendModeValue(modeID)
--------------------------------------------------------------------------------
-- Format: 0x85, <modeID>
--
-- modeID: The ID value of the mode (Unsigned Int)
--------------------------------------------------------------------------------
if not isNumber(modeID) then
return false, format("Missing or invalid `modeID`: %s", inspect(modeID))
end
local byteString = numberToByteString(mod.toHub.modeValue) ..
numberToByteString(modeID)
return mod.send(byteString)
end
--- hs.tangent.sendDisplayText(messages[, doubleHeight]) -> boolean, string
--- Function
--- Updates the Hub with a number of character strings that will be displayed on connected panels if there is space.
---
--- Parameters:
--- * messages - A list of messages to send.
--- * doubleHeight - An optional list of `boolean`s indicating if the corresponding message is double-height.
---
--- Returns:
--- * `true` if successful, or `false` and an error message if not.
---
--- Notes:
--- * Strings may either be 32 character, single height or 16 character double-height. They will be displayed in the order received; the first string displayed at the top of the display.
--- * If a string is not defined as double-height then it will occupy the next line.
--- * If a string is defined as double-height then it will occupy the next 2 lines.
--- * The maximum number of lines which will be used by the application must be indicated in the Controls XML file.
--- * Text which exceeds 32 (single-height) or 16 (double-height) characters will be truncated.
--- * If all text is single-height, the `doubleHeight` table can be omitted.
---
--- Examples:
---
--- ```lua
--- hs.tangent.sendDisplayText(
--- { "Single Height", "Double Height" }, {false, true}
--- )```
function mod.sendDisplayText(messages, doubleHeight)
--------------------------------------------------------------------------------
-- DisplayText (0x86)
-- * Updates the Hub with a number of character strings that will be displayed
-- on connected panels if there is space.
-- * Strings may either be 32 character, single height or 16 character
-- double-height. They will be displayed in the order received; the first
-- string displayed at the top of the display.
-- * If a string is not defined as double-height then it will occupy the
-- next line.
-- * If a string is defined as double-height then it will occupy the next
-- 2 lines.
-- * The maximum number of lines which will be used by the application
-- must be indicated in the Controls XML file.
-- * If a stateStrLen value of 0 is passed then the line will not be
-- overwritten with any information. In this circumstance no data should be
-- passed for stateStr and doubleHeight. The next byte will be the
-- stateStrLen for the next string.
--
-- Format: 0x86, <numStrings>, (<stateStrLen>, <stateStr>, <doubleHeight>)...
--
-- numStrings: The number of strings to follow (Unsigned Int)
-- stateStrLen: The length of stateStr (Unsigned Int)
-- stateStr: A line of status text (Character String)
-- doubleHeight: True if the string is to be printed double height. Otherwise false (Bool)
--------------------------------------------------------------------------------
if isNotList(messages) then
return false, format("The `messages` must be a list of strings: %s", inspect(messages))
end
doubleHeight = doubleHeight or {}
if isNotTable(doubleHeight) then
return false, format("Invalid `doubleHeight` parameter: %s", inspect(doubleHeight))
end
local byteString = numberToByteString(mod.toHub.displayText) ..
numberToByteString(#messages)
for i,value in ipairs(messages) do
--------------------------------------------------------------------------------
-- Trim to size:
--------------------------------------------------------------------------------
if not type(value) == "string" then
return false, format("Invalid message #%s: %s", i, inspect(value))
end
local isDouble = doubleHeight[i]
local maxLength = isDouble and 16 or 32
value = #value > maxLength and value:sub(0, maxLength) or value
byteString = byteString .. numberToByteString(#value)
if #value > 0 then
byteString = byteString .. value .. booleanToByteString(isDouble)
end
end
return mod.send(byteString)
end
--- hs.tangent.sendUnmanagedPanelCapabilitiesRequest(panelID) -> boolean, string
--- Function
--- Requests the Hub to respond with an UnmanagedPanelCapabilities (0x30) command.
---
--- Parameters:
--- * panelID - The ID of the panel as reported in the InitiateComms command (Unsigned Int)
---
--- Returns:
--- * `true` if successful, or `false` and an error message if not.
---
--- Notes:
--- * Only used when working in Unmanaged panel mode
function mod.sendUnmanagedPanelCapabilitiesRequest(panelID)
--------------------------------------------------------------------------------
-- Format: 0xA0, <panelID>
--
-- panelID: The ID of the panel as reported in the InitiateComms command (Unsigned Int)
--------------------------------------------------------------------------------
if not isNumber(panelID) then
return false, format("Missing or invalid panel ID: %s", inspect(panelID))
end
local byteString = numberToByteString(mod.toHub.unmanagedPanelCapabilitiesRequest) ..
numberToByteString(panelID)
return mod.send(byteString)
end
--- hs.tangent.sendUnmanagedDisplayWrite(panelID, displayID, lineNum, pos, message) -> boolean, string
--- Function
--- Updates the Hub with text that will be displayed on a specific panel at the given line and starting position where supported by the panel capabilities.
---
--- Parameters:
--- * panelID - The ID of the panel as reported in the InitiateComms command (Unsigned Int)
--- * displayID - The ID of the display to be written to (Unsigned Int)
--- * lineNum - The line number of the display to be written to with `1` as the top line (Unsigned Int)
--- * pos - The position on the line to start writing from with `1` as the first column (Unsigned Int)
--- * message - A line of text (Character String)
---
--- Returns:
--- * `true` if successful, or `false` and an error message if not.
---
--- Notes:
--- * Only used when working in Unmanaged panel mode.
--- * If the most significant bit of any individual text character in `message` is set it will be displayed as inversed with dark text on a light background.
function mod.sendUnmanagedDisplayWrite(panelID, displayID, lineNum, pos, message)
--------------------------------------------------------------------------------
-- Format: 0xA1, <panelID>, <displayID>, <lineNum>, <pos>, <dispStrLen>, <dispStr>
--
-- panelID: The ID of the panel as reported in the InitiateComms command (Unsigned Int)
-- displayID: The ID of the display to be written to (Unsigned Int)
-- lineNum: The line number of the display to be written to with 0 as the top line (Unsigned Int)
-- pos: The position on the line to start writing from with 0 as the first column (Unsigned Int)
-- dispStrLen: The length of dispStr (Unsigned Int)
-- dispStr: A line of text (Character String)
--------------------------------------------------------------------------------
if not isNumber(panelID) then
return false, format("Missing or invalid panelID: %s", inspect(panelID))
end
if not isNumber(displayID) then
return false, format("Missing or invalid displayID: %s", inspect(displayID))
end
if not isNumber(lineNum) or lineNum < 1 then
return false, format("Missing or invalid lineNum: %s", inspect(lineNum))
end
if not isNumber(pos) or pos < 1 then
return false, format("Missing or invalid pos: %s", inspect(pos))
end
if not type(message) == "string" then
return false, format("Missing or invalid message: %s", inspect(message))
end
local byteString = numberToByteString(mod.toHub.unmanagedDisplayWrite) ..
numberToByteString(panelID) ..
numberToByteString(displayID) ..
numberToByteString(lineNum-1) ..
numberToByteString(pos-1) ..
numberToByteString(#message) ..
message
return mod.send(byteString)
end
--- hs.tangent.sendRenameControl(targetID, newName) -> boolean, string
--- Function
--- Renames a control dynamically.
---
--- Parameters:
--- * targetID - The id of any application defined Parameter, Menu, Action or Mode (Unsigned Int)
--- * newName - The new name to apply.
---
--- Returns:
--- * `true` if successful, `false` and an error message if not.
---
--- Notes:
--- * The string supplied will replace the normal text which has been derived from the Controls XML file.
--- * To remove any existing replacement name set `newName` to `""`, this will remove any renaming and return the system to the normal display text
--- * When applied to Modes, the string displayed on buttons which mapped to the reserved "Go To Mode" action for this particular mode will also change.
function mod.sendRenameControl(targetID, newName)
--------------------------------------------------------------------------------
-- Format: 0xA2, <targetID>, <nameStrLen>, <nameStr>
--
-- targetID: The id of any application defined Parameter, Menu, Action or Mode (Unsigned Int)
-- nameStrLen: The length of nameStr (Unsigned Int)
--------------------------------------------------------------------------------
if not isNumber(targetID) then
return false, format("Missing or invalid targetID: %s", inspect(targetID))
end
if not type(newName) == "string" then
return false, format("Missing or invalid name: %s", inspect(newName))
end
local byteString = numberToByteString(mod.toHub.renameControl) ..
numberToByteString(targetID) ..
numberToByteString(#newName) ..
newName
return mod.send(byteString)
end
--- hs.tangent.sendHighlightControl(targetID, active) -> boolean, string
--- Function
--- Highlights the control on any panel where this feature is available.
---
--- Parameters:
--- * targetID - The id of any application defined Parameter, Menu, Action or Mode (Unsigned Int)
--- * active - If `true`, the control is highlighted, otherwise it is not.
---
--- Returns:
--- * `true` if sent successfully, `false` and an error message if no.
---
--- Notes:
--- * When applied to Modes, buttons which are mapped to the reserved "Go To Mode" action for this particular mode will highlight.
function mod.sendHighlightControl(targetID, active)
--------------------------------------------------------------------------------
-- targetID: The id of any application defined Parameter, Menu, Action or Mode (Unsigned Int)
-- state: The state to set. 1 for highlighted, 0 for clear (Unsigned Int)
--------------------------------------------------------------------------------
if not isNumber(targetID) then
return false, "Missing or invalid paramater: targetID."
end
local state = active == true and 1 or 0
local byteString = numberToByteString(mod.toHub.highlightControl) ..
numberToByteString(targetID) ..
numberToByteString(state)
return mod.send(byteString)
end
--- hs.tangent.sendIndicateControl(targetID, indicated) -> boolean, string
--- Function
--- Sets the Indicator of the control on any panel where this feature is available.
---
--- Parameters:
--- * targetID - The id of any application defined Parameter, Menu, Action or Mode
--- * active - If `true`, the control is indicated, otherwise it is not.
---
--- Returns:
--- * `true` if sent successfully, `false` and an error message if no.
---
--- Notes:
--- * This indicator is driven by the `atDefault` argument for Parameters and Menus. This command therefore only applies to controls mapped to Actions and Modes.
--- * When applied to Modes, buttons which are mapped to the reserved "Go To Mode" action for this particular mode will have their indicator set.
function mod.sendIndicateControl(targetID, active)
--------------------------------------------------------------------------------
-- Format: 0xA4, <targetID>, <state>
--
-- targetID: The id of any application defined Action or Mode (Unsigned Int)
-- state: The state to set. 1 for indicated, 0 for clear (Unsigned Int)
--------------------------------------------------------------------------------
if not isNumber(targetID) then
return false, "Missing or invalid paramater: targetID."
end
local state = active == true and 1 or 0
local byteString = numberToByteString(mod.toHub.indicateControl) ..
numberToByteString(targetID) ..
numberToByteString(state)
return mod.send(byteString)
end
--- hs.tangent.sendPanelConnectionStatesRequest())
--- Function
--- Requests the Hub to respond with a sequence of PanelConnectionState (0x35) commands to report the connected/disconnected status of each configured panel
---
--- Parameters:
--- * None
---
--- Returns:
--- * `true` if sent successfully, `false` and an error message if not.
---
--- Notes:
--- * A single request may result in multiple state responses.
function mod.sendPanelConnectionStatesRequest()
--------------------------------------------------------------------------------
-- Format: 0xA5
--------------------------------------------------------------------------------
local byteString = numberToByteString(mod.toHub.panelConnectionStatesRequest)
return mod.send(byteString)
end
-- notifyDisconnected() -> none
-- Function
-- Triggers the disconnection notification callback and stops the Connection Watcher.
--
-- Parameters:
-- * None
--
-- Returns:
-- * None
local function notifyDisconnected()
if mod._callback then
mod._callback({{id=mod.fromHub.disconnected, metadata={
ipAddress = mod.ipAddress,
port = mod.port,
}}})
end
if mod._connectionWatcher then mod._connectionWatcher:stop() end
end
-- hs.tangent._connectionWatcher -> timer
-- Variable
-- Tracks the Tangent socket connection.
mod._connectionWatcher = timer.new(1.0, function()
if not mod.connected() then
mod._socket = nil
notifyDisconnected()
end
end)
--- hs.tangent.disconnect() -> none
--- Function
--- Disconnects from the Tangent Hub.
---
--- Parameters:
--- * None
---
--- Returns:
--- * None
function mod.disconnect()
if mod._socket then
mod._socket:disconnect()
mod._socket = nil
notifyDisconnected()
mod._connectionWatcher:stop()
end
end
-- MESSAGE_SIZE -> number
-- Constant
-- Message Size.
local MESSAGE_SIZE = 1
-- MESSAGE_BODY -> number
-- Constant
-- Message Body.
local MESSAGE_BODY = 2
-- socketCallback(data, tag) -> none
-- Function
-- Tangent Socket Callback Function.
--
-- Parameters:
-- * data - The data read from the socket as a string
-- * tag - The integer tag associated with the read call, which defaults to -1
--
-- Returns:
-- * None
local function socketCallback(data, tag)
--log.df("Received data: size=%s; tag=%s", #data, inspect(tag))
if tag == MESSAGE_SIZE then
--------------------------------------------------------------------------------
-- Each message starts with an integer value indicating the number of bytes.
--------------------------------------------------------------------------------
local messageSize = byteStringToNumber(data, 1, 4)
if mod._socket then
mod._socket:read(messageSize, MESSAGE_BODY)
else
log.ef("Tangent: The Socket doesn't exist anymore.")
end
elseif tag == MESSAGE_BODY then
--------------------------------------------------------------------------------
-- We've read the rest of series of commands:
--------------------------------------------------------------------------------
processDataFromHub(data)
--------------------------------------------------------------------------------
-- Get set up for the next series of commands:
--------------------------------------------------------------------------------
if mod._socket then
mod._socket:read(4, MESSAGE_SIZE)
else
log.ef("Tangent: The Socket doesn't exist anymore.")
end
else
log.ef("Tangent: Unknown Tag or Data from Socket.")
end
end
--- hs.tangent.connect(applicationName, systemPath[, userPath]) -> boolean, errorMessage
--- Function
--- Connects to the Tangent Hub.
---
--- Parameters:
--- * applicationName - Your application name as a string
--- * systemPath - A string containing the absolute path of the directory that contains the Controls and Default Map XML files.
--- * [userPath] - An optional string containing the absolute path of the directory that contains the User’s Default Map XML files.
---
--- Returns:
--- * success - `true` on success, otherwise `nil`
--- * errorMessage - The error messages as a string or `nil` if `success` is `true`.
function mod.connect(applicationName, systemPath, userPath)
--------------------------------------------------------------------------------
-- Check Paramaters:
--------------------------------------------------------------------------------
if not applicationName or type(applicationName) ~= "string" then
return nil, "applicationName is a required string."
end
if systemPath and type(systemPath) == "string" then
local attr = fs.attributes(systemPath)
if not attr or attr.mode ~= 'directory' then
return nil, "systemPath must be a valid path."
end
else
return nil, "systemPath is a required string."
end
if userPath and type(userPath) == "string" then
local attr = fs.attributes(userPath)
if not attr or attr.mode ~= 'directory' then
return nil, "userPath must be a valid path."
end
end
--------------------------------------------------------------------------------
-- Save values for later:
--------------------------------------------------------------------------------
mod._applicationName = applicationName
mod._systemPath = systemPath
mod._userPath = userPath
--------------------------------------------------------------------------------
-- Connect to Tangent Hub:
--------------------------------------------------------------------------------
mod._socket = socket.new()
if mod._socket then
mod._socket:setCallback(socketCallback)
:connect(mod.ipAddress, mod.port, function()
--------------------------------------------------------------------------------
-- Trigger Callback when connected:
--------------------------------------------------------------------------------
if mod._callback then
mod._callback({{id=mod.fromHub.connected, metadata={
ipAddress = mod.ipAddress,
port = mod.port,
}}})
end
--------------------------------------------------------------------------------
-- Watch for disconnections:
--------------------------------------------------------------------------------
mod._connectionWatcher:start()
--------------------------------------------------------------------------------
-- Read the first 4 bytes, which will trigger the callback:
--------------------------------------------------------------------------------
mod._socket:read(4, MESSAGE_SIZE)
end)
end
return mod._socket ~= nil or nil
end
return mod
| mit |
TheAnswer/FirstTest | bin/scripts/creatures/objects/endor/npcs/gundula/gundulaElderWorker.lua | 1 | 4594 | --Copyright (C) 2008 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
gundulaElderWorker = Creature:new {
objectName = "gundulaElderWorker", -- Lua Object Name
creatureType = "NPC",
faction = "gundula_tribe",
factionPoints = 20,
gender = "",
speciesName = "gundula_elder_worker",
stfName = "mob/creature_names",
objectCRC = 580211289,
socialGroup = "gundula_tribe",
level = 19,
combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG,
healthMax = 5000,
healthMin = 4100,
strength = 0,
constitution = 0,
actionMax = 5000,
actionMin = 4100,
quickness = 0,
stamina = 0,
mindMax = 5000,
mindMin = 4100,
focus = 0,
willpower = 0,
height = 1, -- Size of creature
armor = 0, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy
kinetic = 20,
energy = 0,
electricity = -1,
stun = -1,
blast = 0,
heat = 35,
cold = 35,
acid = -1,
lightsaber = 0,
accuracy = 0,
healer = 0,
pack = 1,
herd = 0,
stalker = 0,
killer = 0,
ferocity = 0,
aggressive = 0,
invincible = 0,
attackCreatureOnSight = "", -- Enter socialGroups
weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx
weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance'
weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance'
weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon'
weaponEquipped = 0,
weaponMinDamage = 170,
weaponMaxDamage = 180,
weaponAttackSpeed = 2,
weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc
weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY
alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx
alternateWeaponName = "", -- Name ex. 'a Vibrolance'
alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance'
alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon'
alternateWeaponEquipped = 0,
alternateWeaponMinDamage = 0,
alternateWeaponMaxDamage = 0,
alternateWeaponAttackSpeed = 0,
alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc
alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY
internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's
lootGroup = "0", -- Group it belongs to for loot
tame = 0,
datapadItemCRC = 0,
mountCRC = 0,
mountSpeed = 0,
mountAcceleration = 0,
milk = 0,
boneType = "",
boneMax = 0,
hideType = "",
hideMax = 0,
meatType = "",
meatMax = 0,
skills = { "gundulaAttack1" },
respawnTimer = 180,
behaviorScript = "", -- Link to the behavior script for this object
}
Creatures:addCreature(gundulaElderWorker, 580211289) -- Add to Global Table
| lgpl-3.0 |
boundary/boundary-plugin-couchbase | init.lua | 2 | 7078 | -- Copyright 2015 Boundary, Inc.
--
-- 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 framework = require('framework')
local json = require('json')
local dns = require('dns')
local Plugin = framework.Plugin
local WebRequestDataSource = framework.WebRequestDataSource
local notEmpty = framework.string.notEmpty
local auth = framework.util.auth
local hasAny = framework.table.hasAny
local clone = framework.table.clone
local table = require('table')
local find = framework.table.find
local percentage = framework.util.percentage
local isHttpSuccess = framework.util.isHttpSuccess
local params = framework.params
params.pollInterval = notEmpty(tonumber(params.pollInterval), 1000)
params.host = notEmpty(params.host, 'localhost')
params.port = notEmpty(params.port, '8091')
params.advanced_metrics = params.advanced_metrics or false
-- 1. get /pools/nodes get the node based on the host parameter.
-- 2. get /pools/default/buckets for a list of available buckets for advanced metrics. This can be done with a CachedWebRequestDataSource
-- 3. get /pools/default/buckets/%s/nodes/%s/stats?zoom=minute for each bucket for advanced metrics. This can be a list of child request returned by the chain function.
local buckets = {}
local pending_requests = {}
local target
local plugin
local function getNode(nodes, hostname)
return find(function (v) return v.hostname == hostname end, nodes)
end
local function standardMetrics(cluster)
local result = {}
result['COUCHBASE_RAM_QUOTA_TOTAL'] = cluster.storageTotals.ram.quotaTotalPerNode or 0
result['COUCHBASE_RAM_QUOTA_USED'] = cluster.storageTotals.ram.quotaUsedPerNode or 0
local node = getNode(cluster.nodes, target)
if node then
result['COUCHBASE_CPU_USAGE_RATE'] = percentage(node.systemStats.cpu_utilization_rate or 0)
result['COUCHBASE_RAM_SYSTEM_TOTAL'] = node.systemStats.mem_total or 0
result['COUCHBASE_RAM_SYSTEM_FREE'] = node.systemStats.mem_free or 0
result['COUCHBASE_SWAP_TOTAL'] = node.systemStats.swap_total or 0
result['COUCHBASE_SWAP_USED'] = node.systemStats.swap_used or 0
result['COUCHBASE_OPERATIONS'] = node.interestingStats.ops or 0
result['COUCHBASE_DOCUMENTS_COUNT'] = node.interestingStats.curr_items or 0
result['COUCHBASE_DOCUMENTS_SIZE'] = node.interestingStats.couch_docs_data_size or 0
result['COUCHBASE_DOCUMENTS_SIZE_ON_DISK'] = node.interestingStats.couch_docs_actual_disk_size or 0
result['COUCHBASE_VIEWS_SIZE'] = node.interestingStats.couch_views_data_size or 0
result['COUCHBASE_VIEWS_SIZE_ON_DISK'] = node.interestingStats.couch_views_actual_disk_size or 0
end
return result
end
local options = {}
options.host = params.host
options.port = params.port
options.auth = auth(params.username, params.password)
options.path = '/pools/nodes'
options.wait_for_end = true
local ds = WebRequestDataSource:new(options)
ds:chain(function (context, callback, data)
local cluster = json.parse(data)
local metrics = standardMetrics(cluster)
plugin:report(metrics)
if params.advanced_metrics then
local data_sources = {}
for i, bucket in ipairs(buckets) do
local node = target
local opts = clone(options)
opts.meta = bucket
opts.path = ('/pools/default/buckets/%s/nodes/%s/stats?zoom=minute'):format(bucket, node)
local child_ds = WebRequestDataSource:new(opts)
child_ds:propagate('error', context)
table.insert(data_sources, child_ds)
pending_requests[bucket] = true
end
return data_sources
end
end)
-- For the standard metrics we look for the node that has the same IP and port as the specified parameters.
-- For the advanced metrics we get a list of buckets and then agregate bucket metrics
local stats_total_tmpl = {
couch_views_fragmentation = 0,
couch_views_fragmentation = 0,
couch_views_ops = 0,
avg_disk_commit_time = 0,
avg_disk_update_time = 0,
cas_hits = 0,
cas_misses = 0,
ep_bg_fetched = 0,
evictions = 0,
misses = 0,
xdc_ops = 0,
replication_changes_left = 0,
major_faults = 0,
minor_faults = 0,
page_faults = 0
}
local stats_total = clone(stats_total_tmpl)
plugin = Plugin:new(params, ds)
function plugin:onParseValues(data, extra)
if not extra.info then
return
end
local parsed = json.parse(data)
for k, v in pairs(stats_total) do
local samples = parsed.op.samples[k] or {}
stats_total[k] = v + tonumber(samples[#samples]) or 0
end
pending_requests[extra.info] = nil
if not hasAny(pending_requests) then
local result = {}
result['COUCHBASE_DOCUMENTS_FRAGMENTATION'] = percentage(stats_total.couch_views_fragmentation)
result['COUCHBASE_VIEWS_FRAGMENTATION'] = percentage(stats_total.couch_views_fragmentation)
result['COUCHBASE_VIEWS_OPERATIONS'] = stats_total.couch_views_ops
result['COUCHBASE_DISK_COMMIT_TIME'] = stats_total.avg_disk_commit_time
result['COUCHBASE_DISK_UPDATE_TIME'] = stats_total.avg_disk_update_time
result['COUCHBASE_CAS_HITS'] = stats_total.cas_hits
result['COUCHBASE_CAS_MISSES'] = stats_total.cas_misses
result['COUCHBASE_DISK_FETCHES'] = stats_total.ep_bg_fetched
result['COUCHBASE_EVICTIONS'] = stats_total.evictions
result['COUCHBASE_MISSES'] = stats_total.misses
result['COUCHBASE_XDCR_OPERATIONS'] = stats_total.xdc_ops
result['COUCHBASE_REPLICATION_CHANGES_LEFT'] = stats_total.replication_changes_left
result['COUCHBASE_MAJOR_FAULTS'] = stats_total.major_faults
result['COUCHBASE_MINOR_FAULTS'] = stats_total.minor_faults
result['COUCHBASE_PAGE_FAULTS'] = stats_total.page_faults
stats_total = clone(stats_total_tmpl)
return result
end
end
local function resolveHost(host)
dns.resolve(host, function (failure, addresses)
if failure then
plugin:emitEvent('critical', ('%s Unresolved'):format(host), host, host, ('Could not resolve the %s'):format(host))
return
end
target = addresses[1] .. ':' .. params.port
plugin:run()
end)
end
local function run()
local opts = clone(options)
opts.path = '/pools/default/buckets'
local buckets_ds = WebRequestDataSource:new(opts)
buckets_ds:propagate('error', plugin)
buckets_ds:fetch(nil, function (data, extra)
if not isHttpSuccess(extra.status_code) then
plugin:emitEvent('error', 'Http Error', params.host, params.host, ('Http status code %s'):format(extra.status_code))
return
end
local parsed = json.parse(data)
for _, bucket in ipairs(parsed) do
table.insert(buckets, bucket.name)
end
resolveHost(params.host)
end)
end
run()
| apache-2.0 |
TheAnswer/FirstTest | bin/scripts/slashcommands/generic/socialInternal.lua | 1 | 2503 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
--true = 1, false = 0
SocialInternalSlashCommand = {
name = "socialinternal",
alternativeNames = "",
animation = "",
invalidStateMask = 3758096448, --feigndeath, pilotingShip, shipOperations, shipGunner,
invalidPostures = "13,14,",
target = 2,
targeType = 0,
disabled = 0,
maxRangeToTarget = 0,
--adminLevel = 0,
addToCombatQueue = 0,
}
AddSocialInternalSlashCommand(SocialInternalSlashCommand)
| lgpl-3.0 |
TheAnswer/FirstTest | bin/scripts/slashcommands/admin/object.lua | 1 | 2421 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
--true = 1, false = 0
ObjectSlashCommand = {
name = "object",
alternativeNames = "",
animation = "",
invalidStateMask = 2097152, --glowingJedi,
invalidPostures = "",
target = 2,
targeType = 0,
disabled = 0,
maxRangeToTarget = 0,
--adminLevel = 0,
addToCombatQueue = 0,
}
AddObjectSlashCommand(ObjectSlashCommand)
| lgpl-3.0 |
miralireza2/xili_bot | plugins/service_entergroup.lua | 355 | 3585 | local add_user_cfg = load_from_file('data/add_user_cfg.lua')
local function template_add_user(base, to_username, from_username, chat_name, chat_id)
base = base or ''
to_username = '@' .. (to_username or '')
from_username = '@' .. (from_username or '')
chat_name = string.gsub(chat_name, '_', ' ') or ''
chat_id = "chat#id" .. (chat_id or '')
if to_username == "@" then
to_username = ''
end
if from_username == "@" then
from_username = ''
end
base = string.gsub(base, "{to_username}", to_username)
base = string.gsub(base, "{from_username}", from_username)
base = string.gsub(base, "{chat_name}", chat_name)
base = string.gsub(base, "{chat_id}", chat_id)
return base
end
function chat_new_user_link(msg)
local pattern = add_user_cfg.initial_chat_msg
local to_username = msg.from.username
local from_username = 'link (@' .. (msg.action.link_issuer.username or '') .. ')'
local chat_name = msg.to.print_name
local chat_id = msg.to.id
pattern = template_add_user(pattern, to_username, from_username, chat_name, chat_id)
if pattern ~= '' then
local receiver = get_receiver(msg)
send_msg(receiver, pattern, ok_cb, false)
end
end
function chat_new_user(msg)
local pattern = add_user_cfg.initial_chat_msg
local to_username = msg.action.user.username
local from_username = msg.from.username
local chat_name = msg.to.print_name
local chat_id = msg.to.id
pattern = template_add_user(pattern, to_username, from_username, chat_name, chat_id)
if pattern ~= '' then
local receiver = get_receiver(msg)
send_msg(receiver, pattern, ok_cb, false)
end
end
local function description_rules(msg, nama)
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
local about = ""
local rules = ""
if data[tostring(msg.to.id)]["description"] then
about = data[tostring(msg.to.id)]["description"]
about = "\nDescription :\n"..about.."\n"
end
if data[tostring(msg.to.id)]["rules"] then
rules = data[tostring(msg.to.id)]["rules"]
rules = "\nRules :\n"..rules.."\n"
end
local sambutan = "You are in group '"..string.gsub(msg.to.print_name, "_", " ").."'\n"
local text = sambutan..about..rules.."\n"
local text = text.."Please welcome "..nama
local receiver = get_receiver(msg)
send_large_msg(receiver, text, ok_cb, false)
end
end
local function run(msg, matches)
if not msg.service then
return "Are you trying to troll me?"
end
--vardump(msg)
if matches[1] == "chat_add_user" then
if not msg.action.user.username then
nama = string.gsub(msg.action.user.print_name, "_", " ")
else
nama = "@"..msg.action.user.username
end
chat_new_user(msg)
description_rules(msg, nama)
elseif matches[1] == "chat_add_user_link" then
if not msg.from.username then
nama = string.gsub(msg.from.print_name, "_", " ")
else
nama = "@"..msg.from.username
end
chat_new_user_link(msg)
description_rules(msg, nama)
elseif matches[1] == "chat_del_user" then
local bye_name = msg.action.user.first_name
return 'Bye '..bye_name..'!'
end
end
return {
description = "Service plugin that sends a custom message when an user enters a chat.",
usage = "Welcoming new member.",
patterns = {
"^!!tgservice (chat_add_user)$",
"^!!tgservice (chat_add_user_link)$",
"^!!tgservice (chat_del_user)$",
},
run = run
}
| gpl-2.0 |
Andrettin/Wyrmsun | scripts/languages/slavic/russian_loanwords.lua | 1 | 1887 | -- _________ __ __
-- / _____// |_____________ _/ |______ ____ __ __ ______
-- \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
-- / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \
-- /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
-- \/ \/ \//_____/ \/
-- ______________________ ______________________
-- T H E W A R B E G I N S
-- Stratagus - A free fantasy real time strategy game engine
--
-- (c) Copyright 2017-2022 by Andrettin
--
-- 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
DefineLanguageWord("Armija", { -- Source: Carl D. Buck, "Words for 'Battle,' 'War,' 'Army,' and 'Soldier'", 1919, p. 14.
Language = "russian",
Type = "noun",
Meanings = {"Army"},
DerivesFrom = {"french", "noun", "Armée"}
})
DefineLanguageWord("Soldat", { -- Source: Carl D. Buck, "Words for 'Battle,' 'War,' 'Army,' and 'Soldier'", 1919, pp. 16-17.
Language = "russian",
Type = "noun",
Meanings = {"Soldier"},
DerivesFrom = {"french", "noun", "Soldat"}
})
| gpl-2.0 |
TheAnswer/FirstTest | bin/scripts/creatures/objects/corellia/creatures/startledVreltMother.lua | 1 | 4750 | --Copyright (C) 2008 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
startledVreltMother = Creature:new {
objectName = "startledVreltMother", -- Lua Object Name
creatureType = "ANIMAL",
gender = "",
speciesName = "startled_vrelt_mother",
stfName = "mob/creature_names",
objectCRC = 2882436158,
socialGroup = "Vreit",
level = 14,
combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG,
healthMax = 1900,
healthMin = 1500,
strength = 0,
constitution = 0,
actionMax = 1900,
actionMin = 1500,
quickness = 0,
stamina = 0,
mindMax = 1900,
mindMin = 1500,
focus = 0,
willpower = 0,
height = 1, -- Size of creature
armor = 0, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy
kinetic = 10,
energy = 10,
electricity = 0,
stun = -1,
blast = 0,
heat = 0,
cold = 0,
acid = 0,
lightsaber = 0,
accuracy = 0,
healer = 0,
pack = 1,
herd = 1,
stalker = 0,
killer = 0,
ferocity = 0,
aggressive = 0,
invincible = 0,
meleeDefense = 1,
rangedDefense = 1,
attackCreatureOnSight = "", -- Enter socialGroups
weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx
weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance'
weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance'
weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon'
weaponEquipped = 0,
weaponMinDamage = 140,
weaponMaxDamage = 150,
weaponAttackSpeed = 2,
weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc
weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY
alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx
alternateWeaponName = "", -- Name ex. 'a Vibrolance'
alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance'
alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon'
alternateWeaponEquipped = 0,
alternateWeaponMinDamage = 0,
alternateWeaponMaxDamage = 0,
alternateWeaponAttackSpeed = 0,
alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc
alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY
internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's
lootGroup = "0", -- Group it belongs to for loot
tame = 0,
datapadItemCRC = 0,
mountCRC = 0,
mountSpeed = 0,
mountAcceleration = 0,
milk = 0,
boneType = "bone_mammal_corellia",
boneMax = 13,
hideType = "hide_bristley_corellia",
hideMax = 13,
meatType = "meat_carnivore_corellia",
meatMax = 13,
--skills = { " Ranged attack (spit)", " Intimidation attack", " Knockdown attack" }
skills = { "vreltAttack3", "vreltAttack5" },
respawnTimer = 60,
behaviorScript = "", -- Link to the behavior script for this object
}
Creatures:addCreature(startledVreltMother, 2882436158) -- Add to Global Table
| lgpl-3.0 |
TheAnswer/FirstTest | bin/scripts/creatures/objects/dathomir/creatures/brackasetFemale.lua | 1 | 4739 | --Copyright (C) 2008 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
brackasetFemale = Creature:new {
objectName = "brackasetFemale", -- Lua Object Name
creatureType = "ANIMAL",
gender = "female",
speciesName = "brackaset_female",
stfName = "mob/creature_names",
objectCRC = 2038129742,
socialGroup = "Brackaset",
level = 29,
combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG,
healthMax = 10100,
healthMin = 8300,
strength = 0,
constitution = 0,
actionMax = 10100,
actionMin = 8300,
quickness = 0,
stamina = 0,
mindMax = 10100,
mindMin = 8300,
focus = 0,
willpower = 0,
height = 1, -- Size of creature
armor = 0, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy
kinetic = 30,
energy = 30,
electricity = -1,
stun = -1,
blast = 20,
heat = 0,
cold = 0,
acid = -1,
lightsaber = 0,
accuracy = 0,
healer = 0,
pack = 1,
herd = 1,
stalker = 0,
killer = 0,
ferocity = 0,
aggressive = 0,
invincible = 0,
meleeDefense = 1,
rangedDefense = 1,
attackCreatureOnSight = "", -- Enter socialGroups
weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx
weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance'
weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance'
weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon'
weaponEquipped = 0,
weaponMinDamage = 260,
weaponMaxDamage = 270,
weaponAttackSpeed = 2,
weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc
weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY
alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx
alternateWeaponName = "", -- Name ex. 'a Vibrolance'
alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance'
alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon'
alternateWeaponEquipped = 0,
alternateWeaponMinDamage = 0,
alternateWeaponMaxDamage = 0,
alternateWeaponAttackSpeed = 0,
alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc
alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY
internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's
lootGroup = "0", -- Group it belongs to for loot
tame = 0.25, -- Likely hood to be tamed
datapadItemCRC = 932343786,
mountCRC = 437036395,
mountSpeed = 15.0,
mountAcceleration = 15.0,
milk = 1,
boneType = "bone_mammal_dathomir",
boneMax = 80,
hideType = "hide_leathery_dathomir",
hideMax = 90,
meatType = "meat_wild_dathomir",
meatMax = 100,
--skills = { " Stun attack", "", "" }
skills = { "brackasetAttack2" },
respawnTimer = 60,
behaviorScript = "", -- Link to the behavior script for this object
}
Creatures:addCreature(brackasetFemale, 437036395) -- Add to Global Table
| lgpl-3.0 |
TheAnswer/FirstTest | bin/scripts/skills/creatureSkills/talus/creatureSkills.lua | 1 | 3000 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
-- Load files
-- Talus
RunSkillsFile("creatureSkills/talus/creatures/decayMiteAttacks.lua")
RunSkillsFile("creatureSkills/talus/creatures/dungMiteAttacks.lua")
RunSkillsFile("creatureSkills/talus/creatures/fliteRaspAttacks.lua")
RunSkillsFile("creatureSkills/talus/creatures/fynockAttacks.lua")
RunSkillsFile("creatureSkills/talus/creatures/gufDrolgAttacks.lua")
RunSkillsFile("creatureSkills/talus/creatures/hufDunAttacks.lua")
RunSkillsFile("creatureSkills/talus/creatures/kahmurraAttacks.lua")
RunSkillsFile("creatureSkills/talus/creatures/kimaAttacks.lua")
RunSkillsFile("creatureSkills/talus/creatures/robaAttacks.lua")
RunSkillsFile("creatureSkills/talus/creatures/rotMiteAttacks.lua")
RunSkillsFile("creatureSkills/talus/creatures/sludgePantherAttacks.lua")
RunSkillsFile("creatureSkills/talus/creatures/torturAttacks.lua")
RunSkillsFile("creatureSkills/talus/creatures/vynockAttacks.lua")
| lgpl-3.0 |
TheAnswer/FirstTest | bin/scripts/object/static/base/objects.lua | 1 | 3907 | --Copyright (C) 2009 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
object_static_base_shared_static_base = SharedStaticObjectTemplate:new {
appearanceFilename = "",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "string_id_table",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "string_id_table",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 0
}
ObjectTemplates:addTemplate(object_static_base_shared_static_base, 1732101595)
object_static_base_shared_static_default = SharedStaticObjectTemplate:new {
appearanceFilename = "",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "string_id_table",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "string_id_table",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 0,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 0
}
ObjectTemplates:addTemplate(object_static_base_shared_static_default, 4025184)
| lgpl-3.0 |
TheAnswer/FirstTest | bin/scripts/creatures/objects/corellia/npcs/hiddenDaggers/hiddenDaggersLieutenant.lua | 1 | 4599 | --Copyright (C) 2008 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
hiddenDaggersLieutenant = Creature:new {
objectName = "hiddenDaggersLieutenant", -- Lua Object Name
creatureType = "NPC",
faction = "hidden_daggers",
factionPoints = 20,
gender = "",
speciesName = "hidden_daggers_lieutenant",
stfName = "mob/creature_names",
objectCRC = 2267502107,
socialGroup = "hidden_daggers",
level = 15,
combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG,
healthMax = 2400,
healthMin = 2000,
strength = 0,
constitution = 0,
actionMax = 2400,
actionMin = 2000,
quickness = 0,
stamina = 0,
mindMax = 2400,
mindMin = 2000,
focus = 0,
willpower = 0,
height = 1, -- Size of creature
armor = 0, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy
kinetic = 0,
energy = 10,
electricity = -1,
stun = -1,
blast = 0,
heat = -1,
cold = -1,
acid = -1,
lightsaber = 0,
accuracy = 0,
healer = 0,
pack = 1,
herd = 0,
stalker = 0,
killer = 1,
ferocity = 0,
aggressive = 0,
invincible = 0,
attackCreatureOnSight = "", -- Enter socialGroups
weapon = "object/weapon/ranged/pistol/shared_pistol_d18.iff", -- File path to weapon -> object\xxx\xxx\xx
weaponName = "D18 Pistol", -- Name ex. 'a Vibrolance'
weaponTemp = "pistol_d18", -- Weapon Template ex. 'lance_vibrolance'
weaponClass = "PistolRangedWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon'
weaponEquipped = 1,
weaponMinDamage = 170,
weaponMaxDamage = 180,
weaponAttackSpeed = 2,
weaponDamageType = "ENERGY", -- ELECTRICITY, KINETIC, etc
weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY
alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx
alternateWeaponName = "", -- Name ex. 'a Vibrolance'
alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance'
alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon'
alternateWeaponEquipped = 0,
alternateWeaponMinDamage = 0,
alternateWeaponMaxDamage = 0,
alternateweaponAttackSpeed = 2,
alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc
alternateweaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY
internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's
lootGroup = "0", -- Group it belongs to for loot
tame = 0,
datapadItemCRC = 0,
mountCRC = 0,
mountSpeed = 0,
mountAcceleration = 0,
milk = 0,
boneType = "",
boneMax = 0,
hideType = "",
hideMax = 0,
meatType = "",
meatMax = 0,
skills = { "hiddenDaggerAttack1" },
respawnTimer = 180,
behaviorScript = "", -- Link to the behavior script for this object
}
Creatures:addCreature(hiddenDaggersLieutenant, 2267502107) -- Add to Global Table
| lgpl-3.0 |
chrisdugne/ludum-dare-36 | src/components/ProgressBar.lua | 1 | 4790 | --------------------------------------------------------------------------------
local ProgressBar = {}
--------------------------------------------------------------------------------
-- DOC desc
-- todo utils.text --> component.Text puis if Text or display.newtText
-- install src.component
-- install assets
function ProgressBar:new(options)
local bar = _.extend({}, options);
setmetatable(bar, { __index = ProgressBar })
return bar;
end
--------------------------------------------------------------------------------
---
-- options :
-- parent
-- x
-- y
-- width
-- height
-- path
--
function ProgressBar:draw( options )
self:prepare ( options )
self:background ( options )
self:progress ( options )
self:icon ( options )
self:text ( options )
end
--------------------------------------------------------------------------------
-- Construction
--------------------------------------------------------------------------------
function ProgressBar:prepare(options)
self.display = display.newGroup()
self.display.x = options.x
self.display.y = options.y
options.parent:insert(self.display)
end
--- greenBG is show when 100%
function ProgressBar:background(options)
self.bg = display.newImage(
self.display,
'assets/images/gui/progress-bar/loading-bg.png'
)
self.bg.width = options.width
self.bg.height = options.height
if(options.disabled) then
self.bg.fill.effect = 'filter.desaturate'
self.bg.fill.effect.intensity = 0.8
end
------------
self.bgGreen = display.newImage(
self.display,
'assets/images/gui/progress-bar/loading-bg-green.png'
)
self.bgGreen.width = options.width
self.bgGreen.height = options.height
self.bgGreen.alpha = 0
end
function ProgressBar:progress(options)
self.progress = display.newImage(
self.display,
'assets/images/gui/progress-bar/loading-progress.png'
)
self.progress.width = self:progressWidth()
self.progress.height = options.height*0.69
self.progress.anchorX = 0
self.progress.x = -options.width/2.06
self.progress:setMask( graphics.newMask(
'assets/images/gui/progress-bar/loading-mask.png'
))
end
function ProgressBar:icon(options)
if(options.path) then
local logoContainer = display.newImage(
self.display,
'assets/images/gui/items/circle.simple.container.png',
-options.width*0.55, 0
)
if(options.disabled) then
logoContainer.fill.effect = 'filter.desaturate'
logoContainer.fill.effect.intensity = 0.8
end
local ratio = (options.height / logoContainer.height) * 1.3
logoContainer:scale(ratio, ratio)
-----------------
Icon:draw(_.defaults({
parent = self.display,
x = -options.width*0.55,
y = 0,
maxSize = logoContainer.height * 0.6
}, options))
end
end
function ProgressBar:text(options)
self.text = display.newText({
parent = self.display,
text = '',
x = 0,
y = 0,
font = FONT,
fontSize = self.progress.height*0.7,
})
end
--------------------------------------------------------------------------------
-- Tools
--------------------------------------------------------------------------------
function ProgressBar:progressWidth()
return self.bg.width*0.97
end
function ProgressBar:showGreenBG()
transition.to(self.bgGreen, {
alpha = 1,
transition = easing.outQuad,
time = 1400
})
end
--------------------------------------------------------------------------------
-- API
--------------------------------------------------------------------------------
function ProgressBar:set(value)
self.text.text = value .. '%'
self.progress.maskX = self:maskX(value)
if(value == 100) then self:showGreenBG() end
end
function ProgressBar:reach(step)
local value, text
if('table' == type(step)) then
value = step.value
text = step.text
else
value = step
text = value .. '%'
end
self.text.text = text
transition.to(self.progress, {
maskX = self:maskX(value),
transition = easing.outQuad,
time = 1400
})
if(value == 100) then self:showGreenBG() end
end
--------------------------------------------------------------------------------
function ProgressBar:maskX(value)
return (value * (self:progressWidth()/100)) - self:progressWidth()/1.835
end
--------------------------------------------------------------------------------
return ProgressBar
| bsd-3-clause |
TheAnswer/FirstTest | bin/scripts/items/objects/clothing/shirts/shirt15.lua | 1 | 2284 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
shirt15 = Clothing:new {
objectName = "Trim Lined Shirt",
templateName = "shirt_s15",
objectCRC = "3575604499",
objectType = SHIRT,
itemMask = HUMANOIDS,
equipped = "0"
} | lgpl-3.0 |
hamode-Aliraq/HAMODE_ALIRAQE | plugins/set_type.lua | 7 | 1026 | --[[
#
#ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ
#:((
# For More Information ....!
# Developer : Aziz < @TH3_GHOST >
# our channel: @DevPointTeam
# Version: 1.1
#:))
#ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ
#
]]
local function run(msg, matches, callback, extra)
local data = load_data(_config.moderation.data)
local group_type = data[tostring(msg.to.id)]['group_type']
if matches[1] and is_sudo(msg) then
data[tostring(msg.to.id)]['group_type'] = matches[1]
save_data(_config.moderation.data, data)
return 'Group Type Seted To : '..matches[1]
end
if not is_owner(msg) then
return 'You Are Not Allow To set Group Type !'
end
end
return {
patterns = {
"^[#!/]type (.*)$",
},
run = run
}
| gpl-2.0 |
fkaa/iceball | pkg/base/lib_util.lua | 3 | 8633 | --[[
This file is part of Ice Lua Components.
Ice Lua Components is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Ice Lua Components is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Ice Lua Components. If not, see <http://www.gnu.org/licenses/>.
]]
if common.argb_split_to_merged then
argb_split_to_merged = common.argb_split_to_merged
else
function argb_split_to_merged(r,g,b,a)
a = a or 0xFF
r = math.min(math.max(0,math.floor(r+0.5)),255)
g = math.min(math.max(0,math.floor(g+0.5)),255)
b = math.min(math.max(0,math.floor(b+0.5)),255)
a = math.min(math.max(0,math.floor(a+0.5)),255)
return 256*(256*(256*a+r)+g)+b
end
end
function abgr_split_to_merged(r,g,b,a)
return argb_split_to_merged(b,g,r,a)
end
if common.argb_merged_to_split then
argb_merged_to_split = common.argb_merged_to_split
else
function argb_merged_to_split(c)
-- yuck
local b = c % (2 ^ 8)
local g = math.floor(c / (2 ^ 8) % (2 ^ 8))
local r = math.floor(c / (2 ^ 16) % (2 ^ 8))
local a = math.floor(c / (2 ^ 24))
if a < 0 then a = 0 end
--print(string.format("%08X %d %d %d %d", c, r, g, b, a))
return a, r, g, b
end
end
function recolor_component(r,g,b,mdata)
for i=1,#mdata do
if mdata[i].r == 0 and mdata[i].g == 0 and mdata[i].b == 0 then
mdata[i].r = r
mdata[i].g = g
mdata[i].b = b
end
end
end
function gen_icon(mspr)
local this = {
ofx = mspr[1],
ofy = mspr[2],
}
do
local i
local lgx, lgy = mspr[1], mspr[2]
for i=3,#mspr,2 do
this.ofx = math.min(this.ofx, mspr[i+0])
this.ofy = math.min(this.ofy, mspr[i+1])
lgx = math.max(lgx, mspr[i+0])
lgy = math.max(lgy, mspr[i+1])
end
this.w = lgx - this.ofx + 1
this.h = lgy - this.ofy + 1
this.img = common.img_new(this.w, this.h)
--print(this.w, this.h, this.ofx, this.ofy)
for i=1,#mspr,2 do
common.img_pixel_set(this.img,
mspr[i+0]-this.ofx,
mspr[i+1]-this.ofy,
0xFFFFFFFF)
end
end
function this.blit(x, y, c, mx, my, x1, y1, x2, y2)
local dx = x + this.ofx - x1
local dy = y + this.ofy - y1
local sx = 0
local sy = 0
local iw = this.w
local ih = this.h
if dx < 0 then
local diff = 0 - dx
dx = 0
sx = sx + diff
iw = iw - diff
end
if dy < 0 then
local diff = 0 - dy
dy = 0
sy = sy + diff
ih = ih - diff
end
if dx + iw >= x2-x1 then
iw = (x2-x1) - dx
end
if dy + ih >= y2-y1 then
ih = (y2-y1) - dy
end
if iw >= 1 and ih >= 1 then
client.img_blit(this.img, dx+mx, dy+my, iw, ih, sx, sy, c)
end
end
return this
end
function string.split(s, sep, plain)
local start = 1
local done = false
local function pass(i, j, ...)
if i then
local seg = s:sub(start, i - 1)
start = j + 1
return seg, ...
else
done = true
return s:sub(start)
end
end
local result = {}
while not done do
if sep == '' then done = true result[#result+1]=s end
result[#result+1]=pass(s:find(sep, start, plain))
end
return result
end
-- trim the character 'sep' from the left hand side of the string
function string.triml(s, sep)
sep = string.byte(sep)
if s == '' then return s end
local pos = 1
while string.byte(s,pos)==sep and #s<=pos do pos = pos + 1 end
return string.sub(s, pos+1)
end
-- trim the character 'sep' from the right hand side of the string
function string.trimr(s, sep)
sep = string.byte(sep)
if s == '' then return s end
local pos = #s
while string.byte(s, pos)==sep and pos>=1 do pos = pos - 1 end
return string.sub(s, 1, pos)
end
-- trim the character 'sep' from both sides of the string
function string.trim(s, sep)
return string.triml(string.trimr(s, sep), sep)
end
function parse_commandline_options(options, nocheckdash, na, nb, nc)
local loose = na or {} -- loose strings, filenames, etc.
local user_toggles = nb or {} -- toggle options (key is name, value is position)
local user_settings = nc or {} -- key-value pairs
for k, v in pairs(options) do
if nocheckdash then
v = "-" .. v
end
local setting_pair = string.split(v, "=")
local first = string.byte(v,1)
if first==string.byte('-') then -- we are toggling an option or setting a value
if #setting_pair == 2 then -- we are setting a key to a value
user_settings[string.triml(setting_pair[1], '-')]=setting_pair[2]
print(string.triml(setting_pair[1], '-'),"trimmed")
else
user_toggles[string.triml(v, '-')]=k
end
elseif first == string.byte('/') then -- optional extra arg on URI
-- look for a ? thing
local npair = string.split(v:sub(2), "?")
if npair[1] ~= "" then
user_settings[" "] = npair[1]
end
if npair[2] then
-- TODO: URI-decode
local nopts = string.split(npair[2], "&")
parse_commandline_options(nopts, true, loose, user_toggles, user_settings)
end
else -- add to the loose values
loose[#loose+1] = v
end
end
return loose, user_toggles, user_settings
end
--[[Create an alarm object. When run, counts down to the specified value
based on the time delta passed in.
time: The time limit of the alarm. Ignored with values less than 1.
progress: the progress towards the time limit.
active: Whether alarm is running or not.
on_frame: Callback run every frame, passed in the dT of that frame.
on_trigger: Callback run when alarm reaches its limit, passed in the dT of that frame.
loop: Whether the alarm will continue after the first run.
preserve_accumulator: Whether looping transfers overflow dT from the previous run
]]
function alarm(options)
local this = {}
this.time = options.time or 1
this.progress = options.progress or 0
if options.active ~= nil then this.active = options.active else this.active = true end
this.loop = options.loop or false
this.preserve_accumulator = options.preserve_accumulator
if this.preserve_accumulator == nil then this.preserve_accumulator = true end
this.on_frame = options.on_frame or nil
this.on_trigger = options.on_trigger or nil
function this.tick(dT)
if this.active then
this.progress = this.progress + dT
if this.on_frame ~= nil then this.on_frame(dT) end
while this.progress >= this.time and this.active do
if this.on_trigger ~= nil then this.on_trigger(dT) end
if this.loop and this.time > 0 then
if this.preserve_accumulator then
this.progress = this.progress - this.time
else
this.progress = 0
end
else
this.active = false
end
end
end
end
function this.restart()
this.progress = 0
this.active = true
end
function this.time_remaining()
return this.time - this.progress
end
return this
end
-- Rescale an "aval" between "amin" and "amax" to values between "bmin" and "bmax".
function rescale_value(amin, amax, bmin, bmax, aval)
local adist = amax - amin;
local bdist = bmax - bmin;
local ratio = bdist / adist;
return bmin + (aval - amin) * ratio;
end
-- Creates a shallow copy of a table
function copy_table(orig)
local orig_type = type(orig)
local copy
if orig_type == 'table' then
copy = {}
for orig_key, orig_value in pairs(orig) do
copy[orig_key] = orig_value
end
else -- number, string, boolean, etc
copy = orig
end
return copy
end
-- GUI Events
-- DELTA_TIME:
-- uses the delta time passed in when listeners are pumped.
-- callback passes in the dT value.
GE_DELTA_TIME = 1
-- SHARED_ALARM:
-- uses the scene's shared alarm, which is run at a fixed interval (default "1/60").
-- callback passes in the dT value of the shared alarm timer.
GE_SHARED_ALARM = 2
-- KEY:
-- User pressed or released a key.
-- callback passes in {key(int), state(bool), modif(int bitmask)}
GE_KEY = 3
-- TEXT:
-- User submitted text to the OS by pressing key(s).
-- callback passes in {text(string)}
GE_TEXT = 4
-- BUTTON:
-- User pressed or released a mapped button.
-- callback passes in {key(int), button{name(string), desc(string)}, state(bool), modif(int bitmask)}
GE_BUTTON = 5
-- MOUSE:
-- Mouse movement: x, y, dx, dy.
-- callback passes in {x(number), y(number), dx(number), dy(number)}
GE_MOUSE = 6
-- MOUSE_BUTTON:
-- Mouse button is pressed or released.
-- callback passes in {button(int), down(bool)}
GE_MOUSE_BUTTON = 7
| gpl-3.0 |
Andrettin/Wyrmsun | scripts/languages/germanic/old_flemish.lua | 1 | 1631 | -- _________ __ __
-- / _____// |_____________ _/ |______ ____ __ __ ______
-- \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
-- / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \
-- /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
-- \/ \/ \//_____/ \/
-- ______________________ ______________________
-- T H E W A R B E G I N S
-- Stratagus - A free fantasy real time strategy game engine
--
-- (c) Copyright 2016-2022 by Andrettin
--
-- 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
DefineLanguageWord("Hameyde", { -- Source: http://www.cnrtl.fr/definition/Amad%E9
Language = "old-flemish",
Type = "noun",
Meanings = {},
DerivesFrom = {"old-frankish", "noun", "Haimithi"} -- presumably
})
| gpl-2.0 |
nullifye/tg-bot-pi | tg_bot/plugins/9gag.lua | 1 | 2035 | return function(msg)
cmd = "pi:9gag"
if command(msg,cmd) then
local found = false
while not found do
rand = math.random(1,1047007)
found = http_code("http://m.9gag.com/gag/"..rand, "200")
end
if found then
curr_time = os.time()
try = os.execute('wget -qO- --load-cookies "'..HOME..'/cookies/9gag.cookie" http://m.9gag.com/gag/'..rand..' | sed -n \'/<div class="badge-entry-content">/,/<\\/div>/p\' > '..TMP_PATH..'/9gag'..curr_time..'.out')
if try then
gettitle = exec('cat '..TMP_PATH..'/9gag'..curr_time..'.out | sed -n \'s/.*alt="\\([^"]*\\).*/\\1/p\'')
gettitle = string.gsub(gettitle, "'", "'")
gettitle = string.gsub(gettitle, """, "\"")
gettitle = string.gsub(gettitle, "&", "&")
send_msg (target, ""..gettitle, ok_cb, false)
imglink = exec('cat '..TMP_PATH..'/9gag'..curr_time..'.out | sed -n \'s/.*data-image="\\([^"]*\\).*/\\1/p\'') -- gif
imglink2 = exec('cat '..TMP_PATH..'/9gag'..curr_time..'.out | sed -n \'s/.*src="\\([^"]*\\).*/\\1/p\'') -- jpg
YT = string.find(imglink2, "youtube.com/embed/", nil, true) ~= nil -- youtube
if YT then
send_msg (target, "("..cmd..") the post is a video embedded from YouTube\n"..imglink2, ok_cb, false)
return true
end
if imglink == "" then
imglink = imglink2
imglink = string.gsub(imglink, "_460s", "_700b") -- change .jpg size
else
send_msg (target, "("..cmd..") GIF uploading...", ok_cb, false)
end
imglink = string.gsub(imglink, "\n", "") -- trim newline
path,lnk,ext = string.match(imglink, "(.-)([^\\]-([^%.]+))$") -- get file extention
getimg = os.execute('curl "'..imglink..'" -so '..TMP_PATH..'/9gag_'..rand..'.'..ext)
if getimg then
send_document (target, TMP_PATH..'/9gag_'..rand..'.'..ext, ok_cb, false)
end
end
end
return true
end
end
| apache-2.0 |
TheAnswer/FirstTest | bin/scripts/creatures/objects/corellia/npcs/meatlump/meatlumpOaf.lua | 1 | 4525 | --Copyright (C) 2008 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
meatlumpOaf = Creature:new {
objectName = "meatlumpOaf", -- Lua Object Name
creatureType = "NPC",
faction = "meatlump",
factionPoints = 20,
gender = "",
speciesName = "meatlump_oaf",
stfName = "mob/creature_names",
objectCRC = 1527998977,
socialGroup = "meatlump",
level = 9,
combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG,
healthMax = 825,
healthMin = 675,
strength = 0,
constitution = 0,
actionMax = 825,
actionMin = 675,
quickness = 0,
stamina = 0,
mindMax = 825,
mindMin = 675,
focus = 0,
willpower = 0,
height = 1, -- Size of creature
armor = 0, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy
kinetic = 0,
energy = 0,
electricity = 0,
stun = -1,
blast = 0,
heat = 0,
cold = 0,
acid = 0,
lightsaber = 0,
accuracy = 0,
healer = 0,
pack = 1,
herd = 0,
stalker = 0,
killer = 0,
ferocity = 0,
aggressive = 0,
invincible = 0,
attackCreatureOnSight = "", -- Enter socialGroups
weapon = "object/weapon/ranged/pistol/shared_pistol_de_10.iff", -- File path to weapon -> object\xxx\xxx\xx
weaponName = "DE10 Pistol", -- Name ex. 'a Vibrolance'
weaponTemp = "pistol_de_10", -- Weapon Template ex. 'lance_vibrolance'
weaponClass = "PistolRangedWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon'
weaponEquipped = 1,
weaponMinDamage = 80,
weaponMaxDamage = 90,
weaponAttackSpeed = 2,
weaponDamageType = "ENERGY", -- ELECTRICITY, KINETIC, etc
weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY
alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx
alternateWeaponName = "", -- Name ex. 'a Vibrolance'
alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance'
alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon'
alternateWeaponEquipped = 0,
alternateWeaponMinDamage = 0,
alternateWeaponMaxDamage = 0,
alternateweaponAttackSpeed = 2,
alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc
alternateweaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY
internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's
lootGroup = "0", -- Group it belongs to for loot
tame = 0,
datapadItemCRC = 0,
mountCRC = 0,
mountSpeed = 0,
mountAcceleration = 0,
milk = 0,
boneType = "",
boneMax = 0,
hideType = "",
hideMax = 0,
meatType = "",
meatMax = 0,
skills = { "meatlumpAttack1" },
respawnTimer = 180,
behaviorScript = "", -- Link to the behavior script for this object
}
Creatures:addCreature(meatlumpOaf, 1527998977) -- Add to Global Table
| lgpl-3.0 |
REZATITAN/XY | bot/utils.lua | 15 | 14995 | URL = require "socket.url"
http = require "socket.http"
https = require "ssl.https"
ltn12 = require "ltn12"
serpent = require "serpent"
feedparser = require "feedparser"
json = (loadfile "./libs/JSON.lua")()
mimetype = (loadfile "./libs/mimetype.lua")()
redis = (loadfile "./libs/redis.lua")()
JSON = (loadfile "./libs/dkjson.lua")()
http.TIMEOUT = 10
function get_receiver(msg)
if msg.to.type == 'user' then
return 'user#id'..msg.from.id
end
if msg.to.type == 'chat' then
return 'chat#id'..msg.to.id
end
if msg.to.type == 'encr_chat' then
return msg.to.print_name
end
end
function is_chat_msg( msg )
if msg.to.type == 'chat' then
return true
end
return false
end
function string.random(length)
local str = "";
for i = 1, length do
math.random(97, 122)
str = str..string.char(math.random(97, 122));
end
return str;
end
function string:split(sep)
local sep, fields = sep or ":", {}
local pattern = string.format("([^%s]+)", sep)
self:gsub(pattern, function(c) fields[#fields+1] = c end)
return fields
end
-- DEPRECATED
function string.trim(s)
print("string.trim(s) is DEPRECATED use string:trim() instead")
return s:gsub("^%s*(.-)%s*$", "%1")
end
-- Removes spaces
function string:trim()
return self:gsub("^%s*(.-)%s*$", "%1")
end
function get_http_file_name(url, headers)
-- Eg: foo.var
local file_name = url:match("[^%w]+([%.%w]+)$")
-- Any delimited alphanumeric on the url
file_name = file_name or url:match("[^%w]+(%w+)[^%w]+$")
-- Random name, hope content-type works
file_name = file_name or str:random(5)
local content_type = headers["content-type"]
local extension = nil
if content_type then
extension = mimetype.get_mime_extension(content_type)
end
if extension then
file_name = file_name.."."..extension
end
local disposition = headers["content-disposition"]
if disposition then
-- attachment; filename=CodeCogsEqn.png
file_name = disposition:match('filename=([^;]+)') or file_name
end
return file_name
end
-- Saves file to /tmp/. If file_name isn't provided,
-- will get the text after the last "/" for filename
-- and content-type for extension
function download_to_file(url, file_name)
print("url to download: "..url)
local respbody = {}
local options = {
url = url,
sink = ltn12.sink.table(respbody),
redirect = true
}
-- nil, code, headers, status
local response = nil
if url:starts('https') then
options.redirect = false
response = {https.request(options)}
else
response = {http.request(options)}
end
local code = response[2]
local headers = response[3]
local status = response[4]
if code ~= 200 then return nil end
file_name = file_name or get_http_file_name(url, headers)
local file_path = "/tmp/"..file_name
print("Saved to: "..file_path)
file = io.open(file_path, "w+")
file:write(table.concat(respbody))
file:close()
return file_path
end
function vardump(value)
print(serpent.block(value, {comment=false}))
end
-- taken from http://stackoverflow.com/a/11130774/3163199
function scandir(directory)
local i, t, popen = 0, {}, io.popen
for filename in popen('ls -a "'..directory..'"'):lines() do
i = i + 1
t[i] = filename
end
return t
end
-- http://www.lua.org/manual/5.2/manual.html#pdf-io.popen
function run_command(str)
local cmd = io.popen(str)
local result = cmd:read('*all')
cmd:close()
return result
end
-- User has privileges
function is_sudo(msg)
local var = false
-- Check users id in config
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
-- user has admins privileges
function is_admin(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
local admins = 'admins'
if data[tostring(admins)] then
if data[tostring(admins)][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
-- user has moderator privileges
function is_mod(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['moderators'] then
if data[tostring(msg.to.id)]['moderators'][tostring(user)] then
var = true
end
end
end
if data['admins'] then
if data['admins'][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
function is_banned(user_id, chat_id)
return redis:get('banned:'..chat_id..':'..user_id) or false
end
function is_super_banned(user_id)
return redis:get('superbanned:'..user_id) or false
end
-- Returns the name of the sender
function get_name(msg)
local name = msg.from.first_name
if name == nil then
name = msg.from.id
end
return name
end
-- Returns at table of lua files inside plugins
function plugins_names( )
local files = {}
for k, v in pairs(scandir("plugins")) do
-- Ends with .lua
if (v:match(".lua$")) then
table.insert(files, v)
end
end
return files
end
-- Function name explains what it does.
function file_exists(name)
local f = io.open(name,"r")
if f ~= nil then
io.close(f)
return true
else
return false
end
end
-- Save into file the data serialized for lua.
-- Set uglify true to minify the file.
function serialize_to_file(data, file, uglify)
file = io.open(file, 'w+')
local serialized
if not uglify then
serialized = serpent.block(data, {
comment = false,
name = '_'
})
else
serialized = serpent.dump(data)
end
file:write(serialized)
file:close()
end
-- Returns true if the string is empty
function string:isempty()
return self == nil or self == ''
end
-- Returns true if the string is blank
function string:isblank()
self = self:trim()
return self:isempty()
end
-- DEPRECATED!!!!!
function string.starts(String, Start)
print("string.starts(String, Start) is DEPRECATED use string:starts(text) instead")
return Start == string.sub(String,1,string.len(Start))
end
-- Returns true if String starts with Start
function string:starts(text)
return text == string.sub(self,1,string.len(text))
end
-- Send image to user and delete it when finished.
-- cb_function and cb_extra are optionals callback
function _send_photo(receiver, file_path, cb_function, cb_extra)
local cb_extra = {
file_path = file_path,
cb_function = cb_function,
cb_extra = cb_extra
}
-- Call to remove with optional callback
send_photo(receiver, file_path, cb_function, cb_extra)
end
-- Download the image and send to receiver, it will be deleted.
-- cb_function and cb_extra are optionals callback
function send_photo_from_url(receiver, url, cb_function, cb_extra)
-- If callback not provided
cb_function = cb_function or ok_cb
cb_extra = cb_extra or false
local file_path = download_to_file(url, false)
if not file_path then -- Error
local text = 'Error downloading the image'
send_msg(receiver, text, cb_function, cb_extra)
else
print("File path: "..file_path)
_send_photo(receiver, file_path, cb_function, cb_extra)
end
end
-- Same as send_photo_from_url but as callback function
function send_photo_from_url_callback(cb_extra, success, result)
local receiver = cb_extra.receiver
local url = cb_extra.url
local file_path = download_to_file(url, false)
if not file_path then -- Error
local text = 'Error downloading the image'
send_msg(receiver, text, ok_cb, false)
else
print("File path: "..file_path)
_send_photo(receiver, file_path, ok_cb, false)
end
end
-- Send multiple images asynchronous.
-- param urls must be a table.
function send_photos_from_url(receiver, urls)
local cb_extra = {
receiver = receiver,
urls = urls,
remove_path = nil
}
send_photos_from_url_callback(cb_extra)
end
-- Use send_photos_from_url.
-- This function might be difficult to understand.
function send_photos_from_url_callback(cb_extra, success, result)
-- cb_extra is a table containing receiver, urls and remove_path
local receiver = cb_extra.receiver
local urls = cb_extra.urls
local remove_path = cb_extra.remove_path
-- The previously image to remove
if remove_path ~= nil then
os.remove(remove_path)
print("Deleted: "..remove_path)
end
-- Nil or empty, exit case (no more urls)
if urls == nil or #urls == 0 then
return false
end
-- Take the head and remove from urls table
local head = table.remove(urls, 1)
local file_path = download_to_file(head, false)
local cb_extra = {
receiver = receiver,
urls = urls,
remove_path = file_path
}
-- Send first and postpone the others as callback
send_photo(receiver, file_path, send_photos_from_url_callback, cb_extra)
end
-- Callback to remove a file
function rmtmp_cb(cb_extra, success, result)
local file_path = cb_extra.file_path
local cb_function = cb_extra.cb_function or ok_cb
local cb_extra = cb_extra.cb_extra
if file_path ~= nil then
os.remove(file_path)
print("Deleted: "..file_path)
end
-- Finally call the callback
cb_function(cb_extra, success, result)
end
-- Send document to user and delete it when finished.
-- cb_function and cb_extra are optionals callback
function _send_document(receiver, file_path, cb_function, cb_extra)
local cb_extra = {
file_path = file_path,
cb_function = cb_function or ok_cb,
cb_extra = cb_extra or false
}
-- Call to remove with optional callback
send_document(receiver, file_path, rmtmp_cb, cb_extra)
end
-- Download the image and send to receiver, it will be deleted.
-- cb_function and cb_extra are optionals callback
function send_document_from_url(receiver, url, cb_function, cb_extra)
local file_path = download_to_file(url, false)
print("File path: "..file_path)
_send_document(receiver, file_path, cb_function, cb_extra)
end
-- Parameters in ?a=1&b=2 style
function format_http_params(params, is_get)
local str = ''
-- If is get add ? to the beginning
if is_get then str = '?' end
local first = true -- Frist param
for k,v in pairs (params) do
if v then -- nil value
if first then
first = false
str = str..k.. "="..v
else
str = str.."&"..k.. "="..v
end
end
end
return str
end
-- Check if user can use the plugin and warns user
-- Returns true if user was warned and false if not warned (is allowed)
function warns_user_not_allowed(plugin, msg)
if not user_allowed(plugin, msg) then
local text = '' --'This plugin requires privileged user.'
local receiver = get_receiver(msg)
send_msg(receiver, text, ok_cb, false)
return true
else
return false
end
end
-- Check if user can use the plugin
function user_allowed(plugin, msg)
-- If plugins moderated = true
if plugin.moderated and not is_mod(msg) then -- Check if user is a mod
if plugin.moderated and not is_admin(msg) then -- Check if user is an admin
if plugin.moderated and not is_sudo(msg) then -- Check if user is a sudoer
return false
end
end
end
-- If plugins privileged = true
if plugin.privileged and not is_sudo(msg) then
return false
end
return true
end
function send_order_msg(destination, msgs)
local cb_extra = {
destination = destination,
msgs = msgs
}
send_order_msg_callback(cb_extra, true)
end
function send_order_msg_callback(cb_extra, success, result)
local destination = cb_extra.destination
local msgs = cb_extra.msgs
local file_path = cb_extra.file_path
if file_path ~= nil then
os.remove(file_path)
print("Deleted: " .. file_path)
end
if type(msgs) == 'string' then
send_large_msg(destination, msgs)
elseif type(msgs) ~= 'table' then
return
end
if #msgs < 1 then
return
end
local msg = table.remove(msgs, 1)
local new_cb_extra = {
destination = destination,
msgs = msgs
}
if type(msg) == 'string' then
send_msg(destination, msg, send_order_msg_callback, new_cb_extra)
elseif type(msg) == 'table' then
local typ = msg[1]
local nmsg = msg[2]
new_cb_extra.file_path = nmsg
if typ == 'document' then
send_document(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'image' or typ == 'photo' then
send_photo(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'audio' then
send_audio(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'video' then
send_video(destination, nmsg, send_order_msg_callback, new_cb_extra)
else
send_file(destination, nmsg, send_order_msg_callback, new_cb_extra)
end
end
end
-- Same as send_large_msg_callback but friendly params
function send_large_msg(destination, text)
local cb_extra = {
destination = destination,
text = text
}
send_large_msg_callback(cb_extra, true)
end
-- If text is longer than 4096 chars, send multiple msg.
-- https://core.telegram.org/method/messages.sendMessage
function send_large_msg_callback(cb_extra, success, result)
local text_max = 4096
local destination = cb_extra.destination
local text = cb_extra.text
local text_len = string.len(text)
local num_msg = math.ceil(text_len / text_max)
if num_msg <= 1 then
send_msg(destination, text, ok_cb, false)
else
local my_text = string.sub(text, 1, 4096)
local rest = string.sub(text, 4096, text_len)
local cb_extra = {
destination = destination,
text = rest
}
send_msg(destination, my_text, send_large_msg_callback, cb_extra)
end
end
-- Returns a table with matches or nil
function match_pattern(pattern, text, lower_case)
if text then
local matches = {}
if lower_case then
matches = { string.match(text:lower(), pattern) }
else
matches = { string.match(text, pattern) }
end
if next(matches) then
return matches
end
end
-- nil
end
-- Function to read data from files
function load_from_file(file, default_data)
local f = io.open(file, "r+")
-- If file doesn't exists
if f == nil then
-- Create a new empty table
default_data = default_data or {}
serialize_to_file(default_data, file)
print ('Created file', file)
else
print ('Data loaded from file', file)
f:close()
end
return loadfile (file)()
end
-- See http://stackoverflow.com/a/14899740
function unescape_html(str)
local map = {
["lt"] = "<",
["gt"] = ">",
["amp"] = "&",
["quot"] = '"',
["apos"] = "'"
}
new = string.gsub(str, '(&(#?x?)([%d%a]+);)', function(orig, n, s)
var = map[s] or n == "#" and string.char(s)
var = var or n == "#x" and string.char(tonumber(s,16))
var = var or orig
return var
end)
return new
end
| gpl-2.0 |
TheAnswer/FirstTest | bin/scripts/creatures/objects/yavin4/creatures/giantGackleBat.lua | 1 | 4737 | --Copyright (C) 2008 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
giantGackleBat = Creature:new {
objectName = "giantGackleBat", -- Lua Object Name
creatureType = "ANIMAL",
gender = "",
speciesName = "giant_gackle_bat",
stfName = "mob/creature_names",
objectCRC = 3301424523,
socialGroup = "Gacklebat",
level = 24,
combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG + AGGRESSIVE_FLAG,
healthMax = 8300,
healthMin = 6800,
strength = 0,
constitution = 0,
actionMax = 8300,
actionMin = 6800,
quickness = 0,
stamina = 0,
mindMax = 8300,
mindMin = 6800,
focus = 0,
willpower = 0,
height = 1, -- Size of creature
armor = 0, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy
kinetic = 15,
energy = 20,
electricity = -1,
stun = -1,
blast = -1,
heat = 25,
cold = -1,
acid = -1,
lightsaber = 0,
accuracy = 0,
healer = 0,
pack = 1,
herd = 0,
stalker = 0,
killer = 0,
ferocity = 0,
aggressive = 1,
invincible = 0,
meleeDefense = 1,
rangedDefense = 1,
attackCreatureOnSight = "", -- Enter socialGroups
weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx
weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance'
weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance'
weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon'
weaponEquipped = 0,
weaponMinDamage = 230,
weaponMaxDamage = 240,
weaponAttackSpeed = 2,
weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc
weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY
alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx
alternateWeaponName = "", -- Name ex. 'a Vibrolance'
alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance'
alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon'
alternateweaponEquipped = 0,
alternateWeaponMinDamage = 0,
alternateWeaponMaxDamage = 0,
alternateWeaponAttackSpeed = 0,
alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc
alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY
internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's
lootGroup = "0", -- Group it belongs to for loot
tame = 0.25, -- Likely hood to be tamed
datapadItemCRC = 184038036,
mountCRC = 0,
mountSpeed = 0,
mountAcceleration = 0,
milk = 0,
boneType = "bone_mammal_yavin4",
boneMax = 6,
hideType = "hide_bristley_yavin4",
hideMax = 5,
meatType = "meat_carnivore_yavin4",
meatMax = 7,
--skills = { " Intimidation attack", "", "" }
skills = { "gackleBatAttack2" },
respawnTimer = 60,
behaviorScript = "", -- Link to the behavior script for this object
}
Creatures:addCreature(giantGackleBat, 3301424523) -- Add to Global Table
| lgpl-3.0 |
JarnoVgr/ZombieSurvival | gamemodes/zombiesurvival/gamemode/sh_colors.lua | 1 | 1253 | COLOR_GRAY = Color(190, 190, 190)
COLOR_RED = Color(120, 0, 0)
COLOR_BLUE = Color(0, 0, 255)
COLOR_GREEN = Color(0, 255, 0)
COLOR_LIMEGREEN = Color(50, 255, 50)
COLOR_YELLOW = Color(255, 255, 0)
COLOR_CYAN = Color(0, 255, 255)
COLOR_WHITE = Color(255, 255, 255)
COLOR_PURPLE = Color(255, 0, 255)
COLOR_DARKGRAY = Color(40, 40, 40)
COLOR_DARKRED = Color(185, 0, 0)
COLOR_DARKGREEN = Color(0, 150, 0)
COLOR_DARKBLUE = Color(5, 75, 150)
COLOR_FRIENDLY = COLOR_DARKGREEN
COLOR_HEALTHY = COLOR_DARKGREEN
COLOR_SCRATCHED = Color(80, 210, 0)
COLOR_HURT = Color(150, 50, 0)
COLOR_CRITICAL = COLOR_DARKRED
color_black_alpha220 = Color(0, 0, 0, 180)
color_black_alpha200 = Color(0, 0, 0, 180)
color_black_alpha180 = Color(0, 0, 0, 180)
color_black_alpha120 = Color(0, 0, 0, 120)
color_black_alpha90 = Color(0, 0, 0, 90)
color_white_alpha220 = Color(255, 255, 255, 200)
color_white_alpha200 = Color(255, 255, 255, 200)
color_white_alpha180 = Color(255, 255, 255, 180)
color_white_alpha120 = Color(255, 255, 255, 120)
color_white_alpha90 = Color(255, 255, 255, 90)
function util.ColorCopy(source, dest, copyalpha)
dest.r = source.r
dest.g = source.g
dest.b = source.b
if copyalpha then
dest.a = source.a
end
end
| gpl-2.0 |
TheAnswer/FirstTest | bin/scripts/slashcommands/crafting/restartCraftingSession.lua | 1 | 2722 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
--true = 1, false = 0
RestartCraftingSessionSlashCommand = {
name = "restartcraftingsession",
alternativeNames = "",
animation = "",
invalidStateMask = 70778859, --cover, combat, aiming, berzerk, feigndeath, combatAttitudeEvasive, combatAttitudeNormal, combatAttitudeAggressive, tumbling, rallied, stunned, blinded, dizzy, intimidated, immobilized, frozen, swimming, crafting, glowingJedi, onFire,
invalidPostures = "3,6,12,13,14,4,",
target = 2,
targeType = 0,
disabled = 0,
maxRangeToTarget = 0,
--adminLevel = 0,
addToCombatQueue = 0,
}
AddRestartCraftingSessionSlashCommand(RestartCraftingSessionSlashCommand)
| lgpl-3.0 |
xboot/xboot | examples/graphics/vision/main.lua | 1 | 1730 | local function onMouseDown(self, e)
if self:hitTestPoint(e.x, e.y) then
self.touchid = -1
self.x0 = e.x
self.y0 = e.y
e.stop = true
end
end
local function onMouseMove(self, e)
if self.touchid == -1 then
local dx = e.x - self.x0
local dy = e.y - self.y0
self:setX(self:getX() + dx)
self:setY(self:getY() + dy)
self.x0 = e.x
self.y0 = e.y
e.stop = true
end
end
local function onMouseUp(self, e)
if self.touchid == -1 then
self.touchid = nil
e.stop = true
end
end
local function onTouchBegin(self, e)
if self:hitTestPoint(e.x, e.y) then
self.touchid = e.id
self.x0 = e.x
self.y0 = e.y
e.stop = true
end
end
local function onTouchMove(self, e)
if self.touchid == e.id then
local dx = e.x - self.x0
local dy = e.y - self.y0
self:setX(self:getX() + dx)
self:setY(self:getY() + dy)
self.x0 = e.x
self.y0 = e.y
e.stop = true
end
end
local function onTouchEnd(self, e)
if self.touchid == e.id then
self.touchid = nil
e.stop = true
end
end
local sw, sh = stage:getSize()
stage:addChild(DisplayImage.new(Image.new("assets/images/bg.png"):extend(sw, sh, "repeat")))
local lena = Image.new("assets/images/lena.png")
local v = Vision.new(lena)
v:convert("hsv")
local img = DisplayImage.new(Image.new(v))
:setPosition(math.random(0, sw - 64), math.random(0, sh - 64))
:setAnchor(0.5, 0.5)
img:addEventListener("mouse-down", onMouseDown)
img:addEventListener("mouse-move", onMouseMove)
img:addEventListener("mouse-up", onMouseUp)
img:addEventListener("touch-begin", onTouchBegin)
img:addEventListener("touch-move", onTouchMove)
img:addEventListener("touch-end", onTouchEnd)
stage:addChild(img)
| mit |
TheAnswer/FirstTest | bin/scripts/creatures/objects/npcs/missionNpcs/missionRsfPalaceGuard.lua | 1 | 4767 | --Copyright (C) 2008 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
missionRsfPalaceGuard = Creature:new {
objectName = "missionRsfPalaceGuard", -- Lua Object Name
creatureType = "NPC",
faction = "RSF",
gender = "",
name = "RSF Palace guard",
objectCRC = 2038367918,
socialGroup = "RSF",
named = FALSE,
level = 15,
xp = 960,
combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG,
healthMax = 3000,
healthMin = 2400,
strength = 0,
constitution = 0,
actionMax = 3000,
actionMin = 2400,
quickness = 0,
stamina = 0,
mindMax = 3000,
mindMin = 2400,
focus = 0,
willpower = 0,
height = 1, -- Size of creature
armor = 1, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy
kinetic = 0,
energy = 0,
electricity = 0,
stun = -1,
blast = 0,
heat = 0,
cold = 0,
acid = 0,
lightsaber = 0,
accuracy = 0,
healer = 0,
pack = 1,
herd = 0,
stalker = 0,
killer = 1,
aggressive = 0,
invincible = 0,
attackCreatureOnSight = "", -- Enter socialGroups
weapon = "", -- File path to weapon -> object\xxx\xxx\xx
weaponName = "", -- Name ex. 'a Vibrolance'
weaponTemp = "", -- Weapon Template ex. 'lance_vibrolance'
weaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon'
weaponEquipped = 0,
weaponMinDamage = 0,
weaponMaxDamage = 0,
weaponAttackSpeed = 0,
weaponDamageType = "", -- ELECTRICITY, KINETIC, etc
weaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY
alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx
alternateWeaponName = "", -- Name ex. 'a Vibrolance'
alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance'
alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon'
alternateWeaponEquipped = 0,
alternateWeaponMinDamage = 0,
alternateWeaponMaxDamage = 0,
alternateWeaponAttackSpeed = 0,
alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc
alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY
internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's
lootGroup = 0, -- Group it belongs to for loot
tame = 0,
datapadItemCRC = 0,
mountCRC = 0,
mountSpeed = 0,
mountAcceleration = 0,
milk = 0,
boneType = "",
boneMax = 0,
hideType = "",
hideMax = 0,
meatType = "",
meatMax = 0,
skills = { "", "", "" }
-- respawnTimer = 180,
behaviorScript = "", -- Link to the behavior script for this object
}
Creatures:addCreature(missionRsfPalaceGuard, 2038367918) -- Add to Global Table
| lgpl-3.0 |
adriancole/finagle | finagle-mux/src/main/lua/mux_dissector.lua | 1 | 15253 | ----------------------------------------
--
-- A wireshark dissector for Mux.
--
-- See README.md for instructions.
--
-- Disclaimers:
-- This is based on Wireshark's example Lua dissector for DNS.
-- There are almost certainly horrible things afoot here
-- as I cobbled it together without knowing either Lua or Wireshark dissectors.
--
-- There is an example pcap file in finagle-mux/src/test/resources/end-to-end.pcap
-- created by capturing the output of finagle-thriftmux's EndToEndTest.
--
local debug_level = {
DISABLED = 0,
LEVEL_1 = 1,
LEVEL_2 = 2
}
-- set this DEBUG to debug_level.LEVEL_1 to enable printing debug_level info
-- set it to debug_level.LEVEL_2 to enable really verbose printing
-- note: this will be overridden by user's preference settings
local DEBUG = debug_level.LEVEL_1
local default_settings =
{
debug_level = DEBUG,
port = 9990,
heur_enabled = true
}
local dprint = function() end
local dprint2 = function() end
local function resetDebugLevel()
if default_settings.debug_level > debug_level.DISABLED then
dprint = function(...)
info(table.concat({"Lua: ", ...}," "))
end
if default_settings.debug_level > debug_level.LEVEL_1 then
dprint2 = dprint
end
else
dprint = function() end
dprint2 = dprint
end
end
resetDebugLevel()
dprint2("Wireshark version = ".. get_version())
dprint2("Lua version = ".. _VERSION)
----------------------------------------
-- Unfortunately, the older Wireshark/Tshark versions have bugs, and part of the point
-- of this script is to test those bugs are now fixed. So we need to check the version
-- end error out if it's too old.
local major, minor, micro = get_version():match("(%d+)%.(%d+)%.(%d+)")
if major and tonumber(major) <= 1 and ((tonumber(minor) <= 10) or (tonumber(minor) == 11 and tonumber(micro) < 3)) then
error( "Sorry, but your Wireshark/Tshark version ("..get_version()..") is too old for this script!\n"..
"This script needs Wireshark/Tshark version 1.11.3 or higher.\n" )
end
-- more sanity checking
-- verify we have the ProtoExpert class in wireshark, as that's the newest thing this file uses
assert(ProtoExpert.new, "Wireshark does not have the ProtoExpert class, so it's too old - get the latest 1.11.3 or higher")
----------------------------------------
----------------------------------------
---- some constants for later use ----
-- the min header size
-- 4 bytes for size, 1 for type, 3 for tag number
local MIN_MUX_LEN = 8
local TAG_MARKER = 0
local TAG_PING = 1
-- magic value defined in finagle/finagle-mux/src/main/scala/com/twitter/finagle/mux/Handshake.scala
local CAN_TINIT_PAYLOAD = "tinit check"
local MIN_TAG = TAG_PING
local MAX_TAG = bit32.lshift(1, 23) - 1
local MSB_TAG = bit32.lshift(1, 23)
local MSG_TYPE_CAN_TINIT = 0
local MSG_TYPE_TREQ = 1
local MSG_TYPE_RREQ = 255 -- -1 & 0xff
local MSG_TYPE_TDISPATCH = 2
local MSG_TYPE_RDISPATCH = 254 -- -2 & 0xff
local MSG_TYPE_TDRAIN = 64
local MSG_TYPE_RDRAIN = 192 -- -64 & 0xff
local MSG_TYPE_TPING = 65
local MSG_TYPE_RPING = 191 -- -65 & 0xff
local MSG_TYPE_TDISCARDED = 66
local MSG_TYPE_OLD_TDISCARDED = 194 -- -62 & 0xff
local MSG_TYPE_RDISCARDED = 190 -- -66 & 0xff
local MSG_TYPE_TLEASE = 67
local MSG_TYPE_TINIT = 68
local MSG_TYPE_RINIT = 188 -- -68 & 0xff
local MSG_TYPE_RERR = 128 -- -128 & 0xff
local MSG_TYPE_OLD_RERR = 127
local MESSAGE_TYPES = {
[MSG_TYPE_CAN_TINIT] = "CanTInit",
[MSG_TYPE_TREQ] = "Treq",
[MSG_TYPE_RREQ] = "Rreq",
[MSG_TYPE_TDISPATCH] = "Tdispatch",
[MSG_TYPE_RDISPATCH] = "Rdispatch",
[MSG_TYPE_TDRAIN] = "Tdrain",
[MSG_TYPE_RDRAIN] = "Rdrain",
[MSG_TYPE_TPING] = "Tping",
[MSG_TYPE_RPING] = "Rping",
[MSG_TYPE_TDISCARDED] = "Tdiscarded",
[MSG_TYPE_OLD_TDISCARDED] = "Tdiscarded",
[MSG_TYPE_RDISCARDED] = "Rdiscarded",
[MSG_TYPE_TLEASE] = "Tlease",
[MSG_TYPE_TINIT] = "Tinit",
[MSG_TYPE_RINIT] = "Rinit",
[MSG_TYPE_RERR] = "Rerr",
[MSG_TYPE_OLD_RERR] = "Rerr"
}
local MARKER_TYPES = {
[MSG_TYPE_TDISCARDED] = true,
[MSG_TYPE_OLD_TDISCARDED] = true,
[MSG_TYPE_TLEASE] = true
}
----------------------------------------
-- creates a Proto object, but doesn't register it yet
local mux = Proto("mux","Mux Protocol")
----------------------------------------
-- multiple ways to do the same thing: create a protocol field (but not register it yet)
-- the abbreviation should always have "<myproto>." before the specific abbreviation, to avoid collisions
local pf_size = ProtoField.uint32("mux.size", "Size")
local pf_type = ProtoField.uint8("mux.type", "Message type", base.DEC, MESSAGE_TYPES)
local pf_tag = ProtoField.uint24("mux.tag", "Tag")
local pf_discard_tag = ProtoField.uint24("mux.discard_tag", "Tag To Discard")
local pf_contexts = ProtoField.bytes("mux.context", "Contexts")
local pf_context_key = ProtoField.string("mux.context_key", "Context key")
local pf_dest = ProtoField.string("mux.dest", "Destination")
local pf_payload_len = ProtoField.string("mux.payload", "Payload Length")
local pf_why = ProtoField.string("mux.msg", "Why")
local pf_trace_flags = ProtoField.uint64("mux.ctx.trace.flags", "Flags", base.HEX)
mux.fields = {
pf_size,
pf_type,
pf_tag,
pf_contexts,
pf_context_key,
pf_dest,
pf_payload_len,
pf_discard_tag,
pf_why,
pf_trace_flags
}
-- Tag bit manipulation
--
function isFragment(tag)
-- Corresponds to `Tags.isFragment`
-- ((tag >> 23) & 1) == 1
return bit.band(bit.rshift(tag, 23), 1) == 1
end
-- Tries to decode the context value for the given key.
-- Understands some of the primary contexts used in Finagle.
--
function decodeCtx(ctx_tree, key, value)
local t = ctx_tree:add(key)
local tvb = ByteArray.tvb(value)
if key == "com.twitter.finagle.Deadline" then
-- format is (big endian):
-- 8 bytes: timestamp in nanos since epoch
-- 8 bytes: deadline in nanos since epoch
local timestamp = tvb:range(0, 8):uint64() / 1000
local deadline = tvb:range(8, 8):uint64() / 1000
t:add("Timestamp (micros after epoch): ".. timestamp)
t:add("Deadline (micros after epoch): ".. deadline)
elseif key == "com.twitter.finagle.tracing.TraceContext" then
-- format is (big endian):
-- 8 bytes: span id
-- 8 bytes: parent id
-- 8 bytes: trace id
-- 8 bytes: flags
t:add("Span id: ".. tvb:range(0, 8):uint64())
t:add("Parent id: ".. tvb:range(8, 8):uint64())
t:add("Trace id: ".. tvb:range(16, 8):uint64())
t:add(pf_trace_flags, tvb:range(24, 8))
elseif key == "com.twitter.finagle.thrift.ClientIdContext" then
-- a utf8 string
t:add("Name: ".. tvb:range():string())
else
t:add("length=".. value:len())
end
end
----------------------------------------
-- The following creates the callback function for the dissector.
-- The 'tvbuf' is a Tvb object, 'pktinfo' is a Pinfo object, and 'root' is a TreeItem object.
-- Whenever Wireshark dissects a packet that our Proto is hooked into, it will call
-- this function and pass it these arguments for the packet it's dissecting.
function mux.dissector(tvbuf,pktinfo,root)
dprint2("mux.dissector called")
-- set the protocol column to show our protocol name
pktinfo.cols.protocol:set("MUX")
-- We want to check that the packet size is rational during dissection, so let's get the length of the
-- packet buffer (Tvb).
-- we can use tvb:len() or tvb:reported_len() here; but I prefer tvb:reported_length_remaining() as it's safer.
local pktlen = tvbuf:reported_length_remaining()
-- We start by adding our protocol to the dissection display tree.
-- A call to tree:add() returns the child created, so we can add more "under" it using that return value.
-- The second argument is how much of the buffer/packet this added tree item covers/represents - in this
-- case that's the remainder of the packet.
local tree = root:add(mux, tvbuf:range(0,pktlen))
-- size starts at offset 0, for 4 bytes length.
tree:add(pf_size, tvbuf:range(0,4))
-- size represents the number of bytes remaining in the frame.
local size = tvbuf:range(0,4):int()
-- now let's add the type, which are all in the packet bytes at offset 4 of length 1
-- instead of calling this again and again, let's just use a variable
local typeint = tvbuf:range(4,1):uint()
local typestr = MESSAGE_TYPES[typeint]
-- special case the magic RErr message used in handshaking
if typeint == MSG_TYPE_OLD_RERR and size == 15 and tvbuf:range(8, 11):string() == CAN_TINIT_PAYLOAD then -- magic!
tree:add(pf_type, MSG_TYPE_CAN_TINIT)
local typestr = "CanTinit"
else
tree:add(pf_type, tvbuf:range(4,1))
end
if not typestr then
typestr = "unknown type (".. typeint .. ")"
end
-- now add more to the main tree
tree:add(pf_tag, tvbuf:range(5,3))
local tag = tvbuf:range(5,3):uint()
pktinfo.cols.info:prepend(typestr .." Tag=".. tag .." ")
local pos = 8
if typeint == MSG_TYPE_RERR or typeint == MSG_TYPE_OLD_RERR then
-- size remaining bytes are the message (-4 bytes for the type and tag)
tree:add(pf_why, tvbuf(pos, size - 4))
elseif typeint == MSG_TYPE_OLD_TDISCARDED or typeint == MSG_TYPE_TDISCARDED then
tree:add(pf_discard_tag, tvbuf:range(pos, 3)) -- first three bytes after
-- tag are the 'discard_tag'
tree:add(pf_why, tvbuf(pos + 3, size - 7)) -- remainder of body is 'why'
elseif typeint == MSG_TYPE_TDISPATCH then
-- 2 bytes for number of contexts
-- for each context:
-- 2 bytes for context key's length, followed by len bytes for the key
-- 2 bytes for context values's length, followed by len bytes for the value
-- 2 bytes for the dest's length, followed by len bytes of the dest
-- 2 bytes for the number of dtab entries
-- for each dtab entry:
-- 2 bytes for the entry's prefix bytes len, followed by len bytes of the src
-- 2 bytes for the entry's tree bytes len, followed by len bytes of the tree
-- the remaining bytes are the payload.
-- begin with contexts
local numctxs = tvbuf:range(pos,2):uint()
pos = pos + 2
local ctx_tree = tree:add("Contexts: ".. numctxs)
for ctx = 1,numctxs do
local keylen = tvbuf:range(pos,2):uint()
pos = pos + 2
local key = tvbuf:range(pos, keylen):string()
pos = pos + keylen
local vallen = tvbuf:range(pos,2):uint()
pos = pos + 2
local value = tvbuf:range(pos,vallen):bytes()
pos = pos + vallen
decodeCtx(ctx_tree, key, value)
end
-- then dest
local destlen = tvbuf:range(pos,2):uint()
pos = pos + 2
local dest = tvbuf:range(pos, destlen):string()
if dest:len() > 0 then
tree:add(pf_dest, dest)
end
pos = pos + destlen
-- then dtabs
local numdtabs = tvbuf:range(pos,2):uint()
pos = pos + 2
if numdtabs > 0 then
local dtab_tree = tree:add("Dtabs")
for entry = 1,numdtabs do
local len = tvbuf:range(pos,2):uint()
pos = pos + 2
local src = tvbuf:range(pos, len):string()
pos = pos + len
len = tvbuf:range(pos,2):uint()
pos = pos + 2
local dst = tvbuf:range(pos, len):string()
pos = pos + len
dtab_tree:add(src .." => ".. dst)
end
end
end
local remaining = size - pos + 4 -- add back the 4 bytes for the size field
tree:add(pf_payload_len, remaining)
pos = pos + remaining
dprint2("mux.dissector returning ".. pos)
-- tell wireshark how much of tvbuf we dissected
return pos
end
----------------------------------------
-- we also want to add the heuristic dissector, for any tcp protocol
-- first we need a heuristic dissection function
-- this is that function - when wireshark invokes this, it will pass in the same
-- things it passes in to the "dissector" function, but we only want to actually
-- dissect it if it's for us, and we need to return true if it's for us, or else false
-- figuring out if it's for us or not is not easy
-- we need to try as hard as possible, or else we'll think it's for us when it's
-- not and block other heuristic dissectors from getting their chance
--
local function heur_dissect_mux(tvbuf,pktinfo,root)
dprint2("heur_dissect_mux called")
-- if our preferences tell us not to do this, return false
if not default_settings.heur_enabled then
dprint2("heur_dissect_mux disabled")
return false
end
if tvbuf:len() < MIN_MUX_LEN then
dprint("heur_dissect_mux: tvb shorter than MIN_MUX_LEN of: ".. MIN_MUX_LEN)
return false
end
-- the first 4 bytes are size id, validate that it is the right size
local size = tvbuf:range(0, 4):int()
if size + 4 ~= tvbuf:len() then
dprint("heur_dissect_mux: size did not match buf length: ".. size .." != ".. tvbuf:len())
return false
end
-- the next byte is the type which we need to verify is valid
local typeint = tvbuf:range(4,1):uint()
local typestr = MESSAGE_TYPES[typeint]
if not typestr then
dprint("heur_dissect_mux: invalid type: ".. typeint)
return false
end
-- examine the tag
local tag = tvbuf:range(5,3):uint()
if typeint == MSG_TYPE_TPING or typeint == MSG_TYPE_RPING then
if tag ~= TAG_PING then
dprint("heur_dissect_mux: invalid ping tag: ".. tag)
return false
end
else
if MARKER_TYPES[typeint] then
if tag ~= TAG_MARKER then
dprint(string.format("%s (%d) %s (%d)", "heur_dissect_mux: marker type", typeint, "with non-marker tag", tag))
return false
end
else
if isFragment(tag) == true then
tag = bit.band(tag, bit.bnot(MSB_TAG))
end
if tag < MIN_TAG or tag > MAX_TAG then
dprint("heur_dissect_mux: invalid tag: ".. tag)
return false
end
end
end
dprint2("heur_dissect_mux: everything looks good calling the real dissector")
-- ok, looks like it's ours, so go dissect it
-- note: calling the dissector directly like this is new in 1.11.3
-- also note that calling a Dissector object, as this does, means we don't
-- get back the return value of the dissector function we created previously
-- so it might be better to just call the function directly instead of doing
-- this, but this script is used for testing and this tests the call() function
mux.dissector(tvbuf,pktinfo,root)
return true
end
----------------------------------------
-- we want to have our protocol dissection invoked for a specific tcp port,
-- so get the tcp dissector table and add our protocol to it
DissectorTable.get("tcp.port"):add(default_settings.port, mux)
-- now register that heuristic dissector into the tcp heuristic list
mux:register_heuristic("tcp",heur_dissect_mux)
-- We're done!
-- our protocol (Proto) gets automatically registered after this script finishes loading
----------------------------------------
| apache-2.0 |
TheAnswer/FirstTest | bin/scripts/skills/creatureSkills/npcs/imperial/imperialSergeantMajorAttacks.lua | 1 | 3019 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
imperialSergeantMajorAttack1 = {
attackname = "imperialSergeantMajorAttack1",
animation = "fire_1_special_single_light",
requiredWeaponType = PISTOL,
range = 65,
damageRatio = 1.2,
speedRatio = 1,
areaRange = 0,
accuracyBonus = 0,
healthAttackChance = 100,
actionAttackChance = 0,
mindAttackChance = 0,
dotChance = 60,
tickStrengthOfHit = 1,
fireStrength = 0,
fireType = 0,
bleedingStrength = 1,
bleedingType = HEALTH,
poisonStrength = 0,
poisonType = 0,
diseaseStrength = 0,
diseaseType = 0,
CbtSpamBlock = "sapblast_block",
CbtSpamCounter = "sapblast_counter",
CbtSpamEvade = "sapblast_evade",
CbtSpamHit = "sapblast_hit",
CbtSpamMiss = "sapblast_miss",
invalidStateMask = 0,
invalidPostures = "",
instant = 0
}
AddRandomPoolAttackTargetSkill(imperialSergeantMajorAttack1)
-----------------------------------------------------------------------
| lgpl-3.0 |
Xeltor/ovale | dist/Warlock.lua | 1 | 5782 | local __exports = LibStub:NewLibrary("ovale/Warlock", 80300)
if not __exports then return end
local __class = LibStub:GetLibrary("tslib").newClass
local aceEvent = LibStub:GetLibrary("AceEvent-3.0", true)
local tonumber = tonumber
local pairs = pairs
local GetTime = GetTime
local CombatLogGetCurrentEventInfo = CombatLogGetCurrentEventInfo
local find = string.find
local pow = math.pow
local CUSTOM_AURAS = {
[80240] = {
customId = -80240,
duration = 10,
stacks = 1,
auraName = "active_havoc"
}
}
local demonData = {
[55659] = {
duration = 12
},
[98035] = {
duration = 12
},
[103673] = {
duration = 12
},
[11859] = {
duration = 25
},
[89] = {
duration = 25
},
[143622] = {
duration = 12
},
[135002] = {
duration = 15
},
[17252] = {
duration = 15
}
}
local self_demons = {}
local self_serial = 1
__exports.OvaleWarlockClass = __class(nil, {
constructor = function(self, ovale, ovaleAura, ovalePaperDoll, ovaleSpellBook)
self.ovale = ovale
self.ovaleAura = ovaleAura
self.ovalePaperDoll = ovalePaperDoll
self.ovaleSpellBook = ovaleSpellBook
self.OnInitialize = function()
if self.ovale.playerClass == "WARLOCK" then
self.module:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED", self.COMBAT_LOG_EVENT_UNFILTERED)
self_demons = {}
end
end
self.OnDisable = function()
if self.ovale.playerClass == "WARLOCK" then
self.module:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end
end
self.COMBAT_LOG_EVENT_UNFILTERED = function(event, ...)
local _, cleuEvent, _, sourceGUID, _, _, _, destGUID, _, _, _, spellId = CombatLogGetCurrentEventInfo()
if sourceGUID ~= self.ovale.playerGUID then
return
end
self_serial = self_serial + 1
if cleuEvent == "SPELL_SUMMON" then
local _, _, _, _, _, _, _, creatureId = find(destGUID, "(%S+)-(%d+)-(%d+)-(%d+)-(%d+)-(%d+)-(%S+)")
creatureId = tonumber(creatureId)
local now = GetTime()
for id, v in pairs(demonData) do
if id == creatureId then
self_demons[destGUID] = {
id = creatureId,
timestamp = now,
finish = now + v.duration
}
break
end
end
for k, d in pairs(self_demons) do
if d.finish < now then
self_demons[k] = nil
end
end
self.ovale:needRefresh()
elseif cleuEvent == "SPELL_CAST_SUCCESS" then
local demonicConsumptionTalent = 20
if spellId == 196277 or (spellId == 265187 and self.ovaleSpellBook:IsKnownTalent(demonicConsumptionTalent)) then
for k, d in pairs(self_demons) do
if d.id == 55659 or d.id == 143622 then
self_demons[k] = nil
end
end
self.ovale:needRefresh()
end
local aura = CUSTOM_AURAS[spellId]
if aura then
self:AddCustomAura(aura.customId, aura.stacks, aura.duration, aura.auraName)
end
end
end
self.module = ovale:createModule("OvaleWarlock", self.OnInitialize, self.OnDisable, aceEvent)
end,
CleanState = function(self)
end,
InitializeState = function(self)
end,
ResetState = function(self)
end,
GetNotDemonicEmpoweredDemonsCount = function(self, creatureId, atTime)
local count = 0
for _, d in pairs(self_demons) do
if d.finish >= atTime and d.id == creatureId and not d.de then
count = count + 1
end
end
return count
end,
GetDemonsCount = function(self, creatureId, atTime)
local count = 0
for _, d in pairs(self_demons) do
if d.finish >= atTime and d.id == creatureId then
count = count + 1
end
end
return count
end,
GetRemainingDemonDuration = function(self, creatureId, atTime)
local max = 0
for _, d in pairs(self_demons) do
if d.finish >= atTime and d.id == creatureId then
local remaining = d.finish - atTime
if remaining > max then
max = remaining
end
end
end
return max
end,
AddCustomAura = function(self, customId, stacks, duration, buffName)
local now = GetTime()
local expire = now + duration
self.ovaleAura:GainedAuraOnGUID(self.ovale.playerGUID, now, customId, self.ovale.playerGUID, "HELPFUL", false, nil, stacks, nil, duration, expire, false, buffName, nil, nil, nil)
end,
TimeToShard = function(self, now)
local value = 3600
local creepingDeathTalent = 20
local tickTime = 2 / self.ovalePaperDoll:GetHasteMultiplier("spell", self.ovalePaperDoll.next)
local activeAgonies = self.ovaleAura:AuraCount(980, "HARMFUL", true, nil, now, nil)
if activeAgonies > 0 then
value = 1 / (0.184 * pow(activeAgonies, -2 / 3)) * tickTime / activeAgonies
if self.ovaleSpellBook:IsKnownTalent(creepingDeathTalent) then
value = value * 0.85
end
end
return value
end,
})
| mit |
TheAnswer/FirstTest | bin/scripts/skills/creatureSkills/tatooine/creatures/dewbackAttacks.lua | 1 | 4214 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
dewbackAttack1 = {
attackname = "dewbackAttack1",
animation = "creature_attack_light",
requiredWeaponType = NONE,
range = 7,
damageRatio = 1.2,
speedRatio = 4,
arearange = 7,
accuracyBonus = 0,
knockdownChance = 0,
postureDownChance = 0,
postureUpChance = 0,
dizzyChance = 50,
blindChance = 0,
stunChance = 0,
intimidateChance = 0,
CbtSpamBlock = "attack_block",
CbtSpamCounter = "attack_counter",
CbtSpamEvade = "attack_evade",
CbtSpamHit = "attack_hit",
CbtSpamMiss = "attack_miss",
invalidStateMask = 0,
invalidPostures = "",
instant = 0
}
AddRandomPoolAttackTargetSkill(dewbackAttack1)
-----------------------------------------------
dewbackAttack2 = {
attackname = "dewbackAttack2",
animation = "creature_attack_light",
requiredWeaponType = NONE,
range = 7,
damageRatio = 1.2,
speedRatio = 4,
arearange = 7,
accuracyBonus = 0,
knockdownChance = 50,
postureDownChance = 0,
postureUpChance = 0,
dizzyChance = 0,
blindChance = 0,
stunChance = 0,
intimidateChance = 0,
CbtSpamBlock = "attack_block",
CbtSpamCounter = "attack_counter",
CbtSpamEvade = "attack_evade",
CbtSpamHit = "attack_hit",
CbtSpamMiss = "attack_miss",
invalidStateMask = 0,
invalidPostures = "",
instant = 0
}
AddRandomPoolAttackTargetSkill(dewbackAttack2)
-----------------------------------------------
dewbackAttack3 = {
attackname = "dewbackAttack3",
animation = "creature_attack_light",
requiredWeaponType = NONE,
range = 7,
damageRatio = 1.2,
speedRatio = 4,
arearange = 7,
accuracyBonus = 0,
knockdownChance = 0,
postureDownChance = 0,
postureUpChance = 0,
dizzyChance = 0,
blindChance = 0,
stunChance = 50,
intimidateChance = 0,
CbtSpamBlock = "attack_block",
CbtSpamCounter = "attack_counter",
CbtSpamEvade = "attack_evade",
CbtSpamHit = "attack_hit",
CbtSpamMiss = "attack_miss",
invalidStateMask = 0,
invalidPostures = "",
instant = 0
}
AddRandomPoolAttackTargetSkill(dewbackAttack3)
-----------------------------------------------
| lgpl-3.0 |
TheAnswer/FirstTest | bin/scripts/creatures/objects/tatooine/npcs/desertDemon/desertDemonBrawler.lua | 1 | 4592 | --Copyright (C) 2008 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
desertDemonBrawler = Creature:new {
objectName = "desertDemonBrawler", -- Lua Object Name
creatureType = "NPC",
faction = "desert_demon",
factionPoints = 20,
gender = "",
speciesName = "desert_demon_brawler",
stfName = "mob/creature_names",
objectCRC = 1319703009,
socialGroup = "desert_demon",
level = 14,
combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG,
healthMax = 2400,
healthMin = 2000,
strength = 0,
constitution = 0,
actionMax = 2400,
actionMin = 2000,
quickness = 0,
stamina = 0,
mindMax = 2400,
mindMin = 2000,
focus = 0,
willpower = 0,
height = 1, -- Size of creature
armor = 1, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy
kinetic = 0,
energy = 0,
electricity = 0,
stun = 0,
blast = 0,
heat = 0,
cold = 0,
acid = 0,
lightsaber = 0,
accuracy = 0,
healer = 0,
pack = 1,
herd = 0,
stalker = 0,
killer = 0,
ferocity = 0,
aggressive = 0,
invincible = 0,
attackCreatureOnSight = "", -- Enter socialGroups
weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx
weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance'
weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance'
weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon'
weaponEquipped = 0,
weaponMinDamage = 150,
weaponMaxDamage = 160,
weaponAttackSpeed = 2,
weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc
weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY
alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx
alternateWeaponName = "", -- Name ex. 'a Vibrolance'
alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance'
alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon'
alternateWeaponEquipped = 0,
alternateWeaponMinDamage = 0,
alternateWeaponMaxDamage = 0,
alternateWeaponAttackSpeed = 0,
alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc
alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY
internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's
lootGroup = "0", -- Group it belongs to for loot
tame = 0,
datapadItemCRC = 0,
mountCRC = 0,
mountSpeed = 0,
mountAcceleration = 0,
milk = 0,
boneType = "",
boneMax = 0,
hideType = "",
hideMax = 0,
meatType = "",
meatMax = 0,
skills = { "desertDemonAttack1" },
respawnTimer = 180,
behaviorScript = "", -- Link to the behavior script for this object
}
Creatures:addCreature(desertDemonBrawler, 1319703009) -- Add to Global Table
| lgpl-3.0 |
technomancy/ss-calandria | mods/digilines/digilines/wire_std.lua | 5 | 3232 | -- naming scheme: wire:(xp)(zp)(xm)(zm)_on/off
-- The conditions in brackets define whether there is a digiline at that place or not
-- 1 = there is one; 0 = there is none
-- y always means y+
box_center = {-1/16, -.5, -1/16, 1/16, -.5+1/16, 1/16}
box_bump1 = { -2/16, -8/16, -2/16, 2/16, -13/32, 2/16 }
box_bump2 = { -3/32, -13/32, -3/32, 3/32, -12/32, 3/32 }
box_xp = {1/16, -.5, -1/16, 8/16, -.5+1/16, 1/16}
box_zp = {-1/16, -.5, 1/16, 1/16, -.5+1/16, 8/16}
box_xm = {-8/16, -.5, -1/16, -1/16, -.5+1/16, 1/16}
box_zm = {-1/16, -.5, -8/16, 1/16, -.5+1/16, -1/16}
box_xpy = {.5-1/16, -.5+1/16, -1/16, .5, .4999+1/16, 1/16}
box_zpy = {-1/16, -.5+1/16, .5-1/16, 1/16, .4999+1/16, .5}
box_xmy = {-.5, -.5+1/16, -1/16, -.5+1/16, .4999+1/16, 1/16}
box_zmy = {-1/16, -.5+1/16, -.5, 1/16, .4999+1/16, -.5+1/16}
for xp=0, 1 do
for zp=0, 1 do
for xm=0, 1 do
for zm=0, 1 do
for xpy=0, 1 do
for zpy=0, 1 do
for xmy=0, 1 do
for zmy=0, 1 do
if (xpy == 1 and xp == 0) or (zpy == 1 and zp == 0)
or (xmy == 1 and xm == 0) or (zmy == 1 and zm == 0) then break end
local groups
local nodeid = tostring(xp )..tostring(zp )..tostring(xm )..tostring(zm )..
tostring(xpy)..tostring(zpy)..tostring(xmy)..tostring(zmy)
if nodeid == "00000000" then
groups = {dig_immediate = 3}
wiredesc = "Digiline"
else
groups = {dig_immediate = 3, not_in_creative_inventory = 1}
end
local nodebox = {}
local adjx = false
local adjz = false
if xp == 1 then table.insert(nodebox, box_xp) adjx = true end
if zp == 1 then table.insert(nodebox, box_zp) adjz = true end
if xm == 1 then table.insert(nodebox, box_xm) adjx = true end
if zm == 1 then table.insert(nodebox, box_zm) adjz = true end
if xpy == 1 then table.insert(nodebox, box_xpy) end
if zpy == 1 then table.insert(nodebox, box_zpy) end
if xmy == 1 then table.insert(nodebox, box_xmy) end
if zmy == 1 then table.insert(nodebox, box_zmy) end
if adjx and adjz and (xp + zp + xm + zm > 2) then
table.insert(nodebox, box_bump1)
table.insert(nodebox, box_bump2)
tiles = {
"digiline_std_bump.png",
"digiline_std_bump.png",
"digiline_std_vertical.png",
"digiline_std_vertical.png",
"digiline_std_vertical.png",
"digiline_std_vertical.png"
}
else
table.insert(nodebox, box_center)
tiles = {
"digiline_std.png",
"digiline_std.png",
"digiline_std_vertical.png",
"digiline_std_vertical.png",
"digiline_std_vertical.png",
"digiline_std_vertical.png"
}
end
if nodeid == "00000000" then
nodebox = {-8/16, -.5, -1/16, 8/16, -.5+1/16, 1/16}
end
minetest.register_node("digilines:wire_std_"..nodeid, {
description = wiredesc,
drawtype = "nodebox",
tiles = tiles,
inventory_image = "digiline_std_inv.png",
wield_image = "digiline_std_inv.png",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
digiline =
{
wire =
{
basename = "digilines:wire_std_",
use_autoconnect = true
}
},
selection_box = {
type = "fixed",
fixed = {-.5, -.5, -.5, .5, -.5+1/16, .5}
},
node_box = {
type = "fixed",
fixed = nodebox
},
groups = groups,
walkable = false,
stack_max = 99,
drop = "digilines:wire_std_00000000"
})
end
end
end
end
end
end
end
end
| gpl-3.0 |
TheAnswer/FirstTest | bin/scripts/sceneobjects/objects/lairs/dantooine/piketLair.lua | 1 | 2478 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
piketLair = Lair:new {
objectName = "piketLair",
stfName = "rock_shelter",
objectCRC = 1495135397,
maxCondition = 5000,
positionX = 0,
positionY = 0,
positionZ = 0,
planet = 1,
creatureCRC = 228250912,
creatureName = "picket",
creaturestfName = "a picket",
spawnSize = 3,
babiesPerMillion = 500000
}
Objects:addObject(picketLair, "picketLair")
| lgpl-3.0 |
TheAnswer/FirstTest | bin/scripts/creatures/objects/yavin4/creatures/kliknikHatchling.lua | 1 | 4635 | --Copyright (C) 2008 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
kliknikHatchling = Creature:new {
objectName = "kliknikHatchling", -- Lua Object Name
creatureType = "ANIMAL",
gender = "",
speciesName = "kliknik_hatchling",
stfName = "mob/creature_names",
objectCRC = 563836998,
socialGroup = "Kliknik",
level = 22,
combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG,
healthMax = 7200,
healthMin = 5900,
strength = 0,
constitution = 0,
actionMax = 7200,
actionMin = 5900,
quickness = 0,
stamina = 0,
mindMax = 7200,
mindMin = 5900,
focus = 0,
willpower = 0,
height = 1, -- Size of creature
armor = 0, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy
kinetic = 0,
energy = 0,
electricity = 0,
stun = 0,
blast = 0,
heat = 0,
cold = 0,
acid = 0,
lightsaber = 0,
accuracy = 0,
healer = 0,
pack = 1,
herd = 1,
stalker = 0,
killer = 0,
ferocity = 0,
aggressive = 0,
invincible = 0,
meleeDefense = 1,
rangedDefense = 1,
attackCreatureOnSight = "", -- Enter socialGroups
weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx
weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance'
weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance'
weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon'
weaponEquipped = 0,
weaponMinDamage = 210,
weaponMaxDamage = 220,
weaponAttackSpeed = 2,
weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc
weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY
alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx
alternateWeaponName = "", -- Name ex. 'a Vibrolance'
alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance'
alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon'
alternateweaponEquipped = 0,
alternateWeaponMinDamage = 0,
alternateWeaponMaxDamage = 0,
alternateWeaponAttackSpeed = 0,
alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc
alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY
internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's
lootGroup = "0", -- Group it belongs to for loot
tame = 0, -- Likely hood to be tamed
datapadItemCRC = 0,
mountCRC = 0,
mountSpeed = 0,
mountAcceleration = 0,
milk = 0,
boneType = "",
boneMax = 20,
hideType = "hide_scaley_yavin4",
hideMax = 4,
meatType = "meat_carnivore_yavin4",
meatMax = 1,
skills = { "kliknikAttack1" },
respawnTimer = 60,
behaviorScript = "", -- Link to the behavior script for this object
}
Creatures:addCreature(kliknikHatchling, 563836998) -- Add to Global Table
| lgpl-3.0 |
TheAnswer/FirstTest | bin/scripts/creatures/objects/dantooine/npcs/janta/jantaRockshaper.lua | 1 | 4868 | --Copyright (C) 2008 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
jantaRockshaper = Creature:new {
objectName = "jantaRockshaper", -- Lua Object Name
creatureType = "NPC",
faction = "janta_tribe",
factionPoints = 20,
gender = "",
speciesName = "janta_rockshaper",
stfName = "mob/creature_names",
objectCRC = 4083847450,
socialGroup = "janta_tribe",
level = 75,
combatFlags = ATTACKABLE_FLAG,
healthMax = 15000,
healthMin = 13000,
strength = 500,
constitution = 500,
actionMax = 15000,
actionMin = 13000,
quickness = 500,
stamina = 500,
mindMax = 15000,
mindMin = 13000,
focus = 500,
willpower = 500,
height = 1, -- Size of creature
armor = 0, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy
kinetic = 100,
energy = 0,
electricity = 100,
stun = -1,
blast = -1,
heat = 0,
cold = 0,
acid = 0,
lightsaber = 0,
accuracy = 300,
healer = 0,
pack = 1,
herd = 1,
stalker = 0,
killer = 0,
ferocity = 0,
aggressive = 0,
invincible = 0,
meleeDefense = 1,
rangedDefense = 1,
attackCreatureOnSight = "", -- Enter socialGroups
weapon = "object/weapon/melee/polearm/shared_lance_staff_wood_s1.iff", -- File path to weapon -> object\xxx\xxx\xx
weaponName = "a Wooden Staff", -- Name ex. 'a Vibrolance'
weaponTemp = "lance_staff_wood_s1", -- Weapon Template ex. 'lance_vibrolance'
weaponClass = "PolearmMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon'
weaponEquipped = 1,
weaponMinDamage = 495,
weaponMaxDamage = 700,
weaponAttackSpeed = 2,
weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc
weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY
alternateWeapon = "object/weapon/melee/knife/shared_knife_stone.iff", -- File path to weapon -> object\xxx\xxx\xx
alternateWeaponName = "a Stone Knife", -- Name ex. 'a Vibrolance'
alternateWeaponTemp = "knife_stone", -- Weapon Template ex. 'lance_vibrolance'
alternateWeaponClass = "OneHandedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon'
alternateWeaponEquipped = 1,
alternateWeaponMinDamage = 495,
alternateWeaponMaxDamage = 700,
alternateweaponAttackSpeed = 2,
alternateWeaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc
alternateWeaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY
internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's
lootGroup = "0,11,15,19,33,65", -- Group it belongs to for loot
tame = 0,
datapadItemCRC = 0,
mountCRC = 0,
mountSpeed = 0,
mountAcceleration = 0,
milk = 0,
boneType = "",
boneMax = 0,
hideType = "",
hideMax = 0,
meatType = "",
meatMax = 0,
skills = { "kungaAttack01", "kungaAttack02", "kungaAttack03", "kungaAttack04", "kungaAttack05", "kungaAttack06", "kungaAttack07", "kungaAttack08" },
respawnTimer = 300,
behaviorScript = "", -- Link to the behavior script for this object
}
Creatures:addCreature(jantaRockshaper, 4083847450) -- Add to Global Table
| lgpl-3.0 |
TheAnswer/FirstTest | bin/scripts/object/mission/base/objects.lua | 1 | 3976 | --Copyright (C) 2009 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
object_mission_base_shared_base_mission = SharedMissionObjectTemplate:new {
appearanceFilename = "appearance/defaultappearance.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 0,
collisionActionFlags = 0,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 0,
collisionMaterialFlags = 0,
collisionMaterialPassFlags = 0,
containerType = 4,
containerVolumeLimit = -1,
detailedDescription = "string_id_table",
gameObjectType = 2051,
locationReservationRadius = 0,
lookAtText = "string_id_table",
noBuildRadius = 0,
objectName = "string_id_table",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 0,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 0
}
ObjectTemplates:addTemplate(object_mission_base_shared_base_mission, 3240843527)
object_mission_base_shared_mission_default = SharedMissionObjectTemplate:new {
appearanceFilename = "appearance/defaultappearance.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 0,
collisionActionFlags = 0,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 0,
collisionMaterialFlags = 0,
collisionMaterialPassFlags = 0,
containerType = 4,
containerVolumeLimit = -1,
detailedDescription = "string_id_table",
gameObjectType = 2051,
locationReservationRadius = 0,
lookAtText = "string_id_table",
noBuildRadius = 0,
objectName = "string_id_table",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 0,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 0,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 0
}
ObjectTemplates:addTemplate(object_mission_base_shared_mission_default, 2210569821)
| lgpl-3.0 |
manuel-arguelles/roidsbuster | spaceship.lua | 1 | 2754 | local shooting_interval = 0.2
local sp = { x = 0, y = 0, speed = 150, img = nil, score = 0, alive = true,
shooting_timer = shooting_interval, allow_shooting = true,
active_lasers = {}, shooting_sound = nil}
local laser = { x = 0, y = 0, speed = 200, img = nil }
spaceship = sp
function sp.load(arg)
sp.img = love.graphics.newImage('images/spaceship.png')
laser.img = love.graphics.newImage('images/laser.png')
sp.x = (love.graphics:getWidth() / 2) - (sp.img:getWidth() / 2)
sp.shooting_sound = love.audio.newSource('sounds/pitiu.ogg', 'static')
--sp.shooting_sound = love.audio.newSource("sounds/pitiu.wav", 'static')
end
function sp.move_right(dt)
if sp.x < (love.graphics.getWidth() - sp.img:getWidth()) then
sp.x = sp.x + (sp.speed * dt)
end
end
function sp.move_left(dt)
if sp.x > 0 then
sp.x = sp.x - (sp.speed * dt)
end
end
function sp.draw(dt)
if spaceship.alive then
sp.y = love.graphics:getHeight() - sp.img:getHeight()
love.graphics.draw(sp.img, sp.x, sp.y)
for i, laser in ipairs(sp.active_lasers) do
love.graphics.draw(laser.img, laser.x, laser.y)
end
else
love.graphics.print("Press 'R' to restart", love.graphics:getWidth()/2-50,
love.graphics:getHeight()/2-10)
end
end
function sp.increase_score()
if sp.alive then
sp.score = sp.score + 1
end
end
function sp.decrease_score()
if sp.alive and sp.score > 0 then
sp.score = sp.score - 1
end
end
function sp.update_shooting_interval(dt)
sp.shooting_timer = sp.shooting_timer - (1 * dt)
if sp.shooting_timer < 0 then
sp.allow_shooting = true
end
end
function sp.shoot(dt)
if sp.allow_shooting and sp.alive then
-- Lets shoot
new_laser = {
x = (sp.x + ((sp.img:getWidth()/2) - (laser.img:getWidth()/2))),
y = (sp.y - (laser.img:getHeight()/2)), speed = laser.speed,
img = laser.img }
if sp.shooting_sound ~= nil then
sp.shooting_sound:rewind()
sp.shooting_sound:play()
end
table.insert(sp.active_lasers, new_laser)
sp.shooting_timer = shooting_interval
sp.allow_shooting = false
end
end
function sp.move_lasers(dt)
for i, d_laser in ipairs(sp.active_lasers) do
d_laser.y = d_laser.y - (d_laser.speed * dt)
if d_laser.y < 0 then
table.remove(sp.active_lasers, i)
end
end
end
function sp.get_lasers()
return sp.active_lasers;
end
function sp.remove_laser(pos)
table.remove(sp.active_lasers, pos)
end
function sp.killed()
sp.alive = false
sp.active_lasers = {}
end
function sp.revive()
if not sp.alive then
sp.x = (love.graphics:getWidth() / 2) - (sp.img:getWidth() / 2)
sp.alive = true
sp.score = 0
end
end
return sp
| gpl-2.0 |
muhkuh-sys/muhkuh_tester | lua/test_class.lua | 1 | 1269 | local class = require 'pl.class'
local TestClass = class()
function TestClass:_init(strTestName, uiTestCase, tLogWriter, strLogLevel)
self.P = require 'parameter_instances'(strTestName, tLogWriter, strLogLevel)
self.pl = require'pl.import_into'()
-- Create a new log target for this test.
local tLogWriterTestcase = require 'log.writer.prefix'.new(
string.format('[Test %02d] ', uiTestCase),
tLogWriter
)
self.tLog = require 'log'.new(
-- maximum log level
strLogLevel,
tLogWriterTestcase,
-- Formatter
require 'log.formatter.format'.new()
)
self.CFG_strTestName = strTestName
self.CFG_uiTestCase = uiTestCase
self.CFG_aParameterDefinitions = {}
end
function TestClass:__parameter(atParameter)
self.CFG_aParameterDefinitions = atParameter
-- Build a lookup table with the parameter name as the key.
local atParameterLookUp = {}
for _, tParameter in pairs(atParameter) do
local strName = tParameter.strName
if atParameterLookUp[strName]~=nil then
self.tLog.error('The test defines the parameter "%s" more than once.', strName)
error('Invalid parameter definition.')
end
atParameterLookUp[strName] = tParameter
end
self.atParameter = atParameterLookUp
end
return TestClass
| gpl-2.0 |
BakaBBQ/siki.lua | love-frames/libraries/util.lua | 14 | 10269 | --[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012-2014 Kenny Shields --
--]]------------------------------------------------
-- get the current require path
local path = string.sub(..., 1, string.len(...) - string.len(".util"))
local loveframes = require(path .. ".common")
-- util library
loveframes.util = {}
--[[---------------------------------------------------------
- func: SetActiveSkin(name)
- desc: sets the active skin
--]]---------------------------------------------------------
function loveframes.util.SetActiveSkin(name)
loveframes.config["ACTIVESKIN"] = name
end
--[[---------------------------------------------------------
- func: GetActiveSkin()
- desc: gets the active skin
--]]---------------------------------------------------------
function loveframes.util.GetActiveSkin()
local index = loveframes.config["ACTIVESKIN"]
local skin = loveframes.skins.available[index]
return skin
end
--[[---------------------------------------------------------
- func: BoundingBox(x1, x2, y1, y2, w1, w2, h1, h2)
- desc: checks for a collision between two boxes
- note: I take no credit for this function
--]]---------------------------------------------------------
function loveframes.util.BoundingBox(x1, x2, y1, y2, w1, w2, h1, h2)
if x1 > x2 + w2 - 1 or y1 > y2 + h2 - 1 or x2 > x1 + w1 - 1 or y2 > y1 + h1 - 1 then
return false
else
return true
end
end
--[[---------------------------------------------------------
- func: GetCollisions(object, table)
- desc: gets all objects colliding with the mouse
--]]---------------------------------------------------------
function loveframes.util.GetCollisions(object, t)
local x, y = love.mouse.getPosition()
local curstate = loveframes.state
local object = object or loveframes.base
local visible = object.visible
local children = object.children
local internals = object.internals
local objectstate = object.state
local t = t or {}
if objectstate == curstate and visible then
local objectx = object.x
local objecty = object.y
local objectwidth = object.width
local objectheight = object.height
local col = loveframes.util.BoundingBox(x, objectx, y, objecty, 1, objectwidth, 1, objectheight)
local collide = object.collide
if col and collide then
local clickbounds = object.clickbounds
if clickbounds then
local cx = clickbounds.x
local cy = clickbounds.y
local cwidth = clickbounds.width
local cheight = clickbounds.height
local clickcol = loveframes.util.BoundingBox(x, cx, y, cy, 1, cwidth, 1, cheight)
if clickcol then
table.insert(t, object)
end
else
table.insert(t, object)
end
end
if children then
for k, v in ipairs(children) do
loveframes.util.GetCollisions(v, t)
end
end
if internals then
for k, v in ipairs(internals) do
local type = v.type
if type ~= "tooltip" then
loveframes.util.GetCollisions(v, t)
end
end
end
end
return t
end
--[[---------------------------------------------------------
- func: GetAllObjects(object, table)
- desc: gets all active objects
--]]---------------------------------------------------------
function loveframes.util.GetAllObjects(object, t)
local object = object or loveframes.base
local internals = object.internals
local children = object.children
local t = t or {}
table.insert(t, object)
if internals then
for k, v in ipairs(internals) do
loveframes.util.GetAllObjects(v, t)
end
end
if children then
for k, v in ipairs(children) do
loveframes.util.GetAllObjects(v, t)
end
end
return t
end
--[[---------------------------------------------------------
- func: GetDirectoryContents(directory, table)
- desc: gets the contents of a directory and all of
its subdirectories
--]]---------------------------------------------------------
function loveframes.util.GetDirectoryContents(dir, t)
local dir = dir
local t = t or {}
local dirs = {}
local files = love.filesystem.getDirectoryItems(dir)
for k, v in ipairs(files) do
local isdir = love.filesystem.isDirectory(dir.. "/" ..v)
if isdir == true then
table.insert(dirs, dir.. "/" ..v)
else
local parts = loveframes.util.SplitString(v, "([.])")
local extension = #parts > 1 and parts[#parts]
if #parts > 1 then
parts[#parts] = nil
end
local name = table.concat(parts, ".")
table.insert(t, {
path = dir,
fullpath = dir.. "/" ..v,
requirepath = dir:gsub("/", ".") .. "." ..name,
name = name,
extension = extension
})
end
end
for k, v in ipairs(dirs) do
t = loveframes.util.GetDirectoryContents(v, t)
end
return t
end
--[[---------------------------------------------------------
- func: Round(num, idp)
- desc: rounds a number based on the decimal limit
- note: I take no credit for this function
--]]---------------------------------------------------------
function loveframes.util.Round(num, idp)
local mult = 10^(idp or 0)
if num >= 0 then
return math.floor(num * mult + 0.5) / mult
else
return math.ceil(num * mult - 0.5) / mult
end
end
--[[---------------------------------------------------------
- func: SplitString(string, pattern)
- desc: splits a string into a table based on a given pattern
- note: I take no credit for this function
--]]---------------------------------------------------------
function loveframes.util.SplitString(str, pat)
local t = {} -- NOTE: use {n = 0} in Lua-5.0
if pat == " " then
local fpat = "(.-)" .. pat
local last_end = 1
local s, e, cap = str:find(fpat, 1)
while s do
if s ~= #str then
cap = cap .. " "
end
if s ~= 1 or cap ~= "" then
table.insert(t,cap)
end
last_end = e+1
s, e, cap = str:find(fpat, last_end)
end
if last_end <= #str then
cap = str:sub(last_end)
table.insert(t, cap)
end
else
local fpat = "(.-)" .. pat
local last_end = 1
local s, e, cap = str:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(t,cap)
end
last_end = e+1
s, e, cap = str:find(fpat, last_end)
end
if last_end <= #str then
cap = str:sub(last_end)
table.insert(t, cap)
end
end
return t
end
--[[---------------------------------------------------------
- func: RemoveAll()
- desc: removes all gui elements
--]]---------------------------------------------------------
function loveframes.util.RemoveAll()
loveframes.base.children = {}
loveframes.base.internals = {}
loveframes.hoverobject = false
loveframes.downobject = false
loveframes.modalobject = false
loveframes.inputobject = false
loveframes.hover = false
end
--[[---------------------------------------------------------
- func: TableHasValue(table, value)
- desc: checks to see if a table has a specific value
--]]---------------------------------------------------------
function loveframes.util.TableHasValue(table, value)
for k, v in pairs(table) do
if v == value then
return true
end
end
return false
end
--[[---------------------------------------------------------
- func: TableHasKey(table, key)
- desc: checks to see if a table has a specific key
--]]---------------------------------------------------------
function loveframes.util.TableHasKey(table, key)
return table[key] ~= nil
end
--[[---------------------------------------------------------
- func: Error(message)
- desc: displays a formatted error message
--]]---------------------------------------------------------
function loveframes.util.Error(message)
error("[Love Frames] " ..message)
end
--[[---------------------------------------------------------
- func: GetCollisionCount()
- desc: gets the total number of objects colliding with
the mouse
--]]---------------------------------------------------------
function loveframes.util.GetCollisionCount()
return loveframes.collisioncount
end
--[[---------------------------------------------------------
- func: GetHover()
- desc: returns loveframes.hover, can be used to check
if the mouse is colliding with a visible
Love Frames object
--]]---------------------------------------------------------
function loveframes.util.GetHover()
return loveframes.hover
end
--[[---------------------------------------------------------
- func: RectangleCollisionCheck(rect1, rect2)
- desc: checks for a collision between two rectangles
based on two tables containing rectangle sizes
and positions
--]]---------------------------------------------------------
function loveframes.util.RectangleCollisionCheck(rect1, rect2)
return loveframes.util.BoundingBox(rect1.x, rect2.x, rect1.y, rect2.y, rect1.width, rect2.width, rect1.height, rect2.height)
end
--[[---------------------------------------------------------
- func: DeepCopy(orig)
- desc: copies a table
- note: I take not credit for this function
--]]---------------------------------------------------------
function loveframes.util.DeepCopy(orig)
local orig_type = type(orig)
local copy
if orig_type == 'table' then
copy = {}
for orig_key, orig_value in next, orig, nil do
copy[loveframes.util.DeepCopy(orig_key)] = loveframes.util.DeepCopy(orig_value)
end
setmetatable(copy, loveframes.util.DeepCopy(getmetatable(orig)))
else -- number, string, boolean, etc
copy = orig
end
return copy
end
--[[---------------------------------------------------------
- func: GetHoverObject()
- desc: returns loveframes.hoverobject
--]]---------------------------------------------------------
function loveframes.util.GetHoverObject()
return loveframes.hoverobject
end
--[[---------------------------------------------------------
- func: IsCtrlDown()
- desc: checks for ctrl, for use with multiselect, copy,
paste, and such. On OS X it actually looks for cmd.
--]]---------------------------------------------------------
function loveframes.util.IsCtrlDown()
if love._os == "OS X" then
return love.keyboard.isDown("lmeta") or love.keyboard.isDown("rmeta") or
love.keyboard.isDown("lgui") or love.keyboard.isDown("rgui")
end
return love.keyboard.isDown("lctrl") or love.keyboard.isDown("rctrl")
end
| mit |
Andrettin/Wyrmsun | scripts/map_templates/nidavellir/heartfangs_foothills.lua | 1 | 1420 | -- _________ __ __
-- / _____// |_____________ _/ |______ ____ __ __ ______
-- \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
-- / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \
-- /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
-- \/ \/ \//_____/ \/
-- ______________________ ______________________
-- T H E W A R B E G I N S
-- Stratagus - A free fantasy real time strategy game engine
--
-- (c) Copyright 2017-2022 by Andrettin
--
-- 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
| gpl-2.0 |
Andrettin/Wyrmsun | scripts/languages/italic/french_loanwords.lua | 1 | 1894 | -- _________ __ __
-- / _____// |_____________ _/ |______ ____ __ __ ______
-- \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
-- / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \
-- /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
-- \/ \/ \//_____/ \/
-- ______________________ ______________________
-- T H E W A R B E G I N S
-- Stratagus - A free fantasy real time strategy game engine
--
-- (c) Copyright 2016-2022 by Andrettin
--
-- 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
DefineLanguageWord("Gourme", {
Language = "french",
Type = "noun",
Meanings = {"Strangles", "Strepcoccus equi"},
DerivesFrom = {"old-provencal", "noun", "Vorm"}, -- Source: http://www.cnrtl.fr/definition/gourme
Gender = "feminine"
})
DefineLanguageWord("Soldat", { -- Source: Carl D. Buck, "Words for 'Battle,' 'War,' 'Army,' and 'Soldier'", 1919, p. 17.
Language = "french",
Type = "noun",
Meanings = {"Soldier"},
DerivesFrom = {"italian", "noun", "Soldato"}
})
| gpl-2.0 |
TheAnswer/FirstTest | bin/scripts/object/tangible/lair/roba/objects.lua | 1 | 4633 | --Copyright (C) 2009 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
object_tangible_lair_roba_shared_lair_roba = SharedTangibleObjectTemplate:new {
appearanceFilename = "appearance/defaultappearance.apt",
arrangementDescriptorFilename = "",
certificationsRequired = {},
clearFloraRadius = 25,
clientDataFile = "clientdata/client_shared_lair_small.cdf",
collisionActionBlockFlags = 0,
collisionActionFlags = 51,
collisionActionPassFlags = 1,
collisionMaterialBlockFlags = 0,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 1,
customizationVariableMapping = {},
detailedDescription = "@lair_d:roba",
gameObjectType = 4,
locationReservationRadius = 0,
lookAtText = "string_id_table",
noBuildRadius = 64,
objectName = "@lair_n:roba",
onlyVisibleInTools = 0,
paletteColorCustomizationVariables = {},
portalLayoutFilename = "",
rangedIntCustomizationVariables = {},
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 1,
socketDestinations = {},
structureFootprintFileName = "",
surfaceType = 0,
targetable = 1,
useStructureFootprintOutline = 0
}
ObjectTemplates:addTemplate(object_tangible_lair_roba_shared_lair_roba, 636662941)
object_tangible_lair_roba_shared_lair_roba_grassland = SharedTangibleObjectTemplate:new {
appearanceFilename = "appearance/defaultappearance.apt",
arrangementDescriptorFilename = "",
certificationsRequired = {},
clearFloraRadius = 25,
clientDataFile = "clientdata/client_shared_lair_small.cdf",
collisionActionBlockFlags = 0,
collisionActionFlags = 51,
collisionActionPassFlags = 1,
collisionMaterialBlockFlags = 0,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 1,
customizationVariableMapping = {},
detailedDescription = "@lair_d:roba_grassland",
gameObjectType = 4,
locationReservationRadius = 0,
lookAtText = "string_id_table",
noBuildRadius = 64,
objectName = "@lair_n:roba_grassland",
onlyVisibleInTools = 0,
paletteColorCustomizationVariables = {},
portalLayoutFilename = "",
rangedIntCustomizationVariables = {},
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 1,
socketDestinations = {},
structureFootprintFileName = "",
surfaceType = 0,
targetable = 1,
useStructureFootprintOutline = 0
}
ObjectTemplates:addTemplate(object_tangible_lair_roba_shared_lair_roba_grassland, 4293395359)
| lgpl-3.0 |
trentapple/BetterUI | Modules/Store/Store.lua | 2 | 3144 | BUI_STORE_SCENE_NAME = "bui_gamepad_store"
BUI.Store.Buy = ZO_GamepadStoreBuy:Subclass()
function BUI.Store.Buy:New(...)
local object = ZO_GamepadStoreBuy.New(self, ...)
--object:Initialize(self, ...)
return object
end
function BUI.Store.Buy:Initialize(scene)
ZOS_GamepadStoreListComponent.Initialize(self, scene, ZO_MODE_STORE_BUY, GetString(SI_STORE_MODE_BUY))
self.fragment:RegisterCallback("StateChange", function(oldState, newState)
if newState == SCENE_SHOWING then
self:RegisterEvents()
self.list:UpdateList()
BUI.Store.Window:UpdateRightTooltip(self.list, ZO_MODE_STORE_BUY)
elseif newState == SCENE_HIDING then
self:UnregisterEvents()
GAMEPAD_TOOLTIPS:ClearTooltip(GAMEPAD_RIGHT_TOOLTIP)
end
end)
self:InitializeKeybindStrip()
self:CreateModeData(SI_STORE_MODE_BUY, ZO_MODE_STORE_BUY, "EsoUI/Art/Vendor/vendor_tabIcon_buy_up.dds", fragment, self.keybindStripDescriptor)
end
local function OnOpenStore()
if IsInGamepadPreferredMode() then
local componentTable = {}
if not IsStoreEmpty() then
table.insert(componentTable, ZO_MODE_STORE_BUY)
end
table.insert(componentTable, ZO_MODE_STORE_SELL)
table.insert(componentTable, ZO_MODE_STORE_BUY_BACK)
if CanStoreRepair() then
table.insert(componentTable, ZO_MODE_STORE_REPAIR)
end
BUI.Store.Window:SetActiveComponents(componentTable)
SCENE_MANAGER:Show(BUI_STORE_SCENE_NAME)
end
end
local function OnCloseStore()
if IsInGamepadPreferredMode() then
-- Ensure that all dialogs related to the store close on interaction end
ZO_Dialogs_ReleaseDialog("REPAIR_ALL")
SCENE_MANAGER:Hide(BUI_STORE_SCENE_NAME)
end
end
BUI.Store.Class = ZO_GamepadStoreManager:Subclass()
local DONT_ACTIVATE_LIST_ON_SHOW = false
function BUI.Store.Class:New(...)
return ZO_GamepadStoreManager.New(self, ...)
end
function BUI.Store.Class:Initialize(control)
self.control = control
self.sceneName = BUI_STORE_SCENE_NAME
BUI_STORE_SCENE = ZO_InteractScene:New(self.sceneName, SCENE_MANAGER, STORE_INTERACTION)
BUI_Gamepad_ParametricList_Screen:Initialize(control, true, DONT_ACTIVATE_LIST_ON_SHOW, BUI_STORE_SCENE)
self.spinner = control:GetNamedChild("SpinnerContainer")
self.spinner:InitializeSpinner()
self.control:RegisterForEvent(EVENT_OPEN_STORE, OnOpenStore)
self.control:RegisterForEvent(EVENT_CLOSE_STORE, OnCloseStore)
self:InitializeKeybindStrip()
self.components = {}
end
function BUI.Store.Class:SetActiveComponents(componentTable)
self.activeComponents = {}
ddebug("SetActiveComponents:")
d(componentTable)
ddebug("---------------------")
d(self.components)
for index, componentMode in ipairs(componentTable) do
local component = self.components[componentMode]
component:Refresh()
table.insert(self.activeComponents, component)
end
self:RebuildHeaderTabs()
end
function BUI.Store.Class:AddComponent(component)
self.components[component:GetStoreMode()] = component
end
| mit |
JarnoVgr/ZombieSurvival | gamemodes/zombiesurvival/entities/weapons/weapon_zs_basemelee/cl_init.lua | 1 | 7695 | include("shared.lua")
include("animations.lua")
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = false
SWEP.ViewModelFOV = 60
SWEP.ViewbobIntensity = 1
SWEP.ViewbobEnabled = true
SWEP.Slot = 0
SWEP.SlotPos = 0
SWEP.BlendPos = Vector(0, 0, 0)
SWEP.BlendAng = Vector(0, 0, 0)
SWEP.OldDelta = Angle(0, 0, 0)
SWEP.AngleDelta = Angle(0, 0, 0)
function SWEP:TranslateFOV(fov)
return GAMEMODE.FOVLerp * fov
end
function SWEP:DrawWeaponSelection(...)
return self:BaseDrawWeaponSelection(...)
end
function SWEP:DrawHUD()
if ENDROUND then
return
else
local SCREEN_W = 1920; --For the screen resolution scale. This means that it can be fit exactly on the screen without any issues.
local SCREEN_H = 1080;
local X_MULTIPLIER = ScrW( ) / 60 ;
local Y_MULTIPLIER = ScrH( ) / 80 ;
local cW, cH = ScrW() * 0.5, ScrH() * 0.5
surface.SetDrawColor( Color ( 188,183,153,30 ) )
surface.DrawLine(cW - X_MULTIPLIER, cH - 2, cW + X_MULTIPLIER, cH - 2)
surface.SetDrawColor( Color ( 188,183,153,160 ) )
surface.DrawLine(cW - X_MULTIPLIER, cH - 1, cW + X_MULTIPLIER, cH - 1)
surface.SetDrawColor( Color ( 188,183,153,160 ) )
surface.DrawLine(cW - X_MULTIPLIER, cH - 0, cW + X_MULTIPLIER, cH - 0)
surface.SetDrawColor( Color ( 188,183,153,30 ) )
surface.DrawLine(cW - X_MULTIPLIER, cH + 1, cW + X_MULTIPLIER, cH + 1)
surface.SetDrawColor( Color ( 188,183,153,50 ) )
surface.DrawLine(cW - 1, cH - Y_MULTIPLIER, cW - 1, cH + Y_MULTIPLIER)
surface.SetDrawColor( Color ( 188,183,153,130 ) )
surface.DrawLine(cW - 0, cH - Y_MULTIPLIER, cW - 0, cH + Y_MULTIPLIER)
surface.SetDrawColor( Color ( 188,183,153,50 ) )
surface.DrawLine(cW + 1, cH - Y_MULTIPLIER, cW + 1, cH + Y_MULTIPLIER)
end
end
function SWEP:OnRemove()
self:Anim_OnRemove()
end
function SWEP:ViewModelDrawn()
self:Anim_ViewModelDrawn()
end
local reg = debug.getregistry()
local Right = reg.Angle.Right
local Up = reg.Angle.Up
local Forward = reg.Angle.Forward
local RotateAroundAxis = reg.Angle.RotateAroundAxis
local GetVelocity = reg.Entity.GetVelocity
local Length = reg.Vector.Length
local Vec0 = Vector(0, 0, 0)
local TargetPos, TargetAng, cos1, sin1, tan, ws, rs, mod, vel, FT, sin2, delta
local SP = game.SinglePlayer()
local PosMod, AngMod = Vector(0, 0, 0), Vector(0, 0, 0)
local CurPosMod, CurAngMod = Vector(0, 0, 0), Vector(0, 0, 0)
function SWEP:PreDrawViewModel(vm)
if self.ShowViewModel == false then
render.SetBlend(0)
end
CT = UnPredictedCurTime()
vm = self.Owner:GetViewModel()
EA = EyeAngles()
FT = FrameTime()
delta = Angle(EA.p, EA.y, 0) - self.OldDelta
delta.p = math.Clamp(delta.p, -10, 10)
self.OldDelta = Angle(EA.p, EA.y, 0)
self.AngleDelta = LerpAngle(math.Clamp(FT * 10, 0, 1), self.AngleDelta, delta)
self.AngleDelta.y = math.Clamp(self.AngleDelta.y, -10, 10)
vel = Length(GetVelocity(self.Owner))
ws = self.Owner:GetWalkSpeed()
PosMod, AngMod = Vec0 * 1, Vec0 * 1
if vel < 10 or not self.Owner:OnGround() then
cos1, sin1 = math.cos(CT), math.sin(CT)
tan = math.atan(cos1 * sin1, cos1 * sin1)
AngMod.x = AngMod.x + tan * 1.15
AngMod.y = AngMod.y + cos1 * 0.4
AngMod.z = AngMod.z + tan
PosMod.y = PosMod.y + tan * 0.2
elseif vel > 10 and vel < ws * 1.2 then
mod = 6 + ws / 130
mul = math.Clamp(vel / ws, 0, 1)
sin1 = math.sin(CT * mod) * mul
cos1 = math.cos(CT * mod) * mul
tan1 = math.tan(sin1 * cos1) * mul
AngMod.x = AngMod.x + tan1
AngMod.y = AngMod.y - cos1
AngMod.z = AngMod.z + cos1
PosMod.x = PosMod.x - sin1 * 0.4
PosMod.y = PosMod.y + tan1 * 1
PosMod.z = PosMod.z + tan1 * 0.5
elseif (vel > ws * 1.2 and self.Owner:KeyDown(IN_SPEED)) or vel > ws * 3 then
rs = self.Owner:GetRunSpeed()
mod = 7 + math.Clamp(rs / 100, 0, 6)
mul = math.Clamp(vel / rs, 0, 1)
sin1 = math.sin(CT * mod) * mul
cos1 = math.cos(CT * mod) * mul
tan1 = math.tan(sin1 * cos1) * mul
AngMod.x = AngMod.x + tan1 * 0.2
AngMod.y = AngMod.y - cos1 * 1.5
AngMod.z = AngMod.z + cos1 * 3
PosMod.x = PosMod.x - sin1 * 1.2
PosMod.y = PosMod.y + tan1 * 1.5
PosMod.z = PosMod.z + tan1
end
FT = FrameTime()
CurPosMod = LerpVector(FT * 10, CurPosMod, PosMod)
CurAngMod = LerpVector(FT * 10, CurAngMod, AngMod)
end
function SWEP:PostDrawViewModel(vm)
if self.ShowViewModel == false then
render.SetBlend(1)
end
end
local wm, pos, ang
local GetBonePosition = debug.getregistry().Entity.GetBonePosition
function SWEP:DrawWorldModel()
local owner = self:GetOwner()
if owner:IsValid() and owner.ShadowMan then return end
if (self.ShowWorldModel == nil or self.ShowWorldModel) then
if self.DrawTraditionalWorldModel then
self:DrawModel()
else
wm = self.WMEnt
if IsValid(wm) then
if IsValid(owner) then
pos, ang = GetBonePosition(owner, owner:LookupBone("ValveBiped.Bip01_R_Hand"))
if pos and ang then
RotateAroundAxis(ang, Right(ang), self.WMAng[1])
RotateAroundAxis(ang, Up(ang), self.WMAng[2])
RotateAroundAxis(ang, Forward(ang), self.WMAng[3])
pos = pos + self.WMPos[1] * Right(ang)
pos = pos + self.WMPos[2] * Forward(ang)
pos = pos + self.WMPos[3] * Up(ang)
wm:SetRenderOrigin(pos)
wm:SetRenderAngles(ang)
wm:DrawModel()
end
else
wm:SetRenderOrigin(self:GetPos())
wm:SetRenderAngles(self:GetAngles())
wm:DrawModel()
wm:DrawShadow()
end
else
self:DrawModel()
end
end
end
self:Anim_DrawWorldModel()
end
local Ang0, curang, curviewbob = Angle(0, 0, 0), Angle(0, 0, 0), Angle(0, 0, 0)
function SWEP:CalcView(ply, pos, ang, fov)
FT, CT = FrameTime(), CurTime()
if self.ViewbobEnabled then
ws = self.Owner:GetWalkSpeed()
vel = Length(GetVelocity(self.Owner))
if self.Owner:OnGround() and vel > ws * 0.3 then
if vel < ws * 1.2 then
cos1 = math.cos(CT * 15)
cos2 = math.cos(CT * 12)
curviewbob.p = cos1 * 0.15
curviewbob.y = cos2 * 0.1
else
cos1 = math.cos(CT * 20)
cos2 = math.cos(CT * 15)
curviewbob.p = cos1 * 0.25
curviewbob.y = cos2 * 0.15
end
else
curviewbob = LerpAngle(FT * 10, curviewbob, Ang0)
end
end
return pos, ang + curviewbob * self.ViewbobIntensity, fov
end
local ghostlerp = 0
function SWEP:GetViewModelPosition(pos, ang)
if self:IsSwinging() then
local rot = self.SwingRotation
local offset = self.SwingOffset
ang = Angle(ang.pitch, ang.yaw, ang.roll) -- Copy
local swingend = self:GetSwingEnd()
local delta = self.SwingTime - math.Clamp(swingend - CurTime(), 0, self.SwingTime)
local power = CosineInterpolation(0, 1, delta / self.SwingTime)
if power >= 0.9 then
power = (1 - power) ^ 0.4 * 2
end
pos = pos + offset.x * power * ang:Right() + offset.y * power * ang:Forward() + offset.z * power * ang:Up()
ang:RotateAroundAxis(ang:Right(), rot.pitch * power)
ang:RotateAroundAxis(ang:Up(), rot.yaw * power)
ang:RotateAroundAxis(ang:Forward(), rot.roll * power)
end
if self.Owner:GetBarricadeGhosting() then
ghostlerp = math.min(1, ghostlerp + FrameTime() * 4)
elseif ghostlerp > 0 then
ghostlerp = math.max(0, ghostlerp - FrameTime() * 5)
end
if ghostlerp > 0 then
pos = pos + 3.5 * ghostlerp * ang:Up()
ang:RotateAroundAxis(ang:Right(), -30 * ghostlerp)
end
RotateAroundAxis(ang, Right(ang), CurAngMod.x + self.AngleDelta.p)
RotateAroundAxis(ang, Up(ang), CurAngMod.y + self.AngleDelta.y * 0.3)
RotateAroundAxis(ang, Forward(ang), CurAngMod.z + self.AngleDelta.y * 0.3)
pos = pos + (CurPosMod.x + self.AngleDelta.y * 0.1) * Right(ang)
pos = pos + (CurPosMod.y + self.BlendPos.y) * Forward(ang)
pos = pos + (CurPosMod.z + self.BlendPos.z - self.AngleDelta.p * 0.1) * Up(ang)
return pos, ang
end
| gpl-2.0 |
TheAnswer/FirstTest | bin/scripts/crafting/objects/draftschematics/armorsmith/personalArmorIChitin/chitinArmorGloves.lua | 1 | 5207 | --Copyright (C) 2009 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
chitinArmorGloves = Object:new {
objectName = "Chitin Armor Gloves",
stfName = "armor_chitin_s01_gloves",
stfFile = "wearables_name",
objectCRC = 2306152409,
groupName = "craftArmorPersonalGroupB", -- Group schematic is awarded in (See skills table)
craftingToolTab = 2, -- (See DraftSchemticImplementation.h)
complexity = 25,
size = 3,
xpType = "crafting_clothing_armor",
xp = 110,
assemblySkill = "armor_assembly",
experimentingSkill = "armor_experimentation",
ingredientTemplateNames = "craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n, craft_clothing_ingredients_n",
ingredientTitleNames = "auxilary_coverage, body, liner, hardware_and_attachments, binding_and_reinforcement, padding, armor, load_bearing_harness, reinforcement",
ingredientSlotType = "0, 0, 0, 0, 0, 0, 2, 2, 2",
resourceTypes = "bone, hide_leathery, hide_scaley, metal_ferrous, petrochem_inert_polymer, hide_wooly, object/tangible/component/armor/shared_armor_segment_chitin.iff, object/tangible/component/clothing/shared_fiberplast_panel.iff, object/tangible/component/clothing/shared_reinforced_fiber_panels.iff",
resourceQuantities = "15, 15, 15, 5, 5, 5, 1, 1, 1",
combineTypes = "0, 0, 0, 0, 0, 0, 1, 1, 1",
contribution = "100, 100, 100, 100, 100, 100, 100, 100, 100",
numberExperimentalProperties = "1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 2, 1",
experimentalProperties = "XX, XX, XX, OQ, SR, OQ, SR, OQ, UT, MA, OQ, MA, OQ, MA, OQ, XX, XX, OQ, SR, XX",
experimentalWeights = "1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1",
experimentalGroupTitles = "null, null, null, null, exp_quality, exp_durability, exp_durability, exp_durability, exp_durability, null, null, exp_resistance, null",
experimentalSubGroupTitles = "null, null, sockets, hit_points, armor_effectiveness, armor_integrity, armor_health_encumbrance, armor_action_encumbrance, armor_mind_encumbrance, armor_rating, armor_special_type, armor_special_effectiveness, armor_special_integrity",
experimentalMin = "0, 0, 0, 1000, 5, 15000, 13, 25, 16, 1, 1, 5, 15000",
experimentalMax = "0, 0, 0, 1000, 30, 25000, 8, 15, 9, 1, 1, 40, 25000",
experimentalPrecision = "0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0",
tanoAttributes = "objecttype=262:objectcrc=2662099985:stfFile=wearables_name:stfName=armor_chitin_s01_gloves:stfDetail=:itemmask=62975:customattributes=specialprotection=kineticeffectiveness;vunerability=stuneffectiveness,heateffectiveness,coldeffectiveness,restraineffectiveness;armorPiece=257;armorStyle=4102;:",
blueFrogAttributes = "",
blueFrogEnabled = False,
customizationOptions = "/private/index_color_0, /private/index_color_1",
customizationDefaults = "0, 6",
customizationSkill = "armor_customization"
}
DraftSchematics:addDraftSchematic(chitinArmorGloves, 2306152409)--- Add to global DraftSchematics table
| lgpl-3.0 |
TheAnswer/FirstTest | bin/scripts/object/tangible/lair/pharple/objects.lua | 1 | 4670 | --Copyright (C) 2009 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
object_tangible_lair_pharple_shared_lair_pharple = SharedTangibleObjectTemplate:new {
appearanceFilename = "appearance/defaultappearance.apt",
arrangementDescriptorFilename = "",
certificationsRequired = {},
clearFloraRadius = 25,
clientDataFile = "clientdata/client_shared_lair_small.cdf",
collisionActionBlockFlags = 0,
collisionActionFlags = 51,
collisionActionPassFlags = 1,
collisionMaterialBlockFlags = 0,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 1,
customizationVariableMapping = {},
detailedDescription = "@lair_d:pharple",
gameObjectType = 4,
locationReservationRadius = 0,
lookAtText = "string_id_table",
noBuildRadius = 64,
objectName = "@lair_n:pharple",
onlyVisibleInTools = 0,
paletteColorCustomizationVariables = {},
portalLayoutFilename = "",
rangedIntCustomizationVariables = {},
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 1,
socketDestinations = {},
structureFootprintFileName = "",
surfaceType = 0,
targetable = 1,
useStructureFootprintOutline = 0
}
ObjectTemplates:addTemplate(object_tangible_lair_pharple_shared_lair_pharple, 3003958462)
object_tangible_lair_pharple_shared_lair_pharple_wasteland = SharedTangibleObjectTemplate:new {
appearanceFilename = "appearance/defaultappearance.apt",
arrangementDescriptorFilename = "",
certificationsRequired = {},
clearFloraRadius = 25,
clientDataFile = "clientdata/client_shared_lair_small.cdf",
collisionActionBlockFlags = 0,
collisionActionFlags = 51,
collisionActionPassFlags = 1,
collisionMaterialBlockFlags = 0,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 1,
customizationVariableMapping = {},
detailedDescription = "@lair_d:pharple_wasteland",
gameObjectType = 4,
locationReservationRadius = 0,
lookAtText = "string_id_table",
noBuildRadius = 64,
objectName = "@lair_n:pharple_wasteland",
onlyVisibleInTools = 0,
paletteColorCustomizationVariables = {},
portalLayoutFilename = "",
rangedIntCustomizationVariables = {},
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 1,
socketDestinations = {},
structureFootprintFileName = "",
surfaceType = 0,
targetable = 1,
useStructureFootprintOutline = 0
}
ObjectTemplates:addTemplate(object_tangible_lair_pharple_shared_lair_pharple_wasteland, 4033646950)
| lgpl-3.0 |
JarnoVgr/ZombieSurvival | gamemodes/zombiesurvival/gamemode/modules/admin_mod/sv_duby.lua | 1 | 2157 | --[[ Special Commands Just For me To Enjoy ]]--
--[[ I Spent 8 Months Coding This, I'm Allowed To Have Fun Sometimes! :P ]]--
--[[ DEBUG MESSAGES ]]--
util.AddNetworkString( "Debug" )
util.AddNetworkString( "Debug_2" )
util.AddNetworkString( "Debug_3" )
util.AddNetworkString( "Debug_4" )
util.AddNetworkString( "Debug_5" )
util.AddNetworkString( "Debug_6" )
util.AddNetworkString( "Debug_7" )
util.AddNetworkString( "Debug_8" )
util.AddNetworkString( "hentai" )
util.AddNetworkString( "slowmo_debug" )
util.AddNetworkString( "Clavus" )
net.Receive( "Clavus", function( len, pl )
pl:Give("weapon_zs_hegrenade")
pl:Give("weapon_zs_flakcannon")
pl:Give("weapon_zs_cerebralbore")
pl:Give("weapon_zs_proxmines")
end )
net.Receive( "Debug", function( len, pl )
pl:Give("admin_raverifle")
end )
net.Receive( "Debug_2", function( len, pl )
pl:Give("admin_tool_igniter")
end )
net.Receive( "Debug_3", function( len, pl )
pl:Give("admin_tool_remover")
end )
net.Receive( "Debug_4", function( len, pl )
pl:Give("swep_construction_kit")
end )
net.Receive( "Debug_5", function( len, pl )
pl:Give("weapon_zs_hate")
end )
net.Receive( "Debug_6", function( len, pl )
pl:SetRenderMode(RENDERMODE_NONE) pl:SetColor(Color(225,225,225,1))
timer.Simple(5, function()
pl:SetRenderMode(RENDERMODE_NORMAL) pl:SetColor(Color(225,225,225,225))
end)
net.Start( "hentai" )
net.Broadcast()
end )
net.Receive( "Debug_7", function( len, pl )
pl:AddPoints(1000)
end )
net.Receive( "Debug_8", function( len, pl )
game.SetTimeScale(0.35)
timer.Simple(0.9, function() game.SetTimeScale(1) end)
net.Start( "slowmo_debug" )
net.Broadcast()
timer.Simple(0.01,function()
hook.Add("RenderScreenspaceEffects", "Slowmo",Slowmo)
end)
local slowmo_tab = {}
slowmo_tab[ "$pp_colour_colour" ] = 0.20
slowmo_tab[ "$pp_colour_contrast" ] = 1
slowmo_tab[ "$pp_colour_mulr" ] = 0.1
slowmo_tab[ "$pp_colour_mulg" ] = 0.02
slowmo_tab[ "$pp_colour_mulb" ] = 0
function Slowmo()
DrawColorModify(slowmo_tab)
end
function SlowmoEnd(um)
hook.Remove("RenderScreenspaceEffects", "Slowmo")
end
end ) | gpl-2.0 |
TheAnswer/FirstTest | bin/scripts/slashcommands/generic/healPet.lua | 1 | 2523 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
--true = 1, false = 0
HealPetSlashCommand = {
name = "healpet",
alternativeNames = "",
animation = "",
invalidStateMask = 3894542352, --alert, frozen, glowingJedi, ridingMount, pilotingShip, shipOperations, shipGunner,
invalidPostures = "2,5,7,9,10,11,12,13,14,4,",
target = 2,
targeType = 1,
disabled = 0,
maxRangeToTarget = 0,
--adminLevel = 0,
addToCombatQueue = 1,
}
AddHealPetSlashCommand(HealPetSlashCommand)
| lgpl-3.0 |
ftpvanmaanen/esp8266 | tools/LuaLoader/examples/httpget.lua | 2 | 1262 | -- tested on NodeMCU 0.9.5 build 20141222...20150108
-- sends connection time and heap size to http://benlo.com/esp8266/test.php
print('httpget.lua started')
Tstart = tmr.now()
conn = nil
conn=net.createConnection(net.TCP, 0)
-- show the retrieved web page
conn:on("receive", function(conn, payload)
success = true
print(payload)
end)
-- when connected, request page (send parameters to a script)
conn:on("connection", function(conn, payload)
print('\nConnected')
conn:send("GET /esp8266/test.php?"
.."T="..(tmr.now()-Tstart)
.."&heap="..node.heap()
.." HTTP/1.1\r\n"
.."Host: benlo.com\r\n"
.."Connection: close\r\n"
.."Accept: */*\r\n"
.."User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n"
.."\r\n")
end)
-- when disconnected, let it be known
conn:on("disconnection", function(conn, payload) print('\nDisconnected') end)
conn:connect(80,'benlo.com')
| gpl-2.0 |
ruphy/tagua | data/themes/pieces/ShogiSVG-TTF/theme.lua | 1 | 3976 | import("piece_theme.lua")
import("shogi_themelib.lua")
shadow=7.0
shadow_color="#404050"
shadow_offset_x=6
shadow_offset_y=4
shadow_grow=5
fontnames = {"Potraced from ???"} --, "Potraced from shogi.net"}
fontlist = {"Shogi.ttf"} -- , "Shogi2.ttf"}
theme.options = OptList {
BoolOpt("moves_overlay", "Moves overlay", true),
SelectOpt("symbols", "Symbol set", BoolOptList {
BoolOpt("use_predefined", "Predefined", true, OptList {
ComboOpt("font", "Symbol set", fontnames)
}),
BoolOpt("use_custom", "Custom font", false, OptList {
UrlOpt("file", "SVG glyph directory", "Shogi.ttf")
}),
-- BoolOpt("use_system", "System font", false, OptList {
-- FontOpt("font", "System font", Font("Arial", true, true))
-- }),
})
}
function addChar(char, promoted)
return function(i, size)
i:draw_glyph(Rect(0,0,size,size),
theme.options.symbols.options.use_predefined.value
and fontlist[theme.options.symbols.options.use_predefined.sub_options.font.selected+1]
or theme.options.symbols.options.use_custom.value
and theme.options.symbols.options.use_custom.sub_options.file.value
or theme.options.symbols.options.use_system.sub_options.font.selected,
char, promoted and "#d00000" or "#004000",
"#fff3c8", 4, false)
return i
end
end
function shogi_piece(char, white, promoted, ratio, moves)
return addShadow(overlay(tile(white, ratio),
shogi_moves(moves),
addChar(char, promoted)))
end
theme.black_king = shogi_piece("0x6B", false, false, 1, shogimoves_king)
theme.black_rook = shogi_piece("0x72", false, false, 0.96, shogimoves_rook)
theme.black_p_rook = shogi_piece("0x52", false, true, 0.96, shogimoves_dragon)
theme.black_bishop = shogi_piece("0x62", false, false, 0.93, shogimoves_bishop)
theme.black_p_bishop = shogi_piece("0x42", false, true, 0.93, shogimoves_horse)
theme.black_gold = shogi_piece("0x67", false, false, 0.9, shogimoves_gold)
theme.black_silver = shogi_piece("0x73", false, false, 0.9, shogimoves_silver)
theme.black_p_silver = shogi_piece("0x53", false, true, 0.9, shogimoves_gold)
theme.black_knight = shogi_piece("0x68", false, false, 0.86, shogimoves_knight)
theme.black_p_knight = shogi_piece("0x48", false, true, 0.86, shogimoves_gold)
theme.black_lance = shogi_piece("0x6C", false, false, 0.83, shogimoves_lance)
theme.black_p_lance = shogi_piece("0x4C", false, true, 0.83, shogimoves_gold)
theme.black_pawn = shogi_piece("0x70", false, false, 0.8, shogimoves_pawn)
theme.black_p_pawn = shogi_piece("0x50", false, true, 0.8, shogimoves_gold)
theme.white_king = shogi_piece("0x6B", true, false, 1, shogimoves_king)
theme.white_rook = shogi_piece("0x72", true, false, 0.96, shogimoves_rook)
theme.white_p_rook = shogi_piece("0x52", true, true, 0.96, shogimoves_dragon)
theme.white_bishop = shogi_piece("0x62", true, false, 0.93, shogimoves_bishop)
theme.white_p_bishop = shogi_piece("0x42", true, true, 0.93, shogimoves_horse)
theme.white_gold = shogi_piece("0x67", true, false, 0.9, shogimoves_gold)
theme.white_silver = shogi_piece("0x73", true, false, 0.9, shogimoves_silver)
theme.white_p_silver = shogi_piece("0x53", true, true, 0.9, shogimoves_gold)
theme.white_knight = shogi_piece("0x68", true, false, 0.86, shogimoves_knight)
theme.white_p_knight = shogi_piece("0x48", true, true, 0.86, shogimoves_gold)
theme.white_lance = shogi_piece("0x6C", true, false, 0.83, shogimoves_lance)
theme.white_p_lance = shogi_piece("0x4C", true, true, 0.83, shogimoves_gold)
theme.white_pawn = shogi_piece("0x70", true, false, 0.8, shogimoves_pawn)
theme.white_p_pawn = shogi_piece("0x50", true, true, 0.8, shogimoves_gold)
-- To be able to adapt this theme to chess too
-- FIXME: should find a FreeKing kanji instead
theme.black_queen = shogi_piece("0x67", false, false, 1, shogimoves_freeking)
theme.white_queen = shogi_piece("0x67", true, false, 1, shogimoves_freeking)
| gpl-2.0 |
ivendrov/rnn | FastLSTM.lua | 6 | 2630 | local FastLSTM, parent = torch.class("nn.FastLSTM", "nn.LSTM")
function FastLSTM:__init(inputSize, outputSize, rho)
parent.__init(self, inputSize, outputSize, rho, false)
end
function FastLSTM:buildModel()
-- input : {input, prevOutput, prevCell}
-- output : {output, cell}
-- Calculate all four gates in one go : input, hidden, forget, output
self.i2g = nn.Linear(self.inputSize, 4*self.outputSize)
self.o2g = nn.LinearNoBias(self.outputSize, 4*self.outputSize)
local para = nn.ParallelTable():add(self.i2g):add(self.o2g)
local gates = nn.Sequential()
gates:add(nn.NarrowTable(1,2))
gates:add(para)
gates:add(nn.CAddTable())
-- Reshape to (batch_size, n_gates, hid_size)
-- Then slize the n_gates dimension, i.e dimension 2
gates:add(nn.Reshape(4,self.outputSize))
gates:add(nn.SplitTable(1,2))
local transfer = nn.ParallelTable()
transfer:add(nn.Sigmoid()):add(nn.Tanh()):add(nn.Sigmoid()):add(nn.Sigmoid())
gates:add(transfer)
local concat = nn.ConcatTable()
concat:add(gates):add(nn.SelectTable(3))
local seq = nn.Sequential()
seq:add(concat)
seq:add(nn.FlattenTable()) -- input, hidden, forget, output, cell
-- input gate * hidden state
local hidden = nn.Sequential()
hidden:add(nn.NarrowTable(1,2))
hidden:add(nn.CMulTable())
-- forget gate * cell
local cell = nn.Sequential()
local concat = nn.ConcatTable()
concat:add(nn.SelectTable(3)):add(nn.SelectTable(5))
cell:add(concat)
cell:add(nn.CMulTable())
local nextCell = nn.Sequential()
local concat = nn.ConcatTable()
concat:add(hidden):add(cell)
nextCell:add(concat)
nextCell:add(nn.CAddTable())
local concat = nn.ConcatTable()
concat:add(nextCell):add(nn.SelectTable(4))
seq:add(concat)
seq:add(nn.FlattenTable()) -- nextCell, outputGate
local cellAct = nn.Sequential()
cellAct:add(nn.SelectTable(1))
cellAct:add(nn.Tanh())
local concat = nn.ConcatTable()
concat:add(cellAct):add(nn.SelectTable(2))
local output = nn.Sequential()
output:add(concat)
output:add(nn.CMulTable())
local concat = nn.ConcatTable()
concat:add(output):add(nn.SelectTable(1))
seq:add(concat)
return seq
end
function FastLSTM:buildGate()
error"Not Implemented"
end
function FastLSTM:buildInputGate()
error"Not Implemented"
end
function FastLSTM:buildForgetGate()
error"Not Implemented"
end
function FastLSTM:buildHidden()
error"Not Implemented"
end
function FastLSTM:buildCell()
error"Not Implemented"
end
function FastLSTM:buildOutputGate()
error"Not Implemented"
end
| bsd-3-clause |
TheAnswer/FirstTest | bin/scripts/object/static/structure/dantooine/objects.lua | 1 | 43919 | --Copyright (C) 2009 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
object_static_structure_dantooine_shared_dant_boundary_post = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_boundary_post.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 1
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_boundary_post, 2924198126)
object_static_structure_dantooine_shared_dant_cooking_stone = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_cooking_stone.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 1
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_cooking_stone, 1600616690)
object_static_structure_dantooine_shared_dant_fence_4m = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_fence_4m.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 3
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_fence_4m, 1600034556)
object_static_structure_dantooine_shared_dant_fence_8m = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_fence_8m.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 3
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_fence_8m, 3938371804)
object_static_structure_dantooine_shared_dant_fire_pit = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_fire_pit.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 1
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_fire_pit, 4033600287)
object_static_structure_dantooine_shared_dant_fish_rack = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_fish.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 1
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_fish_rack, 440746262)
object_static_structure_dantooine_shared_dant_gate = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_gate.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 3
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_gate, 7139239)
object_static_structure_dantooine_shared_dant_hide_tanning_s01 = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_hide_tanning_s01.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 1
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_hide_tanning_s01, 2151826436)
object_static_structure_dantooine_shared_dant_hide_tanning_s02 = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_hide_tanning_s02.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 1
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_hide_tanning_s02, 1532357779)
object_static_structure_dantooine_shared_dant_imprv_bannerpole_s01 = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/mun_corl_imprv_bannerpole_s01.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "clientdata/structure/dant_imprv_bannerpole_s01.cdf",
collisionActionBlockFlags = 0,
collisionActionFlags = 0,
collisionActionPassFlags = 1,
collisionMaterialBlockFlags = 0,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "",
gameObjectType = 5,
lookAtText = "",
noBuildRadius = 1,
objectName = "@item_n:banner_corellia",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 0,
scaleThresholdBeforeExtentTest = 0,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 1
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_imprv_bannerpole_s01, 2238403752)
object_static_structure_dantooine_shared_dant_imprv_flagpole_s01 = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/mun_corl_imprv_flagpole_s01.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "clientdata/structure/dant_imprv_flagpole_s01.cdf",
collisionActionBlockFlags = 0,
collisionActionFlags = 0,
collisionActionPassFlags = 1,
collisionMaterialBlockFlags = 0,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "",
gameObjectType = 5,
lookAtText = "",
noBuildRadius = 1,
objectName = "@item_n:flag_corellia",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 0,
scaleThresholdBeforeExtentTest = 0,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 1
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_imprv_flagpole_s01, 3453851559)
object_static_structure_dantooine_shared_dant_jedi_main_structure = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_jedi_main.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_jedi_main_structure, 3200541181)
object_static_structure_dantooine_shared_dant_jedi_temple_altar = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_jedi_temple_altar.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_jedi_temple_altar, 3549254078)
object_static_structure_dantooine_shared_dant_jedi_temple_pillar = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_jedi_temple_pillar.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_jedi_temple_pillar, 3410738140)
object_static_structure_dantooine_shared_dant_jedi_temple_pillar_base = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_jedi_temple_pillar_base.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_jedi_temple_pillar_base, 3737353832)
object_static_structure_dantooine_shared_dant_jedi_temple_pillar_fallen = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_jedi_temple_pillar_fallen.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_jedi_temple_pillar_fallen, 1808475957)
object_static_structure_dantooine_shared_dant_jedi_temple_pillar_med = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_jedi_temple_pillar_med.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_jedi_temple_pillar_med, 4036421930)
object_static_structure_dantooine_shared_dant_jedi_temple_pillar_sm = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_jedi_temple_pillar_sm.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_jedi_temple_pillar_sm, 1127667832)
object_static_structure_dantooine_shared_dant_jedi_wall_1 = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_jedi_wall_1.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_jedi_wall_1, 3556125150)
object_static_structure_dantooine_shared_dant_jedi_wall_2 = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_jedi_wall_2.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_jedi_wall_2, 148996425)
object_static_structure_dantooine_shared_dant_large_communal = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_large_communal.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_large_communal, 2822062306)
object_static_structure_dantooine_shared_dant_large_communal_dest = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_large_rock_communal_dest_s01.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 15,
clientDataFile = "clientdata/fs_village/client_shared_fs_village_communal_dest.cdf",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:damaged wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:damaged wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_large_communal_dest, 888416774)
object_static_structure_dantooine_shared_dant_large_communal_no_flora_10m = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_large_communal.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 15,
clientDataFile = "clientdata/building/shared_generic_flora_clearing_15m.cdf",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_large_communal_no_flora_10m, 5395298)
object_static_structure_dantooine_shared_dant_large_hut = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_large_hut.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_large_hut, 3738317565)
object_static_structure_dantooine_shared_dant_large_hut_no_flora_10m = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_large_hut.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 15,
clientDataFile = "clientdata/building/shared_generic_flora_clearing_15m.cdf",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_large_hut_no_flora_10m, 2953965200)
object_static_structure_dantooine_shared_dant_large_mudhut = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_large_mudhut.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_large_mudhut, 3375506333)
object_static_structure_dantooine_shared_dant_large_mudhut_no_flora_05m = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_large_mudhut.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 10,
clientDataFile = "clientdata/building/shared_generic_flora_clearing_10m.cdf",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_large_mudhut_no_flora_05m, 3829973531)
object_static_structure_dantooine_shared_dant_large_rock_hut = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_large_rock_hut.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_large_rock_hut, 1876585046)
object_static_structure_dantooine_shared_dant_large_rock_hut_dest = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_large_rock_hut_dest_s01.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 10,
clientDataFile = "clientdata/fs_village/client_shared_fs_village_rock_hut_dest.cdf",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_large_rock_hut_dest, 2097574138)
object_static_structure_dantooine_shared_dant_large_rock_hut_dest_01 = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_large_rock_hut_dest_s01.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 10,
clientDataFile = "clientdata/fs_village/client_shared_fs_village_rock_hut_dest_01.cdf",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_large_rock_hut_dest_01, 2552639748)
object_static_structure_dantooine_shared_dant_large_rock_hut_dest_02 = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_large_rock_hut_dest_s01.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 10,
clientDataFile = "clientdata/fs_village/client_shared_fs_village_rock_hut_dest_02.cdf",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_large_rock_hut_dest_02, 1127324051)
object_static_structure_dantooine_shared_dant_large_rock_hut_dest_03 = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_large_rock_hut_dest_s01.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 10,
clientDataFile = "clientdata/fs_village/client_shared_fs_village_rock_hut_dest_03.cdf",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_large_rock_hut_dest_03, 171769374)
object_static_structure_dantooine_shared_dant_large_rock_hut_no_flora_05m = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_large_rock_hut.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 10,
clientDataFile = "clientdata/building/shared_generic_flora_clearing_10m.cdf",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_large_rock_hut_no_flora_05m, 1673544289)
object_static_structure_dantooine_shared_dant_mud_oven = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_mud_oven.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_mud_oven, 2326141197)
object_static_structure_dantooine_shared_dant_rack_spears = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_rack_spears.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 3
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_rack_spears, 2133865913)
object_static_structure_dantooine_shared_dant_skull_bol = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_bol_skull.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_skull_bol, 3964846407)
object_static_structure_dantooine_shared_dant_skull_lizard = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_lizard_skull.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_skull_lizard, 3296364307)
object_static_structure_dantooine_shared_dant_skull_thune = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_thune_skull.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_skull_thune, 2732329939)
object_static_structure_dantooine_shared_dant_small_mudhut = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_small_mudhut.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 2
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_small_mudhut, 4250788493)
object_static_structure_dantooine_shared_dant_totem_pole = SharedStaticObjectTemplate:new {
appearanceFilename = "appearance/thm_dant_totem_pole.apt",
arrangementDescriptorFilename = "",
clearFloraRadius = 0,
clientDataFile = "",
collisionActionBlockFlags = 255,
collisionActionFlags = 1,
collisionActionPassFlags = 0,
collisionMaterialBlockFlags = 1,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 0,
detailedDescription = "@string_table:pristine wall",
gameObjectType = 5,
locationReservationRadius = 0,
lookAtText = "@string_table:pristine wall",
noBuildRadius = 0,
objectName = "@obj_n:unknown_object",
onlyVisibleInTools = 0,
portalLayoutFilename = "",
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 0,
surfaceType = 3
}
ObjectTemplates:addTemplate(object_static_structure_dantooine_shared_dant_totem_pole, 880635575)
| lgpl-3.0 |
TheAnswer/FirstTest | bin/scripts/items/objects/pharmaceutical/curepacks/areaDiseaseCureC.lua | 1 | 2480 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
areaDiseaseCureC = Object:new {
objectName = "Area Cure Disease Medpack - C",
templateName = "object/tangible/medicine/crafted/shared_medpack_cure_disease_area_c.iff",
objectCRC = "2512470651",
objectType = PHARMACEUTICAL,
medpackType = CUREPACK,
usesRemaining = 37,
medicineUse = 62,
effectiveness = 413,
area = 8,
conditionCured = DISEASED
}
| lgpl-3.0 |
badboyam/redstorm | plugins/inrealm.lua | 287 | 25005 | -- data saved to moderation.json
-- check moderation plugin
do
local function create_group(msg)
-- superuser and admins only (because sudo are always has privilege)
if is_sudo(msg) or is_realm(msg) and is_admin(msg) then
local group_creator = msg.from.print_name
create_group_chat (group_creator, group_name, ok_cb, false)
return 'Group [ '..string.gsub(group_name, '_', ' ')..' ] has been created.'
end
end
local function create_realm(msg)
-- superuser and admins only (because sudo are always has privilege)
if is_sudo(msg) or is_realm(msg) and is_admin(msg) then
local group_creator = msg.from.print_name
create_group_chat (group_creator, group_name, ok_cb, false)
return 'Realm [ '..string.gsub(group_name, '_', ' ')..' ] has been created.'
end
end
local function killchat(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function killrealm(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
for k,v in pairs(result.members) do
kick_user_any(v.id, result.id)
end
end
local function get_group_type(msg)
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
if not data[tostring(msg.to.id)]['group_type'] then
return 'No group type available.'
end
local group_type = data[tostring(msg.to.id)]['group_type']
return group_type
else
return 'Chat type not found.'
end
end
local function callbackres(extra, success, result)
--vardump(result)
local user = result.id
local name = string.gsub(result.print_name, "_", " ")
local chat = 'chat#id'..extra.chatid
send_large_msg(chat, user..'\n'..name)
return user
end
local function set_description(msg, data, target, about)
if not is_admin(msg) then
return "For admins only!"
end
local data_cat = 'description'
data[tostring(target)][data_cat] = about
save_data(_config.moderation.data, data)
return 'Set group description to:\n'..about
end
local function set_rules(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local data_cat = 'rules'
data[tostring(target)][data_cat] = rules
save_data(_config.moderation.data, data)
return 'Set group rules to:\n'..rules
end
-- lock/unlock group name. bot automatically change group name when locked
local function lock_group_name(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'yes' then
return 'Group name is already locked'
else
data[tostring(target)]['settings']['lock_name'] = 'yes'
save_data(_config.moderation.data, data)
rename_chat('chat#id'..target, group_name_set, ok_cb, false)
return 'Group name has been locked'
end
end
local function unlock_group_name(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'no' then
return 'Group name is already unlocked'
else
data[tostring(target)]['settings']['lock_name'] = 'no'
save_data(_config.moderation.data, data)
return 'Group name has been unlocked'
end
end
--lock/unlock group member. bot automatically kick new added user when locked
local function lock_group_member(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'yes' then
return 'Group members are already locked'
else
data[tostring(target)]['settings']['lock_member'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Group members has been locked'
end
local function unlock_group_member(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'no' then
return 'Group members are not locked'
else
data[tostring(target)]['settings']['lock_member'] = 'no'
save_data(_config.moderation.data, data)
return 'Group members has been unlocked'
end
end
--lock/unlock group photo. bot automatically keep group photo when locked
local function lock_group_photo(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'yes' then
return 'Group photo is already locked'
else
data[tostring(target)]['settings']['set_photo'] = 'waiting'
save_data(_config.moderation.data, data)
end
return 'Please send me the group photo now'
end
local function unlock_group_photo(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'no' then
return 'Group photo is not locked'
else
data[tostring(target)]['settings']['lock_photo'] = 'no'
save_data(_config.moderation.data, data)
return 'Group photo has been unlocked'
end
end
local function lock_group_flood(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'yes' then
return 'Group flood is locked'
else
data[tostring(target)]['settings']['flood'] = 'yes'
save_data(_config.moderation.data, data)
return 'Group flood has been locked'
end
end
local function unlock_group_flood(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'no' then
return 'Group flood is not locked'
else
data[tostring(target)]['settings']['flood'] = 'no'
save_data(_config.moderation.data, data)
return 'Group flood has been unlocked'
end
end
-- show group settings
local function show_group_settings(msg, data, target)
local data = load_data(_config.moderation.data, data)
if not is_admin(msg) then
return "For admins only!"
end
local settings = data[tostring(target)]['settings']
local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member
return text
end
local function returnids(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..''
for k,v in pairs(result.members) do
local username = ""
text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n"
end
send_large_msg(receiver, text)
local file = io.open("./groups/lists/"..result.id.."memberlist.txt", "w")
file:write(text)
file:flush()
file:close()
end
local function returnidsfile(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..''
for k,v in pairs(result.members) do
local username = ""
text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n"
end
local file = io.open("./groups/lists/"..result.id.."memberlist.txt", "w")
file:write(text)
file:flush()
file:close()
send_document("chat#id"..result.id,"./groups/lists/"..result.id.."memberlist.txt", ok_cb, false)
end
local function admin_promote(msg, admin_id)
if not is_sudo(msg) then
return "Access denied!"
end
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
if data[tostring(admins)][tostring(admin_id)] then
return admin_name..' is already an admin.'
end
data[tostring(admins)][tostring(admin_id)] = admin_id
save_data(_config.moderation.data, data)
return admin_id..' has been promoted as admin.'
end
local function admin_demote(msg, admin_id)
if not is_sudo(msg) then
return "Access denied!"
end
local data = load_data(_config.moderation.data)
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
if not data[tostring(admins)][tostring(admin_id)] then
return admin_id..' is not an admin.'
end
data[tostring(admins)][tostring(admin_id)] = nil
save_data(_config.moderation.data, data)
return admin_id..' has been demoted from admin.'
end
local function admin_list(msg)
local data = load_data(_config.moderation.data)
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
local message = 'List for Realm admins:\n'
for k,v in pairs(data[tostring(admins)]) do
message = message .. '- (at)' .. v .. ' [' .. k .. '] ' ..'\n'
end
return message
end
local function groups_list(msg)
local data = load_data(_config.moderation.data)
local groups = 'groups'
if not data[tostring(groups)] then
return 'No groups at the moment'
end
local message = 'List of groups:\n'
for k,v in pairs(data[tostring(groups)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairs(settings) do
if m == 'set_name' then
name = n
end
end
local group_owner = "No owner"
if data[tostring(v)]['set_owner'] then
group_owner = tostring(data[tostring(v)]['set_owner'])
end
local group_link = "No link"
if data[tostring(v)]['settings']['set_link'] then
group_link = data[tostring(v)]['settings']['set_link']
end
message = message .. '- '.. name .. ' (' .. v .. ') ['..group_owner..'] \n {'..group_link.."}\n"
end
local file = io.open("./groups/lists/groups.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function realms_list(msg)
local data = load_data(_config.moderation.data)
local realms = 'realms'
if not data[tostring(realms)] then
return 'No Realms at the moment'
end
local message = 'List of Realms:\n'
for k,v in pairs(data[tostring(realms)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairs(settings) do
if m == 'set_name' then
name = n
end
end
local group_owner = "No owner"
if data[tostring(v)]['admins_in'] then
group_owner = tostring(data[tostring(v)]['admins_in'])
end
local group_link = "No link"
if data[tostring(v)]['settings']['set_link'] then
group_link = data[tostring(v)]['settings']['set_link']
end
message = message .. '- '.. name .. ' (' .. v .. ') ['..group_owner..'] \n {'..group_link.."}\n"
end
local file = io.open("./groups/lists/realms.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function admin_user_promote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
if not data['admins'] then
data['admins'] = {}
save_data(_config.moderation.data, data)
end
if data['admins'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is already as admin.')
end
data['admins'][tostring(member_id)] = member_username
save_data(_config.moderation.data, data)
return send_large_msg(receiver, '@'..member_username..' has been promoted as admin.')
end
local function admin_user_demote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
if not data['admins'] then
data['admins'] = {}
save_data(_config.moderation.data, data)
end
if not data['admins'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is not an admin.')
end
data['admins'][tostring(member_id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Admin '..member_username..' has been demoted.')
end
local function username_id(cb_extra, success, result)
local mod_cmd = cb_extra.mod_cmd
local receiver = cb_extra.receiver
local member = cb_extra.member
local text = 'No user @'..member..' in this group.'
for k,v in pairs(result.members) do
vusername = v.username
if vusername == member then
member_username = member
member_id = v.id
if mod_cmd == 'addadmin' then
return admin_user_promote(receiver, member_username, member_id)
elseif mod_cmd == 'removeadmin' then
return admin_user_demote(receiver, member_username, member_id)
end
end
end
send_large_msg(receiver, text)
end
local function set_log_group(msg)
if not is_admin(msg) then
return
end
local log_group = data[tostring(groups)][tostring(msg.to.id)]['log_group']
if log_group == 'yes' then
return 'Log group is already set'
else
data[tostring(groups)][tostring(msg.to.id)]['log_group'] = 'yes'
save_data(_config.moderation.data, data)
return 'Log group has been set'
end
end
local function unset_log_group(msg)
if not is_admin(msg) then
return
end
local log_group = data[tostring(groups)][tostring(msg.to.id)]['log_group']
if log_group == 'no' then
return 'Log group is already disabled'
else
data[tostring(groups)][tostring(msg.to.id)]['log_group'] = 'no'
save_data(_config.moderation.data, data)
return 'log group has been disabled'
end
end
local function help()
local help_text = tostring(_config.help_text_realm)
return help_text
end
function run(msg, matches)
--vardump(msg)
local name_log = user_print_name(msg.from)
if matches[1] == 'log' and is_owner(msg) then
savelog(msg.to.id, "log file created by owner")
send_document("chat#id"..msg.to.id,"./groups/"..msg.to.id.."log.txt", ok_cb, false)
end
if matches[1] == 'who' and is_momod(msg) then
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list ")
local receiver = get_receiver(msg)
chat_info(receiver, returnidsfile, {receiver=receiver})
end
if matches[1] == 'wholist' and is_momod(msg) then
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list in a file")
local receiver = get_receiver(msg)
chat_info(receiver, returnids, {receiver=receiver})
end
if matches[1] == 'creategroup' and matches[2] then
group_name = matches[2]
group_type = 'group'
return create_group(msg)
end
if not is_sudo(msg) or not is_admin(msg) and not is_realm(msg) then
return --Do nothing
end
if matches[1] == 'createrealm' and matches[2] then
group_name = matches[2]
group_type = 'realm'
return create_realm(msg)
end
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
if matches[2] then if data[tostring(matches[2])] then
local settings = data[tostring(matches[2])]['settings']
if matches[1] == 'setabout' and matches[2] then
local target = matches[2]
local about = matches[3]
return set_description(msg, data, target, about)
end
if matches[1] == 'setrules' then
rules = matches[3]
local target = matches[2]
return set_rules(msg, data, target)
end
if matches[1] == 'lock' then --group lock *
local target = matches[2]
if matches[3] == 'name' then
return lock_group_name(msg, data, target)
end
if matches[3] == 'member' then
return lock_group_member(msg, data, target)
end
if matches[3] == 'photo' then
return lock_group_photo(msg, data, target)
end
if matches[3] == 'flood' then
return lock_group_flood(msg, data, target)
end
end
if matches[1] == 'unlock' then --group unlock *
local target = matches[2]
if matches[3] == 'name' then
return unlock_group_name(msg, data, target)
end
if matches[3] == 'member' then
return unlock_group_member(msg, data, target)
end
if matches[3] == 'photo' then
return unlock_group_photo(msg, data, target)
end
if matches[3] == 'flood' then
return unlock_group_flood(msg, data, target)
end
end
if matches[1] == 'settings' and data[tostring(matches[2])]['settings'] then
local target = matches[2]
return show_group_settings(msg, data, target)
end
if matches[1] == 'setname' and is_realm(msg) then
local new_name = string.gsub(matches[2], '_', ' ')
data[tostring(msg.to.id)]['settings']['set_name'] = new_name
save_data(_config.moderation.data, data)
local group_name_set = data[tostring(msg.to.id)]['settings']['set_name']
local to_rename = 'chat#id'..msg.to.id
rename_chat(to_rename, group_name_set, ok_cb, false)
savelog(msg.to.id, "Realm { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]")
end
if matches[1] == 'setgpname' and is_admin(msg) then
local new_name = string.gsub(matches[3], '_', ' ')
data[tostring(matches[2])]['settings']['set_name'] = new_name
save_data(_config.moderation.data, data)
local group_name_set = data[tostring(matches[2])]['settings']['set_name']
local to_rename = 'chat#id'..matches[2]
rename_chat(to_rename, group_name_set, ok_cb, false)
savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]")
end
end
end
if matches[1] == 'help' and is_realm(msg) then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help")
return help()
end
if matches[1] == 'set' then
if matches[2] == 'loggroup' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set as log group")
return set_log_group(msg)
end
end
if matches[1] == 'kill' and matches[2] == 'chat' then
if not is_admin(msg) then
return nil
end
if is_realm(msg) then
local receiver = 'chat#id'..matches[3]
return modrem(msg),
print("Closing Group: "..receiver),
chat_info(receiver, killchat, {receiver=receiver})
else
return 'Error: Group '..matches[3]..' not found'
end
end
if matches[1] == 'kill' and matches[2] == 'realm' then
if not is_admin(msg) then
return nil
end
if is_realm(msg) then
local receiver = 'chat#id'..matches[3]
return realmrem(msg),
print("Closing realm: "..receiver),
chat_info(receiver, killrealm, {receiver=receiver})
else
return 'Error: Realm '..matches[3]..' not found'
end
end
if matches[1] == 'chat_add_user' then
if not msg.service then
return "Are you trying to troll me?"
end
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
if not is_admin(msg) then
chat_del_user(chat, user, ok_cb, true)
end
end
if matches[1] == 'addadmin' then
if string.match(matches[2], '^%d+$') then
local admin_id = matches[2]
print("user "..admin_id.." has been promoted as admin")
return admin_promote(msg, admin_id)
else
local member = string.gsub(matches[2], "@", "")
local mod_cmd = "addadmin"
chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member})
end
end
if matches[1] == 'removeadmin' then
if string.match(matches[2], '^%d+$') then
local admin_id = matches[2]
print("user "..admin_id.." has been demoted")
return admin_demote(msg, admin_id)
else
local member = string.gsub(matches[2], "@", "")
local mod_cmd = "removeadmin"
chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member})
end
end
if matches[1] == 'type'then
local group_type = get_group_type(msg)
return group_type
end
if matches[1] == 'list' and matches[2] == 'admins' then
return admin_list(msg)
end
if matches[1] == 'list' and matches[2] == 'groups' then
if msg.to.type == 'chat' then
groups_list(msg)
send_document("chat#id"..msg.to.id, "./groups/lists/groups.txt", ok_cb, false)
return "Group list created" --group_list(msg)
elseif msg.to.type == 'user' then
groups_list(msg)
send_document("user#id"..msg.from.id, "./groups/lists/groups.txt", ok_cb, false)
return "Group list created" --group_list(msg)
end
end
if matches[1] == 'list' and matches[2] == 'realms' then
if msg.to.type == 'chat' then
realms_list(msg)
send_document("chat#id"..msg.to.id, "./groups/lists/realms.txt", ok_cb, false)
return "Realms list created" --realms_list(msg)
elseif msg.to.type == 'user' then
realms_list(msg)
send_document("user#id"..msg.from.id, "./groups/lists/realms.txt", ok_cb, false)
return "Realms list created" --realms_list(msg)
end
end
if matches[1] == 'res' and is_momod(msg) then
local cbres_extra = {
chatid = msg.to.id
}
local username = matches[2]
local username = username:gsub("@","")
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username)
return res_user(username, callbackres, cbres_extra)
end
end
return {
patterns = {
"^[!/](creategroup) (.*)$",
"^[!/](createrealm) (.*)$",
"^[!/](setabout) (%d+) (.*)$",
"^[!/](setrules) (%d+) (.*)$",
"^[!/](setname) (.*)$",
"^[!/](setgpname) (%d+) (.*)$",
"^[!/](setname) (%d+) (.*)$",
"^[!/](lock) (%d+) (.*)$",
"^[!/](unlock) (%d+) (.*)$",
"^[!/](setting) (%d+)$",
"^[!/](wholist)$",
"^[!/](who)$",
"^[!/](type)$",
"^[!/](kill) (chat) (%d+)$",
"^[!/](kill) (realm) (%d+)$",
"^[!/](addadmin) (.*)$", -- sudoers only
"^[!/](removeadmin) (.*)$", -- sudoers only
"^[!/](list) (.*)$",
"^[!/](log)$",
"^[!/](help)$",
"^!!tgservice (.+)$",
},
run = run
}
end
| gpl-2.0 |
chrisdugne/ludum-dare-36 | src/screens/Shop.lua | 1 | 1253 | --------------------------------------------------------------------------------
local scene = composer.newScene()
--------------------------------------------------------------------------------
function scene:create( event )
--------------------------------------
-- title
self.title = GUI:banner({
parent = self.view,
text = 'Shop'
})
--------------------------------------
-- close button
self.closeButton = Button:icon({
parent = self.view,
type = 'close',
x = display.contentWidth - 75,
y = 75,
action = function ()
Router:open(Router.HOME)
end
})
end
function scene:show( event )
if ( event.phase == 'did' ) then
utils.bounce(self.title)
utils.bounce(self.closeButton)
end
end
function scene:hide( event )
end
function scene:destroy( event )
end
--------------------------------------------------------------------------------
scene:addEventListener( 'create', scene )
scene:addEventListener( 'show', scene )
scene:addEventListener( 'hide', scene )
scene:addEventListener( 'destroy', scene )
--------------------------------------------------------------------------------
return scene
| bsd-3-clause |
JarnoVgr/ZombieSurvival | gamemodes/zombiesurvival/entities/weapons/weapon_zs_bulletstorm.lua | 1 | 2401 | AddCSLuaFile()
if CLIENT then
SWEP.PrintName = "'Bullet Storm' SMG"
SWEP.Description = "Hold right click to use the Storm firing mode: fire rate is reduced to 60% but two bullets are fired at once."
SWEP.Slot = 2
SWEP.SlotPos = 0
SWEP.ViewModelFlip = false
SWEP.ViewModelFOV = 50
SWEP.HUD3DBone = "v_weapon.p90_Release"
SWEP.HUD3DPos = Vector(-1.35, -0.5, -6.5)
SWEP.HUD3DAng = Angle(0, 0, 0)
end
SWEP.Base = "weapon_zs_base"
SWEP.HoldType = "smg"
SWEP.ViewModel = "models/weapons/cstrike/c_smg_p90.mdl"
SWEP.WorldModel = "models/weapons/w_smg_p90.mdl"
SWEP.UseHands = true
SWEP.Primary.Sound = Sound("Weapon_p90.Single")
SWEP.Primary.Damage = 10
SWEP.Primary.NumShots = 1
SWEP.Primary.Delay = 0.09
--SWEP.SDPS ()= 7,222
--(SWEP.Damage x Clipsize / Delay)
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Primary.ClipSize = 50
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "smg1"
GAMEMODE:SetupDefaultClip(SWEP.Primary)
SWEP.ConeMax = 0.11
SWEP.ConeMin = 0.075
SWEP.Primary.Gesture = ACT_HL2MP_GESTURE_RANGE_ATTACK_SMG1
SWEP.ReloadGesture = ACT_HL2MP_GESTURE_RELOAD_SMG1
SWEP.WalkSpeed = SPEED_SLOW
SWEP.IronSightsPos = Vector(-5, 13, 5)
SWEP.IronSightsAng = Vector(0, 2, 0)
SWEP.Primary.DefaultNumShots = SWEP.Primary.NumShots
SWEP.Primary.DefaultDelay = SWEP.Primary.Delay
SWEP.Primary.IronsightsNumShots = SWEP.Primary.NumShots * 2
SWEP.Primary.IronsightsDelay = SWEP.Primary.Delay * 1.6666
function SWEP:SetIronsights(b)
if self:GetIronsights() ~= b then
if b then
self.Primary.NumShots = self.Primary.IronsightsNumShots
self.Primary.Delay = self.Primary.IronsightsDelay
self:EmitSound("npc/scanner/scanner_scan4.wav", 40)
else
self.Primary.NumShots = self.Primary.DefaultNumShots
self.Primary.Delay = self.Primary.DefaultDelay
self:EmitSound("npc/scanner/scanner_scan2.wav", 40)
end
end
self.BaseClass.SetIronsights(self, b)
end
function SWEP:CanPrimaryAttack()
if self:GetIronsights() and self:Clip1() == 1 then
self:SetIronsights(false)
end
return self.BaseClass.CanPrimaryAttack(self)
end
function SWEP:TakeAmmo()
if self:GetIronsights() then
self:TakePrimaryAmmo(2)
else
self.BaseClass.TakeAmmo(self)
end
end
util.PrecacheSound("npc/scanner/scanner_scan4.wav")
util.PrecacheSound("npc/scanner/scanner_scan2.wav")
| gpl-2.0 |
TheAnswer/FirstTest | bin/scripts/object/tangible/lair/crowned_rasp/objects.lua | 1 | 6097 | --Copyright (C) 2009 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
object_tangible_lair_crowned_rasp_shared_lair_crowned_rasp = SharedTangibleObjectTemplate:new {
appearanceFilename = "appearance/poi_all_lair_nest_tree.apt",
arrangementDescriptorFilename = "",
certificationsRequired = {},
clearFloraRadius = 25,
clientDataFile = "clientdata/client_shared_lair_small.cdf",
collisionActionBlockFlags = 0,
collisionActionFlags = 51,
collisionActionPassFlags = 1,
collisionMaterialBlockFlags = 0,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 1,
customizationVariableMapping = {},
detailedDescription = "@lair_d:crowned_rasp",
gameObjectType = 4,
locationReservationRadius = 0,
lookAtText = "string_id_table",
noBuildRadius = 64,
objectName = "@lair_n:crowned_rasp",
onlyVisibleInTools = 0,
paletteColorCustomizationVariables = {},
portalLayoutFilename = "",
rangedIntCustomizationVariables = {},
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 1,
socketDestinations = {},
structureFootprintFileName = "",
surfaceType = 0,
targetable = 1,
useStructureFootprintOutline = 0
}
ObjectTemplates:addTemplate(object_tangible_lair_crowned_rasp_shared_lair_crowned_rasp, 4155092607)
object_tangible_lair_crowned_rasp_shared_lair_crowned_rasp_grassland = SharedTangibleObjectTemplate:new {
appearanceFilename = "appearance/poi_all_lair_nest_tree.apt",
arrangementDescriptorFilename = "",
certificationsRequired = {},
clearFloraRadius = 25,
clientDataFile = "clientdata/client_shared_lair_small.cdf",
collisionActionBlockFlags = 0,
collisionActionFlags = 51,
collisionActionPassFlags = 1,
collisionMaterialBlockFlags = 0,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 1,
customizationVariableMapping = {},
detailedDescription = "@lair_d:crowned_rasp_grassland",
gameObjectType = 4,
locationReservationRadius = 0,
lookAtText = "string_id_table",
noBuildRadius = 64,
objectName = "@lair_n:crowned_rasp_grassland",
onlyVisibleInTools = 0,
paletteColorCustomizationVariables = {},
portalLayoutFilename = "",
rangedIntCustomizationVariables = {},
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 1,
socketDestinations = {},
structureFootprintFileName = "",
surfaceType = 0,
targetable = 1,
useStructureFootprintOutline = 0
}
ObjectTemplates:addTemplate(object_tangible_lair_crowned_rasp_shared_lair_crowned_rasp_grassland, 3519101848)
object_tangible_lair_crowned_rasp_shared_lair_crowned_rasp_mountain = SharedTangibleObjectTemplate:new {
appearanceFilename = "appearance/poi_all_lair_nest_tree.apt",
arrangementDescriptorFilename = "",
certificationsRequired = {},
clearFloraRadius = 25,
clientDataFile = "clientdata/client_shared_lair_small.cdf",
collisionActionBlockFlags = 0,
collisionActionFlags = 51,
collisionActionPassFlags = 1,
collisionMaterialBlockFlags = 0,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 1,
customizationVariableMapping = {},
detailedDescription = "@lair_d:crowned_rasp_mountain",
gameObjectType = 4,
locationReservationRadius = 0,
lookAtText = "string_id_table",
noBuildRadius = 64,
objectName = "@lair_n:crowned_rasp_mountain",
onlyVisibleInTools = 0,
paletteColorCustomizationVariables = {},
portalLayoutFilename = "",
rangedIntCustomizationVariables = {},
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 1,
socketDestinations = {},
structureFootprintFileName = "",
surfaceType = 0,
targetable = 1,
useStructureFootprintOutline = 0
}
ObjectTemplates:addTemplate(object_tangible_lair_crowned_rasp_shared_lair_crowned_rasp_mountain, 3173314157)
| lgpl-3.0 |
BakaBBQ/siki.lua | dkjson.lua | 154 | 22416 | -- 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.5
For the documentation see the corresponding readme.txt or visit
<http://dkolf.de/src/dkjson-lua.fsl/>.
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.
--]==]
-- 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.5" }
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, state)
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, state)
end
local function appendcustom(res, buffer, state)
local buflen = state.bufferlen
if type (res) == 'string' then
buflen = buflen + 1
buffer[buflen] = res
end
return buflen
end
local function exception(reason, value, state, buffer, buflen, defaultmessage)
defaultmessage = defaultmessage or reason
local handler = state.exception
if not handler then
return nil, defaultmessage
else
state.bufferlen = buflen
local ret, msg = handler (reason, value, state, defaultmessage)
if not ret then return nil, msg or defaultmessage end
return appendcustom(ret, buffer, state)
end
end
function json.encodeexception(reason, value, state, defaultmessage)
return quotestring("<" .. defaultmessage .. ">")
end
encode2 = function (value, indent, level, buffer, buflen, tables, globalorder, state)
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 exception('reference cycle', value, state, buffer, buflen)
end
tables[value] = true
state.bufferlen = buflen
local ret, msg = valtojson (value, state)
if not ret then return exception('custom encoder failed', value, state, buffer, buflen, msg) end
tables[value] = nil
buflen = appendcustom(ret, buffer, state)
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 exception('reference cycle', value, state, buffer, buflen)
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, state)
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, state)
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, state)
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, state)
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 exception ('unsupported type', value, state, buffer, buflen,
"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 {}
state.buffer = buffer
updatedecpoint()
local ret, msg = encode2 (value, state.indent, state.level or 0,
buffer, state.bufferlen or 0, state.tables or {}, state.keyorder, state)
if not ret then
error (msg, 2)
elseif oldbuffer == buffer then
state.bufferlen = ret
return true
else
state.bufferlen = nil
state.buffer = nil
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
local sub2 = strsub (str, pos, pos + 1)
if sub2 == "\239\187" and strsub (str, pos + 2, pos + 2) == "\191" then
-- UTF-8 Byte Order Mark
pos = pos + 3
elseif sub2 == "//" then
pos = strfind (str, "[\n\r]", pos + 2)
if not pos then return nil end
elseif sub2 == "/*" then
pos = strfind (str, "*/", pos + 2)
if not pos then return nil end
pos = pos + 2
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 SingleLineComment = P"//" * (1 - S"\n\r")^0
local MultiLineComment = P"/*" * (1 - P"*/")^0 * P"*/"
local Space = (S" \n\r\t" + P"\239\187\191" + SingleLineComment + MultiLineComment)^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
| mit |
thkhxm/TGame | LuaEncoder/luajit_ios/x86_64/jit/bcsave.lua | 26 | 18244 | ----------------------------------------------------------------------------
-- LuaJIT module to save/list bytecode.
--
-- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
--
-- This module saves or lists the bytecode for an input file.
-- It's run by the -b command line option.
--
------------------------------------------------------------------------------
local jit = require("jit")
assert(jit.version_num == 20100, "LuaJIT core/library version mismatch")
local bit = require("bit")
-- Symbol name prefix for LuaJIT bytecode.
local LJBC_PREFIX = "luaJIT_BC_"
------------------------------------------------------------------------------
local function usage()
io.stderr:write[[
Save LuaJIT bytecode: luajit -b[options] input output
-l Only list bytecode.
-s Strip debug info (default).
-g Keep debug info.
-n name Set module name (default: auto-detect from input name).
-t type Set output file type (default: auto-detect from output name).
-a arch Override architecture for object files (default: native).
-o os Override OS for object files (default: native).
-e chunk Use chunk string as input.
-- Stop handling options.
- Use stdin as input and/or stdout as output.
File types: c h obj o raw (default)
]]
os.exit(1)
end
local function check(ok, ...)
if ok then return ok, ... end
io.stderr:write("luajit: ", ...)
io.stderr:write("\n")
os.exit(1)
end
local function readfile(input)
if type(input) == "function" then return input end
if input == "-" then input = nil end
return check(loadfile(input))
end
local function savefile(name, mode)
if name == "-" then return io.stdout end
return check(io.open(name, mode))
end
------------------------------------------------------------------------------
local map_type = {
raw = "raw", c = "c", h = "h", o = "obj", obj = "obj",
}
local map_arch = {
x86 = true, x64 = true, arm = true, arm64 = true, ppc = true,
mips = true, mipsel = true,
}
local map_os = {
linux = true, windows = true, osx = true, freebsd = true, netbsd = true,
openbsd = true, dragonfly = true, solaris = true,
}
local function checkarg(str, map, err)
str = string.lower(str)
local s = check(map[str], "unknown ", err)
return s == true and str or s
end
local function detecttype(str)
local ext = string.match(string.lower(str), "%.(%a+)$")
return map_type[ext] or "raw"
end
local function checkmodname(str)
check(string.match(str, "^[%w_.%-]+$"), "bad module name")
return string.gsub(str, "[%.%-]", "_")
end
local function detectmodname(str)
if type(str) == "string" then
local tail = string.match(str, "[^/\\]+$")
if tail then str = tail end
local head = string.match(str, "^(.*)%.[^.]*$")
if head then str = head end
str = string.match(str, "^[%w_.%-]+")
else
str = nil
end
check(str, "cannot derive module name, use -n name")
return string.gsub(str, "[%.%-]", "_")
end
------------------------------------------------------------------------------
local function bcsave_tail(fp, output, s)
local ok, err = fp:write(s)
if ok and output ~= "-" then ok, err = fp:close() end
check(ok, "cannot write ", output, ": ", err)
end
local function bcsave_raw(output, s)
local fp = savefile(output, "wb")
bcsave_tail(fp, output, s)
end
local function bcsave_c(ctx, output, s)
local fp = savefile(output, "w")
if ctx.type == "c" then
fp:write(string.format([[
#ifdef _cplusplus
extern "C"
#endif
#ifdef _WIN32
__declspec(dllexport)
#endif
const char %s%s[] = {
]], LJBC_PREFIX, ctx.modname))
else
fp:write(string.format([[
#define %s%s_SIZE %d
static const char %s%s[] = {
]], LJBC_PREFIX, ctx.modname, #s, LJBC_PREFIX, ctx.modname))
end
local t, n, m = {}, 0, 0
for i=1,#s do
local b = tostring(string.byte(s, i))
m = m + #b + 1
if m > 78 then
fp:write(table.concat(t, ",", 1, n), ",\n")
n, m = 0, #b + 1
end
n = n + 1
t[n] = b
end
bcsave_tail(fp, output, table.concat(t, ",", 1, n).."\n};\n")
end
local function bcsave_elfobj(ctx, output, s, ffi)
ffi.cdef[[
typedef struct {
uint8_t emagic[4], eclass, eendian, eversion, eosabi, eabiversion, epad[7];
uint16_t type, machine;
uint32_t version;
uint32_t entry, phofs, shofs;
uint32_t flags;
uint16_t ehsize, phentsize, phnum, shentsize, shnum, shstridx;
} ELF32header;
typedef struct {
uint8_t emagic[4], eclass, eendian, eversion, eosabi, eabiversion, epad[7];
uint16_t type, machine;
uint32_t version;
uint64_t entry, phofs, shofs;
uint32_t flags;
uint16_t ehsize, phentsize, phnum, shentsize, shnum, shstridx;
} ELF64header;
typedef struct {
uint32_t name, type, flags, addr, ofs, size, link, info, align, entsize;
} ELF32sectheader;
typedef struct {
uint32_t name, type;
uint64_t flags, addr, ofs, size;
uint32_t link, info;
uint64_t align, entsize;
} ELF64sectheader;
typedef struct {
uint32_t name, value, size;
uint8_t info, other;
uint16_t sectidx;
} ELF32symbol;
typedef struct {
uint32_t name;
uint8_t info, other;
uint16_t sectidx;
uint64_t value, size;
} ELF64symbol;
typedef struct {
ELF32header hdr;
ELF32sectheader sect[6];
ELF32symbol sym[2];
uint8_t space[4096];
} ELF32obj;
typedef struct {
ELF64header hdr;
ELF64sectheader sect[6];
ELF64symbol sym[2];
uint8_t space[4096];
} ELF64obj;
]]
local symname = LJBC_PREFIX..ctx.modname
local is64, isbe = false, false
if ctx.arch == "x64" then
is64 = true
elseif ctx.arch == "ppc" or ctx.arch == "mips" then
isbe = true
end
-- Handle different host/target endianess.
local function f32(x) return x end
local f16, fofs = f32, f32
if ffi.abi("be") ~= isbe then
f32 = bit.bswap
function f16(x) return bit.rshift(bit.bswap(x), 16) end
if is64 then
local two32 = ffi.cast("int64_t", 2^32)
function fofs(x) return bit.bswap(x)*two32 end
else
fofs = f32
end
end
-- Create ELF object and fill in header.
local o = ffi.new(is64 and "ELF64obj" or "ELF32obj")
local hdr = o.hdr
if ctx.os == "bsd" or ctx.os == "other" then -- Determine native hdr.eosabi.
local bf = assert(io.open("/bin/ls", "rb"))
local bs = bf:read(9)
bf:close()
ffi.copy(o, bs, 9)
check(hdr.emagic[0] == 127, "no support for writing native object files")
else
hdr.emagic = "\127ELF"
hdr.eosabi = ({ freebsd=9, netbsd=2, openbsd=12, solaris=6 })[ctx.os] or 0
end
hdr.eclass = is64 and 2 or 1
hdr.eendian = isbe and 2 or 1
hdr.eversion = 1
hdr.type = f16(1)
hdr.machine = f16(({ x86=3, x64=62, arm=40, arm64=183, ppc=20, mips=8, mipsel=8 })[ctx.arch])
if ctx.arch == "mips" or ctx.arch == "mipsel" then
hdr.flags = 0x50001006
end
hdr.version = f32(1)
hdr.shofs = fofs(ffi.offsetof(o, "sect"))
hdr.ehsize = f16(ffi.sizeof(hdr))
hdr.shentsize = f16(ffi.sizeof(o.sect[0]))
hdr.shnum = f16(6)
hdr.shstridx = f16(2)
-- Fill in sections and symbols.
local sofs, ofs = ffi.offsetof(o, "space"), 1
for i,name in ipairs{
".symtab", ".shstrtab", ".strtab", ".rodata", ".note.GNU-stack",
} do
local sect = o.sect[i]
sect.align = fofs(1)
sect.name = f32(ofs)
ffi.copy(o.space+ofs, name)
ofs = ofs + #name+1
end
o.sect[1].type = f32(2) -- .symtab
o.sect[1].link = f32(3)
o.sect[1].info = f32(1)
o.sect[1].align = fofs(8)
o.sect[1].ofs = fofs(ffi.offsetof(o, "sym"))
o.sect[1].entsize = fofs(ffi.sizeof(o.sym[0]))
o.sect[1].size = fofs(ffi.sizeof(o.sym))
o.sym[1].name = f32(1)
o.sym[1].sectidx = f16(4)
o.sym[1].size = fofs(#s)
o.sym[1].info = 17
o.sect[2].type = f32(3) -- .shstrtab
o.sect[2].ofs = fofs(sofs)
o.sect[2].size = fofs(ofs)
o.sect[3].type = f32(3) -- .strtab
o.sect[3].ofs = fofs(sofs + ofs)
o.sect[3].size = fofs(#symname+1)
ffi.copy(o.space+ofs+1, symname)
ofs = ofs + #symname + 2
o.sect[4].type = f32(1) -- .rodata
o.sect[4].flags = fofs(2)
o.sect[4].ofs = fofs(sofs + ofs)
o.sect[4].size = fofs(#s)
o.sect[5].type = f32(1) -- .note.GNU-stack
o.sect[5].ofs = fofs(sofs + ofs + #s)
-- Write ELF object file.
local fp = savefile(output, "wb")
fp:write(ffi.string(o, ffi.sizeof(o)-4096+ofs))
bcsave_tail(fp, output, s)
end
local function bcsave_peobj(ctx, output, s, ffi)
ffi.cdef[[
typedef struct {
uint16_t arch, nsects;
uint32_t time, symtabofs, nsyms;
uint16_t opthdrsz, flags;
} PEheader;
typedef struct {
char name[8];
uint32_t vsize, vaddr, size, ofs, relocofs, lineofs;
uint16_t nreloc, nline;
uint32_t flags;
} PEsection;
typedef struct __attribute((packed)) {
union {
char name[8];
uint32_t nameref[2];
};
uint32_t value;
int16_t sect;
uint16_t type;
uint8_t scl, naux;
} PEsym;
typedef struct __attribute((packed)) {
uint32_t size;
uint16_t nreloc, nline;
uint32_t cksum;
uint16_t assoc;
uint8_t comdatsel, unused[3];
} PEsymaux;
typedef struct {
PEheader hdr;
PEsection sect[2];
// Must be an even number of symbol structs.
PEsym sym0;
PEsymaux sym0aux;
PEsym sym1;
PEsymaux sym1aux;
PEsym sym2;
PEsym sym3;
uint32_t strtabsize;
uint8_t space[4096];
} PEobj;
]]
local symname = LJBC_PREFIX..ctx.modname
local is64 = false
if ctx.arch == "x86" then
symname = "_"..symname
elseif ctx.arch == "x64" then
is64 = true
end
local symexport = " /EXPORT:"..symname..",DATA "
-- The file format is always little-endian. Swap if the host is big-endian.
local function f32(x) return x end
local f16 = f32
if ffi.abi("be") then
f32 = bit.bswap
function f16(x) return bit.rshift(bit.bswap(x), 16) end
end
-- Create PE object and fill in header.
local o = ffi.new("PEobj")
local hdr = o.hdr
hdr.arch = f16(({ x86=0x14c, x64=0x8664, arm=0x1c0, ppc=0x1f2, mips=0x366, mipsel=0x366 })[ctx.arch])
hdr.nsects = f16(2)
hdr.symtabofs = f32(ffi.offsetof(o, "sym0"))
hdr.nsyms = f32(6)
-- Fill in sections and symbols.
o.sect[0].name = ".drectve"
o.sect[0].size = f32(#symexport)
o.sect[0].flags = f32(0x00100a00)
o.sym0.sect = f16(1)
o.sym0.scl = 3
o.sym0.name = ".drectve"
o.sym0.naux = 1
o.sym0aux.size = f32(#symexport)
o.sect[1].name = ".rdata"
o.sect[1].size = f32(#s)
o.sect[1].flags = f32(0x40300040)
o.sym1.sect = f16(2)
o.sym1.scl = 3
o.sym1.name = ".rdata"
o.sym1.naux = 1
o.sym1aux.size = f32(#s)
o.sym2.sect = f16(2)
o.sym2.scl = 2
o.sym2.nameref[1] = f32(4)
o.sym3.sect = f16(-1)
o.sym3.scl = 2
o.sym3.value = f32(1)
o.sym3.name = "@feat.00" -- Mark as SafeSEH compliant.
ffi.copy(o.space, symname)
local ofs = #symname + 1
o.strtabsize = f32(ofs + 4)
o.sect[0].ofs = f32(ffi.offsetof(o, "space") + ofs)
ffi.copy(o.space + ofs, symexport)
ofs = ofs + #symexport
o.sect[1].ofs = f32(ffi.offsetof(o, "space") + ofs)
-- Write PE object file.
local fp = savefile(output, "wb")
fp:write(ffi.string(o, ffi.sizeof(o)-4096+ofs))
bcsave_tail(fp, output, s)
end
local function bcsave_machobj(ctx, output, s, ffi)
ffi.cdef[[
typedef struct
{
uint32_t magic, cputype, cpusubtype, filetype, ncmds, sizeofcmds, flags;
} mach_header;
typedef struct
{
mach_header; uint32_t reserved;
} mach_header_64;
typedef struct {
uint32_t cmd, cmdsize;
char segname[16];
uint32_t vmaddr, vmsize, fileoff, filesize;
uint32_t maxprot, initprot, nsects, flags;
} mach_segment_command;
typedef struct {
uint32_t cmd, cmdsize;
char segname[16];
uint64_t vmaddr, vmsize, fileoff, filesize;
uint32_t maxprot, initprot, nsects, flags;
} mach_segment_command_64;
typedef struct {
char sectname[16], segname[16];
uint32_t addr, size;
uint32_t offset, align, reloff, nreloc, flags;
uint32_t reserved1, reserved2;
} mach_section;
typedef struct {
char sectname[16], segname[16];
uint64_t addr, size;
uint32_t offset, align, reloff, nreloc, flags;
uint32_t reserved1, reserved2, reserved3;
} mach_section_64;
typedef struct {
uint32_t cmd, cmdsize, symoff, nsyms, stroff, strsize;
} mach_symtab_command;
typedef struct {
int32_t strx;
uint8_t type, sect;
int16_t desc;
uint32_t value;
} mach_nlist;
typedef struct {
uint32_t strx;
uint8_t type, sect;
uint16_t desc;
uint64_t value;
} mach_nlist_64;
typedef struct
{
uint32_t magic, nfat_arch;
} mach_fat_header;
typedef struct
{
uint32_t cputype, cpusubtype, offset, size, align;
} mach_fat_arch;
typedef struct {
struct {
mach_header hdr;
mach_segment_command seg;
mach_section sec;
mach_symtab_command sym;
} arch[1];
mach_nlist sym_entry;
uint8_t space[4096];
} mach_obj;
typedef struct {
struct {
mach_header_64 hdr;
mach_segment_command_64 seg;
mach_section_64 sec;
mach_symtab_command sym;
} arch[1];
mach_nlist_64 sym_entry;
uint8_t space[4096];
} mach_obj_64;
typedef struct {
mach_fat_header fat;
mach_fat_arch fat_arch[2];
struct {
mach_header hdr;
mach_segment_command seg;
mach_section sec;
mach_symtab_command sym;
} arch[2];
mach_nlist sym_entry;
uint8_t space[4096];
} mach_fat_obj;
]]
local symname = '_'..LJBC_PREFIX..ctx.modname
local isfat, is64, align, mobj = false, false, 4, "mach_obj"
if ctx.arch == "x64" then
is64, align, mobj = true, 8, "mach_obj_64"
elseif ctx.arch == "arm" then
isfat, mobj = true, "mach_fat_obj"
elseif ctx.arch == "arm64" then
is64, align, isfat, mobj = true, 8, true, "mach_fat_obj"
else
check(ctx.arch == "x86", "unsupported architecture for OSX")
end
local function aligned(v, a) return bit.band(v+a-1, -a) end
local be32 = bit.bswap -- Mach-O FAT is BE, supported archs are LE.
-- Create Mach-O object and fill in header.
local o = ffi.new(mobj)
local mach_size = aligned(ffi.offsetof(o, "space")+#symname+2, align)
local cputype = ({ x86={7}, x64={0x01000007}, arm={7,12}, arm64={0x01000007,0x0100000c} })[ctx.arch]
local cpusubtype = ({ x86={3}, x64={3}, arm={3,9}, arm64={3,0} })[ctx.arch]
if isfat then
o.fat.magic = be32(0xcafebabe)
o.fat.nfat_arch = be32(#cpusubtype)
end
-- Fill in sections and symbols.
for i=0,#cpusubtype-1 do
local ofs = 0
if isfat then
local a = o.fat_arch[i]
a.cputype = be32(cputype[i+1])
a.cpusubtype = be32(cpusubtype[i+1])
-- Subsequent slices overlap each other to share data.
ofs = ffi.offsetof(o, "arch") + i*ffi.sizeof(o.arch[0])
a.offset = be32(ofs)
a.size = be32(mach_size-ofs+#s)
end
local a = o.arch[i]
a.hdr.magic = is64 and 0xfeedfacf or 0xfeedface
a.hdr.cputype = cputype[i+1]
a.hdr.cpusubtype = cpusubtype[i+1]
a.hdr.filetype = 1
a.hdr.ncmds = 2
a.hdr.sizeofcmds = ffi.sizeof(a.seg)+ffi.sizeof(a.sec)+ffi.sizeof(a.sym)
a.seg.cmd = is64 and 0x19 or 0x1
a.seg.cmdsize = ffi.sizeof(a.seg)+ffi.sizeof(a.sec)
a.seg.vmsize = #s
a.seg.fileoff = mach_size-ofs
a.seg.filesize = #s
a.seg.maxprot = 1
a.seg.initprot = 1
a.seg.nsects = 1
ffi.copy(a.sec.sectname, "__data")
ffi.copy(a.sec.segname, "__DATA")
a.sec.size = #s
a.sec.offset = mach_size-ofs
a.sym.cmd = 2
a.sym.cmdsize = ffi.sizeof(a.sym)
a.sym.symoff = ffi.offsetof(o, "sym_entry")-ofs
a.sym.nsyms = 1
a.sym.stroff = ffi.offsetof(o, "sym_entry")+ffi.sizeof(o.sym_entry)-ofs
a.sym.strsize = aligned(#symname+2, align)
end
o.sym_entry.type = 0xf
o.sym_entry.sect = 1
o.sym_entry.strx = 1
ffi.copy(o.space+1, symname)
-- Write Macho-O object file.
local fp = savefile(output, "wb")
fp:write(ffi.string(o, mach_size))
bcsave_tail(fp, output, s)
end
local function bcsave_obj(ctx, output, s)
local ok, ffi = pcall(require, "ffi")
check(ok, "FFI library required to write this file type")
if ctx.os == "windows" then
return bcsave_peobj(ctx, output, s, ffi)
elseif ctx.os == "osx" then
return bcsave_machobj(ctx, output, s, ffi)
else
return bcsave_elfobj(ctx, output, s, ffi)
end
end
------------------------------------------------------------------------------
local function bclist(input, output)
local f = readfile(input)
require("jit.bc").dump(f, savefile(output, "w"), true)
end
local function bcsave(ctx, input, output)
local f = readfile(input)
local s = string.dump(f, ctx.strip)
local t = ctx.type
if not t then
t = detecttype(output)
ctx.type = t
end
if t == "raw" then
bcsave_raw(output, s)
else
if not ctx.modname then ctx.modname = detectmodname(input) end
if t == "obj" then
bcsave_obj(ctx, output, s)
else
bcsave_c(ctx, output, s)
end
end
end
local function docmd(...)
local arg = {...}
local n = 1
local list = false
local ctx = {
strip = true, arch = jit.arch, os = string.lower(jit.os),
type = false, modname = false,
}
while n <= #arg do
local a = arg[n]
if type(a) == "string" and string.sub(a, 1, 1) == "-" and a ~= "-" then
table.remove(arg, n)
if a == "--" then break end
for m=2,#a do
local opt = string.sub(a, m, m)
if opt == "l" then
list = true
elseif opt == "s" then
ctx.strip = true
elseif opt == "g" then
ctx.strip = false
else
if arg[n] == nil or m ~= #a then usage() end
if opt == "e" then
if n ~= 1 then usage() end
arg[1] = check(loadstring(arg[1]))
elseif opt == "n" then
ctx.modname = checkmodname(table.remove(arg, n))
elseif opt == "t" then
ctx.type = checkarg(table.remove(arg, n), map_type, "file type")
elseif opt == "a" then
ctx.arch = checkarg(table.remove(arg, n), map_arch, "architecture")
elseif opt == "o" then
ctx.os = checkarg(table.remove(arg, n), map_os, "OS name")
else
usage()
end
end
end
else
n = n + 1
end
end
if list then
if #arg == 0 or #arg > 2 then usage() end
bclist(arg[1], arg[2] or "-")
else
if #arg ~= 2 then usage() end
bcsave(ctx, arg[1], arg[2])
end
end
------------------------------------------------------------------------------
-- Public module functions.
return {
start = docmd -- Process -b command line option.
}
| apache-2.0 |
mynameis123/uzzbot | plugins/help.lua | 337 | 5009 | do
function pairsByKeys(t, f)
local a = {}
for n in pairs(t) do table.insert(a, n) end
table.sort(a, f)
local i = 0 -- iterator variable
local iter = function () -- iterator function
i = i + 1
if a[i] == nil then return nil
else return a[i], t[a[i]]
end
end
return iter
end
-- Returns true if is not empty
local function has_usage_data(dict)
if (dict.usage == nil or dict.usage == '') then
return false
end
return true
end
-- Get commands for that plugin
local function plugin_help(name,number,requester)
local plugin = ""
if number then
local i = 0
for name in pairsByKeys(plugins) do
if plugins[name].hidden then
name = nil
else
i = i + 1
if i == tonumber(number) then
plugin = plugins[name]
end
end
end
else
plugin = plugins[name]
if not plugin then return nil end
end
local text = ""
if (type(plugin.usage) == "table") then
for ku,usage in pairs(plugin.usage) do
if ku == 'user' then -- usage for user
if (type(plugin.usage.user) == "table") then
for k,v in pairs(plugin.usage.user) do
text = text..v..'\n'
end
elseif has_usage_data(plugin) then -- Is not empty
text = text..plugin.usage.user..'\n'
end
elseif ku == 'moderator' then -- usage for moderator
if requester == 'moderator' or requester == 'admin' or requester == 'sudo' then
if (type(plugin.usage.moderator) == "table") then
for k,v in pairs(plugin.usage.moderator) do
text = text..v..'\n'
end
elseif has_usage_data(plugin) then -- Is not empty
text = text..plugin.usage.moderator..'\n'
end
end
elseif ku == 'admin' then -- usage for admin
if requester == 'admin' or requester == 'sudo' then
if (type(plugin.usage.admin) == "table") then
for k,v in pairs(plugin.usage.admin) do
text = text..v..'\n'
end
elseif has_usage_data(plugin) then -- Is not empty
text = text..plugin.usage.admin..'\n'
end
end
elseif ku == 'sudo' then -- usage for sudo
if requester == 'sudo' then
if (type(plugin.usage.sudo) == "table") then
for k,v in pairs(plugin.usage.sudo) do
text = text..v..'\n'
end
elseif has_usage_data(plugin) then -- Is not empty
text = text..plugin.usage.sudo..'\n'
end
end
else
text = text..usage..'\n'
end
end
text = text..'======================\n'
elseif has_usage_data(plugin) then -- Is not empty
text = text..plugin.usage..'\n======================\n'
end
return text
end
-- !help command
local function telegram_help()
local i = 0
local text = "Plugins list:\n\n"
-- Plugins names
for name in pairsByKeys(plugins) do
if plugins[name].hidden then
name = nil
else
i = i + 1
text = text..i..'. '..name..'\n'
end
end
text = text..'\n'..'There are '..i..' plugins help available.'
text = text..'\n'..'Write "!help [plugin name]" or "!help [plugin number]" for more info.'
text = text..'\n'..'Or "!help all" to show all info.'
return text
end
-- !help all command
local function help_all(requester)
local ret = ""
for name in pairsByKeys(plugins) do
if plugins[name].hidden then
name = nil
else
ret = ret .. plugin_help(name, nil, requester)
end
end
return ret
end
local function run(msg, matches)
if is_sudo(msg) then
requester = "sudo"
elseif is_admin(msg) then
requester = "admin"
elseif is_momod(msg) then
requester = "moderator"
else
requester = "user"
end
if matches[1] == "!help" then
return telegram_help()
elseif matches[1] == "!help all" then
return help_all(requester)
else
local text = ""
if tonumber(matches[1]) then
text = plugin_help(nil, matches[1], requester)
else
text = plugin_help(matches[1], nil, requester)
end
if not text then
text = telegram_help()
end
return text
end
end
return {
description = "Help plugin. Get info from other plugins. ",
usage = {
"!help: Show list of plugins.",
"!help all: Show all commands for every plugin.",
"!help [plugin name]: Commands for that plugin.",
"!help [number]: Commands for that plugin. Type !help to get the plugin number."
},
patterns = {
"^!help$",
"^!help all",
"^!help (.+)"
},
run = run
}
end
| gpl-2.0 |
TheAnswer/FirstTest | bin/scripts/creatures/spawns/corellia/citys/coronet.lua | 1 | 19986 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
spawnCreature(coronetNpc1, 0, 10.3286, -4633.8)
spawnCreature(coronetNpc2, 0, -140.701, -4719.16)
spawnCreature(coronetNpc3, 0, -137.464, -4718.83)
spawnCreature(coronetNpc5, 0, -149.754, -4785.34)
spawnCreature(coronetNpc6, 0, -146.217, -4738.99)
spawnCreature(coronetNpc7, 0, -182.479, -4731.42)
spawnCreatureInCell(coronetNpc8, 0, -62.7673, 2.63942, 40.6604, 1855683)
spawnCreatureInCell(coronetNpc9, 0, -62.7673, 2.63942, 41.7604, 1855683)
spawnCreatureInCell(coronetNpc10, 0, 37.163, 0.639417, 39.6061, 1855678)
spawnCreatureInCell(coronetNpc11, 0, 37.163, 0.639417, 40.7061, 1855678)
spawnCreatureInCell(coronetNpc12, 0, 56.669, -0.521137, 32.6689, 1855678)
spawnCreatureInCell(coronetNpc13, 0, 56.669, -0.521137, 33.7689, 1855678)
spawnCreatureInCell(coronetNpc14, 0, 55.569, -0.521137, 33.7689, 1855678)
spawnCreatureInCell(coronetNpc15, 0, -4.61669, 0.639424, 66.7263, 1855675)
spawnCreatureInCell(coronetNpc16, 0, -4.61669, 0.639424, 67.8263, 1855675)
spawnCreatureInCell(coronetNpc17, 0, 1.1, 0.639421, 66.3, 1855675)
spawnCreatureInCell(coronetNpc18, 0, 8.65132, 0.639421, 74.4483, 1855672)
spawnCreatureInCell(coronetNpc19, 0, 8.65132, 0.639421, 75.5483, 1855672)
spawnCreature(coronetNpc20, 0, -51.7918, -4662.65)
spawnCreature(coronetNpc21, 0, -59.6867, -4596.54)
spawnCreature(imperialDarkTrooper, 0, -76.6, -4625.3)
spawnCreature(imperialDarkTrooper, 0, -148.6, -4660.7)
spawnCreature(imperialDarkTrooper, 0, -159.2, -4660.7)
spawnCreature(coronetNpc25, 0, -177.764, -4766.07)
spawnCreature(imperialStormTrooperSquadLeader, 0, -175.938, -4767.14)
spawnCreature(coronetNpc27, 0, -175.887, -4765.95)
spawnCreature(imperialStormTrooper, 0, -35.4, -4573.8)
spawnCreature(coronetNpc30, 0, -26.0533, -4558.43)
spawnCreature(coronetNpc31, 0, -163.792, -4606.3)
spawnCreature(coronetNpc32, 0, -138.975, -4718.86)
spawnCreature(imperialDarkTrooper, 0, -157.6, -4834.8)
spawnCreature(coronetNpc34, 0, -167.548, -4835.07)
spawnCreature(imperialStormTrooper, 0, -221.1, -4798.1)
spawnCreature(coronetNpc36, 0, -187.1, -4835)
spawnCreature(imperialDarkTrooper, 0, -185.046, -4845.97)
spawnCreature(coronetNpc38, 0, -212.993, -4922.77)
spawnCreature(coronetNpc39, 0, -217.315, -4927.23)
spawnCreature(coronetNpc40, 0, -213.219, -4926.08)
spawnCreature(coronetNpc41, 0, -225.238, -4931.01)
spawnCreature(coronetNpc42, 0, 19.7425, -4775.49)
spawnCreature(coronetNpc43, 0, 55.6269, -4782.24)
spawnCreatures(corellianButterfly, 0, 45.8324, -4890.02, 15, 10)
spawnCreature(coronetNpc45, 0, 53.4915, -4893.52)
spawnCreature(coronetNpc46, 0, 52.8304, -4901.77)
spawnCreature(coronetNpc47, 0, 58.1097, -4902.59)
spawnCreature(coronetNpc48, 0, 49.7884, -4902.64)
spawnCreature(coronetNpc49, 0, 88.4953, -4727.94)
spawnCreature(coronetNpc50, 0, 184.405, -4789.02)
spawnCreature(coronetNpc51, 0, 185.612, -4773.74)
spawnCreature(imperialColonel, 0, 158.9, -4707.2)
spawnCreature(imperialStormTrooper, 0, 168.1, -4698.4)
spawnCreature(coronetNpc54, 0, 185.754, -4685.24)
spawnCreature(coronetNpc55, 0, 184.83, -4684.43)
spawnCreature(imperialStormTrooperSquadLeader, 0, 144.7, -4536.6)
spawnCreature(imperialStormTrooperCommando, 0, 152.386, -4524.14)
spawnCreature(coronetNpc58, 0, 152.1, -4521.94)
spawnCreature(coronetNpc59, 0, 227.363, -4490.61)
spawnCreature(coronetNpc60, 0, 227.709, -4494.78)
spawnCreature(coronetNpc61, 0, 234.249, -4490.03)
spawnCreature(coronetNpc62, 0, 94.8749, -4519.08)
spawnCreature(coronetNpc63, 0, 71.9271, -4568.97)
spawnCreature(coronetNpc64, 0, 229.296, -4484.62)
spawnCreature(imperialStormTrooper, 0, 128.21, -4459.57)
spawnCreature(imperialDarkTrooper, 0, 126.785, -4459.52)
spawnCreature(imperialDarkTrooper, 0, 111.5, -4464.9)
spawnCreature(coronetNpc68, 0, 112.862, -4440.48)
spawnCreature(coronetNpc69, 0, 181.412, -4413.68)
spawnCreature(coronetNpc70, 0, 183.412, -4407.68)
spawnCreature(imperialStormTrooper, 0, 96.6, -4394.9)
spawnCreature(imperialStormTrooperSniper, 0, 96.6, -4407.1)
spawnCreature(coronetNpc73, 0, 40.5453, -4416.63)
spawnCreature(coronetNpc74, 0, 177.412, -4413.68)
spawnCreature(coronetNpc75, 0, 14.4606, -4407.11)
spawnCreature(coronetNpc76, 0, 184.412, -4413.68)
spawnCreature(coronetNpc77, 0, -1.67932, -4464.42)
spawnCreature(coronetNpc78, 0, -15.4515, -4415.25)
spawnCreature(imperialStormTrooperSquadLeader, 0, -12.4, -4404.7)
spawnCreature(coronetNpc80, 0, 177.412, -4411.68)
spawnCreature(imperialStormTrooper, 0, 26.3, -4290.2)
spawnCreature(coronetNpc82, 0, 22.6, -4290.2)
spawnCreature(imperialStormTrooper, 0, 10.5, -4290.5)
spawnCreature(coronetNpc84, 0, -54.3716, -4304.72)
spawnCreature(coronetNpc85, 0, 185.013, -4261.43)
spawnCreature(imperialStormTrooperSniper, 0, -59.1, -4260.1)
spawnCreature(coronetNpc87, 0, -56.7639, -4229.33)
spawnCreature(coronetNpc88, 0, -78.7157, -4286.4)
spawnCreature(coronetNpc89, 0, -103.047, -4182.61)
spawnCreature(imperialStormTrooperRifleman, 0, -118.7, -4204.6)
spawnCreature(coronetNpc91, 0, -87.6481, -4302.16)
spawnCreature(coronetNpc92, 0, -118.993, -4285.29)
spawnCreature(coronetNpc93, 0, -163.872, -4181.48)
spawnCreature(imperialStormTrooper, 0, -158.235, -4194.42)
spawnCreature(coronetNpc95, 0, -201.2, -4122)
spawnCreature(imperialStormTrooperRifleman, 0, -188.9, -4076.8)
spawnCreatureInCell(coronetNpc97, 0, -20.3488, 2.12878, 64.9854, 2365400)
spawnCreatureInCell(coronetNpc98, 0, -20.3488, 2.12878, 65.9854, 2365400)
spawnCreatureInCell(coronetNpc99, 0, 26.5189, 2.12846, 71.9319, 2365399)
spawnCreatureInCell(coronetNpc100, 0, 26.5189, 2.12858, 73.0319, 2365399)
spawnCreatureInCell(coronetNpc101, 0, 19.26, 2.12847, 56.13, 2365399)
spawnCreatureInCell(coronetNpc102, 0, 21.99, 2.12804, 64.05, 2365399)
spawnCreatureInCell(coronetNpc103, 0, 28.93, 2.12878, 58.19, 2365398)
spawnCreatureInCell(coronetNpc104, 0, -6.12488, 2.6, 13.0431, 2365397)
spawnCreatureInCell(coronetNpc105, 0, -6.12488, 2.6, 14.1431, 2365397)
spawnCreatureInCell(coronetNpc106, 0, -7.22488, 2.6, 14.1431, 2365397)
spawnCreatureInCell(coronetNpc107, 0, 22.2962, 0.788717, 42.1976, 2365397)
spawnCreatureInCell(coronetNpc108, 0, 22.2962, 0.688613, 43.2884, 2365397)
spawnCreatureInCell(coronetNpc109, 0, -17.5041, 0.992207, 39.9855, 2365397)
spawnCreatureInCell(coronetNpc110, 0, -17.5041, 0.887194, 41.0759, 2365397)
spawnCreatureInCell(coronetNpc111, 0, -18.6041, 0.887072, 41.0759, 2365397)
spawnCreatureInCell(coronetNpc112, 0, 3.66172, 0.6, -3.74185, 2365392)
spawnCreatureInCell(coronetNpc113, 0, 3.66172, 0.6, -2.64185, 2365392)
spawnCreatureInCell(coronetNpc114, 0, 2.56172, 0.6, -2.64185, 2365392)
spawnCreature(coronetNpc115, 0, -203.95, -4076.98)
spawnCreature(imperialFirstLieutenant, 0, -199.701, -4077.2)
spawnCreature(imperialStormTrooper, 0, -216.9, -4121.1)
spawnCreature(coronetNpc118, 0, -222.123, -4065.14)
spawnCreature(imperialStormTrooperRifleman, 0, -223.2, -4078)
spawnCreatures(corellianButterfly, 0, -122.13, -4045.32, 15, 10)
spawnCreatures(corellianButterfly, 0, -107.963, -4053.06, 15, 10)
spawnCreature(coronetNpc122, 0, -205.027, -4002.32)
spawnCreature(coronetNpc123, 0, -205.027, -3998.32)
spawnCreatures(corellianButterfly, 0, -110.715, -4035.45, 15, 10)
spawnCreatures(corellianButterfly, 0, -115.776, -4034.87, 15, 10)
spawnCreature(coronetNpc126, 0, -113.249, -4042.52)
spawnCreature(coronetNpc127, 0, -205.027, -3995.32)
spawnCreature(coronetNpc128, 0, -205.027, -3996.32)
spawnCreatures(corellianButterfly, 0, -109.002, -4032.55, 15, 10)
spawnCreature(imperialDarkTrooper, 0, -303.8, -4144.4)
spawnCreature(coronetNpc131, 0, -205.027, -4001.32)
spawnCreature(coronetNpc132, 0, -316.537, -4047.13)
spawnCreatures(corellianButterfly, 0, -309.685, -4046.34, 15, 10)
spawnCreature(coronetNpc134, 0, -308.894, -4040.87)
spawnCreature(coronetNpc135, 0, -325.89, -4049.4)
spawnCreature(coronetNpc136, 0, -321.205, -4046.72)
spawnCreature(coronetNpc137, 0, -322.342, -4048.61)
spawnCreature(coronetNpc138, 0, -205.027, -4002.32)
spawnCreature(coronetNpc139, 0, -350.892, -4219.92)
spawnCreature(imperialMedic, 0, -439.1, -4144.4)
spawnCreature(coronetNpc141, 0, -525.124, -4079.84)
spawnCreature(coronetNpc142, 0, -532.124, -4078.84)
spawnCreature(imperialStormTrooper, 0, -517.9, -4213.9)
spawnCreature(coronetNpc144, 0, -534.124, -4078.84)
spawnCreature(coronetNpc145, 0, -528.124, -4085.84)
spawnCreature(imperialStormTrooper, 0, -557.5, -4230.3)
spawnCreature(imperialStormTrooper, 0, -569.553, -4243.99)
spawnCreature(imperialDarkTrooper, 0, -574.2, -4247)
spawnCreature(coronetNpc149, 0, -582.736, -4260.62)
spawnCreature(imperialMedic, 0, -582.441, -4259.52)
spawnCreature(coronetNpc151, 0, -529.124, -4087.84)
spawnCreature(coronetNpc152, 0, -662.805, -4182.05)
spawnCreature(imperialStormTrooperSquadLeader, 0, -593.7, -4321.9)
spawnCreature(coronetNpc155, 0, -682.722, -4204.18)
spawnCreature(coronetNpc160, 0, -672.123, -4164.83)
spawnCreature(coronetNpc161, 0, -691.483, -4227.75)
spawnCreature(coronetNpc162, 0, -671.712, -4169.03)
spawnCreature(coronetNpc163, 0, -687.141, -4203.72)
spawnCreature(coronetNpc166, 0, -704.545, -4245.47)
spawnCreature(coronetNpc167, 0, -705.242, -4243.95)
spawnCreature(coronetNpc170, 0, -712.063, -4304.96)
spawnCreature(coronetNpc176, 0, -719.18, -4309.55)
spawnCreature(imperialStormTrooperSniper, 0, -593.7, -4483.1)
spawnCreature(imperialStormTrooper, 0, -593.7, -4502.9)
spawnCreature(imperialStormTrooperRifleman, 0, -499.3, -4469.1)
spawnCreature(coronetNpc188, 0, -535.282, -4633.32)
spawnCreature(imperialStormTrooperSniper, 0, -533.523, -4632.07)
spawnCreature(imperialStormTrooper, 0, -533.6, -4626.5)
spawnCreature(coronetNpc191, 0, -547.026, -4669.14)
spawnCreature(coronetNpc192, 0, -545.52, -4669.28)
spawnCreature(imperialStormTrooper, 0, -526.1, -4675.8)
spawnCreature(imperialStormTrooperRifleman, 0, -526.1, -4670.1)
spawnCreature(coronetNpc195, 0, -528.144, -4699.89)
spawnCreature(coronetNpc196, 0, -659.072, -4623.24)
spawnCreature(coronetNpc197, 0, -658.492, -4619.81)
spawnCreatures(corellianButterfly, 0, -657.498, -4622.14, 15, 10)
spawnCreatures(corellianButterfly, 0, -656.872, -4625.8, 15, 10)
spawnCreature(coronetNpc200, 0, -707.002, -4659.71)
spawnCreature(coronetNpc201, 0, -703.067, -4657.98)
spawnCreature(coronetNpc202, 0, -711.002, -4657.71)
spawnCreature(coronetNpc203, 0, -524.755, -4700.63)
spawnCreature(coronetNpc204, 0, -710.949, -4660.02)
spawnCreature(imperialStormTrooperSquadLeader, 0, -502.1, -4701.1)
spawnCreature(imperialDarkTrooper, 0, -458, -4590.8)
spawnCreature(imperialStormTrooper, 0, -446.5, -4744)
spawnCreature(imperialFirstLieutenant, 0, -336.602, -4791.97)
spawnCreature(coronetNpc209, 0, -336.361, -4790.74)
spawnCreature(coronetNpc210, 0, -386.125, -4867.54)
spawnCreature(coronetNpc211, 0, -385.025, -4878.38)
spawnCreature(coronetNpc212, 0, -396.754, -4869.82)
spawnCreature(coronetNpc213, 0, -397.655, -4875.17)
spawnCreature(imperialStormTrooperSniper, 0, -295.9, -4786.4)
spawnCreature(imperialStormTrooper, 0, -306.7, -4785.9)
spawnCreature(coronetNpc216, 0, -135.995, -4745.63)
--spawnCreatureInCell(coronetNpc217, 0, -2.4866, -13.75, -1.94528, 18183846445461798810)
--spawnCreatureInCell(coronetNpc218, 0, -3.75394, -13.75, -11.0451, 18183846445461798810)
--spawnCreatureInCell(coronetNpc219, 0, 2.3237, -13.75, -13.3448, 18183846445461798810)
--spawnCreatureInCell(coronetNpc220, 0, -2.5029, -13.75, -12.0875, 18183846445461798810)
--spawnCreatureInCell(coronetNpc221, 0, 5.61023, -6.75, -2.57632, 18183846445461798814)
--spawnCreatureInCell(coronetNpc222, 0, 6.40846, -6.75, -5.03812, 18183846445461798814)
--spawnCreatureInCell(coronetNpc223, 0, 2.10413, -6.76678, -16.203, 18183846445461798817)
--spawnCreatureInCell(coronetNpc224, 0, 0.0075745, -6.76678, -14.1183, 18183846445461798817)
--spawnCreatureInCell(coronetNpc225, 0, -5.5575, -6.75, -5.9982, 18183846445461798820)
--spawnCreatureInCell(coronetNpc226, 0, -3.20018, -6.75, -4.1671, 18183846445461798820)
spawnCreature(coronetNpc227, 0, 101.283, -4554.86)
spawnCreature(coronetNpc228, 0, -54.9984, -4530.84)
spawnCreature(imperialStormTrooper, 0, -42.2, -4500.6)
spawnCreature(coronetNpc230, 0, -106.79, -4528.6)
spawnCreature(coronetNpc231, 0, -14.9281, -4451.64)
spawnCreature(coronetNpc232, 0, -92.217, -4471.14)
spawnCreature(coronetNpc233, 0, -163.751, -4552.14)
spawnCreature(coronetNpc234, 0, -158.666, -4526.31)
spawnCreature(coronetNpc235, 0, -168.38, -4515.61)
spawnCreature(coronetNpc236, 0, -181.008, -4505.08)
spawnCreature(coronetNpc237, 0, -37.2537, -4476.76)
spawnCreature(coronetNpc238, 0, -64.8198, -4398.56)
spawnCreature(coronetNpc239, 0, -71.0095, -4325.21)
spawnCreature(coronetNpc240, 0, -122.156, -4392.8)
spawnCreatureInCell(coronetNpc241, 0, 21.5803, 14.26, -8.84205, 1855541)
spawnCreatureInCell(coronetNpc242, 0, 21.5803, 14.26, -7.84205, 1855541)
spawnCreatureInCell(coronetNpc243, 0, -25.52, 0.26, -3.48, 1855535)
spawnCreature(coronetNpc244, 0, -112.646, -4310.7)
spawnCreature(coronetNpc245, 0, -302.182, -4300.76)
spawnCreature(coronetNpc246, 0, -282.189, -4343.57)
spawnCreature(coronetNpc247, 0, -357.932, -4267.81)
spawnCreature(coronetNpc248, 0, -350.452, -4287.73)
spawnCreature(coronetNpc249, 0, -374.063, -4286.45)
spawnCreature(coronetNpc250, 0, -350.998, -4250.76)
spawnCreature(coronetNpc252, 0, -358.581, -4445.64)
spawnCreature(imperialStormTrooperRifleman, 0, -291.603, -4413.99)
spawnCreature(coronetNpc254, 0, -289.923, -4414.09)
spawnCreature(imperialCorporal, 0, -291.531, -4412.73)
spawnCreature(imperialStormTrooper, 0, -283.2, -4411)
spawnCreatureInCell(coronetNpc258, 0, -5.02826, -0.894991, -21.3375, 8105501)
spawnCreatureInCell(coronetNpc259, 0, 0.978477, -0.894992, 21.4841, 8105500)
spawnCreatureInCell(coronetNpc260, 0, 7.60649, -0.894992, 1.42464, 8105496)
spawnCreatureInCell(coronetNpc261, 0, 4.71201, -0.894992, -9.83418, 8105496)
spawnCreatureInCell(coronetNpc262, 0, 4.71201, -0.894992, -8.73417, 8105496)
spawnCreatureInCell(coronetNpc263, 0, 3.61201, -0.894992, -8.73417, 8105496)
spawnCreatureInCell(coronetNpc264, 0, 2.80432, -0.894991, 9.55434, 8105496)
spawnCreatureInCell(coronetNpc265, 0, 2.80432, -0.894991, 10.6543, 8105496)
spawnCreatureInCell(coronetNpc266, 0, -7.91375, -0.894992, -5.88587, 8105496)
spawnCreature(coronetNpc268, 0, -306.539, -4546.52)
spawnCreature(coronetNpc269, 0, -231.211, -4381.69)
spawnCreature(imperialStormTrooperSquadLeader, 0, -226.4, -4372)
spawnCreature(coronetNpc271, 0, -451.472, -4572.05)
spawnCreature(imperialStormTrooper, 0, -458, -4585)
spawnCreature(imperialStormTrooper, 0, -276.7, -4535.2)
spawnCreature(coronetNpc274, 0, -312.404, -4646.51)
spawnCreature(coronetNpc275, 0, -306.061, -4600.68)
spawnCreature(imperialStormTrooperSniper, 0, -275.4, -4614.6)
spawnCreatureInCell(coronetNpc277, 0, -22.3764, 1.6, -15.0418, 1855554)
spawnCreatureInCell(coronetNpc278, 0, -24, 1.6, -4, 1855554)
spawnCreatureInCell(coronetNpc279, 0, -15.4768, 1, -8.20706, 1855551)
spawnCreatureInCell(coronetNpc280, 0, 24.3471, 1.28309, 8.93357, 1855549)
spawnCreatureInCell(coronetNpc281, 0, 24.3471, 1.28309, 10.0336, 1855549)
spawnCreatureInCell(coronetNpc282, 0, 17.2826, 1.28309, -12.8404, 1855549)
spawnCreatureInCell(coronetNpc283, 0, 17.2826, 1.28309, -11.8404, 1855549)
spawnCreatureInCell(coronetNpc284, 0, 7.44572, 1.00001, -8.00652, 1855548)
spawnCreatureInCell(coronetNpc285, 0, 7.44572, 1.00001, -6.90652, 1855548)
spawnCreature(coronetNpc286, 0, -258.479, -4620)
spawnCreatureInCell(coronetNpc287, 0, 11.9421, 1.75, -19.8404, 1855484)
spawnCreatureInCell(coronetNpc288, 0, -9.42234, 1.75, -19.8259, 1855484)
spawnCreatureInCell(coronetNpc289, 0, -9.42234, 1.75, -18.7259, 1855484)
spawnCreatureInCell(coronetNpc290, 0, -10.5223, 1.75, -18.7259, 1855484)
spawnCreatureInCell(coronetNpc291, 0, 0.180826, 1.75, -21.4842, 1855484)
spawnCreatureInCell(coronetNpc292, 0, 11.9421, 1.75, -18.7404, 1855484)
spawnCreatureInCell(coronetNpc293, 0, 17.3045, 2.25, 18.2968, 1855477)
spawnCreatureInCell(coronetNpc294, 0, 17.3045, 2.25, 19.3968, 1855477)
spawnCreatureInCell(coronetNpc295, 0, 16.2045, 2.25, 19.3968, 1855477)
spawnCreatureInCell(coronetNpc296, 0, 1.70956, 1.75, -14.1406, 1855483)
spawnCreatureInCell(coronetNpc297, 0, 37.1168, 1.29422, -4.41488, 1855470)
spawnCreatureInCell(coronetNpc298, 0, 37.1168, 1.29422, -3.41488, 1855470)
spawnCreatureInCell(coronetNpc299, 0, 21.8079, 3.22324, 25.517, 1855469)
spawnCreatureInCell(coronetNpc300, 0, 21.8079, 3.22324, 26.617, 1855469)
spawnCreatureInCell(coronetNpc301, 0, -20.2743, 3.22324, 21.681, 1855468)
spawnCreatureInCell(coronetNpc302, 0, -20.2743, 3.22324, 22.781, 1855468)
spawnCreatureInCell(coronetNpc303, 0, -21.3743, 3.22324, 22.781, 1855468)
spawnCreatureInCell(coronetNpc305, 0, -1.72746, 7.9, -32.175, 1855463)
spawnCreatureInCell(coronetNpc306, 0, -1.72746, 7.9, -31.075, 1855463)
spawnCreatureInCell(coronetNpc307, 0, -18.6014, 1.30259, -11.3146, 1855463)
spawnCreatureInCell(coronetNpc308, 0, -18.6014, 1.30292, -10.2146, 1855463)
spawnCreatureInCell(coronetNpc309, 0, 5.22842, 0.3, 2.91677, 1855463)
spawnCreatureInCell(coronetNpc310, 0, 5.22842, 0.3, 4.01677, 1855463)
spawnCreatureInCell(coronetNpc311, 0, 4.12842, 0.3, 4.01677, 1855463)
spawnCreatureInCell(coronetNpc312, 0, 0.767877, 0.3, -4.00219, 1855463)
spawnCreatureInCell(coronetNpc313, 0, 0.767877, 0.3, -2.90219, 1855463)
spawnCreatureInCell(coronetNpc314, 0, -0.332123, 0.3, -2.90219, 1855463)
spawnCreatureInCell(coronetNpc315, 0, -0.332123, 0.3, -4.00219, 1855463)
spawnCreatureInCell(coronetNpc317, 0, 5.43518, 2.27819, -27.0615, 1855463)
spawnCreatureInCell(coronetNpc318, 0, 5.18395, 2.27819, -26.1292, 1855463)
spawnCreature(imperialStormTrooper, 0, -215.7, -4509.8)
spawnCreature(imperialStormTrooper, 0, -204.7, -4509.8)
spawnCreature(coronetNpc323, 0, -239.932, -4522.15)
spawnCreature(coronetNpc324, 0, -202.143, -4504.32)
spawnCreature(coronetNpc325, 0, -306.34, -4620.82)
spawnCreature(coronetNpc326, 0, -195.909, -4451.7)
spawnCreature(coronetNpc327, 0, -185.082, -4460.71)
spawnCreature(coronetNpc328, 0, -213.642, -4445.46)
spawnCreature(coronetNpc329, 0, -324.144, -4442.29)
| lgpl-3.0 |
TheAnswer/FirstTest | bin/scripts/slashcommands/admin/setPublicState.lua | 1 | 2498 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
--true = 1, false = 0
SetPublicStateSlashCommand = {
name = "setpublicstate",
alternativeNames = "",
animation = "",
invalidStateMask = 3760193536, --glowingJedi, pilotingShip, shipOperations, shipGunner,
invalidPostures = "",
target = 2,
targeType = 0,
disabled = 0,
maxRangeToTarget = 0,
--adminLevel = 0,
addToCombatQueue = 0,
}
AddSetPublicStateSlashCommand(SetPublicStateSlashCommand)
| lgpl-3.0 |
meysamx0/Crazy | plugins/lock_fosh.lua | 1 | 1649 | local function run(msg, matches)
if is_momod(msg) then
return
end
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['settings'] then
if data[tostring(msg.to.id)]['settings']['fosh'] then
lock_fosh = data[tostring(msg.to.id)]['settings']['fosh']
end
end
end
local chat = get_receiver(msg)
local user = "user#id"..msg.from.id
if lock_fosh == "yes" then
delete_msg(msg.id, ok_cb, true)
end
end
return {
patterns = {
"(ک*س)$",
"کیر",
"کص",
"کــــــــــیر",
"کــــــــــــــــــــــــــــــیر",
"کـیـــــــــــــــــــــــــــــــــــــــــــــــــــر",
"ک×یر",
"ک÷یر",
"ک*ص",
"کــــــــــیرر",
"kir",
"kos",
"گوساله",
"کس کش",
"بی ناموس",
"کونی",
"جنده",
"مادر جنده",
"پدر سگ",
"سگ پدر",
"زن جنده",
"گایید",
"گاییدم",
"گاییدمت",
"سگ طوله",
"طوله سگ",
"سگ پدر",
"خواهر جنده",
"کص خواهر",
"کص مادر",
"کس ننه",
"کس عمه",
"جاکش",
"سکس",
"دیوث",
"sex",
"خار کوس",
"خار کوص",
"خارکوس",
"خارکوص",
"سیک",
"قرمساغ",
"قرمساق",
"غرمساخ",
"غرمساق",
"کسلیس",
"کصلیس",
"لاشی",
"هرزه",
"حرومی",
"تخمی",
"حرومزاده",
"جق",
"کونکش",
"کس گشاد",
"کونگشاد",
},
run = run
}
| agpl-3.0 |
TheAnswer/FirstTest | bin/scripts/creatures/objects/dathomir/creatures/enragedRancor.lua | 1 | 4729 | --Copyright (C) 2008 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
enragedRancor = Creature:new {
objectName = "enragedRancor", -- Lua Object Name
creatureType = "ANIMAL",
gender = "",
speciesName = "enraged_rancor",
stfName = "mob/creature_names",
objectCRC = 3516440142,
socialGroup = "Rancor",
level = 80,
combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG + AGGRESSIVE_FLAG,
healthMax = 15000,
healthMin = 12000,
strength = 0,
constitution = 0,
actionMax = 15000,
actionMin = 12000,
quickness = 0,
stamina = 0,
mindMax = 15000,
mindMin = 12000,
focus = 0,
willpower = 0,
height = 1, -- Size of creature
armor = 1, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy
kinetic = 30,
energy = 60,
electricity = 100,
stun = 30,
blast = 30,
heat = 100,
cold = 100,
acid = 30,
lightsaber = 0,
accuracy = 200,
healer = 0,
pack = 1,
herd = 0,
stalker = 0,
killer = 1,
ferocity = 12,
aggressive = 1,
invincible = 0,
meleeDefense = 1,
rangedDefense = 1,
attackCreatureOnSight = "", -- Enter socialGroups
weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx
weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance'
weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance'
weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon'
weaponEquipped = 0,
weaponMinDamage = 840,
weaponMaxDamage = 850,
weaponAttackSpeed = 2,
weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc
weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY
alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx
alternateWeaponName = "", -- Name ex. 'a Vibrolance'
alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance'
alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon'
alternateWeaponEquipped = 0,
alternateWeaponMinDamage = 0,
alternateWeaponMaxDamage = 0,
alternateWeaponAttackSpeed = 0,
alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc
alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY
internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's
lootGroup = "0", -- Group it belongs to for loot
tame = 0, -- Likely hood to be tamed
datapadItemCRC = 0,
mountCRC = 0,
mountSpeed = 0,
mountAcceleration = 0,
milk = 0,
boneType = "bone_mammal_dathomir",
boneMax = 778,
hideType = "hide_leathery_dathomir",
hideMax = 878,
meatType = "meat_carnivore_dathomir",
meatMax = 950,
skills = { "rancorAttack1", "rancorAttack2", "rancorAttack3" },
respawnTimer = 180,
behaviorScript = "", -- Link to the behavior script for this object
}
Creatures:addCreature(enragedRancor, 3516440142) -- Add to Global Table
| lgpl-3.0 |
TheAnswer/FirstTest | bin/scripts/items/objects/clothing/casualShoes.lua | 1 | 2294 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
casualShoes = Clothing:new {
objectName = "Casual Shoes",
templateName = "shoes_s02",
objectCRC = "143099030",
objectType = FOOTWEAR,
itemMask = HUMANOID_FOOTWEAR,
equipped = "1"
} | lgpl-3.0 |
TheAnswer/FirstTest | bin/scripts/object/tangible/lair/spined_puc/objects.lua | 1 | 4710 | --Copyright (C) 2009 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
object_tangible_lair_spined_puc_shared_lair_spined_puc = SharedTangibleObjectTemplate:new {
appearanceFilename = "appearance/defaultappearance.apt",
arrangementDescriptorFilename = "",
certificationsRequired = {},
clearFloraRadius = 25,
clientDataFile = "clientdata/client_shared_lair_small.cdf",
collisionActionBlockFlags = 0,
collisionActionFlags = 51,
collisionActionPassFlags = 1,
collisionMaterialBlockFlags = 0,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 1,
customizationVariableMapping = {},
detailedDescription = "@lair_d:spined_puc",
gameObjectType = 4,
locationReservationRadius = 0,
lookAtText = "string_id_table",
noBuildRadius = 64,
objectName = "@lair_n:spined_puc",
onlyVisibleInTools = 0,
paletteColorCustomizationVariables = {},
portalLayoutFilename = "",
rangedIntCustomizationVariables = {},
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 1,
socketDestinations = {},
structureFootprintFileName = "",
surfaceType = 0,
targetable = 1,
useStructureFootprintOutline = 0
}
ObjectTemplates:addTemplate(object_tangible_lair_spined_puc_shared_lair_spined_puc, 3786767749)
object_tangible_lair_spined_puc_shared_lair_spined_puc_underwater = SharedTangibleObjectTemplate:new {
appearanceFilename = "appearance/defaultappearance.apt",
arrangementDescriptorFilename = "",
certificationsRequired = {},
clearFloraRadius = 25,
clientDataFile = "clientdata/client_shared_lair_small.cdf",
collisionActionBlockFlags = 0,
collisionActionFlags = 51,
collisionActionPassFlags = 1,
collisionMaterialBlockFlags = 0,
collisionMaterialFlags = 1,
collisionMaterialPassFlags = 0,
containerType = 0,
containerVolumeLimit = 1,
customizationVariableMapping = {},
detailedDescription = "@lair_d:spined_puc_underwater",
gameObjectType = 4,
locationReservationRadius = 0,
lookAtText = "string_id_table",
noBuildRadius = 64,
objectName = "@lair_n:spined_puc_underwater",
onlyVisibleInTools = 0,
paletteColorCustomizationVariables = {},
portalLayoutFilename = "",
rangedIntCustomizationVariables = {},
scale = 1,
scaleThresholdBeforeExtentTest = 0.5,
sendToClient = 1,
slotDescriptorFilename = "",
snapToTerrain = 1,
socketDestinations = {},
structureFootprintFileName = "",
surfaceType = 0,
targetable = 1,
useStructureFootprintOutline = 0
}
ObjectTemplates:addTemplate(object_tangible_lair_spined_puc_shared_lair_spined_puc_underwater, 2429481167)
| lgpl-3.0 |
TheAnswer/FirstTest | bin/scripts/skills/creatureSkills/tatooine/npcs/mosTaikeAttacks.lua | 1 | 2839 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
mosTaikeAttack1 = {
attackname = "mosTaikeAttack1",
animation = "creature_attack_light",
requiredWeaponType = NONE,
range = 10,
damageRatio = 1.2,
speedRatio = 4,
areaRange = 0,
accuracyBonus = 0,
knockdownChance = 0,
postureDownChance = 0,
postureUpChance = 0,
dizzyChance = 0,
blindChance = 0,
stunChance = 0,
intimidateChance = 0,
CbtSpamBlock = "attack_block",
CbtSpamCounter = "attack_counter",
CbtSpamEvade = "attack_evade",
CbtSpamHit = "attack_hit",
CbtSpamMiss = "attack_miss",
invalidStateMask = 0,
invalidPostures = "",
instant = 0
}
AddRandomPoolAttackTargetSkill(mosTaikeAttack1)
---------------------------------------------------------------------------------------
| lgpl-3.0 |
TheAnswer/FirstTest | bin/scripts/creatures/objects/endor/npcs/jinda/jindaVeteran.lua | 1 | 4734 | --Copyright (C) 2008 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
jindaVeteran = Creature:new {
objectName = "jindaVeteran", -- Lua Object Name
creatureType = "NPC",
faction = "Jinda Tribe",
gender = "",
speciesName = "jinda_veteran",
stfName = "mob/creature_names",
objectCRC = 2886364858,
socialGroup = "Jinda Tribe",
level = 45,
combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG,
healthMax = 11900,
healthMin = 9700,
strength = 0,
constitution = 0,
actionMax = 11900,
actionMin = 9700,
quickness = 0,
stamina = 0,
mindMax = 11900,
mindMin = 9700,
focus = 0,
willpower = 0,
height = 1, -- Size of creature
armor = 1, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy
kinetic = 0,
energy = 0,
electricity = 0,
stun = 0,
blast = 0,
heat = 0,
cold = 0,
acid = 0,
lightsaber = 0,
accuracy = 200,
healer = 0,
pack = 1,
herd = 0,
stalker = 0,
killer = 0,
ferocity = 0,
aggressive = 0,
invincible = 0,
meleeDefense = 1,
rangedDefense = 1,
attackCreatureOnSight = "", -- Enter socialGroups
weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx
weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance'
weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance'
weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon'
weaponEquipped = 0,
weaponMinDamage = 370,
weaponMaxDamage = 450,
weaponAttackSpeed = 2,
weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc
weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY
alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx
alternateWeaponName = "", -- Name ex. 'a Vibrolance'
alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance'
alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon'
alternateWeaponEquipped = 0,
alternateWeaponMinDamage = 0,
alternateWeaponMaxDamage = 0,
alternateWeaponAttackSpeed = 0,
alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc
alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY
internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's
lootGroup = "0,11,15,19,33", -- Group it belongs to for loot
tame = 0,
datapadItemCRC = 0,
mountCRC = 0,
mountSpeed = 0,
mountAcceleration = 0,
milk = 0,
boneType = "",
boneMax = 0,
hideType = "",
hideMax = 0,
meatType = "",
meatMax = 0,
skills = { "jindaAttack01", "jindaAttack02", "jindaAttack03", "jindaAttack04", "jindaAttack05", "jindaAttack06", "jindaAttack07", "jindaAttack08", "jindaAttack09" },
respawnTimer = 300,
behaviorScript = "", -- Link to the behavior script for this object
}
Creatures:addCreature(jindaVeteran, 2886364858) -- Add to Global Table
| lgpl-3.0 |
Maxsteam/seed | plugins/inrealm.lua | 228 | 16974 | -- data saved to moderation.json
-- check moderation plugin
do
local function create_group(msg)
-- superuser and admins only (because sudo are always has privilege)
if is_sudo(msg) or is_realm(msg) and is_admin(msg) then
local group_creator = msg.from.print_name
create_group_chat (group_creator, group_name, ok_cb, false)
return 'Group '..string.gsub(group_name, '_', ' ')..' has been created.'
end
end
local function set_description(msg, data, target, about)
if not is_admin(msg) then
return "For admins only!"
end
local data_cat = 'description'
data[tostring(target)][data_cat] = about
save_data(_config.moderation.data, data)
return 'Set group description to:\n'..about
end
local function set_rules(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local data_cat = 'rules'
data[tostring(target)][data_cat] = rules
save_data(_config.moderation.data, data)
return 'Set group rules to:\n'..rules
end
-- lock/unlock group name. bot automatically change group name when locked
local function lock_group_name(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'yes' then
return 'Group name is already locked'
else
data[tostring(target)]['settings']['lock_name'] = 'yes'
save_data(_config.moderation.data, data)
rename_chat('chat#id'..target, group_name_set, ok_cb, false)
return 'Group name has been locked'
end
end
local function unlock_group_name(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'no' then
return 'Group name is already unlocked'
else
data[tostring(target)]['settings']['lock_name'] = 'no'
save_data(_config.moderation.data, data)
return 'Group name has been unlocked'
end
end
--lock/unlock group member. bot automatically kick new added user when locked
local function lock_group_member(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'yes' then
return 'Group members are already locked'
else
data[tostring(target)]['settings']['lock_member'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Group members has been locked'
end
local function unlock_group_member(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'no' then
return 'Group members are not locked'
else
data[tostring(target)]['settings']['lock_member'] = 'no'
save_data(_config.moderation.data, data)
return 'Group members has been unlocked'
end
end
--lock/unlock group photo. bot automatically keep group photo when locked
local function lock_group_photo(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'yes' then
return 'Group photo is already locked'
else
data[tostring(target)]['settings']['set_photo'] = 'waiting'
save_data(_config.moderation.data, data)
end
return 'Please send me the group photo now'
end
local function unlock_group_photo(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'no' then
return 'Group photo is not locked'
else
data[tostring(target)]['settings']['lock_photo'] = 'no'
save_data(_config.moderation.data, data)
return 'Group photo has been unlocked'
end
end
local function lock_group_flood(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'yes' then
return 'Group flood is locked'
else
data[tostring(target)]['settings']['flood'] = 'yes'
save_data(_config.moderation.data, data)
return 'Group flood has been locked'
end
end
local function unlock_group_flood(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'no' then
return 'Group flood is not locked'
else
data[tostring(target)]['settings']['flood'] = 'no'
save_data(_config.moderation.data, data)
return 'Group flood has been unlocked'
end
end
-- show group settings
local function show_group_settings(msg, data, target)
if not is_admin(msg) then
return "For admins only!"
end
local settings = data[tostring(target)]['settings']
local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member
return text
end
local function returnids(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..''
for k,v in pairs(result.members) do
local username = ""
text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n"
end
send_large_msg(receiver, text)
local file = io.open("./groups/"..result.id.."memberlist.txt", "w")
file:write(text)
file:flush()
file:close()
end
local function returnidsfile(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..''
for k,v in pairs(result.members) do
local username = ""
text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n"
end
local file = io.open("./groups/"..result.id.."memberlist.txt", "w")
file:write(text)
file:flush()
file:close()
send_document("chat#id"..result.id,"./groups/"..result.id.."memberlist.txt", ok_cb, false)
end
local function admin_promote(msg, admin_id)
if not is_sudo(msg) then
return "Access denied!"
end
local data = load_data(_config.moderation.data)
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
if data[tostring(admins)][tostring(admin_id)] then
return admin_name..' is already an admin.'
end
data[tostring(admins)][tostring(admin_id)] = admin_id
save_data(_config.moderation.data, data)
return admin_id..' has been promoted as admin.'
end
local function admin_demote(msg, admin_id)
if not is_sudo(msg) then
return "Access denied!"
end
local data = load_data(_config.moderation.data)
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
if not data[tostring(admins)][tostring(admin_id)] then
return admin_id..' is not an admin.'
end
data[tostring(admins)][tostring(admin_id)] = nil
save_data(_config.moderation.data, data)
return admin_id..' has been demoted from admin.'
end
local function admin_list(msg)
local data = load_data(_config.moderation.data)
local admins = 'admins'
if not data[tostring(admins)] then
data[tostring(admins)] = {}
save_data(_config.moderation.data, data)
end
local message = 'List for Realm admins:\n'
for k,v in pairs(data[tostring(admins)]) do
message = message .. '- (at)' .. v .. ' [' .. k .. '] ' ..'\n'
end
return message
end
local function group_list(msg)
local data = load_data(_config.moderation.data)
local groups = 'groups'
if not data[tostring(groups)] then
return 'No groups at the moment'
end
local message = 'List of groups:\n'
for k,v in pairs(data[tostring(groups)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairs(settings) do
if m == 'set_name' then
name = n
end
end
local group_owner = "No owner"
if data[tostring(v)]['set_owner'] then
group_owner = tostring(data[tostring(v)]['set_owner'])
end
local group_link = "No link"
if data[tostring(v)]['settings']['set_link'] then
group_link = data[tostring(v)]['settings']['set_link']
end
message = message .. '- '.. name .. ' (' .. v .. ') ['..group_owner..'] \n {'..group_link.."}\n"
end
local file = io.open("groups.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function admin_user_promote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
if not data['admins'] then
data['admins'] = {}
save_data(_config.moderation.data, data)
end
if data['admins'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is already as admin.')
end
data['admins'][tostring(member_id)] = member_username
save_data(_config.moderation.data, data)
return send_large_msg(receiver, '@'..member_username..' has been promoted as admin.')
end
local function admin_user_demote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
if not data['admins'] then
data['admins'] = {}
save_data(_config.moderation.data, data)
end
if not data['admins'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is not an admin.')
end
data['admins'][tostring(member_id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Admin '..member_username..' has been demoted.')
end
local function username_id(cb_extra, success, result)
local mod_cmd = cb_extra.mod_cmd
local receiver = cb_extra.receiver
local member = cb_extra.member
local text = 'No user @'..member..' in this group.'
for k,v in pairs(result.members) do
vusername = v.username
if vusername == member then
member_username = member
member_id = v.id
if mod_cmd == 'addadmin' then
return admin_user_promote(receiver, member_username, member_id)
elseif mod_cmd == 'removeadmin' then
return admin_user_demote(receiver, member_username, member_id)
end
end
end
send_large_msg(receiver, text)
end
function run(msg, matches)
--vardump(msg)
if matches[1] == 'creategroup' and matches[2] then
group_name = matches[2]
return create_group(msg)
end
if matches[1] == 'log' and is_owner(msg) then
savelog(msg.to.id, "log file created by owner")
send_document("chat#id"..msg.to.id,"./groups/"..msg.to.id.."log.txt", ok_cb, false)
end
if matches[1] == 'who' and is_momod(msg) then
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list ")
local receiver = get_receiver(msg)
chat_info(receiver, returnidsfile, {receiver=receiver})
end
if matches[1] == 'wholist' and is_momod(msg) then
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list in a file")
local receiver = get_receiver(msg)
chat_info(receiver, returnids, {receiver=receiver})
end
if not is_realm(msg) then
return
end
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
if matches[2] then if data[tostring(matches[2])] then
local settings = data[tostring(matches[2])]['settings']
if matches[1] == 'setabout' and matches[2] then
local target = matches[2]
local about = matches[3]
return set_description(msg, data, target, about)
end
if matches[1] == 'setrules' then
rules = matches[3]
local target = matches[2]
return set_rules(msg, data, target)
end
if matches[1] == 'lock' then --group lock *
local target = matches[2]
if matches[3] == 'name' then
return lock_group_name(msg, data, target)
end
if matches[3] == 'member' then
return lock_group_member(msg, data, target)
end
if matches[3] == 'photo' then
return lock_group_photo(msg, data, target)
end
if matches[3] == 'flood' then
return lock_group_flood(msg, data, target)
end
end
if matches[1] == 'unlock' then --group unlock *
local target = matches[2]
if matches[3] == 'name' then
return unlock_group_name(msg, data, target)
end
if matches[3] == 'member' then
return unlock_group_member(msg, data, target)
end
if matches[3] == 'photo' then
return unlock_group_photo(msg, data, target)
end
if matches[3] == 'flood' then
return unlock_group_flood(msg, data, target)
end
end
if matches[1] == 'setting' and data[tostring(matches[2])]['settings'] then
local target = matches[2]
return show_group_settings(msg, data, target)
end
if matches[1] == 'setname' and is_admin(msg) then
local new_name = string.gsub(matches[3], '_', ' ')
data[tostring(matches[2])]['settings']['set_name'] = new_name
save_data(_config.moderation.data, data)
local group_name_set = data[tostring(matches[2])]['settings']['set_name']
local to_rename = 'chat#id'..matches[2]
rename_chat(to_rename, group_name_set, ok_cb, false)
end
end end
if matches[1] == 'chat_add_user' then
if not msg.service then
return "Are you trying to troll me?"
end
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
if not is_admin(msg) then
chat_del_user(chat, user, ok_cb, true)
end
end
if matches[1] == 'addadmin' then
if string.match(matches[2], '^%d+$') then
local admin_id = matches[2]
print("user "..admin_id.." has been promoted as admin")
return admin_promote(msg, admin_id)
else
local member = string.gsub(matches[2], "@", "")
local mod_cmd = "addadmin"
chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member})
end
end
if matches[1] == 'removeadmin' then
if string.match(matches[2], '^%d+$') then
local admin_id = matches[2]
print("user "..admin_id.." has been demoted")
return admin_demote(msg, admin_id)
else
local member = string.gsub(matches[2], "@", "")
local mod_cmd = "removeadmin"
chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member})
end
end
if matches[1] == 'list' and matches[2] == 'admins' then
return admin_list(msg)
end
if matches[1] == 'list' and matches[2] == 'groups' then
group_list(msg)
send_document("chat#id"..msg.to.id, "groups.txt", ok_cb, false)
return " Group list created" --group_list(msg)
end
end
return {
patterns = {
"^[!/](creategroup) (.*)$",
"^[!/](setabout) (%d+) (.*)$",
"^[!/](setrules) (%d+) (.*)$",
"^[!/](setname) (%d+) (.*)$",
"^[!/](lock) (%d+) (.*)$",
"^[!/](unlock) (%d+) (.*)$",
"^[!/](setting) (%d+)$",
"^[!/](wholist)$",
"^[!/](who)$",
"^[!/](addadmin) (.*)$", -- sudoers only
"^[!/](removeadmin) (.*)$", -- sudoers only
"^[!/](list) (.*)$",
"^[!/](log)$",
"^!!tgservice (.+)$",
},
run = run
}
end
| gpl-2.0 |
hamode-Aliraq/HAMODE_ALIRAQE | plugins/writer.lua | 13 | 15918 | --[[
#
#ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ
#:((
# For More Information ....!
# Developer : Aziz < @TH3_GHOST >
# our channel: @DevPointTeam
# Version: 1.1
#:))
#ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ
#
]]
local function DevPoint(msg, matches)
if #matches < 2 then
return "اكتب الامر /write ثم ضع فاصلة واكتب الجملة وستظهر لك نتائج الزخرفة " end
if string.len(matches[2]) > 20 then
return "متاح لك 20 حرف انكليزي فقط لايمكنك وضع حروف اكثر ❤️😐 @"..msg.from.username..'\n'
end--@devPointch
local font_base = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,9,8,7,6,5,4,3,2,1,.,_"
local font_hash = "z,y,x,w,v,u,t,s,r,q,p,o,n,m,l,k,j,i,h,g,f,e,d,c,b,a,Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C,B,A,0,1,2,3,4,5,6,7,8,9,.,_"
local fonts = {
"ⓐ,ⓑ,ⓒ,ⓓ,ⓔ,ⓕ,ⓖ,ⓗ,ⓘ,ⓙ,ⓚ,ⓛ,ⓜ,ⓝ,ⓞ,ⓟ,ⓠ,ⓡ,ⓢ,ⓣ,ⓤ,ⓥ,ⓦ,ⓧ,ⓨ,ⓩ,ⓐ,ⓑ,ⓒ,ⓓ,ⓔ,ⓕ,ⓖ,ⓗ,ⓘ,ⓙ,ⓚ,ⓛ,ⓜ,ⓝ,ⓞ,ⓟ,ⓠ,ⓡ,ⓢ,ⓣ,ⓤ,ⓥ,ⓦ,ⓧ,ⓨ,ⓩ,⓪,➈,➇,➆,➅,➄,➃,➂,➁,➀,●,_",
"⒜,⒝,⒞,⒟,⒠,⒡,⒢,⒣,⒤,⒥,⒦,⒧,⒨,⒩,⒪,⒫,⒬,⒭,⒮,⒯,⒰,⒱,⒲,⒳,⒴,⒵,⒜,⒝,⒞,⒟,⒠,⒡,⒢,⒣,⒤,⒥,⒦,⒧,⒨,⒩,⒪,⒫,⒬,⒭,⒮,⒯,⒰,⒱,⒲,⒳,⒴,⒵,⓪,⑼,⑻,⑺,⑹,⑸,⑷,⑶,⑵,⑴,.,_",
"α,в,c,∂,є,ƒ,g,н,ι,נ,к,ℓ,м,η,σ,ρ,q,я,ѕ,т,υ,ν,ω,χ,у,z,α,в,c,∂,є,ƒ,g,н,ι,נ,к,ℓ,м,η,σ,ρ,q,я,ѕ,т,υ,ν,ω,χ,у,z,0,9,8,7,6,5,4,3,2,1,.,_",
"α,в,c,d,e,ғ,ɢ,н,ι,j,ĸ,l,м,ɴ,o,p,q,r,ѕ,т,υ,v,w,х,y,z,α,в,c,d,e,ғ,ɢ,н,ι,j,ĸ,l,м,ɴ,o,p,q,r,ѕ,т,υ,v,w,х,y,z,0,9,8,7,6,5,4,3,2,1,.,_",
"α,в,¢,đ,e,f,g,ħ,ı,נ,κ,ł,м,и,ø,ρ,q,я,š,т,υ,ν,ω,χ,ч,z,α,в,¢,đ,e,f,g,ħ,ı,נ,κ,ł,м,и,ø,ρ,q,я,š,т,υ,ν,ω,χ,ч,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ą,ҍ,ç,ժ,ҽ,ƒ,ց,հ,ì,ʝ,ҟ,Ӏ,ʍ,ղ,օ,ք,զ,ɾ,ʂ,է,մ,ѵ,ա,×,վ,Հ,ą,ҍ,ç,ժ,ҽ,ƒ,ց,հ,ì,ʝ,ҟ,Ӏ,ʍ,ղ,օ,ք,զ,ɾ,ʂ,է,մ,ѵ,ա,×,վ,Հ,⊘,९,𝟠,7,Ϭ,Ƽ,५,Ӡ,ϩ,𝟙,.,_", "ค,ც,८,ძ,૯,Բ,૭,Һ,ɿ,ʆ,қ,Ն,ɱ,Ո,૦,ƿ,ҩ,Ր,ς,੮,υ,౮,ω,૪,ע,ઽ,ค,ც,८,ძ,૯,Բ,૭,Һ,ɿ,ʆ,қ,Ն,ɱ,Ո,૦,ƿ,ҩ,Ր,ς,੮,υ,౮,ω,૪,ע,ઽ,0,9,8,7,6,5,4,3,2,1,.,_",
"α,ß,ς,d,ε,ƒ,g,h,ï,յ,κ,レ,m,η,⊕,p,Ω,r,š,†,u,∀,ω,x,ψ,z,α,ß,ς,d,ε,ƒ,g,h,ï,յ,κ,レ,m,η,⊕,p,Ω,r,š,†,u,∀,ω,x,ψ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ค,๒,ς,๔,є,Ŧ,ɠ,ђ,เ,ן,к,l,๓,ภ,๏,թ,ợ,г,ร,t,ย,v,ฬ,x,ץ,z,ค,๒,ς,๔,є,Ŧ,ɠ,ђ,เ,ן,к,l,๓,ภ,๏,թ,ợ,г,ร,t,ย,v,ฬ,x,ץ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ム,乃,ζ,Ð,乇,キ,Ǥ,ん,ノ,フ,ズ,レ,ᄊ,刀,Ծ,ア,Q,尺,ㄎ,イ,Ц,Џ,Щ,メ,リ,乙,ム,乃,ζ,Ð,乇,キ,Ǥ,ん,ノ,フ,ズ,レ,ᄊ,刀,Ծ,ア,q,尺,ㄎ,イ,Ц,Џ,Щ,メ,リ,乙,ᅙ,9,8,ᆨ,6,5,4,3,ᆯ,1,.,_",
"α,β,c,δ,ε,Ŧ,ĝ,h,ι,j,κ,l,ʍ,π,ø,ρ,φ,Ʀ,$,†,u,υ,ω,χ,ψ,z,α,β,c,δ,ε,Ŧ,ĝ,h,ι,j,κ,l,ʍ,π,ø,ρ,φ,Ʀ,$,†,u,υ,ω,χ,ψ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ձ,ъ,ƈ,ժ,ε,բ,ց,հ,ﻨ,յ,ĸ,l,ო,ռ,օ,թ,զ,г,ร,է,ս,ν,ա,×,ყ,২,ձ,ъ,ƈ,ժ,ε,բ,ց,հ,ﻨ,յ,ĸ,l,ო,ռ,օ,թ,զ,г,ร,է,ս,ν,ա,×,ყ,২,0,9,8,7,6,5,4,3,2,1,.,_",
"Λ,ɓ,¢,Ɗ,£,ƒ,ɢ,ɦ,ĩ,ʝ,Қ,Ł,ɱ,ה,ø,Ṗ,Ҩ,Ŕ,Ş,Ŧ,Ū,Ɣ,ω,Ж,¥,Ẑ,Λ,ɓ,¢,Ɗ,£,ƒ,ɢ,ɦ,ĩ,ʝ,Қ,Ł,ɱ,ה,ø,Ṗ,Ҩ,Ŕ,Ş,Ŧ,Ū,Ɣ,ω,Ж,¥,Ẑ,0,9,8,7,6,5,4,3,2,1,.,_",
"Λ,Б,Ͼ,Ð,Ξ,Ŧ,G,H,ł,J,К,Ł,M,Л,Ф,P,Ǫ,Я,S,T,U,V,Ш,Ж,Џ,Z,Λ,Б,Ͼ,Ð,Ξ,Ŧ,g,h,ł,j,К,Ł,m,Л,Ф,p,Ǫ,Я,s,t,u,v,Ш,Ж,Џ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ɐ,q,ɔ,p,ǝ,ɟ,ɓ,ɥ,ı,ſ,ʞ,ๅ,ɯ,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,ɐ,q,ɔ,p,ǝ,ɟ,ɓ,ɥ,ı,ſ,ʞ,ๅ,ɯ,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ɒ,d,ɔ,b,ɘ,ʇ,ϱ,н,i,į,ʞ,l,м,и,o,q,p,я,ƨ,т,υ,v,w,x,γ,z,ɒ,d,ɔ,b,ɘ,ʇ,ϱ,н,i,į,ʞ,l,м,и,o,q,p,я,ƨ,т,υ,v,w,x,γ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"A̴,̴B̴,̴C̴,̴D̴,̴E̴,̴F̴,̴G̴,̴H̴,̴I̴,̴J̴,̴K̴,̴L̴,̴M̴,̴N̴,̴O̴,̴P̴,̴Q̴,̴R̴,̴S̴,̴T̴,̴U̴,̴V̴,̴W̴,̴X̴,̴Y̴,̴Z̴,̴a̴,̴b̴,̴c̴,̴d̴,̴e̴,̴f̴,̴g̴,̴h̴,̴i̴,̴j̴,̴k̴,̴l̴,̴m̴,̴n̴,̴o̴,̴p̴,̴q̴,̴r̴,̴s̴,̴t̴,̴u̴,̴v̴,̴w̴,̴x̴,̴y̴,̴z̴,̴0̴,̴9̴,̴8̴,̴7̴,̴6̴,̴5̴,̴4̴,̴3̴,̴2̴,̴1̴,̴.̴,̴_̴",
"ⓐ,ⓑ,ⓒ,ⓓ,ⓔ,ⓕ,ⓖ,ⓗ,ⓘ,ⓙ,ⓚ,ⓛ,ⓜ,ⓝ,ⓞ,ⓟ,ⓠ,ⓡ,ⓢ,ⓣ,ⓤ,ⓥ,ⓦ,ⓧ,ⓨ,ⓩ,ⓐ,ⓑ,ⓒ,ⓓ,ⓔ,ⓕ,ⓖ,ⓗ,ⓘ,ⓙ,ⓚ,ⓛ,ⓜ,ⓝ,ⓞ,ⓟ,ⓠ,ⓡ,ⓢ,ⓣ,ⓤ,ⓥ,ⓦ,ⓧ,ⓨ,ⓩ,⓪,➈,➇,➆,➅,➄,➃,➂,➁,➀,●,_",
"⒜,⒝,⒞,⒟,⒠,⒡,⒢,⒣,⒤,⒥,⒦,⒧,⒨,⒩,⒪,⒫,⒬,⒭,⒮,⒯,⒰,⒱,⒲,⒳,⒴,⒵,⒜,⒝,⒞,⒟,⒠,⒡,⒢,⒣,⒤,⒥,⒦,⒧,⒨,⒩,⒪,⒫,⒬,⒭,⒮,⒯,⒰,⒱,⒲,⒳,⒴,⒵,⓪,⑼,⑻,⑺,⑹,⑸,⑷,⑶,⑵,⑴,.,_",
"α,в,c,∂,є,ƒ,g,н,ι,נ,к,ℓ,м,η,σ,ρ,q,я,ѕ,т,υ,ν,ω,χ,у,z,α,в,c,∂,є,ƒ,g,н,ι,נ,к,ℓ,м,η,σ,ρ,q,я,ѕ,т,υ,ν,ω,χ,у,z,0,9,8,7,6,5,4,3,2,1,.,_",
"α,в,c,ɗ,є,f,g,н,ι,נ,к,Ɩ,м,η,σ,ρ,q,я,ѕ,т,υ,ν,ω,x,у,z,α,в,c,ɗ,є,f,g,н,ι,נ,к,Ɩ,м,η,σ,ρ,q,я,ѕ,т,υ,ν,ω,x,у,z,0,9,8,7,6,5,4,3,2,1,.,_",
"α,в,c,d,e,ғ,ɢ,н,ι,j,ĸ,l,м,ɴ,o,p,q,r,ѕ,т,υ,v,w,х,y,z,α,в,c,d,e,ғ,ɢ,н,ι,j,ĸ,l,м,ɴ,o,p,q,r,ѕ,т,υ,v,w,х,y,z,0,9,8,7,6,5,4,3,2,1,.,_",
"α,Ⴆ,ƈ,ԃ,ҽ,ϝ,ɠ,ԋ,ι,ʝ,ƙ,ʅ,ɱ,ɳ,σ,ρ,ϙ,ɾ,ʂ,ƚ,υ,ʋ,ɯ,x,ყ,ȥ,α,Ⴆ,ƈ,ԃ,ҽ,ϝ,ɠ,ԋ,ι,ʝ,ƙ,ʅ,ɱ,ɳ,σ,ρ,ϙ,ɾ,ʂ,ƚ,υ,ʋ,ɯ,x,ყ,ȥ,0,9,8,7,6,5,4,3,2,1,.,_",
"α,в,¢,đ,e,f,g,ħ,ı,נ,κ,ł,м,и,ø,ρ,q,я,š,т,υ,ν,ω,χ,ч,z,α,в,¢,đ,e,f,g,ħ,ı,נ,κ,ł,м,и,ø,ρ,q,я,š,т,υ,ν,ω,χ,ч,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ą,ɓ,ƈ,đ,ε,∱,ɠ,ɧ,ï,ʆ,ҡ,ℓ,ɱ,ŋ,σ,þ,ҩ,ŗ,ş,ŧ,ų,√,щ,х,γ,ẕ,ą,ɓ,ƈ,đ,ε,∱,ɠ,ɧ,ï,ʆ,ҡ,ℓ,ɱ,ŋ,σ,þ,ҩ,ŗ,ş,ŧ,ų,√,щ,х,γ,ẕ,0,9,8,7,6,5,4,3,2,1,.,_",
"ą,ҍ,ç,ժ,ҽ,ƒ,ց,հ,ì,ʝ,ҟ,Ӏ,ʍ,ղ,օ,ք,զ,ɾ,ʂ,է,մ,ѵ,ա,×,վ,Հ,ą,ҍ,ç,ժ,ҽ,ƒ,ց,հ,ì,ʝ,ҟ,Ӏ,ʍ,ղ,օ,ք,զ,ɾ,ʂ,է,մ,ѵ,ա,×,վ,Հ,⊘,९,𝟠,7,Ϭ,Ƽ,५,Ӡ,ϩ,𝟙,.,_",
"მ,ჩ,ƈ,ძ,ε,բ,ց,հ,ἶ,ʝ,ƙ,l,ო,ղ,օ,ր,գ,ɾ,ʂ,է,մ,ν,ω,ჯ,ყ,z,მ,ჩ,ƈ,ძ,ε,բ,ց,հ,ἶ,ʝ,ƙ,l,ო,ղ,օ,ր,գ,ɾ,ʂ,է,մ,ν,ω,ჯ,ყ,z,0,Գ,Ց,Դ,6,5,Վ,Յ,Զ,1,.,_",
"ค,ც,८,ძ,૯,Բ,૭,Һ,ɿ,ʆ,қ,Ն,ɱ,Ո,૦,ƿ,ҩ,Ր,ς,੮,υ,౮,ω,૪,ע,ઽ,ค,ც,८,ძ,૯,Բ,૭,Һ,ɿ,ʆ,қ,Ն,ɱ,Ո,૦,ƿ,ҩ,Ր,ς,੮,υ,౮,ω,૪,ע,ઽ,0,9,8,7,6,5,4,3,2,1,.,_",
"α,ß,ς,d,ε,ƒ,g,h,ï,յ,κ,レ,m,η,⊕,p,Ω,r,š,†,u,∀,ω,x,ψ,z,α,ß,ς,d,ε,ƒ,g,h,ï,յ,κ,レ,m,η,⊕,p,Ω,r,š,†,u,∀,ω,x,ψ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ª,b,¢,Þ,È,F,૬,ɧ,Î,j,Κ,Ļ,м,η,◊,Ƿ,ƍ,r,S,⊥,µ,√,w,×,ý,z,ª,b,¢,Þ,È,F,૬,ɧ,Î,j,Κ,Ļ,м,η,◊,Ƿ,ƍ,r,S,⊥,µ,√,w,×,ý,z,0,9,8,7,6,5,4,3,2,1,.,_",
"Δ,Ɓ,C,D,Σ,F,G,H,I,J,Ƙ,L,Μ,∏,Θ,Ƥ,Ⴓ,Γ,Ѕ,Ƭ,Ʊ,Ʋ,Ш,Ж,Ψ,Z,λ,ϐ,ς,d,ε,ғ,ɢ,н,ι,ϳ,κ,l,ϻ,π,σ,ρ,φ,г,s,τ,υ,v,ш,ϰ,ψ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ค,๒,ς,๔,є,Ŧ,ɠ,ђ,เ,ן,к,l,๓,ภ,๏,թ,ợ,г,ร,t,ย,v,ฬ,x,ץ,z,ค,๒,ς,๔,є,Ŧ,ɠ,ђ,เ,ן,к,l,๓,ภ,๏,թ,ợ,г,ร,t,ย,v,ฬ,x,ץ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"Λ,ß,Ƈ,D,Ɛ,F,Ɠ,Ĥ,Ī,Ĵ,Ҡ,Ŀ,M,И,♡,Ṗ,Ҩ,Ŕ,S,Ƭ,Ʊ,Ѵ,Ѡ,Ӿ,Y,Z,Λ,ß,Ƈ,D,Ɛ,F,Ɠ,Ĥ,Ī,Ĵ,Ҡ,Ŀ,M,И,♡,Ṗ,Ҩ,Ŕ,S,Ƭ,Ʊ,Ѵ,Ѡ,Ӿ,Y,Z,0,9,8,7,6,5,4,3,2,1,.,_",
"ム,乃,ζ,Ð,乇,キ,Ǥ,ん,ノ,フ,ズ,レ,ᄊ,刀,Ծ,ア,Q,尺,ㄎ,イ,Ц,Џ,Щ,メ,リ,乙,ム,乃,ζ,Ð,乇,キ,Ǥ,ん,ノ,フ,ズ,レ,ᄊ,刀,Ծ,ア,q,尺,ㄎ,イ,Ц,Џ,Щ,メ,リ,乙,ᅙ,9,8,ᆨ,6,5,4,3,ᆯ,1,.,_",
"α,β,c,δ,ε,Ŧ,ĝ,h,ι,j,κ,l,ʍ,π,ø,ρ,φ,Ʀ,$,†,u,υ,ω,χ,ψ,z,α,β,c,δ,ε,Ŧ,ĝ,h,ι,j,κ,l,ʍ,π,ø,ρ,φ,Ʀ,$,†,u,υ,ω,χ,ψ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ค,๖,¢,໓,ē,f,ງ,h,i,ว,k,l,๓,ຖ,໐,p,๑,r,Ş,t,น,ง,ຟ,x,ฯ,ຊ,ค,๖,¢,໓,ē,f,ງ,h,i,ว,k,l,๓,ຖ,໐,p,๑,r,Ş,t,น,ง,ຟ,x,ฯ,ຊ,0,9,8,7,6,5,4,3,2,1,.,_",
"ձ,ъ,ƈ,ժ,ε,բ,ց,հ,ﻨ,յ,ĸ,l,ო,ռ,օ,թ,զ,г,ร,է,ս,ν,ա,×,ყ,২,ձ,ъ,ƈ,ժ,ε,բ,ց,հ,ﻨ,յ,ĸ,l,ო,ռ,օ,թ,զ,г,ร,է,ս,ν,ա,×,ყ,২,0,9,8,7,6,5,4,3,2,1,.,_",
"Â,ß,Ĉ,Ð,Є,Ŧ,Ǥ,Ħ,Ī,ʖ,Қ,Ŀ,♏,И,Ø,P,Ҩ,R,$,ƚ,Ц,V,Щ,X,¥,Ẕ,Â,ß,Ĉ,Ð,Є,Ŧ,Ǥ,Ħ,Ī,ʖ,Қ,Ŀ,♏,И,Ø,P,Ҩ,R,$,ƚ,Ц,V,Щ,X,¥,Ẕ,0,9,8,7,6,5,4,3,2,1,.,_",
"Λ,ɓ,¢,Ɗ,£,ƒ,ɢ,ɦ,ĩ,ʝ,Қ,Ł,ɱ,ה,ø,Ṗ,Ҩ,Ŕ,Ş,Ŧ,Ū,Ɣ,ω,Ж,¥,Ẑ,Λ,ɓ,¢,Ɗ,£,ƒ,ɢ,ɦ,ĩ,ʝ,Қ,Ł,ɱ,ה,ø,Ṗ,Ҩ,Ŕ,Ş,Ŧ,Ū,Ɣ,ω,Ж,¥,Ẑ,0,9,8,7,6,5,4,3,2,1,.,_",
"Λ,Б,Ͼ,Ð,Ξ,Ŧ,G,H,ł,J,К,Ł,M,Л,Ф,P,Ǫ,Я,S,T,U,V,Ш,Ж,Џ,Z,Λ,Б,Ͼ,Ð,Ξ,Ŧ,g,h,ł,j,К,Ł,m,Л,Ф,p,Ǫ,Я,s,t,u,v,Ш,Ж,Џ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"Թ,Յ,Շ,Ժ,ȝ,Բ,Գ,ɧ,ɿ,ʝ,ƙ,ʅ,ʍ,Ռ,Ծ,ρ,φ,Ր,Տ,Ե,Մ,ע,ա,Ճ,Վ,Հ,Թ,Յ,Շ,Ժ,ȝ,Բ,Գ,ɧ,ɿ,ʝ,ƙ,ʅ,ʍ,Ռ,Ծ,ρ,φ,Ր,Տ,Ե,Մ,ע,ա,Ճ,Վ,Հ,0,9,8,7,6,5,4,3,2,1,.,_",
"Æ,þ,©,Ð,E,F,ζ,Ħ,Ї,¿,ズ,ᄂ,M,Ñ,Θ,Ƿ,Ø,Ґ,Š,τ,υ,¥,w,χ,y,շ,Æ,þ,©,Ð,E,F,ζ,Ħ,Ї,¿,ズ,ᄂ,M,Ñ,Θ,Ƿ,Ø,Ґ,Š,τ,υ,¥,w,χ,y,շ,0,9,8,7,6,5,4,3,2,1,.,_",
"ɐ,q,ɔ,p,ǝ,ɟ,ɓ,ɥ,ı,ſ,ʞ,ๅ,ɯ,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,ɐ,q,ɔ,p,ǝ,ɟ,ɓ,ɥ,ı,ſ,ʞ,ๅ,ɯ,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ɒ,d,ɔ,b,ɘ,ʇ,ϱ,н,i,į,ʞ,l,м,и,o,q,p,я,ƨ,т,υ,v,w,x,γ,z,ɒ,d,ɔ,b,ɘ,ʇ,ϱ,н,i,į,ʞ,l,м,и,o,q,p,я,ƨ,т,υ,v,w,x,γ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"4,8,C,D,3,F,9,H,!,J,K,1,M,N,0,P,Q,R,5,7,U,V,W,X,Y,2,4,8,C,D,3,F,9,H,!,J,K,1,M,N,0,P,Q,R,5,7,U,V,W,X,Y,2,0,9,8,7,6,5,4,3,2,1,.,_",
"Λ,M,X,ʎ,Z,ɐ,q,ɔ,p,ǝ,ɟ,ƃ,ɥ,ı,ɾ,ʞ,l,ա,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,Λ,M,X,ʎ,Z,ɐ,q,ɔ,p,ǝ,ɟ,ƃ,ɥ,ı,ɾ,ʞ,l,ա,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,0,9,8,7,6,5,4,3,2,1,.,‾",
"A̴,̴B̴,̴C̴,̴D̴,̴E̴,̴F̴,̴G̴,̴H̴,̴I̴,̴J̴,̴K̴,̴L̴,̴M̴,̴N̴,̴O̴,̴P̴,̴Q̴,̴R̴,̴S̴,̴T̴,̴U̴,̴V̴,̴W̴,̴X̴,̴Y̴,̴Z̴,̴a̴,̴b̴,̴c̴,̴d̴,̴e̴,̴f̴,̴g̴,̴h̴,̴i̴,̴j̴,̴k̴,̴l̴,̴m̴,̴n̴,̴o̴,̴p̴,̴q̴,̴r̴,̴s̴,̴t̴,̴u̴,̴v̴,̴w̴,̴x̴,̴y̴,̴z̴,̴0̴,̴9̴,̴8̴,̴7̴,̴6̴,̴5̴,̴4̴,̴3̴,̴2̴,̴1̴,̴.̴,̴_̴",
"A̱,̱Ḇ,̱C̱,̱Ḏ,̱E̱,̱F̱,̱G̱,̱H̱,̱I̱,̱J̱,̱Ḵ,̱Ḻ,̱M̱,̱Ṉ,̱O̱,̱P̱,̱Q̱,̱Ṟ,̱S̱,̱Ṯ,̱U̱,̱V̱,̱W̱,̱X̱,̱Y̱,̱Ẕ,̱a̱,̱ḇ,̱c̱,̱ḏ,̱e̱,̱f̱,̱g̱,̱ẖ,̱i̱,̱j̱,̱ḵ,̱ḻ,̱m̱,̱ṉ,̱o̱,̱p̱,̱q̱,̱ṟ,̱s̱,̱ṯ,̱u̱,̱v̱,̱w̱,̱x̱,̱y̱,̱ẕ,̱0̱,̱9̱,̱8̱,̱7̱,̱6̱,̱5̱,̱4̱,̱3̱,̱2̱,̱1̱,̱.̱,̱_̱",
"A̲,̲B̲,̲C̲,̲D̲,̲E̲,̲F̲,̲G̲,̲H̲,̲I̲,̲J̲,̲K̲,̲L̲,̲M̲,̲N̲,̲O̲,̲P̲,̲Q̲,̲R̲,̲S̲,̲T̲,̲U̲,̲V̲,̲W̲,̲X̲,̲Y̲,̲Z̲,̲a̲,̲b̲,̲c̲,̲d̲,̲e̲,̲f̲,̲g̲,̲h̲,̲i̲,̲j̲,̲k̲,̲l̲,̲m̲,̲n̲,̲o̲,̲p̲,̲q̲,̲r̲,̲s̲,̲t̲,̲u̲,̲v̲,̲w̲,̲x̲,̲y̲,̲z̲,̲0̲,̲9̲,̲8̲,̲7̲,̲6̲,̲5̲,̲4̲,̲3̲,̲2̲,̲1̲,̲.̲,̲_̲",
"Ā,̄B̄,̄C̄,̄D̄,̄Ē,̄F̄,̄Ḡ,̄H̄,̄Ī,̄J̄,̄K̄,̄L̄,̄M̄,̄N̄,̄Ō,̄P̄,̄Q̄,̄R̄,̄S̄,̄T̄,̄Ū,̄V̄,̄W̄,̄X̄,̄Ȳ,̄Z̄,̄ā,̄b̄,̄c̄,̄d̄,̄ē,̄f̄,̄ḡ,̄h̄,̄ī,̄j̄,̄k̄,̄l̄,̄m̄,̄n̄,̄ō,̄p̄,̄q̄,̄r̄,̄s̄,̄t̄,̄ū,̄v̄,̄w̄,̄x̄,̄ȳ,̄z̄,̄0̄,̄9̄,̄8̄,̄7̄,̄6̄,̄5̄,̄4̄,̄3̄,̄2̄,̄1̄,̄.̄,̄_̄",
"A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,9,8,7,6,5,4,3,2,1,.,_",
"a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,9,8,7,6,5,4,3,2,1,.,_",
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
local result = {}
i=0
for k=1,#fonts do
i=i+1
local tar_font = fonts[i]:split(",")
local text = matches[2]
local text = text:gsub("A",tar_font[1])
local text = text:gsub("B",tar_font[2])
local text = text:gsub("C",tar_font[3])
local text = text:gsub("D",tar_font[4])
local text = text:gsub("E",tar_font[5])
local text = text:gsub("F",tar_font[6])
local text = text:gsub("G",tar_font[7])
local text = text:gsub("H",tar_font[8])
local text = text:gsub("I",tar_font[9])
local text = text:gsub("J",tar_font[10])
local text = text:gsub("K",tar_font[11])
local text = text:gsub("L",tar_font[12])
local text = text:gsub("M",tar_font[13])
local text = text:gsub("N",tar_font[14])
local text = text:gsub("O",tar_font[15])
local text = text:gsub("P",tar_font[16])
local text = text:gsub("Q",tar_font[17])
local text = text:gsub("R",tar_font[18])
local text = text:gsub("S",tar_font[19])
local text = text:gsub("T",tar_font[20])
local text = text:gsub("U",tar_font[21])
local text = text:gsub("V",tar_font[22])
local text = text:gsub("W",tar_font[23])
local text = text:gsub("X",tar_font[24])
local text = text:gsub("Y",tar_font[25])
local text = text:gsub("Z",tar_font[26])
local text = text:gsub("a",tar_font[27])
local text = text:gsub("b",tar_font[28])
local text = text:gsub("c",tar_font[29])
local text = text:gsub("d",tar_font[30])
local text = text:gsub("e",tar_font[31])
local text = text:gsub("f",tar_font[32])
local text = text:gsub("g",tar_font[33])
local text = text:gsub("h",tar_font[34])
local text = text:gsub("i",tar_font[35])
local text = text:gsub("j",tar_font[36])
local text = text:gsub("k",tar_font[37])
local text = text:gsub("l",tar_font[38])
local text = text:gsub("m",tar_font[39])
local text = text:gsub("n",tar_font[40])
local text = text:gsub("o",tar_font[41])
local text = text:gsub("p",tar_font[42])
local text = text:gsub("q",tar_font[43])
local text = text:gsub("r",tar_font[44])
local text = text:gsub("s",tar_font[45])
local text = text:gsub("t",tar_font[46])
local text = text:gsub("u",tar_font[47])
local text = text:gsub("v",tar_font[48])
local text = text:gsub("w",tar_font[49])
local text = text:gsub("x",tar_font[50])
local text = text:gsub("y",tar_font[51])
local text = text:gsub("z",tar_font[52])
local text = text:gsub("0",tar_font[53])
local text = text:gsub("9",tar_font[54])
local text = text:gsub("8",tar_font[55])
local text = text:gsub("7",tar_font[56])
local text = text:gsub("6",tar_font[57])
local text = text:gsub("5",tar_font[58])
local text = text:gsub("4",tar_font[59])
local text = text:gsub("3",tar_font[60])
local text = text:gsub("2",tar_font[61])
local text = text:gsub("1",tar_font[62])
table.insert(result, text)
end--@DevPointCH
local result_text = "زخرفة كلمة : "..matches[2].."\nتطبيق اكثر من "..tostring(#fonts).." نوع من الخطوط : \n______________________________\n"
a=0
for v=1,#result do
a=a+1
result_text = result_text..a.."- "..result[a].."\n\n"
end
return result_text.."______________________________\nChannel : @DevPointCH 🎗"
end
return {
description = "Fantasy Writer",
usagehtm = '<tr><td align="center">write </td><td align="right">ملف زخرفة للكلمات الانكليزية ملف يحتوي على اكثر من 50 نوع من الخطوط للزخرفة وتحصل على زخارف رائعة يمكنك وضع 20 حرف انكليزي فقط لايمكنك وضع اكثر</td></tr>',
usage = {"write [text] : ",},
patterns = {
"^([/,!][Ww]rite) (.*)",
"^([/,!][Ww]rite)$",
},
run = DevPoint
}
--post by Channel @DevPointCH
--Dont Remove This
| gpl-2.0 |
zachmoore12/wrk-1 | deps/luajit/src/jit/dis_arm.lua | 88 | 19364 | ----------------------------------------------------------------------------
-- LuaJIT ARM disassembler module.
--
-- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This is a helper module used by the LuaJIT machine code dumper module.
--
-- It disassembles most user-mode ARMv7 instructions
-- NYI: Advanced SIMD and VFP instructions.
------------------------------------------------------------------------------
local type = type
local sub, byte, format = string.sub, string.byte, string.format
local match, gmatch, gsub = string.match, string.gmatch, string.gsub
local concat = table.concat
local bit = require("bit")
local band, bor, ror, tohex = bit.band, bit.bor, bit.ror, bit.tohex
local lshift, rshift, arshift = bit.lshift, bit.rshift, bit.arshift
------------------------------------------------------------------------------
-- Opcode maps
------------------------------------------------------------------------------
local map_loadc = {
shift = 8, mask = 15,
[10] = {
shift = 20, mask = 1,
[0] = {
shift = 23, mask = 3,
[0] = "vmovFmDN", "vstmFNdr",
_ = {
shift = 21, mask = 1,
[0] = "vstrFdl",
{ shift = 16, mask = 15, [13] = "vpushFdr", _ = "vstmdbFNdr", }
},
},
{
shift = 23, mask = 3,
[0] = "vmovFDNm",
{ shift = 16, mask = 15, [13] = "vpopFdr", _ = "vldmFNdr", },
_ = {
shift = 21, mask = 1,
[0] = "vldrFdl", "vldmdbFNdr",
},
},
},
[11] = {
shift = 20, mask = 1,
[0] = {
shift = 23, mask = 3,
[0] = "vmovGmDN", "vstmGNdr",
_ = {
shift = 21, mask = 1,
[0] = "vstrGdl",
{ shift = 16, mask = 15, [13] = "vpushGdr", _ = "vstmdbGNdr", }
},
},
{
shift = 23, mask = 3,
[0] = "vmovGDNm",
{ shift = 16, mask = 15, [13] = "vpopGdr", _ = "vldmGNdr", },
_ = {
shift = 21, mask = 1,
[0] = "vldrGdl", "vldmdbGNdr",
},
},
},
_ = {
shift = 0, mask = 0 -- NYI ldc, mcrr, mrrc.
},
}
local map_vfps = {
shift = 6, mask = 0x2c001,
[0] = "vmlaF.dnm", "vmlsF.dnm",
[0x04000] = "vnmlsF.dnm", [0x04001] = "vnmlaF.dnm",
[0x08000] = "vmulF.dnm", [0x08001] = "vnmulF.dnm",
[0x0c000] = "vaddF.dnm", [0x0c001] = "vsubF.dnm",
[0x20000] = "vdivF.dnm",
[0x24000] = "vfnmsF.dnm", [0x24001] = "vfnmaF.dnm",
[0x28000] = "vfmaF.dnm", [0x28001] = "vfmsF.dnm",
[0x2c000] = "vmovF.dY",
[0x2c001] = {
shift = 7, mask = 0x1e01,
[0] = "vmovF.dm", "vabsF.dm",
[0x0200] = "vnegF.dm", [0x0201] = "vsqrtF.dm",
[0x0800] = "vcmpF.dm", [0x0801] = "vcmpeF.dm",
[0x0a00] = "vcmpzF.d", [0x0a01] = "vcmpzeF.d",
[0x0e01] = "vcvtG.dF.m",
[0x1000] = "vcvt.f32.u32Fdm", [0x1001] = "vcvt.f32.s32Fdm",
[0x1800] = "vcvtr.u32F.dm", [0x1801] = "vcvt.u32F.dm",
[0x1a00] = "vcvtr.s32F.dm", [0x1a01] = "vcvt.s32F.dm",
},
}
local map_vfpd = {
shift = 6, mask = 0x2c001,
[0] = "vmlaG.dnm", "vmlsG.dnm",
[0x04000] = "vnmlsG.dnm", [0x04001] = "vnmlaG.dnm",
[0x08000] = "vmulG.dnm", [0x08001] = "vnmulG.dnm",
[0x0c000] = "vaddG.dnm", [0x0c001] = "vsubG.dnm",
[0x20000] = "vdivG.dnm",
[0x24000] = "vfnmsG.dnm", [0x24001] = "vfnmaG.dnm",
[0x28000] = "vfmaG.dnm", [0x28001] = "vfmsG.dnm",
[0x2c000] = "vmovG.dY",
[0x2c001] = {
shift = 7, mask = 0x1e01,
[0] = "vmovG.dm", "vabsG.dm",
[0x0200] = "vnegG.dm", [0x0201] = "vsqrtG.dm",
[0x0800] = "vcmpG.dm", [0x0801] = "vcmpeG.dm",
[0x0a00] = "vcmpzG.d", [0x0a01] = "vcmpzeG.d",
[0x0e01] = "vcvtF.dG.m",
[0x1000] = "vcvt.f64.u32GdFm", [0x1001] = "vcvt.f64.s32GdFm",
[0x1800] = "vcvtr.u32FdG.m", [0x1801] = "vcvt.u32FdG.m",
[0x1a00] = "vcvtr.s32FdG.m", [0x1a01] = "vcvt.s32FdG.m",
},
}
local map_datac = {
shift = 24, mask = 1,
[0] = {
shift = 4, mask = 1,
[0] = {
shift = 8, mask = 15,
[10] = map_vfps,
[11] = map_vfpd,
-- NYI cdp, mcr, mrc.
},
{
shift = 8, mask = 15,
[10] = {
shift = 20, mask = 15,
[0] = "vmovFnD", "vmovFDn",
[14] = "vmsrD",
[15] = { shift = 12, mask = 15, [15] = "vmrs", _ = "vmrsD", },
},
},
},
"svcT",
}
local map_loadcu = {
shift = 0, mask = 0, -- NYI unconditional CP load/store.
}
local map_datacu = {
shift = 0, mask = 0, -- NYI unconditional CP data.
}
local map_simddata = {
shift = 0, mask = 0, -- NYI SIMD data.
}
local map_simdload = {
shift = 0, mask = 0, -- NYI SIMD load/store, preload.
}
local map_preload = {
shift = 0, mask = 0, -- NYI preload.
}
local map_media = {
shift = 20, mask = 31,
[0] = false,
{ --01
shift = 5, mask = 7,
[0] = "sadd16DNM", "sasxDNM", "ssaxDNM", "ssub16DNM",
"sadd8DNM", false, false, "ssub8DNM",
},
{ --02
shift = 5, mask = 7,
[0] = "qadd16DNM", "qasxDNM", "qsaxDNM", "qsub16DNM",
"qadd8DNM", false, false, "qsub8DNM",
},
{ --03
shift = 5, mask = 7,
[0] = "shadd16DNM", "shasxDNM", "shsaxDNM", "shsub16DNM",
"shadd8DNM", false, false, "shsub8DNM",
},
false,
{ --05
shift = 5, mask = 7,
[0] = "uadd16DNM", "uasxDNM", "usaxDNM", "usub16DNM",
"uadd8DNM", false, false, "usub8DNM",
},
{ --06
shift = 5, mask = 7,
[0] = "uqadd16DNM", "uqasxDNM", "uqsaxDNM", "uqsub16DNM",
"uqadd8DNM", false, false, "uqsub8DNM",
},
{ --07
shift = 5, mask = 7,
[0] = "uhadd16DNM", "uhasxDNM", "uhsaxDNM", "uhsub16DNM",
"uhadd8DNM", false, false, "uhsub8DNM",
},
{ --08
shift = 5, mask = 7,
[0] = "pkhbtDNMU", false, "pkhtbDNMU",
{ shift = 16, mask = 15, [15] = "sxtb16DMU", _ = "sxtab16DNMU", },
"pkhbtDNMU", "selDNM", "pkhtbDNMU",
},
false,
{ --0a
shift = 5, mask = 7,
[0] = "ssatDxMu", "ssat16DxM", "ssatDxMu",
{ shift = 16, mask = 15, [15] = "sxtbDMU", _ = "sxtabDNMU", },
"ssatDxMu", false, "ssatDxMu",
},
{ --0b
shift = 5, mask = 7,
[0] = "ssatDxMu", "revDM", "ssatDxMu",
{ shift = 16, mask = 15, [15] = "sxthDMU", _ = "sxtahDNMU", },
"ssatDxMu", "rev16DM", "ssatDxMu",
},
{ --0c
shift = 5, mask = 7,
[3] = { shift = 16, mask = 15, [15] = "uxtb16DMU", _ = "uxtab16DNMU", },
},
false,
{ --0e
shift = 5, mask = 7,
[0] = "usatDwMu", "usat16DwM", "usatDwMu",
{ shift = 16, mask = 15, [15] = "uxtbDMU", _ = "uxtabDNMU", },
"usatDwMu", false, "usatDwMu",
},
{ --0f
shift = 5, mask = 7,
[0] = "usatDwMu", "rbitDM", "usatDwMu",
{ shift = 16, mask = 15, [15] = "uxthDMU", _ = "uxtahDNMU", },
"usatDwMu", "revshDM", "usatDwMu",
},
{ --10
shift = 12, mask = 15,
[15] = {
shift = 5, mask = 7,
"smuadNMS", "smuadxNMS", "smusdNMS", "smusdxNMS",
},
_ = {
shift = 5, mask = 7,
[0] = "smladNMSD", "smladxNMSD", "smlsdNMSD", "smlsdxNMSD",
},
},
false, false, false,
{ --14
shift = 5, mask = 7,
[0] = "smlaldDNMS", "smlaldxDNMS", "smlsldDNMS", "smlsldxDNMS",
},
{ --15
shift = 5, mask = 7,
[0] = { shift = 12, mask = 15, [15] = "smmulNMS", _ = "smmlaNMSD", },
{ shift = 12, mask = 15, [15] = "smmulrNMS", _ = "smmlarNMSD", },
false, false, false, false,
"smmlsNMSD", "smmlsrNMSD",
},
false, false,
{ --18
shift = 5, mask = 7,
[0] = { shift = 12, mask = 15, [15] = "usad8NMS", _ = "usada8NMSD", },
},
false,
{ --1a
shift = 5, mask = 3, [2] = "sbfxDMvw",
},
{ --1b
shift = 5, mask = 3, [2] = "sbfxDMvw",
},
{ --1c
shift = 5, mask = 3,
[0] = { shift = 0, mask = 15, [15] = "bfcDvX", _ = "bfiDMvX", },
},
{ --1d
shift = 5, mask = 3,
[0] = { shift = 0, mask = 15, [15] = "bfcDvX", _ = "bfiDMvX", },
},
{ --1e
shift = 5, mask = 3, [2] = "ubfxDMvw",
},
{ --1f
shift = 5, mask = 3, [2] = "ubfxDMvw",
},
}
local map_load = {
shift = 21, mask = 9,
{
shift = 20, mask = 5,
[0] = "strtDL", "ldrtDL", [4] = "strbtDL", [5] = "ldrbtDL",
},
_ = {
shift = 20, mask = 5,
[0] = "strDL", "ldrDL", [4] = "strbDL", [5] = "ldrbDL",
}
}
local map_load1 = {
shift = 4, mask = 1,
[0] = map_load, map_media,
}
local map_loadm = {
shift = 20, mask = 1,
[0] = {
shift = 23, mask = 3,
[0] = "stmdaNR", "stmNR",
{ shift = 16, mask = 63, [45] = "pushR", _ = "stmdbNR", }, "stmibNR",
},
{
shift = 23, mask = 3,
[0] = "ldmdaNR", { shift = 16, mask = 63, [61] = "popR", _ = "ldmNR", },
"ldmdbNR", "ldmibNR",
},
}
local map_data = {
shift = 21, mask = 15,
[0] = "andDNPs", "eorDNPs", "subDNPs", "rsbDNPs",
"addDNPs", "adcDNPs", "sbcDNPs", "rscDNPs",
"tstNP", "teqNP", "cmpNP", "cmnNP",
"orrDNPs", "movDPs", "bicDNPs", "mvnDPs",
}
local map_mul = {
shift = 21, mask = 7,
[0] = "mulNMSs", "mlaNMSDs", "umaalDNMS", "mlsDNMS",
"umullDNMSs", "umlalDNMSs", "smullDNMSs", "smlalDNMSs",
}
local map_sync = {
shift = 20, mask = 15, -- NYI: brackets around N. R(D+1) for ldrexd/strexd.
[0] = "swpDMN", false, false, false,
"swpbDMN", false, false, false,
"strexDMN", "ldrexDN", "strexdDN", "ldrexdDN",
"strexbDMN", "ldrexbDN", "strexhDN", "ldrexhDN",
}
local map_mulh = {
shift = 21, mask = 3,
[0] = { shift = 5, mask = 3,
[0] = "smlabbNMSD", "smlatbNMSD", "smlabtNMSD", "smlattNMSD", },
{ shift = 5, mask = 3,
[0] = "smlawbNMSD", "smulwbNMS", "smlawtNMSD", "smulwtNMS", },
{ shift = 5, mask = 3,
[0] = "smlalbbDNMS", "smlaltbDNMS", "smlalbtDNMS", "smlalttDNMS", },
{ shift = 5, mask = 3,
[0] = "smulbbNMS", "smultbNMS", "smulbtNMS", "smulttNMS", },
}
local map_misc = {
shift = 4, mask = 7,
-- NYI: decode PSR bits of msr.
[0] = { shift = 21, mask = 1, [0] = "mrsD", "msrM", },
{ shift = 21, mask = 3, "bxM", false, "clzDM", },
{ shift = 21, mask = 3, "bxjM", },
{ shift = 21, mask = 3, "blxM", },
false,
{ shift = 21, mask = 3, [0] = "qaddDMN", "qsubDMN", "qdaddDMN", "qdsubDMN", },
false,
{ shift = 21, mask = 3, "bkptK", },
}
local map_datar = {
shift = 4, mask = 9,
[9] = {
shift = 5, mask = 3,
[0] = { shift = 24, mask = 1, [0] = map_mul, map_sync, },
{ shift = 20, mask = 1, [0] = "strhDL", "ldrhDL", },
{ shift = 20, mask = 1, [0] = "ldrdDL", "ldrsbDL", },
{ shift = 20, mask = 1, [0] = "strdDL", "ldrshDL", },
},
_ = {
shift = 20, mask = 25,
[16] = { shift = 7, mask = 1, [0] = map_misc, map_mulh, },
_ = {
shift = 0, mask = 0xffffffff,
[bor(0xe1a00000)] = "nop",
_ = map_data,
}
},
}
local map_datai = {
shift = 20, mask = 31, -- NYI: decode PSR bits of msr. Decode imm12.
[16] = "movwDW", [20] = "movtDW",
[18] = { shift = 0, mask = 0xf00ff, [0] = "nopv6", _ = "msrNW", },
[22] = "msrNW",
_ = map_data,
}
local map_branch = {
shift = 24, mask = 1,
[0] = "bB", "blB"
}
local map_condins = {
[0] = map_datar, map_datai, map_load, map_load1,
map_loadm, map_branch, map_loadc, map_datac
}
-- NYI: setend.
local map_uncondins = {
[0] = false, map_simddata, map_simdload, map_preload,
false, "blxB", map_loadcu, map_datacu,
}
------------------------------------------------------------------------------
local map_gpr = {
[0] = "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "sp", "lr", "pc",
}
local map_cond = {
[0] = "eq", "ne", "hs", "lo", "mi", "pl", "vs", "vc",
"hi", "ls", "ge", "lt", "gt", "le", "al",
}
local map_shift = { [0] = "lsl", "lsr", "asr", "ror", }
------------------------------------------------------------------------------
-- Output a nicely formatted line with an opcode and operands.
local function putop(ctx, text, operands)
local pos = ctx.pos
local extra = ""
if ctx.rel then
local sym = ctx.symtab[ctx.rel]
if sym then
extra = "\t->"..sym
elseif band(ctx.op, 0x0e000000) ~= 0x0a000000 then
extra = "\t; 0x"..tohex(ctx.rel)
end
end
if ctx.hexdump > 0 then
ctx.out(format("%08x %s %-5s %s%s\n",
ctx.addr+pos, tohex(ctx.op), text, concat(operands, ", "), extra))
else
ctx.out(format("%08x %-5s %s%s\n",
ctx.addr+pos, text, concat(operands, ", "), extra))
end
ctx.pos = pos + 4
end
-- Fallback for unknown opcodes.
local function unknown(ctx)
return putop(ctx, ".long", { "0x"..tohex(ctx.op) })
end
-- Format operand 2 of load/store opcodes.
local function fmtload(ctx, op, pos)
local base = map_gpr[band(rshift(op, 16), 15)]
local x, ofs
local ext = (band(op, 0x04000000) == 0)
if not ext and band(op, 0x02000000) == 0 then
ofs = band(op, 4095)
if band(op, 0x00800000) == 0 then ofs = -ofs end
if base == "pc" then ctx.rel = ctx.addr + pos + 8 + ofs end
ofs = "#"..ofs
elseif ext and band(op, 0x00400000) ~= 0 then
ofs = band(op, 15) + band(rshift(op, 4), 0xf0)
if band(op, 0x00800000) == 0 then ofs = -ofs end
if base == "pc" then ctx.rel = ctx.addr + pos + 8 + ofs end
ofs = "#"..ofs
else
ofs = map_gpr[band(op, 15)]
if ext or band(op, 0xfe0) == 0 then
elseif band(op, 0xfe0) == 0x60 then
ofs = format("%s, rrx", ofs)
else
local sh = band(rshift(op, 7), 31)
if sh == 0 then sh = 32 end
ofs = format("%s, %s #%d", ofs, map_shift[band(rshift(op, 5), 3)], sh)
end
if band(op, 0x00800000) == 0 then ofs = "-"..ofs end
end
if ofs == "#0" then
x = format("[%s]", base)
elseif band(op, 0x01000000) == 0 then
x = format("[%s], %s", base, ofs)
else
x = format("[%s, %s]", base, ofs)
end
if band(op, 0x01200000) == 0x01200000 then x = x.."!" end
return x
end
-- Format operand 2 of vector load/store opcodes.
local function fmtvload(ctx, op, pos)
local base = map_gpr[band(rshift(op, 16), 15)]
local ofs = band(op, 255)*4
if band(op, 0x00800000) == 0 then ofs = -ofs end
if base == "pc" then ctx.rel = ctx.addr + pos + 8 + ofs end
if ofs == 0 then
return format("[%s]", base)
else
return format("[%s, #%d]", base, ofs)
end
end
local function fmtvr(op, vr, sh0, sh1)
if vr == "s" then
return format("s%d", 2*band(rshift(op, sh0), 15)+band(rshift(op, sh1), 1))
else
return format("d%d", band(rshift(op, sh0), 15)+band(rshift(op, sh1-4), 16))
end
end
-- Disassemble a single instruction.
local function disass_ins(ctx)
local pos = ctx.pos
local b0, b1, b2, b3 = byte(ctx.code, pos+1, pos+4)
local op = bor(lshift(b3, 24), lshift(b2, 16), lshift(b1, 8), b0)
local operands = {}
local suffix = ""
local last, name, pat
local vr
ctx.op = op
ctx.rel = nil
local cond = rshift(op, 28)
local opat
if cond == 15 then
opat = map_uncondins[band(rshift(op, 25), 7)]
else
if cond ~= 14 then suffix = map_cond[cond] end
opat = map_condins[band(rshift(op, 25), 7)]
end
while type(opat) ~= "string" do
if not opat then return unknown(ctx) end
opat = opat[band(rshift(op, opat.shift), opat.mask)] or opat._
end
name, pat = match(opat, "^([a-z0-9]*)(.*)")
if sub(pat, 1, 1) == "." then
local s2, p2 = match(pat, "^([a-z0-9.]*)(.*)")
suffix = suffix..s2
pat = p2
end
for p in gmatch(pat, ".") do
local x = nil
if p == "D" then
x = map_gpr[band(rshift(op, 12), 15)]
elseif p == "N" then
x = map_gpr[band(rshift(op, 16), 15)]
elseif p == "S" then
x = map_gpr[band(rshift(op, 8), 15)]
elseif p == "M" then
x = map_gpr[band(op, 15)]
elseif p == "d" then
x = fmtvr(op, vr, 12, 22)
elseif p == "n" then
x = fmtvr(op, vr, 16, 7)
elseif p == "m" then
x = fmtvr(op, vr, 0, 5)
elseif p == "P" then
if band(op, 0x02000000) ~= 0 then
x = ror(band(op, 255), 2*band(rshift(op, 8), 15))
else
x = map_gpr[band(op, 15)]
if band(op, 0xff0) ~= 0 then
operands[#operands+1] = x
local s = map_shift[band(rshift(op, 5), 3)]
local r = nil
if band(op, 0xf90) == 0 then
if s == "ror" then s = "rrx" else r = "#32" end
elseif band(op, 0x10) == 0 then
r = "#"..band(rshift(op, 7), 31)
else
r = map_gpr[band(rshift(op, 8), 15)]
end
if name == "mov" then name = s; x = r
elseif r then x = format("%s %s", s, r)
else x = s end
end
end
elseif p == "L" then
x = fmtload(ctx, op, pos)
elseif p == "l" then
x = fmtvload(ctx, op, pos)
elseif p == "B" then
local addr = ctx.addr + pos + 8 + arshift(lshift(op, 8), 6)
if cond == 15 then addr = addr + band(rshift(op, 23), 2) end
ctx.rel = addr
x = "0x"..tohex(addr)
elseif p == "F" then
vr = "s"
elseif p == "G" then
vr = "d"
elseif p == "." then
suffix = suffix..(vr == "s" and ".f32" or ".f64")
elseif p == "R" then
if band(op, 0x00200000) ~= 0 and #operands == 1 then
operands[1] = operands[1].."!"
end
local t = {}
for i=0,15 do
if band(rshift(op, i), 1) == 1 then t[#t+1] = map_gpr[i] end
end
x = "{"..concat(t, ", ").."}"
elseif p == "r" then
if band(op, 0x00200000) ~= 0 and #operands == 2 then
operands[1] = operands[1].."!"
end
local s = tonumber(sub(last, 2))
local n = band(op, 255)
if vr == "d" then n = rshift(n, 1) end
operands[#operands] = format("{%s-%s%d}", last, vr, s+n-1)
elseif p == "W" then
x = band(op, 0x0fff) + band(rshift(op, 4), 0xf000)
elseif p == "T" then
x = "#0x"..tohex(band(op, 0x00ffffff), 6)
elseif p == "U" then
x = band(rshift(op, 7), 31)
if x == 0 then x = nil end
elseif p == "u" then
x = band(rshift(op, 7), 31)
if band(op, 0x40) == 0 then
if x == 0 then x = nil else x = "lsl #"..x end
else
if x == 0 then x = "asr #32" else x = "asr #"..x end
end
elseif p == "v" then
x = band(rshift(op, 7), 31)
elseif p == "w" then
x = band(rshift(op, 16), 31)
elseif p == "x" then
x = band(rshift(op, 16), 31) + 1
elseif p == "X" then
x = band(rshift(op, 16), 31) - last + 1
elseif p == "Y" then
x = band(rshift(op, 12), 0xf0) + band(op, 0x0f)
elseif p == "K" then
x = "#0x"..tohex(band(rshift(op, 4), 0x0000fff0) + band(op, 15), 4)
elseif p == "s" then
if band(op, 0x00100000) ~= 0 then suffix = "s"..suffix end
else
assert(false)
end
if x then
last = x
if type(x) == "number" then x = "#"..x end
operands[#operands+1] = x
end
end
return putop(ctx, name..suffix, operands)
end
------------------------------------------------------------------------------
-- Disassemble a block of code.
local function disass_block(ctx, ofs, len)
if not ofs then ofs = 0 end
local stop = len and ofs+len or #ctx.code
ctx.pos = ofs
ctx.rel = nil
while ctx.pos < stop do disass_ins(ctx) end
end
-- Extended API: create a disassembler context. Then call ctx:disass(ofs, len).
local function create_(code, addr, out)
local ctx = {}
ctx.code = code
ctx.addr = addr or 0
ctx.out = out or io.write
ctx.symtab = {}
ctx.disass = disass_block
ctx.hexdump = 8
return ctx
end
-- Simple API: disassemble code (a string) at address and output via out.
local function disass_(code, addr, out)
create_(code, addr, out):disass()
end
-- Return register name for RID.
local function regname_(r)
if r < 16 then return map_gpr[r] end
return "d"..(r-16)
end
-- Public module functions.
module(...)
create = create_
disass = disass_
regname = regname_
| apache-2.0 |
TheAnswer/FirstTest | bin/scripts/slashcommands/skills/forceOfWill.lua | 1 | 2531 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
--true = 1, false = 0
ForceOfWillSlashCommand = {
name = "forceofwill",
alternativeNames = "",
animation = "",
invalidStateMask = 3894411264, --glowingJedi, ridingMount, pilotingShip, shipOperations, shipGunner,
invalidPostures = "0,3,1,2,5,6,7,8,9,10,11,12,14,4,",
target = 2,
targeType = 0,
disabled = 0,
maxRangeToTarget = 0,
--adminLevel = 0,
addToCombatQueue = 1,
}
AddForceOfWillSlashCommand(ForceOfWillSlashCommand)
| lgpl-3.0 |
asmagill/hammerspoon | extensions/window/window_layout.lua | 4 | 40796 | --- === hs.window.layout ===
---
--- **WARNING**: EXPERIMENTAL MODULE. DO **NOT** USE IN PRODUCTION.
--- This module is *for testing purposes only*. It can undergo breaking API changes or *go away entirely* **at any point and without notice**.
--- (Should you encounter any issues, please feel free to report them on https://github.com/Hammerspoon/hammerspoon/issues
--- or #hammerspoon on irc.libera.chat)
---
--- Window management
---
--- Windowlayouts work by selecting certain windows via windowfilters and arranging them onscreen according to specific rules.
---
--- A **layout** is composed of a list of rules and, optionally, a screen arrangement definition.
--- Rules within a layout are evaluated in order; once a window is acted upon by a rule, subsequent rules will not affect it further.
--- A **rule** needs a **windowfilter**, producing a dynamic list of windows (the "window pool") to which the rule is applied,
--- and a list of commands, evaluated in order.
--- A **command** acts on one or more of the windows, and is composed of:
--- * an **action**, it can be
--- - `move`: moves the window(s) to a specified onscreen rect (if the action is omitted, `move` is assumed)
--- - `minimize`, `maximize`, `fullscreen`
--- - `tile`, `fit`: tiles the windows onto a specified rect, using `hs.window.tiling.tileWindows()`; for `fit`, the
--- `preserveRelativeArea` parameter will be set to true
--- - `hide`, `unhide`: hides or unhides the window's application (like when using cmd-h)
--- - `noaction`: skip action on the window(s)
--- * a **maxn** number, indicating how many windows from this rule's window pool will be affected (at most) by this command;
--- if omitted (or if explicitly the string `all`) all the remaining windows will be processed by this command; processed
--- windows are "consumed" and are excluded from the window pool for subsequent commands in this rule, and from subsequent rules
--- * a **selector**, describing the sort order used to pick the first *maxn* windows from the window pool for this command;
--- it can be one of `focused` (pick *maxn* most recently focused windows), `frontmost` (pick the recent focused window if its
--- application is frontmost applicaion, otherwise the command will be skipped), `newest` (most recently created), `oldest`
--- (least recently created), or `closest` (pick the *maxn* windows that are closest to the destination rect); if omitted,
--- defaults to `closest` for move, tile and fit, and `newest` for everything else
--- * an `hs.geometry` *size* (only valid for tile and fit) indicating the desired optimal aspect ratio for the tiled windows;
--- if omitted, defaults to 1x1 (i.e. square windows)
--- * for move, tile and fit, an `hs.geometry` *rect*, or a *unit rect* plus a *screen hint* (for `hs.screen.find()`),
--- indicating the destination rect for the command
--- * for fullscreen and maximize, a *screen hint* indicating the desired screen; if omitted, uses the window's current screen
---
--- You should place higher-priority rules (with highly specialized windowfilters) first, and "fallback" rules
--- (with more generic windowfilters) last; similarly, *within* a rule, you should have commands for the more "important"
--- (i.e. relevant to your current workflow) windows first (move, maximize...) and after that deal with less prominent
--- windows, if any remain, e.g. by placing them out of the way (minimize).
--- `unhide` and `hide`, if used, should usually go into their own rules (with a windowfilter that allows invisible windows
--- for `unhide`) that come *before* other rules that deal with actual window placement - unlike the other actions,
--- they don't "consume" windows making them unavailable for subsequent rules, as they act on applications.
---
--- In order to avoid dealing with deeply nested maps, you can define a layout in your scripts via a list, where each element
--- (or row) denotes a rule; in turn every rule can be a simplified list of two elements:
--- - a windowfilter or a constructor argument table for one (see `hs.window.filter.new()` and `hs.window.filter:setFilters()`)
--- - a single string containing all the commands (action and parameters) in order; actions and selectors can be shortened to
--- 3 characters; all tokens must be separated by spaces (do not use spaces inside `hs.geometry` constructor strings);
--- for greater clarity you can separate commands with `|` (pipe character)
---
--- Some command string examples:
--- - `"move 1 [0,0,50,50] -1,0"` moves the closest window to the topleft quadrant of the left screen
--- - `"max 0,0"` maximizes all the windows onto the primary screen, one on top of another
--- - `"move 1 foc [0,0,30,100] 0,0 | tile all foc [30,0,100,100] 0,0"` moves the most recently focused window to the left third,
--- and tiles the remaining windows onto the right side, keeping the most recently focused on top and to the left
--- - `"1 new [0,0,50,100] 0,0 | 1 new [50,0,100,100] 0,0 | min"` divides the primary screen between the two newest windows
--- and minimizes any other windows
---
--- Each layout can work in "passive" or "active" modes; passive layouts must be triggered manually (via `hs.hotkey.bind()`,
--- `hs.menubar`, etc.) while active layouts continuously keep their rules enforced (see `hs.window.layout:start()`
--- for more information); in general you should avoid having multiple active layouts targeting the same windows, as the
--- results will be unpredictable (if such a situation is detected, you'll see an error in the Hammerspoon console); you
--- *can* have multiple active layouts, but be careful to maintain a clear "separation of concerns" between their respective windowfilters.
---
--- Each layout can have an associated screen configuration; if so, the layout will only be valid while the current screen
--- arrangement satisfies it; see `hs.window.layout:setScreenConfiguration()` for more information.
--TODO full examples in the wiki
local application = require 'hs.application'
local pairs,ipairs,next,type,pcall=pairs,ipairs,next,type,pcall
local floor=math.floor
local sformat,ssub,gmatch,gsub=string.format,string.sub,string.gmatch,string.gsub
local tonumber,tostring=tonumber,tostring
local tpack,tremove,tconcat=table.pack,table.remove,table.concat
local window=hs.window
local windowfilter=require'hs.window.filter'
local tileWindows=require'hs.window.tiling'.tileWindows
local geom,screen,timer,eventtap=require'hs.geometry',require'hs.screen',require'hs.timer',require'hs.eventtap'
local logger=require'hs.logger'
local log=logger.new'wlayout'
local layout={} -- module and class
layout.setLogLevel=log.setLogLevel
layout.getLogLevel=log.getLogLevel
local winbuf,appbuf={},{} -- action buffers for windows and apps
local rulebuf={} -- buffer for rules to apply
local screenCache={} -- memoize screen.find() on current screens
local activeInstances={} -- wlayouts currently in 'active mode'
local screenInstances={} -- wlayouts that care about screen configuration (they become active/inactive as screens change)
local function tlen(t)local i,e=0,next(t) while e do i,e=i+1,next(t,e) end return i end
local function errorf(s,...) local args=tpack(...) error(sformat(s,...),args[#args]+1) end
local function strip(s) return type(s)=='string' and s:gsub('%s+','') or s end
local MOVE,TILE,FIT,HIDE,UNHIDE,MINIMIZE,MAXIMIZE,FULLSCREEN,RESTORE='move','tile','fit','hide','unhide','minimize','maximize','fullscreen','restore'
local NOACTION='noaction'
local CREATEDLAST,CREATEDFIRST,FOCUSEDLAST,CLOSEST,FRONTMOST='createdLast','created','focusedLast','closest','frontmost'
local ACTIONS={mov=MOVE,fra=MOVE,til=TILE,fit=FIT,hid=HIDE,unh=UNHIDE,sho=UNHIDE,max=MAXIMIZE,ful=FULLSCREEN,fs=FULLSCREEN,min=MINIMIZE,res=RESTORE,noa=NOACTION}
local SELECTORS={cre=CREATEDLAST,new=CREATEDLAST,old=CREATEDFIRST,foc=FOCUSEDLAST,clo=CLOSEST,pos=CLOSEST,fro=FRONTMOST}
local function getaction(s,i)
if type(s)~='string' then return nil,i end
local r=ACTIONS[ssub(s,1,3)] return r,r and i+1 or i
end
local function getmaxnumber(n,i)
if n=='all' then return nil,i+1 end
n=tonumber(n) if type(n)=='number' and n<1000 then return n,i+1 else return nil,i end
end
local function getselector(s,i)
if type(s)~='string' then return nil,i end
local r=SELECTORS[ssub(s,1,3)] return r,r and i+1 or i
end
local function getaspect(a,i)
if type(a)=='string' then
if a:sub(1,3)=='hor' or a=='row' then return 0.01,i+1
elseif a:sub(1,3)=='ver' or a:sub(1,3)=='col' then return 100,i+1 end
end
-- if type(a)=='number' then return a,i+1 end
local ok,res=pcall(geom.new,a)
if ok and res:type()=='size' then return res.aspect,i+1 else return nil,i end
end
local function getrect(r,i)
local ok,res=pcall(geom.new,r)
if ok and geom.type(res)=='rect' then return res,i+1 else return nil,i end
end
local function getunitrect(r,i)
local ok,res=pcall(geom.new,r)
if ok and geom.type(res)=='unitrect' then return res,i+1 else return nil,i end
end
local function validatescreen(s,i)
if getaction(s,i) then return nil,i
elseif type(s)=='number' and s>=1000 then return s,i+1
elseif type(s)=='string' or type(s)=='table' then
local ok,res=pcall(geom.new,s) --disallow full frame, as it could be mistaken for the next cmd (implicit 'move')
if ok then
local typ=geom.type(res)
if typ=='point' or typ=='size' then return s,i+1 else return nil,i end
end
if type(s)=='string' then return s,i+1 else return nil,i end
end
return nil,i
end
local function screenstr(s)
if type(s)=='number' then return s
elseif type(s)=='string' or type(s)=='table' then
local ok,res=pcall(geom.new,s)
if ok then return res.string end
if type(s)=='string' then return s end
end
end
local function validateCommand(command,ielem,icmd,irule,l)
local idx=irule..'.'..icmd
if command.irule~=irule or command.icmd~=icmd then errorf('invalid indices %d.%d, %s expected',command.irule,command.icmd,idx,6) end
local function error(s) return errorf('invalid %s, token %d in rule %s',s,ielem,idx,7) end
local action=getaction(command.action,0)
if not action then error'action' end
local logs=sformat('rule %d.%d: %s',irule,icmd,action)
-- if action==RESTORE then command.max=999 return command,ielem,icmd+1 end
if command.max then
if type(command.max)~='number' or floor(command.max)~=command.max or command.max<1 or command.max>999 then error'max number' end
-- if command.action~=UNHIDE and command.max<1 then error'max number' end --allow "unhide 0"
logs=logs..' '..command.max
else logs=logs..' all' end
if command.select then
if not getselector(command.select,0) then error'selector'
else logs=logs..' '..command.select end
end
if action==MAXIMIZE or action==FULLSCREEN or action==NOACTION then
if command.screen then
if not validatescreen(command.screen,ielem) then error'screen'end
logs=logs..' screen='..screenstr(command.screen)
end
elseif action==MOVE or action==TILE or action==FIT then
if action==TILE or action==FIT then
if command.aspect then
if type(command.aspect)~='number' or command.aspect<=0 or command.aspect==command.aspect/2 then error'aspect'
else logs=logs..' aspect='..sformat('%.2f',command.aspect) end
end
end
if command.rect then
local rect=geom.new(command.rect)
if geom.type(rect)~='rect' then error'rect'
else logs=logs..' rect='..rect.string end
else
if not command.unitrect then errorf('need rect or unitrect, token %d in rule %s',ielem,idx,6) end
local unitrect=geom.new(command.unitrect)
if geom.type(unitrect)~='unitrect' then error'unitrect'
else logs=logs..' unitrect='..unitrect.string end
if not validatescreen(command.screen,ielem) then error'screen'end
logs=logs..' screen='..screenstr(command.screen)
end
elseif action==HIDE or action==MINIMIZE or action==UNHIDE or action==RESTORE then
if getselector(command.select,0)==CLOSEST then error'selector' end
else error'action' end
l.i(logs)
return command,ielem,icmd+1
end
local function parseCommand(rule,ielem,icmd,irule,l)
if type(rule[ielem])=='table' and rule[ielem].action then
return validateCommand(rule[ielem],ielem,icmd,irule,l),ielem+1,icmd+1
end
local r={irule=irule,icmd=icmd}
r.action,ielem=getaction(rule[ielem],ielem)
--optional number of windows to process for this cmd
r.max,ielem=getmaxnumber(rule[ielem],ielem)
-- r.max=r.max or 999
if not r.action then r.action=MOVE
elseif r.action==RESTORE then return validateCommand(r,ielem,icmd,irule,l) end
r.select,ielem=getselector(rule[ielem],ielem)
if not r.select then
if r.action==MOVE or r.action==TILE or r.action==FIT then r.select=CLOSEST
else r.select=CREATEDLAST end
end
if r.action==HIDE or r.action==MINIMIZE or r.action==UNHIDE then
return validateCommand(r,ielem,icmd,irule,l)
elseif r.action==FULLSCREEN or r.action==MAXIMIZE then
r.screen,ielem=validatescreen(rule[ielem],ielem)
return validateCommand(r,ielem,icmd,irule,l)
end
-- move or tile
if r.action==TILE or r.action==FIT then
-- optional aspect
r.aspect,ielem=getaspect(rule[ielem],ielem)
end
-- now rect or unitrect+screen
r.rect,ielem=getrect(rule[ielem],ielem)
if not r.rect then
r.unitrect,ielem=getunitrect(rule[ielem],ielem)
r.screen,ielem=validatescreen(rule[ielem],ielem)
end
validateCommand(r,ielem,icmd,irule,l)
-- if (r.action==MINIMIZE or r.action==HIDE) and elemi<=#row then error(r.action..' must be the last action in a rule',2)end
return r,ielem,icmd+1
end
local function getwf(wf,idx,logname,loglevel) return windowfilter.new(wf,'r'..idx..'-'..(logname or 'wlayout'),loglevel) end
local function wferror(wfkey,irule,res)
errorf('element %s in rule %d must be a windowfilter object or valid constructor argument\n%s',wfkey,irule,res,5)
end
local function parseRule(self,rule,irule)
local logname,loglevel=self.logname,self.loglevel
local r={windowlayout=self,irule=irule}
log.df('parsing rule %d, getting windowfilter',irule)
local ok,res,wfkey
if rule.windowfilter then
wfkey='windowfilter'
ok,res=pcall(getwf,rule.windowfilter,irule,logname,loglevel)
if not ok then wferror(wfkey,irule,res,4)
else r.windowfilter=res end
else
for k,_ in pairs(rule) do
if type(k)=='string' then wfkey,ok,res=k,pcall(getwf,{[k]=rule[k]},irule,logname,loglevel) break end
end
if ok then r.windowfilter=res
elseif ok==false then wferror(wfkey,irule,res,4)
elseif ok==nil then
wfkey,ok,res=1,pcall(getwf,rule[1],irule,logname,loglevel)
if not ok then wferror(wfkey,irule,res,4) end
r.windowfilter=res
end
end
-- hs.assert(r.windowfilter,'invalid rule windowfilter',rule)
local split,slog={},{}
for i=(wfkey==1 and 2 or 1),#rule do
local elem=rule[i]
if type(elem)=='string' then
elem=gsub(elem,'%s+[|>/-,]%s+',' ')
for s in gmatch(elem,'%s*%g+%s*') do
split[#split+1]=strip(s)
slog[#slog+1]=strip(s)
end
else
split[#split+1]=elem
slog[#slog+1]=tostring(elem)
end
end
log.vf('tokenized rule %d: %s',irule,tconcat(slog,'|'))
local ielem,icmd,cmd=1,1
while ielem<=#split do
cmd,ielem,icmd=parseCommand(split,ielem,icmd,irule,log)
cmd.windowlayout=self
r[#r+1]=cmd
end
return r
end
local function parseRules(rules,self)
local r={}
for _,row in ipairs(rules) do
if type(row)~='table' then rules={rules} break end
end
self.log.vf('will parse %d rules',#rules)
for irule=1,#rules do
r[irule]=parseRule(self,rules[irule],irule)
end
return r
end
--- hs.window.layout.new(rules[,logname[,loglevel]]) -> hs.window.layout object
--- Constructor
--- Creates a new hs.window.layout instance
---
--- Parameters:
--- * rules - a table containing the rules for this windowlayout (see the module description); additionally, if a special key `screens`
--- is present, its value must be a valid screen configuration as per `hs.window.layout:setScreenConfiguration()`
--- * logname - (optional) name of the `hs.logger` instance for the new windowlayout; if omitted, the class logger will be used
--- * loglevel - (optional) log level for the `hs.logger` instance for the new windowlayout
---
--- Returns:
--- * a new windowlayout instance
local function __tostring(self) return sformat('hs.window.layout: %s (%s)',self.logname or '...',self.__address) end
function layout.new(rules,logname,loglevel)
if type(rules)~='table' then error('rules must be a table',2)end
local o={log=logname and logger.new(logname,loglevel) or log,logname=logname,loglevel=loglevel}
o.__address=gsub(tostring(o),'table: ','')
setmetatable(o,{__index=layout,__tostring=__tostring,__gc=layout.delete})
if logname then o.setLogLevel=o.log.setLogLevel o.getLogLevel=o.log.getLogLevel end
local mt=getmetatable(rules)
if mt and mt.__index==layout then
o.log.i('new windowlayout copy')
rules=rules.rules
else
o.log.i('new windowlayout')
end
o.rules=parseRules(rules,o)
o:setScreenConfiguration(rules.screens)
return o
end
--- hs.window.layout:getRules() -> table
--- Method
--- Return a table with all the rules (and the screen configuration, if present) defined for this windowlayout
---
--- Parameters:
--- * None
---
--- Returns:
--- * a table containing the rules of this windowlayout; you can pass this table (optionally
--- after performing valid manipulations) to `hs.window.layout.new()`
function layout:getRules()
local r={}
for _,rule in ipairs(self.rules) do
local nrule={}
nrule.windowfilter=rule.windowfilter:getFilters()
for _,command in ipairs(rule) do
nrule[#nrule+1]={
action=command.action,max=command.max,select=command.select,aspect=command.aspect,
rect=command.rect and geom.new(command.rect).table,
unitrect=command.unitrect and geom.new(command.unitrect).table,
screen=command.screen,--irule=irule,icmd=icmd,
}
end
r[#r+1]=nrule
end
r.screens=self.screens
return r
end
local function findScreen(s)
if not s then return elseif not screenCache[s] then screenCache[s]=screen.find(s) end
return screenCache[s]
end
-- applies pending actions on windows and apps (winbuf,appbuf)
local function performPendingActions()
-- show apps
if not next(winbuf) and not next(appbuf) then return end
log.vf('applying %d pending actions',tlen(winbuf))
for app,command in pairs(appbuf) do
if command.hide==false and app:isHidden() then
app:unhide()
command.log.f('rule %d.%d: %s unhidden',command.irule,command.icmd,app:name())
end
end
-- move/min/max/fs
for win,command in pairs(winbuf) do
local idx,appname,id=command.irule..'.'..command.icmd,win:application():name(),win:id()
local action=command.action
if action==MINIMIZE then
if not win:isMinimized() then
win:minimize()
command.log.f('rule %s: %s (%d) minimized',idx,appname,id)
end
winbuf[win]=nil
else
if win:isMinimized() then
win:unminimize()
command.log.f('rule %s: %s (%d) unminimized',idx,appname,id)
end
if action~=TILE and action~=FIT then
winbuf[win]=nil
local winscreen=win:screen()
local toscreen=findScreen(command.screen) or winscreen
if win:isFullScreen() and (action~=FULLSCREEN or toscreen~=winscreen) then
win:setFullScreen(false)
command.log.f('rule %s: %s (%d) unfullscreened',idx,appname,id)
end
if action==FULLSCREEN then
if toscreen~=winscreen then win:moveToScreen(toscreen) end
if not win:isFullScreen() then
win:setFullScreen(true)
command.log.f('rule %s: %s (%d) fullscreened to %s',idx,appname,id,toscreen:name())
end
elseif action==MAXIMIZE then
local frame=toscreen:frame()
if win:frame()~=frame then
win:setFrame(toscreen:frame())
command.log.f('rule %s: %s (%d) maximized to %s',idx,appname,id,toscreen:name())
end
elseif action==MOVE then
local frame=command.rect or toscreen:fromUnitRect(command.unitrect)
if win:frame()~=frame then
win:setFrame(frame)
command.log.f('rule %s: %s (%d) moved to %s',idx,appname,id,frame.string)
end
--elseif action==NOACTION then
--else --hs.assert(false,'(422) wrong action: '..action,command)
end
end
end
end
-- tile remaining windows
local toTile={}
for win,command in pairs(winbuf) do
-- hs.assert(command.action==TILE or command.action==FIT,'(431) unexptected action: '..command.action,command)
local idx=command.irule..'.'..command.icmd
if not toTile[idx] then toTile[idx]=command
end
local e=toTile[idx]
e[command.nwindow]=win
winbuf[win]=nil
end
for idx,command in pairs(toTile) do
--FIXME assert for lack of holes in the list
-- hs.assert(#command>0,'(443)',command)
-- hs.assert(#command<=(command.max or 999),'(444)',command)
local toscreen=findScreen(command.screen) or command[1]:screen()
local frame=command.rect or toscreen:fromUnitRect(command.unitrect)
command.log.f('rule %s: %s %d windows into %s by %s',idx,command.action,#command,frame.string,command.select)
-- tileWindows(command,frame,command.aspect,command.select~=CLOSEST,command.action==FIT)
tileWindows(command,frame,command.aspect,false,command.action==FIT) -- always tile by position
end
-- hide apps
for app,command in pairs(appbuf) do
if command.hide==true and not app:isHidden() then
app:hide()
command.log.f('rule %d.%d: %s hidden',command.irule,command.icmd,app:name())
end
appbuf[app]=nil
end
-- hs.assert(not next(winbuf) and not next(appbuf),'(432)')
end
local function removeFromList(win,winlist)
local id=win:id() for i,w in ipairs(winlist) do if w:id()==id then tremove(winlist,i) return end end
end
local function findDestinationFrame(s,unitrect,candidateWindow)
local toscreen=findScreen(s) or (candidateWindow and candidateWindow:screen() or findScreen'0,0')
return unitrect and toscreen:fromUnitRect(unitrect) or toscreen:frame()
end
local function findClosestWindow(winlist,destFrame) --winlist must be sorted by focusedLast
-- hs.assert(#winlist>0,'no candidates for closest window')
local center,rd,rwin=destFrame.center,999999
for _,w in ipairs(winlist) do -- first, try the "smallest" of all windows already fully inside frame
local frame=w:frame()
-- TODO? if w:isVisible() then
if frame:inside(destFrame) then
local distance=frame.xy:distance(center)+frame.x2y2:distance(center)
if distance<rd then rd=distance rwin=w end
end
end
if rwin then return rwin end
for _,w in ipairs(winlist) do -- otherwise, just get the closest
local frame=w:frame()
local distance=frame:distance(center)
if distance<rd then rd=distance rwin=w end
end
-- hs.assert(rwin,'no closest window to '..destFrame.string,winlist)
return rwin
end
-- applies a layout rule onto the action buffers
local function applyRule(rule)
local irule=rule.irule
local l=rule.windowlayout.log
-- local rule=self.rules[irule]
local windows,windowsCreated=rule.windowfilter:getWindows(FOCUSEDLAST),rule.windowfilter:getWindows(CREATEDLAST)
log.vf('applying rule %d to %d windows',irule,#windows)
local icmd,nprocessed=1,0
--local ASSERT_ITER=1
-- local readdUnhiddenWindows={}
while icmd<=#rule and windows[1] do
-- ASSERT_ITER=ASSERT_ITER+1 hs.assert(ASSERT_ITER<100,'applyRule looping',rule.irule)
local command,win=rule[icmd]
local selector=command.select
if selector==CLOSEST then
local destFrame=command.rect or findDestinationFrame(command.screen,command.unitrect)
win=findClosestWindow(windows,destFrame)
l.vf('found closest window %d to %s',win:id(),destFrame.string)
elseif selector==FOCUSEDLAST then
win=windows[1]
elseif selector==CREATEDLAST then
win=windowsCreated[1]
elseif selector==CREATEDFIRST then
win=windowsCreated[#windowsCreated]
elseif selector==FRONTMOST then
if windows[1]:application() == application.frontmostApplication() then
win=windows[1]
nprocessed = 999
else
icmd=icmd+1 nprocessed=0
goto _next_
end
end
-- hs.assert(win,'no window to apply rule',rule)
removeFromList(win,windows) removeFromList(win,windowsCreated)
nprocessed=nprocessed+1
local buffered=winbuf[win]
if buffered and buffered.windowlayout~=rule.windowlayout then
l.ef('multiple active windowlayout instances for %s (%s)!',win:application():name(),win:id())
end
local action=command.action
if action==HIDE or action==UNHIDE then
local app=win:application()
if not appbuf[app] or appbuf[app].irule>irule then
appbuf[app]={hide=action==HIDE,log=l,irule=irule,icmd=icmd}
end
-- if action==UNHIDE then tinsert(readdUnhiddenWindows,win) end
-- action=NOACTION
else
if not buffered or buffered.irule>irule then
-- hs.assert(command.irule==irule and command.icmd==icmd,'(451) wrong indices: '..irule..'.'..icmd,command)
command.log=l
winbuf[win]={action=action,select=command.select,rect=command.rect,unitrect=command.unitrect,screen=command.screen,
max=command.max,aspect=command.aspect,log=command.log,irule=command.irule,icmd=command.icmd,nwindow=nprocessed,windowlayout=rule.windowlayout}
-- winbuf[win]=command winbuf[win].nwindow=nprocessed
l.df('pending action "%s" for %s (%d), %d total',action,win:application():name(),win:id(),tlen(winbuf))
end
end
if nprocessed>=(command.max or 999) then --done with this cmd
icmd=icmd+1 nprocessed=0
-- for i=#readdUnhiddenWindows,1,-1 do --was UNHIDE, now done
-- local w=readdUnhiddenWindows[i] tinsert(windows,w,1) tinsert(windowsCreated,w,1)
-- end
end
::_next_::
end
end
-- applies pending rules
local function applyPendingRules()
for rule in pairs(rulebuf) do applyRule(rule) end
rulebuf={} return performPendingActions()
end
--- hs.window.layout:apply()
--- Method
--- Applies the layout
---
--- Parameters:
--- * None
---
--- Returns:
--- * the `hs.window.layout` object
---
--- Notes:
--- * if a screen configuration is defined for this windowfilter, and currently not satisfied, this method will do nothing
function layout:apply()
if screenInstances[self] and not self._screenConfigurationAllowed then
self.log.i('current screen configuration not allowed, ignoring apply') return self end
local batchID=windowfilter.startBatchOperation()
for _,rule in ipairs(self.rules) do applyRule(rule) end
self.log.i('Applying layout') performPendingActions()
windowfilter.stopBatchOperation(batchID)
return self
end
--- hs.window.layout.applyDelay
--- Variable
--- When "active mode" windowlayouts apply a rule, they will pause briefly for this amount of time in seconds, to allow windows
--- to "settle" in their new configuration without triggering other rules (or the same rule), which could result in a
--- cascade (or worse, a loop) or rules being applied. Defaults to 1; increase this if you experience unwanted repeated
--- triggering of rules due to sluggish performance.
layout.applyDelay=1
local DISTANT_FUTURE=315360000 -- 10 years (roughly)
--delay applying autolayouts while e.g. a window is being dragged with the mouse or moved via keyboard shortcuts
--or while switching focus with cmd-alt or cmd-`
local function checkMouseOrMods()
local mbut=eventtap.checkMouseButtons()
local mods=eventtap.checkKeyboardModifiers(true)._raw
return mods>0 or mbut.left or mbut.right or mbut.middle
end
local MODS_INTERVAL=0.2 -- recheck for (lack of) mouse buttons and mod keys after this interval
local modsTimer=timer.waitWhile(checkMouseOrMods,function(tmr)applyPendingRules()tmr:start():setNextTrigger(DISTANT_FUTURE)end,MODS_INTERVAL)
--- hs.window.layout:start() -> hs.window.layout object
--- Method
--- Puts a windowlayout instance in "active mode"
---
--- Parameters:
--- * None
---
--- Returns:
--- * the `hs.window.layout` object
---
--- Notes:
--- * If a screen configuration is defined for this windowfilter, and currently not satisfied, this windowfilter will be put in "active mode" but will remain paused until the screen configuration requirements are met
--- * When in active mode, a windowlayout instance will constantly monitor the windowfilters for its rules, by subscribing to all the relevant events. As soon as any change is detected (e.g. when you drag a window, switch focus, open or close apps/windows, etc.) the relative rule will be automatically re-applied. In other words, the rules you defined will remain enforced all the time, instead of waiting for manual intervention via `hs.window.layout:apply()`.
function layout:start()
if activeInstances[self] then self.log.d('windowlayout instance already started') return self end
layout._hasActiveInstances=true -- used by hs.grid to pause all during modal operation
activeInstances[self]=true
self.log.i('starting windowlayout instance (active mode)')
return self:resume()
end
--- hs.window.layout:resume() -> hs.window.layout object
--- Method
--- Resumes an active windowlayout instance after it was paused
---
--- Parameters:
--- * None
---
--- Returns:
--- * the `hs.window.layout` object
---
--- Notes:
--- * if a screen configuration is defined for this windowfilter, and currently not satisfied, this method will do nothing
function layout:resume()
if not activeInstances[self] then self.log.i('windowlayout instance not started, ignoring resume') return self end
if self.autolayout then self.log.d('windowlayout instance already running, ignoring resume') return self end
if screenInstances[self] and not self._screenConfigurationAllowed then
self.log.d('current screen configuration not allowed, ignoring resume') return self end
for _,rule in ipairs(self.rules) do
--timers and upvalues galore
local hasFocusedSelector--,hasPositionSelector
for _,cmd in ipairs(rule) do
if cmd.select==FOCUSEDLAST or cmd.select==FRONTMOST then hasFocusedSelector=true end
-- elseif cmd.select==CLOSEST then hasPositionSelector=true end
end
rule.callback=function()
rulebuf[rule]=true modsTimer:setNextTrigger(MODS_INTERVAL)
rule.windowfilter:unsubscribe(windowfilter.windowMoved,rule.callback)
rule.resubTimer:setNextTrigger(MODS_INTERVAL+window.animationDuration+layout.applyDelay)
end
if not rule.resubTimer then
rule.resubTimer=timer.new(DISTANT_FUTURE,
function()rule.windowfilter:subscribe(windowfilter.windowMoved,rule.callback)end):start()
end
rule.windowfilter:subscribe({windowfilter.windowVisible,windowfilter.windowNotVisible,windowfilter.windowMoved},rule.callback)
if hasFocusedSelector then rule.windowfilter:subscribe({windowfilter.windowFocused,windowfilter.windowUnfocused},rule.callback) end
end
self.log.i('windowlayout instance resumed')
self:apply()
self.autolayout=true
return self
end
--- hs.window.layout:pause() -> hs.window.layout object
--- Method
--- Pauses an active windowlayout instance; while paused no automatic window management will occur
---
--- Parameters:
--- * None
---
--- Returns:
--- * the `hs.window.layout` object
function layout:pause()
if not activeInstances[self] then self.log.i('windowlayout instance not started, ignoring pause') return self end
if not self.autolayout then self.log.d('windowlayout instance already paused, ignoring') return self end
for _,rule in ipairs(self.rules) do
if rule.callback then rule.windowfilter:unsubscribe(rule.callback) rule.callback=nil end
if rule.resubTimer then rule.resubTimer:setNextTrigger(DISTANT_FUTURE) end
end
-- if self.timer then self.timer:stop() self.timer=nil end
self.autolayout=false
self.log.i('windowlayout instance paused')
return self
end
--- hs.window.layout:stop() -> hs.window.layout object
--- Method
--- Stops a windowlayout instance (i.e. not in "active mode" anymore)
---
--- Parameters:
--- * None
---
--- Returns:
--- * the `hs.window.layout` object
function layout:stop()
if not activeInstances[self] then self.log.d('windowlayout instance already stopped') return self end
if self.autolayout then self:pause() end
activeInstances[self]=nil self.autolayout=nil
self.log.i('windowlayout instance stopped')
return self
end
local screenWatcher
function layout:delete()
self:stop()
for _,rule in ipairs(self.rules) do rule.windowfilter:delete() end self.rules={}
self.log.i('windowlayout instance deleted')
screenInstances[self]=nil
if not next(activeInstances) and not next(screenInstances) then
--global stop
if screenWatcher then screenWatcher:stop() screenWatcher=nil end
end
setmetatable(self,nil)
end
--- hs.window.layout.screensChangedDelay
--- Variable
--- The number of seconds to wait, after a screen configuration change has been detected, before
--- resuming any active windowlayouts that are allowed in the new configuration; defaults
--- to 10, to give sufficient time to OSX to do its own housekeeping
layout.screensChangedDelay = 10
local screensChangedTimer
local function screensChanged()
log.d'screens changed, pausing all active instances'
layout.pauseAllInstances()
screenCache={}
screensChangedTimer:setNextTrigger(layout.screensChangedDelay)
end
local function checkScreenInstances()
-- check screenInstances, set them active appropriately
local newActiveInstances={}
for wl in pairs(activeInstances) do newActiveInstances[wl]=true end
for wl in pairs(screenInstances) do
newActiveInstances[wl]=true
wl.log.v('checking screen configuration')
for hint, pos in pairs(wl.screens) do
local screens=tpack(screen.find(hint))
if pos==false then if #screens>0 then newActiveInstances[wl]=nil wl.log.df('screen %s is present, required absent',screens[1]:name()) break end
elseif pos==true then if #screens==0 then newActiveInstances[wl]=nil wl.log.df('screen %s is absent, required present',hint) break end
else
local sp,found=findScreen(pos),nil
if not sp then newActiveInstances[wl]=nil wl.log.df('screen at %s is absent, %s required',pos,hint) break end
local spid=sp:id()
for _,s in ipairs(screens) do if s:id()==spid then found=true break end end
if not found then newActiveInstances[wl]=nil wl.log.df('screen at %s is not %s',pos,hint) break end
end
end
end
for wl in pairs(screenInstances) do if not newActiveInstances[wl] and wl._screenConfigurationAllowed then
wl.log.i('current screen configuration not allowed')
wl._screenConfigurationAllowed=nil
if activeInstances[wl] then wl:pause() end
end end
for wl in pairs(newActiveInstances) do
wl.log.i('current screen configuration is allowed')
wl._screenConfigurationAllowed=true
if activeInstances[wl] then wl:resume() end
end
if next(screenInstances) then if not screenWatcher then screenWatcher=screen.watcher.new(screensChanged):start() end
elseif screenWatcher then screenWatcher:stop() screenWatcher=nil end
-- layout.resumeAllInstances()
end
local function processScreensChanged()
log.i'applying new screen configuration'
screensChangedTimer:setNextTrigger(DISTANT_FUTURE)
return checkScreenInstances()
end
screensChangedTimer=timer.new(DISTANT_FUTURE,processScreensChanged):start()
--- hs.window.layout:setScreenConfiguration(screens) -> hs.window.layout object
--- Method
--- Determines the screen configuration that permits applying this windowlayout
---
--- Parameters:
--- * screens - a map, where each *key* must be a valid "hint" for `hs.screen.find()`, and the corresponding
--- value can be:
--- * `true` - the screen must be currently present (attached and enabled)
--- * `false` - the screen must be currently absent
--- * an `hs.geometry` point (or constructor argument) - the screen must be present and in this specific
--- position in the current arragement (as per `hs.screen:position()`)
---
--- Returns:
--- * the `hs.window.layout` object
---
--- Notes:
--- * If `screens` is `nil`, any previous screen configuration is removed, and this windowlayout will be always allowed
--- * For "active" windowlayouts, call this method *before* calling `hs.window.layout:start()`
--- * By using `hs.geometry` size objects as hints you can define separate layouts for the same physical screen at different resolutions
--- * With this method you can define different windowlayouts for different screen configurations (as per System Preferences->Displays->Arrangement).
--- * For example, suppose you define two "graphics design work" windowlayouts, one for "desk with dual monitors" and one for "laptop only mode":
--- * "passive mode" use: you call `:apply()` on *both* on your chosen hotkey (via `hs.hotkey:bind()`), but only the appropriate layout for the current arrangement will be applied
--- * "active mode" use: you just call `:start()` on both windowlayouts; as you switch between workplaces (by attaching or detaching external screens) the correct layout "kicks in" automatically - this is in effect a convenience wrapper that calls `:pause()` on the no longer relevant layout, and `:resume()` on the appropriate one, at every screen configuration change
---
--- Examples:
--- ```lua
--- local laptop_layout,desk_layout=... -- define your layouts
--- -- just the laptop screen:
--- laptop_layout:setScreenConfiguration{['Color LCD']='0,0',dell=false,['3840x2160']=false}:start()
--- -- attached to a 4k primary + a Dell on the right:
--- desk_layout:setScreenConfiguration{['3840x2160']='0,0',['dell']='1,0',['Color LCD']='-1,0'}:start()
--- -- as above, but in clamshell mode (laptop lid closed):
--- clamshell_layout:setScreenConfiguration{['3840x2160']='0,0',['dell']='1,0',['Color LCD']=false}:start()
--- ```
function layout:setScreenConfiguration(screens)
if not screens then
screenInstances[self]=nil
self.screens=nil self.log.i'screen configuration removed'
else
if type(screens)~='table' then error('screens must be a map',2) end
local r={}
for hint,pos in pairs(screens) do
local s=validatescreen(hint,0) if not s then errorf('invalid screen hint: %s',hint,2) end
if type(pos)=='boolean' then
r[s]=pos self.log.f('screen configuration: %s %s',s,pos and 'present' or 'absent')
else
local ok,res=pcall(geom.new,pos)
if not ok or geom.type(res)~='point' then errorf('invalid screen position: %s',pos,2) end
r[s]=res self.log.f('screen configuration: %s at %s',s,res.string)
end
end
self.screens=r screenInstances[self]=true
end
checkScreenInstances()
return self
end
--- hs.window.layout.pauseAllInstances()
--- Function
--- Pauses all active windowlayout instances
---
--- Parameters:
--- * None
---
--- Returns:
--- * None
function layout.pauseAllInstances() for wl in pairs(activeInstances) do wl:pause() end end
--- hs.window.layout.resumeAllInstances()
--- Function
--- Resumes all active windowlayout instances
---
--- Parameters:
--- * None
---
--- Returns:
--- * None
function layout.resumeAllInstances() for wl in pairs(activeInstances) do wl:resume() end end
--- hs.window.layout.applyLayout(rules)
--- Function
--- Applies a layout
---
--- Parameters:
--- * rules - see `hs.window.layout.new()`
---
--- Returns:
--- * None
---
--- Notes:
--- * this is a convenience wrapper for "passive mode" use that creates, applies, and deletes a windowlayout object;
--- do *not* use shared windowfilters in `rules`, as they'll be deleted; you can just use constructor argument maps instead
-- Note: the windowfilters are created on the fly, used and immediately deleted when done, must warn user against passing in his own windowfilters, or allow
-- *another* parameter (meh), or set up __mode='k' and __gc in wf's activeInstances; this to make stuff like
-- layout.apply{hs.application.frontmostApplication():title,...} straightforward
function layout.applyLayout(rules) layout.new(rules):apply():delete() end
--TODO...
--function layout.getLayout(layout,includeScreen)
--layout is optional
-- to detect tiling: no intersections, union area = sum of areas
--end
--TODO "restore" action
-- for 'restore': settings.set should be 1. screen definitions if provided or 2.screens geometry as per old windowlayouts
return layout
| mit |
TheAnswer/FirstTest | bin/scripts/slashcommands/skills/confusionShot.lua | 1 | 2580 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
--true = 1, false = 0
ConfusionShotSlashCommand = {
name = "confusionshot",
alternativeNames = "",
animation = "",
invalidStateMask = 3894805552, --alert, berzerk, tumbling, frozen, swimming, glowingJedi, ridingMount, pilotingShip, shipOperations, shipGunner,
invalidPostures = "3,5,6,7,8,9,10,11,12,13,14,4,",
target = 1,
targeType = 2,
disabled = 0,
maxRangeToTarget = 0,
--adminLevel = 0,
addToCombatQueue = 1,
}
AddConfusionShotSlashCommand(ConfusionShotSlashCommand)
| lgpl-3.0 |
chrisdugne/ludum-dare-36 | main.lua | 1 | 1999 | --------------------------------------------------------------------------------
--
-- main.lua
--
--------------------------------------------------------------------------------
--- Corona's libraries
json = require 'json'
composer = require 'composer'
---- Additional libs
CBE = require 'CBE.CBE'
_ = require 'src.libs.Underscore'
utils = require 'src.libs.Utils'
analytics = require 'src.libs.google.Analytics'
--------------------------------------------------------------------------------
---- App packages
-- main
App = require 'src.App'
Router = require 'src.Router'
User = require 'src.User'
-- game engine
Game = require 'src.game.engine.Game'
Camera = require 'src.game.engine.Camera'
HUD = require 'src.game.engine.HUD'
Effects = require 'src.game.engine.Effects'
Touch = require 'src.game.engine.TouchController'
Score = require 'src.game.engine.Score'
Sound = require 'src.game.engine.Sound'
-- gui components
GUI = require 'src.components.GUI'
Background = require 'src.components.Background'
Panel = require 'src.components.Panel'
Banner = require 'src.components.Banner'
Button = require 'src.components.Button'
Icon = require 'src.components.Icon'
ProgressBar = require 'src.components.ProgressBar'
Scroller = require 'src.components.Scroller'
Screen = require 'src.components.Screen'
Focus = require 'src.components.Focus'
--------------------------------------------------------------------------------
---- Models
Cerise = require 'src.game.models.Cerise'
Bird = require 'src.game.models.Bird'
--------------------------------------------------------------------------------
App:start()
| bsd-3-clause |
TheAnswer/FirstTest | bin/scripts/items/bluefrog/jedWeaponSet.lua | 1 | 2206 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
jediItems = {oneHandedLightsaber, polearmLightsaber, twoHandedLightsaber}
addBFItemSet("Jedi Items" , jediItems);
| lgpl-3.0 |
TheAnswer/FirstTest | bin/scripts/creatures/objects/naboo/npcs/tradeFederation/tradeFederationPirate.lua | 1 | 4626 | --Copyright (C) 2008 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
tradeFederationPirate = Creature:new {
objectName = "tradeFederationPirate", -- Lua Object Name
creatureType = "NPC",
faction = "trade_federation",
factionPoints = 20,
gender = "",
speciesName = "trade_federation_pirate",
stfName = "mob/creature_names",
objectCRC = 595567551,
socialGroup = "trade_federation",
level = 10,
combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG + AGGRESSIVE_FLAG,
healthMax = 990,
healthMin = 810,
strength = 0,
constitution = 0,
actionMax = 990,
actionMin = 810,
quickness = 0,
stamina = 0,
mindMax = 990,
mindMin = 810,
focus = 0,
willpower = 0,
height = 1, -- Size of creature
armor = 0, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy
kinetic = 0,
energy = 0,
electricity = 0,
stun = -1,
blast = 0,
heat = 0,
cold = 0,
acid = 0,
lightsaber = 0,
accuracy = 0,
healer = 0,
pack = 1,
herd = 0,
stalker = 0,
killer = 0,
ferocity = 0,
aggressive = 1,
invincible = 0,
attackCreatureOnSight = "", -- Enter socialGroups
weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx
weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance'
weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance'
weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon'
weaponEquipped = 0,
weaponMinDamage = 90,
weaponMaxDamage = 110,
weaponAttackSpeed = 2,
weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc
weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY
alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx
alternateWeaponName = "", -- Name ex. 'a Vibrolance'
alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance'
alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon'
alternateWeaponEquipped = 0,
alternateWeaponMinDamage = 0,
alternateWeaponMaxDamage = 0,
alternateWeaponAttackSpeed = 0,
alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc
alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY
internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's
lootGroup = "0", -- Group it belongs to for loot
tame = 0,
datapadItemCRC = 0,
mountCRC = 0,
mountSpeed = 0,
mountAcceleration = 0,
milk = 0,
boneType = "",
boneMax = 0,
hideType = "",
hideMax = 0,
meatType = "",
meatMax = 0,
skills = { "tradeFederationAttack1" },
respawnTimer = 180,
behaviorScript = "", -- Link to the behavior script for this object
}
Creatures:addCreature(tradeFederationPirate, 595567551) -- Add to Global Table
| lgpl-3.0 |
Andrettin/Wyrmsun | scripts/settlements_switzerland.lua | 1 | 3304 | -- _________ __ __
-- / _____// |_____________ _/ |______ ____ __ __ ______
-- \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
-- / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \
-- /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
-- \/ \/ \//_____/ \/
-- ______________________ ______________________
-- T H E W A R B E G I N S
-- Stratagus - A free fantasy real time strategy game engine
--
-- (c) Copyright 2016-2022 by Andrettin
--
-- 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
DefineSite("martigny", {
Name = "Martigny",
MapTemplate = "old_earth",
Position = {3996, 999},
CulturalNames = {
"french", "Martigny"
},
HistoricalOwners = {
395, "rome", -- Martigny was a part of the Roman Empire in 395; Source: William R. Shepherd, "Historical Atlas", 1911, pp. 42-43.
481, "burgundy", -- Martigny's area was a Burgundian possession in the 481-532 period; Source: William R. Shepherd, "Historical Atlas", 1911, p. 53.
486, "burgundy", -- Martigny's area was a part of the Kingdom of the Burgundians in 486; Source: William R. Shepherd, "Historical Atlas", 1911, pp. 50-51.
561, "burgundia" -- Martigny's area went to Gunthram when Chlotar I died in 561; Source: Gustav Droysen, "Droysens Allgemeiner Historischer Handatlas", 1886, p. 20.
},
HistoricalBuildings = {
395, 0, "temple" -- Martigny was the seat of a bishopric in 395; Source: William R. Shepherd, "Historical Atlas", 1911, pp. 42-43.
},
Regions = {"europe"}
})
DefineSite("vindonissa", {
Name = "Vindonissa",
MapTemplate = "old_earth",
Position = {4029, 969},
HistoricalOwners = {
395, "rome", -- Vindonissa was a part of the Roman Empire in 395; Source: William R. Shepherd, "Historical Atlas", 1911, pp. 42-43.
481, "alamannia", -- Vindonissa's area was an Alamannic possession in the 481-536 period; Source: William R. Shepherd, "Historical Atlas", 1911, p. 53.
486, "alamannia", -- Vindonissa's area was belonged to the Alamanni in 486; Source: William R. Shepherd, "Historical Atlas", 1911, pp. 50-51.
561, "austrasia" -- Vindonissa's area went to Sigibert when Chlotar I died in 561; Source: Gustav Droysen, "Droysens Allgemeiner Historischer Handatlas", 1886, p. 20.
},
HistoricalBuildings = {
395, 0, "temple" -- Vindonissa was the seat of a bishopric in 395; Source: William R. Shepherd, "Historical Atlas", 1911, pp. 42-43.
},
Regions = {"europe"}
})
| gpl-2.0 |
BakaBBQ/siki.lua | main.lua | 1 | 2362 |
currentFrameImage = nil
root = os.getenv("HOME")
require 'minibuffer'
require 'datautils'
local json = require('dkjson')
local inspect = require 'inspect'
-- frameDatas, a filename -> framedata hash
frameDatas = {}
currentFrameData = nil
require("stage")
tmp_file = 'tmp.json'
function love.load()
if love.filesystem.exists( tmp_file ) and love.filesystem.isFile(tmp_file) then
local contents, size = love.filesystem.read(tmp_file)
local obj, pos, err = json.decode(contents, 1, nil)
if err then
print ("Error: ", err)
else
root = obj.root
end
else
print("[WARNING] cannot find tmp file, using the user home")
root = os.getenv("HOME")
end
loveframes = require("love-frames")
loveframes.util.RemoveAll()
require("savestate")
require("boxLists")
require("flagLists")
require("filelist")
end
function loadFrame(relative_path) -- just the filename... no path...
if #frameDatas == 0 then
print("Blank frame data, loading json")
frameDatas = datautils.loadJson()
else
print("Already inited frameData")
print(inspect(frameDatas))
end
local absolute_path = root .. '/' .. relative_path
print("Absolute Path: " .. absolute_path)
local f = io.open(absolute_path)
local contents = f:read('*a')
f:close()
currentFrameData = datautils.retrieveFrameData(relative_path)
print("Current Frame Data: " .. inspect(frameDatas))
image = love.graphics.newImage(love.image.newImageData(love.filesystem.newFileData(contents, 'Images/character.png')))
datautils.saveCurrentState()
refreshFlagList()
refreshBoxList()
return image
end
function love.update(dt)
stage.updateKeyStroke()
if love.keyboard.isDown("p") then
print(inspect(frameDatas))
end
require("lurker").update()
loveframes.update(dt)
end
function love.draw()
decorateStage()
drawMinibuffer()
loveframes.draw()
end
function love.mousepressed(x, y, button)
loveframes.mousepressed(x, y, button)
stage.onMouseClick(x,y)
end
function love.mousereleased(x, y, button)
stage.mousereleased(x, y, button)
loveframes.mousereleased(x, y, button)
end
function love.keypressed(key, unicode)
loveframes.keypressed(key, unicode)
end
function love.keyreleased(key)
loveframes.keyreleased(key)
end
function love.textinput(text)
loveframes.textinput(text)
end
| mit |
TheAnswer/FirstTest | bin/scripts/creatures/objects/lok/npcs/canyonCorsair/canyonCorsairDestroyer.lua | 1 | 4638 | --Copyright (C) 2008 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
canyonCorsairDestroyer = Creature:new {
objectName = "canyonCorsairDestroyer", -- Lua Object Name
creatureType = "NPC",
faction = "canyon_corsair",
factionPoints = 20,
gender = "",
speciesName = "canyon_corsair_destroyer",
stfName = "mob/creature_names",
objectCRC = 3900861345,
socialGroup = "canyon_corsair",
level = 40,
combatFlags = ATTACKABLE_FLAG + ENEMY_FLAG + AGGRESSIVE_FLAG,
healthMax = 10800,
healthMin = 8800,
strength = 0,
constitution = 0,
actionMax = 10800,
actionMin = 8800,
quickness = 0,
stamina = 0,
mindMax = 10800,
mindMin = 8800,
focus = 0,
willpower = 0,
height = 1, -- Size of creature
armor = 0, -- 0 = None; 1 = Light; 2 = Medium; 3 = Heavy
kinetic = 0,
energy = 60,
electricity = 0,
stun = -1,
blast = 0,
heat = 0,
cold = -1,
acid = 0,
lightsaber = 0,
accuracy = 0,
healer = 0,
pack = 1,
herd = 0,
stalker = 0,
killer = 1,
ferocity = 0,
aggressive = 1,
invincible = 0,
attackCreatureOnSight = "", -- Enter socialGroups
weapon = "object/weapon/creature/shared_creature_default_weapon.iff", -- File path to weapon -> object\xxx\xxx\xx
weaponName = "Creature Defualt", -- Name ex. 'a Vibrolance'
weaponTemp = "creature_default_weapon", -- Weapon Template ex. 'lance_vibrolance'
weaponClass = "UnarmedMeleeWeapon", -- Weapon Class ex. 'PolearmMeleeWeapon'
weaponEquipped = 0,
weaponMinDamage = 355,
weaponMaxDamage = 420,
weaponAttackSpeed = 2,
weaponDamageType = "KINETIC", -- ELECTRICITY, KINETIC, etc
weaponArmorPiercing = "NONE", -- LIGHT, NONE, MEDIUM, HEAVY
alternateWeapon = "", -- File path to weapon -> object\xxx\xxx\xx
alternateWeaponName = "", -- Name ex. 'a Vibrolance'
alternateWeaponTemp = "", -- Weapon Template ex. 'lance_vibrolance'
alternateWeaponClass = "", -- Weapon Class ex. 'PolearmMeleeWeapon'
alternateWeaponEquipped = 0,
alternateWeaponMinDamage = 0,
alternateWeaponMaxDamage = 0,
alternateWeaponAttackSpeed = 0,
alternateWeaponDamageType = "", -- ELECTRICITY, KINETIC, etc
alternateWeaponArmorPiercing = "", -- LIGHT, NONE, MEDIUM, HEAVY
internalNPCDamageModifier = 0.3, -- Damage Modifier to other NPC's
lootGroup = "0", -- Group it belongs to for loot
tame = 0,
datapadItemCRC = 0,
mountCRC = 0,
mountSpeed = 0,
mountAcceleration = 0,
milk = 0,
boneType = "",
boneMax = 0,
hideType = "",
hideMax = 0,
meatType = "",
meatMax = 0,
skills = { "canyonCorsairAttack1" },
respawnTimer = 180,
behaviorScript = "", -- Link to the behavior script for this object
}
Creatures:addCreature(canyonCorsairDestroyer, 3900861345) -- Add to Global Table
| lgpl-3.0 |
GranPC/kindleroot | adb.lua | 2 | 1798 | adb = {}
function adb.waitfordevice( callback )
local command = util.generatecall( "adb", "-s product:soho wait-for-device" )
local function adbcallback( code, out )
if code ~= 0 then
adb.waitfordevice( callback )
print( "adb process died mysteriously..." )
print( "--------- PROCESS OUTPUT ---------\n")
print( out )
print( "--------- NO MORE OUTPUT ---------\n")
else
callback( code == 0 )
end
end
if EMULATE_DEVICE_INTERACTION then
print( "Spoofing ADB device detection... Would have run \"" .. command .. "\"" )
callback( true )
else
util.run( command, adbcallback )
end
end
local emulatedoutputs = {}
emulatedoutputs[ "getprop ro.rom.type" ] = "minisystem"
emulatedoutputs[ "su -c \"chmod 777 /cache && rm -f /cache/update.zip\"" ] = ""
function adb.run( command, callback )
local sh = command
local command = util.generatecall( "adb", "-s product:soho shell " .. command )
if EMULATE_DEVICE_INTERACTION then
print( "Spoofing ADB shell command... Would have run \"" .. command .. "\"" )
callback( 0, emulatedoutputs[ sh ] or "nothing happens..." )
else
util.run( command, callback )
end
end
function adb.push( what, where, callback )
local command = util.generatecall( "adb", "-s product:soho push " .. what .. " " .. where )
if EMULATE_DEVICE_INTERACTION then
print( "Spoofing ADB push... Would have run \"" .. command .. "\"" )
callback( 0, "OK" )
else
util.run( command, callback )
end
end
function adb.reboot( mode, callback )
mode = mode and ( " " .. mode ) or ""
local command = util.generatecall( "adb", "-s product:soho reboot" .. mode )
if EMULATE_DEVICE_INTERACTION then
print( "Spoofing ADB reboot... Would have run \"" .. command .. "\"" )
callback( 0, "" )
else
util.run( command, callback )
end
end
| mit |
yav/language-lua | lua-5.3.1-tests/literals.lua | 4 | 10040 | -- $Id: literals.lua,v 1.34 2015/03/04 13:09:38 roberto Exp $
print('testing scanner')
local debug = require "debug"
local function dostring (x) return assert(load(x), "")() end
dostring("x \v\f = \t\r 'a\0a' \v\f\f")
assert(x == 'a\0a' and string.len(x) == 3)
-- escape sequences
assert('\n\"\'\\' == [[
"'\]])
assert(string.find("\a\b\f\n\r\t\v", "^%c%c%c%c%c%c%c$"))
-- assume ASCII just for tests:
assert("\09912" == 'c12')
assert("\99ab" == 'cab')
assert("\099" == '\99')
assert("\099\n" == 'c\10')
assert('\0\0\0alo' == '\0' .. '\0\0' .. 'alo')
assert(010 .. 020 .. -030 == "1020-30")
-- hexadecimal escapes
assert("\x00\x05\x10\x1f\x3C\xfF\xe8" == "\0\5\16\31\60\255\232")
local function lexstring (x, y, n)
local f = assert(load('return ' .. x ..
', require"debug".getinfo(1).currentline', ''))
local s, l = f()
assert(s == y and l == n)
end
lexstring("'abc\\z \n efg'", "abcefg", 2)
lexstring("'abc\\z \n\n\n'", "abc", 4)
lexstring("'\\z \n\t\f\v\n'", "", 3)
lexstring("[[\nalo\nalo\n\n]]", "alo\nalo\n\n", 5)
lexstring("[[\nalo\ralo\n\n]]", "alo\nalo\n\n", 5)
lexstring("[[\nalo\ralo\r\n]]", "alo\nalo\n", 4)
lexstring("[[\ralo\n\ralo\r\n]]", "alo\nalo\n", 4)
lexstring("[[alo]\n]alo]]", "alo]\n]alo", 2)
assert("abc\z
def\z
ghi\z
" == 'abcdefghi')
-- UTF-8 sequences
assert("\u{0}\u{00000000}\x00\0" == string.char(0, 0, 0, 0))
-- limits for 1-byte sequences
assert("\u{0}\u{7F}" == "\x00\z\x7F")
-- limits for 2-byte sequences
assert("\u{80}\u{7FF}" == "\xC2\x80\z\xDF\xBF")
-- limits for 3-byte sequences
assert("\u{800}\u{FFFF}" == "\xE0\xA0\x80\z\xEF\xBF\xBF")
-- limits for 4-byte sequences
assert("\u{10000}\u{10FFFF}" == "\xF0\x90\x80\x80\z\xF4\x8F\xBF\xBF")
-- Error in escape sequences
local function lexerror (s, err)
local st, msg = load('return ' .. s, '')
if err ~= '<eof>' then err = err .. "'" end
assert(not st and string.find(msg, "near .-" .. err))
end
lexerror([["abc\x"]], [[\x"]])
lexerror([["abc\x]], [[\x]])
lexerror([["\x]], [[\x]])
lexerror([["\x5"]], [[\x5"]])
lexerror([["\x5]], [[\x5]])
lexerror([["\xr"]], [[\xr]])
lexerror([["\xr]], [[\xr]])
lexerror([["\x.]], [[\x.]])
lexerror([["\x8%"]], [[\x8%%]])
lexerror([["\xAG]], [[\xAG]])
lexerror([["\g"]], [[\g]])
lexerror([["\g]], [[\g]])
lexerror([["\."]], [[\%.]])
lexerror([["\999"]], [[\999"]])
lexerror([["xyz\300"]], [[\300"]])
lexerror([[" \256"]], [[\256"]])
-- errors in UTF-8 sequences
lexerror([["abc\u{110000}"]], [[abc\u{110000]]) -- too large
lexerror([["abc\u11r"]], [[abc\u1]]) -- missing '{'
lexerror([["abc\u"]], [[abc\u"]]) -- missing '{'
lexerror([["abc\u{11r"]], [[abc\u{11r]]) -- missing '}'
lexerror([["abc\u{11"]], [[abc\u{11"]]) -- missing '}'
lexerror([["abc\u{11]], [[abc\u{11]]) -- missing '}'
lexerror([["abc\u{r"]], [[abc\u{r]]) -- no digits
-- unfinished strings
lexerror("[=[alo]]", "<eof>")
lexerror("[=[alo]=", "<eof>")
lexerror("[=[alo]", "<eof>")
lexerror("'alo", "<eof>")
lexerror("'alo \\z \n\n", "<eof>")
lexerror("'alo \\z", "<eof>")
lexerror([['alo \98]], "<eof>")
-- valid characters in variable names
for i = 0, 255 do
local s = string.char(i)
assert(not string.find(s, "[a-zA-Z_]") == not load(s .. "=1", ""))
assert(not string.find(s, "[a-zA-Z_0-9]") ==
not load("a" .. s .. "1 = 1", ""))
end
-- long variable names
var1 = string.rep('a', 15000) .. '1'
var2 = string.rep('a', 15000) .. '2'
prog = string.format([[
%s = 5
%s = %s + 1
return function () return %s - %s end
]], var1, var2, var1, var1, var2)
local f = dostring(prog)
assert(_G[var1] == 5 and _G[var2] == 6 and f() == -1)
var1, var2, f = nil
print('+')
-- escapes --
assert("\n\t" == [[
]])
assert([[
$debug]] == "\n $debug")
assert([[ [ ]] ~= [[ ] ]])
-- long strings --
b = "001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789"
assert(string.len(b) == 960)
prog = [=[
print('+')
a1 = [["this is a 'string' with several 'quotes'"]]
a2 = "'quotes'"
assert(string.find(a1, a2) == 34)
print('+')
a1 = [==[temp = [[an arbitrary value]]; ]==]
assert(load(a1))()
assert(temp == 'an arbitrary value')
-- long strings --
b = "001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789"
assert(string.len(b) == 960)
print('+')
a = [[00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
00123456789012345678901234567890123456789123456789012345678901234567890123456789
]]
assert(string.len(a) == 1863)
assert(string.sub(a, 1, 40) == string.sub(b, 1, 40))
x = 1
]=]
print('+')
x = nil
dostring(prog)
assert(x)
prog = nil
a = nil
b = nil
-- testing line ends
prog = [[
a = 1 -- a comment
b = 2
x = [=[
hi
]=]
y = "\
hello\r\n\
"
return require"debug".getinfo(1).currentline
]]
for _, n in pairs{"\n", "\r", "\n\r", "\r\n"} do
local prog, nn = string.gsub(prog, "\n", n)
assert(dostring(prog) == nn)
assert(_G.x == "hi\n" and _G.y == "\nhello\r\n\n")
end
-- testing comments and strings with long brackets
a = [==[]=]==]
assert(a == "]=")
a = [==[[===[[=[]]=][====[]]===]===]==]
assert(a == "[===[[=[]]=][====[]]===]===")
a = [====[[===[[=[]]=][====[]]===]===]====]
assert(a == "[===[[=[]]=][====[]]===]===")
a = [=[]]]]]]]]]=]
assert(a == "]]]]]]]]")
--[===[
x y z [==[ blu foo
]==
]
]=]==]
error error]=]===]
-- generate all strings of four of these chars
local x = {"=", "[", "]", "\n"}
local len = 4
local function gen (c, n)
if n==0 then coroutine.yield(c)
else
for _, a in pairs(x) do
gen(c..a, n-1)
end
end
end
for s in coroutine.wrap(function () gen("", len) end) do
assert(s == load("return [====[\n"..s.."]====]", "")())
end
-- testing decimal point locale
if os.setlocale("pt_BR") or os.setlocale("ptb") then
assert(not load("a = (3,4)"))
assert(tonumber("3,4") == 3.4 and tonumber"3.4" == nil)
assert(assert(load("return 3.4"))() == 3.4)
assert(assert(load("return .4,3"))() == .4)
assert(assert(load("return 4."))() == 4.)
assert(assert(load("return 4.+.5"))() == 4.5)
local a,b = load("return 4.5.")
assert(string.find(b, "'4%.5%.'"))
assert(os.setlocale("C"))
else
(Message or print)(
'\n >>> pt_BR locale not available: skipping decimal point tests <<<\n')
end
-- testing %q x line ends
local s = "a string with \r and \n and \r\n and \n\r"
local c = string.format("return %q", s)
assert(assert(load(c))() == s)
-- testing errors
assert(not load"a = 'non-ending string")
assert(not load"a = 'non-ending string\n'")
assert(not load"a = '\\345'")
assert(not load"a = [=x]")
print('OK')
| bsd-3-clause |
thkhxm/TGame | Assets/LuaFramework/ToLua/Lua/protobuf/encoder.lua | 7 | 15221 | --
--------------------------------------------------------------------------------
-- FILE: encoder.lua
-- DESCRIPTION: protoc-gen-lua
-- Google's Protocol Buffers project, ported to lua.
-- https://code.google.com/p/protoc-gen-lua/
--
-- Copyright (c) 2010 , 林卓毅 (Zhuoyi Lin) netsnail@gmail.com
-- All rights reserved.
--
-- Use, modification and distribution are subject to the "New BSD License"
-- as listed at <url: http://www.opensource.org/licenses/bsd-license.php >.
--
-- COMPANY: NetEase
-- CREATED: 2010年07月29日 19时30分46秒 CST
--------------------------------------------------------------------------------
--
local string = string
local table = table
local ipairs = ipairs
local assert =assert
local pb = require "pb"
local wire_format = require "protobuf.wire_format"
module "protobuf.encoder"
function _VarintSize(value)
if value <= 0x7f then return 1 end
if value <= 0x3fff then return 2 end
if value <= 0x1fffff then return 3 end
if value <= 0xfffffff then return 4 end
return 5
end
function _SignedVarintSize(value)
if value < 0 then return 10 end
if value <= 0x7f then return 1 end
if value <= 0x3fff then return 2 end
if value <= 0x1fffff then return 3 end
if value <= 0xfffffff then return 4 end
return 5
end
function _TagSize(field_number)
return _VarintSize(wire_format.PackTag(field_number, 0))
end
function _SimpleSizer(compute_value_size)
return function(field_number, is_repeated, is_packed)
local tag_size = _TagSize(field_number)
if is_packed then
local VarintSize = _VarintSize
return function(value)
local result = 0
for _, element in ipairs(value) do
result = result + compute_value_size(element)
end
return result + VarintSize(result) + tag_size
end
elseif is_repeated then
return function(value)
local result = tag_size * #value
for _, element in ipairs(value) do
result = result + compute_value_size(element)
end
return result
end
else
return function (value)
return tag_size + compute_value_size(value)
end
end
end
end
function _ModifiedSizer(compute_value_size, modify_value)
return function (field_number, is_repeated, is_packed)
local tag_size = _TagSize(field_number)
if is_packed then
local VarintSize = _VarintSize
return function (value)
local result = 0
for _, element in ipairs(value) do
result = result + compute_value_size(modify_value(element))
end
return result + VarintSize(result) + tag_size
end
elseif is_repeated then
return function (value)
local result = tag_size * #value
for _, element in ipairs(value) do
result = result + compute_value_size(modify_value(element))
end
return result
end
else
return function (value)
return tag_size + compute_value_size(modify_value(value))
end
end
end
end
function _FixedSizer(value_size)
return function (field_number, is_repeated, is_packed)
local tag_size = _TagSize(field_number)
if is_packed then
local VarintSize = _VarintSize
return function (value)
local result = #value * value_size
return result + VarintSize(result) + tag_size
end
elseif is_repeated then
local element_size = value_size + tag_size
return function(value)
return #value * element_size
end
else
local field_size = value_size + tag_size
return function (value)
return field_size
end
end
end
end
Int32Sizer = _SimpleSizer(_SignedVarintSize)
Int64Sizer = Int32Sizer
EnumSizer = Int32Sizer
UInt32Sizer = _SimpleSizer(_VarintSize)
UInt64Sizer = UInt32Sizer
SInt32Sizer = _ModifiedSizer(_SignedVarintSize, wire_format.ZigZagEncode)
SInt64Sizer = SInt32Sizer
Fixed32Sizer = _FixedSizer(4)
SFixed32Sizer = Fixed32Sizer
FloatSizer = Fixed32Sizer
Fixed64Sizer = _FixedSizer(8)
SFixed64Sizer = Fixed64Sizer
DoubleSizer = Fixed64Sizer
BoolSizer = _FixedSizer(1)
function StringSizer(field_number, is_repeated, is_packed)
local tag_size = _TagSize(field_number)
local VarintSize = _VarintSize
assert(not is_packed)
if is_repeated then
return function(value)
local result = tag_size * #value
for _, element in ipairs(value) do
local l = #element
result = result + VarintSize(l) + l
end
return result
end
else
return function(value)
local l = #value
return tag_size + VarintSize(l) + l
end
end
end
function BytesSizer(field_number, is_repeated, is_packed)
local tag_size = _TagSize(field_number)
local VarintSize = _VarintSize
assert(not is_packed)
if is_repeated then
return function (value)
local result = tag_size * #value
for _,element in ipairs(value) do
local l = #element
result = result + VarintSize(l) + l
end
return result
end
else
return function (value)
local l = #value
return tag_size + VarintSize(l) + l
end
end
end
function MessageSizer(field_number, is_repeated, is_packed)
local tag_size = _TagSize(field_number)
local VarintSize = _VarintSize
assert(not is_packed)
if is_repeated then
return function(value)
local result = tag_size * #value
for _,element in ipairs(value) do
local l = element:ByteSize()
result = result + VarintSize(l) + l
end
return result
end
else
return function (value)
local l = value:ByteSize()
return tag_size + VarintSize(l) + l
end
end
end
-- ====================================================================
-- Encoders!
local _EncodeVarint = pb.varint_encoder
local _EncodeSignedVarint = pb.signed_varint_encoder
local _EncodeVarint64 = pb.varint_encoder64
local _EncodeSignedVarint64 = pb.signed_varint_encoder64
function _VarintBytes(value)
local out = {}
local write = function(value)
out[#out + 1 ] = value
end
_EncodeSignedVarint(write, value)
return table.concat(out)
end
function TagBytes(field_number, wire_type)
return _VarintBytes(wire_format.PackTag(field_number, wire_type))
end
function _SimpleEncoder(wire_type, encode_value, compute_value_size)
return function(field_number, is_repeated, is_packed)
if is_packed then
local tag_bytes = TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED)
local EncodeVarint = _EncodeVarint
return function(write, value)
write(tag_bytes)
local size = 0
for _, element in ipairs(value) do
size = size + compute_value_size(element)
end
EncodeVarint(write, size)
for element in value do
encode_value(write, element)
end
end
elseif is_repeated then
local tag_bytes = TagBytes(field_number, wire_type)
return function(write, value)
for _, element in ipairs(value) do
write(tag_bytes)
encode_value(write, element)
end
end
else
local tag_bytes = TagBytes(field_number, wire_type)
return function(write, value)
write(tag_bytes)
encode_value(write, value)
end
end
end
end
function _ModifiedEncoder(wire_type, encode_value, compute_value_size, modify_value)
return function (field_number, is_repeated, is_packed)
if is_packed then
local tag_bytes = TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED)
local EncodeVarint = _EncodeVarint
return function (write, value)
write(tag_bytes)
local size = 0
for _, element in ipairs(value) do
size = size + compute_value_size(modify_value(element))
end
EncodeVarint(write, size)
for _, element in ipairs(value) do
encode_value(write, modify_value(element))
end
end
elseif is_repeated then
local tag_bytes = TagBytes(field_number, wire_type)
return function (write, value)
for _, element in ipairs(value) do
write(tag_bytes)
encode_value(write, modify_value(element))
end
end
else
local tag_bytes = TagBytes(field_number, wire_type)
return function (write, value)
write(tag_bytes)
encode_value(write, modify_value(value))
end
end
end
end
function _StructPackEncoder(wire_type, value_size, format)
return function(field_number, is_repeated, is_packed)
local struct_pack = pb.struct_pack
if is_packed then
local tag_bytes = TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED)
local EncodeVarint = _EncodeVarint
return function (write, value)
write(tag_bytes)
EncodeVarint(write, #value * value_size)
for _, element in ipairs(value) do
struct_pack(write, format, element)
end
end
elseif is_repeated then
local tag_bytes = TagBytes(field_number, wire_type)
return function (write, value)
for _, element in ipairs(value) do
write(tag_bytes)
struct_pack(write, format, element)
end
end
else
local tag_bytes = TagBytes(field_number, wire_type)
return function (write, value)
write(tag_bytes)
struct_pack(write, format, value)
end
end
end
end
Int32Encoder = _SimpleEncoder(wire_format.WIRETYPE_VARINT, _EncodeSignedVarint, _SignedVarintSize)
Int64Encoder = _SimpleEncoder(wire_format.WIRETYPE_VARINT, _EncodeSignedVarint64, _SignedVarintSize)
EnumEncoder = Int32Encoder
UInt32Encoder = _SimpleEncoder(wire_format.WIRETYPE_VARINT, _EncodeVarint, _VarintSize)
UInt64Encoder = _SimpleEncoder(wire_format.WIRETYPE_VARINT, _EncodeVarint64, _VarintSize)
SInt32Encoder = _ModifiedEncoder(
wire_format.WIRETYPE_VARINT, _EncodeVarint, _VarintSize,
wire_format.ZigZagEncode32)
SInt64Encoder = _ModifiedEncoder(
wire_format.WIRETYPE_VARINT, _EncodeVarint64, _VarintSize,
wire_format.ZigZagEncode64)
Fixed32Encoder = _StructPackEncoder(wire_format.WIRETYPE_FIXED32, 4, string.byte('I'))
Fixed64Encoder = _StructPackEncoder(wire_format.WIRETYPE_FIXED64, 8, string.byte('Q'))
SFixed32Encoder = _StructPackEncoder(wire_format.WIRETYPE_FIXED32, 4, string.byte('i'))
SFixed64Encoder = _StructPackEncoder(wire_format.WIRETYPE_FIXED64, 8, string.byte('q'))
FloatEncoder = _StructPackEncoder(wire_format.WIRETYPE_FIXED32, 4, string.byte('f'))
DoubleEncoder = _StructPackEncoder(wire_format.WIRETYPE_FIXED64, 8, string.byte('d'))
function BoolEncoder(field_number, is_repeated, is_packed)
local false_byte = '\0'
local true_byte = '\1'
if is_packed then
local tag_bytes = TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED)
local EncodeVarint = _EncodeVarint
return function (write, value)
write(tag_bytes)
EncodeVarint(write, #value)
for _, element in ipairs(value) do
if element then
write(true_byte)
else
write(false_byte)
end
end
end
elseif is_repeated then
local tag_bytes = TagBytes(field_number, wire_format.WIRETYPE_VARINT)
return function(write, value)
for _, element in ipairs(value) do
write(tag_bytes)
if element then
write(true_byte)
else
write(false_byte)
end
end
end
else
local tag_bytes = TagBytes(field_number, wire_format.WIRETYPE_VARINT)
return function (write, value)
write(tag_bytes)
if value then
return write(true_byte)
end
return write(false_byte)
end
end
end
function StringEncoder(field_number, is_repeated, is_packed)
local tag = TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED)
local EncodeVarint = _EncodeVarint
assert(not is_packed)
if is_repeated then
return function (write, value)
for _, element in ipairs(value) do
-- encoded = element.encode('utf-8')
write(tag)
EncodeVarint(write, #element)
write(element)
end
end
else
return function (write, value)
-- local encoded = value.encode('utf-8')
write(tag)
EncodeVarint(write, #value)
return write(value)
end
end
end
function BytesEncoder(field_number, is_repeated, is_packed)
local tag = TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED)
local EncodeVarint = _EncodeVarint
assert(not is_packed)
if is_repeated then
return function (write, value)
for _, element in ipairs(value) do
write(tag)
EncodeVarint(write, #element)
write(element)
end
end
else
return function(write, value)
write(tag)
EncodeVarint(write, #value)
return write(value)
end
end
end
function MessageEncoder(field_number, is_repeated, is_packed)
local tag = TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED)
local EncodeVarint = _EncodeVarint
assert(not is_packed)
if is_repeated then
return function(write, value)
for _, element in ipairs(value) do
write(tag)
EncodeVarint(write, element:ByteSize())
element:_InternalSerialize(write)
end
end
else
return function (write, value)
write(tag)
EncodeVarint(write, value:ByteSize())
return value:_InternalSerialize(write)
end
end
end
| apache-2.0 |
manuel-arguelles/roidsbuster | asteroids.lua | 1 | 1998 | local create_interval = 0.5
local roid = { speed = 200, img = nil, active_asteroids = {}, lost_roid_cb = nil }
local create_timer = create_interval
asteroids = roid
function roid.load(arg)
roid.img = love.graphics.newImage('images/asteroid.png')
end
function roid.create(dt)
create_timer = create_timer - (1 * dt)
if create_timer < 0 then
-- Create new enemy
local rnd_num = math.random(0, love.graphics.getWidth() -
roid.img:getWidth())
new_asteroid = { x = rnd_num, y = -100, img = roid.img }
table.insert(roid.active_asteroids, new_asteroid)
create_timer = create_interval
end
end
function roid.set_decrease_score_cb(cb)
roid.lost_roid_cb = cb
end
function roid.move(dt)
for i, asteroid in ipairs(roid.active_asteroids) do
asteroid.y = asteroid.y + (roid.speed * dt)
if (asteroid.y > love.graphics.getHeight()) then
table.remove(roid.active_asteroids, i)
if roid.lost_roid_cb ~= nil then
roid.lost_roid_cb()
end
end
end
end
function roid.draw(dt)
for i, asteroid in ipairs(roid.active_asteroids) do
love.graphics.draw(asteroid.img, asteroid.x, asteroid.y)
end
end
-- Collision detection taken function from http://love2d.org/wiki/BoundingBox.lua
-- Returns true if two boxes overlap, false if they don't
-- x1,y1 are the left-top coords of the first box, while w1,h1 are its width and height
-- x2,y2,w2 & h2 are the same, but for the second box
local function check_collision(x1, y1, w1, h1, x2, y2, w2, h2)
return x1 < x2+w2 and
x2 < x1+w1 and
y1 < y2+h2 and
y2 < y1+h1
end
function roid.check_collision(x, y, w, h)
for i, asteroid in ipairs(roid.active_asteroids) do
if check_collision(x, y, w, h, asteroid.x, asteroid.y,
asteroid.img:getWidth(), asteroid.img:getHeight()) then
table.remove(roid.active_asteroids, i)
return true
end
end
return false
end
function roid.reset()
roid.active_asteroids = {}
end
return roid
| gpl-2.0 |
Andrettin/Wyrmsun | scripts/guichan.lua | 1 | 14126 | -- _________ __ __
-- / _____// |_____________ _/ |______ ____ __ __ ______
-- \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
-- / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \
-- /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
-- \/ \/ \//_____/ \/
-- ______________________ ______________________
-- T H E W A R B E G I N S
-- Stratagus - A free fantasy real time strategy game engine
--
-- (c) Copyright 2006-2022 by Jimmy Salmon, Pali Rohár and Andrettin
--
-- 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
SetPlayerData(GetThisPlayer(), "RaceName", "gnome")
-- Global useful objects for menus ----------
dark = Color(38, 38, 78)
clear = Color(200, 200, 120)
black = Color(0, 0, 0)
function panel(n)
local panels = {}
panels = {
"interface/" .. GetCivilizationData(GetPlayerData(GetThisPlayer(), "RaceName"), "Interface") .. "/panel_1.png",
"interface/" .. GetCivilizationData(GetPlayerData(GetThisPlayer(), "RaceName"), "Interface") .. "/panel_2.png",
"interface/" .. GetCivilizationData(GetPlayerData(GetThisPlayer(), "RaceName"), "Interface") .. "/panel_3.png",
"interface/" .. GetCivilizationData(GetPlayerData(GetThisPlayer(), "RaceName"), "Interface") .. "/panel_4.png",
"interface/" .. GetCivilizationData(GetPlayerData(GetThisPlayer(), "RaceName"), "Interface") .. "/panel_5.png"
}
return panels[n]
end
function AddMenuHelpers(menu)
function menu:addLabel(text, x, y, font, center)
local label = Label(text)
if (font == nil) then font = Fonts["large"] end
label:setFont(font)
label:adjustSize()
if (center == nil or center == true) then -- center text by default
x = x - label:getWidth() / 2
end
self:add(label, x, y)
return label
end
function menu:writeText(text, x, y)
return self:addLabel(text, x, y, Fonts["game"], false)
end
function menu:writeLargeText(text, x, y)
return self:addLabel(text, x, y, Fonts["large"], false)
end
function menu:addButton(caption, hotkey, x, y, callback, size)
local b = ButtonWidget(caption)
if (hotkey ~= "") then
b:setHotKey(hotkey)
end
b:setActionCallback(
function()
-- PlaySound("click")
callback()
end
)
if (size == nil) then size = {200 * get_scale_factor(), 24 * get_scale_factor()} end
b:setSize(size[1], size[2])
b:setBackgroundColor(dark)
b:setBaseColor(dark)
self:add(b, x, y)
return b
end
function menu:addImageButton(caption, hotkey, x, y, callback)
local b = ImageButton(caption)
if (hotkey ~= "") then
b:setHotKey(hotkey)
end
b:setActionCallback(
function()
PlaySound("click")
callback()
end
)
self:add(b, x, y)
b:setBorderSize(0) -- Andrettin: make buttons not have the borders they previously had
return b
end
function menu:addFullButton(caption, hotkey, x, y, callback)
local b = self:addImageButton(caption, hotkey, x, y, callback)
b:setBaseColor(Color(0,0,0,0))
b:setForegroundColor(Color(0,0,0,0))
b:setBackgroundColor(Color(0,0,0,0))
local g_bln
local g_blp
local g_blg
if (GetPlayerData(GetThisPlayer(), "RaceName") == "gnome") then
g_bln = "interface/default/button_large_normal.png"
g_blp = "interface/default/button_large_pressed.png"
g_blg = "interface/default/button_large_grayed.png"
else
g_bln = "interface/" .. GetCivilizationData(GetPlayerData(GetThisPlayer(), "RaceName"), "Interface") .. "/button_large_normal.png"
g_blp = "interface/" .. GetCivilizationData(GetPlayerData(GetThisPlayer(), "RaceName"), "Interface") .. "/button_large_pressed.png"
g_blg = "interface/" .. GetCivilizationData(GetPlayerData(GetThisPlayer(), "RaceName"), "Interface") .. "/button_large_grayed.png"
end
b:setNormalImage(g_bln)
b:setPressedImage(g_blp)
b:setDisabledImage(g_blg)
b:setSize(224 * get_scale_factor(), 28 * get_scale_factor())
if (string.len(caption) > 24) then
b:setFont(Fonts["game"])
end
return b
end
function menu:addHalfButton(caption, hotkey, x, y, callback)
local b = self:addImageButton(caption, hotkey, x, y, callback)
b:setBaseColor(Color(0,0,0,0))
b:setForegroundColor(Color(0,0,0,0))
b:setBackgroundColor(Color(0,0,0,0))
local g_bsn
local g_bsp
local g_bsg
if (GetPlayerData(GetThisPlayer(), "RaceName") == "gnome") then
g_bsn = "interface/default/button_small_normal.png"
g_bsp = "interface/default/button_small_pressed.png"
g_bsg = "interface/default/button_small_grayed.png"
else
g_bsn = "interface/" .. GetCivilizationData(GetPlayerData(GetThisPlayer(), "RaceName"), "Interface") .. "/button_small_normal.png"
g_bsp = "interface/" .. GetCivilizationData(GetPlayerData(GetThisPlayer(), "RaceName"), "Interface") .. "/button_small_pressed.png"
g_bsg = "interface/" .. GetCivilizationData(GetPlayerData(GetThisPlayer(), "RaceName"), "Interface") .. "/button_small_grayed.png"
end
b:setNormalImage(g_bsn)
b:setPressedImage(g_bsp)
b:setDisabledImage(g_bsg)
b:setSize(106 * get_scale_factor(), 28 * get_scale_factor())
return b
end
function menu:addListBox(x, y, w, h, list)
local bq = ListBoxWidget(w, h)
bq:setList(list)
bq:setBaseColor(black)
bq:setForegroundColor(clear)
bq:setBackgroundColor(dark)
bq:setFont(Fonts["game"])
self:add(bq, x, y)
bq.itemslist = list
return bq
end
function menu:addBrowser(path, filter, x, y, w, h, default, show_subfolders)
local sortMode = 0
-- Andrettin: make it so that it is possible to have a browser without showing subfolders
if (show_subfolders == nil) then
show_subfolders = true
end
-- Create a list of all dirs and files in a directory
local function listfiles(path)
local dirlist = {}
local i
local f
local u = 1
if (show_subfolders) then
local dirs = ListDirsInDirectory(path)
for i,f in ipairs(dirs) do
dirlist[u] = f .. "/"
u = u + 1
end
end
local fileslist
if (sortMode == 0) then
fileslist = ListFilesInDirectory(path)
else
fileslist = ListFilesInDirectorySortByTime(path)
end
for i,f in ipairs(fileslist) do
if (string.find(f, filter)) then
dirlist[u] = f
u = u + 1
end
end
return dirlist
end
local bq = self:addListBox(x, y, w, h, {})
if (string.sub(path, string.len(path)) ~= "/") then
path = path .. "/"
end
bq.origpath = path
bq.actioncb = nil
-- The directory changed, update the list
local function updatelist()
bq.itemslist = listfiles(bq.path)
if (bq.path ~= bq.origpath) then
table.insert(bq.itemslist, 1, "../")
end
bq:setList(bq.itemslist)
end
-- Change to the default directory and select the default file
if (default == nil) then
bq.path = path
updatelist()
else
local i
for i=string.len(default)-1,1,-1 do
if (string.sub(default, i, i) == "/") then
bq.path = string.sub(default, 1, i)
updatelist()
local f = string.sub(default, i + 1)
for i=1,table.getn(bq.itemslist) do
if (bq.itemslist[i] == f) then
bq:setSelected(i - 1)
end
end
break
end
end
end
function bq:exists(name)
for i,v in ipairs(self.itemslist) do
if(v == name) then
return true
end
end
return false
end
function bq:getSelectedItem()
if (self:getSelected() < 0) then
return self.itemslist[1]
end
return self.itemslist[self:getSelected() + 1]
end
-- If a directory was clicked change dirs
-- Otherwise call the user's callback
local function cb(s)
local f = bq:getSelectedItem()
if (f == "../") then
local i
for i=string.len(bq.path)-1,1,-1 do
if (string.sub(bq.path, i, i) == "/") then
bq.path = string.sub(bq.path, 1, i)
updatelist()
break
end
end
elseif (string.sub(f, string.len(f)) == '/') then
bq.path = bq.path .. f
updatelist()
else
if (bq.actioncb ~= nil) then
bq:actioncb(s)
end
end
end
bq:setActionCallback(cb)
bq.oldSetActionCallback = bq.setActionCallback
function bq:setActionCallback(cb)
bq.actioncb = cb
end
function bq:sortByName()
sortMode = 0
updatelist()
end
function bq:sortByTime()
sortMode = 1
updatelist()
end
return bq
end
function menu:addImageCheckBox(caption, x, y, callback) -- DinkyDyeAussie's new function
local b = ImageCheckBox(caption)
b:setBaseColor(Color(0,0,0,0))
b:setForegroundColor(Color(0,0,0,0))
b:setBackgroundColor(Color(0,0,0,0))
-- new functions to display checkbox graphics
local g_checkbox_off
local g_checkbox_off2
local g_checkbox_on
local g_checkbox_on2
g_checkbox_off = "interface/" .. GetCivilizationData(GetPlayerData(GetThisPlayer(), "RaceName"), "Interface") .. "/radio_normal_unselected.png"
g_checkbox_off2 = "interface/" .. GetCivilizationData(GetPlayerData(GetThisPlayer(), "RaceName"), "Interface") .. "/radio_pressed_unselected.png"
g_checkbox_on = "interface/" .. GetCivilizationData(GetPlayerData(GetThisPlayer(), "RaceName"), "Interface") .. "/radio_normal_selected.png"
g_checkbox_on2 = "interface/" .. GetCivilizationData(GetPlayerData(GetThisPlayer(), "RaceName"), "Interface") .. "/radio_pressed_selected.png"
b:setUncheckedNormalImage(g_checkbox_off)
b:setUncheckedPressedImage(g_checkbox_off2)
b:setCheckedNormalImage(g_checkbox_on)
b:setCheckedPressedImage(g_checkbox_on2)
if (callback ~= nil) then b:setActionCallback(function(s) PlaySound("click"); callback(b, s) end) end
b:setFont(Fonts["game"])
self:add(b, x - 1 * get_scale_factor(), y - 1 * get_scale_factor()) -- reduced by 1 because the images are bigger than they are supposed to be, as they are graphics for radio buttons
return b
end
function menu:addDropDown(list, x, y, callback)
local dd = ImageDropDownWidget()
dd:setFont(Fonts["game"])
local g_bar
local g_dslider_n
local g_dslider_p
g_bar = "interface/" .. GetCivilizationData(GetPlayerData(GetThisPlayer(), "RaceName"), "Interface") .. "/pulldown_bar_normal.png"
g_dslider_n = "interface/" .. GetCivilizationData(GetPlayerData(GetThisPlayer(), "RaceName"), "Interface") .. "/down_arrow_normal.png"
g_dslider_p = "interface/" .. GetCivilizationData(GetPlayerData(GetThisPlayer(), "RaceName"), "Interface") .. "/down_arrow_pressed.png"
dd:setItemImage(g_bar)
dd:setDownNormalImage(g_dslider_n)
dd:setDownPressedImage(g_dslider_p)
dd:setList(list)
dd:setActionCallback(function(s) PlaySound("click"); callback(dd, s) end)
dd:setBorderSize(0)
self:add(dd, x, y)
return dd
end
function menu:addTextInputField(text, x, y, w)
local b = TextField(text)
b:setActionCallback(function() end) --FIXME: remove this?
b:setFont(Fonts["game"])
b:setBaseColor(clear)
b:setForegroundColor(clear)
b:setBackgroundColor(dark)
if (w == nil) then
w = 100 * get_scale_factor()
end
b:setSize(w, 18 * get_scale_factor())
self:add(b, x, y)
return b
end
end
function WarMenu(title, background, resize)
local menu
local exitButton
local bg
local bgg
menu = MenuScreen()
if background ~= nil then
if (resize == nil or resize == true) then
bg = ImageWidget(background, 1, Video.Width, Video.Height)
else
bg = ImageWidget(background)
end
menu:add(bg, 0, 0)
end
AddMenuHelpers(menu)
if title then
menu:addLabel(title, Video.Width / 2, Video.Height / 20, Fonts["large"])
end
return menu
end
function WarGrandStrategyMenu(title, resize)
local menu
local exitButton
local bg
local bgg
menu = MenuScreen()
AddMenuHelpers(menu)
if title then
menu:addLabel(title, Video.Width / 2, Video.Height / 20, Fonts["large"])
end
return menu
end
-- Default configurations -------
Widget:setGlobalFont(Fonts["large"])
DefaultObjectives = {"- Defeat your rivals"}
-- Define the different menus ----------
function InitGameSettings()
GameSettings:reset()
end
InitGameSettings()
local buttonStatut = 0 -- 0:not initialised, 1: Ok, 2: Cancel
Load("scripts/menus/save.lua")
Load("scripts/menus/options.lua")
Load("scripts/menus/editor.lua")
Load("scripts/menus/game.lua")
Load("scripts/menus/objectives.lua")
Load("scripts/menus/mods.lua")
Load("scripts/grand_strategy/grand_strategy.lua")
LoadData() -- process the data
load_database(false)
-- load DLCs and mods now
LoadDLCs()
Load("scripts/language_words.lua")
Load("scripts/map_template_data.lua")
Load("scripts/ai_helper.lua") -- load the AI helper after the mods
-- load heroes after the DLCs and mods, so that they can use mod-specific items
LoadingPersistentHeroes = true
if (CanAccessFile("wyr/heroes.lua")) then -- keep compatibility with how heroes were saved before
Load("heroes.lua")
SaveHeroes()
else
LoadHeroes() -- load persistent heroes
end
LoadingPersistentHeroes = false
initialize_database()
--pack_image_folder("C:/Wyrmsun/models/units/aether_workship/Sprites")
| gpl-2.0 |
alireza1998/radical-boy | bot/seedbot.lua | 1 | 9014 | package.path = package.path .. ';.luarocks/share/lua/5.2/?.lua'
..';.luarocks/share/lua/5.2/?/init.lua'
package.cpath = package.cpath .. ';.luarocks/lib/lua/5.2/?.so'
require("./bot/utils")
VERSION = '1.0'
-- This function is called when tg receive a msg
function on_msg_receive (msg)
if not started then
return
end
local receiver = get_receiver(msg)
print (receiver)
-- vardump(msg)
msg = pre_process_service_msg(msg)
if msg_valid(msg) then
msg = pre_process_msg(msg)
if msg then
match_plugins(msg)
-- mark_read(receiver, ok_cb, false)
end
end
end
function ok_cb(extra, success, result)
end
function on_binlog_replay_end()
started = true
postpone (cron_plugins, false, 60*5.0)
_config = load_config()
-- load plugins
plugins = {}
load_plugins()
end
function msg_valid(msg)
-- Don't process outgoing messages
if msg.out then
print('\27[36mNot valid: msg from us\27[39m')
return false
end
-- Before bot was started
if msg.date < now then
print('\27[36mNot valid: old msg\27[39m')
return false
end
if msg.unread == 0 then
print('\27[36mNot valid: readed\27[39m')
return false
end
if not msg.to.id then
print('\27[36mNot valid: To id not provided\27[39m')
return false
end
if not msg.from.id then
print('\27[36mNot valid: From id not provided\27[39m')
return false
end
if msg.from.id == our_id then
print('\27[36mNot valid: Msg from our id\27[39m')
return false
end
if msg.to.type == 'encr_chat' then
print('\27[36mNot valid: Encrypted chat\27[39m')
return false
end
if msg.from.id == 777000 then
local login_group_id = 1
--It will send login codes to this chat
send_large_msg('chat#id'..login_group_id, msg.text)
end
return true
end
--
function pre_process_service_msg(msg)
if msg.service then
local action = msg.action or {type=""}
-- Double ! to discriminate of normal actions
msg.text = "!!tgservice " .. action.type
-- wipe the data to allow the bot to read service messages
if msg.out then
msg.out = false
end
if msg.from.id == our_id then
msg.from.id = 0
end
end
return msg
end
-- Apply plugin.pre_process function
function pre_process_msg(msg)
for name,plugin in pairs(plugins) do
if plugin.pre_process and msg then
print('Preprocess', name)
msg = plugin.pre_process(msg)
end
end
return msg
end
-- Go over enabled plugins patterns.
function match_plugins(msg)
for name, plugin in pairs(plugins) do
match_plugin(plugin, name, msg)
end
end
-- Check if plugin is on _config.disabled_plugin_on_chat table
local function is_plugin_disabled_on_chat(plugin_name, receiver)
local disabled_chats = _config.disabled_plugin_on_chat
-- Table exists and chat has disabled plugins
if disabled_chats and disabled_chats[receiver] then
-- Checks if plugin is disabled on this chat
for disabled_plugin,disabled in pairs(disabled_chats[receiver]) do
if disabled_plugin == plugin_name and disabled then
local warning = 'Plugin '..disabled_plugin..' is disabled on this chat'
print(warning)
send_msg(receiver, warning, ok_cb, false)
return true
end
end
end
return false
end
function match_plugin(plugin, plugin_name, msg)
local receiver = get_receiver(msg)
-- Go over patterns. If one matches it's enough.
for k, pattern in pairs(plugin.patterns) do
local matches = match_pattern(pattern, msg.text)
if matches then
print("msg matches: ", pattern)
if is_plugin_disabled_on_chat(plugin_name, receiver) then
return nil
end
-- Function exists
if plugin.run then
-- If plugin is for privileged users only
if not warns_user_not_allowed(plugin, msg) then
local result = plugin.run(msg, matches)
if result then
send_large_msg(receiver, result)
end
end
end
-- One patterns matches
return
end
end
end
-- DEPRECATED, use send_large_msg(destination, text)
function _send_msg(destination, text)
send_large_msg(destination, text)
end
-- Save the content of _config to config.lua
function save_config( )
serialize_to_file(_config, './data/config.lua')
print ('saved config into ./data/config.lua')
end
-- Returns the config from config.lua file.
-- If file doesn't exist, create it.
function load_config( )
local f = io.open('./data/config.lua', "r")
-- If config.lua doesn't exist
if not f then
print ("Created new config file: data/config.lua")
create_config()
else
f:close()
end
local config = loadfile ("./data/config.lua")()
for v,user in pairs(config.sudo_users) do
print("Allowed user: " .. user)
end
return config
end
-- Create a basic config.json file and saves it.
function create_config( )
-- A simple config with basic plugins and ourselves as privileged user
config = {
enabled_plugins = {
"onservice",
"inrealm",
"ingroup",
"inpm",
"banhammer",
"stats",
"anti_spam",
"owners",
"arabic_lock",
"set",
"get",
"broadcast",
"download_media",
"invite",
"all"
},
sudo_users = {152035077,140962646},--Sudo users
disabled_channels = {},
realm = {},--Realms Id
moderation = {data = 'data/moderation.json'},
about_text = [[Teleseed v1
An advance Administration bot based on yagop/telegram-bot
https://github.com/alireza1998/black-devil
Admins
@alireza_PT [Founder]
@alireza_PT [Developer]
@alireza_PT [Manager]
Special thanks to
awkward_potato
Siyanew
topkecleon
Vamptacus
Our channels
@alireza_PT [English]
]],
help_text = [[
لیست دستورات :
!اخراج [username|id]
You can also do it by reply
!بن [ username|id]
You can also do it by reply
!خارج کردن از بن [id]
You can also do it by reply
!لیست افراد
Members list
!لیست مدیران
Moderators list
! ارتقا درجه [username]
Promote someone
!گرفتن درجه [username]
Demote someone
!منو اخراج کن
Will kick user
!درباره
Group description
!تنظیم عکس
Set and locks group photo
!تنظیم اسم [name]
Set group name
!قوانین
Group rules
!آیدی
return group id or user id
!راهنما
!قفل کردن [member|name|bots]
Locks [member|name|bots]
!باز کردن قفل [member|name|photo|bots]
Unlocks [member|name|photo|bots]
!تنظیم قوانین <text>
Set <text> as rules
!تنظیم درباره گروه <text>
Set <text> as about
!تنظیمات
Returns group settings
!لینک جدید
create/revoke your group link
!لینک
returns group link
!اونر
returns group owner id
!تنظیم اونر [id]
Will set id as owner
!تنظیم حساسیت اسپم [value]
Set [value] as flood sensitivity
!اطلاعات گروه
Simple message statistics
!ذخیره [value] <text>
Save <text> as [value]
!هدایت [value]
Returns text of [value]
!پاک کردن [modlist|rules|about]
Will clear [modlist|rules|about] and set it to nil
!درباره [username]
returns user id
"!res @username"
!لوگ
will return group logs
!لیست بن شده ها
will return group ban list
**U can use both "/" and "!"
*Only owner and mods can add bots in group
*Only moderators and owner can use kick,ban,unban,newlink,link,setphoto,setname,lock,unlock,set rules,set about and settings commands
*Only owner can use res,setowner,promote,demote and log commands
]]
}
serialize_to_file(config, './data/config.lua')
print('saved config into ./data/config.lua')
end
function on_our_id (id)
our_id = id
end
function on_user_update (user, what)
--vardump (user)
end
function on_chat_update (chat, what)
end
function on_secret_chat_update (schat, what)
--vardump (schat)
end
function on_get_difference_end ()
end
-- Enable plugins in config.json
function load_plugins()
for k, v in pairs(_config.enabled_plugins) do
print("Loading plugin", v)
local ok, err = pcall(function()
local t = loadfile("plugins/"..v..'.lua')()
plugins[v] = t
end)
if not ok then
print('\27[31mError loading plugin '..v..'\27[39m')
print('\27[31m'..err..'\27[39m')
end
end
end
-- custom add
function load_data(filename)
local f = io.open(filename)
if not f then
return {}
end
local s = f:read('*all')
f:close()
local data = JSON.decode(s)
return data
end
function save_data(filename, data)
local s = JSON.encode(data)
local f = io.open(filename, 'w')
f:write(s)
f:close()
end
-- Call and postpone execution for cron plugins
function cron_plugins()
for name, plugin in pairs(plugins) do
-- Only plugins with cron function
if plugin.cron ~= nil then
plugin.cron()
end
end
-- Called again in 2 mins
postpone (cron_plugins, false, 120)
end
-- Start and load values
our_id = 0
now = os.time()
math.randomseed(now)
started = false
| gpl-2.0 |
GeekWithALife/love-bone | conf.lua | 1 | 3338 | function love.conf(t)
t.identity = nil -- The name of the save directory (string)
t.version = "0.10.2" -- The LÖVE version this game was made for (string)
t.console = true -- Attach a console (boolean, Windows only)
t.accelerometerjoystick = true -- Enable the accelerometer on iOS and Android by exposing it as a Joystick (boolean)
t.gammacorrect = false -- Enable gamma-correct rendering, when supported by the system (boolean)
t.window.title = "Boner Test" -- The window title (string)
t.window.icon = nil -- Filepath to an image to use as the window's icon (string)
t.window.width = 1024 -- The window width (number)
t.window.height = 840 -- The window height (number)
t.window.borderless = false -- Remove all border visuals from the window (boolean)
t.window.resizable = true -- Let the window be user-resizable (boolean)
t.window.minwidth = 1 -- Minimum window width if the window is resizable (number)
t.window.minheight = 1 -- Minimum window height if the window is resizable (number)
t.window.fullscreen = false -- Enable fullscreen (boolean)
t.window.fullscreentype = "desktop" -- Choose between "desktop" fullscreen or "exclusive" fullscreen mode (string)
t.window.vsync = true -- Enable vertical sync (boolean)
t.window.msaa = 0 -- The number of samples to use with multi-sampled antialiasing (number)
t.window.display = 1 -- Index of the monitor to show the window in (number)
t.window.highdpi = false -- Enable high-dpi mode for the window on a Retina display (boolean)
t.window.x = nil -- The x-coordinate of the window's position in the specified display (number)
t.window.y = nil -- The y-coordinate of the window's position in the specified display (number)
t.modules.audio = true -- Enable the audio module (boolean)
t.modules.event = true -- Enable the event module (boolean)
t.modules.graphics = true -- Enable the graphics module (boolean)
t.modules.image = true -- Enable the image module (boolean)
t.modules.joystick = true -- Enable the joystick module (boolean)
t.modules.keyboard = true -- Enable the keyboard module (boolean)
t.modules.math = true -- Enable the math module (boolean)
t.modules.mouse = true -- Enable the mouse module (boolean)
t.modules.physics = true -- Enable the physics module (boolean)
t.modules.sound = true -- Enable the sound module (boolean)
t.modules.system = true -- Enable the system module (boolean)
t.modules.timer = true -- Enable the timer module (boolean), Disabling it will result 0 delta time in love.update
t.modules.touch = true -- Enable the touch module (boolean)
t.modules.video = true -- Enable the video module (boolean)
t.modules.window = true -- Enable the window module (boolean)
t.modules.thread = true -- Enable the thread module (boolean)
end
| mit |
TheAnswer/FirstTest | bin/scripts/mission/basemission.lua | 1 | 4598 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
Mission = Object:new {
missionKey = "", -- UNIQUE internal key used to identify the mission. No spaces, keep small
-- Title/Name:
stfTitleKey = "", -- key used by client to look up title in mission stf. Can be blank if custom is set
titleStf = "", -- TRE path to title stf. Can be blank if stfTitleKey isnt used
customTitle = "", -- if stfTitleKey is not used, set a custom title here
-- General: (type, terminal etc)
terminalMask = TMASK_GENERAL, -- Terminal Bitmask
typeStr = "", -- SWG mission type string
typeCrc = 0, -- deliver(E5C27EC6,3854728902) or destroy(74EF9BE3,1961860067) SWGCRC of mission type
creatorName = "", -- Name that appears in game as the assigner of the mission (usually an npc name)
difficultyLevel = 1, -- Mission difficulty level
-- Location: Start (npc assigner)
startX = 0.0, -- X coordinate for start (aka "target/assigner npc") of mission
startY = 0.0, -- Y coordinate for start (aka "target/assigner npc") of mission
startPlanetStr = "", -- start planet name, must be lowercase
-- Location: Destination (target)
destinationX = 0.0, -- X coordinate for destination of mission
destinationY = 0.0, -- Y coordinate for destination of mission
destinationPlanetStr = "", -- Destination planet name, must be lowercase
-- Rewards
rewardCredits = 0, -- Amount of credits awarded to bank
rewardXP = "", -- (xpType:value;xpType:value etc) Xp to reward upon mission completion
rewardBadgeIds = "", -- (badge ids, delimited by commas) Ids of the badge to award
rewardFactions = "", -- (factionName:points;factionName:points etc) Faction & points to award to that faction. If points are negative, they will be subtracted from the faction
rewardObjects = "", -- Serialized string of objects (items) to award the player. See documentation for details
-- Description
stfDescriptionKey = "", -- key used by client to look up description in mission stf. Can be blank if custom is set
descriptionStf = "", -- TRE path to description stf. Can be blank if stfDescriptionKey isnt used
customDescription = "", -- if stfDescriptionKey is not used, set a custom description here
-- Objective & Target
targetName = "", --Name of target to display
depictedObjectCrc = 0, -- Object CRC of the object pictured in mission window
objectiveDefaults = "", --Objective String. See documentation for formatting
instantComplete = 1, --do Mission complete as soon as objectives are complete (no return to npc for evaluation)
}
| lgpl-3.0 |
TheAnswer/FirstTest | bin/scripts/items/objects/clothing/ithorian/ithCargoPants.lua | 1 | 2299 | --Copyright (C) 2007 <SWGEmu>
--This File is part of Core3.
--This program is free software; you can redistribute
--it and/or modify it under the terms of the GNU Lesser
--General Public License as published by the Free Software
--Foundation; either version 2 of the License,
--or (at your option) any later version.
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--See the GNU Lesser General Public License for
--more details.
--You should have received a copy of the GNU Lesser General
--Public License along with this program; if not, write to
--the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--Linking Engine3 statically or dynamically with other modules
--is making a combined work based on Engine3.
--Thus, the terms and conditions of the GNU Lesser General Public License
--cover the whole combination.
--In addition, as a special exception, the copyright holders of Engine3
--give you permission to combine Engine3 program with free software
--programs or libraries that are released under the GNU LGPL and with
--code included in the standard release of Core3 under the GNU LGPL
--license (or modified versions of such code, with unchanged license).
--You may copy and distribute such a system following the terms of the
--GNU LGPL for Engine3 and the licenses of the other code concerned,
--provided that you include the source code of that other code when
--and as the GNU LGPL requires distribution of source code.
--Note that people who make modified versions of Engine3 are not obligated
--to grant this special exception for their modified versions;
--it is their choice whether to do so. The GNU Lesser General Public License
--gives permission to release a modified version without this exception;
--this exception also makes it possible to release a modified version
--which carries forward this exception.
ithCargoPants = Clothing:new {
objectName = "Ithorian Cargo Pants",
templateName = "ith_pants_s12",
objectCRC = "2204230753",
objectType = ITHOGARB,
equipped = "1",
itemMask = ITHORIANS
}
| lgpl-3.0 |
weiDDD/WSSParticleSystem | cocos2d/cocos/scripting/lua-bindings/auto/api/GLViewImpl.lua | 1 | 1185 |
--------------------------------
-- @module GLViewImpl
-- @extend GLView
-- @parent_module cc
--------------------------------
--
-- @function [parent=#GLViewImpl] createWithRect
-- @param self
-- @param #string viewName
-- @param #rect_table rect
-- @param #float frameZoomFactor
-- @return GLViewImpl#GLViewImpl ret (return value: cc.GLViewImpl)
--------------------------------
--
-- @function [parent=#GLViewImpl] create
-- @param self
-- @param #string viewname
-- @return GLViewImpl#GLViewImpl ret (return value: cc.GLViewImpl)
--------------------------------
--
-- @function [parent=#GLViewImpl] createWithFullScreen
-- @param self
-- @param #string viewName
-- @return GLViewImpl#GLViewImpl ret (return value: cc.GLViewImpl)
--------------------------------
--
-- @function [parent=#GLViewImpl] setIMEKeyboardState
-- @param self
-- @param #bool bOpen
-- @return GLViewImpl#GLViewImpl self (return value: cc.GLViewImpl)
--------------------------------
--
-- @function [parent=#GLViewImpl] isOpenGLReady
-- @param self
-- @return bool#bool ret (return value: bool)
return nil
| apache-2.0 |
FTBpro/count-von-count | lib/nginx/utils.lua | 1 | 1087 | local redis = require "resty.redis"
local utils = {}
function utils:normalizeKeys(tbl)
local normalized = {}
for k, v in pairs(tbl) do
local key = k:gsub("amp;", "")
local value = v
if key:match("[[]]") then
key = key:gsub("[[]]", "")
if type(value) ~= "table" then
value = { v }
end
end
normalized[key] = value
end
return normalized
end
function utils:initRedis()
local red = redis:new()
red:set_timeout(3000) -- 3 sec
local ok, err = red:connect(SYSTEM_CONFIG["redis_host"], SYSTEM_CONFIG["redis_port"])
if not ok then utils:logErrorAndExit("Error connecting to redis: ".. err) end
return red
end
function utils:loadSystemConfig()
config_path = "/usr/local/openresty/nginx/count-von-count/config/system.config"
SYSTEM_CONFIG = {}
for line in io.lines(config_path) do
for i,j in line:gmatch("(%S+):%s*(%S+)") do
SYSTEM_CONFIG[i] = j
end
end
end
function utils:logErrorAndExit(err)
ngx.log(ngx.ERR, err)
utils:emptyGif()
end
function utils:emptyGif()
ngx.exec('/_.gif')
end
return utils
| mit |
weiDDD/WSSParticleSystem | cocos2d/cocos/scripting/lua-bindings/auto/api/PhysicsJointDistance.lua | 1 | 1409 |
--------------------------------
-- @module PhysicsJointDistance
-- @extend PhysicsJoint
-- @parent_module cc
--------------------------------
--
-- @function [parent=#PhysicsJointDistance] createConstraints
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- Set the distance of the anchor points.
-- @function [parent=#PhysicsJointDistance] setDistance
-- @param self
-- @param #float distance
-- @return PhysicsJointDistance#PhysicsJointDistance self (return value: cc.PhysicsJointDistance)
--------------------------------
-- Get the distance of the anchor points.
-- @function [parent=#PhysicsJointDistance] getDistance
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- Create a fixed distance joint.<br>
-- param a A is the body to connect.<br>
-- param b B is the body to connect.<br>
-- param anchr1 Anchr1 is the anchor point on body a.<br>
-- param anchr2 Anchr2 is the anchor point on body b.<br>
-- return A object pointer.
-- @function [parent=#PhysicsJointDistance] construct
-- @param self
-- @param #cc.PhysicsBody a
-- @param #cc.PhysicsBody b
-- @param #vec2_table anchr1
-- @param #vec2_table anchr2
-- @return PhysicsJointDistance#PhysicsJointDistance ret (return value: cc.PhysicsJointDistance)
return nil
| apache-2.0 |
gabrielPeart/keys | VSCOKeys.lrdevplugin/halfway_server/Http.lua | 11 | 2879 | package.path = "../?.lua;" .. package.path
local JSON = require "json"
local Http = {}
function Http.parseHttpHeaders(lines)
local data = {}
local stringLoc = 1
local reqLine = lines[1]
data.method = reqLine:sub(stringLoc,reqLine:find(" ", stringLoc) - 1)
stringLoc = stringLoc + #data.method + 1
data.path = reqLine:sub(stringLoc,reqLine:find(" ", stringLoc) - 1)
stringLoc = stringLoc + #data.path + 1
data.version = reqLine:sub(stringLoc)
for i,v in ipairs(lines) do
if (v:find("UUID")) then
data.uuid = v:sub(#"UUID: ")
end
if (v:find("Content-Type: ",1,true)) then
data.contentType = v:sub(#"Content-Type: "+1)
end
if (v:find("Content-Length: ",1,true)) then
data.contentLength = tonumber(v:sub(#"Content-Length: "+1))
end
end
--
-- data.content = {}
-- for i = dataStartLine, #lines do
-- table.insert(data.content, lines[i])
-- end
--
-- data.content = table.concat(data.content, "\n")
--
-- if (data.contentType == "application/json") then
-- data.json = JSON:decode(data.content)
-- end
return data
end
function Http.parseHttpContent(data)
if (data.contentType == "application/json") then
data.json = JSON:decode(data.content)
end
return data
end
local function prepareContent(response, data)
if (data.json ~= nil) then
data.contentType = "application/json"
data.content = JSON:encode(data.json)
data.contentLength = #data.content
else
return response .. "\n"
end
if (data.contentLength ~= nil and
data.contentLength > 0 and
data.contentType ~= nil and
data.content ~= nil) then
response = response .. "Content-Type: " .. data.contentType .. "\n"
response = response .. "Content-Length: " .. data.contentLength .. "\n"
response = response .. "\n" .. data.content .. "\n"
end
return response
end
function Http.createResponse(data)
if (data.code == nil or data.reason == nil) then
data.code = 200
data.reason = "OK"
end
-- This os.date format string crashes in windows -- doesn't seem to affect http response / request fortitude.
-- data.date = os.date("%A, %d-%b-%y %T GMT", os.time())
local response = data.version .. " " .. data.code .. " " .. data.reason .. "\n"
-- response = response .. "Date: " ..data.date .. "\n"
response = prepareContent(response, data)
return response
end
function Http.continue()
data = {}
data.code = 100
data.reason = "Continue"
data.version = "Http/1.1"
return Http.createResponse(data)
end
function Http.badRequest()
data = {}
data.code = 200
data.reason = "OK"
data.version = "Http/1.1"
return Http.createResponse(data)
end
function Http.createRequest(data)
local response = data.method .. " " .. data.path .. " " .. data.version .. "\n"
response = prepareContent(response, data)
return response
end
return Http | gpl-2.0 |
Andrettin/Wyrmsun | scripts/item_sets.lua | 1 | 2188 | -- _________ __ __
-- / _____// |_____________ _/ |______ ____ __ __ ______
-- \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
-- / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \
-- /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
-- \/ \/ \//_____/ \/
-- ______________________ ______________________
-- T H E W A R B E G I N S
-- Stratagus - A free fantasy real time strategy game engine
--
-- (c) Copyright 2015-2022 by Andrettin
--
-- 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
DefineUpgrade("upgrade-item-set-the-dragons-stars", { -- Source: Richard Hinckley Allen, "Star-Names and their Meanings", 1874, pp. 202-206.
Name = "The Dragon's Stars",
MagicLevel = 1, -- should approximately reflect the level of the bonus divided by the number of items in the set
Description = "The Dragon's Stars are a group of artifacts believed to derive power from the constellation of Draco - the Dragon."
})
DefineUpgrade("upgrade-item-set-the-sun-horses", {
Name = "The Sun Horses' Stars",
MagicLevel = 2 -- should approximately reflect the level of the bonus divided by the number of items in the set
})
DefineModifier("upgrade-item-set-the-dragons-stars",
{"FireDamage", 2}
)
DefineModifier("upgrade-item-set-the-sun-horses",
{"SightRange", 2}
)
| gpl-2.0 |
mkwia/jc2atc | scripts/airtraffic/client/cManager.lua | 1 | 1846 | class 'AirTrafficManager'
function AirTrafficManager:__init()
self.npcs = {}
self.debug = false
Events:Subscribe("Render", self, self.PostTick)
Events:Subscribe("EntitySpawn", self, self.EntitySpawn)
Events:Subscribe("EntityDespawn", self, self.EntityDespawn)
Events:Subscribe("VehicleCollide", self, self.VehicleCollide)
Events:Subscribe("NetworkObjectValueChange", self, self.ValueChange)
end
function AirTrafficManager:PostTick()
for _, npc in pairs(self.npcs) do
npc:Tick()
if self.debug then
math.randomseed(npc:GetModelId())
local color = Color(math.random(255), math.random(255), math.random(255))
Render:DrawCircle(Render:WorldToScreen(npc:GetTargetPosition()), 10, color)
Render:DrawCircle(Render:WorldToScreen(npc:GetPosition()), 10, color)
end
end
end
function AirTrafficManager:VehicleCollide(args)
if args.entity.__type ~= "Vehicle" then return end
local npc = self.npcs[args.entity:GetId()]
if not npc then return end
npc:CollisionResponse()
end
function AirTrafficManager:EntitySpawn(args)
if args.entity.__type ~= "Vehicle" then return end
if not args.entity:GetValue("P") then return end
AirTrafficNPC(args)
end
function AirTrafficManager:EntityDespawn(args)
if args.entity.__type ~= "Vehicle" then return end
local npc = self.npcs[args.entity:GetId()]
if not npc then return end
npc:Remove()
end
function AirTrafficManager:ValueChange(args)
if args.object.__type ~= "Vehicle" then return end
local npc = self.npcs[args.object:GetId()]
if not npc then return end
if args.key == "P" then
if args.value then
npc.timers.tick:Restart()
npc.network_position = args.value
else
npc:Remove()
end
end
end
function AirTrafficManager:ModuleUnload()
for _, npc in pairs(self.npcs) do
npc:Remove()
end
end
AirTrafficManager = AirTrafficManager()
| mit |
praveenjha527/Algorithm-Implementations | Symmetric_Difference/Lua/Yonaba/symdiff_test.lua | 26 | 1051 | -- Tests for symmdiff.lua
local symdiff = require 'symdiff'
local total, pass = 0, 0
local function dec(str, len)
return #str < len
and str .. (('.'):rep(len-#str))
or str:sub(1,len)
end
local function run(message, f)
total = total + 1
local ok, err = pcall(f)
if ok then pass = pass + 1 end
local status = ok and 'PASSED' or 'FAILED'
print(('%02d. %68s: %s'):format(total, dec(message,68), status))
end
local function same(t1, t2)
if #t1~=#t2 then return false end
for k,v in pairs(t1) do
if t2[k] ~= v then return false end
end
return true
end
run('Symmetric difference', function()
local s1, s2 = {1, 2, 3, 4}, {3, 4, 5, 6}
assert(same(symdiff(s1,s2),{1,2,5,6}))
local s1, s2 = {}, {}
assert(same(symdiff(s1,s2),{}))
local s1, s2 = {1}, {2}
assert(same(symdiff(s1,s2),{1,2}))
local s1, s2 = {3}, {3}
assert(same(symdiff(s1,s2),{}))
end)
print(('-'):rep(80))
print(('Total : %02d: Pass: %02d - Failed : %02d - Success: %.2f %%')
:format(total, pass, total-pass, (pass*100/total)))
| mit |
peterjc/samtools | misc/r2plot.lua | 42 | 2685 | #!/usr/bin/env luajit
function string:split(sep, n)
local a, start = {}, 1;
sep = sep or "%s+";
repeat
local b, e = self:find(sep, start);
if b == nil then
table.insert(a, self:sub(start));
break
end
a[#a+1] = self:sub(start, b - 1);
start = e + 1;
if n and #a == n then
table.insert(a, self:sub(start));
break
end
until start > #self;
return a;
end
function io.xopen(fn, mode)
mode = mode or 'r';
if fn == nil then return io.stdin;
elseif fn == '-' then return (mode == 'r' and io.stdin) or io.stdout;
elseif fn:sub(-3) == '.gz' then return (mode == 'r' and io.popen('gzip -dc ' .. fn, 'r')) or io.popen('gzip > ' .. fn, 'w');
elseif fn:sub(-4) == '.bz2' then return (mode == 'r' and io.popen('bzip2 -dc ' .. fn, 'r')) or io.popen('bgzip2 > ' .. fn, 'w');
else return io.open(fn, mode) end
end
local eps = {};
function eps.func(fp)
fp = fp or io.stdout
fp:write("/C { dup 255 and 255 div exch dup -8 bitshift 255 and 255 div 3 1 roll -16 bitshift 255 and 255 div 3 1 roll setrgbcolor } bind def\n")
fp:write("/L { 4 2 roll moveto lineto } bind def\n")
fp:write("/LX { dup 4 -1 roll exch moveto lineto } bind def\n")
fp:write("/LY { dup 4 -1 roll moveto exch lineto } bind def\n")
fp:write("/LS { 3 1 roll moveto show } bind def\n")
fp:write("/RS { dup stringwidth pop 4 -1 roll exch sub 3 -1 roll moveto show } bind def\n")
fp:write("/B { 4 copy 3 1 roll exch 6 2 roll 8 -2 roll moveto lineto lineto lineto closepath } bind def\n")
end
function eps.font(ft, size, fp)
fp = fp or io.stdout
fp:write(string.format('/FS %d def\n', size));
fp:write('/FS4 FS 4 div def\n');
fp:write('/' .. ft .. ' findfont FS scalefont setfont\n');
end
local scale = 8;
if #arg == 0 then
print("Usage: r2plot.lua <in.txt>");
os.exit(1)
end
local fp = io.xopen(arg[1]);
local n = tonumber(fp:read());
print('%!PS-Adobe-3.0 EPSF-3.0');
print('%%' .. string.format('BoundingBox: -%d -%d %.3f %.3f\n', 10*scale, scale, (n+1)*scale, (n+1)*scale));
print(string.format('%.3f setlinewidth', scale));
print(string.format('/plot { setgray moveto 0 %d rlineto } def', scale));
print(string.format('/plothalf { setgray moveto 0 %.2f rlineto } def', scale/2));
eps.func();
eps.font('Helvetica', scale-1);
local i = 1;
for l in fp:lines() do
local t = l:split('\t');
print(string.format("%d %d FS4 add (%s) RS", (i-1)*scale-2, (i-1)*scale, t[1]));
for j = 2, #t do
if tonumber(t[j]) > 0.01 then
print(string.format('%.2f %.2f %.2f plot stroke', (i-1+.5)*scale, (j-2)*scale, 1.-t[j]));
end
end
i = i + 1;
end
for j = 1, 21 do
print(string.format('%.2f %.2f %.2f plothalf stroke', -8*scale, (j-1) * scale/2, 1.-(j-1)/20));
end
print('showpage');
| mit |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.