content
stringlengths 5
1.05M
|
|---|
local queries = require("nvim-treesitter.query")
local M = {}
function M.init()
require("nvim-treesitter").define_modules({
rainbow = {
module_path = "rainbow.internal",
is_supported = function(lang)
return queries.get_query(lang, "parens") ~= nil
end,
extended_mode = true,
},
})
end
return M
|
local M = {}
local platform = system.getInfo("platform")
local hasFacebook
local hasTwitter
local hasWeibo
local canShowShareDialog
, showShareDialog
, showPopup
, getSocialButtons
function M.share(params)
if canShowShareDialog() then
showShareDialog(params)
end
end
function canShowShareDialog()
local isAvailable = false
if platform == "android" then
isAvailable = native.canShowPopup("social", "share")
elseif platform == "ios" then
hasFacebook = native.canShowPopup("social", "facebook")
hasTwitter = native.canShowPopup("social", "twitter")
hasWeibo = native.canShowPopup("social", "sinaWeibo")
if hasFacebook or hasTwitter or hasWeibo then
isAvailable = true
end
end
return isAvailable
end
function showShareDialog(params)
if platform == "android" then
showPopup("share", params)
elseif platform == "ios" then
local socialButtons = getSocialButtons(hasFacebook, hasTwitter, hasWeibo)
native.showAlert("Поделиться картинкой", "Выберите приложение, в котором хотите поделитья картинкой.", socialButtons, function(event)
if event.action == "clicked" then
local index = event.index
if index < #socialButtons then
local serviceName = socialButtons[index]
showPopup(serviceName, params)
end
end
end)
end
end
function showPopup(serviceName, params)
local params = params or {}
native.showPopup("social", {
service = serviceName,
message = params.message,
image = params.image,
url = params.url,
listener = params.listener,
})
end
function getSocialButtons(hasFacebook, hasTwitter, hasWeibo)
local socialButtons = {}
if hasFacebook then
table.insert(socialButtons, "facebook")
end
if hasTwitter then
table.insert(socialButtons, "twitter")
end
if hasWeibo then
table.insert(socialButtons, "sinaWeibo")
end
table.insert(socialButtons, "cancel")
return socialButtons
end
return M
|
-- Copyright 2006-2017 Mitchell mitchell.att.foicica.com. See LICENSE.
-- JavaScript LPeg lexer.
local l = require('lexer')
local token, word_match = l.token, l.word_match
local P, R, S = lpeg.P, lpeg.R, lpeg.S
local M = {_NAME = 'javascript'}
-- Whitespace.
local ws = token(l.WHITESPACE, l.space^1)
-- Comments.
local line_comment = '//' * l.nonnewline_esc^0
local block_comment = '/*' * (l.any - '*/')^0 * P('*/')^-1
local comment = token(l.COMMENT, line_comment + block_comment)
-- Strings.
local sq_str = l.delimited_range("'")
local dq_str = l.delimited_range('"')
local template_str = l.delimited_range('`')
local regex_str = #P('/') * l.last_char_includes('+-*%^!=&|?:;,([{<>') *
l.delimited_range('/', true) * S('igm')^0
local string = token(l.STRING, sq_str + dq_str + template_str) +
token(l.REGEX, regex_str)
-- Numbers.
local number = token(l.NUMBER, l.float + l.integer)
-- Keywords.
local keyword = token(l.KEYWORD, word_match{
'abstract', 'async', 'await', 'boolean', 'break', 'byte', 'case', 'catch', 'char', 'class',
'const', 'continue', 'debugger', 'default', 'delete', 'do', 'double', 'else',
'enum', 'export', 'extends', 'false', 'final', 'finally', 'float', 'for',
'function', 'get', 'goto', 'if', 'implements', 'import', 'in', 'instanceof',
'int', 'interface', 'let', 'long', 'native', 'new', 'null', 'of', 'package',
'private', 'protected', 'public', 'return', 'set', 'short', 'static', 'super',
'switch', 'synchronized', 'this', 'throw', 'throws', 'transient', 'true',
'try', 'typeof', 'var', 'void', 'volatile', 'while', 'with', 'yield'
})
-- Identifiers.
local identifier = token(l.IDENTIFIER, l.word)
-- Operators.
local operator = token(l.OPERATOR, P('===') + P('!==') + P('!=') + P('==') + P('=>') + S('+-/*%^!&|?:,.<>'))
local brackets = token('brackets', S('()[]{}'))
local unimportant = token('unimportant', S(';'))
local assignment = token('assignment', S('='))
M._rules = {
{'whitespace', ws},
{'comment', comment},
{'operator', operator},
{'keyword', keyword},
{'identifier', identifier},
{'number', number},
{'string', string},
{'assignment', assignment},
{'brackets', brackets},
}
M._foldsymbols = {
_patterns = {'[{}]', '/%*', '%*/', '//'},
[l.OPERATOR] = {['{'] = 1, ['}'] = -1},
[l.COMMENT] = {['/*'] = 1, ['*/'] = -1, ['//'] = l.fold_line_comments('//')}
}
M._tokenstyles = {
unimportant = l.STYLE_UNIMPORTANT,
assignment = l.STYLE_ASSIGNMENT,
brackets = l.STYLE_BRACKETS
}
return M
|
--[[
TheNexusAvenger
Implementation of a command.
--]]
local BaseCommand = require(script.Parent.Parent:WaitForChild("BaseCommand"))
local Command = BaseCommand:Extend()
--[[
Creates the command.
--]]
function Command:__new()
self:InitializeSuper("unff","UsefulFunCommands","Removes all force fields from the given players.")
self.Arguments = {
{
Type = "nexusAdminPlayers",
Name = "Players",
Description = "Players to remove force fields from.",
},
}
end
--[[
Runs the command.
--]]
function Command:Run(CommandContext,Players)
self.super:Run(CommandContext)
--Give the forcefields.
for _,Player in pairs(Players) do
local Character = Player.Character
if Character then
for _,Ins in pairs(Character:GetChildren()) do
if Ins:IsA("ForceField") then
Ins:Destroy()
end
end
end
end
end
return Command
|
-- Copyright 2017-2022 Jason Tackaberry
--
-- 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 rtk = require('rtk.core')
--- Displays arbitrary text which can be optionally wrapped (either to fit width constraints
-- imposed by the parent container or within the widget's own @{w|defined width}),
-- otherwise it's clipped (unless disabled by setting `overflow` to true).
--
-- @code
-- local hbox = rtk.HBox{spacing=5}
-- hbox:add(rtk.Text{'Name:'}, {valign='center'})
-- hbox:add(rtk.Entry())
--
-- Here's an example with a large block of center-aligned text that will wrap and scroll
-- within a viewport:
--
-- @code
-- local data = 'A big long block of text goes here ... pretend this is it.'
-- -- Comic Sans used ironically
-- local text = rtk.Text{data, halign='center', wrap=true, margin=10, font='Comic Sans MS'}
-- -- Constrain height to 100 pixels within which the wrapped text will scroll
-- box:add(rtk.Viewport{text, h=100})
--
-- @class rtk.Text
-- @inherits rtk.Widget
rtk.Text = rtk.class('rtk.Text', rtk.Widget)
--- Word Wrap Constants.
--
-- Used with the `wrap` attribute, where lowercase versions of these constants without the `WRAP_` prefix
-- can be used for convenience.
--
-- @section wrapconst
-- @compact
--- Don't wrap the text and instead allow the widget to overflow its bounding box.
-- @meta 'none'
rtk.Text.static.WRAP_NONE = false
--- Wrap the text at normal word-break boundaries (at whitespace or punctuation), and allow
-- long unbreakable words to overflow the bounding box.
-- @meta 'normal'
rtk.Text.static.WRAP_NORMAL = true
--- Wrap text as with `WRAP_NORMAL` but allow breaking in the middle of long words in order to
-- avoid overflowing the bounding box.
-- @meta 'break-word'
rtk.Text.static.WRAP_BREAK_WORD = 2
--- Class API.
--- @section api
rtk.Text.register{
[1] = rtk.Attribute{alias='text'},
--- The string of text to be displayed.
--
-- This attribute may be passed as the first positional argument during initialization. (In
-- other words, `rtk.Text{'Foo'}` is equivalent to `rtk.Text{text='Foo'}`.)
--
-- Strings containing explicit newlines are rendered across multiple lines as you'd expect.
-- @meta read/write
-- @type string
text = rtk.Attribute{
default='Text',
reflow=rtk.Widget.REFLOW_FULL,
},
--- The color of the text, which uses the @{rtk.themes.text|theme default} if nil
-- (default nil).
-- @meta read/write
-- @type colortype
color = rtk.Attribute{
default=function(self, attr)
return rtk.theme.text
end,
calculate=rtk.Reference('bg'),
},
--- Controls the wrapping behavior of text lines that exceed the bounding box imposed
-- by our container (default `WRAP_NONE`).
-- @meta read/write
-- @type wrapconst
wrap = rtk.Attribute{
default=rtk.Text.WRAP_NONE,
reflow=rtk.Widget.REFLOW_FULL,
calculate={
['none']=rtk.Text.WRAP_NONE,
['normal']=rtk.Text.WRAP_NORMAL,
['break-word']=rtk.Text.WRAP_BREAK_WORD
},
},
--- How individual lines of text should be aligned within the widget's inner content area
-- (defaults to match `halign`). Any of the horizontal alignment constants are supported.
--
-- This is subtly different from `halign`. The internal laid out text has its own natural
-- size based on the line contents, and `halign` controls the positioning of this inner
-- content box within the overall `rtk.Text` widget's box. In contrast, `textalign` controls
-- the alignment of each individual line within the inner content box.
--
-- When `textalign` is not specified (i.e. is nil), then it uses the same value as for
-- `halign` as a sane default behavior.
--
-- To demonstrate, consider:
-- @code
-- local text = 'This is\na few lines of\nshort text'
-- -- Lines of text are right-aligned relative to itself, but centered within the
-- -- overall rtk.Text box.
-- vbox:add(rtk.Text{text, w=300, border='red', wrap=true, halign='center', textalign='right'})
-- -- Lines of text are center-aligned relative to itself, but right-aligned within
-- -- the overall rtk.Text box.
-- vbox:add(rtk.Text{text, w=300, border='red', wrap=true, halign='right', textalign='center'})
-- -- When textalign isn't specified, it uses the same value as halign, which
-- -- simplifies the most common use case.
-- vbox:add(rtk.Text{text, w=300, border='red', wrap=true, halign='center'})
--
-- Which results in the following:
--
-- 
--
-- @meta read/write
-- @type alignmentconst
textalign = rtk.Attribute{
default=nil,
calculate=rtk.Reference('halign'),
},
--- Whether the text is allowed to overflow its bounding box, otherwise it will be clipped (default false,
-- which will clip overflowed text).
-- @meta read/write
-- @type boolean
overflow = false,
--- The amount of space between separate lines, where 0 does not add any additional space (i.e. it uses
-- the font's natural line height) (default 0).
-- @type number
-- @meta read/write
spacing = rtk.Attribute{
default=0,
reflow=rtk.Widget.REFLOW_FULL,
},
--- The name of the font face (e.g. `'Calibri`'), which uses the @{rtk.themes.text_font|global text
-- default} if nil (default nil).
-- @type string|nil
-- @meta read/write
font = rtk.Attribute{
default=function(self, attr)
return self._theme_font[1]
end,
reflow=rtk.Widget.REFLOW_FULL,
},
--- The pixel size of the text font (e.g. 18), which uses the @{rtk.themes.text_font|global text
-- default} if nil (default nil).
-- @meta read/write
-- @type number|nil
fontsize = rtk.Attribute{
default=function(self, attr)
return self._theme_font[2]
end,
reflow=rtk.Widget.REFLOW_FULL,
},
--- Scales `fontsize` by the given multiplier (default 1.0). This is a convenient way to adjust
-- the relative font size without specifying the exact size.
-- @type number
-- @meta read/write
fontscale = rtk.Attribute{
default=1.0,
reflow=rtk.Widget.REFLOW_FULL,
},
--- A bitmap of @{rtk.font|font flags} to alter the text appearance (default nil). Nil
-- (or 0) does not style the font.
-- @type number|nil
-- @meta read/write
fontflags = rtk.Attribute{
default=function(self, attr)
return self._theme_font[3]
end
},
}
--- Create a new text widget with the given attributes.
--
-- @display rtk.Text
function rtk.Text:initialize(attrs, ...)
self._theme_font = self._theme_font or rtk.theme.text_font or rtk.theme.default_font
rtk.Widget.initialize(self, attrs, rtk.Text.attributes.defaults, ...)
self._font = rtk.Font()
end
function rtk.Text:__tostring_info()
return self.text
end
function rtk.Text:_handle_attr(attr, value, oldval, trigger, reflow)
local ok = rtk.Widget._handle_attr(self, attr, value, oldval, trigger, reflow)
if ok == false then
return ok
end
if self._segments and (attr == 'text' or attr == 'wrap' or attr == 'textalign' or attr == 'spacing') then
-- Force regeneration of segments on next reflow
self._segments.invalid = true
end
return ok
end
function rtk.Text:_reflow(boxx, boxy, boxw, boxh, fillw, fillh, clampw, clamph, uiscale, viewport, window)
local calc = self.calc
calc.x, calc.y = self:_get_box_pos(boxx, boxy)
self._font:set(calc.font, calc.fontsize, calc.fontscale, calc.fontflags)
local w, h, tp, rp, bp, lp = self:_get_content_size(boxw, boxh, fillw, fillh, clampw, clamph)
local hpadding = lp + rp
local vpadding = tp + bp
local lmaxw = (clampw or fillw) and (boxw - hpadding) or w or math.inf
local lmaxh = (clamph or fillh) and (boxh - vpadding) or h or math.inf
-- Avoid re-laying out the string if nothing relevant has changed.
local seg = self._segments
if not seg or seg.boxw ~= lmaxw or seg.invalid or rtk.scale.value ~= seg.scale then
self._segments, self.lw, self.lh = self._font:layout(
calc.text,
lmaxw, lmaxh,
calc.wrap ~= rtk.Text.WRAP_NONE,
self.textalign and calc.textalign or calc.halign,
true,
calc.spacing,
calc.wrap == rtk.Text.WRAP_BREAK_WORD
)
end
-- Text objects support clipping, so we respect our bounding box when clamping is requested.
calc.w = (w and w + hpadding) or (fillw and boxw) or math.min(clampw and boxw or math.inf, self.lw + hpadding)
calc.h = (h and h + vpadding) or (fillh and boxh) or math.min(clamph and boxh or math.inf, self.lh + vpadding)
-- Finally, apply min/max and round to ensure alignment to pixel boundaries.
calc.w = math.round(rtk.clamp(calc.w, calc.minw, calc.maxw))
calc.h = math.round(rtk.clamp(calc.h, calc.minh, calc.maxh))
end
-- Precalculate positions for _draw()
function rtk.Text:_realize_geometry()
local calc = self.calc
local tp, rp, bp, lp = self:_get_padding_and_border()
local lx, ly
if calc.halign == rtk.Widget.LEFT then
lx = lp
elseif calc.halign == rtk.Widget.CENTER then
lx = lp + math.max(0, calc.w - self.lw - lp - rp) / 2
elseif calc.halign == rtk.Widget.RIGHT then
lx = math.max(0, calc.w - self.lw - rp)
end
if calc.valign == rtk.Widget.TOP then
ly = tp
elseif calc.valign == rtk.Widget.CENTER then
ly = tp + math.max(0, calc.h - self.lh - tp - bp) / 2
elseif calc.valign == rtk.Widget.BOTTOM then
ly = math.max(0, calc.h - self.lh - bp)
end
self._pre = {
tp=tp, rp=rp, bp=bp, lp=lp,
lx=lx, ly=ly,
}
end
function rtk.Text:_draw(offx, offy, alpha, event, clipw, cliph, cltargetx, cltargety, parentx, parenty)
rtk.Widget._draw(self, offx, offy, alpha, event, clipw, cliph, cltargetx, cltargety, parentx, parenty)
local calc = self.calc
local x, y = calc.x + offx, calc.y + offy
if y + calc.h < 0 or y > cliph or calc.ghost then
-- Widget not viewable on viewport
return
end
local pre = self._pre
self:_handle_drawpre(offx, offy, alpha, event)
self:_draw_bg(offx, offy, alpha, event)
self:setcolor(calc.color, alpha)
assert(self._segments)
self._font:draw(
self._segments,
x + pre.lx,
y + pre.ly,
not calc.overflow and math.min(clipw - x, calc.w) - pre.lx - pre.rp or nil,
not calc.overflow and math.min(cliph - y, calc.h) - pre.ly - pre.bp or nil
)
self:_draw_borders(offx, offy, alpha)
self:_handle_draw(offx, offy, alpha, event)
end
|
local component = require "component"
local serialization = require "serialization"
local shell = require "shell"
local eeprom = component.eeprom
local args, ops = shell.parse(...)
print(args)
if #args < 3 then
print("You need to specify all 3 coords (x,y,z order)")
os.exit()
end
local pos = serialization.serialize({args[1],args[2],args[3]})
print("Writing to EEPROM" .. tostring(pos))
eeprom.setData(pos)
local lbl = eeprom.getLabel();
eeprom.setLabel(lbl .. " " .. args[1] .. "/" .. args[2] .. "/" ..args[3])
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
--print(dump(eeprom.getData()))
|
return {
'halloween',
'carnival',
'ghosts',
'trick or treat',
'costume',
'candy',
'candycorn',
'snickers',
'reeses cups',
'candied apples',
'ghouls',
'goblin',
'frankenstein',
'graveyard',
'haunted house',
'monster',
'scary',
'spooky',
'dracula',
'mummy',
'vampire',
'bat',
'devils night',
'bloodcurdling',
'scream',
'horror',
'thankskilling',
'jason',
'freddy krueger',
'saw',
'creepy',
-- 'headless horseman', -- Too long
'ichabod crane',
'decapitated',
'raven',
'edgar allen poe',
'werewolf',
'werewolves',
'fright',
'fright night',
'cemetery',
'cobwebs',
'spider',
'tarantula',
'casket',
'cauldron',
'witch',
'broom',
'witchs brew',
'corpse',
'eerie',
'cackle',
'bloody',
'bones',
'skeleton',
'crypt',
'cryptkeeper',
'grim reaper',
'pumpkin',
'apple cider',
'pumpkin spice',
'pumpkin carving',
'jack o lantern',
'mausoleum',
'mummy',
'owl',
'black lodge',
'howling',
'occult',
'shadow',
'spectre',
'poltergeist',
'warlock',
'undead',
'zombie',
'wraith',
'zombie',
'casper',
'great pumpkin',
'hocus pocus',
'nightmare',
'scream',
'michael myers',
'jason voorhees',
-- 'friday the thirteenth', -- Too long
'october',
-- 'october thirty first', -- Too long
}
|
-- https://www.w3schools.com/colors/colors_names.asp
local _, Addon = ...
local DCL = Addon.DethsColorLib
if DCL.__loaded then return end
DCL.CSS = {
AliceBlue = "F0F8FF",
AntiqueWhite = "FAEBD7",
Aqua = "00FFFF",
Aquamarine = "7FFFD4",
Azure = "F0FFFF",
Beige = "F5F5DC",
Bisque = "FFE4C4",
Black = "000000",
BlanchedAlmond = "FFEBCD",
Blue = "0000FF",
BlueViolet = "8A2BE2",
Brown = "A52A2A",
BurlyWood = "DEB887",
CadetBlue = "5F9EA0",
Chartreuse = "7FFF00",
Chocolate = "D2691E",
Coral = "FF7F50",
CornflowerBlue = "6495ED",
Cornsilk = "FFF8DC",
Crimson = "DC143C",
Cyan = "00FFFF",
DarkBlue = "00008B",
DarkCyan = "008B8B",
DarkGoldenRod = "B8860B",
DarkGray = "A9A9A9",
DarkGrey = "A9A9A9",
DarkGreen = "006400",
DarkKhaki = "BDB76B",
DarkMagenta = "8B008B",
DarkOliveGreen = "556B2F",
DarkOrange = "FF8C00",
DarkOrchid = "9932CC",
DarkRed = "8B0000",
DarkSalmon = "E9967A",
DarkSeaGreen = "8FBC8F",
DarkSlateBlue = "483D8B",
DarkSlateGray = "2F4F4F",
DarkSlateGrey = "2F4F4F",
DarkTurquoise = "00CED1",
DarkViolet = "9400D3",
DeepPink = "FF1493",
DeepSkyBlue = "00BFFF",
DimGray = "696969",
DimGrey = "696969",
DodgerBlue = "1E90FF",
FireBrick = "B22222",
FloralWhite = "FFFAF0",
ForestGreen = "228B22",
Fuchsia = "FF00FF",
Gainsboro = "DCDCDC",
GhostWhite = "F8F8FF",
Gold = "FFD700",
GoldenRod = "DAA520",
Gray = "808080",
Grey = "808080",
Green = "008000",
GreenYellow = "ADFF2F",
HoneyDew = "F0FFF0",
HotPink = "FF69B4",
IndianRed = "CD5C5C",
Indigo = "4B0082",
Ivory = "FFFFF0",
Khaki = "F0E68C",
Lavender = "E6E6FA",
LavenderBlush = "FFF0F5",
LawnGreen = "7CFC00",
LemonChiffon = "FFFACD",
LightBlue = "ADD8E6",
LightCoral = "F08080",
LightCyan = "E0FFFF",
LightGoldenRodYellow = "FAFAD2",
LightGray = "D3D3D3",
LightGrey = "D3D3D3",
LightGreen = "90EE90",
LightPink = "FFB6C1",
LightSalmon = "FFA07A",
LightSeaGreen = "20B2AA",
LightSkyBlue = "87CEFA",
LightSlateGray = "778899",
LightSlateGrey = "778899",
LightSteelBlue = "B0C4DE",
LightYellow = "FFFFE0",
Lime = "00FF00",
LimeGreen = "32CD32",
Linen = "FAF0E6",
Magenta = "FF00FF",
Maroon = "800000",
MediumAquaMarine = "66CDAA",
MediumBlue = "0000CD",
MediumOrchid = "BA55D3",
MediumPurple = "9370DB",
MediumSeaGreen = "3CB371",
MediumSlateBlue = "7B68EE",
MediumSpringGreen = "00FA9A",
MediumTurquoise = "48D1CC",
MediumVioletRed = "C71585",
MidnightBlue = "191970",
MintCream = "F5FFFA",
MistyRose = "FFE4E1",
Moccasin = "FFE4B5",
NavajoWhite = "FFDEAD",
Navy = "000080",
OldLace = "FDF5E6",
Olive = "808000",
OliveDrab = "6B8E23",
Orange = "FFA500",
OrangeRed = "FF4500",
Orchid = "DA70D6",
PaleGoldenRod = "EEE8AA",
PaleGreen = "98FB98",
PaleTurquoise = "AFEEEE",
PaleVioletRed = "DB7093",
PapayaWhip = "FFEFD5",
PeachPuff = "FFDAB9",
Peru = "CD853F",
Pink = "FFC0CB",
Plum = "DDA0DD",
PowderBlue = "B0E0E6",
Purple = "800080",
RebeccaPurple = "663399",
Red = "FF0000",
RosyBrown = "BC8F8F",
RoyalBlue = "4169E1",
SaddleBrown = "8B4513",
Salmon = "FA8072",
SandyBrown = "F4A460",
SeaGreen = "2E8B57",
SeaShell = "FFF5EE",
Sienna = "A0522D",
Silver = "C0C0C0",
SkyBlue = "87CEEB",
SlateBlue = "6A5ACD",
SlateGray = "708090",
SlateGrey = "708090",
Snow = "FFFAFA",
SpringGreen = "00FF7F",
SteelBlue = "4682B4",
Tan = "D2B48C",
Teal = "008080",
Thistle = "D8BFD8",
Tomato = "FF6347",
Turquoise = "40E0D0",
Violet = "EE82EE",
Wheat = "F5DEB3",
White = "FFFFFF",
WhiteSmoke = "F5F5F5",
Yellow = "FFFF00",
YellowGreen = "9ACD32",
}
DCL:HexTableToRGBA(DCL.CSS)
|
--scifi_nodes by D00Med
scifi_nodes = {}
local MP = minetest.get_modpath("scifi_nodes")
if minetest.get_modpath("xpanes") then
dofile(MP.."/panes.lua")
end
dofile(MP.."/common.lua")
dofile(MP.."/builder.lua")
dofile(MP.."/chest.lua")
dofile(MP.."/plants.lua")
dofile(MP.."/nodes.lua")
dofile(MP.."/doors.lua")
dofile(MP.."/switches.lua")
dofile(MP.."/nodeboxes.lua")
dofile(MP.."/palm_scanner.lua")
dofile(MP.."/digicode.lua")
dofile(MP.."/models.lua")
dofile(MP.."/crafts.lua")
|
local API_RE = require(script:GetCustomProperty("APIReliableEvents"))
local FORCE_CLOSE_BUTTON = script.parent
local VIEW_NAME = FORCE_CLOSE_BUTTON:GetCustomProperty("ViewName")
FORCE_CLOSE_BUTTON.clickedEvent:Connect(function() API_RE.Broadcast("ForceCloseViewByName", VIEW_NAME) end)
|
test_run = require('test_run').new()
engine = test_run:get_cfg('engine')
box.sql.execute('pragma sql_default_engine=\''..engine..'\'')
-- Verify that constraints on 'view' option are working.
-- box.cfg()
-- Create space and view.
box.sql.execute("CREATE TABLE t1(a, b, PRIMARY KEY(a, b));");
box.sql.execute("CREATE VIEW v1 AS SELECT a+b FROM t1;");
-- View can't have any indexes.
box.sql.execute("CREATE INDEX i1 on v1(a);");
v1 = box.space.V1;
v1:create_index('primary', {parts = {1, 'string'}})
v1:create_index('secondary', {parts = {1, 'string'}})
-- View option can't be changed.
v1 = box.space._space.index[2]:select('V1')[1]:totable();
v1[6]['view'] = false;
box.space._space:replace(v1);
t1 = box.space._space.index[2]:select('T1')[1]:totable();
t1[6]['view'] = true;
box.space._space:replace(t1);
-- View can't exist without SQL statement.
v1[6] = {};
v1[6]['view'] = true;
box.space._space:replace(v1);
-- Views can't be created via space_create().
box.schema.create_space('view', {view = true})
-- View can be created via straight insertion into _space.
sp = box.schema.create_space('test');
raw_sp = box.space._space:get(sp.id):totable();
sp:drop();
raw_sp[6].sql = 'CREATE VIEW v as SELECT * FROM t1;';
raw_sp[6].view = true;
sp = box.space._space:replace(raw_sp);
box.space._space:select(sp['id'])[1]['name']
-- Can't create view with incorrect SELECT statement.
box.space.test:drop();
-- This case must fail since parser converts it to expr AST.
raw_sp[6].sql = 'SELECT 1;';
sp = box.space._space:replace(raw_sp);
-- Can't drop space via Lua if at least one view refers to it.
box.sql.execute('CREATE TABLE t2(id INT PRIMARY KEY);');
box.sql.execute('CREATE VIEW v2 AS SELECT * FROM t2;');
box.space.T2:drop();
box.sql.execute('DROP VIEW v2;');
box.sql.execute('DROP TABLE t2;');
-- Check that alter transfers reference counter.
box.sql.execute("CREATE TABLE t2(id INTEGER PRIMARY KEY);");
box.sql.execute("CREATE VIEW v2 AS SELECT * FROM t2;");
box.sql.execute("DROP TABLE t2;");
sp = box.space._space:get{box.space.T2.id};
sp = box.space._space:replace(sp);
box.sql.execute("DROP TABLE t2;");
box.sql.execute("DROP VIEW v2;");
box.sql.execute("DROP TABLE t2;");
-- Cleanup
box.sql.execute("DROP VIEW v1;");
box.sql.execute("DROP TABLE t1;");
|
local admins = {"FreakingHulk", "nutkitten"}
local datastore = game:GetService("DataStoreService")
game.Players.PlayerAdded:Connect(function(p)
p.Chatted:Connect(function(msg)
if msg:lower():sub(1,6) == ":kick " then
local plr = msg:lower()
if plr:sub(7,10) == "all" then
for _,players in pairs(game.Players:GetPlayers()) do
players:Kick("All players have been kicked.")
end
end
local plrs = game.Players:GetPlayers()
for _,players in pairs(plrs) do
if players.Name == plr then
if admins[players.Name] then
warn("Player tried to kick admin.")
players.PlayerGui:SetCore("Notification", {
Title = "Cannot kick admin;",
Text = "You just tried to kick an admin! Admins can't be kicked."
})
else
players:Kick("You have been kicked by a moderator.")
end
end
end
else
end
end)
end)
|
FLAG.PrintName = "Stalker";
FLAG.Flag = "S";
FLAG.Team = TEAM_STALKER;
FLAG.Loadout = { "weapon_cc_stalker" };
function FLAG.ModelFunc( ply )
return "models/stalker.mdl";
end
|
-- MTE "CASTLE DEMO" ----------------------------------------------------------
local composer = require("composer")
local myData = require("RotateConstrainComposer.mydata")
myData.prevMap = nil
myData.nextMap = "map1"
--SETUP D-PAD ------------------------------------------------------------
myData.controlGroup = display.newGroup()
myData.DpadBack = display.newImageRect(myData.controlGroup, "RotateConstrainComposer/Dpad.png", 100, 100)
myData.DpadBack.x = Screen.Left + myData.DpadBack.width*0.5 + 10
myData.DpadBack.y = Screen.Bottom - myData.DpadBack.height*0.5 - 10
myData.DpadUp = display.newRect(myData.controlGroup, myData.DpadBack.x - 0, myData.DpadBack.y - 31, 33, 33)
myData.DpadDown = display.newRect(myData.controlGroup, myData.DpadBack.x - 0, myData.DpadBack.y + 31, 33, 33)
myData.DpadLeft = display.newRect(myData.controlGroup, myData.DpadBack.x - 31, myData.DpadBack.y - 0, 33, 33)
myData.DpadRight = display.newRect(myData.controlGroup, myData.DpadBack.x + 31, myData.DpadBack.y - 0, 33, 33)
myData.DpadBack:toFront()
composer.gotoScene("RotateConstrainComposer.scene")
|
local DBAB = Instance.new("ScreenGui")
local Frame = Instance.new("Frame")
local TextLabel = Instance.new("TextLabel")
local BlackBox = Instance.new("Frame")
local TextLabel_2 = Instance.new("TextLabel")
local TextLabel_3 = Instance.new("TextLabel")
local TextLabel_4 = Instance.new("TextLabel")
local TextButton = Instance.new("TextButton")
local TextButton_2 = Instance.new("TextButton")
local TextButton_3 = Instance.new("TextButton")
local TextBox2 = Instance.new("TextBox")
local TextButton_4 = Instance.new("TextButton")
local TutFrame2 = Instance.new("Frame")
local TextLabel_5 = Instance.new("TextLabel")
local TextLabel_6 = Instance.new("TextLabel")
local TextLabel_7 = Instance.new("TextLabel")
local TextLabel_8 = Instance.new("TextLabel")
local TextLabel_9 = Instance.new("TextLabel")
local TextLabel_10 = Instance.new("TextLabel")
local TextLabel_11 = Instance.new("TextLabel")
local TextLabel_12 = Instance.new("TextLabel")
local TextLabel_13 = Instance.new("TextLabel")
local TutFrame = Instance.new("Frame")
local TextLabel_14 = Instance.new("TextLabel")
local TextLabel_15 = Instance.new("TextLabel")
local TextLabel_16 = Instance.new("TextLabel")
local TextLabel_17 = Instance.new("TextLabel")
local TextLabel_18 = Instance.new("TextLabel")
local TextLabel_19 = Instance.new("TextLabel")
local TextLabel_20 = Instance.new("TextLabel")
local TextLabel_21 = Instance.new("TextLabel")
local TextLabel_22 = Instance.new("TextLabel")
local TextLabel_23 = Instance.new("TextLabel")
local TextLabel_24 = Instance.new("TextLabel")
local TextLabel_25 = Instance.new("TextLabel")
local TextButton_5 = Instance.new("TextButton")
local TextButton_6 = Instance.new("TextButton")
local TextButton_7 = Instance.new("TextButton")
local TextButton_8 = Instance.new("TextButton")
local TextButton_9 = Instance.new("TextButton")
local TextButton_10 = Instance.new("TextButton")
local TextButton_11 = Instance.new("TextButton")
local TextButton_12 = Instance.new("TextButton")
local TextBox = Instance.new("TextBox")
local TextButton_13 = Instance.new("TextButton")
--Properties:
DBAB.Name = "DBAB"
DBAB.Parent = game.CoreGui
Frame.Parent = DBAB
Frame.BackgroundColor3 = Color3.new(1, 1, 0.4)
Frame.BackgroundTransparency = 0.30000001192093
Frame.BorderSizePixel = 0
Frame.Position = UDim2.new(0.400638342, 0, 0.278142214, 0)
Frame.Size = UDim2.new(0, 169, 0, 285)
TextLabel.Parent = Frame
TextLabel.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel.BackgroundTransparency = 1
TextLabel.Position = UDim2.new(0.183431938, 0, -0.196491227, 0)
TextLabel.Size = UDim2.new(0, 106, 0, 22)
TextLabel.Font = Enum.Font.Gotham
TextLabel.Text = "A Bizarre"
TextLabel.TextColor3 = Color3.new(0.952941, 0.27451, 1)
TextLabel.TextSize = 24
BlackBox.Name = "BlackBox"
BlackBox.Parent = Frame
BlackBox.BackgroundColor3 = Color3.new(1, 0.666667, 0)
BlackBox.BorderSizePixel = 0
BlackBox.Position = UDim2.new(-0.00394489337, 0, 0.731593072, 0)
BlackBox.Size = UDim2.new(0, 169, 0, 76)
BlackBox.Style = Enum.FrameStyle.DropShadow
TextLabel_2.Parent = Frame
TextLabel_2.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_2.BackgroundTransparency = 1
TextLabel_2.Position = UDim2.new(0.183431923, 0, -0.119298242, 0)
TextLabel_2.Size = UDim2.new(0, 106, 0, 22)
TextLabel_2.Font = Enum.Font.Gotham
TextLabel_2.Text = "Day"
TextLabel_2.TextColor3 = Color3.new(0, 1, 0.113725)
TextLabel_2.TextSize = 24
TextLabel_3.Parent = Frame
TextLabel_3.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_3.BackgroundTransparency = 1
TextLabel_3.Position = UDim2.new(0.183431953, 0, -0.196491227, 0)
TextLabel_3.Size = UDim2.new(0, 114, 0, 22)
TextLabel_3.Font = Enum.Font.Gotham
TextLabel_3.Text = "A Bizarre"
TextLabel_3.TextColor3 = Color3.new(0.952941, 0.27451, 1)
TextLabel_3.TextSize = 24
TextLabel_3.TextTransparency = 0.60000002384186
TextLabel_4.Parent = Frame
TextLabel_4.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_4.BackgroundTransparency = 1
TextLabel_4.Position = UDim2.new(0.20710057, 0, -0.119298242, 0)
TextLabel_4.Size = UDim2.new(0, 106, 0, 22)
TextLabel_4.Font = Enum.Font.Gotham
TextLabel_4.Text = "Day"
TextLabel_4.TextColor3 = Color3.new(0, 1, 0.113725)
TextLabel_4.TextSize = 24
TextLabel_4.TextTransparency = 0.60000002384186
TextButton.Parent = Frame
TextButton.BackgroundColor3 = Color3.new(1, 1, 1)
TextButton.BorderSizePixel = 0
TextButton.Position = UDim2.new(0.284023672, 0, 0, 0)
TextButton.Size = UDim2.new(0, 67, 0, 19)
TextButton.Style = Enum.ButtonStyle.RobloxRoundDropdownButton
TextButton.Font = Enum.Font.Fantasy
TextButton.Text = "Cash"
TextButton.TextColor3 = Color3.new(0.172549, 0.941177, 0)
TextButton.TextSize = 14
TextButton_2.Parent = Frame
TextButton_2.BackgroundColor3 = Color3.new(1, 1, 1)
TextButton_2.BackgroundTransparency = 1
TextButton_2.BorderSizePixel = 0
TextButton_2.Position = UDim2.new(0.177514732, 0, 0.884210527, 0)
TextButton_2.Size = UDim2.new(0, 106, 0, 19)
TextButton_2.Font = Enum.Font.Fantasy
TextButton_2.Text = "Close"
TextButton_2.TextColor3 = Color3.new(0.976471, 0, 0)
TextButton_2.TextSize = 20
TextButton_3.Parent = Frame
TextButton_3.BackgroundColor3 = Color3.new(1, 1, 1)
TextButton_3.BorderSizePixel = 0
TextButton_3.Position = UDim2.new(0.177514791, 0, 0.0982456133, 0)
TextButton_3.Size = UDim2.new(0, 54, 0, 19)
TextButton_3.Style = Enum.ButtonStyle.RobloxRoundDropdownButton
TextButton_3.Font = Enum.Font.Fantasy
TextButton_3.Text = "Change"
TextButton_3.TextColor3 = Color3.new(0.941177, 0.0235294, 0.423529)
TextButton_3.TextSize = 14
TextBox2.Name = "TextBox2"
TextBox2.Parent = Frame
TextBox2.BackgroundColor3 = Color3.new(1, 1, 1)
TextBox2.BackgroundTransparency = 1
TextBox2.Position = UDim2.new(0.514793098, 0, 0.638596475, 0)
TextBox2.Size = UDim2.new(0, 76, 0, 19)
TextBox2.Font = Enum.Font.SourceSans
TextBox2.PlaceholderColor3 = Color3.new(0.156863, 0.227451, 0.180392)
TextBox2.PlaceholderText = "Name Here"
TextBox2.Text = ""
TextBox2.TextColor3 = Color3.new(0, 0, 0)
TextBox2.TextSize = 14
TextButton_4.Parent = Frame
TextButton_4.BackgroundColor3 = Color3.new(1, 1, 1)
TextButton_4.BorderSizePixel = 0
TextButton_4.Position = UDim2.new(0.0118342843, 0, 0.0982456207, 0)
TextButton_4.Size = UDim2.new(0, 33, 0, 19)
TextButton_4.Style = Enum.ButtonStyle.RobloxRoundDropdownButton
TextButton_4.Font = Enum.Font.Fantasy
TextButton_4.Text = "List"
TextButton_4.TextColor3 = Color3.new(0.941177, 0.0235294, 0.423529)
TextButton_4.TextSize = 14
TutFrame2.Name = "TutFrame2"
TutFrame2.Parent = Frame
TutFrame2.BackgroundColor3 = Color3.new(1, 0.666667, 0)
TutFrame2.BorderSizePixel = 0
TutFrame2.Position = UDim2.new(-0.962524772, 0, -0.00174025155, 0)
TutFrame2.Size = UDim2.new(0, 162, 0, 278)
TutFrame2.Visible = false
TutFrame2.Style = Enum.FrameStyle.DropShadow
TextLabel_5.Parent = TutFrame2
TextLabel_5.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_5.BackgroundTransparency = 1
TextLabel_5.Position = UDim2.new(0.220885411, 0, -0.00696256757, 0)
TextLabel_5.Size = UDim2.new(0, 80, 0, 22)
TextLabel_5.Font = Enum.Font.Gotham
TextLabel_5.Text = "ID's"
TextLabel_5.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_5.TextSize = 15
TextLabel_6.Parent = TutFrame2
TextLabel_6.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_6.BackgroundTransparency = 1
TextLabel_6.Position = UDim2.new(0.220885411, 0, 0.0757712424, 0)
TextLabel_6.Size = UDim2.new(0, 80, 0, 22)
TextLabel_6.Font = Enum.Font.Gotham
TextLabel_6.Text = "12 - SPOH"
TextLabel_6.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_6.TextSize = 15
TextLabel_7.Parent = TutFrame2
TextLabel_7.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_7.BackgroundTransparency = 1
TextLabel_7.Position = UDim2.new(0.220885411, 0, 0.158505037, 0)
TextLabel_7.Size = UDim2.new(0, 80, 0, 22)
TextLabel_7.Font = Enum.Font.Gotham
TextLabel_7.Text = "13 - TWOH"
TextLabel_7.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_7.TextSize = 15
TextLabel_8.Parent = TutFrame2
TextLabel_8.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_8.BackgroundTransparency = 1
TextLabel_8.Position = UDim2.new(0.220885411, 0, 0.237641737, 0)
TextLabel_8.Size = UDim2.new(0, 80, 0, 22)
TextLabel_8.Font = Enum.Font.Gotham
TextLabel_8.Text = "14 - One More Time"
TextLabel_8.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_8.TextSize = 15
TextLabel_9.Parent = TutFrame2
TextLabel_9.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_9.BackgroundTransparency = 1
TextLabel_9.Position = UDim2.new(0.220885411, 0, 0.316778421, 0)
TextLabel_9.Size = UDim2.new(0, 80, 0, 22)
TextLabel_9.Font = Enum.Font.Gotham
TextLabel_9.Text = "15 - Sword"
TextLabel_9.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_9.TextSize = 15
TextLabel_10.Parent = TutFrame2
TextLabel_10.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_10.BackgroundTransparency = 1
TextLabel_10.Position = UDim2.new(0.220885411, 0, 0.403109372, 0)
TextLabel_10.Size = UDim2.new(0, 80, 0, 22)
TextLabel_10.Font = Enum.Font.Gotham
TextLabel_10.Text = "16 - Rice Farmer"
TextLabel_10.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_10.TextSize = 15
TextLabel_11.Parent = TutFrame2
TextLabel_11.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_11.BackgroundTransparency = 1
TextLabel_11.Position = UDim2.new(0.220885411, 0, 0.482246041, 0)
TextLabel_11.Size = UDim2.new(0, 80, 0, 22)
TextLabel_11.Font = Enum.Font.Gotham
TextLabel_11.Text = "17 - Samurai"
TextLabel_11.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_11.TextSize = 15
TextLabel_12.Parent = TutFrame2
TextLabel_12.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_12.BackgroundTransparency = 1
TextLabel_12.Position = UDim2.new(0.220885411, 0, 0.561382711, 0)
TextLabel_12.Size = UDim2.new(0, 80, 0, 22)
TextLabel_12.Font = Enum.Font.Gotham
TextLabel_12.Text = "1003 - TWAU (Buffed)"
TextLabel_12.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_12.TextSize = 15
TextLabel_13.Parent = TutFrame2
TextLabel_13.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_13.BackgroundTransparency = 1
TextLabel_13.Position = UDim2.new(0.220885411, 0, 0.640519381, 0)
TextLabel_13.Size = UDim2.new(0, 80, 0, 22)
TextLabel_13.Font = Enum.Font.Gotham
TextLabel_13.Text = "1004 - GER (Buffed)"
TextLabel_13.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_13.TextSize = 15
TutFrame.Name = "TutFrame"
TutFrame.Parent = Frame
TutFrame.BackgroundColor3 = Color3.new(1, 0.666667, 0)
TutFrame.BorderSizePixel = 0
TutFrame.Position = UDim2.new(-1.92110467, 0, -0.00174025155, 0)
TutFrame.Size = UDim2.new(0, 162, 0, 278)
TutFrame.Visible = false
TutFrame.Style = Enum.FrameStyle.DropShadow
TextLabel_14.Parent = TutFrame
TextLabel_14.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_14.BackgroundTransparency = 1
TextLabel_14.Position = UDim2.new(0.220885411, 0, -0.00696256757, 0)
TextLabel_14.Size = UDim2.new(0, 80, 0, 22)
TextLabel_14.Font = Enum.Font.Gotham
TextLabel_14.Text = "ID's"
TextLabel_14.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_14.TextSize = 15
TextLabel_15.Parent = TutFrame
TextLabel_15.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_15.BackgroundTransparency = 1
TextLabel_15.Position = UDim2.new(0.220885411, 0, 0.0613827556, 0)
TextLabel_15.Size = UDim2.new(0, 80, 0, 22)
TextLabel_15.Font = Enum.Font.Gotham
TextLabel_15.Text = "1 - N/A"
TextLabel_15.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_15.TextSize = 15
TextLabel_16.Parent = TutFrame
TextLabel_16.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_16.BackgroundTransparency = 1
TextLabel_16.Position = UDim2.new(0.220885411, 0, 0.14051944, 0)
TextLabel_16.Size = UDim2.new(0, 80, 0, 22)
TextLabel_16.Font = Enum.Font.Gotham
TextLabel_16.Text = "2 - Star Platinum"
TextLabel_16.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_16.TextSize = 15
TextLabel_17.Parent = TutFrame
TextLabel_17.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_17.BackgroundTransparency = 1
TextLabel_17.Position = UDim2.new(0.220885411, 0, 0.21965614, 0)
TextLabel_17.Size = UDim2.new(0, 80, 0, 22)
TextLabel_17.Font = Enum.Font.Gotham
TextLabel_17.Text = "3 - Star Platinum TW"
TextLabel_17.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_17.TextSize = 15
TextLabel_18.Parent = TutFrame
TextLabel_18.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_18.BackgroundTransparency = 1
TextLabel_18.Position = UDim2.new(0.220885411, 0, 0.298792839, 0)
TextLabel_18.Size = UDim2.new(0, 80, 0, 22)
TextLabel_18.Font = Enum.Font.Gotham
TextLabel_18.Text = "4 - The World"
TextLabel_18.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_18.TextSize = 15
TextLabel_19.Parent = TutFrame
TextLabel_19.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_19.BackgroundTransparency = 1
TextLabel_19.Position = UDim2.new(0.220885411, 0, 0.377929538, 0)
TextLabel_19.Size = UDim2.new(0, 80, 0, 22)
TextLabel_19.Font = Enum.Font.Gotham
TextLabel_19.Text = "5 - Crazy Diamond"
TextLabel_19.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_19.TextSize = 15
TextLabel_20.Parent = TutFrame
TextLabel_20.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_20.BackgroundTransparency = 1
TextLabel_20.Position = UDim2.new(0.220885411, 0, 0.47145474, 0)
TextLabel_20.Size = UDim2.new(0, 80, 0, 22)
TextLabel_20.Font = Enum.Font.Gotham
TextLabel_20.Text = "6 - Killer Queen"
TextLabel_20.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_20.TextSize = 15
TextLabel_21.Parent = TutFrame
TextLabel_21.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_21.BackgroundTransparency = 1
TextLabel_21.Position = UDim2.new(0.220885411, 0, 0.550591409, 0)
TextLabel_21.Size = UDim2.new(0, 80, 0, 22)
TextLabel_21.Font = Enum.Font.Gotham
TextLabel_21.Text = "7 - Gold Experience"
TextLabel_21.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_21.TextSize = 15
TextLabel_22.Parent = TutFrame
TextLabel_22.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_22.BackgroundTransparency = 1
TextLabel_22.Position = UDim2.new(0.220885411, 0, 0.629728079, 0)
TextLabel_22.Size = UDim2.new(0, 80, 0, 22)
TextLabel_22.Font = Enum.Font.Gotham
TextLabel_22.Text = "8 - GER"
TextLabel_22.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_22.TextSize = 15
TextLabel_23.Parent = TutFrame
TextLabel_23.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_23.BackgroundTransparency = 1
TextLabel_23.Position = UDim2.new(0.220885411, 0, 0.708864748, 0)
TextLabel_23.Size = UDim2.new(0, 80, 0, 22)
TextLabel_23.Font = Enum.Font.Gotham
TextLabel_23.Text = "9 - King Crimson"
TextLabel_23.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_23.TextSize = 15
TextLabel_24.Parent = TutFrame
TextLabel_24.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_24.BackgroundTransparency = 1
TextLabel_24.Position = UDim2.new(0.220885411, 0, 0.788001418, 0)
TextLabel_24.Size = UDim2.new(0, 80, 0, 22)
TextLabel_24.Font = Enum.Font.Gotham
TextLabel_24.Text = "10 - Doppio's KC"
TextLabel_24.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_24.TextSize = 15
TextLabel_25.Parent = TutFrame
TextLabel_25.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel_25.BackgroundTransparency = 1
TextLabel_25.Position = UDim2.new(0.220885411, 0, 0.867138088, 0)
TextLabel_25.Size = UDim2.new(0, 80, 0, 22)
TextLabel_25.Font = Enum.Font.Gotham
TextLabel_25.Text = "11 - The World (AU)"
TextLabel_25.TextColor3 = Color3.new(0.14902, 0.0392157, 1)
TextLabel_25.TextSize = 15
TextButton_5.Parent = Frame
TextButton_5.BackgroundColor3 = Color3.new(1, 1, 1)
TextButton_5.BorderSizePixel = 0
TextButton_5.Position = UDim2.new(0.177514791, 0, 0.19298245, 0)
TextButton_5.Size = UDim2.new(0, 106, 0, 19)
TextButton_5.Style = Enum.ButtonStyle.RobloxRoundDropdownButton
TextButton_5.Font = Enum.Font.Fantasy
TextButton_5.Text = "Select Menu"
TextButton_5.TextColor3 = Color3.new(0.866667, 0.0196078, 0.941177)
TextButton_5.TextSize = 14
TextButton_6.Parent = Frame
TextButton_6.BackgroundColor3 = Color3.new(1, 1, 1)
TextButton_6.BorderSizePixel = 0
TextButton_6.Position = UDim2.new(0.284023672, 0, 0.280701756, 0)
TextButton_6.Size = UDim2.new(0, 67, 0, 19)
TextButton_6.Style = Enum.ButtonStyle.RobloxRoundDropdownButton
TextButton_6.Font = Enum.Font.Fantasy
TextButton_6.Text = "Inf Block"
TextButton_6.TextColor3 = Color3.new(0.141176, 0.0823529, 0.941177)
TextButton_6.TextSize = 14
TextButton_7.Parent = Frame
TextButton_7.BackgroundColor3 = Color3.new(1, 1, 1)
TextButton_7.BorderSizePixel = 0
TextButton_7.Position = UDim2.new(0.284023672, 0, 0.368421048, 0)
TextButton_7.Size = UDim2.new(0, 67, 0, 19)
TextButton_7.Style = Enum.ButtonStyle.RobloxRoundDropdownButton
TextButton_7.Font = Enum.Font.Fantasy
TextButton_7.Text = "Inf Dodge"
TextButton_7.TextColor3 = Color3.new(0.941177, 0.843137, 0.0823529)
TextButton_7.TextSize = 14
TextButton_8.Parent = Frame
TextButton_8.BackgroundColor3 = Color3.new(1, 1, 1)
TextButton_8.BorderSizePixel = 0
TextButton_8.Position = UDim2.new(0.0118343234, 0, 0.44561404, 0)
TextButton_8.Size = UDim2.new(0, 67, 0, 19)
TextButton_8.Style = Enum.ButtonStyle.RobloxRoundDropdownButton
TextButton_8.Font = Enum.Font.Fantasy
TextButton_8.Text = "Arrow"
TextButton_8.TextColor3 = Color3.new(0.941177, 0.843137, 0.0823529)
TextButton_8.TextSize = 14
TextButton_9.Parent = Frame
TextButton_9.BackgroundColor3 = Color3.new(1, 1, 1)
TextButton_9.BorderSizePixel = 0
TextButton_9.Position = UDim2.new(0.544378698, 0, 0.44561404, 0)
TextButton_9.Size = UDim2.new(0, 67, 0, 19)
TextButton_9.Style = Enum.ButtonStyle.RobloxRoundDropdownButton
TextButton_9.Font = Enum.Font.Fantasy
TextButton_9.Text = "Rokakaka"
TextButton_9.TextColor3 = Color3.new(0.941177, 0.00392157, 0.0196078)
TextButton_9.TextSize = 14
TextButton_10.Parent = Frame
TextButton_10.BackgroundColor3 = Color3.new(1, 1, 1)
TextButton_10.BorderSizePixel = 0
TextButton_10.Position = UDim2.new(0.0059171319, 0, 0.533333361, 0)
TextButton_10.Size = UDim2.new(0, 67, 0, 19)
TextButton_10.Style = Enum.ButtonStyle.RobloxRoundDropdownButton
TextButton_10.Font = Enum.Font.Fantasy
TextButton_10.Text = "Req. Arrow"
TextButton_10.TextColor3 = Color3.new(0.0392157, 0.941177, 0.32549)
TextButton_10.TextSize = 14
TextButton_11.Parent = Frame
TextButton_11.BackgroundColor3 = Color3.new(1, 1, 1)
TextButton_11.BorderSizePixel = 0
TextButton_11.Position = UDim2.new(0.544378698, 0, 0.533333361, 0)
TextButton_11.Size = UDim2.new(0, 67, 0, 19)
TextButton_11.Style = Enum.ButtonStyle.RobloxRoundDropdownButton
TextButton_11.Font = Enum.Font.Fantasy
TextButton_11.Text = "Dio's Diary"
TextButton_11.TextColor3 = Color3.new(0.941177, 0.745098, 0.027451)
TextButton_11.TextSize = 14
TextButton_12.Parent = Frame
TextButton_12.BackgroundColor3 = Color3.new(1, 1, 1)
TextButton_12.BorderSizePixel = 0
TextButton_12.Position = UDim2.new(0.408284009, 0, 0.487719327, 0)
TextButton_12.Size = UDim2.new(0, 24, 0, 19)
TextButton_12.Style = Enum.ButtonStyle.RobloxRoundDropdownButton
TextButton_12.Font = Enum.Font.Fantasy
TextButton_12.Text = "H"
TextButton_12.TextColor3 = Color3.new(0.941177, 0.745098, 0.027451)
TextButton_12.TextSize = 14
TextBox.Parent = Frame
TextBox.BackgroundColor3 = Color3.new(1, 1, 1)
TextBox.BackgroundTransparency = 1
TextBox.Position = UDim2.new(0.497041613, 0, 0.0982456133, 0)
TextBox.Size = UDim2.new(0, 76, 0, 19)
TextBox.Font = Enum.Font.SourceSans
TextBox.PlaceholderColor3 = Color3.new(0.698039, 0.0352941, 0.247059)
TextBox.PlaceholderText = "ID Here"
TextBox.Text = ""
TextBox.TextColor3 = Color3.new(0, 0, 0)
TextBox.TextSize = 14
TextButton_13.Parent = Frame
TextButton_13.BackgroundColor3 = Color3.new(1, 1, 1)
TextButton_13.BorderSizePixel = 0
TextButton_13.Position = UDim2.new(0.0118343197, 0, 0.638596475, 0)
TextButton_13.Size = UDim2.new(0, 73, 0, 19)
TextButton_13.Style = Enum.ButtonStyle.RobloxRoundDropdownButton
TextButton_13.Font = Enum.Font.Fantasy
TextButton_13.Text = "Kill User"
TextButton_13.TextColor3 = Color3.new(0.941177, 0, 0.0156863)
TextButton_13.TextSize = 14
-- Scripts:
function SCRIPT_WLTS73_FAKESCRIPT() -- Frame.DragProperties
local script = Instance.new('LocalScript')
script.Parent = Frame
local UserInputService = game:GetService("UserInputService")
--stop scrounging through me guis fatt
local gui = script.Parent
local dragging
local dragInput
local dragStart
local startPos
local function update(input)
local delta = input.Position - dragStart
gui.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
end
gui.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
dragging = true
dragStart = input.Position
startPos = gui.Position
input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
dragging = false
end
end)
end
end)
gui.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
dragInput = input
end
end)
UserInputService.InputChanged:Connect(function(input)
if input == dragInput and dragging then
update(input)
end
end)
end
coroutine.resume(coroutine.create(SCRIPT_WLTS73_FAKESCRIPT))
function SCRIPT_PLXV80_FAKESCRIPT() -- TextButton.LocalScript
local script = Instance.new('LocalScript')
script.Parent = TextButton
script.Parent.MouseButton1Click:Connect(function()
local A_1 = "10000000"
local Event = game:GetService("ReplicatedStorage").Money
Event:FireServer(A_1)
end)
end
coroutine.resume(coroutine.create(SCRIPT_PLXV80_FAKESCRIPT))
function SCRIPT_JBZW76_FAKESCRIPT() -- TextButton_2.LocalScript
local script = Instance.new('LocalScript')
script.Parent = TextButton_2
script.Parent.MouseButton1Click:Connect(function()
_G.On = false
script.Parent.Parent.Parent:Destroy()
end)
end
coroutine.resume(coroutine.create(SCRIPT_JBZW76_FAKESCRIPT))
function SCRIPT_QNYF65_FAKESCRIPT() -- TextButton_3.LocalScript
local script = Instance.new('LocalScript')
script.Parent = TextButton_3
script.Parent.MouseButton1Click:Connect(function()
game.Players.LocalPlayer.Data.Stand.Value = script.Parent.Parent.TextBox.Text
end)
end
coroutine.resume(coroutine.create(SCRIPT_QNYF65_FAKESCRIPT))
function SCRIPT_RMRI71_FAKESCRIPT() -- TextButton_4.LocalScript
local script = Instance.new('LocalScript')
script.Parent = TextButton_4
script.Parent.MouseButton1Click:Connect(function()
if script.Parent:FindFirstChild("yes") then
else
local toggle = Instance.new("BoolValue")
toggle.Parent = script.Parent
toggle.Name = "yes"
end
local tut1 = script.Parent.Parent.TutFrame
local tut2 = script.Parent.Parent.TutFrame2
local toggle = script.Parent.yes
if toggle.Value == true then
toggle.Value = false
tut1.Visible = false
tut2.Visible = false
elseif toggle.Value == false then
toggle.Value = true
tut1.Visible = true
tut2.Visible = true
end
end)
end
coroutine.resume(coroutine.create(SCRIPT_RMRI71_FAKESCRIPT))
function SCRIPT_PTMT73_FAKESCRIPT() -- TextButton_5.LocalScript
local script = Instance.new('LocalScript')
script.Parent = TextButton_5
script.Parent.MouseButton1Click:Connect(function()
game.Players.LocalPlayer.PlayerGui.Select.Enabled = true
end)
end
coroutine.resume(coroutine.create(SCRIPT_PTMT73_FAKESCRIPT))
function SCRIPT_CXNU77_FAKESCRIPT() -- TextButton_6.LocalScript
local script = Instance.new('LocalScript')
script.Parent = TextButton_6
script.Parent.MouseButton1Click:Connect(function()
local yes = true
game.ReplicatedStorage.Block:FireServer(yes)
end)
end
coroutine.resume(coroutine.create(SCRIPT_CXNU77_FAKESCRIPT))
function SCRIPT_UXPC86_FAKESCRIPT() -- TextButton_7.LocalScript
local script = Instance.new('LocalScript')
script.Parent = TextButton_7
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.Epitaph:FireServer()
end)
end
coroutine.resume(coroutine.create(SCRIPT_UXPC86_FAKESCRIPT))
function SCRIPT_CFJS70_FAKESCRIPT() -- TextButton_8.LocalScript
local script = Instance.new('LocalScript')
script.Parent = TextButton_8
script.Parent.MouseButton1Click:Connect(function()
local boyy = game.Lighting.Arrow:Clone()
boyy.Parent = game.Players.LocalPlayer.Backpack
boyy.Handle.Anchored = false
end)
end
coroutine.resume(coroutine.create(SCRIPT_CFJS70_FAKESCRIPT))
function SCRIPT_BWFA81_FAKESCRIPT() -- TextButton_9.LocalScript
local script = Instance.new('LocalScript')
script.Parent = TextButton_9
script.Parent.MouseButton1Click:Connect(function()
local boyy = game.Lighting["Rokakaka Fruit"]:Clone()
boyy.Parent = game.Players.LocalPlayer.Backpack
boyy.Handle.Anchored = false
end)
end
coroutine.resume(coroutine.create(SCRIPT_BWFA81_FAKESCRIPT))
function SCRIPT_QGXD76_FAKESCRIPT() -- TextButton_10.LocalScript
local script = Instance.new('LocalScript')
script.Parent = TextButton_10
script.Parent.MouseButton1Click:Connect(function()
local boyy = game.Lighting["Requiem Arrow"]:Clone()
boyy.Parent = game.Players.LocalPlayer.Backpack
boyy.Handle.Anchored = false
end)
end
coroutine.resume(coroutine.create(SCRIPT_QGXD76_FAKESCRIPT))
function SCRIPT_XADM69_FAKESCRIPT() -- TextButton_11.LocalScript
local script = Instance.new('LocalScript')
script.Parent = TextButton_11
script.Parent.MouseButton1Click:Connect(function()
local boyy = game.Lighting["DIO's Diary"]:Clone()
boyy.Parent = game.Players.LocalPlayer.Backpack
boyy.Handle.Anchored = false
end)
end
coroutine.resume(coroutine.create(SCRIPT_XADM69_FAKESCRIPT))
function SCRIPT_SPUE77_FAKESCRIPT() -- TextButton_12.LocalScript
local script = Instance.new('LocalScript')
script.Parent = TextButton_12
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.TWAUKnife:FireServer()
end)
end
coroutine.resume(coroutine.create(SCRIPT_SPUE77_FAKESCRIPT))
function SCRIPT_BCFM79_FAKESCRIPT() -- TextButton_13.LocalScript
local script = Instance.new('LocalScript')
script.Parent = TextButton_13
script.Parent.MouseButton1Click:Connect(function()
local targetuser = script.Parent.Parent.TextBox2.Text
if game.Workspace:FindFirstChild(targetuser) then
local A_1 = game:GetService("Workspace"):FindFirstChild(targetuser).Humanoid
local A_2 = game.Workspace:FindFirstChild(targetuser).Torso.CFrame
local A_3 = 1000000000000000
local A_4 = 0.25
local A_5 = Vector3.new(9.97749424, 8.83126745e-07, -0.670526147)
local A_6 = "rbxassetid://241837157"
local A_7 = 0.075
local A_8 = Color3.new(255, 255, 255)
local A_9 = "rbxassetid://260430079"
local A_10 = 1
local A_11 = 2
local Event = game:GetService("ReplicatedStorage").Damage
Event:FireServer(A_1, A_2, A_3, A_4, A_5, A_6, A_7, A_8, A_9, A_10, A_11)
end
end)
end
coroutine.resume(coroutine.create(SCRIPT_BCFM79_FAKESCRIPT))
|
-- coding: utf-8
--[[
-- PLEASE DO "NOT" EDIT THIS FILE!
-- This file is generated by script.
--
-- If you want to apply corrections visit:
-- http://rom.curseforge.com/addons/DungeonLoots/localization/
--]]
return
{
["Boss_TT"] = "Boss %d: %s (%d)",
["Boss2_TT"] = "Loots -> %s (%d)",
["BossInstance"] = "Bosse zu Instanzen zuordnen",
["BossList"] = "Bossliste",
["ChangeSortOrder"] = "Sortierung ändern",
["HideWoWMapTeleport"] = "Verberge WoWMap Transportpunkte",
["HideWoWMapZone"] = "Verberge WoWMap Zonenportale",
["instance_memsmsg"] = "In dieser Instanz gibt es %s %s. ",
["instance_memswarning"] = "%s %s zu viel!",
["InstanceList"] = "Instanzliste",
["InstanceOrder"] = "Nach %s sortieren",
["ItemList"] = "Itemliste",
["Itemplus"] = "Item +:",
["MoreButton"] = "Mehr",
["NPCTT"] = [=[HP: %s
Atk: %s, %s
Def: %s, %s
CritRes: %s, %s]=],
["OnlyInstance"] = "Nur Instanzergebnisse anzeigen",
["OtherSex"] = "Anderes Geschlecht",
["RAIDSIZE"] = "Raidgröße: %d Personen",
["RAKSHA_CHEST_NOTE"] = "Kistenverteilung stimmt nur für Diamant!",
["Rarity"] = "+ Seltenheit:",
["Rune"] = "Rune %d:",
["SearchBoss"] = "Nach Bossen suchen",
["SearchInstance"] = "Nach Instanzen suchen",
["SearchItem"] = "Nach Items suchen",
["SearchList"] = "SuFu",
["SearchMinLength"] = [=[Suchbegriff muss aus mindestens %d Buchstaben bestehen!
Leerzeichen werden nicht gezählt!]=],
["SearchTreasure"] = "Nach Schätzen suchen",
["ShowBoss"] = "Zeige aktuelles Ziel",
["ShowInDB"] = "In der rom-welten.de Datenbank anzeigen",
["ShowInDL"] = "In Dungeon Loots anzeigen",
["ShowInstance"] = "Zeige aktuelle Zone",
["StartPlus"] = "GO!",
["Stat"] = "Stat %d:",
["TabTier"] = "+/Grad",
["TreasureList"] = "Schatzliste",
["UseDLBossPoi"] = "Zeige Dungeon Loot Boss Positionen",
["UseDLInstancePoi"] = "Zeige Dungeon Loot Instanzportale",
["UseDLPoi"] = "DL Pois benutzen",
["Version"] = "%s: Version %s",
["WorldmapButton"] = "DL-Einstellungen",
}
|
player_manager.AddValidModel( "PMC3_04", "models/player/PMC_3/PMC__04.mdl" ) list.Set( "PlayerOptionsModel", "PMC3_04", "models/player/PMC_3/PMC__04.mdl" )
|
local dc1 = DifficultyIndexColor(1)
local dc2 = DifficultyIndexColor(2)
local image = ThemePrefs.Get("VisualTheme")
local t = Def.ActorFrame{
OffCommand=cmd(linear,1)
}
-- centers
t[#t+1] = Def.ActorFrame {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(x,_screen.cx;y,_screen.cy+50;diffusealpha,1;decelerate,0.4;addy,-250;accelerate,0.5;addy,20;diffusealpha,0;);
--top center
LoadActor("ScreenTitleMenu underlay/".. image .."_flycenter") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc2;rotationy,180;zoom,0;diffusealpha,0;accelerate,0.8;addx,50;zoom,1;diffusealpha,0.4;sleep,0;zoom,0;);
};
LoadActor("ScreenTitleMenu underlay/".. image .."_flycenter") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc1;zoom,0;diffusealpha,0;accelerate,0.8;addx,-50;zoom,0.6;diffusealpha,0.6;sleep,0;zoom,0;);
};
}
t[#t+1] = Def.ActorFrame {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(x,_screen.cx;y,_screen.cy+380;diffusealpha,1;decelerate,0.4;addy,-250;accelerate,0.5;addy,80;diffusealpha,0;);
--bottom center
LoadActor("ScreenTitleMenu underlay/".. image .."_flycenter") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc2;rotationy,180;zoom,0;diffusealpha,0;accelerate,0.8;addx,50;zoom,0.6;diffusealpha,0.6;sleep,0;zoom,0;);
};
LoadActor("ScreenTitleMenu underlay/".. image .."_flycenter") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc1;zoom,0;diffusealpha,0;accelerate,0.8;addx,-50;zoom,1;diffusealpha,0.4;sleep,0;zoom,0;);
};
}
-- up 200
t[#t+1] = Def.ActorFrame {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(x,_screen.cx;y,_screen.cy+200;diffusealpha,1;decelerate,0.4;addy,-200;accelerate,0.5;addy,100;diffusealpha,0;);
--top left
LoadActor("ScreenTitleMenu underlay/".. image .."_flytop") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc1;rotationy,180;zoom,0;diffusealpha,0;accelerate,0.8;addx,-200;zoom,1.0;diffusealpha,0.6;sleep,0;zoom,0;);
};
--top right
LoadActor("ScreenTitleMenu underlay/".. image .."_flytop") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc1;zoom,0;diffusealpha,0;accelerate,0.8;addx,200;zoom,1.0;diffusealpha,0.4;sleep,0;zoom,0;);
};
}
--up 250
t[#t+1] = Def.ActorFrame {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(x,_screen.cx; y,_screen.cy+200;diffusealpha,1; decelerate,0.5; addy,-250; accelerate,0.5; addy,100;diffusealpha,0;);
--top left
LoadActor("ScreenTitleMenu underlay/".. image .."_flytop") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc2;rotationy,180;zoom,0;diffusealpha,0;accelerate,0.8;addx,-200;zoom,1.5;diffusealpha,0.3;sleep,0;zoom,0;);
};
LoadActor("ScreenTitleMenu underlay/".. image .."_flytop") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc1;rotationy,180;zoom,0;diffusealpha,0;accelerate,0.8;addx,-200;zoom,0.8;diffusealpha,0.6;sleep,0;zoom,0;);
};
--top right
LoadActor("ScreenTitleMenu underlay/".. image .."_flytop") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc1;zoom,0;diffusealpha,0;accelerate,0.8;addx,200;zoom,1.5;diffusealpha,0.2;sleep,0;zoom,0;);
};
LoadActor("ScreenTitleMenu underlay/".. image .."_flytop") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc2;zoom,0;diffusealpha,0;accelerate,0.8;addx,200;zoom,0.8;diffusealpha,0.4;sleep,0;zoom,0;);
};
}
--up 150, out 280
t[#t+1] = Def.ActorFrame {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(x,_screen.cx;y,_screen.cy+200;diffusealpha,1;decelerate,0.4;addy,-150;accelerate,0.5;addy,100;diffusealpha,0;);
--top left
LoadActor("ScreenTitleMenu underlay/".. image .."_flytop") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc1;rotationy,180;zoom,0;diffusealpha,0;accelerate,0.8;addx,-280;zoom,1.2;diffusealpha,0.6;sleep,0;zoom,0;);
};
--top right
LoadActor("ScreenTitleMenu underlay/".. image .."_flytop") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc1;zoom,0;diffusealpha,0;accelerate,0.8;addx,280;zoom,1.2;diffusealpha,0.4;sleep,0;zoom,0;);
};
}
--up 250, out 280
t[#t+1] = Def.ActorFrame {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(x,_screen.cx;y,_screen.cy+200;diffusealpha,1;decelerate,0.4;addy,-250;accelerate,0.5;addy,100;diffusealpha,0;);
--top left
LoadActor("ScreenTitleMenu underlay/".. image .."_flytop") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc1;rotationy,180;zoom,0;diffusealpha,0;accelerate,0.8;addx,-280;zoom,0.2;diffusealpha,0.3;sleep,0;zoom,0;);
};
--top right
LoadActor("ScreenTitleMenu underlay/".. image .."_flytop") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc1;zoom,0;diffusealpha,0;accelerate,0.8;addx,280;zoom,0.2;diffusealpha,0.2;sleep,0;zoom,0;);
};
}
--up 200
t[#t+1] = Def.ActorFrame {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(x,_screen.cx;y,_screen.cy+200;diffusealpha,1;decelerate,0.4;addy,-200;accelerate,0.5;addy,100;diffusealpha,0;);
--bottom left
LoadActor("ScreenTitleMenu underlay/".. image .."_flybottom") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc1;rotationy,180;zoom,0;diffusealpha,0;accelerate,0.8;addx,-200;zoom,1.0;diffusealpha,0.3;sleep,0;zoom,0;);
};
--bottom right
LoadActor("ScreenTitleMenu underlay/".. image .."_flybottom") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc1;zoom,0;diffusealpha,0;accelerate,0.8;addx,200;zoom,1.0;diffusealpha,0.2;sleep,0;zoom,0;);
};
}
--up 250
t[#t+1] = Def.ActorFrame {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(x,_screen.cx;y,_screen.cy+200;diffusealpha,1;decelerate,0.4;addy,-250;accelerate,0.5;addy,100;diffusealpha,0;);
-- bottom left
LoadActor("ScreenTitleMenu underlay/".. image .."_flybottom") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc2;rotationy,180;zoom,0;diffusealpha,0;accelerate,0.8;addx,-200;zoom,1.5;diffusealpha,0.6;sleep,0;zoom,0;);
};
LoadActor("ScreenTitleMenu underlay/".. image .."_flybottom") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc1;rotationy,180;zoom,0;diffusealpha,0;accelerate,0.8;addx,-200;zoom,0.8;diffusealpha,0.3;sleep,0;zoom,0;);
};
-- bottom right
LoadActor("ScreenTitleMenu underlay/".. image .."_flybottom") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc1;zoom,0;diffusealpha,0;accelerate,0.8;addx,200;zoom,1.5;diffusealpha,0.4;sleep,0;zoom,0;);
};
LoadActor("ScreenTitleMenu underlay/".. image .."_flybottom") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc2;zoom,0;diffusealpha,0;accelerate,0.8;addx,200;zoom,0.8;diffusealpha,0.2;sleep,0;zoom,0;);
};
}
--up 150, out 280
t[#t+1] = Def.ActorFrame {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(x,_screen.cx;y,_screen.cy+200;diffusealpha,1;decelerate,0.4;addy,-150;accelerate,0.5;addy,100;diffusealpha,0;);
--bottom left
LoadActor("ScreenTitleMenu underlay/".. image .."_flybottom") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc1;rotationy,180;zoom,0;diffusealpha,0;accelerate,0.8;addx,-280;zoom,1.2;diffusealpha,0.3;sleep,0;zoom,0;);
};
--bottom right
LoadActor("ScreenTitleMenu underlay/".. image .."_flybottom") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc1;zoom,0;diffusealpha,0;accelerate,0.8;addx,280;zoom,1.2;diffusealpha,0.2;sleep,0;zoom,0;);
};
}
--up 250, out 280
t[#t+1] = Def.ActorFrame {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(x,_screen.cx; y,_screen.cy+200;diffusealpha,1; decelerate,0.4; addy,-250; accelerate,0.5; addy,100; diffusealpha,0;);
--bottom left
LoadActor("ScreenTitleMenu underlay/".. image .."_flybottom") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc1;rotationy,180;zoom,0;diffusealpha,0;accelerate,0.8;addx,-280;zoom,0.2;diffusealpha,0.3;sleep,0;zoom,0;);
};
--bottom right
LoadActor("ScreenTitleMenu underlay/".. image .."_flybottom") .. {
InitCommand=cmd(diffusealpha,0);
OnCommand=cmd(diffuse,dc1;zoom,0;diffusealpha,0;accelerate,0.8;addx,280;zoom,0.2;diffusealpha,0.2;sleep,0;zoom,0;);
};
}
return t;
|
return function (Data)
local NeedAddReturn = false
return ValidLua(Data, NeedAddReturn)
end
|
name = "[SW]托托莉Totooria"
description =
[[托托莉.赫尔蒙德 阿兰德的炼金术师
初始智商高,血量低,攻击力低
吃聪明豆升级,吃龙人心洗点
不同的等级能自动学到不同的生存特技
可以读书,可以制造更多的物品
自带托托莉的法杖,可以升级
高级的法杖能有更多的用处
]]
author = "柴柴"
version = "1.9.0"
forumthread = ""
api_version = 6
dont_starve_compatible = true
reign_of_giants_compatible = true
dst_compatible = false
shipwrecked_compatible = true
icon_atlas = "modicon.xml"
icon = "modicon.tex"
configuration_options = {
{
name = "Language",
label = "语言Language",
options = {
{description = "English", data = false},
{description = "简体中文", data = true}
},
default = true
},
{
name = "Sound",
label = "托托莉声音Sound",
options = {
{description = "Wendy", data = false},
{description = "Willow", data = true}
},
default = true
},
{
name = "TotooriaSpeech",
label = "托托莉对话Speech",
options = {
{description = "Wilson", data = 1},
{description = "Willow", data = 2},
{description = "Walani", data = 3},
{description = "Wigfrid", data = 4},
{description = "Wickerbottom", data = 5}
},
default = 1
},
{
name = "Hack",
label = "法杖当砍刀Hack",
options = {
{description = "Yes", data = true},
{description = "No", data = false}
},
default = false
},
{
name = "Dig",
label = "法杖当铲子Dig",
options = {
{description = "Yes", data = true},
{description = "No", data = false}
},
default = false
},
{
name = "Hammer",
label = "法杖当锤子Hammer",
options = {
{description = "Yes", data = true},
{description = "No", data = false}
},
default = true
}
}
|
local AddPrefabPostInit = AddPrefabPostInit
GLOBAL.setfenv(1, GLOBAL)
local nightmare_prefabs =
{
"crawlinghorror",
"terrorbeak",
"swimminghorror",
}
local function sanity_reward_postinit(inst)
if not TheWorld.ismastersim then return end
local oldOnKilledByOther = inst.components.combat.onkilledbyother
inst.components.combat.onkilledbyother = function(inst, attacker)
if attacker and attacker:HasTag("nightmare_twins") and attacker.components.sanity then
attacker.components.sanity:DoDelta((inst.sanityreward or TUNING.SANITY_SMALL) * 0.5)
else
oldOnKilledByOther(inst, attacker)
end
end
end
for _, prefab in ipairs(nightmare_prefabs) do
AddPrefabPostInit(prefab, sanity_reward_postinit)
end
local function new_onpickedfn(inst, picker)
local pos = inst:GetPosition()
if picker then
if picker.components.sanity and not picker:HasTag("plantkin") and not picker:HasTag("nightmarebreaker") then -- changed part from original fn
picker.components.sanity:DoDelta(TUNING.SANITY_TINY)
end
if inst.animname == "rose" and
picker.components.combat and
not (picker.components.inventory and picker.components.inventory:EquipHasTag("bramble_resistant")) then
picker.components.combat:GetAttacked(inst, TUNING.ROSE_DAMAGE)
picker:PushEvent("thorns")
end
end
if not inst.planted then
TheWorld:PushEvent("beginregrowth", inst)
end
inst:Remove()
TheWorld:PushEvent("plantkilled", { doer = picker, pos = pos }) --this event is pushed
end
AddPrefabPostInit("flower", function(inst)
if not TheWorld.ismastersim then return end
if inst.components.pickable then
inst.components.pickable.onpickedfn = new_onpickedfn
end
end)
local function new_onpickedfn_evil(inst, picker)
if picker and picker.components.sanity and not picker:HasTag("nightmarebreaker") then
picker.components.sanity:DoDelta(-TUNING.SANITY_TINY)
end
inst:Remove()
end
AddPrefabPostInit("flower_evil", function(inst)
if not TheWorld.ismastersim then return end
if inst.components.pickable then
inst.components.pickable.onpickedfn = new_onpickedfn_evil
end
end)
|
local I2C = require("hardware.i2c")
local M = Class()
local REG_SECOND = 0x0
local REG_MINUTE = 0x1
local REG_HOUR = 0x2
local REG_DAY = 0x3
local REG_DATE = 0x4
local REG_MONTH = 0x5
local REG_YEAR = 0x6
local REG_CTRL = 0x7
local REG_RAM = 0x8
function M:init(bus)
self.i2c = I2C.new(bus, 0x68)
if self:readReg(REG_CTRL) & 0x20 ~= 0 then
self:setTime({ second = 0, minute = 0, hour = 0, day = 5, date = 1, month = 1, year = 2016 })
self:writeReg(REG_CTRL, 0x0)
end
end
function M:bcd2bin(bcd)
return (bcd // 16 * 10 + bcd % 16)
end
function M:bin2bcd(bin)
return (bin // 10 * 16 + bin % 10)
end
function M:writeReg(reg, val)
self.i2c:write(string.char(reg, val))
return self
end
function M:readReg(reg)
self.i2c:write(string.char(reg))
return string.byte(self.i2c:read(1) or "0", 1, 1)
end
function M:writeRam(offset, val)
if type(offset) == "number" and offset >= 0 and offset <= 55 then
self:writeReg(REG_RAM + offset, val)
end
return self
end
function M:readRam(offset)
if type(offset) == "number" and offset >= 0 and offset <= 55 then
return self:readReg(REG_RAM + offset)
else
return nil
end
end
--[[
-------------------------------------------------------------
| OUT | | OSF | SQWE | | | RS1 | RS0 | SQW Output |
-------------------------------------------------------------
| X | | 0 | 1 | | | 0 | 0 | 1Hz |
| X | | 0 | 1 | | | 0 | 1 | 4.096kHz |
| X | | 0 | 1 | | | 1 | 0 | 8.192kHz |
| X | | 0 | 1 | | | 1 | 1 | 32.768kHz |
| 0 | | 0 | 0 | | | X | X | 0 |
| 1 | | 0 | 0 | | | X | X | 1 |
-------------------------------------------------------------
--]]
function M:squareWave(hz)
local ctrl = 0x0
if hz == 1 then
ctrl = 0x10
elseif hz == 4096 then
ctrl = 0x11
elseif hz == 8192 then
ctrl = 0x12
elseif hz == 32768 then
ctrl = 0x13
end
self:writeReg(REG_CTRL, ctrl)
return self
end
function M:outputLevel(level)
local ctrl = 0x0
if type(level) == "number" and level ~= 0 then
ctrl = 0x80
end
self:writeReg(REG_CTRL, ctrl)
return self
end
function M:setTime(t)
local t = t or {}
if t.second ~= nil and t.second >= 0 and t.second <= 59 then
self:writeReg(REG_SECOND, self:bin2bcd(t.second) & 0x7f)
end
if t.minute ~= nil and t.minute >= 0 and t.minute <= 59 then
self:writeReg(REG_MINUTE, self:bin2bcd(t.minute) & 0x7f)
end
if t.hour ~= nil and t.hour >= 0 and t.hour <= 23 then
self:writeReg(REG_HOUR, self:bin2bcd(t.hour) & 0x3f)
end
if t.day ~= nil and t.day >= 0 and t.day <= 6 then
self:writeReg(REG_DAY, self:bin2bcd(t.day + 1) & 0x7)
end
if t.date ~= nil and t.date >= 0 and t.date <= 31 then
self:writeReg(REG_DATE, self:bin2bcd(t.date) & 0x3f)
end
if t.month ~= nil and t.month >= 0 and t.month <= 12 then
self:writeReg(REG_MONTH, self:bin2bcd(t.month) & 0x1f)
end
if t.year ~= nil and t.year >= 2000 and t.year <= 2000 + 99 then
self:writeReg(REG_YEAR, self:bin2bcd(t.year - 2000) & 0xff)
end
return self
end
function M:getTime()
return {
second = self:bcd2bin(self:readReg(REG_SECOND) & 0x7f),
minute = self:bcd2bin(self:readReg(REG_MINUTE) & 0x7f),
hour = self:bcd2bin(self:readReg(REG_HOUR) & 0x3f),
day = self:bcd2bin(self:readReg(REG_DAY) & 0x7) - 1,
date = self:bcd2bin(self:readReg(REG_DATE) & 0x3f),
month = self:bcd2bin(self:readReg(REG_MONTH) & 0x1f),
year = self:bcd2bin(self:readReg(REG_YEAR) & 0xff) + 2000,
}
end
return M
|
-- Chinese Translation Valkyrie@CWDG
if GetLocale() ~= "zhCN" then return end
local media = LibStub("LibSharedMedia-3.0")
--Event and Damage option values
SCT.LOCALS.OPTION_EVENT1 = {name = "伤害", tooltipText = "显示受到的近战伤害与其他伤害(火焰、摔落等)"};
SCT.LOCALS.OPTION_EVENT2 = {name = "未击中", tooltipText = "显示敌人未击中你的近战攻击"};
SCT.LOCALS.OPTION_EVENT3 = {name = "闪避", tooltipText = "显示闪避的近战攻击"};
SCT.LOCALS.OPTION_EVENT4 = {name = "招架", tooltipText = "显示招架的近战攻击"};
SCT.LOCALS.OPTION_EVENT5 = {name = "格挡", tooltipText = "显示格挡的近战攻击"};
SCT.LOCALS.OPTION_EVENT6 = {name = "法术伤害", tooltipText = "显示受到的法术伤害"};
SCT.LOCALS.OPTION_EVENT7 = {name = "法术治疗", tooltipText = "显示受到的法术治疗"};
SCT.LOCALS.OPTION_EVENT8 = {name = "法术抵抗", tooltipText = "显示抵抗敌人的法术"};
SCT.LOCALS.OPTION_EVENT9 = {name = "不良效果", tooltipText = "显示受到的不良效果影响"};
SCT.LOCALS.OPTION_EVENT10 = {name = "吸收/其它", tooltipText = "显示对敌人伤害的吸收、反射、免疫效果等"};
SCT.LOCALS.OPTION_EVENT11 = {name = "生命过低", tooltipText = "生命值过低警告"};
SCT.LOCALS.OPTION_EVENT12 = {name = "法力过低", tooltipText = "法力值过低警告"};
SCT.LOCALS.OPTION_EVENT13 = {name = "能量获得", tooltipText = "显示透过药水、物品、增益效果等获得的法力值、怒气、能量(非正常恢复)"};
SCT.LOCALS.OPTION_EVENT14 = {name = "战斗标记", tooltipText = "显示进入、脱离战斗状态的提示信息"};
SCT.LOCALS.OPTION_EVENT15 = {name = "连击点", tooltipText = "显示获得的连击点数"};
SCT.LOCALS.OPTION_EVENT16 = {name = "荣誉获得", tooltipText = "显示获得的荣誉点数"};
SCT.LOCALS.OPTION_EVENT17 = {name = "Buff效果", tooltipText = "显示获得的增益效果"};
SCT.LOCALS.OPTION_EVENT18 = {name = "Buff消失", tooltipText = "显示从你身上消失的增益效果"};
SCT.LOCALS.OPTION_EVENT19 = {name = "可使用技能", tooltipText = "显示进入可使用状态的特定技能(斩杀、猫鼬撕咬、愤怒之锤等)"};
SCT.LOCALS.OPTION_EVENT20 = {name = "声望", tooltipText = "显示声望的提昇或降低"};
SCT.LOCALS.OPTION_EVENT21 = {name = "玩家治疗", tooltipText = "显示对别人的治疗"};
SCT.LOCALS.OPTION_EVENT22 = {name = "技能点数", tooltipText = "显示技能点数的提昇"};
SCT.LOCALS.OPTION_EVENT23 = {name = "击杀", tooltipText = "显示是否是由你的最后一击造成怪物死亡的。"};
SCT.LOCALS.OPTION_EVENT24 = {name = "被打断", tooltipText = "显示施法被中断提示。"};
--Check Button option values
SCT.LOCALS.OPTION_CHECK1 = { name = "启用SCT", tooltipText = "启用 Scrolling Combat Text"};
SCT.LOCALS.OPTION_CHECK2 = { name = "标记战斗信息", tooltipText = "在战斗信息两侧添加'*'标记"};
SCT.LOCALS.OPTION_CHECK3 = { name = "显示治疗者", tooltipText = "显示治疗你的玩家或生物的名字"};
SCT.LOCALS.OPTION_CHECK4 = { name = "文字向下滚动", tooltipText = "战斗信息向下滚动"};
SCT.LOCALS.OPTION_CHECK5 = { name = "重击效果", tooltipText = "以特效显示受到的致命一击或极效治疗"};
SCT.LOCALS.OPTION_CHECK6 = { name = "法术伤害类型", tooltipText = "显示你受到的法术伤害的类型"};
SCT.LOCALS.OPTION_CHECK7 = { name = "对伤害启用字体设定", tooltipText = "以SCT使用的字体显示游戏预设的伤害数字。\n\n注意:此设定必须重新登入才能生效。重新载入界面无效。"};
SCT.LOCALS.OPTION_CHECK8 = { name = "显示所有能量获得", tooltipText = "显示所有的能量获得,而不是仅显示战斗记录中出现的。 \n\n注意:必须先启用普通的“能量获得”事件。非常容易洗频。且德鲁伊在切换回施法者形态时会有不正常的现象。"};
SCT.LOCALS.OPTION_CHECK9 = { name = "FPS独立模式", tooltipText = "切换动画显示速度是否与画面的FPS同步。打开后动画速度会更稳定,且在电脑画面卡住或不顺的情况下,能够使SCT动画表现流畅速度。"};
SCT.LOCALS.OPTION_CHECK10 = { name = "显示过量治疗", tooltipText = "显示你的过量治疗值,必须先启用“玩家治疗”事件。"};
SCT.LOCALS.OPTION_CHECK11 = { name = "警报声音", tooltipText = "当发出警告时播放声音。"};
SCT.LOCALS.OPTION_CHECK12 = { name = "法术伤害颜色", tooltipText = "以不同的颜色显示不同类型的法术伤害(颜色不可更改)"};
SCT.LOCALS.OPTION_CHECK13 = { name = "启用自定义事件", tooltipText = "启用自定义事件。关闭后能节省大量记忆体的使用。"};
SCT.LOCALS.OPTION_CHECK14 = { name = "启用低耗模式", tooltipText = "启用低CPU消耗模式。低耗模式使用WoW内建的事件来驱动大部分SCT事件,减少对战斗记录的监控分析。能够提高整体效能,但部分功能将不能使用,包括自定事件。\n\n请注意这些WoW事件回馈的信息不如战斗记录那麽丰富,而且可能会出错。"};
SCT.LOCALS.OPTION_CHECK15 = { name = "闪烁", tooltipText = "使得致命/极效的效果呈现闪烁状态。"};
SCT.LOCALS.OPTION_CHECK16 = { name = "横扫/碾压", tooltipText = "显示横扫 ~150~ 以及碾压 ^150^ 攻击"};
SCT.LOCALS.OPTION_CHECK17 = { name = "你的持续治疗", tooltipText = "显示你对别的角色所施放的持续性治疗法术效果。请注意如果你对很多人放恢复或是回春术的话,画面上将会有一堆HOT信息。"};
SCT.LOCALS.OPTION_CHECK18 = { name = "在血条上显示治疗", tooltipText = "在你对玩家施放治疗法术的血条上,启用或禁用显示你要治疗的动作。\n\n友方的血条必须为开放状态,并且你必须能看见血条。本功能不一定100%正常工作。若为正常工作,治疗文字将显示在默认位置。\n\n若要禁用的话,需重新加载UI才可以。"};
SCT.LOCALS.OPTION_CHECK19 = { name = "关闭WoW自带治疗显示", tooltipText = "启用或禁用(2.1版本)治疗显示文字。"};
SCT.LOCALS.OPTION_CHECK20 = { name = "显示图标", tooltipText = "显示你施放的法术技能图标。"};
--Slider options values
SCT.LOCALS.OPTION_SLIDER1 = { name="文字动画速度", minText="快", maxText="慢", tooltipText = "调整动态文字滚动速度"};
SCT.LOCALS.OPTION_SLIDER2 = { name="文字大小", minText="小", maxText="大", tooltipText = "调整动态文字的大小"};
SCT.LOCALS.OPTION_SLIDER3 = { name="生命百分比", minText="10%", maxText="90%", tooltipText = "设定玩家生命值降低到几%时发出警告"};
SCT.LOCALS.OPTION_SLIDER4 = { name="法力百分比", minText="10%", maxText="90%", tooltipText = "设定玩家法力值降低到几%时发出警告"};
SCT.LOCALS.OPTION_SLIDER5 = { name="文字透明度", minText="0%", maxText="100%", tooltipText = "调整动态文字的透明度"};
SCT.LOCALS.OPTION_SLIDER6 = { name="文字移动距离", minText="小", maxText="大", tooltipText = "调整动态文字间的距离"};
SCT.LOCALS.OPTION_SLIDER7 = { name="文字横坐标", minText="-600", maxText="600", tooltipText = "调整以文字中间点为准,其显示的水平位置"};
SCT.LOCALS.OPTION_SLIDER8 = { name="文字纵坐标", minText="-400", maxText="400", tooltipText = "调整以文字中间点为准,其显示的垂直位置"};
SCT.LOCALS.OPTION_SLIDER9 = { name="静态文字横坐标", minText="-600", maxText="600", tooltipText = "调整以文字中间点为准,静态信息其显示的水平位置"};
SCT.LOCALS.OPTION_SLIDER10 = { name="静态文字纵坐标", minText="-400", maxText="400", tooltipText = "调整以文字中间点为准,静态信息其显示的垂直位置"};
SCT.LOCALS.OPTION_SLIDER11 = { name="静态信息淡出速度", minText="快", maxText="慢", tooltipText = "调整静态信息淡出的速度"};
SCT.LOCALS.OPTION_SLIDER12 = { name="静态信息字体大小", minText="小", maxText="大", tooltipText = "调整静态信息的文字大小"};
SCT.LOCALS.OPTION_SLIDER13 = { name="治疗者过滤", minText="0", maxText="500", tooltipText = "调整SCT要显示的最小的治疗量的值,用於不想显示如恢复,回春术,祝福等小量的治疗效果时"};
SCT.LOCALS.OPTION_SLIDER14 = { name="法力过滤", minText="0", maxText="500", tooltipText = "设定SCT要显示的数字的最低法力获得的门槛值.对於过滤掉少量的法力恢复如图腾,祝福效果...等等."};
SCT.LOCALS.OPTION_SLIDER15 = { name="弧形条间距", minText="0", maxText="200", tooltipText = "控制HUD动画效果和水平中点距离。对于想要信息尽量靠中间显示,但是又想要调整和水平中间点距离时使用."};
SCT.LOCALS.OPTION_SLIDER16 = { name="简写法术名", minText="1", maxText="30", tooltipText = "法术名用简写方式来代替。"};
SCT.LOCALS.OPTION_SLIDER17 = { name="伤害过滤", minText="0", maxText="500", tooltipText = "过滤最小伤害数值,比如dot等..."};
--Spell Color options]
SCT.LOCALS.OPTION_COLOR1 = { name=SPELL_SCHOOL0_CAP, tooltipText = "设定"..SPELL_SCHOOL0_CAP.."法术的显示颜色"};
SCT.LOCALS.OPTION_COLOR2 = { name=SPELL_SCHOOL1_CAP, tooltipText = "设定"..SPELL_SCHOOL1_CAP.."法术的显示颜色"};
SCT.LOCALS.OPTION_COLOR3 = { name=SPELL_SCHOOL2_CAP, tooltipText = "设定"..SPELL_SCHOOL2_CAP.."法术的显示颜色"};
SCT.LOCALS.OPTION_COLOR4 = { name=SPELL_SCHOOL3_CAP, tooltipText = "设定"..SPELL_SCHOOL3_CAP.."法术的显示颜色"};
SCT.LOCALS.OPTION_COLOR5 = { name=SPELL_SCHOOL4_CAP, tooltipText = "设定"..SPELL_SCHOOL4_CAP.."法术的显示颜色"};
SCT.LOCALS.OPTION_COLOR6 = { name=SPELL_SCHOOL5_CAP, tooltipText = "设定"..SPELL_SCHOOL5_CAP.."法术的显示颜色"};
SCT.LOCALS.OPTION_COLOR7 = { name=SPELL_SCHOOL6_CAP, tooltipText = "设定"..SPELL_SCHOOL6_CAP.."法术的显示颜色"};
--Misc option values
SCT.LOCALS.OPTION_MISC1 = {name="SCT设定"..SCT.Version, tooltipText = "按左键拖曳来移动"};
SCT.LOCALS.OPTION_MISC2 = {name="关闭", tooltipText = "关闭法术颜色设定" };
SCT.LOCALS.OPTION_MISC3 = {name="编辑", tooltipText = "编辑法术显示颜色" };
SCT.LOCALS.OPTION_MISC4 = {name="杂项设定"};
SCT.LOCALS.OPTION_MISC5 = {name="警告设定"};
SCT.LOCALS.OPTION_MISC6 = {name="动画设定"};
SCT.LOCALS.OPTION_MISC7 = {name="选择设定档"};
SCT.LOCALS.OPTION_MISC8 = {name="存档并关闭", tooltipText = "储存所有目前设定,并关闭设定选单"};
SCT.LOCALS.OPTION_MISC9 = {name="重置", tooltipText = ">>警告<<\n\n确定要还原所有SCT设定为预设值吗?"};
SCT.LOCALS.OPTION_MISC10 = {name="设定档", tooltipText = "选择其它角色的设定档"};
SCT.LOCALS.OPTION_MISC11 = {name="载入", tooltipText = "载入其它角色的设定档到此角色"};
SCT.LOCALS.OPTION_MISC12 = {name="删除", tooltipText = "删除一个角色设定档"};
SCT.LOCALS.OPTION_MISC13 = {name="文字设定" };
SCT.LOCALS.OPTION_MISC14 = {name="框架1"};
SCT.LOCALS.OPTION_MISC15 = {name="静态信息"};
SCT.LOCALS.OPTION_MISC16 = {name="动画效果"};
SCT.LOCALS.OPTION_MISC17 = {name="法术设定"};
SCT.LOCALS.OPTION_MISC18 = {name="视窗"};
SCT.LOCALS.OPTION_MISC19 = {name="法术"};
SCT.LOCALS.OPTION_MISC20 = {name="框架2"};
SCT.LOCALS.OPTION_MISC21 = {name="事件"};
SCT.LOCALS.OPTION_MISC22 = {name="典型设定档", tooltipText = "载入典型设定档,使得SCT的动作行为接近内定值。"};
SCT.LOCALS.OPTION_MISC23 = {name="效能设定档", tooltipText = "载入高效能配置。选取所有的设定来得到最佳的效能。"};
SCT.LOCALS.OPTION_MISC24 = {name="分割设定档", tooltipText = "载入分割配置。使得伤害和事件显示在右侧,治疗和增益效果在左侧。"};
SCT.LOCALS.OPTION_MISC25 = {name="Grayhoof设定档", tooltipText = "载入Grayhoof配置。使SCT有如Grayhoof(作者)在使用它时一般的运作"};
SCT.LOCALS.OPTION_MISC26 = {name="内建设定档", tooltipText = ""};
SCT.LOCALS.OPTION_MISC27 = {name="分割的SCTD设定档", tooltipText = "载入分割SCTD配置。如果有安装SCTD,会使得收到的事件在右侧,输出的事件在左侧,其它的事件在上方。"};
SCT.LOCALS.OPTION_MISC28 = {name="测试", tooltipText = "在每个框架中生成测试事件。"};
--Animation Types
SCT.LOCALS.OPTION_SELECTION1 = { name="动画类型", tooltipText = "选择动态文字动画类型", table = {[1] = "垂直(预设)",[2] = "彩虹",[3] = "水平",[4] = "斜下", [5] = "斜上", [6] = "飘洒", [7] = "HUD曲线", [8] = "HUD斜向"}};
SCT.LOCALS.OPTION_SELECTION2 = { name="弹出方式", tooltipText = "选择动态文字弹出方式", table = {[1] = "交错",[2] = "伤害向左",[3] = "伤害向右", [4] = "全部向左", [5] = "全部向右"}};
SCT.LOCALS.OPTION_SELECTION3 = { name="战斗字体", tooltipText = "选择你使用的字体", table = media:List("font")};
SCT.LOCALS.OPTION_SELECTION4 = { name="字体描边", tooltipText = "选择动态文字字体描边类型", table = {[1] = "无",[2] = "细",[3] = "粗"}};
SCT.LOCALS.OPTION_SELECTION5 = { name="静态信息字体", tooltipText = "选择静态信息字体", table = media:List("font")};
SCT.LOCALS.OPTION_SELECTION6 = { name="静态信息字体轮廓", tooltipText = "选择静态信息字体轮廓类型", table = {[1] = "无",[2] = "细",[3] = "粗"}};
SCT.LOCALS.OPTION_SELECTION7 = { name="对齐", tooltipText = "设定文字对齐。在使用HUD动画或是垂直显示时最有用。「HUD方式对齐」将使得左侧文字为靠右对齐/右侧文字为靠左对齐。", table = {[1] = "左",[2] = "居中",[3] = "右", [4] = "HUD方式对齐"}};
SCT.LOCALS.OPTION_SELECTION8 = { name="法术名缩写", tooltipText = "缩写方式", table = {[1] = "切断",[2] = "缩写"}};
SCT.LOCALS.OPTION_SELECTION9 = { name="图标的设置", tooltipText = "设置图标的位置.", table = {[1] = "左", [2] = "右", [3] = "内部", [4] = "外部",}};
|
local theme_path = require("gears.filesystem").get_configuration_dir() .. "theme/"
local theme = {}
theme.wallpaper_name = "lake"
theme.wallpaper_dir = theme_path .. "dynamic-wallpaper"
theme.wallpaper = function(s)
local h = os.date("*t", os.time()).hour
return theme.wallpaper_dir .. "/" .. theme.wallpaper_name .. "/" .. tostring(h) .. ".jpg"
end
theme.font = "Play 13"
theme.icon_theme = "Papirus"
theme.fg_normal = "#DDDDDD"
theme.fg_focus = "#FFFFFF"
theme.fg_urgent = "#CC9393"
theme.bg_normal = "#00000080"
theme.bg_focus = "#2BA7D7"
theme.bg_urgent = "#3F3F3F"
theme.bg_systray = "#000000"
theme.useless_gap = 20
theme.border_width = 10
theme.border_normal = "#00000080"
theme.border_focus = "#2BA7D7"
theme.border_marked = "#CC9393"
theme.titlebar_bg_focus = "#2BA7D7"
theme.titlebar_bg_normal = "#00000080"
theme.titlebar_close_button_focus = theme_path .. "close.png"
theme.titlebar_close_button_normal = theme_path .. "close.png"
theme.titlebar_maximized_button_focus_active = theme_path .. "maximized.png"
theme.titlebar_maximized_button_normal_active = theme_path .. "maximized.png"
theme.titlebar_maximized_button_focus_inactive = theme_path .. "maximized.png"
theme.titlebar_maximized_button_normal_inactive = theme_path .. "maximized.png"
theme.titlebar_client_menu_button_focus_active = theme_path .. "client_menu.png"
theme.titlebar_client_menu_button_normal_active = theme_path .. "client_menu.png"
theme.titlebar_client_menu_button_focus_inactive = theme_path .. "client_menu.png"
theme.titlebar_client_menu_button_normal_inactive = theme_path .. "client_menu.png"
return theme
|
AddCSLuaFile()
local function rb655_property_filter( filtor, ent, ply )
if ( type( filtor ) == "string" && filtor != ent:GetClass() ) then return false end
if ( type( filtor ) == "table" && !table.HasValue( filtor, ent:GetClass() ) ) then return false end
if ( type( filtor ) == "function" && !filtor( ent, ply ) ) then return false end
return true
end
function AddEntFunctionProperty( name, label, pos, filtor, func, icon )
properties.Add( name, {
MenuLabel = label,
MenuIcon = icon,
Order = pos,
Filter = function( self, ent, ply )
if ( !IsValid( ent ) or !gamemode.Call( "CanProperty", ply, name, ent ) ) then return false end
if ( !rb655_property_filter( filtor, ent, ply ) ) then return false end
return true
end,
Action = function( self, ent )
self:MsgStart()
net.WriteEntity( ent )
self:MsgEnd()
end,
Receive = function( self, length, ply )
local ent = net.ReadEntity()
if ( !IsValid( ply ) or !IsValid( ent ) or !self:Filter( ent, ply ) ) then return false end
func( ent, ply )
end
} )
end
function AddEntFireProperty( name, label, pos, class, input, icon )
AddEntFunctionProperty( name, label, pos, class, function( e ) e:Fire( unpack( string.Explode( " ", input ) ) ) end, icon )
end
local ExplodeIcon = "icon16/bomb.png"
local EnableIcon = "icon16/tick.png"
local DisableIcon = "icon16/cross.png"
local ToggleIcon = "icon16/arrow_switch.png"
local SyncFuncs = {}
SyncFuncs.prop_door_rotating = function( ent )
ent:SetNWBool( "Locked", ent:GetSaveTable().m_bLocked )
local state = ent:GetSaveTable().m_eDoorState
ent:SetNWBool( "Closed", state == 0 or state == 3 )
end
SyncFuncs.func_door = function( ent )
ent:SetNWBool( "Locked", ent:GetSaveTable().m_bLocked )
--[[local state = ent:GetSaveTable().m_eDoorState
ent:SetNWBool( "Closed", state == 0 or state == 3 )]]
end
SyncFuncs.func_door_rotating = function( ent )
ent:SetNWBool( "Locked", ent:GetSaveTable().m_bLocked )
--[[local state = ent:GetSaveTable().m_eDoorState
ent:SetNWBool( "Closed", state == 0 or state == 3 )]]
end
SyncFuncs.prop_vehicle_jeep = function( ent )
ent:SetNWBool( "Locked", ent:GetSaveTable().VehicleLocked )
ent:SetNWBool( "HasDriver", IsValid( ent:GetDriver() ) )
ent:SetNWBool( "m_bRadarEnabled", ent:GetSaveTable().m_bRadarEnabled )
end
SyncFuncs.prop_vehicle_airboat = function( ent )
ent:SetNWBool( "Locked", ent:GetSaveTable().VehicleLocked )
ent:SetNWBool( "HasDriver", IsValid( ent:GetDriver() ) )
end
--[[SyncFuncs.prop_vehicle_prisoner_pod = function( ent )
ent:SetNWBool( "Locked", ent:GetSaveTable().VehicleLocked )
ent:SetNWBool( "HasDriver", IsValid( ent:GetDriver() ) )
end]]
SyncFuncs.func_tracktrain = function( ent )
ent:SetNWInt( "m_dir", ent:GetSaveTable().m_dir )
ent:SetNWBool( "m_moving", ent:GetSaveTable().speed != 0 )
--[[local driver = ent:GetDriver()
ent:SetNWBool( "HasDriver", IsValid( driver ) )]]
end
hook.Add( "Tick", "rb655_prop_sync", function()
if ( CLIENT ) then return end
for id, ply in pairs( player.GetAll() ) do
local ent = ply:GetEyeTrace().Entity
if ( !IsValid( ent ) ) then continue end
if ( SyncFuncs[ ent:GetClass() ] ) then
SyncFuncs[ ent:GetClass() ]( ent )
end
end
end )
-------------------------------------------------- Half - Life 2 Specific --------------------------------------------------
AddEntFireProperty( "rb655_door_open", "Open", 655, function( ent, ply )
if ( !ent:GetNWBool( "Closed" ) && ent:GetClass() == "prop_door_rotating" ) then return false end
return rb655_property_filter( { "prop_door_rotating", "func_door_rotating", "func_door" }, ent, ply )
end, "Open", "icon16/door_open.png" )
AddEntFireProperty( "rb655_door_close", "Close", 656, function( ent, ply )
if ( ent:GetNWBool( "Closed" ) && ent:GetClass() == "prop_door_rotating" ) then return false end
return rb655_property_filter( { "prop_door_rotating", "func_door_rotating", "func_door" }, ent, ply )
end, "Close", "icon16/door.png" )
AddEntFireProperty( "rb655_door_lock", "Lock", 657, function( ent, ply )
if ( ent:GetNWBool( "Locked" ) && ent:GetClass() != "prop_vehicle_prisoner_pod" ) then return false end
return rb655_property_filter( { "prop_door_rotating", "func_door_rotating", "func_door", "prop_vehicle_jeep", "prop_vehicle_airboat", "prop_vehicle_prisoner_pod" }, ent, ply )
end, "Lock", "icon16/lock.png" )
AddEntFireProperty( "rb655_door_unlock", "Unlock", 658, function( ent, ply )
if ( !ent:GetNWBool( "Locked" ) && ent:GetClass() != "prop_vehicle_prisoner_pod" ) then return false end
return rb655_property_filter( { "prop_door_rotating", "func_door_rotating", "func_door", "prop_vehicle_jeep", "prop_vehicle_airboat", "prop_vehicle_prisoner_pod" }, ent, ply )
end, "Unlock", "icon16/lock_open.png" )
AddEntFireProperty( "rb655_func_movelinear_open", "Start", 655, "func_movelinear", "Open", "icon16/arrow_right.png" )
AddEntFireProperty( "rb655_func_movelinear_close", "Return", 656, "func_movelinear", "Close", "icon16/arrow_left.png" )
AddEntFireProperty( "rb655_func_tracktrain_StartForward", "Start Forward", 655, function( ent, ply )
if ( ent:GetNWInt( "m_dir" ) == 1 ) then return false end
return rb655_property_filter( "func_tracktrain", ent, ply )
end, "StartForward", "icon16/arrow_right.png" )
AddEntFireProperty( "rb655_func_tracktrain_StartBackward", "Start Backward", 656, function( ent, ply )
if ( ent:GetNWInt( "m_dir" ) == -1 ) then return false end
return rb655_property_filter( "func_tracktrain", ent, ply )
end, "StartBackward", "icon16/arrow_left.png" )
--AddEntFireProperty( "rb655_func_tracktrain_Reverse", "Reverse", 657, "func_tr2acktrain", "Reverse", "icon16/arrow_undo.png" ) -- Same as two above
AddEntFireProperty( "rb655_func_tracktrain_Stop", "Stop", 658, function( ent, ply )
if ( !ent:GetNWBool( "m_moving" ) ) then return false end
return rb655_property_filter( "func_tracktrain", ent, ply )
end, "Stop", "icon16/shape_square.png" )
AddEntFireProperty( "rb655_func_tracktrain_Resume", "Resume", 659, function( ent, ply )
if ( ent:GetNWInt( "m_moving" ) ) then return false end
return rb655_property_filter( "func_tracktrain", ent, ply )
end, "Resume", "icon16/resultset_next.png" )
--AddEntFireProperty( "rb655_func_tracktrain_Toggle", "Toggle", 660, "func_track2train", "Toggle", ToggleIcon ) -- Same as two above
AddEntFireProperty( "rb655_breakable_break", "Break", 655, function( ent, ply )
if ( ent:Health() < 1 ) then return false end
return rb655_property_filter( { "func_breakable", "func_physbox", "prop_physics", "func_pushable" }, ent, ply )
end, "Break", ExplodeIcon ) -- Do not include item_item_crate, it insta crashes the server, dunno why.
AddEntFireProperty( "rb655_turret_toggle", "Toggle", 655, { "npc_combine_camera", "npc_turret_ceiling", "npc_turret_floor" }, "Toggle", ToggleIcon )
AddEntFireProperty( "rb655_self_destruct", "Self Destruct", 656, { "npc_turret_floor", "npc_helicopter" }, "SelfDestruct", ExplodeIcon )
AddEntFunctionProperty( "rb655_turret_ammo_remove", "Deplete Ammo", 657, function( ent )
if ( bit.band( ent:GetSpawnFlags(), 256 ) == 256 ) then return false end
if ( ent:GetClass() == "npc_turret_floor" or ent:GetClass() == "npc_turret_ceiling" ) then return true end
return false
end, function( ent )
ent:SetKeyValue( "spawnflags", bit.bor( ent:GetSpawnFlags(), 256 ) )
ent:Activate()
end, "icon16/delete.png" )
AddEntFunctionProperty( "rb655_turret_ammo_restore", "Restore Ammo", 658, function( ent )
if ( bit.band( ent:GetSpawnFlags(), 256 ) == 0 ) then return false end
if ( ent:GetClass() == "npc_turret_floor" or ent:GetClass() == "npc_turret_ceiling" ) then return true end
return false
end, function( ent )
ent:SetKeyValue( "spawnflags", bit.bxor( ent:GetSpawnFlags(), 256 ) )
ent:Activate()
end, "icon16/add.png" )
AddEntFunctionProperty( "rb655_turret_make_friendly", "Make Friendly", 659, function( ent )
if ( bit.band( ent:GetSpawnFlags(), 512 ) == 512 ) then return false end
if ( ent:GetClass() == "npc_turret_floor" ) then return true end
return false
end, function( ent )
ent:SetKeyValue( "spawnflags", bit.bor( ent:GetSpawnFlags(), SF_FLOOR_TURRET_CITIZEN ) )
--ent:SetMaterial( "models/combine_turrets/floor_turret/floor_turret_citizen" )
ent:Activate()
end, "icon16/user_green.png" )
AddEntFunctionProperty( "rb655_turret_make_hostile", "Make Hostile", 660, function( ent )
if ( bit.band( ent:GetSpawnFlags(), 512 ) == 0 ) then return false end
if ( ent:GetClass() == "npc_turret_floor" ) then return true end
return false
end, function( ent )
ent:SetKeyValue( "spawnflags", bit.bxor( ent:GetSpawnFlags(), SF_FLOOR_TURRET_CITIZEN ) )
ent:Activate()
end, "icon16/user_red.png" )
AddEntFireProperty( "rb655_suitcharger_recharge", "Recharge", 655, "item_suitcharger", "Recharge", "icon16/arrow_refresh.png" )
AddEntFireProperty( "rb655_manhack_jam", "Jam", 655, "npc_manhack", "InteractivePowerDown", ExplodeIcon )
AddEntFireProperty( "rb655_scanner_mineadd", "Equip Mine", 655, "npc_clawscanner", "EquipMine", "icon16/add.png" )
AddEntFireProperty( "rb655_scanner_minedeploy", "Deploy Mine", 656, "npc_clawscanner", "DeployMine", "icon16/arrow_down.png" ) -- m_bIsOpen
AddEntFireProperty( "rb655_scanner_disable_spotlight", "Disable Spotlight", 658, { "npc_clawscanner", "npc_cscanner" }, "DisableSpotlight", DisableIcon ) -- SpotlightDisabled
-- AddEntFireProperty( "rb655_dropship_d1", "1", 655, "npc_combinedropship", "DropMines 1", DisableIcon )
AddEntFireProperty( "rb655_rollermine_selfdestruct", "Self Destruct", 655, "npc_rollermine", "InteractivePowerDown", ExplodeIcon )
AddEntFireProperty( "rb655_rollermine_turnoff", "Turn Off", 656, "npc_rollermine", "TurnOff", DisableIcon ) -- m_bTurnedOn
AddEntFireProperty( "rb655_rollermine_turnon", "Turn On", 657, "npc_rollermine", "TurnOn", EnableIcon )
AddEntFireProperty( "rb655_helicopter_gun_on", "Enable Turret", 655, "npc_helicopter", "GunOn", EnableIcon ) -- m_fHelicopterFlags = 1?
AddEntFireProperty( "rb655_helicopter_gun_off", "Disable Turret", 656, "npc_helicopter", "GunOff", DisableIcon ) -- m_fHelicopterFlags = 0?
AddEntFireProperty( "rb655_helicopter_dropbomb", "Drop Bomb", 657, "npc_helicopter", "DropBomb", "icon16/arrow_down.png" )
AddEntFireProperty( "rb655_helicopter_norm_shoot", "Start Normal Shooting", 660, "npc_helicopter", "StartNormalShooting", "icon16/clock.png" ) -- m_nShootingMode = 0
AddEntFireProperty( "rb655_helicopter_long_shoot", "Start Long Cycle Shooting", 661, "npc_helicopter", "StartLongCycleShooting", "icon16/clock_red.png" ) -- m_nShootingMode = 1
AddEntFireProperty( "rb655_helicopter_deadly_on", "Enable Deadly Shooting", 662, "npc_helicopter", "EnableDeadlyShooting", EnableIcon ) -- m_bDeadlyShooting
AddEntFireProperty( "rb655_helicopter_deadly_off", "Disable Deadly Shooting", 663, "npc_helicopter", "DisableDeadlyShooting", DisableIcon )
AddEntFireProperty( "rb655_gunship_OmniscientOn", "Enable Omniscient", 655, "npc_combinegunship", "OmniscientOn", EnableIcon ) -- m_fOmniscient
AddEntFireProperty( "rb655_gunship_OmniscientOff", "Disable Omniscient", 656, "npc_combinegunship", "OmniscientOff", DisableIcon )
AddEntFireProperty( "rb655_gunship_BlindfireOn", "Enable Blindfire", 657, "npc_combinegunship", "BlindfireOn", EnableIcon ) -- m_fBlindfire
AddEntFireProperty( "rb655_gunship_BlindfireOff", "Disable Blindfire", 658, "npc_combinegunship", "BlindfireOff", DisableIcon )
AddEntFireProperty( "rb655_alyx_HolsterWeapon", "Holster Weapon", 655, function( ent )
if ( !ent:IsNPC() or ent:GetClass() != "npc_alyx" or !IsValid( ent:GetActiveWeapon() ) ) then return false end
return true
end, "HolsterWeapon", "icon16/gun.png" )
AddEntFireProperty( "rb655_alyx_UnholsterWeapon", "Unholster Weapon", 656, "npc_alyx", "UnholsterWeapon", "icon16/gun.png" )
AddEntFireProperty( "rb655_alyx_HolsterAndDestroyWeapon", "Holster And Destroy Weapon", 657, function( ent )
if ( !ent:IsNPC() or ent:GetClass() != "npc_alyx" or !IsValid( ent:GetActiveWeapon() ) ) then return false end
return true
end, "HolsterAndDestroyWeapon", "icon16/gun.png" )
AddEntFireProperty( "rb655_antlion_burrow", "Burrow", 655, { "npc_antlion" , "npc_antlion_worker" }, "BurrowAway", "icon16/arrow_down.png" )
AddEntFireProperty( "rb655_barnacle_free", "Free Target", 655, "npc_barnacle", "LetGo", "icon16/heart.png" )
AddEntFireProperty( "rb655_zombine_suicide", "Suicide", 655, "npc_zombine", "PullGrenade", ExplodeIcon )
AddEntFireProperty( "rb655_zombine_sprint", "Sprint", 656, "npc_zombine", "StartSprint", "icon16/flag_blue.png" )
AddEntFireProperty( "rb655_thumper_enable", "Enable", 655, "prop_thumper", "Enable", EnableIcon ) -- m_bEnabled
AddEntFireProperty( "rb655_thumper_disable", "Disable", 656, "prop_thumper", "Disable", DisableIcon )
AddEntFireProperty( "rb655_dog_fetch_on", "Start Playing Fetch", 655, "npc_dog", "StartCatchThrowBehavior", "icon16/accept.png" ) -- m_bDoCatchThrowBehavior=true
AddEntFireProperty( "rb655_dog_fetch_off", "Stop Playing Fetch", 656, "npc_dog", "StopCatchThrowBehavior", "icon16/cancel.png" )
AddEntFireProperty( "rb655_soldier_look_off", "Enable Blindness", 655, "npc_combine_s", "LookOff", "icon16/user_green.png" )
AddEntFireProperty( "rb655_soldier_look_on", "Disable Blindness", 656, "npc_combine_s", "LookOn", "icon16/user_gray.png" )
AddEntFireProperty( "rb655_citizen_wep_pick_on", "Permit Weapon Upgrade Pickup", 655, "npc_citizen", "EnableWeaponPickup", EnableIcon )
AddEntFireProperty( "rb655_citizen_wep_pick_off", "Restrict Weapon Upgrade Pickup", 656, "npc_citizen", "DisableWeaponPickup", DisableIcon )
AddEntFireProperty( "rb655_citizen_panic", "Start Panicking", 658, { "npc_citizen", "npc_alyx", "npc_barney" }, "SetReadinessPanic", "icon16/flag_red.png" )
AddEntFireProperty( "rb655_citizen_panic_off", "Stop Panicking", 659, { "npc_citizen", "npc_alyx", "npc_barney" }, "SetReadinessHigh", "icon16/flag_green.png" )
AddEntFireProperty( "rb655_camera_angry", "Make Angry", 656, "npc_combine_camera", "SetAngry", "icon16/flag_red.png" )
AddEntFireProperty( "rb655_combine_mine_disarm", "Disarm", 655, "combine_mine", "Disarm", "icon16/wrench.png" )
AddEntFireProperty( "rb655_hunter_enable", "Enable Shooting", 655, "npc_hunter", "EnableShooting", EnableIcon )
AddEntFireProperty( "rb655_hunter_disable", "Disable Shooting", 656, "npc_hunter", "DisableShooting", DisableIcon )
AddEntFireProperty( "rb655_vortigaunt_enable", "Enable Armor Recharge", 655, "npc_vortigaunt", "EnableArmorRecharge", EnableIcon )
AddEntFireProperty( "rb655_vortigaunt_disable", "Disable Armor Recharge", 656, "npc_vortigaunt", "DisableArmorRecharge", DisableIcon )
AddEntFireProperty( "rb655_antlion_enable", "Enable Jump", 655, { "npc_antlion", "npc_antlion_worker" }, "EnableJump", EnableIcon )
AddEntFireProperty( "rb655_antlion_disable", "Disable Jump", 656, { "npc_antlion", "npc_antlion_worker" }, "DisableJump", DisableIcon )
AddEntFireProperty( "rb655_antlion_hear", "Hear Bugbait", 657, { "npc_antlion", "npc_antlion_worker" }, "HearBugbait", EnableIcon )
AddEntFireProperty( "rb655_antlion_ignore", "Ignore Bugbait", 658, { "npc_antlion", "npc_antlion_worker" }, "IgnoreBugbait", DisableIcon )
AddEntFireProperty( "rb655_antlion_grub_squash", "Squash", 655, "npc_antlion_grub", "Squash", "icon16/bug.png" )
AddEntFireProperty( "rb655_antlionguard_bark_on", "Enable Antlion Summon", 655, "npc_antlionguard", "EnableBark", EnableIcon )
AddEntFireProperty( "rb655_antlionguard_bark_off", "Disable Antlion Summon", 656, "npc_antlionguard", "DisableBark", DisableIcon )
AddEntFireProperty( "rb655_headcrab_burrow", "Burrow", 655, "npc_headcrab", "BurrowImmediate", "icon16/arrow_down.png" )
AddEntFireProperty( "rb655_strider_stand", "Force Stand", 655, "npc_strider", "Stand", "icon16/arrow_up.png" )
AddEntFireProperty( "rb655_strider_crouch", "Force Crouch", 656, "npc_strider", "Crouch", "icon16/arrow_down.png" )
AddEntFireProperty( "rb655_strider_break", "Destroy", 657, { "npc_strider", "npc_clawscanner", "npc_cscanner" }, "Break", ExplodeIcon )
-- This just doesn't do anything
AddEntFireProperty( "rb655_patrol_on", "Start Patrolling", 660, { "npc_citizen", "npc_combine_s" }, "StartPatrolling", "icon16/flag_green.png" )
AddEntFireProperty( "rb655_patrol_off", "Stop Patrolling", 661, { "npc_citizen", "npc_combine_s" }, "StopPatrolling", "icon16/flag_red.png" )
AddEntFireProperty( "rb655_strider_aggressive_e", "Make More Aggressive", 658, "npc_strider", "EnableAggressiveBehavior", EnableIcon )
AddEntFireProperty( "rb655_strider_aggressive_d", "Make Less Aggressive", 659, "npc_strider", "DisableAggressiveBehavior", DisableIcon )
AddEntFunctionProperty( "rb655_healthcharger_recharge", "Recharge", 655, "item_healthcharger", function( ent )
local n = ents.Create( "item_healthcharger" )
n:SetPos( ent:GetPos() )
n:SetAngles( ent:GetAngles() )
n:Spawn()
n:Activate()
n:EmitSound( "items/suitchargeok1.wav" )
undo.ReplaceEntity( ent, n )
cleanup.ReplaceEntity( ent, n )
ent:Remove()
end, "icon16/arrow_refresh.png" )
-------------------------------------------------- Vehicles --------------------------------------------------
AddEntFunctionProperty( "rb655_vehicle_exit", "Kick Driver", 655, function( ent )
if ( ent:IsVehicle() && ent:GetNWBool( "HasDriver" ) ) then return true end
return false
end, function( ent )
if ( !IsValid( ent:GetDriver() ) or !ent:GetDriver().ExitVehicle ) then return end
ent:GetDriver():ExitVehicle()
end, "icon16/car.png" )
AddEntFireProperty( "rb655_vehicle_radar", "Enable Radar", 655, function( ent )
if ( !ent:IsVehicle() or ent:GetClass() != "prop_vehicle_jeep" ) then return false end
if ( ent:LookupAttachment( "controlpanel0_ll" ) == 0 ) then return false end -- These two attachments must exist!
if ( ent:LookupAttachment( "controlpanel0_ur" ) == 0 ) then return false end
if ( ent:GetNWBool( "m_bRadarEnabled", false ) ) then return false end
return true
end, "EnableRadar", "icon16/application_add.png" )
AddEntFireProperty( "rb655_vehicle_radar_off", "Disable Radar", 655, function( ent )
if ( !ent:IsVehicle() or ent:GetClass() != "prop_vehicle_jeep" ) then return false end
-- if ( ent:LookupAttachment( "controlpanel0_ll" ) == 0 ) then return false end -- These two attachments must exist!
-- if ( ent:LookupAttachment( "controlpanel0_ur" ) == 0 ) then return false end
if ( !ent:GetNWBool( "m_bRadarEnabled", false ) ) then return false end
return true
end, "DisableRadar", "icon16/application_delete.png" )
AddEntFunctionProperty( "rb655_vehicle_enter", "Enter Vehicle", 656, function( ent )
if ( ent:IsVehicle() && !ent:GetNWBool( "HasDriver" ) ) then return true end
return false
end, function( ent, ply )
ply:ExitVehicle()
ply:EnterVehicle( ent )
end, "icon16/car.png" )
AddEntFunctionProperty( "rb655_vehicle_add_gun", "Mount Gun", 657, function( ent )
if ( !ent:IsVehicle() ) then return false end
if ( ent:GetNWBool( "EnableGun", false ) ) then return false end
if ( ent:GetBodygroup( 1 ) == 1 ) then return false end
if ( ent:LookupSequence( "aim_all" ) > 0 ) then return true end
if ( ent:LookupSequence( "weapon_yaw" ) > 0 && ent:LookupSequence( "weapon_pitch" ) > 0 ) then return true end
return false
end, function( ent )
ent:SetKeyValue( "EnableGun", "1" )
ent:Activate()
ent:SetBodygroup( 1, 1 )
ent:SetNWBool( "EnableGun", true )
end, "icon16/gun.png" )
-------------------------------------------------- Garry's Mod Specific --------------------------------------------------
AddEntFunctionProperty( "rb655_baloon_break", "Pop", 655, "gmod_balloon", function( ent, ply )
local dmginfo = DamageInfo()
dmginfo:SetAttacker( ply )
ent:OnTakeDamage( dmginfo )
end, ExplodeIcon )
AddEntFunctionProperty( "rb655_dynamite_activate", "Explode", 655, "gmod_dynamite", function( ent, ply )
ent:Explode( 0, ply )
end, ExplodeIcon )
-- Emitter
AddEntFunctionProperty( "rb655_emitter_on", "Start Emitting", 655, function( ent )
if ( ent:GetClass() == "gmod_emitter" && !ent:GetOn() ) then return true end
return false
end, function( ent, ply )
ent:SetOn( true )
end, EnableIcon )
AddEntFunctionProperty( "rb655_emitter_off", "Stop Emitting", 656, function( ent )
if ( ent:GetClass() == "gmod_emitter" && ent:GetOn() ) then return true end
return false
end, function( ent, ply )
ent:SetOn( false )
end, DisableIcon )
-- Lamps
AddEntFunctionProperty( "rb655_lamp_on", "Enable", 655, function( ent )
if ( ent:GetClass() == "gmod_lamp" && !ent:GetOn() ) then return true end
return false
end, function( ent, ply )
ent:Switch( true )
end, EnableIcon )
AddEntFunctionProperty( "rb655_lamp_off", "Disable", 656, function( ent )
if ( ent:GetClass() == "gmod_lamp" && ent:GetOn() ) then return true end
return false
end, function( ent, ply )
ent:Switch( false )
end, DisableIcon )
-- Light
AddEntFunctionProperty( "rb655_light_on", "Enable", 655, function( ent )
if ( ent:GetClass() == "gmod_light" && !ent:GetOn() ) then return true end
return false
end, function( ent, ply )
ent:SetOn( true )
end, EnableIcon )
AddEntFunctionProperty( "rb655_light_off", "Disable", 656, function( ent )
if ( ent:GetClass() == "gmod_light" && ent:GetOn() ) then return true end
return false
end, function( ent, ply )
ent:SetOn( false )
end, DisableIcon )
-- No thruster, it is glitchy
-------------------------------------------------- HL1 Specific --------------------------------------------------
AddEntFireProperty( "rb655_func_rotating_forward", "Start Forward", 655, "func_rotating", "StartForward", "icon16/arrow_right.png" )
AddEntFireProperty( "rb655_func_rotating_backward", "Start Backward", 656, "func_rotating", "StartBackward", "icon16/arrow_left.png" )
AddEntFireProperty( "rb655_func_rotating_reverse", "Reverse", 657, "func_rotating", "Reverse", "icon16/arrow_undo.png" )
AddEntFireProperty( "rb655_func_rotating_stop", "Stop", 658, "func_rotating", "Stop", "icon16/shape_square.png" )
AddEntFireProperty( "rb655_func_platrot_up", "Go Up", 655, "func_platrot", "GoUp", "icon16/arrow_up.png" )
AddEntFireProperty( "rb655_func_platrot_down", "Go Down", 656, "func_platrot", "GoDown", "icon16/arrow_down.png" )
AddEntFireProperty( "rb655_func_platrot_toggle", "Toggle", 657, "func_platrot", "Toggle", ToggleIcon )
AddEntFireProperty( "rb655_func_train_start", "Start", 655, "func_train", "Start", "icon16/arrow_right.png" )
AddEntFireProperty( "rb655_func_train_stop", "Stop", 656, "func_train", "Stop", "icon16/arrow_left.png" )
AddEntFireProperty( "rb655_func_train_toggle", "Toggle", 657, "func_train", "Toggle", ToggleIcon )
-------------------------------------------------- Pickupable Items --------------------------------------------------
AddEntFunctionProperty( "rb655_item_suit", "Wear", 655, function( ent, ply )
if ( ent:GetClass() != "item_suit" ) then return false end
if ( !ply:IsSuitEquipped() ) then return true end
return false
end, function( ent, ply )
ent:Remove()
ply:EquipSuit()
end, "icon16/user_green.png" )
local CheckFuncs = {}
CheckFuncs[ "item_ammo_pistol" ] = function( ply ) return ply:GetAmmoCount( "pistol" ) < 9999 end
CheckFuncs[ "item_ammo_pistol_large" ] = function( ply ) return ply:GetAmmoCount( "pistol" ) < 9999 end
CheckFuncs[ "item_ammo_smg1" ] = function( ply ) return ply:GetAmmoCount( "smg1" ) < 9999 end
CheckFuncs[ "item_ammo_smg1_large" ] = function( ply ) return ply:GetAmmoCount( "smg1" ) < 9999 end
CheckFuncs[ "item_ammo_smg1_grenade" ] = function( ply ) return ply:GetAmmoCount( "smg1_grenade" ) < 9999 end
CheckFuncs[ "item_ammo_ar2" ] = function( ply ) return ply:GetAmmoCount( "ar2" ) < 9999 end
CheckFuncs[ "item_ammo_ar2_large" ] = function( ply ) return ply:GetAmmoCount( "ar2" ) < 9999 end
CheckFuncs[ "item_ammo_ar2_altfire" ] = function( ply ) return ply:GetAmmoCount( "AR2AltFire" ) < 9999 end
CheckFuncs[ "item_ammo_357" ] = function( ply ) return ply:GetAmmoCount( "357" ) < 9999 end
CheckFuncs[ "item_ammo_357_large" ] = function( ply ) return ply:GetAmmoCount( "357" ) < 9999 end
CheckFuncs[ "item_ammo_crossbow" ] = function( ply ) return ply:GetAmmoCount( "xbowbolt" ) < 9999 end
CheckFuncs[ "item_rpg_round" ] = function( ply ) return ply:GetAmmoCount( "rpg_round" ) < 9999 end
CheckFuncs[ "item_box_buckshot" ] = function( ply ) return ply:GetAmmoCount( "buckshot" ) < 9999 end
CheckFuncs[ "item_battery" ] = function( ply ) return ply:Armor() < 100 end
CheckFuncs[ "item_healthvial" ] = function( ply ) return ply:Health() < 100 end
CheckFuncs[ "item_healthkit" ] = function( ply ) return ply:Health() < 100 end
CheckFuncs[ "item_grubnugget" ] = function( ply ) return ply:Health() < 100 end
AddEntFunctionProperty( "rb655_pickupitem", "Pick up", 655, function( ent, ply )
if ( !table.HasValue( table.GetKeys( CheckFuncs ), ent:GetClass() ) ) then return false end
if ( CheckFuncs[ ent:GetClass() ]( ply ) ) then return true end
return false
end, function( ent, ply )
ply:Give( ent:GetClass() )
ent:Remove()
end, "icon16/user_green.png" )
-------------------------------------------------- NPCs --------------------------------------------------
-- Passive NPCs - You cannot make these hostile or friendly
local passive = {
"npc_seagull", "npc_crow", "npc_piegon", "monster_cockroach",
"npc_dog", "npc_gman", "npc_antlion_grub",
-- "monster_scientist", -- Can't attack, but does run away
"monster_nihilanth", -- Doesn't attack from spawn menu, so not allowing to change his dispositions
"npc_turret_floor" -- Uses a special input for this sort of stuff
}
local friendly = {
"npc_monk", "npc_alyx", "npc_barney", "npc_citizen",
"npc_turret_floor", "npc_dog", "npc_vortigaunt",
"npc_kleiner", "npc_eli", "npc_magnusson", "npc_breen", "npc_mossman", -- They can use SHOTGUNS!
"npc_fisherman", -- He sorta can use shotgun
"monster_barney", "monster_scientist", "player"
}
local hostile = {
"npc_turret_ceiling", "npc_combine_s", "npc_combinegunship", "npc_combinedropship",
"npc_cscanner", "npc_clawscanner", "npc_turret_floor", "npc_helicopter", "npc_hunter", "npc_manhack",
"npc_stalker", "npc_rollermine", "npc_strider", "npc_metropolice", "npc_turret_ground",
"npc_cscanner", "npc_clawscanner", "npc_combine_camera", -- These are friendly to enemies
"monster_human_assassin", "monster_human_grunt", "monster_turret", "monster_miniturret", "monster_sentry"
}
local monsters = {
"npc_antlion", "npc_antlion_worker", "npc_antlionguard", "npc_barnacle", "npc_fastzombie", "npc_fastzombie_torso",
"npc_headcrab", "npc_headcrab_fast", "npc_headcrab_black", "npc_headcrab_poison", "npc_poisonzombie", "npc_zombie", "npc_zombie_torso", "npc_zombine",
"monster_alien_grunt", "monster_alien_slave", "monster_babycrab", "monster_headcrab", "monster_bigmomma", "monster_bullchicken", "monster_barnacle",
"monster_alien_controller", "monster_gargantua", "monster_nihilanth", "monster_snark", "monster_zombie", "monster_tentacle", "monster_houndeye"
}
---------------------------- Functional stuff ----------------------------
local NPCsThisWorksOn = {}
local function RecalcUsableNPCs()
-- Not resetting NPCsThisWorksOn as you can't remove classes from the tables below
-- Not including passive monsters here, you can't make them hostile or friendly
for _, class in pairs( friendly ) do NPCsThisWorksOn[ class ] = true end
for _, class in pairs( hostile ) do NPCsThisWorksOn[ class ] = true end
for _, class in pairs( monsters ) do NPCsThisWorksOn[ class ] = true end
end
RecalcUsableNPCs()
-- For mods
function ExtProp_AddPassive( class ) table.insert( passive, class ) end -- Probably shouldn't exist
function ExtProp_AddFriendly( class ) table.insert( friendly, class ) RecalcUsableNPCs() end
function ExtProp_AddHostile( class ) table.insert( hostile, class ) RecalcUsableNPCs() end
function ExtProp_AddMonster( class ) table.insert( monsters, class ) RecalcUsableNPCs() end
local friendliedNPCs = {}
local hostaliziedNPCs = {}
local function SetRelationships( ent, tab, status )
for id, fnpc in pairs( tab ) do
if ( !IsValid( fnpc ) ) then table.remove( tab, id ) continue end
fnpc:AddEntityRelationship( ent, status, 999 )
ent:AddEntityRelationship( fnpc, status, 999 )
end
end
local function Rbt_ProcessOtherNPC( ent )
if ( table.HasValue( friendly, ent:GetClass() ) && !table.HasValue( hostaliziedNPCs, ent ) ) then -- It's a friendly that isn't made hostile
SetRelationships( ent, friendliedNPCs, D_LI )
SetRelationships( ent, hostaliziedNPCs, D_HT )
elseif ( table.HasValue( hostile, ent:GetClass() ) && !table.HasValue( friendliedNPCs, ent ) ) then -- It's a hostile that isn't made friendly
SetRelationships( ent, friendliedNPCs, D_HT )
SetRelationships( ent, hostaliziedNPCs, D_LI )
elseif ( table.HasValue( monsters, ent:GetClass() ) && !table.HasValue( friendliedNPCs, ent ) && !table.HasValue( hostaliziedNPCs, ent ) ) then -- It's a monster that isn't made friendly or hostile to the player
SetRelationships( ent, friendliedNPCs, D_HT )
SetRelationships( ent, hostaliziedNPCs, D_HT )
end
end
if ( SERVER ) then
hook.Add( "OnEntityCreated", "rb655_properties_friently/hostile", function( ent )
if ( ent:IsNPC() ) then Rbt_ProcessOtherNPC( ent ) end
end )
end
AddEntFunctionProperty( "rb655_make_friendly", "Make Friendly", 652, function( ent )
if ( ent:IsNPC() && !table.HasValue( passive, ent:GetClass() ) && NPCsThisWorksOn[ ent:GetClass() ] ) then return true end
return false
end, function( ent )
table.insert( friendliedNPCs, ent )
table.RemoveByValue( hostaliziedNPCs, ent )
-- Remove the NPC from any squads so the console doesn't spam. TODO: Add a suffix like _friendly instead?
ent:Fire( "SetSquad", "" )
-- Special case for stalkers
if ( ent:GetClass() == "npc_stalker" ) then
ent:SetSaveValue( "m_iPlayerAggression", 0 )
end
-- Is this even necessary anymore?
for id, class in pairs( friendly ) do ent:AddRelationship( class .. " D_LI 999" ) end
for id, class in pairs( monsters ) do ent:AddRelationship( class .. " D_HT 999" ) end
for id, class in pairs( hostile ) do ent:AddRelationship( class .. " D_HT 999" ) end
SetRelationships( ent, friendliedNPCs, D_LI )
SetRelationships( ent, hostaliziedNPCs, D_HT )
for id, oent in pairs( ents.GetAll() ) do
if ( oent:IsNPC() && oent != ent ) then Rbt_ProcessOtherNPC( oent ) end
end
ent:Activate()
end, "icon16/user_green.png" )
AddEntFunctionProperty( "rb655_make_hostile", "Make Hostile", 653, function( ent )
if ( ent:IsNPC() && !table.HasValue( passive, ent:GetClass() ) && NPCsThisWorksOn[ ent:GetClass() ] ) then return true end
return false
end, function( ent )
table.insert( hostaliziedNPCs, ent )
table.RemoveByValue( friendliedNPCs, ent )
-- Remove the NPC from any squads so the console doesn't spam. TODO: Add a suffix like _hostile instead?
ent:Fire( "SetSquad", "" )
-- Special case for stalkers
if ( ent:GetClass() == "npc_stalker" ) then
ent:SetSaveValue( "m_iPlayerAggression", 1 )
end
-- Is this even necessary anymore?
for id, class in pairs( hostile ) do ent:AddRelationship( class .. " D_LI 999" ) end
for id, class in pairs( monsters ) do ent:AddRelationship( class .. " D_HT 999" ) end
for id, class in pairs( friendly ) do ent:AddRelationship( class .. " D_HT 999" ) end
SetRelationships( ent, friendliedNPCs, D_HT )
SetRelationships( ent, hostaliziedNPCs, D_LI )
for id, oent in pairs( ents.GetAll() ) do
if ( oent:IsNPC() && oent != ent ) then Rbt_ProcessOtherNPC( oent ) end
end
end, "icon16/user_red.png" )
|
----------------------------------------------------------------------------
-- LuaJIT ARM64BE disassembler wrapper module.
--
-- Copyright (C) 2005-2017 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- ARM64 instructions are always little-endian. So just forward to the
-- common ARM64 disassembler module. All the interesting stuff is there.
------------------------------------------------------------------------------
return require((string.match(..., ".*%.") or "").."dis_arm64")
|
if not modules then modules = { } end modules ['luat-fmt'] = {
version = 1.001,
comment = "companion to mtxrun",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
}
local format = string.format
local concat = table.concat
local quoted = string.quoted
local luasuffixes = utilities.lua.suffixes
local report_format = logs.reporter("resolvers","formats")
local function primaryflags() -- not yet ok
local trackers = environment.argument("trackers")
local directives = environment.argument("directives")
local flags = { }
if trackers and trackers ~= "" then
flags = { "--trackers=" .. quoted(trackers) }
end
if directives and directives ~= "" then
flags = { "--directives=" .. quoted(directives) }
end
if environment.argument("jit") then
flags = { "--jiton" }
end
return concat(flags," ")
end
-- The silent option is Taco. It's a bit of a hack because we cannot yet mess
-- with directives. In fact, I could probably clean up the maker a bit by now.
function environment.make_format(name,silent)
local engine = environment.ownmain or "luatex"
-- change to format path (early as we need expanded paths)
local olddir = dir.current()
local path = caches.getwritablepath("formats",engine) or "" -- maybe platform
if path ~= "" then
lfs.chdir(path)
end
report_format("using format path %a",dir.current())
-- check source file
local texsourcename = file.addsuffix(name,"mkiv")
local fulltexsourcename = resolvers.findfile(texsourcename,"tex") or ""
if fulltexsourcename == "" then
texsourcename = file.addsuffix(name,"tex")
fulltexsourcename = resolvers.findfile(texsourcename,"tex") or ""
end
if fulltexsourcename == "" then
report_format("no tex source file with name %a (mkiv or tex)",name)
lfs.chdir(olddir)
return
else
report_format("using tex source file %a",fulltexsourcename)
end
local texsourcepath = dir.expandname(file.dirname(fulltexsourcename)) -- really needed
-- check specification
local specificationname = file.replacesuffix(fulltexsourcename,"lus")
local fullspecificationname = resolvers.findfile(specificationname,"tex") or ""
if fullspecificationname == "" then
specificationname = file.join(texsourcepath,"context.lus")
fullspecificationname = resolvers.findfile(specificationname,"tex") or ""
end
if fullspecificationname == "" then
report_format("unknown stub specification %a",specificationname)
lfs.chdir(olddir)
return
end
local specificationpath = file.dirname(fullspecificationname)
-- load specification
local usedluastub = nil
local usedlualibs = dofile(fullspecificationname)
if type(usedlualibs) == "string" then
usedluastub = file.join(file.dirname(fullspecificationname),usedlualibs)
elseif type(usedlualibs) == "table" then
report_format("using stub specification %a",fullspecificationname)
local texbasename = file.basename(name)
local luastubname = file.addsuffix(texbasename,luasuffixes.lua)
local lucstubname = file.addsuffix(texbasename,luasuffixes.luc)
-- pack libraries in stub
report_format("creating initialization file %a",luastubname)
utilities.merger.selfcreate(usedlualibs,specificationpath,luastubname)
-- compile stub file (does not save that much as we don't use this stub at startup any more)
if utilities.lua.compile(luastubname,lucstubname) and lfs.isfile(lucstubname) then
report_format("using compiled initialization file %a",lucstubname)
usedluastub = lucstubname
else
report_format("using uncompiled initialization file %a",luastubname)
usedluastub = luastubname
end
else
report_format("invalid stub specification %a",fullspecificationname)
lfs.chdir(olddir)
return
end
-- generate format
local dump = os.platform=="unix" and "\\\\dump" or "\\dump"
if silent then
statistics.starttiming()
local command = format("%s --ini --interaction=batchmode %s --lua=%s %s %s > temp.log",engine,primaryflags(),quoted(usedluastub),quoted(fulltexsourcename),dump)
local result = os.execute(command)
local runtime = statistics.stoptiming()
if result ~= 0 then
print(format("%s silent make > fatal error when making format %q",engine,name)) -- we use a basic print
else
print(format("%s silent make > format %q made in %.3f seconds",engine,name,runtime)) -- we use a basic print
end
os.remove("temp.log")
else
local command = format("%s --ini %s --lua=%s %s %sdump",engine,primaryflags(),quoted(usedluastub),quoted(fulltexsourcename),dump)
report_format("running command: %s\n",command)
os.execute(command)
end
-- remove related mem files
local pattern = file.removesuffix(file.basename(usedluastub)).."-*.mem"
-- report_format("removing related mplib format with pattern %a", pattern)
local mp = dir.glob(pattern)
if mp then
for i=1,#mp do
local name = mp[i]
report_format("removing related mplib format %a", file.basename(name))
os.remove(name)
end
end
lfs.chdir(olddir)
end
function environment.run_format(name,data,more)
if name and name ~= "" then
local engine = environment.ownmain or "luatex"
local barename = file.removesuffix(name)
local fmtname = caches.getfirstreadablefile(file.addsuffix(barename,"fmt"),"formats",engine)
if fmtname == "" then
fmtname = resolvers.findfile(file.addsuffix(barename,"fmt")) or ""
end
fmtname = resolvers.cleanpath(fmtname)
if fmtname == "" then
report_format("no format with name %a",name)
else
local barename = file.removesuffix(name) -- expanded name
local luaname = file.addsuffix(barename,"luc")
if not lfs.isfile(luaname) then
luaname = file.addsuffix(barename,"lua")
end
if not lfs.isfile(luaname) then
report_format("using format name %a",fmtname)
report_format("no luc/lua file with name %a",barename)
else
local command = format("%s %s --fmt=%s --lua=%s %s %s",engine,primaryflags(),quoted(barename),quoted(luaname),quoted(data),more ~= "" and quoted(more) or "")
report_format("running command: %s",command)
os.execute(command)
end
end
end
end
|
--Ext.AddPathOverride("Public/Game/GUI/characterSheet.swf", "Public/lx_luxen_gm_rulesystem_ff4dba5a-16e3-420a-aa51-e5c8531b0095/Game/GUI/characterSheet.swf")
-- Ext.Require("SRP_StatsPatching.lua")
-- Ext.Require("SRP_ShadowPower_Client.lua")
Ext.Require("BootstrapShared.lua")
-- Ext.Require("Stats/Client/CustomStatsClient.lua")
-- Ext.Require("Stats/Client/CustomStatsTooltips.lua")
Ext.Require("Client/_InitClient.lua")
tEnergy = 0
local function SRP_GetCharacter()
local sheet = Ext.GetBuiltinUI("Public/Game/GUI/characterSheet.swf")
local charHandle = sheet:GetValue("charHandle", "number")
local char = Ext.GetCharacter(Ext.DoubleToHandle(charHandle))
return char
end
local function SendCharacterMessage(message, ...)
local char = SRP_GetCharacter()
-- ALWAYS make sure to cast the netID into number server-side
Ext.PostMessageToServer(message, tostring(char.NetID), ...)
end
local function CustomStatChanged(ui, call, ...)
SendCharacterMessage("SRP_MakeCustomStatCheck")
end
local function TNCFormat(tn, cap)
local string = ""
if tn ~= nil then
string = "<font color=#604020>["..tn.."]</font>"
end
if cap ~= nil then
string = string.."<font color=#000066>("..cap..")<font>"
end
return string
end
local function DisplayTNandCap(ui, ctatList, indexList, character)
local stats = character.Stats
local mAptitudes = {
Endurance = {"BaseStrength", "BaseConstitution", "#ff0000"},
Mind = {"BaseMemory", "BaseIntelligence", "#0000ff"},
Agility = {"BaseWits", "BaseFinesse", "#00802b"}
}
local sAptitudes = {
Willpower = {"Endurance", "Mind"},
Perception = {"Mind", "Agility"},
Body = {"Endurance", "Agility"}
}
local social = {
Charisma = "Endurance",
Manipulation = "Agility",
Suasion = "Mind",
Intimidation = "Might",
Insight = "Perception",
Intuition = "Willpower"
}
local knowledge = {
Alchemist = 8,
Blacksmith = 8,
Tailoring = 8,
Enchanter = 8,
Survivalist = 8,
Magic = 8,
Medicine = 8,
Academics = 8
}
local misc = {
['Soul points'] = 0,
['Fortune point'] = 1,
['Body condition'] = 5,
['Tenebrium infusion'] = 100
}
for i=0,300,1 do
local ctat = indexList[i]
if ctat ~= nil then
for ctat2, cont in pairs(mAptitudes) do
if ctat == ctat2 then
local amount = ctatList[ctat][2]
if amount ~= nil then
local tn = math.floor(4 * amount)
local cap = math.min(10 + math.floor((stats[cont[1]] + stats[cont[2]] - Ext.ExtraData.AttributeBaseValue*2)/2), 20)
ui:SetValue("customStats_array", "<font color="..cont[3]..">"..ctat.."</font> "..TNCFormat(tn, cap), ctatList[ctat][1])
end
end
end
for ctat2, cont in pairs(sAptitudes) do
if ctat == ctat2 then
local amount = ctatList[cont[1]][2] + ctatList[cont[2]][2]
amount = math.floor(amount/2)
local tn = math.floor(4 * amount)
ctatList[ctat][2] = amount
ui:SetValue("customStats_array", ctat.." "..TNCFormat(tn), ctatList[ctat][1])
ui:SetValue("customStats_array", amount, ctatList[ctat][1]+1)
end
end
if ctat == "Might" then
local amount = math.floor((ctatList["Endurance"][2] + ctatList["Mind"][2] + ctatList["Agility"][2])*2)
ctatList[ctat][2] = amount
ui:SetValue("customStats_array", ctat.." "..TNCFormat(amount), ctatList[ctat][1])
ui:SetValue("customStats_array", amount, ctatList[ctat][1]+1)
end
for ctat2, cont in pairs(social) do
if ctat == ctat2 then
local fromApt = ctatList[cont][2]
if cont == "Might" then fromApt = fromApt/4 end
local tn = math.floor(fromApt * 2 + ctatList[ctat][2] * 4)
local cap = 10
ui:SetValue("customStats_array", ctat.." "..TNCFormat(tn, cap), ctatList[ctat][1])
end
end
for ctat2, cont in pairs(knowledge) do
if ctat == ctat2 then
local amount = ctatList[ctat][2]
local tn = math.floor(cont*amount + 1*ctatList["Mind"][2])
local cap = 10
ui:SetValue("customStats_array", ctat.." "..TNCFormat(tn, cap), ctatList[ctat][1])
end
end
for ctat2,cont in pairs(misc) do
if ctat == ctat2 then
local cap = cont
if cont > 0 then
ui:SetValue("customStats_array", ctat.." "..TNCFormat(tn, cap), ctatList[ctat][1])
end
end
if ctat == "Tenebrium infusion" then
-- Ext.Print(tostring(character.NetID).."_"..ctatList[ctat][2])
Ext.PostMessageToServer("SetCharacterTenebriumInfusionTag", tostring(character.NetID).."_"..ctatList[ctat][2])
-- SetCharacterCustomStatTag(character, "SRP_TenebriumInfusion_", ctatList[ctat][2])
end
end
end
end
end
local function AddToSecStatArray(array, location, label, value, suffix, icon, statID)
local length = #array
if length > 0 then
array[length + 1] = location
array[length + 2] = label
array[length + 3] = tostring(value)..suffix
array[length + 4] = statID
array[length + 5] = icon
array[length + 6] = value
-- array[length + 7] = ""
end
end
-- local function SetTEAmount(message, amount)
-- amount = tonumber(amount)
-- tEnergy = amount
-- local sheet = Ext.GetBuiltinUI("Public/Game/GUI/characterSheet.swf")
-- sheet:GetRoot().updateArraySystem()
-- Ext.Print("TEST")
-- end
-- Ext.RegisterNetListener("SRP_UISheetCharacterTE", SetTEAmount)
local function DisplayTEInfo(ui, call, ...)
local statusConsole = Ext.GetBuiltinUI("Public/Game/GUI/statusConsole.swf")
local hotbar = Ext.GetBuiltinUI("Public/Game/GUI/hotBar.swf")
if statusConsole ~= nil then
if call == "statusConsoleRollOver" then
statusConsole:GetRoot().console_mc.sbTxt_mc.visible = true
elseif call == "statusConsoleRollOut" then
statusConsole:GetRoot().console_mc.sbTxt_mc.visible = false
end
end
end
-- function CreateShadowBar()
-- return Ext.CreateUI("shadowBar", "Public/lx_luxen_gm_rulesystem_ff4dba5a-16e3-420a-aa51-e5c8531b0095/Game/GUI/shadowBar.swf", 3)
-- end
-- local function SwitchShadowBarDisplay(ui, call, ...)
-- local shadowBar = Ext.GetUI("shadowBar")
-- if shadowBar == nil then shadowBar = CreateShadowBar() end
-- if call == "BackToGMPressed" then
-- shadowBar.Hide(shadowBar)
-- end
-- end
local function UpdateShadowBarValue(ui, call, handle)
local statusConsole = Ext.GetBuiltinUI("Public/Game/GUI/statusConsole.swf")
statusConsole:GetRoot().console_mc.sbHolder_mc.bg_mc.gotoAndStop(3)
local char = Ext.GetCharacter(Ext.DoubleToHandle(handle))
Ext.PostMessageToServer("SRP_UIRequestCharacterTE", tostring(char.NetID))
end
local function ShowTenebriumInfusionTooltip(ui, call, ...)
Ext.Dump({...})
end
local function SRP_SetupUI()
local charSheet = Ext.GetBuiltinUI("Public/Game/GUI/characterSheet.swf")
local statusConsole = Ext.GetBuiltinUI("Public/Game/GUI/statusConsole.swf")
local hotbar = Ext.GetBuiltinUI("Public/Game/GUI/hotBar.swf")
statusConsole:GetRoot().console_mc.sourceHolder_mc.y = -53
-- Ext.Print("statusconsole", statusConsole.GetTypeId(statusConsole))
-- Ext.RegisterUICall(charSheet, "plusCustomStat", CustomStatChanged)
-- Ext.RegisterUICall(charSheet, "minusCustomStat", CustomStatChanged)
Ext.RegisterUICall(statusConsole, "statusConsoleRollOver", DisplayTEInfo)
Ext.RegisterUICall(statusConsole, "statusConsoleRollOut", DisplayTEInfo)
-- Ext.RegisterUICall(statusConsole, "BackToGMPressed", SwitchShadowBarDisplay)
-- Ext.RegisterUINameCall("possess", TestTooltip4, "After")
-- Ext.RegisterUITypeCall(32, "charSel", UpdateShadowBarValue)
-- Ext.RegisterUITypeCall(119, "selectCharacter", UpdateShadowBarValue)
-- Ext.RegisterUITypeCall(119, "centerCamOnCharacter", UpdateShadowBarValue)
Ext.RegisterUIInvokeListener(hotbar, "setPlayerHandle", UpdateShadowBarValue)
-- Ext.RegisterUICall(charSheet, "showCustomStatTooltip", ShowTenebriumInfusionTooltip)
Ext.Print("Registered UI listeners")
end
-- Ext.RegisterListener("SessionLoaded", SRP_SetupUI)
|
module("Editor",package.seeall);
function Point(x, y, size, coler, alpha)
if not EDIT then return end
for j = -size/2, size/2 do
for k = -size/2, size/2 do
obj.putpixel(x + j, y + k, coler, alpha);
end
end
end
|
local AddonName, MethodDungeonTools = ...
MethodDungeonTools.U = {}
local U = MethodDungeonTools.U
U.count_if = function(t, func)
local count = 0
for k, v in pairs(t) do
if func(v) then
count = count + 1
end
end
return count
end
U.lerp = function(a, b, alpha)
return (b - a) * alpha + a
end
|
return {
mod_description = {
en = "Any Weapon"
},
}
|
-- title: Axayacalt Tomb
-- author: VERHILLE Arnaud - gist974@gmail.com
-- desc: Axayacalt's Tomb Port for TIC-80
-- graphics: 24x24 tiles & sprites by Petitjean & Shurder
-- script: Lua
-- INIT --------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
------------- PLAYER AND CO INIT --------------------------
-- player.state : 0->wait // 1->walk // 2->swim
-- // 3->Aim // 4->Jump // 5->Inventory // 6->Dead
player = {
x,
y,
dir,
state = 0,
life = 10,
O2 = 80,
greenKey = 0,
blueKey = 0,
redKey = 0,
yellowKey = 0,
score = 0
}
monsters = nil -- This a Lua Linked List
doors = nil -- This a Lua Linked List
chests = nil -- This a Lua Linked List
camera = {x = 0, y = 0}
input = -1
game = {state = 5, init = -1, time = 0}
-- INIT FROM MAP
-- --------------------
function initFromMap(x1, y1, x2, y2)
for i = x1, x2 do
for j = y1, y2 do
val = peek(0x08000 + i + j * 240)
if val == 49 then -- Some monsters to add from the map
monsters = {
next = monsters,
x = i,
y = j,
dir = 0
}
end
if val == 64 then -- Player starting position
player.x = i
player.y = j
player.dir = -1
end
if val == 2 then -- SECRET WALL
doors = {
next = doors,
x = i,
y = j,
color = "secret",
open = 0
}
end
if val == 33 then -- RED DOOR
doors = {
next = doors,
x = i,
y = j,
color = "red",
open = 0
}
end
if val == 34 then -- GREEN DOOR
doors = {
next = doors,
x = i,
y = j,
color = "green",
open = 0
}
end
if val == 35 then -- BLUE DOOR
doors = {
next = doors,
x = i,
y = j,
color = "blue",
open = 0
}
end
if val == 36 then -- YELLOW DOOR
doors = {
next = doors,
x = i,
y = j,
color = "yellow",
open = 0
}
end
if val == 20 then -- LITTLE CHEST CLOSED
chests = {
next = chests,
x = i,
y = j,
type = "little",
inside = "score",
open = 0
}
end
if val == 21 then -- LITTLE CHEST OPEN
chests = {
next = chests,
x = i,
y = j,
type = "little",
inside = "nothing",
open = 1
}
end
if val == 21 then -- BIG CHEST
chests = {
next = chests,
x = i,
y = j,
type = "big",
inside = "nothing",
open = 0
}
end
end
end
end
-- SELECT BASIC LOOP FONCTIONS -- -------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
function TIC()
game.time = game.time + 1
if game.state == -1 then flyBy() end -- flyBy Mode
if game.state == 0 then playMap(72, 08, 81, 13) end -- Attract Mode
if game.state == 1 then playMap(0, 0, 66, 67) end -- Original Map
if game.state == 2 then playMap(66, 16, 87, 33) end -- Arena Map
if game.state == 3 then playMap(64, 33, 89, 50) end -- The Cave
if game.state == 4 then playMap(64, 51, 88, 66) end -- The Keys
if game.state == 5 then playMap(89, 01, 120, 17) end -- The Keys 2
end
function playMap(x1, y1, x2, y2)
if game.init == -1 then
initFromMap(x1, y1, x2, y2)
game.init = 1
end
if player.state == 5 then -- INVENTORY MODE
if btnp(6) then -- Triangle to Quit INVENTORY MODE
input = 6
player.state = 0
end
else -- PLAYING MODE
updateMonster()
updatePlayer()
updateCamera()
checkInteraction()
end
cls(0)
drawMap(camera.x, camera.y)
drawMonsters()
drawHUD()
drawPlayer()
end
-- CAMERA ------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
function updateCamera()
if game.state == 0 then -- Attract Mode Fixed Camera
camera.x = 72
camera.y = 8
else -- Camera Follow the player
camera.x = player.x - 5
camera.y = player.y - 2
end
end
function flyBy()
cls(0)
if btn(0) then camera.y = camera.y - 1 end
if btn(1) then camera.y = camera.y + 1 end
if camera.y < 0 then camera.y = 0 end
if camera.y > 135 then camera.y = 135 end
if btn(2) then camera.x = camera.x - 1 end
if btn(3) then camera.x = camera.x + 1 end
if camera.x < 0 then camera.x = 0 end
if camera.x > 239 then camera.x = 239 end
drawMap(camera.x, camera.y)
-- show coordinates
c = string.format('(%03i,%03i)', toInt(camera.x),
toInt(camera.y))
rect(0, 0, 52, 8, 0)
print(c, 0, 0, 12, 1)
end
-- INTERACTION -----------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
function checkInteraction()
-- collide with Monsters
local m = monsters
while m do
if m.x == player.x then
if m.y == player.y then
player.life = player.life - 1
end
end
m = m.next
end
-- IF GREEN KEY
if mget(player.x, player.y) == 239 then
player.greenKey = 1
end
-- IF BLUE KEY
if mget(player.x, player.y) == 255 then
player.blueKey = 1
end
-- IF RED KEY
if mget(player.x, player.y) == 223 then
player.redKey = 1
end
-- IF YELLOW KEY
if mget(player.x, player.y) == 207 then
player.yellowKey = 1
end
end
-- PLAYER CONTROL ----------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
function updatePlayer()
if btnp(6) then -- Triangle
input = 6
player.state = 5 -- Inventory
-- if attractmode then run original game
if game.state == 0 then
game.state = 1
game.init = -1
end
end
-- Important!! player speed !
if game.time % 15 == 0 then
player.state = 0
if btn(5) then
input = 5
player.state = 3 -- Aiming Cercle
end
if btn(4) then
input = 4
player.state = 4 -- Jump Croix
end
if btn(7) then -- Shoot Button Carre
input = 7
player.state = 3 -- Aiming
if player.dir == 0 then -- Vise vers le haut
if doorIsOpen(player.x, player.y - 1) then
chgDoorState(player.x, player.y - 1)
end
if chestIsHere(player.x, player.y - 1) then
chgChestState(player.x, player.y - 1)
end
end
if player.dir == 1 then -- Vise vers le droite
if doorIsOpen(player.x + 1, player.y) then
chgDoorState(player.x + 1, player.y)
end
if chestIsHere(player.x + 1, player.y) then
chgChestState(player.x + 1, player.y)
end
end
if player.dir == 2 then -- Vise vers le bas
if doorIsOpen(player.x, player.y + 1) then
chgDoorState(player.x, player.y + 1)
end
if chestIsHere(player.x, player.y + 1) then
chgChestState(player.x, player.y + 1)
end
end
if player.dir == 3 then -- Vise vers la gauche
if doorIsOpen(player.x - 1, player.y) then
chgDoorState(player.x - 1, player.y)
end
if chestIsHere(player.x - 1, player.y) then
chgChestState(player.x - 1, player.y)
end
end
end
-- Avance vers le haut
if btn(0) then
input = 0
player.dir = 0
if playerCanMove(player.x, player.y - 1) == 1 then
player.y = player.y - 1
player.state = 1
end
end
-- Avance vers le bas
if btn(1) then
input = 1
player.dir = 2
if playerCanMove(player.x, player.y + 1) == 1 then
player.y = player.y + 1
player.state = 1
end
end
-- Avance vers la gauche
if btn(2) then
input = 2
player.dir = 3
if playerCanMove(player.x - 1, player.y) == 1 then
player.x = player.x - 1
player.state = 1
end
end
-- Avance vers la droite
if btn(3) then
input = 4
player.dir = 1
if playerCanMove(player.x + 1, player.y) == 1 then
player.x = player.x + 1
player.state = 1
end
end
-- if WATER you have to SWIM
if isWater(player.x, player.y) == 1 then
player.state = 2 -- SWIM
if player.O2 == 0 then
player.life = player.life - 1
else
player.O2 = player.O2 - 1
end
else
player.O2 = 300
end
-- if PEAK and not jumping -> Dead
if mget(player.x, player.y + 1) == 7 then
if player.state == 4 then
else
player.life = 0
end
end
end -- Wait
end
function playerCanMove(x, y)
val = mget(x, y)
if val == 1 or val == 3 or val == 39 or val == 10 or
val == 11 or val == 12 or val == 23 or val == 15 or
val == 17 or val == 20 or val == 21 or val == 22 or
val == 37 or val == 18 then return -1 end
if val == 2 then -- Secret Door
if doorIsOpen(x, y) == 0 then
return -1
else
return 1
end
end
if val == 34 then -- Green Door
if player.greenKey == 0 then
return -1
else
if doorIsOpen(x, y) == 0 then
return -1
else
return 1
end
end
end
if val == 35 then -- Blue Door
if player.blueKey == 0 then
return -1
else
if doorIsOpen(x, y) == 0 then
return -1
else
return 1
end
end
end
if val == 33 then -- Red Door
if player.redKey == 0 then
return -1
else
if doorIsOpen(x, y) == 0 then
return -1
else
return 1
end
end
end
if val == 36 then -- Yellow Door
if player.yellowKey == 0 then
return -1
else
if doorIsOpen(x, y) == 0 then
return -1
else
return 1
end
end
end
if player.state == 3 then -- AIMING
return 0
else
if doorIsOpen(x, y) == 0 then
return -1
else
return 1
end
end
end
function isWater(x, y)
val = mget(x, y)
if val == 14 then -- Water tiles
return 1
else
return -1
end
end
-- DOORS AND CHEST ----------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
function doorIsOpen(x, y)
local d = doors
while d do
if d.x == x and d.y == y then
if d.open == 1 then
return 1
else
return 0
end
end
d = d.next
end
end
function chgDoorState(x, y)
local d = doors
while d do
if d.x == x and d.y == y then
if d.color == "secret" then
if d.open == 0 then
d.open = 1
else
d.open = 0
end
end
if d.color == "green" and player.greenKey == 1 then
if d.open == 0 then
d.open = 1
else
d.open = 0
end
return
end
if d.color == "blue" and player.blueKey == 1 then
if d.open == 0 then
d.open = 1
else
d.open = 0
end
return
end
if d.color == "red" and player.redKey == 1 then
if d.open == 0 then
d.open = 1
else
d.open = 0
end
return
end
if d.color == "yellow" and player.yellowKey == 1 then
if d.open == 0 then
d.open = 1
else
d.open = 0
end
return
end
end
d = d.next
end
end
-- ------------------------------------
-- -------------- CHESTS -------------
-- ------------------------------------
function chestIsHere(x, y)
local c = chests
while c do
if c.x == x and c.y == y then return 1 end
c = c.next
end
return 0
end
function chgChestState(x, y)
local c = chests
while c do
if c.x == x and c.y == y then
if c.open == 0 then
if c.inside == "life" then
player.life = player.life + 5
c.inside = "nothing"
end
if c.inside == "score" then
player.score = player.score + 100
c.inside = "nothing"
end
c.open = 1
else
c.open = 0
end
end
c = c.next
end
end
-- MONSTER AI --------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
function updateMonster()
if game.time % 20 == 0 then
local m = monsters
while m do
if m.dir == 0 then
if monsterCanMove(m.x + 1, m.y) == 1 then
m.x = m.x + 1
m.dir = 0
else
m.dir = toInt(math.random(0, 3))
end
end
if m.dir == 1 then
if monsterCanMove(m.x, m.y - 1) == 1 then
m.y = m.y - 1
m.dir = 1
else
m.dir = toInt(math.random(0, 3))
end
end
if m.dir == 2 then
if monsterCanMove(m.x - 1, m.y) == 1 then
m.x = m.x - 1
m.dir = 2
else
m.dir = toInt(math.random(0, 3))
end
end
if m.dir == 3 then
if monsterCanMove(m.x, m.y + 1) == 1 then
m.y = m.y + 1
m.dir = 3
else
m.dir = toInt(math.random(0, 3))
end
end
m = m.next
end
end
end
function monsterCanMove(x, y)
val = mget(x, y)
if val == 1 or val == 2 or val == 3 or val == 8 or val ==
9 or val == 39 or val == 10 or val == 11 or val ==
12 or val == 23 or val == 15 or val == 17 or val ==
20 or val == 21 or val == 22 or val == 37 or val ==
18 or val == 14 then
return 0
else
if val == 33 or val == 34 or val == 35 or val == 36 then
return doorIsOpen(x, y)
end
return 1
end
end
-- DRAWING ------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
function drawPlayer()
if player.state == 0 then
-- En Face
spr(256, (player.x - camera.x) * 24,
(player.y - camera.y) * 24, 15, 1, 0, 0, 3, 3)
spr(271, (player.x - camera.x) * 24 + 8,
(player.y - camera.y) * 24 + 4, 15, 1, 0, 0, 1,
1)
end
if player.state == 1 then -- Walk
-- Vers le haut
if player.dir == -1 then
spr(304 + game.time % 30 // 15 * 3,
(player.x - camera.x) * 24,
(player.y - camera.y) * 24, 15, 1, 0, 0, 3, 3)
end
-- Vers le haut
if player.dir == 0 then
spr(304 + game.time % 30 // 15 * 3,
(player.x - camera.x) * 24,
(player.y - camera.y) * 24, 15, 1, 0, 0, 3, 3)
end
-- vers la droite
if player.dir == 1 then
spr(259 + game.time % 30 // 15 * 3,
(player.x - camera.x) * 24,
(player.y - camera.y) * 24, 15, 1, 0, 0, 3, 3)
end
-- Vers le bas
if player.dir == 2 then
spr(304 + game.time % 30 // 15 * 3,
(player.x - camera.x) * 24,
(player.y - camera.y) * 24, 15, 1, 0, 0, 3, 3)
spr(271, (player.x - camera.x) * 24 + 8,
(player.y - camera.y) * 24 + 4, 15, 1, 0, 0,
1, 1)
end
-- Vers la gauche
if player.dir == 3 then
spr(259 + game.time % 30 // 15 * 3,
(player.x - camera.x) * 24,
(player.y - camera.y) * 24, 15, 1, 1, 0, 3, 3)
end
end
-- Swimming mode
if player.state == 2 then -- Swimming mode
if player.dir == -1 then
spr(265 + game.time % 30 // 15 * 3,
(player.x - camera.x) * 24,
(player.y - camera.y) * 24, 15, 1, 0, 0, 3, 3)
spr(271, (player.x - camera.x) * 24 + 9,
(player.y - camera.y) * 24 + 3 + game.time %
30 // 15, 15, 1, 0, 0, 1, 1)
end
if player.dir >= 0 then
spr(265 + game.time % 30 // 15 * 3,
(player.x - camera.x) * 24,
(player.y - camera.y) * 24, 15, 1, 0,
player.dir, 3, 3)
end
end
-- Aiming mode
if player.state == 3 then
if player.dir == -1 then
spr(256, (player.x - camera.x) * 24,
(player.y - camera.y) * 24, 15, 1, 0, 0, 3, 3)
spr(271, (player.x - camera.x) * 24 + 8,
(player.y - camera.y) * 24 + 4, 15, 1, 0, 0,
1, 1)
end
if player.dir == 0 then
spr(313, (player.x - camera.x) * 24,
(player.y - camera.y) * 24, 15, 1, 0, 0, 3, 3)
end
if player.dir == 1 then
spr(310, (player.x - camera.x) * 24,
(player.y - camera.y) * 24, 15, 1, 0, 0, 3, 3)
end
if player.dir == 2 then
spr(316, (player.x - camera.x) * 24,
(player.y - camera.y) * 24, 15, 1, 0, 0, 3, 3)
end
if player.dir == 3 then
spr(310, (player.x - camera.x) * 24,
(player.y - camera.y) * 24, 15, 1, 1, 0, 3, 3)
end
end
if player.state == 4 then -- JUMP
-- En Face
if player.dir == 0 then
spr(412, (player.x - camera.x) * 24,
(player.y - camera.y) * 24 - 2, 15, 1, 0, 0,
3, 3)
end
if player.dir == 1 then
spr(364, (player.x - camera.x) * 24,
(player.y - camera.y) * 24 - 2, 15, 1, 0, 0,
3, 3)
end
if player.dir == 2 then
spr(412, (player.x - camera.x) * 24,
(player.y - camera.y) * 24 - 2, 15, 1, 0, 0,
3, 3)
end
if player.dir == 3 then
spr(364, (player.x - camera.x) * 24,
(player.y - camera.y) * 24 - 2, 15, 1, 1, 0,
3, 3)
end
end
if player.state == 5 then -- INVENTORY WINDOW DRAW
-- En Face
spr(256, 3 * 24, (player.y - camera.y) * 24, 15, 1,
0, 0, 3, 3)
spr(271, 3 * 24 + 8, (player.y - camera.y) * 24 + 4,
15, 1, 0, 0, 1, 1)
end
end
-- -----------------------------
-- DRAW MONSTERS
-- -----------------------------
-- print(game.time%30//15,75,2*24,10,2,2)
function drawMonsters()
local m = monsters
while m do
if m.dir == -1 then
spr(352 + game.time % 30 // 15 * 3,
(m.x - camera.x) * 24, (m.y - camera.y) * 24,
15, 1, m.dir, 0, 3, 3)
end
if m.dir == 0 then -- Right
spr(352 + game.time % 30 // 15 * 3,
(m.x - camera.x) * 24, (m.y - camera.y) * 24,
15, 1, m.dir, 0, 3, 3)
end
if m.dir == 1 then -- UP
spr(361, (m.x - camera.x) * 24,
(m.y - camera.y) * 24, 15, 1, 0, 0, 3, 3)
end
if m.dir == 2 then -- Left
spr(352 + game.time % 30 // 15 * 3,
(m.x - camera.x) * 24, (m.y - camera.y) * 24,
15, 1, 1, 0, 3, 3)
end
if m.dir == 3 then -- Down
spr(358, (m.x - camera.x) * 24,
(m.y - camera.y) * 24, 15, 1, 0, 0, 3, 3)
end
m = m.next
end
end
-- ----------------
-- DRAW HUD
-- ----------------
function drawHUD()
if game.state == 0 then -- Attract Mode
print("Axayacalt's", 75, 1 * 24 + 6, 10, 2, 2)
print("Tomb", 125, 2 * 24, 10, 2, 2)
print("A TIC-80 game by gist974", 50, 5 * 24 + 2, 1,
1, 1)
print("Graphics: Petitjean & Shurder", 35,
5 * 24 + 10, 1, 1, 1)
else -- INGAME HUD
if player.state == 5 then -- Show HUD 5 only in Inventory
rect(2 * 24, 1 * 24, 5 * 24, 3 * 24, 8) -- Main Rect
rectb(2 * 24, 1 * 24, 5 * 24, 3 * 24, 12)
rect(2 * 24 + 12, 1 * 24 + 8, 19, 7, 1) -- HUD Life
spr(26, 2 * 24 + 6, 1 * 24 + 8, 15, 1, 0, 0, 1, 1)
print(player.life, 2 * 24 + 16, 1 * 24 + 9, 12, 1,
1)
rect(3 * 24 + 18, 1 * 24 + 8, 24, 7, 1) -- HUD O2
spr(25, 3 * 24 + 12, 1 * 24 + 8, 15, 1, 0, 0, 1, 1)
print(player.O2, 3 * 24 + 22, 1 * 24 + 9, 12, 1, 1)
print("Keys", 5 * 24, 1 * 24 + 9, 12, 1, 1)
if player.greenKey == 1 then
spr(239, 5 * 24, 1 * 24 + 18, 12, 1, 1)
end
if player.blueKey == 1 then
spr(255, 5 * 24 + 10, 1 * 24 + 18, 12, 1, 1)
end
if player.redKey == 1 then
spr(223, 5 * 24 + 20, 1 * 24 + 18, 12, 1, 1)
end
if player.yellowKey == 1 then
spr(207, 5 * 24 + 30, 1 * 24 + 18, 12, 1, 1)
end
print("Gold", 5 * 24, 2 * 24 + 14, 12, 1, 1)
-- spr(126, 5 * 24, 3 * 24, 12, 1, 1, 0, 2, 2)
print(player.score, 5 * 24, 2 * 24 + 16 + 10, 4,
1, 1)
else
-- HUD Life
rect(211, 3, 19, 7, 1)
spr(26, 208, 2, 15, 1, 0, 0, 1, 1)
print(player.life, 218, 4, 12, 1, 1)
if player.state == 2 then -- Show HUD O2 only if swimming
rect(211, 13, 25, 7, 1)
spr(25, 208, 12, 15, 1, 0, 0, 1, 1)
print(player.O2, 218, 14, 12, 1, 1)
end
end
end
end
-- ------------------------------
-- DRAW MAP
-- -----------------------------
function drawMap(x, y) -- draw 64x64 Sprite Map
x = toInt(x)
y = toInt(y)
for i = 0, 9 do
for j = 0, 5 do
-- Get the mini-sprite value from TIC-80 map
val = peek(0x08000 + (i + x) + (j + y) * 240)
if i + x < 0 then val = 17 end
if i + x > 239 then val = 17 end
if j + y < 0 then val = 17 end
if j + y > 135 then val = 17 end
drawMapSprite(val, i, j)
end
end
drawDoors()
drawChests()
end
function drawDoors()
local d = doors
while d do
if d.open == 0 then
if d.color == "green" then
spr(211, (d.x - camera.x) * 24,
(d.y - camera.y) * 24, -1, 1, 0, 0, 3, 3)
spr(239, (d.x - camera.x) * 24 + 8,
(d.y - camera.y) * 24 + 8, -1, 1, 0, 0, 1, 1)
end
if d.color == "blue" then
spr(211, (d.x - camera.x) * 24,
(d.y - camera.y) * 24, -1, 1, 0, 0, 3, 3)
spr(255, (d.x - camera.x) * 24 + 8,
(d.y - camera.y) * 24 + 8, -1, 1, 0, 0, 1, 1)
end
if d.color == "red" then
spr(211, (d.x - camera.x) * 24,
(d.y - camera.y) * 24, -1, 1, 0, 0, 3, 3)
spr(223, (d.x - camera.x) * 24 + 8,
(d.y - camera.y) * 24 + 8, -1, 1, 0, 0, 1, 1)
end
if d.color == "yellow" then
spr(211, (d.x - camera.x) * 24,
(d.y - camera.y) * 24, -1, 1, 0, 0, 3, 3)
spr(207, (d.x - camera.x) * 24 + 8,
(d.y - camera.y) * 24 + 8, -1, 1, 0, 0, 1, 1)
end
if d.color == "secret" then
-- Secret Wall
spr(65, (d.x - camera.x) * 24,
(d.y - camera.y) * 24, -1, 1, 0, 0, 3, 3)
spr(2, (d.x - camera.x) * 24 + 8,
(d.y - camera.y) * 24 + 8, -1, 1, 0, 0, 1, 1)
end
end
d = d.next
end
end
function drawChests()
local c = chests
while c do
-- Big Chest
if c.type == "big" then
spr(185, (c.x - camera.x) * 24,
(c.y - camera.y) * 24 + 7, -1, 1, 0, 0, 3, 2)
return
end
-- Little Chest
if c.open == 0 then
spr(121, (c.x - camera.x) * 24,
(c.y - camera.y) * 24 + 8, -1, 1, 0, 0, 3, 2)
end
-- Little Chest Open
if c.open == 1 then
spr(153, (c.x - camera.x) * 24,
(c.y - camera.y) * 24 + 8, -1, 1, 0, 0, 3, 2)
end
c = c.next
end
end
-- DRAW SPRITES
-- --------------------------------------------------
function drawMapSprite(val, i, j)
-- Wall 1
if val == 1 then
spr(65, i * 24, j * 24, -1, 1, 0, 0, 3, 3)
end
-- Wall 2
if val == 3 then
spr(68, i * 24, j * 24, -1, 1, 0, 0, 3, 3)
end
-- Stairs left
if val == 4 then
spr(71, i * 24, j * 24, -1, 1, 0, 0, 2, 3)
spr(72, i * 24 + 16, j * 24, -1, 1, 0, 0, 1, 3)
end
-- Stairs center
if val == 5 then
spr(72, i * 24, j * 24, -1, 1, 0, 0, 1, 3)
spr(72, i * 24 + 8, j * 24, -1, 1, 0, 0, 1, 3)
spr(72, i * 24 + 16, j * 24, -1, 1, 0, 0, 1, 3)
end
-- Stairs right
if val == 6 then
spr(72, i * 24, j * 24, -1, 1, 0, 0, 1, 3)
spr(72, i * 24 + 8, j * 24, -1, 1, 0, 0, 2, 3)
end
-- Pikes
if val == 7 then
spr(160, i * 24, j * 24, -1, 1, 0, 0, 3, 3)
end
-- Little Skull
if val == 8 then
spr(204, i * 24, j * 24, -1, 1, 0, 0, 3, 2)
end
-- Big Skull
if val == 9 then
spr(236, i * 24, j * 24, -1, 1, 0, 0, 3, 2)
end
-- Aztec Statue
if val == 10 then
spr(163, i * 24, j * 24, -1, 1, 0, 0, 3, 3)
end
-- Weird Statue
if val == 11 then
spr(118, i * 24, j * 24, -1, 1, 0, 0, 3, 3)
end
-- Pedestal
if val == 12 then
spr(166, i * 24, j * 24, -1, 1, 0, 0, 3, 3)
end
-- Book
if val == 13 then
spr(13, i * 24 + 8, j * 24 + 16, -1, 1, 0, 0, 1, 1)
end
-- Water
if val == 14 then
spr(112, i * 24, j * 24, -1, 1, 0, 0, 3, 3)
end
-- Pillar
if val == 15 then
spr(208, i * 24, j * 24, -1, 1, 0, 0, 3, 3)
end
-- Tree
if val == 17 then
spr(78, i * 24 + 8, j * 24, -1, 1, 0, 0, 2, 3)
end
-- Rotated Stairs up
if val == 16 then
spr(71, i * 24, j * 24, -1, 1, 0, 1, 1, 3)
spr(72, i * 24, j * 24 + 8, -1, 1, 0, 1, 1, 3)
spr(72, i * 24, j * 24 + 16, -1, 1, 0, 1, 1, 3)
end
-- Rotated Stairs center
if val == 32 then
spr(72, i * 24, j * 24, -1, 1, 0, 1, 1, 3)
spr(72, i * 24, j * 24 + 8, -1, 1, 0, 1, 1, 3)
spr(72, i * 24, j * 24 + 16, -1, 1, 0, 1, 1, 3)
end
-- Rotated Stairs right
if val == 48 then
spr(72, i * 24, j * 24, -1, 1, 0, 1, 1, 3)
spr(72, i * 24, j * 24 + 8, -1, 1, 0, 1, 2, 3)
end
-- Mine
if val == 18 then
spr(115, i * 24, j * 24, -1, 1, 0, 0, 3, 3)
end
-- Boulder
if val == 19 then
spr(470, i * 24, j * 24, -1, 1, 0, 0, 3, 3)
end
-- Pretty Statue
if val == 23 then
spr(126, i * 24 + 4, j * 24 + 8, -1, 1, 0, 0, 2, 2)
end
-- Spacechip way
if val == 38 then
spr(188, i * 24, j * 24, -1, 1, 0, 0, 3, 1)
spr(188, i * 24, j * 24 + 16, -1, 1, 0, 2, 3, 1)
end
if game.state == -1 then -- It's flyBy Mode
-- Gobelin Sprite
if val == 49 then
spr(352, i * 24, j * 24, 15, 1, 0, 0, 3, 3)
end
-- Player Sprite
if val == 64 then
spr(256, i * 24, j * 24, 15, 1, 0, 0, 3, 3)
spr(271, i * 24 + 8, j * 24 + 4, 15, 1, 0, 0, 1, 1)
end
end
-- Big Desk
if val == 37 then
spr(27, i * 24 - 32 + 3, j * 24, -1, 1, 0, 0, 5, 3)
spr(27, i * 24 + 8 + 3, j * 24, -1, 1, 1, 0, 5, 3)
end
-- Yellow Key
if val == 207 then
if player.yellowKey == 0 then
spr(val, i * 24 + 8, j * 24 + 8, -1, 1, 0, 0, 1, 1)
end
end
-- Red Key
if val == 223 then
if player.redKey == 0 then
spr(val, i * 24 + 8, j * 24 + 8, -1, 1, 0, 0, 1, 1)
end
end
-- Green Key
if val == 239 then
if player.greenKey == 0 then
spr(val, i * 24 + 8, j * 24 + 8, -1, 1, 0, 0, 1, 1)
end
end
-- Blue Key
if val == 255 then
if player.blueKey == 0 then
spr(val, i * 24 + 8, j * 24 + 8, -1, 1, 0, 0, 1, 1)
end
end
-- Big Arch
if val == 55 then
spr(74, i * 24 - 24 + 3, j * 24 - 24, -1, 1, 0, 0,
4, 3)
spr(74, i * 24 + 11, j * 24 - 24, -1, 1, 1, 0, 4, 3)
spr(124, i * 24 - 15, j * 24, -1, 1, 1, 0, 2, 3)
spr(124, i * 24 + 22, j * 24, -1, 1, 1, 0, 2, 3)
end
-- SpaceShip Control
if val == 80 then
spr(172, i * 24 + 5, j * 24 - 24 + 8, -1, 1, 0, 0,
2, 1)
spr(217, i * 24, j * 24, -1, 1, 1, 0, 3, 3)
end
end
-- FONCTION UTILITAIRES
-- -------------------------------
function toInt(n)
local s = tostring(n)
local i, j = s:find('%.')
if i then
return tonumber(s:sub(1, i - 1))
else
return n
end
end
-- Linear Interpolation
function lerp(a, b, mu) return a * (1 - mu) + b * mu end
-- <TILES>
-- 001:ffffffffffffffffff0ff0ffffffffffff0ff0fffff00fffffffffffffffffff
-- 002:4444444444044044444444444440044400000000044444400440044004044040
-- 003:ffffffffffffffffff0ff0ffffffffffffffffffff0000ffffffffffffffffff
-- 004:fffffffffff00000fff0eeeefff0eeeeff000000ff0eeeeef00eeeeef0000000
-- 005:ffffffff00000000eeeeeeeeeeeeeeee00000000eeeeeeeeeeeeeeee00000000
-- 006:ffffffff00000fffeeee0fffeeee0fff000000ffeeeee0ffeeeee00f0000000f
-- 007:000000000000000000e00e000ee0ee0000e00e00f0e00e0ff0e00e0fffffffff
-- 008:00000000000cc00000cccc000c0cc0c00cccccc000cccc0000c00c0000000000
-- 009:0000000000cccc000cccccc0cc0cc0cccccccccc0cccccc00c0cc0c000000000
-- 010:0400004000400400040440400004400000444400040440400004400000400400
-- 011:0444444004044040004444000004400004444440040440400004400000444400
-- 012:00000000022222200eeeeee000e44e0000e44e0000eeee000eeeeee00ee00ee0
-- 013:4444444440000004400000044040440440000004404404044000000444444444
-- 014:000000000aa00aa0a000a00000000000000000000aa00aa0a000a00000000000
-- 015:0000000000ffff000ff00ff00f0ee0f00f0ee0f00ff00ff000ffff0000000000
-- 016:ffffffff00ffffff0000ffff0ee0000f0ee0ee0f0ee0ee0f0ee0ee0f0ee0ee0f
-- 017:0006000000666000006660000066600000666000000200000002000000222000
-- 018:00dddd00000ee000d00ee00ddeeffeeddeeffeedd00ee00d000ee00000dddd00
-- 019:0000000000eeee000eee0ee00eeee0e00eeeeee00eeeeee000eeee0000000000
-- 020:0000000000000000000000000044440004400440044444400444444000000000
-- 021:0000000000000000044444400400004004000040044444400444444000000000
-- 022:0000000000444400044444400440044004444440044444400444444000000000
-- 023:0000000000000000004004000044440000444400000440000004400000444400
-- 025:f9aaaa9f9aa99aa99a999ccc9a999cac9a9999ac9aa99ac999aaac99f9999ccc
-- 026:f00000ff0220220f2222222022222c202222c2200222220ff02220ffff020fff
-- 027:000000000000000000000000000000000000000000000fff0000ffff0000ff00
-- 028:0000000000000000000000000000000000000000ffffffffffffffff00000000
-- 029:0000000000000000000000000000000000000000ffffffffffffffff00000000
-- 030:0000000000000000000000000000000000000000ffffffffffffffff00000000
-- 031:0000000000000000000000000000000000000000ffffffffffffffff00000000
-- 032:0ee0ee0f0ee0ee0f0ee0ee0f0ee0ee0f0ee0ee0f0ee0ee0f0ee0ee0f0ee0ee0f
-- 033:2200002222222222020000200200002002000020020000202222222222000022
-- 034:6600006666666666060000600600006006000060060000606666666666000066
-- 035:9900009999999999090000900900009009000090090000909999999999000099
-- 036:4400004444444444040000400400004004000040040000404444444444000044
-- 037:0000000000000000ffffffffeeeeeeeeeffffffeef0000feff0000ffff0000ff
-- 038:fffffffff4f44f4fffffffff0000000000000000fffffffff4f44f4fffffffff
-- 039:0000000002000020002002000002200000022000002002000200002000000000
-- 043:0000ff010000ff010000ff000000ffff0000ffff0000000000000f0d00000f0d
-- 044:010101010101010100000000ffffffffffffffff000000000d0d0d0f0d0d0d0f
-- 045:010101010101010100000000f0101010f010101000000000ffff0fff000f0f00
-- 046:010101010101010100000000ffffff0fffffff0f00000000ff0fffff0f0f0000
-- 047:111101111111011100000000ffffffffffffffff00000000fffffffff0000f00
-- 048:0ee0ee0f0ee0ee0f0ee0ee0f0ee0ee0f0ee0000f0000ffff00ffffffffffffff
-- 049:3000000003333000033033000333333003300030033300000033330000000000
-- 050:0004400000440400044444400400440004400440004444000004400000440400
-- 051:0000000000011100001010100111111111100011111111110011110000000000
-- 055:044444404444444444444444eee00eee0e0000e00e0000e00e0000e0fff00fff
-- 059:00000f0d00000f0000000fff00000fff0000000000000f0f0000f0f00000ff0f
-- 060:0d0d0d0f0000000fffffffffffffffff000000000f0f0f0ff0f0f0f00f0f0f0f
-- 061:0f0f0f0f0fff0fff00000000000000000000000000000000f0000000f0000000
-- 062:0f0f00f00f0ffff00f0000000fffffff00000000000000000000000000000000
-- 063:f00f0f00ffff0fff00000000ffffffff00000000000000000000000000000000
-- 064:0000000000444400040440400444444004044040044004400044440000000000
-- 065:fff0fff0f0000000f0eeeeee00ee000ef0ee040ef0ee000ef0eeee0e00e000e0
-- 066:ffffffff00000000eeeeeeee000ee000040ee040000ee000e0eeee0e00000000
-- 067:0fff0fff0000000feeeeee0fe000ee00e040ee0fe000ee0fe0eeee0f0e000e00
-- 068:fff0fff0f0000000f0dddddd00d00000f0d0eee0f0d0e0e0f0d0e0ee00d0e000
-- 069:ffffffff00000000dddddddd00000000eee00eeee0e00e0ee0eeee0e00000000
-- 070:0fff0fff0000000fdddddd0f00000d000eee0d0f0e0e0d0fee0e0d0f000e0d00
-- 071:0000000000000000000000000000000000000000fffff0ff000000000eeeeeee
-- 072:0000000000000000000000000000000000000000fff0ffff00000000eeeeeeee
-- 073:0000000000000000000000000000000000000000ff0fffff00000000eeeeeee0
-- 074:0000000000000000000000000000000000000000000000440000044400000444
-- 075:0000000000000000000000000000000000000000000440004044440440444404
-- 076:0000000000000000000000000000000000000000440004404440444444404444
-- 077:0000000000000000000000000000000000440004044440440444404404440000
-- 078:0000000000000000000006060000006000000006000000600000060600006060
-- 079:0000000000000000000000006000000006000000606000000606000060600000
-- 080:0000000000000000000440000044440004400440440440440000000000000000
-- 081:f0e04000f0e000e0f0eeeee0f0e000e0f0e04000f0e000eef0eeee00f0000e04
-- 082:4444444444044044444444444440044400000000040440400440044004444440
-- 083:00040e0f0e000e0f0eeeee0f0e000e0f00040e0fee000e0f00eeee0f40e0000f
-- 084:f0d0eee0f0d000e0f0d0eee0f0d0e000f0d0e000f0d0eee0f0d000e0f0d0eee0
-- 085:4444444444444444440440444444444444044044400000044444444444444444
-- 086:0eee0d0f0e000d0f0eee0d0f000e0d0f000e0d0f0eee0d0f0e000d0f0eee0d0f
-- 087:0eeeeeee0eeeeeee0eeeeeee00000000f0eeeeeef0eeeeeef0eeeeeef0eeeeee
-- 088:eeeeeeeeeeeeeeeeeeeeeeee00000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
-- 089:eeeeeee0eeeeeee0eeeeeee000000000eeeeee0feeeeee0feeeeee0feeeeee0f
-- 090:0000044400000444000000000000004400000004000000000000004400000444
-- 091:4044440440444404000000004044440440444404000000004444404444444044
-- 092:44404444444000000000444444404444444044440000044044000000444440dd
-- 093:04440888000008880444000004444044044440440044000400000000dddddddd
-- 094:0000060600006060000606060000606000060606000060600006060600006060
-- 095:0600000060600000060600006060600006060000606000000606000060600000
-- 097:00dd0e00f0dd0ee0f0000ee0f0ee0eee00ee0000f0eeeeeef0000000fff0fff0
-- 098:00000000ffffffff00000000040ee04000000000eeeeeeee00000000ffffffff
-- 099:00e0dd000ee0dd0f0ee0000feee0ee0f0000ee00eeeeee0f0000000f0fff0fff
-- 100:00d0e000f0d0e0eef0d0e0e0f0d0eee000d00000f0ddddddf0000000fff0fff0
-- 101:00000000e0eeee0ee0e00e0eeee00eee00000000dddddddd00000000ffffffff
-- 102:000e0d00ee0e0d0f0e0e0d0f0eee0d0f00000d00dddddd0f0000000f0fff0fff
-- 103:00000000ff0eeeeeff0eeeeeff0eeeee000eeeeeff000000ff000000ff000000
-- 104:00000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000
-- 105:00000000eeeee0ffeeeee0ffeeeee0ffeeeee000000000ff000000ff000000ff
-- 106:0000044400000044000000000000440400044404000444040000440400000000
-- 107:4444404444444044000000004444440444444404444444044444440400000000
-- 108:444400dd44000ddd00000ddd4400000044440ee044440ee044400ee000000000
-- 109:0000000004444444000000000404040400000000040404040040404000000000
-- 110:0000060600006060000000060000000000000000000000020000000200000022
-- 111:0606000060606000060600002200000022000000220000002200000002000000
-- 112:00000000000aaa0000aa0aa0a0aa00a0aaa00aa00000000000000000000aaa00
-- 113:00000000000aaa0000aa0aa0a0aa00a0aaa00aa00000000000000000000aaa00
-- 114:00000000000aaa0000aa0aa0a0aa00a0aaa00aa00000000000000000000aaa00
-- 115:000000000000000000d0d0d0000d0d0000d0d0d0000d0d0000d0d0d00000000d
-- 116:0dddddd00d0000d00004400000000000000440000000000000ffff00d0f00f0d
-- 117:00000000000000000d0d0d0000d0d0000d0d0d0000d0d0000d0d0d00d0000000
-- 118:0000000000004444444444404444444440044440400444000444440004004440
-- 119:0444440044000444004440004444444404444400004440000044400004404400
-- 120:0000000044400000444444404444444044440040044400400444440044400400
-- 121:0000000000000000000000000000000000000000000004440000400000044044
-- 122:0000000000000000000000000000000000000000444444440000000004444440
-- 123:0000000000000000000000000000000000000000444000000004000044044000
-- 124:000dddd0000dddd00000000000eeeeee00eeeeee0000000000eeeeee00eeeeee
-- 125:00dddd0000dddd00000000000eeeeee00eeeeee0000000000eeeeee00eeeeee0
-- 126:0000000000400040040404040040000004040444004004040404044400400400
-- 127:0000000004000400404040400000040044404040404004004440404000400400
-- 128:00aa0aa0a0aa00a0aaa00aa00000000000000000000aaa0000aa0aa0a0aa00a0
-- 129:00aa0aa0a0aa00a0aaa00aa00000000000000000000aaa0000aa0aa0a0aa00a0
-- 130:00aa0aa0a0aa00a0aaa00aa00000000000000000000aaa0000aa0aa0a0aa00a0
-- 131:0000000ddd000000d00000ffd04040f0d04040f0d00000ffdd0000000000000d
-- 132:d0ffff0d00000000f0dddd0ff0d00d0ff0d00d0ff0dddd0f00000000d0ffff0d
-- 133:d0000000000000ddff00000d0f04040d0f04040dff00000d000000ddd0000000
-- 134:0400444400444444004004440040044400044440000440440004444000000444
-- 135:4440444444000444444444440000000400000000444444440444440040000044
-- 136:4440040044444000440040004400400044440000404400004444000044000000
-- 137:0004000000000404000404400000040400040000000440440000000000000000
-- 138:0000000004044040404444040404404000000000444444440000000000000000
-- 139:0000400040400000044040004040000000004000440440000000000000000000
-- 140:0000000000eeeeee00eeeeee0000000000eeeeee00eeeeee00000000000dddd0
-- 141:000000000eeeeee00eeeeee0000000000eeeeee00eeeeee00000000000dddd00
-- 142:0000004404440444004404440440004400004440004444440040404400000000
-- 143:4400000044404440444044004400044004440000444444004404040000000000
-- 144:aaa00aa00000000000000000000aaa0000aa0aa0a0aa00a0aaa00aa000000000
-- 145:aaa00aa00000000000000000000aaa0000aa0aa0a0aa00a0aaa00aa000000000
-- 146:aaa00aa00000000000000000000aaa0000aa0aa0a0aa00a0aaa00aa000000000
-- 147:0000000d00d0d0d0000d0d0000d0d0d0000d0d0000d0d0d00000000000000000
-- 148:d0f00f0d00ffff00000000000004400000000000000440000d0000d00dddddd0
-- 149:d00000000d0d0d0000d0d0000d0d0d0000d0d0000d0d0d000000000000000000
-- 150:0004440000444000044400000444000004444440004444000000000000000fff
-- 151:0fffff00f0fff0f0ff0f0ff0ff0f0ff0fffffff00fffff00fffffff0ffffffff
-- 152:04440000004440000004440000044400444444000444400000000000ff000000
-- 153:0000000000004444000400000004044000040400000404000004040000044044
-- 154:0000000044444444000000004444444400000000000000000000000004444440
-- 155:0000000044440000000040000440400000404000004040000040400044044000
-- 156:000dddd000000000000dddd0000dddd00000000000ffffff00ffffff00000000
-- 157:00dddd000000000000dddd0000dddd00000000000ffffff00ffffff000000000
-- 158:0000000d000000d000000d0d00000d0d000000dd000000000000000000000000
-- 159:dd0000000dd000000dddddddd0000000d00fffff000fffff00000000000d0d0d
-- 161:00000000000000000000000000000000000000000000000002000000dd200000
-- 162:00000000000000000000000000000000000000000000000002000000dd200000
-- 163:0044044000400400004404400004004000440440000000000044404000404440
-- 164:4444444440044004440440440000000044444444400440044444444444044044
-- 165:0440440000400400044044000400400004404400000000000404440004440400
-- 166:0000000000033333000303030000d0d00000dddd000000000000dddd0000d000
-- 167:000000003333333303033030d0d00d0ddddddddd00000000d044440dd040040d
-- 168:0000000033333000303030000d0d0000dddd000000000000dddd0000000d0000
-- 169:0004000000000404000404400000040400040000000440440000000000000000
-- 170:0000000004044040404444040404404000000000444444440000000000000000
-- 171:0000400040400000044040004040000000004000440440000000000000000000
-- 172:0000444400004040000004040004444400444040044404044444444400404040
-- 173:4440000040400000040000004444000040444000040444004444444040404000
-- 174:0ddddd00ddd0ddd0d00000d0d0eee0d0d0e0e0ddd00000d0ddd0ddd0ddddddd0
-- 175:000d0d0d000d0d0d000d0d0d000d0d0d000d0d0d00000000000fffff000fffff
-- 176:000000000000020000002dd000000d0000000d0000000d0000000d0000000d00
-- 177:0d0002000d00dd200d000d000d000d000d000d000d000d000d000d000d000d00
-- 178:0d0000000d0000000d0000000d0000000d0000000d0000000d0000000d000000
-- 179:0000000000444040004044400040400400400040004400040000044000000444
-- 180:4040040444444444004444000404404040400404040440404040040004044040
-- 181:0000000004044400044404004004040004000400400044000440000044400000
-- 182:0000d0d00000ddd0000000000000000000000000000000000000000000000000
-- 183:d040040dd044440dd000000d0dddddd0d000000ddd0dd0dddd0dd0dddd0dd0dd
-- 184:0d0d00000ddd0000000000000000000000000000000000000000000000000000
-- 185:0000000000e0eeee0ee000000ee0eee00ee0eee0000000000ff0fff00f000000
-- 186:0eeeeee0ee0000eeee0440eeee0000eeeeeeeeee00000000ffffffff00000000
-- 187:00000000eeee0e0000000ee00eee0ee00eee0ee0000000000fff0ff0000000f0
-- 188:00000000fff0fff0f0000000f0eeeeee00ee000ef0ee040ef0ee000ef0eeeeee
-- 189:00000000ffffffff00000000eeeeeeee000ee000040ee040000ee000eeeeeeee
-- 190:000000000fff0fff0000000feeeeee0fe000ee00e040ee0fe000ee0feeeeee0f
-- 192:00ee0d00f0ee0d00f0000d00f0ee0d0000ee0000f0eeeeeef0000000fff0fff0
-- 193:0d000d000d000d000d000d000d000d0000000000eeeeeeee00000000ffffffff
-- 194:0d00ee000d00ee0f0d00000f0d00ee0f0000ee00eeeeee0f0000000f0fff0fff
-- 195:0000044400004444000004040000000000000004000440040004440400044444
-- 196:0404404004044040044004400000000044044044440440444404404444044044
-- 197:4440000044440000404000000000000040000000400440004044400044444000
-- 198:0000000000000000000dddd0000d00d0000dd0d0000dd0dd000dd00000000000
-- 199:dd0dd0dddd0dd0dddd0dd0dddd0dd0dd000dd000dd0dd0dddd0dd0dd00000000
-- 200:00000000000000000dddd0000d00d0000d0dd000dd0dd000000dd00000000000
-- 201:000eeeee0f0e000e0f0e04000f0e000e000eeeee0f0000000ff0fff000000000
-- 202:eeeeeeee000ee00004000040000ee000eeeeeeee00000000ffffffff00000000
-- 203:eeeee000e000e0f00040e0f0e000e0f0eeeee000000000f00fff0ff000000000
-- 204:000000000000000000000000000000000000000c000000c0000000c0000000c0
-- 205:000000000000000000000000000000000c0c000000c0c00c00c0c0cc00c0c0cc
-- 206:0000000000000000000000000000000000000000cccc00000c0cc000ccccc000
-- 207:0000000004444400040004000444440000040000000440000004000000000000
-- 208:0000000000000000000000ff00000f000000f0ee000f0e0000f0e00f00f0e0ff
-- 209:00000000ffffffff000000000eeeeeeeee00000e00088800ff08880f0f08880f
-- 210:00000000f00000000ff00000000f0000eee0f000000e0f00ff00e0f00ff0e0f0
-- 211:fff0fff0f0000000f0eeeeee00eeeeeef0ee0000f0ee0404f0ee004000ee0404
-- 212:ffffffff00000000eeeeeeeeeeeeeeee00000000040440404040040400000000
-- 213:0fff0fff0000000feeeeee0feeeeee000000ee0f4040ee0f0400ee0f4040ee00
-- 214:4444444440000000404444444040404040440404404040404004040040404400
-- 215:4040404004040404444444444000004000000004000000000000000000000000
-- 216:4040404004040404444040404044040404044040404044040404044004404044
-- 217:4400000444040404400000440040404400000000040400400000044004044440
-- 218:4444444440444044404440440000000400000000000000000000000000000000
-- 219:0000044004040440400000404040400000000000400404004400000044440400
-- 220:000c000c00c0cc0c00000000000cccc000c00000000000000000000000000000
-- 221:0cc0c0cc00cc0c0000000000000000000000000c00000cc00000000c00000000
-- 222:c0ccc00cccc00cc0c0c0000c0000c0000000cc00000000000000000000000000
-- 223:0000000002222200020002000222220000020000000220000002000000000000
-- 224:00f0e0f000f0e0ff0f00e0000f0e00880f0e08880f0e00880f00e00000f0e0ff
-- 225:0f08880fff08880f0000000088044408880444088804440800000000ff08880f
-- 226:00f0e0f0fff0e0f00000e00f88800e0f88880e0f88800e0f0000e00ffff0e0ff
-- 227:f0ee0040f0ee0404f0ee0040f0ee0404f0ee0404f0ee0040f0ee0404f0ee0040
-- 228:0444444004044040044444400004400004444440040440400004400004444440
-- 229:0400ee0f4040ee0f0400ee0f4040ee0f4040ee0f0400ee0f4040ee0f0400ee0f
-- 230:4044440040444000400000004444440040000400400004004000400040040000
-- 232:0444404400444044000040440000404400004044000040440000404400004044
-- 233:0000044044440040444400004404400004004000440040004400400004440000
-- 235:4400000040044440000444400044044000400400004004400040044000044400
-- 236:000000000000000000000000000000000000000c000000c0000000c000000c00
-- 237:000000000000000000000000000000000cc0000cc00cc0ccc0c000ccc0c0c0cc
-- 238:000000000000000000000000ccccc0000ccc0c0000c00cc00ccc0cc0c0c0ccc0
-- 239:0000000006666600060006000666660000060000000660000006000000000000
-- 240:00f0e0f000f0e0ff00f0e00f000f0e000000f0ee00000f00000000ff00000000
-- 241:0f08880f0f08880fff08880f00088800ee00000e0eeeeeee00000000ffffffff
-- 242:00f0e0f00ff0e0f0ff00e0f0000e0f00eee0f000000f00000ff00000f0000000
-- 243:00ee0404f0ee0040f0ee0404f0ee000000eeeeeef0eeeeeef0000000fff0fff0
-- 244:00000000404004040404404000000000eeeeeeeeeeeeeeee00000000ffffffff
-- 245:4040ee000400ee0f4040ee0f0000ee0feeeeee00eeeeee0f0000000f0fff0fff
-- 246:4440000040000000404400004044000040444400404444004044440044444400
-- 248:0000404400004044000040440000404404444044044400440444044404444444
-- 249:4440000044400000040000004440000044400000444440004444444044444440
-- 251:0000444000004440000004000000444000004440004444404444444044444440
-- 252:00000c0c00000c0c000c0c0c0ccc00c000cc000000c000000000000000000000
-- 253:0c00c00c0c00c00c0cc00c0000000000000c00000cccc000cc0c0c0000000000
-- 254:cccccc000c0c0c0000000000ccccc0c00000000c00000ccc0000c0c000000000
-- 255:0000000009999900090009000999990000090000000990000009000000000000
-- </TILES>
-- <SPRITES>
-- 000:fffffffffffffffffffffffffffffffffffffff0fffffff0fffffff0fffffff0
-- 001:ffffffffffffffffffffffff0000000f04444400444444404444444044444440
-- 002:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 003:fffffffffffffffffffffffffffffffffffffff0fffffff0fffffff0fffffff0
-- 004:ffffffffffffffffffffffff000000ff04444400444444404444404044404440
-- 005:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 006:fffffffffffffffffffffffffffffffffffffff0fffffff0fffffff0fffffff0
-- 007:ffffffffffffffffffffffff000000ff04444400444444404444404044404440
-- 008:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 009:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 010:fffffffffffffffffffffffff000000000444440044444440444444404444444
-- 011:ffffffffffffffffffffffffffffffff0fffffff0fffffff0fffffff0fffffff
-- 012:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000
-- 013:fffffffffffffffff00000000044444004444444044444440444444404444444
-- 014:ffffffffffffffffffffffff0fffffff0fffffff0fffffff0fffffff00000fff
-- 015:04444400444444404404044044444440440004400444440000444000ffffffff
-- 016:fffffff0fffffff0fffffff0fffffff0ffffff00fffff004fffff044fff00044
-- 017:4444444004444400004440009900099009909900090909040909090409090904
-- 018:ffffffffffffffffffffffffffffffffffffffff0fffffff40ffffff4000ffff
-- 019:fffffff0fffffff0ffffffffffffff00ffff0004fff00404ff004400ff044440
-- 020:444400000444440f0044400f9990090f00990900090999040909090409090900
-- 021:ffffffffffffffffffffffff000fffff0400ffff0440ffff0440ffff0000ffff
-- 022:fffffff0fffffff0fffffffffffffff0ffffff00ffffff04ffffff04ffffff00
-- 023:444400000444440f0044400f9990090f0099090f090999000909090044090904
-- 024:ffffffffffffffffffffffffffffffffffffffffffffffff0fffffff0fffffff
-- 025:fffffffffffffffffffffffffffffff0ffffff00fffff004ffff0044ffff0444
-- 026:0444444400444440f00444000090009040990990409090900090909040909090
-- 027:0fffffff0fffffffffffffff00ffffff400fffff4400ffff04400fff44440fff
-- 028:ffff0404ffff0444ffff0044fffff004ffffff00fffffff0ffffffffffffffff
-- 029:004444404004440000900090409909904090909000909090f0909090f0909090
-- 030:04040fff44440fff04400fff4400ffff400fffff00ffffffffffffffffffffff
-- 031:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 032:fff04440fff00444ffff0440ffff0000fffffffffffffff0fffffff0fffffff0
-- 033:09090900099099040900090000d0d0000d000d0f00d0d000ddd0ddd000000000
-- 034:4440ffff4400ffff440fffff000fffffffffffffffffffffffffffffffffffff
-- 035:ff000400ffff0000ffffff0dffffff0dffffff0dffffff00ffffffffffffffff
-- 036:0909090f0909090fd0d0d0000d0d0d0d0000d0dd0ff00dd0ffff0000ffffffff
-- 037:ffffffffffffffff0fffffff0fffffff0fffffff0fffffffffffffffffffffff
-- 038:fffffff0fffffff0fffffff0ffffff00ffffff0dffffff0dffffff0dffffff00
-- 039:4409090404090900d0d0d0d00d000d00d000d0000000ddd0dd000000000fffff
-- 040:0fffffff0fffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 041:ffff0404ffff0000ffffffffffffffffffffffffffffffffffffffffffffffff
-- 042:0090909000990990f0900090f00d0d00f0d000d0f0dd0dd0f0dd0dd0f0000000
-- 043:04040fff00000fffffffffffffffffffffffffffffffffffffffffffffffffff
-- 044:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 045:f0990990f0900090f00d0d0000dd0dd00ddd0ddd0dd000dd0d0fff0d00fffff0
-- 046:ffffffffffffffffffffffff0fffffff0fffffff0fffffff0fffffff0fffffff
-- 047:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 048:fffffffffffffffffffffffffffffffffffffff0fffffff0fffffff0fffffff0
-- 049:ffffffffffffffffffffffff0000000f04444400444444404444444044444440
-- 050:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 051:fffffffffffffffffffffffffffffffffffffff0fffffff0fffffff0fffffff0
-- 052:ffffffffffffffffffffffff0000000f04444400444444404444444044444440
-- 053:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 054:fffffffffffffffffffffffffffff000ffff0044ffff0444ffff0440ffff0444
-- 055:ffffffffffffffffffffffff0000ffff44400fff44440fff40440fff44440fff
-- 056:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 057:fffffffffffffffffffffffffffffff0ffffff00ffffff04ffffff04ffffff04
-- 058:ffffffffffffffffffffffff000000ff4444400f4444440f4040440f4444440f
-- 059:fffffffffffffffffffffffffffffffff000ffff00400fff04440fff04040fff
-- 060:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 061:ffffffffffffffffffffffffff000000f0044444f0444444f0440404f0444444
-- 062:ffffffffffffffffffffffff0fffffff00ffffff40ffffff40ffffff40ffffff
-- 063:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 064:fffffff0fffffff0fffffff0fffffff0ffffff00fffff004fffff044fff00044
-- 065:4444444004444400004440009900099009909900090909040909090409090900
-- 066:ffffffffffffffffffffffffffffffff0fffffff0fffffff00ffffff40ffffff
-- 067:fffffff0fffffff0fffffffffffffff0ffffff00ffffff04fffff004fffff040
-- 068:44444440044444000044400f9900099009909900090909040909090409090904
-- 069:ffffffffffffffffffffffffffffffff0fffffff00ffffff40ffffff4000ffff
-- 070:ffff0440ffff0044ffff0004ffff0990fff00099ff004090ff04409000044090
-- 071:00440fff44400fff44000fff00990fff09900000909040449090440490904444
-- 072:ffffffffffffffffffffffffffffffff0000000f444444004440044044444400
-- 073:ffffff04ffffff00ffffff00ffffff09fffff000ffff0040ffff0440ff000440
-- 074:4000440f4444400f0444000f9000990f99099000909090409090904490909004
-- 075:04040fff04440fff04440fff04440fff044400ff040440ff444400ff444440ff
-- 076:ffffffffffff0000ffff0444ffff0044ffff0444fff00444fff04044fff04440
-- 077:f044000400044444000044400099000904099099440909094409090940090909
-- 078:40ffffff00ffffff00ffffff90ffffff000fffff0400ffff0440ffff044000ff
-- 079:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 080:fff04440fff00444ffff0440ffff0000fffffff0fffffff0ffffffffffffffff
-- 081:09090904099099040900090000d0d00fddd00d0f00000d0ffff0d000fff0ddd0
-- 082:40ffffff40ffffff00ffffffffffffffffffffffffffffffffffffffffffffff
-- 083:fffff044fffff044fffff000fffffffffffffffffffffffffffffff0fffffff0
-- 084:09090900099099040900090000d0d0000d00ddd00d00000000d0ffffddd0ffff
-- 085:4440ffff4400ffff440fffff000fffffffffffffffffffffffffffffffffffff
-- 086:0444009000444099f0440090f000000dfffff0d0ffff000dffff0dddffff0000
-- 087:9090044009904440009000000d00ffff00d0ffff0d000fff0ddd0fff00000fff
-- 088:4000000f00ffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 089:ff044400ff004440fff04400fff00000fffffff0ffffff00ffffff0dffffff00
-- 090:90909000990990f0900090ff0d0d00ffd000d0ff0d0d000fdd0ddd0f0000000f
-- 091:440440ff004440fff00000ffffffffffffffffffffffffffffffffffffffffff
-- 092:fff04440fff04440fff04440fff04040fff04040fff04440fff00400ffff000f
-- 093:00090909ff099099ff090009ff00d0d0ff0d000df000d0d0f0ddd0ddf0000000
-- 094:004440ff044400ff00440fff00000fff0fffffff00ffffffd0ffffff00ffffff
-- 095:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 096:ffffffffffffffffffffffffffffff00ffffff03ffffff00fffffff0fffffff0
-- 097:ffffffffffffffff000000000333333030333003330333003333003303330000
-- 098:ffffffffffffffffffffffff0fffffff00ffffff30ffffff30ffffff30ffffff
-- 099:ffffffffffffffffffffff00ffffff03ffffff00fffffff0fffffff0ffffffff
-- 100:ffffffff00000000033333303033300333033300333300330333000000003300
-- 101:ffffffffffffffff0fffffff00ffffff30ffffff30ffffff30ffffff000fffff
-- 102:fffffffffffffffffff000f0fff03000fff03303fff00330ffff0330ffff0033
-- 103:ffffffffffffffff000000003333333300333300300330030333333000000000
-- 104:ffffffffffffffff0f000fff00030fff30330fff03300fff0330ffff3300ffff
-- 105:fffffffffffffffffffffffffff000f0fff03000fff03303fff00333ffff0333
-- 106:ffffffffffffffffffffffff0000000033333330333333333333333333333333
-- 107:fffffffffffffffffffffffff000ffff0030ffff0330ffff3300ffff330fffff
-- 108:fffffffffffffffffffffffffffffffffffffff0fffffff0fffffff0fffffff0
-- 109:ffffffffffffffffffffffff000000ff04444400444444404444404044404440
-- 110:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 111:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 112:fffffffffffffff0fffff000ffff0033fff00333fff03330f0003300f0333300
-- 113:0000330000330033330330003070330007070303707070330707070370707000
-- 114:000fffff330fffff000ffffff000ffff003000ff303330ff333300ff333330ff
-- 115:ffffff00fffff003ffff0033ffff0333ffff0330ffff0033fffff003ffff0030
-- 116:0333003333033000307033030707030370707033070303033033030333333300
-- 117:330fffff000fffff030fffff300fffff330fffff300fffff030fffff000fffff
-- 118:ffff0000ff000333ff033300f0033007f0330f00f0330f000033300703030300
-- 119:3333333303033030703333070733337070333307703333070733337070333307
-- 120:0000ffff333000ff003330ff7003300f0000330f00f0330f70f0330f00f0330f
-- 121:ffff0033ffff0000ff000333ff033300f0033007f0330000f0330f07f0330f00
-- 122:3333333333333330030303037077707007777707707770700777770770777070
-- 123:300fffff000fffff33000fff03330fff003300ff000330ff0033300f0303030f
-- 124:fffffff0fffffff0ffffff00ffff0004fff00404fff04400fff04440fff00400
-- 125:444400000444440f0044400f0990090f00990900090999040909090409090900
-- 126:ffffffffffffffffffffffff000fffff0400ffff0440ffff0440ffff0000ffff
-- 127:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 128:f0033300f0333000f0000000ffff0033fff00333fff03333fff00303ffff0000
-- 129:070707003330333333000033330f0033300f0303300f0000030fffff000fffff
-- 130:003300ff000330ff300000ff33300fff03030fff00000fffffffffffffffffff
-- 131:f0000333f0333330f0333300f033000ff03030fff00000ffffffffffffffffff
-- 132:0333303300330303f0003003fff000f0ffffff03ffffff03ffffff00ffffffff
-- 133:00ffffff300fffff330fffff33000fff333300ff303030ff000000ffffffffff
-- 134:0303000000000ff0fffffff0fffff000ffff0033fff00333fff03030fff00000
-- 135:0303303033000033330ff033330ff033330ff033330000333030030300000000
-- 136:0f00330f0003330000303030000030303300000033300fff03030fff00000fff
-- 137:f03300f000333000030303000303000000000033fff00333fff03030fff00000
-- 138:03070300330003333300333333003030330000003330ffff3030ffff0000ffff
-- 139:0003030f0000000f3300ffff3030ffff0000ffffffffffffffffffffffffffff
-- 140:ffff0000fffff000ffff00d0fff00dddfff0ddd0fff00000ffffffffffffffff
-- 141:0909090f09090900d0d0d0d00d000d0d000f0000fffffff0ffffffffffffffff
-- 142:0000ffff0dd0ffffddd0ffffdd00ffffd00fffff00ffffffffffffffffffffff
-- 143:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 144:0000000f440044004000400440000444404044444040444400004000fff00040
-- 145:ffffffff0000ffff444000ff4444400f44004400400400400000004040404040
-- 146:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 147:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 148:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 149:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 150:ff0000ffff0440ffff0400f0ff040000ff040404ff040404ff000000fff00440
-- 151:fffffffff0000000004444404444444440044400004040400000400040404040
-- 152:fff0000ffff0440f00f0040f4000040f4404040f0404040f0000000f404400ff
-- 153:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 154:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 155:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 156:fffffffffffffffffffffffffffffffffffffff0fffffff0fffffff0fffffff0
-- 157:ffffffffffffffffffffffff0000000f04444400444444404404044044444440
-- 158:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 159:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 160:f0444400f0444444f0000000f044004000400000044004000440000004400400
-- 161:0000000044444400000044400004044000000040000400000000004400400044
-- 162:ffffffffffffffff00ff000f4000040040404440400044404000444040404400
-- 163:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 164:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 165:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 166:fff04040ff004444ff040000f0000444f0400444f00000040040040404444004
-- 167:0000000044040404040404040000000040444440404040404044444044040404
-- 168:004040ff4444400f0000040f0444000044440040440000004404004044000000
-- 169:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 170:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 171:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 172:fff000f0ff004000ff044400ff044404ff004404fff00000ffffffffffffffff
-- 173:4400044004444400004440000900090409909904090909000909090f0909090f
-- 174:f000fffff0400fff04440fff04440fff04400fff0000ffffffffffffffffffff
-- 175:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 176:044000000440444400404444f00004440000000004440004444440004444444f
-- 177:00000444444004444040004040000000000000000004004000000000fffffff0
-- 178:0000000f0ff0000f0000440f4004440f0044440f0044440f0444400f000000ff
-- 179:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 180:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 181:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 182:044040000444000000000000fffff040fffff000fffff040fffff000fffff044
-- 183:4404440404444444000040000000000000040400000000000004040044440444
-- 184:40004040000444400004044000404440000000000040ffff0000ffff4440ffff
-- 185:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 186:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 187:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 188:fffffffffff0000ffff0dd00fff0ddd0fff00dddffff0dddffff0000ffffffff
-- 189:0909090f0909090f09090900d0d0d0d00d000d0d000f000d0fffff00ffffffff
-- 190:ffffffff0000ffff0dd0ffffddd0ffffdd00ffffdd0fffff000fffffffffffff
-- 191:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 192:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 193:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 194:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 195:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 196:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 197:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 198:fffff44fffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 199:4f44f44fffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 200:4f44ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 201:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 202:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 203:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 204:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 205:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 206:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 207:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 208:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000f
-- 209:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 210:ffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000
-- 211:fffffffffffffffffffffffffffffff0ffffff00fffff004ffff0040fff00400
-- 212:ffffffffff00000000044444044444444000000000ffffff0fffffffffffffff
-- 213:ffffffff0000ffff4440ffff4440ffff0000ff44004000440440404004404040
-- 214:000000000000000000000000000000ee0000ee0e000eee0e000eeeee00eeeeee
-- 215:0000000000000000eeeeeeeeeeeeeeeeeeeee00eeeeeeee0eeeeeee0eeeeeeee
-- 216:000000000000000000000000e0000000eee000000eee000000ee0000000ee000
-- 217:ffffffffffffffffffffffffffffffffffffff00fffff004fffff044fffff044
-- 218:ffffffffffffffffffffffffffffffff00000fff444400ff444440ff040440ff
-- 219:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 220:ffffffffffffffffffffffffffffffffffffff00fffff004fffff044fffff044
-- 221:ffffffffffffffffffffffffffffffff00000fff444400ff444440ff040440ff
-- 222:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
-- 224:ff00040f0004040f4440440f0404040f0400040f0400000f444400ff444440ff
-- 225:fffffffffffffffffffffffffffffffffffffffffffffff0ffffff00ffff0004
-- 226:0400444004044044040400040404040404040440040400004404440044000400
-- 227:fff0400ffff040fffff0400f0000040004440040440040044040404440440040
-- 228:ffffffffffffffffffffffffffffffff0fffffff000000004444444000000040
-- 229:0440404004404044044044440440404404404040000040404040004000004044
-- 230:00eeeeee0eeeeeee0eeeeeee0eeeeeee0eeeeeee0eeee0ee0eeee0ee00eeee0e
-- 231:e0eeeeee0eeeeeee0eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
-- 232:00eee000eeeee000eeeeee00eeeeee00eeeeee00eeeeee00eeeeee00eee0e000
-- 233:fffff0440000004004040004004400000444009900440009f0000409ff040409
-- 234:444440ff000040ff000400ff444000ff000990ff9099000f0909040009090440
-- 235:ffffffffffffffffffffffffffffffffffffffffffffffffffffffff0fffffff
-- 236:fffff0440000004004040004004400000444009900440009f0000409ff040409
-- 237:444440ff000040ff000400ff44400f0000099004909900400909044009090440
-- 238:ffffffffffffffff00000fff444400ff0000400f400004000040404000000040
-- 240:400040004000404400404040404040404040404400404000f0004444fff00444
-- 241:0000044444440404000444044404440444440444000000444444440044444444
-- 242:44040400040404000404040f0404040f4404040f4004040f0444000f44000fff
-- 243:440004400440044400440044f0044000ff004440fff00444ffff0000ffffffff
-- 244:44444040044440404000004044444040000000004444444400000000ffffffff
-- 245:4040004400004000404000ff040040ff000400ff44400fff0000ffffffffffff
-- 246:00eeee0e000eee0e000eeee00000eeee00000eee0000000e0000000000000000
-- 247:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0eeeeeeeeeeeeeeee0eeeeee000000000
-- 248:ee0ee000ee0e0000e0ee00000ee00000ee000000000000000000000000000000
-- 249:ff000409ffff0009ffffff09ffffff09ffffff00ffffff0dfffff000fffff0dd
-- 250:090900440909000490990f0400090f04d0d00f04000d0f00d0d000ffd0ddd0ff
-- 251:00000fff44440fff44000fff4040ffff0400ffff000fffffffffffffffffffff
-- 252:ff000409ffff0009ffffff09ffffff09ffffff00ffffff0dfffff000fffff0dd
-- 253:09090040090900449099000400090f00d0d00fff000d0fffd0d000ffd0ddd0ff
-- 254:4004004000000040444444004400000f000fffffffffffffffffffffffffffff
-- </SPRITES>
-- <MAP>
-- 000:101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 001:100000000000000010101010000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 002:100000000000000010101010001010101010405060101010101010101010405060101010101000100010101010101010101010101010101010101010101022101111111111111111111111111111111111111111111111111111111111fe0000000011111111111110101010101010101010101010111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 003:100000000000000062626262001000610000000013000061001000001300000000000000001000100010000000000000000000000031000000100000000000101111111111111111000000000000000000000000001111111111111111000000000000111111000020000000000000000000000010101111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 004:100000000000000010101010001000000000000000000000001000001300000000000000001000100010001000101010101010001010101010100010101000101111111111110000000000000000001111111100001111111111111111111111110000111100000010101010101010100000000000101011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 005:101010101010101010101010001000610000000000000061001000410000410041000041001000100010101000100000000010001000000000100000011000101111111100000000000000000000001111111111001111111111111111111111111100111100000022000000000000100000000000101011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 006:101010101010101010101010001010101010101010101010101010101010101010101010101000100000000000100000004110001000000000100004021000101111110000000000111110304060301011111111001111111111111111111111111100111100000010411300ff0041100000000000001011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 007:10101010101010101010101000000000000000000000000000000000000000000000000000000010001010101010000000001000220000130010000003100010111111610000611111111000000000101111111100111111111111111111111111110011110000001010101010101010000000a100001011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 008:1000000013001000000000102010b0000000b01010101040601010101010101040601010101000100000000000220000004110001000000000100010101000101111111300000011101010405050601010101141004111111111111100000000001100110000000032000000000000100000725272001011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 009:1071000000003200800000130010000000000010000000000013800010000000000000000010001010101010101000130000100010000080001000000000fe101111116100006111107100727272727272100000000011111111110000000000000000000000000010411300fd0041100000000000001011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 010:10c0000000001000000000000010b0000000b01000f000000000f0001000f000000000f000100010004100410010101010101000101010101010201010101010111111111111111130c000008072720000300000000011111111110400000000000000000000000010101010101010100000000000001011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 011:100000000013100000000000801000000000001000000000000000001000000080000000001000100000000000000020000000000000000000220000000000101111111111111111101300000000800004207200000011111111110000000000000000000000000012000000000000100000000000001011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 012:1010101010101040506010100010b0000000b01000f013000000f0001000f000000000f01310001000000000001310101010101010101010001000f013f000101111111111111111101010101010701010100000001111111111110000000000000000000000000010411300fc0041100000000000001011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 013:100000000000000000000010001000000000001000000000000000001000000000000000001000102210101010101000000000000000001000101300000000101111111111111111900000000000727272900000001111111111111100000000000000000000000010101010101010100000000000101011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 014:1000101010101010101000101010b0000000b01010101040601010101010101040601010101000100000100000000000000000000000130000100000000000101111111111111111000000000000000000000000001111111111111100000000000000000000000042000000000000000000000010101111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 015:100010ff0000000000100010000000000000000000100000000000000000000000000000000000100000100000000000f00000f00000130000100000710000101100000000000000000000000000000000000000111111111111111111000041000041000000000010101010101010101010101010111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 016:10001000f00000f013100010000030405060300000100010101010101032103210101010101000100000100000100000000000000000001000100000c00000101100001111111111000000000000000000001111111111111111111111111111111111111111111111111111111111111111111111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 017:100010000000000000100010000030e0e0e0300000100010008013000000100000000000001000100000100000101300000000000000001000100000000000101100111111111111111111111100111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 018:100010000000000000010010000030e0e0e030000010001000f00000f000100000000000801000100000100000100000f00000f00000131000101010101010101100111110101010101010101020101010101010101011111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 019:100010000000000013030010101010101010101010100010000000000080100000000000001000100000100000100000000000000000001000000000000000101100111110130000800000000000000000800000001011111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 020:10001000000000000010001000000000000000000010001000f00000f000100000000000001000100000100000101010101010104060101000101040506010101100111110003040506010101010101040506030001011111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 021:10001000f00000f00010001000b000b000b000b000100010000000130000108000000000001000100000100000000000000010000000001000100000000000101100111110001000000001a00000130000000010001011111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 022:10001013000000000010001000000000000000000010001000f00000f0001000000000008010001000001010405060101000104100004110001000f000f000101100111110001013000002000000000000000010801011111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 023:100010101010101010100010000000727272000000100010000000000000100000000080001000100000100000000000100010000000001000102300000000101100111110001000000002130000000000000010001011111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 024:1000000000000000000000100000007273720000001000101010101010101010101010101010001000001000000080001000100000000010001000f000f000101100111110001000000002000000000013000010001011111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 025:103210101010101010101010000000000000000000100000000000100000000000000000001000100000100000000000100010410000411000100000000000101100111110001000001303a00400800000000010001011111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 026:10000000000000000000001000b000b000b000b0001010221010003200000000000000000010001000001010405060101000100000000010001000f000f000101100111110003040506010101010701040506030e01011111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 027:10101010101010103210001000000000000000000010000000100010000000725272000000100010000010000000000010001010222210100010000000000010110011111013000000000000000000000000e0e0e01011111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 028:10b00000000000b000100010101010101010101010100000001000100013000000000000001000100000104100000041100010000000001000100072527200101100111110e0e0101010101010101010101010e0e01011111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 029:100000727272000100100010000000000000800000100072001000100000000000000000fd1000100000100000000000100010000000001000102300000000101100111110e0e0e021e0e0e0e0e021e0e0e0e0e0e01011111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 030:100000727372000300100001008000725272000000100005001000101010101010101010101000100000100000000000100010101010101000101010101010101100111110e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e01011111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 031:10b00000000000b00010000300000000000000000010000000100020000000000000000000000010000010000000000010000000000000000020000000000010110011111021e0e0e0e0e021e0e0e0e0e021e0e0e01011111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 032:101010101010101010101010101010101010101010101010101010101070104050601070101010104060101010101010101010101010101010101010101020101100111110101010101010101010101010101010101011111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 033:100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101111111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 034:100010101010101010101010101010101010101010101010101010101070701010107070101070701010707010101010101010101010101010101010101010101111111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 035:100010000000000000000000000000001000000000000000000000001000000000000000100000000000000000000000000000000000001000000000000000101100001111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 036:100010001010101040506010101010001000303030405060303030001000800000000000100010101010101010406010101010101010001000f000f0000000101100000000101010101010101010101010101010101010101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 037:10001000100000000000000000001000100030e0e0e0e0e0e0e030001013000000000000100010000000000000000000000000000010001000000000001000101100000000000000000000000000130000000000000000101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 038:100010001000a00000a00000a0001000100030e0e0e0e0e0e0e030001010101000101010100010001010101010406010101010100010001000f000f0001000101111000000000000000000000000000000000000000000101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 039:10000000100000000000000000001000100030e0e0e0e0e0e0e030001000000000000000100010001080000000000000800000100010001000000000001000101111110000101010101010101010101010405050505060101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 040:101010101010101010101010101010001000303030303030303030001000a0000000a00010001000100000800080000000000010001000104210001042100010111111000010130000000000fee0e01010000000000000101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 041:10000000000000000000000000001000120000000000000000000000100000000000000010001000100080000000008000000010001000100010001000100010111111000410000000000000e0e0e01010405050505060101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 042:10e01010101010101010101010e010101010101010e0e0e010101010101010e0e0e0101010001000101010101040601010101010001000100010001000100010111111000010000000000000e0e0e00113000000000000101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 043:10e0e0e0e0e0e0e0e0e0e0e010e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e010001000000000001000001000000000001000100010001000100010111111000010000000000000e0e0e00200000000000000101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 044:1010101010101010101010e010e010101010101010e0e0e01010101010101010101010e010001010101010101000001010101010101000100010001000100010111111000010000000000000e0e0e00200000000000000101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 045:1000000000000000120010e010e010000000000010e0e0e010e0e0e0e0e0e0e0e0e0e0e01000100000001300000000000000001300100010001000100010001011111100001010221000e0e0e0e0e00200000013000000101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 046:100010001000100010e010e010e01000f000f01310e0e0e010e01010101010101010101010001013000000131000131013000000001000100000000000100010111111130000000010e0e0e0e0e0e00200000000000000101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 047:100010001000100010e0e0e010e010000000000010e0e0e010e010e0e0e0e0e0e0e0e0e010001000130000001000801000001300001000101010421010100010111111000000000010e0e0e0e0e0e00300000000000000101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 048:10001000100010001010101010e010101010e0e010e0e0e010e010e010101010101010e0100010101010101010000010101010101010001000000000001000101111111300000000101010101010101010101010101010101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 049:10001000100010000000000010e0e0e0e0e0e0e010e0e0e010e010e01000000000d010e0100010000000000000000000000000000010001000f000f0001000101111111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 050:10001000100010101010100010101010101010e010e0e0e010e010e01013000000c010e010001000f000f0001080001000f000f00010001013000000001000101111111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 051:10001000100000000000100000000000000010e010e0e0e010e010e010e0e010101010e0100010000000000010000010000013000010001000f000f0001000101111111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 052:10001000101010101000101010701070100010e010e0e0e010e0e0e010e0e0e0e0e0e0e0100010101010101010424210101010100010001000000000131000101111111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 053:10001000000010001000000000000000100010e010e0e0e0101010101010101010101010100010001000000000000000000000100010001000000000001000101111111010101010101010101010101010101010101010101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 054:10001010101010001010101010101000100010e010e0e0e01021e0e0e0e01000410041000000100010004100410000410041001000100010101042101010001011111110f01300f010f000f010f000f010000000000000101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 055:10001000000010000000000000000000100010e010e0e0e010e0e0e021e0100000000000101010001010101010101010101010100010101000a000a0001000101111111000ff00001000fd001000fc0010000000000071101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 056:10001000100010101010101010101010100010e010e0e0e010e02110e0e01000f000f0001000000000000000000000000000001000000000130000000010001011111110000000001000000010000000100000000000c0101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 057:10000000100000000000000000100000000010e010e0e0e010e0e010e0e0100000000000101010101010101010101010101010101010101010101010101000101111111013000000101300001013000010000000000000101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 058:10101010101010701070102010101010101010e010e0e0e010e0e010e0211000f000f000100000001300100000000000000010101010101010000000000000101111111010102210101032101010121010104210101010101111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 059:10000000000000001313000000100000120010e010e0e0e01021e010e0e01000000000001000000000001000f0000000f00010101010101010000000101010101111111111000000130000001300000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 060:1013800013001300000000000010800010e010e010e0e0e010e0e01021e0100072527200100000000013100000000013000010101010a000000000000000a0101111111100000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 061:1000000000000000000000000010fc0010e0e0e010e0e0e010e02110e0e0100000000000000013000000000000000000000010101010000000725272000000101111111100000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 062:1010e0e0e010101010101010101010101010101010e0e0e010e0e010e021101010101010101010101010101010e0e0e0101010101010a000000000000000a0101111111100000000000011111111110000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 063:10e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e010e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0101010100000007252720000001011111111fe000000001111111111111111000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 064:10e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e010e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e0e010101010a000000000000000a0101111111111110000111111111111111111110000000004001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 065:101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101111111111111111111111111111111111110000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 066:111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- 067:111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-- </MAP>
-- <WAVES>
-- 000:9ceffffeb853100122468aceeeddcba9
-- 001:0123456789abcdeffedcba9876543210
-- 002:0123456789abcdef0123456789abcdef
-- </WAVES>
-- <SFX>
-- 000:a030b050b070b080b080c080c070d050e030b020b030a030a05090609080809080b070c060b060a060906080607070609050a040a030b020c020d010507000000000
-- </SFX>
-- <PALETTE>
-- 000:1a1c2c5d275db13e53ef7d57ffea75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
-- </PALETTE>
|
local model = require "tiled.model"
local function TileAdapter(...)
local self = {
indices = arg
}
function self.getDataIterator(tiledTable)
local layerIdx = 1
local dataIdx = 1
return function()
while layerIdx <= #tiledTable.layers do
local layer = tiledTable.layers[layerIdx]
if layer.data ~= nil then
while dataIdx <= #layer.data do
local gid = layer.data[dataIdx]
horizontalOffset = ((dataIdx - 1) % layer.width)
verticalOffset = math.floor((dataIdx - 1) / layer.width)
dataIdx = dataIdx + 1
if gid > 0 then -- do not return tiles without image
return {
objectData = layer,
gid = gid,
layerName = layer.name,
horizontalOffset = horizontalOffset,
verticalOffset = verticalOffset
}
end
end
end
dataIdx = 1
layerIdx = layerIdx + 1
end
end
end
function self.adaptData(selector, data)
local tile = model.Tile(selector, data.layerName, data.gid, 0, 0, 0, 0)
local tileInfo = tile.getTileInfo()
local x = data.objectData.x + tileInfo.width * data.horizontalOffset
local y = data.objectData.y + tileInfo.height * data.verticalOffset
tile.setSize(tileInfo.width, tileInfo.height)
tile.setCoordinates(x, y)
return tile
end
return self
end
local function ObjectAdapter(...)
local self = {
indices = arg
}
function self.getDataIterator(tiledTable)
local layerIdx = 1
local objectIdx = 1
return function()
while layerIdx <= #tiledTable.layers do
local layer = tiledTable.layers[layerIdx]
if layer.objects ~= nil then
while objectIdx <= #layer.objects do
local objectData = layer.objects[objectIdx]
objectIdx = objectIdx + 1
return {
objectData = objectData,
layerName = layer.name
}
end
end
objectIdx = 1
layerIdx = layerIdx + 1
end
end
end
function self.adaptData(selector, data)
local classes = {}
if data.objectData.properties ~= nil then
if data.objectData.properties.class ~= nil then
for class in string.gmatch(data.objectData.properties.class, "[^%s]+") do
table.insert(classes, class)
end
end
if data.objectData.gid then
return model.Object(
selector,
data.layerName, data.objectData.gid,
data.objectData.x,
data.objectData.y - data.objectData.height,
data.objectData.width,
data.objectData.height,
data.objectData.properties.id, classes
)
elseif data.objectData.polyline then
return model.Shape(
data.layerName,
data.objectData.x,
data.objectData.y,
data.objectData.properties.id, classes,
model.BoundsFactory(data.objectData.polyline),
data.objectData.properties.offsetX,
data.objectData.properties.offsetY
)
else
return model.Rectangle(
data.layerName,
data.objectData.x,
data.objectData.y,
data.objectData.width,
data.objectData.height,
data.objectData.properties.id, classes
)
end
end
end
return self
end
local function TilesetAdapter(...)
local self = {
indices = arg
}
function self.getDataIterator(tiledTable)
local tilesetIdx = 1
return function()
while tilesetIdx <= #tiledTable.tilesets do
local tileset = tiledTable.tilesets[tilesetIdx]
tilesetIdx = tilesetIdx + 1
return {
objectData = tileset
}
end
end
end
function self.adaptData(selector, data)
return model.Tileset(
data.objectData.firstgid, data.objectData.image,
data.objectData.tilewidth, data.objectData.tileheight,
data.objectData.imagewidth, data.objectData.imageheight
)
end
return self
end
return {
Tile = TileAdapter,
Object = ObjectAdapter,
Tileset = TilesetAdapter
}
|
function onStepHit()
if curStep == 639 then
makeAnimatedLuaSprite('sans','sans',100, 350);
addAnimationByPrefix('sans','idle','poopshitter bop',24,true);
scaleObject('sans', 1, 1);
addLuaSprite('sans', true)
end
if curStep == 640 then
makeAnimatedLuaSprite('poopshitterBG-trumpet','poopshitterBG-trumpet',2300, 720);
addAnimationByPrefix('poopshitterBG-trumpet','idle','poopshitter idle',24,true);
scaleObject('poopshitterBG-trumpet', 1, 1);
setProperty('poopshitterBG-trumpet.flipX', true);
end
if curStep == 896 then
makeLuaSprite('dark','dark',-300, -250);
setScrollFactor('dark', 0, 0)
addLuaSprite('dark', true)
scaleObject('dark', 5, 5)
end
if curStep == 899 then
makeAnimatedLuaSprite('monsterlogo','monsterlogo',100, -350);
addAnimationByPrefix('monsterlogo','idle','logo bumpin',24,true);
setScrollFactor('monsterlogo', 1, 1)
addLuaSprite('monsterlogo', false)
scaleObject('monsterlogo', 1.5, 1.5)
end
if curStep == 899 then
makeAnimatedLuaSprite('poopshitterBg','poopshitterBg',-200, 320);
addAnimationByPrefix('poopshitterBg','idle','poopshitter bop',24,true);
scaleObject('poopshitterBg', 1, 1);
end
if curStep == 899 then
makeAnimatedLuaSprite('poopshitterBg3','poopshitterBg3',-400, 420);
addAnimationByPrefix('poopshitterBg3','idle','poopshitter bop',24,true);
scaleObject('poopshitterBg3', 1, 1);
end
if curStep == 899 then
makeAnimatedLuaSprite('poopshitterBg2','poopshitterBg2',1200, 320);
addAnimationByPrefix('poopshitterBg2','idle','poopshitter bop',24,true);
scaleObject('poopshitterBg2', 1, 1);
end
if curStep == 899 then
makeAnimatedLuaSprite('poopshitterBG-trumpet','poopshitterBG-trumpet',1300, 420);
addAnimationByPrefix('poopshitterBG-trumpet','idle','poopshitter idle',24,true);
scaleObject('poopshitterBG-trumpet', 1, 1);
setProperty('poopshitterBG-trumpet.flipX', true);
end
if curStep == 899 then
makeAnimatedLuaSprite('sans','sans',100, 350);
addAnimationByPrefix('sans','idle','poopshitter bop',24,true);
scaleObject('sans', 1, 1);
end
if curStep == 899 then
makeAnimatedLuaSprite('poopshitterlogo','poopshitterlogo',100, -150);
addAnimationByPrefix('poopshitterlogo','idle','logo bumpin',24,true);
setScrollFactor('poopshitterlogo', 0, 0)
end
if curStep == 939 then
makeLuaSprite('dark','dark',100, -150);
setScrollFactor('dark', 0, 0)
scaleObject('dark', 5, 5)
end
if curStep == 940 then
noteTweenX("NoteMove1", 0, 400, 1, cubeInOut);
noteTweenX("NoteMove2", 1, 510, 1, cubeInOut);
noteTweenX("NoteMove3", 2, 620, 1, cubeInOut);
noteTweenX("NoteMove4", 3, 730, 1, cubeInOut);
noteTweenX("NoteMove5", 4, 400, 1, cubeInOut);
noteTweenX("NoteMove6", 5, 510, 1, cubeInOut);
noteTweenX("NoteMove7", 6, 620, 1, cubeInOut);
noteTweenX("NoteMove8", 7, 730, 1, cubeInOut);
end
if curStep == 1090 then
makeAnimatedLuaSprite('poopshitterlogo','poopshitterlogo',100, -150);
addAnimationByPrefix('poopshitterlogo','idle','logo bumpin',24,true);
setScrollFactor('poopshitterlogo', 0, 0)
addLuaSprite('poopshitterlogo',false)
end
if curStep == 1090 then
makeAnimatedLuaSprite('poopshitterBG-trumpet','poopshitterBG-trumpet',2300, 720);
addAnimationByPrefix('poopshitterBG-trumpet','idle','poopshitter idle',24,true);
scaleObject('poopshitterBG-trumpet', 1, 1);
setProperty('poopshitterBG-trumpet.flipX', true);
addLuaSprite('poopshitterBG-trumpet', false);
end
if curStep == 1089 then
makeLuaSprite('dark','dark',-300, -250);
setScrollFactor('dark', 0, 0)
addLuaSprite('dark', true)
scaleObject('dark', 5, 5)
end
if curStep == 1090 then
makeAnimatedLuaSprite('monsterlogo','monsterlogo',100, -350);
addAnimationByPrefix('monsterlogo','idle','logo bumpin',24,true);
setScrollFactor('monsterlogo', 1, 1)
scaleObject('monsterlogo', 1.5, 1.5)
end
if curStep == 1090 then
makeAnimatedLuaSprite('poopshitterBg','poopshitterBg',-200, 320);
addAnimationByPrefix('poopshitterBg','idle','poopshitter bop',24,true);
scaleObject('poopshitterBg', 1, 1);
addLuaSprite('poopshitterBg',false);
end
if curStep == 1090 then
makeAnimatedLuaSprite('poopshitterBg3','poopshitterBg3',-400, 420);
addAnimationByPrefix('poopshitterBg3','idle','poopshitter bop',24,true);
scaleObject('poopshitterBg3', 1, 1);
addLuaSprite('poopshitterBg3', false);
end
if curStep == 1090 then
makeAnimatedLuaSprite('poopshitterBg2','poopshitterBg2',1200, 320);
addAnimationByPrefix('poopshitterBg2','idle','poopshitter bop',24,true);
scaleObject('poopshitterBg2', 1, 1);
addLuaSprite('poopshitterBg2', false);
end
if curStep == 1090 then
makeAnimatedLuaSprite('sans','sans',100, 350);
addAnimationByPrefix('sans','idle','poopshitter bop',24,true);
scaleObject('sans', 1, 1);
end
if curStep == 1102 then
makeLuaSprite('dark','dark',100, -150);
setScrollFactor('dark', 0, 0)
scaleObject('dark', 5, 5)
end
if curStep == 1102 then
noteTweenX("NoteMove1", 0, 70, 0.8, cubeInOut);
noteTweenX("NoteMove2", 1, 180, 0.8, cubeInOut);
noteTweenX("NoteMove3", 2, 290, 0.8, cubeInOut);
noteTweenX("NoteMove4", 3, 400, 0.8, cubeInOut);
noteTweenX("NoteMove5", 4, 760, 0.8, cubeInOut);
noteTweenX("NoteMove6", 5, 870, 0.8, cubeInOut);
noteTweenX("NoteMove7", 6, 980, 0.8, cubeInOut);
noteTweenX("NoteMove8", 7, 1090, 0.8, cubeInOut);
end
end
|
--[[-------------------------------------------------------------------]]--[[
Copyright wiltOS Technologies LLC, 2020
Contact: www.wiltostech.com
----------------------------------------]]--
wOS = wOS or {}
wOS.ALCS = wOS.ALCS or {}
wOS.ALCS.Config = wOS.ALCS.Config or {}
wOS.ALCS.Config.Crafting = wOS.ALCS.Config.Crafting or {}
--Your MySQL Data ( Fill in if you are using MySQL Database )
--DO NOT GIVE THIS INFORMATION OUT! Malicious users can connect to your database with it
wOS.ALCS.Config.Crafting.CraftingDatabase = wOS.ALCS.Config.Crafting.CraftingDatabase or {}
wOS.ALCS.Config.Crafting.CraftingDatabase.Host = "localhost"
wOS.ALCS.Config.Crafting.CraftingDatabase.Port = 3306
wOS.ALCS.Config.Crafting.CraftingDatabase.Username = "root"
wOS.ALCS.Config.Crafting.CraftingDatabase.Password = ""
wOS.ALCS.Config.Crafting.CraftingDatabase.Database = "wos-crafting"
wOS.ALCS.Config.Crafting.CraftingDatabase.Socket = ""
--How often do you want to save player crafting ( in seconds )
wOS.ALCS.Config.Crafting.CraftingDatabase.SaveFrequency = 360
--Do you want to use MySQL Database to save your data?
--PlayerData ( text files in your data folder ) are a lot less intensive but lock you in on one server
--MySQL Saving lets you sync with many servers that share the database, but has the potential to increase server load due to querying
wOS.ALCS.Config.Crafting.ShouldCraftingUseMySQL = false
--How long should we wait before doing a respawn wave of items? ( seconds )
wOS.ALCS.Config.Crafting.ItemSpawnFrequency = 0.1
--How much of the lootspawns should be active? ( 0 to 1 )
wOS.ALCS.Config.Crafting.LootSpawnPercent = 1
--How long should it take before the items despawn? ( seconds )
wOS.ALCS.Config.Crafting.ItemDespawnTime = 600
wOS.ALCS.Config.Crafting.SaberExperienceTable = {}
wOS.ALCS.Config.Crafting.SaberExperienceTable[ "Default" ] = {
PlayerKill = 20,
NPCKill = 0,
}
wOS.ALCS.Config.Crafting.SaberExperienceTable[ "vip" ] = {
PlayerKill = 40,
NPCKill = 0,
}
|
--- 模块功能:算法功能测试.
-- @author openLuat
-- @module crypto.testCrypto
-- @license MIT
-- @copyright openLuat
-- @release 2018.03.20
module(...,package.seeall)
require"utils"
--[[
加解密算法结果,可对照
http://tool.oschina.net/encrypt?type=2
http://www.ip33.com/crc.html
http://tool.chacuo.net/cryptaes
进行测试
]]
local slen = string.len
--- base64加解密算法测试
-- @return 无
-- @usage base64Test()
local function base64Test()
local originStr = "123456crypto.base64_encodemodule(...,package.seeall)sys.timerStart(test,5000)jdklasdjklaskdjklsa"
local encodeStr = crypto.base64_encode(originStr,slen(originStr))
log.info("testCrypto.base64_encode",encodeStr)
log.info("testCrypto.base64_decode",crypto.base64_decode(encodeStr,slen(encodeStr)))
end
--- hmac_md5算法测试
-- @return 无
-- @usage hmacMd5Test()
local function hmacMd5Test()
local originStr = "asdasdsadas"
local signKey = "123456"
log.info("testCrypto.hmac_md5",crypto.hmac_md5(originStr,slen(originStr),signKey,slen(signKey)))
end
--[[
--- xxtea算法测试
-- @return 无
-- @usage xxteaTest()
local function xxteaTest()
if crypto.xxtea_encrypt then
local text = "Hello World!";
local key = "07946";
local encrypt_data = crypto.xxtea_encrypt(text, key);
log.info("testCrypto.xxteaTest","xxtea_encrypt:"..encrypt_data)
local decrypt_data = crypto.xxtea_decrypt(encrypt_data, key);
log.info("testCrypto.xxteaTest","decrypt_data:"..decrypt_data)
end
end
]]
--- 流式md5算法测试
-- @return 无
-- @usage flowMd5Test()
local function flowMd5Test()
local fmd5Obj=crypto.flow_md5()
local testTable={"lqlq666lqlq946","07946lq94607946","lq54075407540707946"}
for i=1, #(testTable) do
fmd5Obj:update(testTable[i])
end
log.info("testCrypto.flowMd5Test",fmd5Obj:hexdigest())
end
--- md5算法测试
-- @return 无
-- @usage md5Test()
local function md5Test()
--计算字符串的md5值
local originStr = "sdfdsfdsfdsffdsfdsfsdfs1234"
log.info("testCrypto.md5",crypto.md5(originStr,slen(originStr)))
-- crypto.md5,第一个参数为文件路径,第二个参数必须是"file"
log.info("testCrypto.sys.lua md5",crypto.md5("/lua/sys.lua","file"))
end
--- hmac_sha1算法测试
-- @return 无
-- @usage hmacSha1Test()
local function hmacSha1Test()
local originStr = "asdasdsadasweqcdsjghjvcb"
local signKey = "12345689012345"
log.info("testCrypto.hmac_sha1",crypto.hmac_sha1(originStr,slen(originStr),signKey,slen(signKey)))
end
--- sha1算法测试
-- @return 无
-- @usage sha1Test()
local function sha1Test()
local originStr = "sdfdsfdsfdsffdsfdsfsdfs1234"
log.info("testCrypto.sha1",crypto.sha1(originStr,slen(originStr)))
end
--- sha256算法测试
-- @return 无
-- @usage sha256Test()
local function sha256Test()
local originStr = "sdfdsfdsfdsffdsfdsfsdfs1234"
log.info("testCrypto.sha1",crypto.sha256(originStr,slen(originStr)))
end
--- crc算法测试
-- @return 无
-- @usage crcTest()
local function crcTest()
local originStr = "sdfdsfdsfdsffdsfdsfsdfs1234"
--crypto.crc16()第一个参数是校验方法,必须为以下几个;第二个参数为计算校验的字符串
log.info("testCrypto.crc16_MODBUS",string.format("%04X",crypto.crc16("MODBUS",originStr)))
log.info("testCrypto.crc16_IBM",string.format("%04X",crypto.crc16("IBM",originStr)))
log.info("testCrypto.crc16_X25",string.format("%04X",crypto.crc16("X25",originStr)))
log.info("testCrypto.crc16_MAXIM",string.format("%04X",crypto.crc16("MAXIM",originStr)))
log.info("testCrypto.crc16_USB",string.format("%04X",crypto.crc16("USB",originStr)))
log.info("testCrypto.crc16_CCITT",string.format("%04X",crypto.crc16("CCITT",originStr)))
log.info("testCrypto.crc16_CCITT-FALSE",string.format("%04X",crypto.crc16("CCITT-FALSE",originStr)))
log.info("testCrypto.crc16_XMODEM",string.format("%04X",crypto.crc16("XMODEM",originStr)))
log.info("testCrypto.crc16_DNP",string.format("%04X",crypto.crc16("DNP",originStr)))
-- log.info("testCrypto.crc16_modbus",string.format("%04X",crypto.crc16_modbus(originStr,slen(originStr))))
-- log.info("testCrypto.crc32",string.format("%08X",crypto.crc32(originStr,slen(originStr))))
end
--- aes算法测试(参考http://tool.chacuo.net/cryptaes)
-- @return 无
-- @usage aesTest()
local function aesTest()
local originStr = "AES128 ECB ZeroP"
--加密模式:ECB;填充方式:ZeroPadding;密钥:1234567890123456;密钥长度:128 bit
local encodeStr = crypto.aes_encrypt("ECB","ZERO",originStr,"1234567890123456")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("ECB","ZERO",encodeStr,"1234567890123456"))
originStr = "AES128 ECB ZeroP"
--加密模式:ECB;填充方式:Pkcs5Padding;密钥:1234567890123456;密钥长度:128 bit
encodeStr = crypto.aes_encrypt("ECB","PKCS5",originStr,"1234567890123456")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("ECB","PKCS5",encodeStr,"1234567890123456"))
originStr = "AES128 ECB ZeroPt"
--加密模式:ECB;填充方式:Pkcs7Padding;密钥:1234567890123456;密钥长度:128 bit
encodeStr = crypto.aes_encrypt("ECB","PKCS7",originStr,"1234567890123456")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("ECB","PKCS7",encodeStr,"1234567890123456"))
originStr = "AES192 ECB ZeroPadding test"
--加密模式:ECB;填充方式:ZeroPadding;密钥:123456789012345678901234;密钥长度:192 bit
local encodeStr = crypto.aes_encrypt("ECB","ZERO",originStr,"123456789012345678901234")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("ECB","ZERO",encodeStr,"123456789012345678901234"))
originStr = "AES192 ECB Pkcs5Padding test"
--加密模式:ECB;填充方式:Pkcs5Padding;密钥:123456789012345678901234;密钥长度:192 bit
encodeStr = crypto.aes_encrypt("ECB","PKCS5",originStr,"123456789012345678901234")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("ECB","PKCS5",encodeStr,"123456789012345678901234"))
originStr = "AES192 ECB Pkcs7Padding test"
--加密模式:ECB;填充方式:Pkcs7Padding;密钥:123456789012345678901234;密钥长度:192 bit
encodeStr = crypto.aes_encrypt("ECB","PKCS7",originStr,"123456789012345678901234")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("ECB","PKCS7",encodeStr,"123456789012345678901234"))
originStr = "AES256 ECB ZeroPadding test"
--加密模式:ECB;填充方式:ZeroPadding;密钥:12345678901234567890123456789012;密钥长度:256 bit
local encodeStr = crypto.aes_encrypt("ECB","ZERO",originStr,"12345678901234567890123456789012")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("ECB","ZERO",encodeStr,"12345678901234567890123456789012"))
originStr = "AES256 ECB Pkcs5Padding test"
--加密模式:ECB;填充方式:Pkcs5Padding;密钥:12345678901234567890123456789012;密钥长度:256 bit
encodeStr = crypto.aes_encrypt("ECB","PKCS5",originStr,"12345678901234567890123456789012")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("ECB","PKCS5",encodeStr,"12345678901234567890123456789012"))
originStr = "AES256 ECB Pkcs7Padding test"
--加密模式:ECB;填充方式:Pkcs7Padding;密钥:12345678901234567890123456789012;密钥长度:256 bit
encodeStr = crypto.aes_encrypt("ECB","PKCS7",originStr,"12345678901234567890123456789012")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("ECB","PKCS7",encodeStr,"12345678901234567890123456789012"))
originStr = "AES128 CBC ZeroPadding test"
--加密模式:CBC;填充方式:ZeroPadding;密钥:1234567890123456;密钥长度:128 bit;偏移量:1234567890666666
local encodeStr = crypto.aes_encrypt("CBC","ZERO",originStr,"1234567890123456","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CBC","ZERO",encodeStr,"1234567890123456","1234567890666666"))
originStr = "AES128 CBC Pkcs5Padding test"
--加密模式:CBC;填充方式:Pkcs5Padding;密钥:1234567890123456;密钥长度:128 bit;偏移量:1234567890666666
encodeStr = crypto.aes_encrypt("CBC","PKCS5",originStr,"1234567890123456","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CBC","PKCS5",encodeStr,"1234567890123456","1234567890666666"))
originStr = "AES128 CBC Pkcs7Padding test"
--加密模式:CBC;填充方式:Pkcs7Padding;密钥:1234567890123456;密钥长度:128 bit;偏移量:1234567890666666
encodeStr = crypto.aes_encrypt("CBC","PKCS7",originStr,"1234567890123456","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CBC","PKCS7",encodeStr,"1234567890123456","1234567890666666"))
originStr = "AES192 CBC ZeroPadding test"
--加密模式:CBC;填充方式:ZeroPadding;密钥:123456789012345678901234;密钥长度:192 bit;偏移量:1234567890666666
local encodeStr = crypto.aes_encrypt("CBC","ZERO",originStr,"123456789012345678901234","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CBC","ZERO",encodeStr,"123456789012345678901234","1234567890666666"))
originStr = "AES192 CBC Pkcs5Padding test"
--加密模式:CBC;填充方式:Pkcs5Padding;密钥:123456789012345678901234;密钥长度:192 bit;偏移量:1234567890666666
encodeStr = crypto.aes_encrypt("CBC","PKCS5",originStr,"123456789012345678901234","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CBC","PKCS5",encodeStr,"123456789012345678901234","1234567890666666"))
originStr = "AES192 CBC Pkcs7Padding test"
--加密模式:CBC;填充方式:Pkcs7Padding;密钥:123456789012345678901234;密钥长度:192 bit;偏移量:1234567890666666
encodeStr = crypto.aes_encrypt("CBC","PKCS7",originStr,"123456789012345678901234","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CBC","PKCS7",encodeStr,"123456789012345678901234","1234567890666666"))
originStr = "AES256 CBC ZeroPadding test"
--加密模式:CBC;填充方式:ZeroPadding;密钥:12345678901234567890123456789012;密钥长度:256 bit;偏移量:1234567890666666
local encodeStr = crypto.aes_encrypt("CBC","ZERO",originStr,"12345678901234567890123456789012","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CBC","ZERO",encodeStr,"12345678901234567890123456789012","1234567890666666"))
originStr = "AES256 CBC Pkcs5Padding test"
--加密模式:CBC;填充方式:Pkcs5Padding;密钥:12345678901234567890123456789012;密钥长度:256 bit;偏移量:1234567890666666
encodeStr = crypto.aes_encrypt("CBC","PKCS5",originStr,"12345678901234567890123456789012","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CBC","PKCS5",encodeStr,"12345678901234567890123456789012","1234567890666666"))
originStr = "AES256 CBC Pkcs7Padding test"
--加密模式:CBC;填充方式:Pkcs7Padding;密钥:12345678901234567890123456789012;密钥长度:256 bit;偏移量:1234567890666666
encodeStr = crypto.aes_encrypt("CBC","PKCS7",originStr,"12345678901234567890123456789012","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CBC","PKCS7",encodeStr,"12345678901234567890123456789012","1234567890666666"))
originStr = "AES128 CTR ZeroPadding test"
--加密模式:CTR;填充方式:ZeroPadding;密钥:1234567890123456;密钥长度:128 bit;偏移量:1234567890666666
local encodeStr = crypto.aes_encrypt("CTR","ZERO",originStr,"1234567890123456","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CTR","ZERO",encodeStr,"1234567890123456","1234567890666666"))
originStr = "AES128 CTR Pkcs5Padding test"
--加密模式:CTR;填充方式:Pkcs5Padding;密钥:1234567890123456;密钥长度:128 bit;偏移量:1234567890666666
encodeStr = crypto.aes_encrypt("CTR","PKCS5",originStr,"1234567890123456","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CTR","PKCS5",encodeStr,"1234567890123456","1234567890666666"))
originStr = "AES128 CTR Pkcs7Padding test"
--加密模式:CTR;填充方式:Pkcs7Padding;密钥:1234567890123456;密钥长度:128 bit;偏移量:1234567890666666
encodeStr = crypto.aes_encrypt("CTR","PKCS7",originStr,"1234567890123456","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CTR","PKCS7",encodeStr,"1234567890123456","1234567890666666"))
originStr = "AES128 CTR NonePadding test"
--加密模式:CTR;填充方式:NonePadding;密钥:1234567890123456;密钥长度:128 bit;偏移量:1234567890666666
encodeStr = crypto.aes_encrypt("CTR","NONE",originStr,"1234567890123456","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CTR","NONE",encodeStr,"1234567890123456","1234567890666666"))
originStr = "AES192 CTR ZeroPadding test"
--加密模式:CTR;填充方式:ZeroPadding;密钥:123456789012345678901234;密钥长度:192 bit;偏移量:1234567890666666
local encodeStr = crypto.aes_encrypt("CTR","ZERO",originStr,"123456789012345678901234","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CTR","ZERO",encodeStr,"123456789012345678901234","1234567890666666"))
originStr = "AES192 CTR Pkcs5Padding test"
--加密模式:CTR;填充方式:Pkcs5Padding;密钥:123456789012345678901234;密钥长度:192 bit;偏移量:1234567890666666
encodeStr = crypto.aes_encrypt("CTR","PKCS5",originStr,"123456789012345678901234","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CTR","PKCS5",encodeStr,"123456789012345678901234","1234567890666666"))
originStr = "AES192 CTR Pkcs7Padding test"
--加密模式:CTR;填充方式:Pkcs7Padding;密钥:123456789012345678901234;密钥长度:192 bit;偏移量:1234567890666666
encodeStr = crypto.aes_encrypt("CTR","PKCS7",originStr,"123456789012345678901234","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CTR","PKCS7",encodeStr,"123456789012345678901234","1234567890666666"))
originStr = "AES192 CTR NonePadding test"
--加密模式:CTR;填充方式:NonePadding;密钥:123456789012345678901234;密钥长度:192 bit;偏移量:1234567890666666
encodeStr = crypto.aes_encrypt("CTR","NONE",originStr,"123456789012345678901234","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CTR","NONE",encodeStr,"123456789012345678901234","1234567890666666"))
originStr = "AES256 CTR ZeroPadding test"
--加密模式:CTR;填充方式:ZeroPadding;密钥:12345678901234567890123456789012;密钥长度:256 bit;偏移量:1234567890666666
local encodeStr = crypto.aes_encrypt("CTR","ZERO",originStr,"12345678901234567890123456789012","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CTR","ZERO",encodeStr,"12345678901234567890123456789012","1234567890666666"))
originStr = "AES256 CTR Pkcs5Padding test"
--加密模式:CTR;填充方式:Pkcs5Padding;密钥:12345678901234567890123456789012;密钥长度:256 bit;偏移量:1234567890666666
encodeStr = crypto.aes_encrypt("CTR","PKCS5",originStr,"12345678901234567890123456789012","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CTR","PKCS5",encodeStr,"12345678901234567890123456789012","1234567890666666"))
originStr = "AES256 CTR Pkcs7Padding test"
--加密模式:CTR;填充方式:Pkcs7Padding;密钥:12345678901234567890123456789012;密钥长度:256 bit;偏移量:1234567890666666
encodeStr = crypto.aes_encrypt("CTR","PKCS7",originStr,"12345678901234567890123456789012","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CTR","PKCS7",encodeStr,"12345678901234567890123456789012","1234567890666666"))
originStr = "AES256 CTR NonePadding test"
--加密模式:CTR;填充方式:NonePadding;密钥:12345678901234567890123456789012;密钥长度:256 bit;偏移量:1234567890666666
encodeStr = crypto.aes_encrypt("CTR","NONE",originStr,"12345678901234567890123456789012","1234567890666666")
print(originStr,"encrypt",string.toHex(encodeStr))
log.info("testCrypto.decrypt",crypto.aes_decrypt("CTR","NONE",encodeStr,"12345678901234567890123456789012","1234567890666666"))
end
--- 算法测试入口
-- @return
local function cryptoTest()
print("test start")
hmacMd5Test()
md5Test()
hmacSha1Test()
flowMd5Test()
base64Test()
crcTest()
aesTest()
sha1Test()
sha256Test()
-- xxtea 需要lod打开支持
-- xxteaTest()
print("test end")
end
sys.timerStart(cryptoTest,2000)
|
-- el codigo es un desastre, lo se, sorry :c
-- pero funciona :)
-- ~ serivesmejia
local class = require "lib.lua-oop"
local gameover_stage = require "game.stages.gameover_stage"
require "engine.core"
require "engine.stage"
require "engine.stage.object"
require "engine.objects.basic"
require "util.color"
require "util.math.vector"
require "util"
local SimonRectangleObj = class("Obj-SimonRectangle", RectangleObj)
function SimonRectangleObj:constructor(position, size, color, clickColor, mouseObj)
self.mouseObj = mouseObj
self.defColor = color:set(color.r, color.g, color.b, 255)
self.clickColor = clickColor
self.currColor = color
self.doHighlight = false
self.highlightFrames = 0
self.highlightFramesC = 0
self.onClick = function() end
RectangleObj.constructor(self, position, size, color)
end
function SimonRectangleObj:update(dt)
-- separating conditions into different variables for better readbility
local a = self:isHitting(self.mouseObj) -- if mouse hitbox is inside the rectangle
local ab = a and self.parentStage.mouseIsPrimaryDown -- if mouse is inside the rectangle and mouse primary is clicked
local cd = self.parentStage.isClickEnabled and not self.parentStage.alreadyClickedOne -- better look stuff
self.greenColor = Color:new(21, 189, 21, 255)
self.redColor = Color:new(255, 0, 0, 255)
-- highlighting the rectangle
if ab and cd or self.doHighlight then
self.color = self.clickColor
self.parentStage.alreadyClickedOne = true
else
self.color = self.currColor
self.parentStage.alreadyClickedOne = false
end
-- highlighting without clicking (specific no. of frames)
-- done with the highlight() function
if self.doHighlight then
self.highlightFramesC = self.highlightFramesC + 1
self.doHighlight = self.highlightFramesC <= self.highlightFrames
end
-- playing sound and calling click function
if a and cd and self.parentStage.mousePrimaryClicked then
self.snd:stop()
self.snd:play()
self.onClick()
end
end
function SimonRectangleObj:highlight(frames, playSound)
if playSound == nil or playSound then
self.snd:stop()
self.snd:play()
end
self.doHighlight = true
self.highlightFrames = frames
self.highlightFramesC = 0
end
function SimonRectangleObj:setColorGreen()
self.currColor = self.greenColor
end
function SimonRectangleObj:setColorRed()
self.currColor = self.redColor
end
function SimonRectangleObj:setColorOriginal()
self.currColor = self.defColor
end
local simon_stage = class("Stage-Simon", Stage)
-- stage constructor
-- declare all variables here
function simon_stage:constructor()
Stage.constructor(self)
self.lives = 5 -- default 5, don't forget
self.score = 0
self.mousePrimaryDownC = 0
self.mouseIsPrimaryDown = false
self.mousePrimaryClicked = false
self.alreadyClickedOne = false
self.isClickEnabled = true
self.order = nil
self.orderSize = 4
self.plays = 0
self.clickOrder = nil
self.memorizeOrderCurrentI = 0
self.memorizeNextFrame = 0
-- states: memorize, repeat, wrong, gameover
self.state = "memorize"
self.beforeState = ""
self.framesCurrentState = 0
self.stateChange = false
end
function simon_stage:init()
setBackgroundColor(0, 0, 0, 255) -- better look
self.statsTxtObj = TextObj:new(nil, Color:new(255, 255, 255, 255), "", 20)
self:addObject(self.statsTxtObj)
self.stateTxtObj = TextObj:new(Vector2:new((love.graphics.getWidth() / 2) - 50, 20), Color:new(255, 255, 255, 255), "Memorize", 20)
self:addObject(self.stateTxtObj)
-- load sounds into memory ('static')
self.sndNice = love.audio.newSource("game/assets/snd_nice.ogg", "stream")
self.sndWrong = love.audio.newSource("game/assets/snd_wrong.ogg", "stream")
self.sndRepeat = love.audio.newSource("game/assets/snd_repeat.ogg", "stream")
self.sndRepeat:setVolume(0.3)
local winW = love.graphics.getWidth()
local winH = love.graphics.getHeight()
local size = Vector2:new(winW / 4, winW / 4)
local clickColor = Color:new(255, 255, 255, 255)
-- simon rectangles setup
-- beware, messy code ahead.
-- rect A
local posA = Vector2:new(winW / 4, winH / 6)
self.rectA = SimonRectangleObj:new(posA, size, Color:new(255, 0, 0, 255), clickColor, self.mouseObj)
self:addObject(self.rectA)
self.rectA.snd = love.audio.newSource("game/assets/snd_rectA.ogg", "stream")
self.rectA.onClick = function()
table.insert(self.clickOrder, 1)
end
-- rect B
local posB = Vector2:new(winW / 4 + size.x + 10, winH / 6)
self.rectB = SimonRectangleObj:new(posB, size, Color:new(255, 242, 3, 255), clickColor, self.mouseObj)
self:addObject(self.rectB)
self.rectB.snd = love.audio.newSource("game/assets/snd_rectB.ogg", "stream")
self.rectB.onClick = function()
table.insert(self.clickOrder, 2)
end
-- rect C
local posC = Vector2:new(winW / 4, winH / 6 + 212)
self.rectC = SimonRectangleObj:new(posC, size, Color:new(0, 0, 255, 255), clickColor, self.mouseObj)
self:addObject(self.rectC)
self.rectC.snd = love.audio.newSource("game/assets/snd_rectC.ogg", "stream")
self.rectC.onClick = function()
table.insert(self.clickOrder, 3)
end
-- rect D
local posD = Vector2:new(winW / 4 + size.x + 10, winH / 6 + 212)
self.rectD = SimonRectangleObj:new(posD, size, Color:new(21, 189, 21, 255), clickColor, self.mouseObj)
self:addObject(self.rectD)
self.rectD.snd = love.audio.newSource("game/assets/snd_rectD.ogg", "stream")
self.rectD.onClick = function()
table.insert(self.clickOrder, 4)
end
end
function simon_stage:update()
self.statsTxtObj.color:setFromBackground():invert()
self.statsTxtObj.text = "Lives: " .. tostring(self.lives) .. "\n" .. "Plays: " .. tostring(self.plays) .. "\n" .. "Score: " .. tostring(self.score)
-- primary mouse boolean handling
if love.mouse.isDown(1) then
self.mouseIsPrimaryDown = self.mousePrimaryDownC <= 5
self.mousePrimaryClicked = self.mousePrimaryDownC == 0
self.mousePrimaryDownC = self.mousePrimaryDownC + 1
else
self.mousePrimaryDownC = 0
self.mouseIsPrimaryDown = false
self.mousePrimaryClicked = false
end
-- state handling
if self.state == "memorize" then
self.stateTxtObj.text = "Memorize"
-- executed once
if self:stateChanged() then
self.order = {} -- create a new random order
for i = 1, self.orderSize do
self.order[i] = math.random(1, 4)
end
self.memorizeNextFrame = self.framesCurrentState + 80
self.memorizeOrderCurrentI = 0
self.firstDoMemorize = true
self.stateChange = false
end
-- highlighting the next simon rect every 60 frames
if self.framesCurrentState >= self.memorizeNextFrame then
if self.firstDoMemorize then
self.firstDoMemorize = false
self.rectA:setColorOriginal()
self.rectB:setColorOriginal()
self.rectC:setColorOriginal()
self.rectD:setColorOriginal()
end
local toHighlightRect = self.order[self.memorizeOrderCurrentI]
if toHighlightRect == 1 then
self.rectA:highlight(40)
elseif toHighlightRect == 2 then
self.rectB:highlight(40)
elseif toHighlightRect == 3 then
self.rectC:highlight(40)
elseif toHighlightRect == 4 then
self.rectD:highlight(40)
end
if self.memorizeOrderCurrentI > #self.order then
self.plays = self.plays + 1
if self.plays % 6 == 0 then -- every six plays there will be +1 rectangle to click
self.orderSize = self.orderSize + 1
end
self:setState("repeat")
end
self.memorizeNextFrame = self.framesCurrentState + 60
self.memorizeOrderCurrentI = self.memorizeOrderCurrentI + 1
end
self.isClickEnabled = false
elseif self.state == "repeat" then
self.stateTxtObj.text = " Repeat"
-- executed once
if self:stateChanged() then
self.clickOrder = {}
self.sndRepeat:play() -- play a cute sound effect uwu
self.repeatMaxTimeSecs = os.time() + math.floor((self.orderSize * 1.7)+0.5) -- timer
self.stateChange = false
end
local remainingTime = self.repeatMaxTimeSecs - os.time() -- delta between future timeout and current time
if remainingTime < 0 then -- time's out
self:setState("wrong")
else -- still have some time
self.stateTxtObj.text = self.stateTxtObj.text .. "\n " .. tostring(remainingTime)
end
local i = #self.clickOrder
if not (i == 0) then -- at least 1 rectangle clicked
if self.order[i] == self.clickOrder[i] then -- currently success
if i == #self.order then -- all clicked successfully
self.score = self.score + (50 * self.orderSize) -- add +50 score for each rectangle clicked
self.rectA:setColorGreen()
self.rectB:setColorGreen()
self.rectC:setColorGreen()
self.rectD:setColorGreen()
self.sndNice:play()
self:setState("memorize") -- sucess, memorize again
end
else -- failed
self:setState("wrong") -- wrong clicked
end
end
self.isClickEnabled = true
elseif self.state == "wrong" then
-- executed once
if self:stateChanged() then
self.lives = self.lives - 1 -- remove 1 live
self.framesMemorizeState = self.framesCurrentState + 100 -- frames to go back to memorize state (100)
self.stateChange = false
self.rectA:setColorRed()
self.rectB:setColorRed()
self.rectC:setColorRed()
self.rectD:setColorRed()
if self.lives > 0 then -- if not gameover
self.sndWrong:play()
end
end
if self.lives <= 0 then -- gameover
self.stageManager:changeStage(gameover_stage:new(self.plays, self.score)) -- change to gameover stage
else -- not gameover
self.stateTxtObj.text = " Wrong!" -- change the state txt to this
end
if self.framesCurrentState >= self.framesMemorizeState then
self:setState("memorize") -- set state to memorize after 100 frames
end
self.isClickEnabled = false
else
self.state = "memorize" -- set state to memorize if the current state is invalid
end
self.framesCurrentState = self.framesCurrentState + 1
self.beforeState = self.state
end
function simon_stage:draw() end
function simon_stage:stateChanged()
return not (self.state == self.beforeState) or self.stateChange
end
function simon_stage:setState(state)
self.framesCurrentState = 0
self.stateChange = true
self.state = state
print("Change state to " .. state)
end
return simon_stage
|
-----------------------------------
-- Area: Upper Jeuno
-- NPC: Guslam
-- Starts Quest: Borghertz's Hands (AF Hands, Many job)
-- !pos -5 1 48 244
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
-----------------------------------
function onTrade(player,npc,trade)
end;
-----------------------------------
-- If it's the first Hands quest
-----------------------------------
function nbHandsQuestsCompleted(player)
local questNotAvailable = 0;
for nb = 0, 14, 1 do
if (player:getQuestStatus(JEUNO,tpz.quest.id.jeuno.BORGHERTZ_S_WARRING_HANDS + nb) ~= QUEST_AVAILABLE) then
questNotAvailable = questNotAvailable + 1;
end
end
return questNotAvailable;
end;
function onTrigger(player,npc)
if (player:getMainLvl() >= 50 and player:getCharVar("BorghertzAlreadyActiveWithJob") == 0) then
if (player:getMainJob() == tpz.job.WAR and
player:getQuestStatus(BASTOK,tpz.quest.id.bastok.THE_TALEKEEPER_S_TRUTH) ~= QUEST_AVAILABLE and
player:getQuestStatus(JEUNO,tpz.quest.id.jeuno.BORGHERTZ_S_WARRING_HANDS) == QUEST_AVAILABLE) then
player:startEvent(155); -- Start Quest for WAR
elseif (player:getMainJob() == tpz.job.MNK and
player:getQuestStatus(BASTOK,tpz.quest.id.bastok.THE_FIRST_MEETING) ~= QUEST_AVAILABLE and
player:getQuestStatus(JEUNO,tpz.quest.id.jeuno.BORGHERTZ_S_STRIKING_HANDS) == QUEST_AVAILABLE) then
player:startEvent(155); -- Start Quest for MNK
elseif (player:getMainJob() == tpz.job.WHM and
player:getQuestStatus(SANDORIA,tpz.quest.id.sandoria.PRELUDE_OF_BLACK_AND_WHITE) ~= QUEST_AVAILABLE and
player:getQuestStatus(JEUNO,tpz.quest.id.jeuno.BORGHERTZ_S_HEALING_HANDS) == QUEST_AVAILABLE) then
player:startEvent(155); -- Start Quest for WHM
elseif (player:getMainJob() == tpz.job.BLM and
player:getQuestStatus(WINDURST,tpz.quest.id.windurst.RECOLLECTIONS) ~= QUEST_AVAILABLE and
player:getQuestStatus(JEUNO,tpz.quest.id.jeuno.BORGHERTZ_S_SORCEROUS_HANDS) == QUEST_AVAILABLE) then
player:startEvent(155); -- Start Quest for BLM
elseif (player:getMainJob() == tpz.job.RDM and
player:getQuestStatus(SANDORIA,tpz.quest.id.sandoria.ENVELOPED_IN_DARKNESS) ~= QUEST_AVAILABLE and
player:getQuestStatus(JEUNO,tpz.quest.id.jeuno.BORGHERTZ_S_VERMILLION_HANDS) == QUEST_AVAILABLE) then
player:startEvent(155); -- Start Quest for RDM
elseif (player:getMainJob() == tpz.job.THF and
player:getQuestStatus(WINDURST,tpz.quest.id.windurst.AS_THICK_AS_THIEVES) ~= QUEST_AVAILABLE and
player:getQuestStatus(JEUNO,tpz.quest.id.jeuno.BORGHERTZ_S_SNEAKY_HANDS) == QUEST_AVAILABLE) then
player:startEvent(155); -- Start Quest for THF
elseif (player:getMainJob() == tpz.job.PLD and
player:getQuestStatus(SANDORIA,tpz.quest.id.sandoria.A_BOY_S_DREAM) ~= QUEST_AVAILABLE and
player:getQuestStatus(JEUNO,tpz.quest.id.jeuno.BORGHERTZ_S_STALWART_HANDS) == QUEST_AVAILABLE) then
player:startEvent(155); -- Start Quest for PLD
elseif (player:getMainJob() == tpz.job.DRK and
player:getQuestStatus(BASTOK,tpz.quest.id.bastok.DARK_PUPPET) ~= QUEST_AVAILABLE and
player:getQuestStatus(JEUNO,tpz.quest.id.jeuno.BORGHERTZ_S_SHADOWY_HANDS) == QUEST_AVAILABLE) then
player:startEvent(155); -- Start Quest for DRK
elseif (player:getMainJob() == tpz.job.BST and
player:getQuestStatus(JEUNO,tpz.quest.id.jeuno.SCATTERED_INTO_SHADOW) ~= QUEST_AVAILABLE and
player:getQuestStatus(JEUNO,tpz.quest.id.jeuno.BORGHERTZ_S_WILD_HANDS) == QUEST_AVAILABLE) then
player:startEvent(155); -- Start Quest for BST
elseif (player:getMainJob() == tpz.job.BRD and
player:getQuestStatus(JEUNO,tpz.quest.id.jeuno.THE_REQUIEM) ~= QUEST_AVAILABLE and
player:getQuestStatus(JEUNO,tpz.quest.id.jeuno.BORGHERTZ_S_HARMONIOUS_HANDS) == QUEST_AVAILABLE) then
player:startEvent(155); -- Start Quest for BRD
elseif (player:getMainJob() == tpz.job.RNG and
player:getQuestStatus(WINDURST,tpz.quest.id.windurst.FIRE_AND_BRIMSTONE) ~= QUEST_AVAILABLE and
player:getQuestStatus(JEUNO,tpz.quest.id.jeuno.BORGHERTZ_S_CHASING_HANDS) == QUEST_AVAILABLE) then
player:startEvent(155); -- Start Quest for RNG
elseif (player:getMainJob() == tpz.job.SAM and
player:getQuestStatus(OUTLANDS,tpz.quest.id.outlands.YOMI_OKURI) ~= QUEST_AVAILABLE and
player:getQuestStatus(JEUNO,tpz.quest.id.jeuno.BORGHERTZ_S_LOYAL_HANDS) == QUEST_AVAILABLE) then
player:startEvent(155); -- Start Quest for SAM
elseif (player:getMainJob() == tpz.job.NIN and
player:getQuestStatus(OUTLANDS,tpz.quest.id.outlands.I_LL_TAKE_THE_BIG_BOX) ~= QUEST_AVAILABLE and
player:getQuestStatus(JEUNO,tpz.quest.id.jeuno.BORGHERTZ_S_LURKING_HANDS) == QUEST_AVAILABLE) then
player:startEvent(155); -- Start Quest for NIN
elseif (player:getMainJob() == tpz.job.DRG and
player:getQuestStatus(SANDORIA,tpz.quest.id.sandoria.CHASING_QUOTAS) ~= QUEST_AVAILABLE and
player:getQuestStatus(JEUNO,tpz.quest.id.jeuno.BORGHERTZ_S_DRAGON_HANDS) == QUEST_AVAILABLE) then
player:startEvent(155); -- Start Quest for DRG
elseif (player:getMainJob() == tpz.job.SMN and
player:getQuestStatus(WINDURST,tpz.quest.id.windurst.CLASS_REUNION) ~= QUEST_AVAILABLE and
player:getQuestStatus(JEUNO,tpz.quest.id.jeuno.BORGHERTZ_S_CALLING_HANDS) == QUEST_AVAILABLE) then
player:startEvent(155); -- Start Quest for SMN
else
player:startEvent(154); -- Standard dialog
end
elseif (player:getCharVar("BorghertzAlreadyActiveWithJob") >= 1 and player:hasKeyItem(tpz.ki.OLD_GAUNTLETS) == false) then
player:startEvent(43); -- During Quest before KI obtained
elseif (player:hasKeyItem(tpz.ki.OLD_GAUNTLETS) == true) then
player:startEvent(26); -- Dialog with Old Gauntlets KI
if (nbHandsQuestsCompleted(player) == 1) then
player:setCharVar("BorghertzHandsFirstTime",1);
else
player:setCharVar("BorghertzCS",1);
end
else
player:startEvent(154); -- Standard dialog
end
end;
-- 154 Standard dialog
-- 155 Start Quest
-- 43 During Quest before KI obtained
-- 26 Dialog avec Old Gauntlets KI
-- 156 During Quest after Old Gauntlets KI ?
function onEventUpdate(player,csid,option)
end;
function onEventFinish(player,csid,option)
if (csid == 155) then
local NumQuest = tpz.quest.id.jeuno.BORGHERTZ_S_WARRING_HANDS + player:getMainJob() - 1;
player:addQuest(JEUNO,NumQuest);
player:setCharVar("BorghertzAlreadyActiveWithJob",player:getMainJob());
end
end;
|
if not yatm_data_network then
return
end
|
local entity = {}
entity["level"] = [[32]]
entity["spellDeck"] = {}
entity["spellDeck"][1] = [[Agilao]]
entity["spellDeck"][2] = [[]]
entity["spellDeck"][3] = [[Tarunda]]
entity["spellDeck"][4] = [[]]
entity["spellDeck"][5] = [[]]
entity["spellDeck"][6] = [[]]
entity["heritage"] = {}
entity["heritage"][1] = [[Fire]]
entity["heritage"][2] = [[]]
entity["resistance"] = {}
entity["resistance"][1] = [[Normal]]
entity["resistance"][2] = [[Normal]]
entity["resistance"][3] = [[Normal]]
entity["resistance"][4] = [[Drain]]
entity["resistance"][5] = [[Weak]]
entity["resistance"][6] = [[Normal]]
entity["resistance"][7] = [[Normal]]
entity["resistance"][8] = [[Normal]]
entity["resistance"][9] = [[Normal]]
entity["desc"] = [[Also known as Jack O`Lantern, he was an Irish farmer who persuaded Satan not to take him to hell. When he was refused entry into heaven, he wandered earth as a pumpkin-headed soul.]]
--a function: evolveName
entity["arcana"] = [[Magician]]
entity["stats"] = {}
entity["stats"][1] = [[16]]
entity["stats"][2] = [[26]]
entity["stats"][3] = [[19]]
entity["stats"][4] = [[22]]
entity["stats"][5] = [[20]]
entity["name"] = [[Pyro Jack]]
entity["spellLearn"] = {}
entity["spellLearn"]["Maragion"] = [[36]]
entity["spellLearn"]["Resist Ice"] = [[38]]
entity["spellLearn"]["Auto-Rakukaja"] = [[37]]
entity["spellLearn"]["Marakukaja"] = [[34]]
return entity
|
handlerConnect = nil
canScriptWork = true
addEventHandler('onResourceStart', getResourceRootElement(),
function()
handlerConnect = dbConnect( 'mysql', 'host=' .. get"*gcshop.host" .. ';dbname=' .. get"*gcshop.dbname", get("*gcshop.user"), get("*gcshop.pass"))
if handlerConnect then
dbExec( handlerConnect, "CREATE TABLE IF NOT EXISTS `mapstop100` ( `id` int(11) NOT NULL AUTO_INCREMENT, `mapresourcename` VARCHAR(70) BINARY NOT NULL, `mapname` VARCHAR(70) BINARY NOT NULL, `author` VARCHAR(70) BINARY NOT NULL, `gamemode` VARCHAR(70) BINARY NOT NULL, `rank` INTEGER, `votes` INTEGER, `balance` INTEGER, PRIMARY KEY (`id`) )" )
dbExec( handlerConnect, "CREATE TABLE IF NOT EXISTS `votestop100` ( `id` int(11) NOT NULL AUTO_INCREMENT, `forumid` int(10) unsigned NOT NULL, `choice1` VARCHAR(70) BINARY NOT NULL, `choice2` VARCHAR(70) BINARY NOT NULL, `choice3` VARCHAR(70) BINARY NOT NULL, `choice4` VARCHAR(70) BINARY NOT NULL, `choice5` VARCHAR(70) BINARY NOT NULL, PRIMARY KEY (`id`) )" )
else
outputDebugString('Maps top 100 error: could not connect to the mysql db')
canScriptWork = false
return
end
end
)
function maps100_fetchMaps(player)
refreshResources()
local mapList = {}
-- Get race and uploaded maps
local raceMps = exports.mapmanager:getMapsCompatibleWithGamemode(getResourceFromName("race"))
if not raceMps then return false end
for _,map in ipairs(raceMps) do
local name = getResourceInfo(map,"name")
local author = getResourceInfo(map,"author")
local resname = getResourceName(map)
if not name then name = resname end
if not author then author = "N/A" end
local gamemode
local t = {name = name, author = author, resname = resname, gamemode = "Race"}
table.insert(mapList,t)
end
table.sort(mapList,function(a,b) return tostring(a.name) < tostring(b.name) end)
local map100 = {}
local qh = dbQuery(handlerConnect, "SELECT * FROM `mapstop100`")
local map100_sql = dbPoll(qh,-1)
if not map100_sql then return false end
for _,row in ipairs(map100_sql) do
local name = tostring(row.mapname)
local author = tostring(row.author)
local resname = tostring(row.mapresourcename)
local gamemode = tostring(row.gamemode)
local t = {name = name, author = author, resname = resname, gamemode = gamemode}
table.insert(map100,t)
end
table.sort(map100,function(a,b) return tostring(a.name) < tostring(b.name) end)
triggerClientEvent(player,"maps100_receiveMapLists",resourceRoot,mapList,map100)
end
function maps100_command(p)
maps100_fetchMaps(p)
triggerClientEvent(p,"maps100_openCloseGUI",resourceRoot)
end
addCommandHandler("maps100", maps100_command, true, true)
function maps100_addMap(p, name, author, gamemode, resname)
local qh = dbQuery(handlerConnect, "SELECT * FROM `mapstop100` WHERE `mapresourcename`=?", tostring(resname))
local resCheck = dbPoll(qh,-1)
if resCheck[1] then
if tostring(resCheck[1].mapresourcename) == tostring(resname) then
outputChatBox("Map already added", p)
return
end
end
local qh = dbQuery(handlerConnect, "INSERT INTO `mapstop100` (`mapresourcename`, `mapname`, `author`, `gamemode`, `rank`, `votes`) VALUES (?,?,?,?,?,?)", resname, name, author, gamemode, "0", "0" )
if dbFree( qh ) then
outputChatBox("Map added succesfully", p)
end
maps100_fetchMaps(p)
end
addEvent("maps100_addMap", true)
addEventHandler("maps100_addMap", resourceRoot, maps100_addMap)
function maps100_delMap(p, name, author, gamemode, resname)
local qh = dbQuery(handlerConnect, "DELETE FROM `mapstop100` WHERE `mapresourcename`=?", resname)
if dbFree( qh ) then
outputChatBox("Map deleted succesfully", p)
end
maps100_fetchMaps(p)
end
addEvent("maps100_delMap", true)
addEventHandler("maps100_delMap", resourceRoot, maps100_delMap)
function maps100_fetchInsight(p)
local voterList = {}
local qh = dbQuery(handlerConnect, "SELECT * FROM `votestop100`")
local map100_sql = dbPoll(qh,-1)
if not map100_sql then return false end
for _,row in ipairs(map100_sql) do
local id = tostring(row.id)
local forumid = tostring(row.forumid)
local choice1 = tostring(row.choice1)
local choice2 = tostring(row.choice2)
local choice3 = tostring(row.choice3)
local choice4 = tostring(row.choice4)
local choice5 = tostring(row.choice5)
local t = {id = id, forumid = forumid, choice1 = choice1, choice2 = choice2, choice3 = choice3, choice4 = choice4, choice5 = choice5}
table.insert(voterList,t)
end
table.sort(voterList,function(a,b) return tostring(a.id) < tostring(b.id) end)
local mapsList = {}
local qh = dbQuery(handlerConnect, "SELECT * FROM `mapstop100` ORDER BY `rank` DESC")
local map100_sql = dbPoll(qh,-1)
if not map100_sql then return false end
for _,row in ipairs(map100_sql) do
local id = tostring(row.id)
local mapresourcename = tostring(row.mapresourcename)
local rank = tostring(row.rank)
local votes = tostring(row.votes)
local balance = tostring(row.balance)
local mapname = tostring(row.mapname)
local author = tostring(row.author)
local gamemode = tostring(row.gamemode)
local t = {id = id, mapresourcename = mapresourcename, rank = rank, votes = votes, balance = balance, mapname = mapname, author = author, gamemode = gamemode}
table.insert(mapsList,t)
end
--table.sort(mapsList,function(a,b) return tostring(a.rank) < tostring(b.rank) end)
triggerClientEvent(p,"maps100_receiveInsight",resourceRoot,voterList,mapsList)
end
addEvent("maps100_fetchInsight", true)
addEventHandler("maps100_fetchInsight", resourceRoot, maps100_fetchInsight)
function maps100_removeVote(p, forumid, option)
local qh = dbQuery(handlerConnect, "SELECT * FROM `votestop100` WHERE `forumid`=?", forumid)
local votesList_sql = dbPoll(qh,-1)
if not votesList_sql then return false end
if votesList_sql[1] then
local empty = ""
if option == "all" then
local qh = dbQuery(handlerConnect, "DELETE FROM `votestop100` WHERE `forumid`=?", forumid)
if dbFree( qh ) then
outputChatBox("Voter removed succesfully", p)
end
elseif option == "choice1" then
local qh = dbQuery(handlerConnect, "UPDATE `votestop100` SET `choice1`=? WHERE `forumid`=?", empty, forumid)
if dbFree( qh ) then
outputChatBox("Vote ".. option .. " removed succesfully", p)
end
elseif option == "choice2" then
local qh = dbQuery(handlerConnect, "UPDATE `votestop100` SET `choice2`=? WHERE `forumid`=?", empty, forumid)
if dbFree( qh ) then
outputChatBox("Vote ".. option .. " removed succesfully", p)
end
elseif option == "choice3" then
local qh = dbQuery(handlerConnect, "UPDATE `votestop100` SET `choice3`=? WHERE `forumid`=?", empty, forumid)
if dbFree( qh ) then
outputChatBox("Vote ".. option .. " removed succesfully", p)
end
elseif option == "choice4" then
local qh = dbQuery(handlerConnect, "UPDATE `votestop100` SET `choice4`=? WHERE `forumid`=?", empty, forumid)
if dbFree( qh ) then
outputChatBox("Vote ".. option .. " removed succesfully", p)
end
elseif option == "choice5" then
local qh = dbQuery(handlerConnect, "UPDATE `votestop100` SET `choice5`=? WHERE `forumid`=?", empty, forumid)
if dbFree( qh ) then
outputChatBox("Vote ".. option .. " removed succesfully", p)
end
else
outputChatBox("No option selected", p)
end
maps100_fetchInsight(p)
else
outputChatBox("Player not in database", p)
end
end
addEvent("maps100_removeVote", true)
addEventHandler("maps100_removeVote", resourceRoot, maps100_removeVote)
function maps100_countVotes(p)
local qh = dbQuery(handlerConnect, "SELECT * FROM `mapstop100`")
local maps_sql = dbPoll(qh,-1)
if not maps_sql then
outputDebugString("Could not fetch maps_sql")
return false
end
local mapRatings = exports.mapratings:getTableOfRatedMaps()
if not mapRatings then
outputDebugString("Could not fetch mapRatings")
return false
end
local qh = dbQuery(handlerConnect, "SELECT * FROM `votestop100`")
local votes_sql = dbPoll(qh,-1)
if not votes_sql then
outputDebugString("Could not fetch votes_sql")
return false
end
for _,row in ipairs(maps_sql) do
local resname = tostring(maps_sql[_].mapresourcename)
local votes = 0
for i,rij in ipairs(votes_sql) do
if tostring(votes_sql[i].choice1) == resname then votes = votes + 1 end
if tostring(votes_sql[i].choice2) == resname then votes = votes + 1 end
if tostring(votes_sql[i].choice3) == resname then votes = votes + 1 end
if tostring(votes_sql[i].choice4) == resname then votes = votes + 1 end
if tostring(votes_sql[i].choice5) == resname then votes = votes + 1 end
end
local rating = mapRatings[resname]
local balance = 0
if rating then
likes = rating.likes
dislikes = rating.dislikes
if tonumber(likes) and tonumber(dislikes) then
balance = tonumber(likes) - tonumber(dislikes)
end
end
local qh = dbQuery(handlerConnect, "UPDATE `mapstop100` SET `votes`=?, `balance`=? WHERE `mapresourcename`=?", votes, balance, resname)
if dbFree( qh ) then
else
outputChatBox("Could not set ".. votes .. " votes for " .. resname, p)
end
end
local qh = dbQuery(handlerConnect, "SELECT * FROM `mapstop100` ORDER BY `votes` DESC, `balance` DESC")
local maps_sql = dbPoll(qh,-1)
if not maps_sql then return false end
for _,row in ipairs(maps_sql) do
local resname = tostring(maps_sql[_].mapresourcename)
local qh = dbQuery(handlerConnect, "UPDATE `mapstop100` SET `rank`=? WHERE `mapresourcename`=?", _, resname)
if dbFree( qh ) then
else
outputChatBox("Could not set ".. _ .. " rank for " .. resname, p)
end
end
maps100_fetchInsight(p)
end
addEvent("maps100_countVotes", true)
addEventHandler("maps100_countVotes", resourceRoot, maps100_countVotes)
function mapstop100_insertTrigger(p, rank)
local qh = dbQuery(handlerConnect, "SELECT * FROM `mapstop100` WHERE `rank`<=? ORDER BY `rank` DESC", rank)
local map100_sql = dbPoll(qh,-1)
if not map100_sql then return false end
exports.gcshop:mapstop100_insert(p, map100_sql)
end
addEvent("mapstop100_insertTrigger", true)
addEventHandler("mapstop100_insertTrigger", resourceRoot, mapstop100_insertTrigger)
function mapstop100_removeTrigger(p)
exports.gcshop:mapstop100_remove(p)
end
addEvent("mapstop100_removeTrigger", true)
addEventHandler("mapstop100_removeTrigger", resourceRoot, mapstop100_removeTrigger)
|
--------------------------------------------------------------------------------
-- modules that extend functionality of the string.
--------------------------------------------------------------------------------
local M = {}
setmetatable(M, {__index = string})
local string = M
--------------------------------------------------------------------------------
-- Converts the string to number, or returns string if fail.
--------------------------------------------------------------------------------
function string.toNumber( self )
if type( tonumber( self ) ) =="number" then
return tonumber( self )
else
return self
end
end
--------------------------------------------------------------------------------
-- Converts number to string, filling in zeros at beginning.
-- Technically, this shouldn't really extend string class
-- because it doesn't operate on string (doesn't have a "self" )
-- Usage: print( string.fromNumbersWithZeros( 421, 6 ) )
-- 000421
--------------------------------------------------------------------------------
function string.fromNumberWithZeros( n, l )
local s = tostring ( n )
local sl = string.len ( s )
if sl < l then
-- add zeros before
for i=1, l - sl do
s = "0"..s
end
end
return s
end
--------------------------------------------------------------------------------
-- Converts hex number to rgb (format: #FF00FF)
--------------------------------------------------------------------------------
function string.hexToRGB( s, returnAsTable )
if returnAsTable then
return { tonumber ( string.sub( s, 2, 3 ),16 )/255.0,
tonumber ( string.sub( s, 4, 5 ),16 )/255.0,
tonumber ( string.sub( s, 6, 7 ),16 )/255.0 }
else
return tonumber ( string.sub( s, 2, 3 ),16 )/255.0,
tonumber ( string.sub( s, 4, 5 ),16 )/255.0,
tonumber ( string.sub( s, 6, 7 ),16 )/255.0
end
end
--------------------------------------------------------------------------------
-- Splits string into N lines, using default ("#") or custom delimiter
-- Routine separate words by spaces so make sure you have them.
-- USAGE: For a string "width:150 height:150", or "width:150_height:150"
-- returns a table { width=150, height=150 }
--------------------------------------------------------------------------------
function string.toTable( self, delimiter )
local t = {}
if not delimiter then delimiter = " " end
local kvPairs = self:split( delimiter )
local k, v, kvPair
for i=1, #kvPairs do
kvPair = kvPairs[i]:split( ":" )
if #kvPair == 2 then
t[ kvPair[1] ] = string.toNumber( kvPair[2] )
end
end
return t
end
--------------------------------------------------------------------------------
-- Splits string into a table of strings using delimiter.<br>
-- Usage: local table = a:split( ",", false )<br>
-- TODO: Does not correspond to multi-byte.<br>
-- @param self string.
-- @param delim Delimiter.
-- @param toNumber If set to true or to be converted to a numeric value.
-- @return Split the resulting table
--------------------------------------------------------------------------------
function string.split( self, delim, toNumber )
local start = 1
local t = {} -- results table
local newElement
-- find each instance of a string followed by the delimiter
while true do
local pos = string.find (self, delim, start, true) -- plain find
if not pos then
break
end
-- force to number
newElement = string.sub (self, start, pos - 1)
if toNumber then
newElement = newElement:toNumber()
end
table.insert (t, newElement)
start = pos + string.len (delim)
end -- while
-- insert final one (after last delimiter)
local value = string.sub (self, start)
if toNumber then
value = value:toNumber()
end
table.insert (t,value )
return t
end
--------------------------------------------------------------------------------
-- Splits string into N lines, using default ("#") or custom delimiter
-- Routine separate words by spaces so make sure you have them.
-- Usage: local string = s:splitIntoLines( 3, "\n" )
--------------------------------------------------------------------------------
function string.splitToLines( self, numLines, delim )
local result = ""
delim = delim or "#" -- Default delimiter used for display.newText
numLines = numLines or 2
-- break into all words.
local allWords = self:split( " " )
if #allWords < numLines then
numLines = #allWords
end
-- Words per line
local wordsPerLine = math.ceil( #allWords/numLines )
local counter = wordsPerLine
for i=1, #allWords do
result = result..allWords[i]
counter = counter - 1
if counter == 0 and i<#allWords then
counter = wordsPerLine
result = result..delim
else
result = result.." "
end
end
return result
end
------------------------------------------------------------------------------
-- String encryption
--------------------------------------------------------------------------------
function string.encrypt( str, code )
code = code or math.random(3,8)
local newString = string.char( 65 + code )
local newChar
for i=1, str:len() do
newChar = str:byte(i) + code
newString = newString..string.char(newChar)
end
return newString
end
------------------------------------------------------------------------------
-- String encryption
--------------------------------------------------------------------------------
function string.decrypt( str )
local newString = ""
local code = str:byte(1) - 65
for i = 2, str:len() do
newChar = str:byte(i) - code
newString = newString..string.char(newChar)
end
return newString
end
return M
|
local PLUGIN = PLUGIN;
local Clockwork = Clockwork;
local startSounds = {
"npc/overwatch/radiovoice/on1.wav",
"npc/overwatch/radiovoice/on3.wav",
"npc/metropolice/vo/on2.wav"
};
local endSounds = {
"npc/metropolice/vo/off1.wav",
"npc/metropolice/vo/off2.wav",
"npc/metropolice/vo/off3.wav",
"npc/metropolice/vo/off4.wav",
"npc/overwatch/radiovoice/off2.wav",
"npc/overwatch/radiovoice/off2.wav"
};
local commaFile = "npc/overwatch/radiovoice/_comma.wav";
--[[
stages:
0-start sound
1-attention...
2-[charges]
3-judged guilty...
4-stop sound
]]
local function DispChargesContinue(player, stage, chargesLeft)
if (!IsValid(player) or !Schema:PlayerIsCombine(player)) then
return;
end;
local sound;
local waitTime;
if (stage < 1) then
sound = startSounds[math.random( #startSounds )];
waitTime = SoundDuration(sound);
stage = stage + 1;
elseif (stage == 1) then
sound = "npc/overwatch/radiovoice/attentionyouhavebeenchargedwith.wav";
waitTime = SoundDuration(sound) + SoundDuration(commaFile);
stage = stage + 1;
elseif (stage == 2) then
local chargeNum = chargesLeft[1];
if PLUGIN.chargesData[chargeNum] then
sound = PLUGIN.chargesData[chargeNum][1];
waitTime = SoundDuration(sound) + SoundDuration(commaFile);
else
-- Invalid charge somehow.
SoundDuration(commaFile);
end;
table.remove(chargesLeft, 1);
if (#chargesLeft < 1) then
stage = stage + 1;
end;
elseif (stage == 3) then
sound = "npc/overwatch/radiovoice/youarejudgedguilty.wav";
waitTime = SoundDuration(sound);
stage = stage + 1;
else
sound = endSounds[math.random( #endSounds )];
end;
if (sound) then
player:EmitSound(sound);
end;
if (waitTime) then
timer.Simple(waitTime, function()
DispChargesContinue(player, stage, chargesLeft);
end);
end;
end;
Clockwork.datastream:Hook("DispCharges", function(player, data)
if (Schema:PlayerIsCombine(player) and type(data[1]) == "table") then
if (#data[1] < 1) then
Clockwork.player:Notify(player, "You haven't checked any charges!");
else
local sentence = "Attention, you have been charged with: ";
for i, chargeNum in ipairs(data[1]) do
if PLUGIN.chargesData[chargeNum] then
sentence = sentence .. PLUGIN.chargesData[chargeNum][2] .. (i == #data[1] and "." or ";") .. " ";
end;
end;
sentence = sentence .. "You are judged guilty by civil protection teams.";
DispChargesContinue(player, 0, data[1]);
Clockwork.chatBox:AddInRadius(player, "ic", sentence, player:GetPos(), Clockwork.config:Get("talk_radius"):Get());
end;
end;
end)
|
workspace "Apate"
architecture "x64"
startproject "Sandbox"
configurations
{
"Debug",
"Release",
"Dist"
}
outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
-- Include directories relative to root folder (solution directory)
IncludeDir = {}
IncludeDir["GLFW"] = "Apate/vendor/GLFW/include"
IncludeDir["Glad"] = "Apate/vendor/Glad/include"
IncludeDir["ImGui"] = "Apate/vendor/imgui"
IncludeDir["glm"] = "Apate/vendor/glm"
group "Dependencies"
include "Apate/vendor/GLFW"
include "Apate/vendor/Glad"
include "Apate/vendor/imgui"
group ""
project "Apate"
location "Apate"
kind "StaticLib"
language "C++"
cppdialect "C++17"
staticruntime "on"
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
files
{
"%{prj.name}/src/**.h",
"%{prj.name}/src/**.cpp",
"%{prj.name}/src/**.c",
"%{prj.name}/vendor/glm/glm/**.hpp",
"%{prj.name}/vendor/glm/glm/**.inl",
}
defines
{
"_CRT_SECURE_NO_WARNINGS",
}
-- The contents of the %{} are run through loadstring()
includedirs
{
"%{prj.name}/src",
"%{prj.name}/vendor/spdlog/include",
"%{IncludeDir.GLFW}",
"%{IncludeDir.Glad}",
"%{IncludeDir.ImGui}",
"%{IncludeDir.glm}",
}
links
{
"GLFW",
"Glad",
"ImGui",
"opengl32.lib",
}
pchheader "APpch.h"
pchsource "Apate/src/APpch.cpp"
filter "files:**.c"
flags { "NoPCH" }
filter "system:windows"
systemversion "latest"
defines
{
"AP_PLATFORM_WINDOWS",
"AP_BUILD_DLL",
"GLFW_INCLUDE_NONE",
}
filter "configurations:Debug"
defines "AP_DEBUG"
runtime "Debug"
symbols "on"
filter "configurations:Release"
defines "AP_RELEASE"
runtime "Release"
optimize "on"
filter "configurations:Dist"
defines "AP_DIST"
runtime "Release"
optimize "on"
project "Sandbox"
location "Sandbox"
kind "ConsoleApp"
language "C++"
cppdialect "C++17"
staticruntime "on"
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
files
{
"%{prj.name}/src/**.h",
"%{prj.name}/src/**.cpp",
}
includedirs
{
"Apate/vendor/spdlog/include",
"Apate/src",
"Apate/vendor",
"%{IncludeDir.glm}",
}
links
{
"Apate",
}
filter "system:windows"
systemversion "latest"
defines
{
"AP_PLATFORM_WINDOWS",
}
filter "configurations:Debug"
defines "AP_DEBUG"
runtime "Debug"
symbols "on"
filter "configurations:Release"
defines "AP_RELEASE"
runtime "Release"
optimize "on"
filter "configurations:Dist"
defines "AP_DIST"
runtime "Release"
optimize "on"
|
controller = class("controller")
function controller:initialize()
self.currentPlayer = 1
players[self.currentPlayer].beingControlled = true
self.team = 1
self.bulletCooldown = 0
end
function controller:update(dt)
if not players[self.currentPlayer] then
self:switchToRandom()
end
if players[self.currentPlayer] then
self:move(dt)
self:shoot()
self.bulletCooldown = self.bulletCooldown - dt
if love.mouse.isDown(1) then
self:fireGun()
end
end
end
function controller:move(dt)
if players[self.currentPlayer] then
if love.keyboard.isDown("w") then
players[self.currentPlayer].y = players[self.currentPlayer].y - players[self.currentPlayer].speed*dt
players[self.currentPlayer].up = true
else
players[self.currentPlayer].up = false
end
if love.keyboard.isDown("a") then
players[self.currentPlayer].x = players[self.currentPlayer].x - players[self.currentPlayer].speed*dt
players[self.currentPlayer].left = true
else
players[self.currentPlayer].left = false
end
if love.keyboard.isDown("s") then
players[self.currentPlayer].y = players[self.currentPlayer].y + players[self.currentPlayer].speed*dt
players[self.currentPlayer].down = true
else
players[self.currentPlayer].down = false
end
if love.keyboard.isDown("d") then
players[self.currentPlayer].x = players[self.currentPlayer].x + players[self.currentPlayer].speed*dt
players[self.currentPlayer].right = true
else
players[self.currentPlayer].right = false
end
--Decide quad. This is temporary until animations!
if players[self.currentPlayer].up then
if players[self.currentPlayer].left then
players[self.currentPlayer].direction = 1
elseif players[self.currentPlayer].right then
players[self.currentPlayer].direction = 3
else
players[self.currentPlayer].direction = 2
end
players[self.currentPlayer].currentQuad = 5
elseif players[self.currentPlayer].down then
if players[self.currentPlayer].left then
players[self.currentPlayer].direction = 7
players[self.currentPlayer].currentQuad = 1
elseif players[self.currentPlayer].right then
players[self.currentPlayer].direction = 5
players[self.currentPlayer].currentQuad = 2
else
players[self.currentPlayer].direction = 6
players[self.currentPlayer].currentQuad = 1
end
elseif players[self.currentPlayer].right then
players[self.currentPlayer].direction = 4
players[self.currentPlayer].currentQuad = 4
elseif players[self.currentPlayer].left then
players[self.currentPlayer].direction = 8
players[self.currentPlayer].currentQuad = 3
end
end
-- 1 2 3
-- 8 4
-- 7 6 5
end
function controller:shoot()
if love.keyboard.isDown("space") and players[self.currentPlayer].hasBall then
players[self.currentPlayer]:shootDirection(players[self.currentPlayer].direction, self.currentPlayer)
end
end
function controller:switchPlayer(n)
if players[self.currentPlayer] then
players[self.currentPlayer].beingControlled = false
end
self.currentPlayer = n
if players[self.currentPlayer] then
players[self.currentPlayer].beingControlled = true
end
end
function controller:switchToRandom()
if game.team1Players > 1 then
local n = math.random(1, #players)
while players[n] == nil or n == controller.currentPlayer or players[n].team == 2 do
n = math.random(1, #players)
end
self:switchPlayer(n)
else
for i,v in pairs(players) do
if v.team == 1 then
self:switchPlayer(v.id)
end
end
end
end
function controller:fireGun()
if self.bulletCooldown <= 0 then
local mouseX, mouseY = camera:mousePosition()
local angle = math.atan2((mouseY - players[self.currentPlayer].y), (mouseX - players[self.currentPlayer].x))
bullet:new(players[self.currentPlayer].x, players[self.currentPlayer].y, angle)
self.bulletCooldown = 0.5
love.audio.play(shootSound)
end
end
function controller:reset()
self.currentPlayer = 1
players[self.currentPlayer].beingControlled = true
self.bulletCooldown = 0
end
|
ESX = nil
local playerInventory = {}
local Stashs = {}
local Drops = {}
local ESXItems = {}
local Shops = {}
local invopened = {}
local openedinventories = {}
local Gloveboxes = {}
local Trunks = {}
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
print( ('^1[%s]^2 is starting..^7'):format('hsn-inventory') )
exports.ghmattimysql:ready(function()
exports.ghmattimysql:execute('SELECT * FROM items', {}, function(result)
for k,v in ipairs(result) do
ESXItems[v.name] = {
name = v.name,
label = v.label,
weight = v.weight,
stackable = v.stackable,
description = v.description,
closeonuse = v.closeonuse
}
end
for k,v in pairs(Config.ItemList) do
if not ESXItems[k] then
print( ('^1[%s]^3 Item `%s` is missing from your database! Item has been created with placeholder data.^7'):format('hsn-inventory', k) )
ESXItems[k] = {
name = k,
label = k,
weight = 1,
stackable = 1,
description = 'Item is not loaded in SQL',
closeonuse = 1
}
end
end
end)
print( ('^1[%s]^2 Items have been created!^7'):format('hsn-inventory') )
end)
IfInventoryCanCarry = function(inventory, maxweight, newWeight)
newWeight = tonumber(newWeight)
local weight = 0
local returnData = false
if inventory ~= nil then
for k, v in pairs(inventory) do
weight = weight + (v.weight * v.count)
end
if weight + newWeight <= maxweight then
returnData = true
end
end
return returnData
end
GetRandomLicense = function(text)
if not text then text = 'HSN' end
local random = math.random(111111,999999)
local random2 = math.random(111111,999999)
local license = ('%s%s%s'):format(random, text, random2)
return license
end
GetItemsSlot = function(inventory, name)
local returnData = {}
for k,v in pairs(inventory) do
if v.name == name then
table.insert(returnData,v)
end
end
return returnData
end
GetItemCount = function(identifier, item)
local count = 0
for i,j in pairs(playerInventory[identifier]) do
if (j.name == item) then
count = count + j.count
end
end
return count
end
AddPlayerInventory = function(identifier, item, count, slot, metadata)
if playerInventory[identifier] == nil then
playerInventory[identifier] = {}
end
local xPlayer = ESX.GetPlayerFromIdentifier(identifier)
if ESXItems[item] ~= nil then
if item ~= nil and count ~= nil then
if item:find('WEAPON_') then
count = 1
for i = 1, Config.PlayerSlot do
if playerInventory[identifier][i] == nil then
if metadata == nil then
metadata = {}
metadata.durability = 100
metadata.ammo = 0
metadata.components = {}
end
metadata.weaponlicense = GetRandomLicense(metadata.weaponlicense)
if metadata.registered == 'setname' then metadata.registered = xPlayer.getName() end
playerInventory[identifier][i] = {name = item ,label = ESXItems[item].label , weight = ESXItems[item].weight, slot = i, count = count, description = ESXItems[item].description, metadata = metadata or {}, stackable = false, closeonuse = ESXItems[item].closeonuse} -- because weapon :)
break
end
end
elseif item:find('identification') then
count = 1
for i = 1, Config.PlayerSlot do
if playerInventory[identifier][i] == nil then
if metadata == nil then
metadata = {}
metadata.description = getPlayerIdentification(xPlayer)
end
playerInventory[identifier][i] = {name = item ,label = ESXItems[item].label , weight = ESXItems[item].weight, slot = i, count = count, description = ESXItems[item].description, metadata = metadata or {}, stackable = false, closeonuse = ESXItems[item].closeonuse}
break
end
end
else
if slot ~= nil then
playerInventory[identifier][slot] = {name = item ,label = ESXItems[item].label, weight = ESXItems[item].weight, slot = i, count = count, description = ESXItems[item].description, metadata = metadata or {}, stackable = ESXItems[item].stackable, closeonuse = ESXItems[item].closeonuse}
else
for i = 1, Config.PlayerSlot do
if playerInventory[identifier][i] ~= nil and playerInventory[identifier][i].name == item then
playerInventory[identifier][i] = {name = item ,label = ESXItems[item].label, weight = ESXItems[item].weight, slot = i, count = playerInventory[identifier][i].count + count, description = ESXItems[item].description, metadata = metadata or {}, stackable = ESXItems[item].stackable, closeonuse = ESXItems[item].closeonuse}
break
else
if playerInventory[identifier][i] == nil then
playerInventory[identifier][i] = {name = item ,label = ESXItems[item].label, weight = ESXItems[item].weight, slot = i, count = count, description = ESXItems[item].description, metadata = metadata or {}, stackable = ESXItems[item].stackable, closeonuse = ESXItems[item].closeonuse}
break
end
end
end
end
end
end
else
print("[^2hsn-inventory^0] - item not found")
end
end
RemovePlayerInventory = function(identifier,item, count, slot, metadata)
if ESXItems[item] ~= nil then
for i = 1, Config.PlayerSlot do
if playerInventory[identifier][i] ~= nil and playerInventory[identifier][i].name == item then
playerInventory[identifier][i].count = tonumber(playerInventory[identifier][i].count)
if playerInventory[identifier][i].count > count then
playerInventory[identifier][i].count = playerInventory[identifier][i].count - count
break
elseif playerInventory[identifier][i].count == count then
playerInventory[identifier][i] = nil
break
elseif playerInventory[identifier][i].count < count then
local slots = GetItemsSlot(playerInventory[identifier], item)
for i,j in pairs(slots) do
if j ~= nil then
j.count = tonumber(j.count)
if j.count - count < 0 then
local tempCount = playerInventory[identifier][j.slot].count
playerInventory[identifier][j.slot] = nil
count = count - tempCount
elseif j.count - count > 0 then
playerInventory[identifier][j.slot].count = playerInventory[identifier][j.slot] - count
elseif j.count - count == 0 then
playerInventory[identifier][j.slot] = nil
end
end
end
break
end
end
end
end
end
RandomDropId = function()
local random = math.random(11111,99999)
return random
end
RegisterNetEvent("inventory:isShopOpen")
AddEventHandler("inventory:isShopOpen",function(state)
local state = state
if state == false then
shopOpen = false
elseif state == true then
shopOpen = true
end
return shopOpen
end)
RegisterNetEvent("hsn-inventory:server:saveInventoryData")
AddEventHandler("hsn-inventory:server:saveInventoryData",function(data)
local src = source
local Player = ESX.GetPlayerFromId(src)
if data ~= nil then
if data.frominv == data.toinv and (data.frominv == 'Playerinv') and not shopOpen then
if data.type == 'swap' and not shopOpen then
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.fromItem)
playerInventory[Player.identifier][data.toslot] = {name = data.toItem.name ,label = data.toItem.label, weight = data.toItem.weight, slot = data.toslot, count = data.toItem.count, description = data.toItem.description, metadata = data.toItem.metadata, stackable = data.toItem.stackable, closeonuse = ESXItems[data.toItem.name].closeonuse}
playerInventory[Player.identifier][data.fromslot] = {name = data.fromItem.name ,label = data.fromItem.label, weight = data.fromItem.weight, slot = data.fromslot, count = data.fromItem.count, description = data.fromItem.description, metadata = data.fromItem.metadata, stackable = data.fromItem.stackable}
elseif data.type == 'freeslot' and not shopOpen then
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.item)
playerInventory[Player.identifier][data.emptyslot] = nil
playerInventory[Player.identifier][data.toslot] = {name = data.item.name ,label = data.item.label, weight = data.item.weight, slot = data.toslot, count = data.item.count, description = data.item.description, metadata = data.item.metadata, stackable = data.item.stackable, closeonuse = ESXItems[data.item.name].closeonuse}
elseif data.type == 'yarimswap' and not shopOpen then
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.oldslotItem)
playerInventory[Player.identifier][data.fromSlot] = {name = data.oldslotItem.name ,label = data.oldslotItem.label, weight = data.oldslotItem.weight, slot = data.fromSlot, count = data.oldslotItem.count, description = data.oldslotItem.description, metadata = data.oldslotItem.metadata, stackable = data.oldslotItem.stackable, closeonuse = ESXItems[data.oldslotItem.name].closeonuse}
playerInventory[Player.identifier][data.toSlot] = {name = data.newslotItem.name ,label = data.newslotItem.label, weight = data.newslotItem.weight, slot = data.toSlot, count = data.newslotItem.count, description = data.newslotItem.description, metadata = data.newslotItem.metadata, stackable = data.newslotItem.stackable, closeonuse = ESXItems[data.newslotItem.name].closeonuse}
end
elseif data.frominv == data.toinv and (data.frominv == "drop") then
local dropid = data.invid
if data.type == 'swap' then
Drops[dropid].inventory[data.toslot] = {name = data.toItem.name ,label = data.toItem.label, weight = data.toItem.weight, slot = data.toslot, count = data.toItem.count, description = data.toItem.description, metadata = data.toItem.metadata, stackable = data.toItem.stackable, closeonuse = ESXItems[data.toItem.name].closeonuse}
Drops[dropid].inventory[data.fromslot] = {name = data.fromItem.name ,label = data.fromItem.label, weight = data.fromItem.weight, slot = data.fromslot, count = data.fromItem.count, description = data.fromItem.description, metadata = data.fromItem.metadata, stackable = data.fromItem.stackable,closeonuse = ESXItems[data.fromItem.name].closeonuse}
elseif data.type == 'freeslot' then
Drops[dropid].inventory[data.emptyslot] = nil
Drops[dropid].inventory[data.toslot] = {name = data.item.name ,label = data.item.label, weight = data.item.weight, slot = data.toslot, count = data.item.count, description = data.item.description, metadata = data.item.metadata, stackable = data.item.stackable, closeonuse = ESXItems[data.item.name].closeonuse}
elseif data.type == 'yarimswap' then
Drops[dropid].inventory[data.fromSlot] = {name = data.oldslotItem.name ,label = data.oldslotItem.label, weight = data.oldslotItem.weight, slot = data.fromSlot, count = data.oldslotItem.count, description = data.oldslotItem.description, metadata = data.oldslotItem.metadata, stackable = data.oldslotItem.stackable, closeonuse = ESXItems[data.oldslotItem.name].closeonuse}
Drops[dropid].inventory[data.toSlot] = {name = data.newslotItem.name ,label = data.newslotItem.label, weight = data.newslotItem.weight, slot = data.toSlot, count = data.newslotItem.count, description = data.newslotItem.description, metadata = data.newslotItem.metadata, stackable = data.newslotItem.stackable, closeonuse = ESXItems[data.newslotItem.name].closeonuse}
end
elseif data.frominv == data.toinv and (data.frominv == "TargetPlayer") then
local targetplayer = tPlayer
if playerInventory[targetplayer.identifier] ~= nil then
if data.type == 'swap' then
playerInventory[targetplayer.identifier][data.toslot] = {name = data.toItem.name ,label = data.toItem.label, weight = data.toItem.weight, slot = data.toslot, count = data.toItem.count, description = data.toItem.description, metadata = data.toItem.metadata, stackable = data.toItem.stackable, closeonuse = ESXItems[data.toItem.name].closeonuse}
playerInventory[targetplayer.identifier][data.fromslot] = {name = data.fromItem.name ,label = data.fromItem.label, weight = data.fromItem.weight, slot = data.fromslot, count = data.fromItem.count, description = data.fromItem.description, metadata = data.fromItem.metadata, stackable = data.fromItem.stackable,closeonuse = ESXItems[data.fromItem.name].closeonuse}
elseif data.type == 'freeslot' then
playerInventory[targetplayer.identifier][data.emptyslot] = nil
playerInventory[targetplayer.identifier][data.toslot] = {name = data.item.name ,label = data.item.label, weight = data.item.weight, slot = data.toslot, count = data.item.count, description = data.item.description, metadata = data.item.metadata, stackable = data.item.stackable, closeonuse = ESXItems[data.item.name].closeonuse}
elseif data.type == 'yarimswap' then
playerInventory[targetplayer.identifier][data.fromSlot] = {name = data.oldslotItem.name ,label = data.oldslotItem.label, weight = data.oldslotItem.weight, slot = data.fromSlot, count = data.oldslotItem.count, description = data.oldslotItem.description, metadata = data.oldslotItem.metadata, stackable = data.oldslotItem.stackable, closeonuse = ESXItems[data.oldslotItem.name].closeonuse}
playerInventory[targetplayer.identifier][data.toSlot] = {name = data.newslotItem.name ,label = data.newslotItem.label, weight = data.newslotItem.weight, slot = data.toSlot, count = data.newslotItem.count, description = data.newslotItem.description, metadata = data.newslotItem.metadata, stackable = data.newslotItem.stackable, closeonuse = ESXItems[data.newslotItem.name].closeonuse}
end
end
elseif data.frominv ~= data.toinv and (data.toinv == "TargetPlayer" and data.frominv == 'Playerinv') then
local targetplayer = tPlayer
if playerInventory[targetplayer.identifier] ~= nil then
if data.type == 'swap' then
if IfInventoryCanCarry(playerInventory[targetplayer.identifier],ESX.GetConfig().MaxWeight, (data.toItem.weight * data.toItem.count)) then
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.toItem)
playerInventory[targetplayer.identifier][data.toslot] = {name = data.toItem.name ,label = data.toItem.label, weight = data.toItem.weight, slot = data.toslot, count = data.toItem.count, description = data.toItem.description, metadata = data.toItem.metadata, stackable = data.toItem.stackable, closeonuse = ESXItems[data.toItem.name].closeonuse}
playerInventory[Player.identifier][data.fromslot] = {name = data.fromItem.name ,label = data.fromItem.label, weight = data.fromItem.weight, slot = data.fromslot, count = data.fromItem.count, description = data.fromItem.description, metadata = data.fromItem.metadata, stackable = data.fromItem.stackable, closeonuse = ESXItems[data.fromItem.name].closeonuse}
TriggerEvent("hsn-inventory:onRemoveInventoryItem",src,data.toItem.name,data.toItem.count)
TriggerEvent("hsn-inventory:onAddInventoryItem",src,data.fromItem.name,data.fromItem.count)
TriggerEvent("hsn-inventory:onAddInventoryItem",targetplayer.source,data.toItem.name,data.toItem.count)
TriggerEvent("hsn-inventory:onRemoveInventoryItem",targetplayer.source,data.fromItem.name,data.fromItem.count)
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
elseif data.type == 'freeslot' then
if IfInventoryCanCarry(playerInventory[targetplayer.identifier],ESX.GetConfig().MaxWeight, (data.item.weight * data.item.count)) then
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.item)
playerInventory[Player.identifier][data.emptyslot] = nil
playerInventory[targetplayer.identifier][data.toslot] = {name = data.item.name ,label = data.item.label, weight = data.item.weight, slot = data.toslot, count = data.item.count, description = data.item.description, metadata = data.item.metadata, stackable = data.item.stackable, closeonuse = ESXItems[data.item.name].closeonuse}
TriggerEvent("hsn-inventory:onRemoveInventoryItem",src,data.item.name,data.item.count)
TriggerEvent("hsn-inventory:onAddInventoryItem",targetplayer.source,data.item.name,data.item.count)
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
elseif data.type == 'yarimswap' then
if IfInventoryCanCarry(playerInventory[targetplayer.identifier],ESX.GetConfig().MaxWeight, (data.item.weight * data.item.count)) then
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.newslotItem)
playerInventory[Player.identifier][data.fromSlot] = {name = data.oldslotItem.name ,label = data.oldslotItem.label, weight = data.oldslotItem.weight, slot = data.fromSlot, count = data.oldslotItem.count, description = data.oldslotItem.description, metadata = data.oldslotItem.metadata, stackable = data.oldslotItem.stackable, closeonuse = ESXItems[data.oldslotItem.name].closeonuse}
playerInventory[targetplayer.identifier][data.toSlot] = {name = data.newslotItem.name ,label = data.newslotItem.label, weight = data.newslotItem.weight, slot = data.toSlot, count = data.newslotItem.count, description = data.newslotItem.description, metadata = data.newslotItem.metadata, stackable = data.newslotItem.stackable, closeonuse = ESXItems[data.newslotItem.name].closeonuse}
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
end
end
elseif data.frominv ~= data.toinv and (data.toinv == 'Playerinv' and data.frominv == 'TargetPlayer') then
local targetplayer = tPlayer
if playerInventory[targetplayer.identifier] ~= nil then
if data.type == 'swap' then
if IfInventoryCanCarry(playerInventory[Player.identifier],ESX.GetConfig().MaxWeight, (data.toItem.weight * data.toItem.count)) then
TriggerClientEvent("hsn-inventory:client:checkweapon",targetplayer.source,data.toItem)
playerInventory[Player.identifier][data.toslot] = {name = data.toItem.name ,label = data.toItem.label, weight = data.toItem.weight, slot = data.toslot, count = data.toItem.count, description = data.toItem.description, metadata = data.toItem.metadata, stackable = data.toItem.stackable, closeonuse = ESXItems[data.toItem.name].closeonuse}
playerInventory[targetplayer.identifier][data.fromslot] = {name = data.fromItem.name ,label = data.fromItem.label, weight = data.fromItem.weight, slot = data.fromslot, count = data.fromItem.count, description = data.fromItem.description, metadata = data.fromItem.metadata, stackable = data.fromItem.stackable, closeonuse = ESXItems[data.fromItem.name].closeonuse}
TriggerEvent("hsn-inventory:onAddInventoryItem",src,data.toItem.name,data.toItem.count)
TriggerEvent("hsn-inventory:onRemoveInventoryItem",src,data.fromItem.name,data.fromItem.count)
TriggerEvent("hsn-inventory:RemoveAddInventoryItem",src,data.toItem.name,data.toItem.count)
TriggerEvent("hsn-inventory:onAddInventoryItem",src,data.fromItem.name,data.fromItem.count)
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
elseif data.type == 'freeslot' then
if IfInventoryCanCarry(playerInventory[Player.identifier],ESX.GetConfig().MaxWeight, (data.item.weight * data.item.count)) then
TriggerClientEvent("hsn-inventory:client:checkweapon",targetplayer.source,data.item)
playerInventory[targetplayer.identifier][data.emptyslot] = nil
playerInventory[Player.identifier][data.toslot] = {name = data.item.name ,label = data.item.label, weight = data.item.weight, slot = data.toslot, count = data.item.count, description = data.item.description, metadata = data.item.metadata, stackable = data.item.stackable, closeonuse = ESXItems[data.item.name].closeonuse}
TriggerEvent("hsn-inventory:onAddInventoryItem",src,data.item.name,data.item.count)
TriggerEvent("hsn-inventory:onRemoveInventoryItem",targetplayer.source,data.item.name,data.item.count)
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
elseif data.type == 'yarimswap' then
if IfInventoryCanCarry(playerInventory[Player.identifier],ESX.GetConfig().MaxWeight, (data.newslotItem.weight * data.newslotItem.count)) then
TriggerClientEvent("hsn-inventory:client:checkweapon",targetplayer.source,data.newslotItem)
playerInventory[targetplayer.identifier][data.fromSlot] = {name = data.oldslotItem.name ,label = data.oldslotItem.label, weight = data.oldslotItem.weight, slot = data.fromSlot, count = data.oldslotItem.count, description = data.oldslotItem.description, metadata = data.oldslotItem.metadata, stackable = data.oldslotItem.stackable, closeonuse = ESXItems[data.oldslotItem.name].closeonuse}
playerInventory[Player.identifier][data.toSlot] = {name = data.newslotItem.name ,label = data.newslotItem.label, weight = data.newslotItem.weight, slot = data.toSlot, count = data.newslotItem.count, description = data.newslotItem.description, metadata = data.newslotItem.metadata, stackable = data.newslotItem.stackable, closeonuse = ESXItems[data.newslotItem.name].closeonuse}
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
end
end
elseif data.frominv == data.toinv and (data.frominv == "stash") then
local stashId = data.invid
if data.type == 'swap' then
Stashs[stashId].inventory[data.toslot] = {name = data.toItem.name ,label = data.toItem.label, weight = data.toItem.weight, slot = data.toslot, count = data.toItem.count, description = data.toItem.description, metadata = data.toItem.metadata, stackable = data.toItem.stackable, closeonuse = ESXItems[data.toItem.name].closeonuse}
Stashs[stashId].inventory[data.fromslot] = {name = data.fromItem.name ,label = data.fromItem.label, weight = data.fromItem.weight, slot = data.fromslot, count = data.fromItem.count, description = data.fromItem.description, metadata = data.fromItem.metadata, stackable = data.fromItem.stackable, closeonuse = ESXItems[data.fromItem.name].closeonuse}
elseif data.type == 'freeslot' then
Stashs[stashId].inventory[data.emptyslot] = nil
Stashs[stashId].inventory[data.toslot] = {name = data.item.name ,label = data.item.label, weight = data.item.weight, slot = data.toslot, count = data.item.count, description = data.item.description, metadata = data.item.metadata, stackable = data.item.stackable, closeonuse = ESXItems[data.item.name].closeonuse}
elseif data.type == 'yarimswap' then
Stashs[stashId].inventory[data.fromSlot] = {name = data.oldslotItem.name ,label = data.oldslotItem.label, weight = data.oldslotItem.weight, slot = data.fromSlot, count = data.oldslotItem.count, description = data.oldslotItem.description, metadata = data.oldslotItem.metadata, stackable = data.oldslotItem.stackable, closeonuse = ESXItems[data.oldslotItem.name].closeonuse}
Stashs[stashId].inventory[data.toSlot] = {name = data.newslotItem.name ,label = data.newslotItem.label, weight = data.newslotItem.weight, slot = data.toSlot, count = data.newslotItem.count, description = data.newslotItem.description, metadata = data.newslotItem.metadata, stackable = data.newslotItem.stackable, closeonuse = ESXItems[data.newslotItem.name].closeonuse}
end
elseif data.frominv == data.toinv and (data.frominv == "trunk") then
local plate = data.invid
if data.type == 'swap' then
Trunks[plate].inventory[data.toslot] = {name = data.toItem.name ,label = data.toItem.label, weight = data.toItem.weight, slot = data.toslot, count = data.toItem.count, description = data.toItem.description, metadata = data.toItem.metadata, stackable = data.toItem.stackable, closeonuse = ESXItems[data.toItem.name].closeonuse}
Trunks[plate].inventory[data.fromslot] = {name = data.fromItem.name ,label = data.fromItem.label, weight = data.fromItem.weight, slot = data.fromslot, count = data.fromItem.count, description = data.fromItem.description, metadata = data.fromItem.metadata, stackable = data.fromItem.stackable, closeonuse = ESXItems[data.fromItem.name].closeonuse}
elseif data.type == 'freeslot' then
Trunks[plate].inventory[data.emptyslot] = nil
Trunks[plate].inventory[data.toslot] = {name = data.item.name ,label = data.item.label, weight = data.item.weight, slot = data.toslot, count = data.item.count, description = data.item.description, metadata = data.item.metadata, stackable = data.item.stackable, closeonuse = ESXItems[data.item.name].closeonuse}
elseif data.type == 'yarimswap' then
Trunks[plate].inventory[data.fromSlot] = {name = data.oldslotItem.name ,label = data.oldslotItem.label, weight = data.oldslotItem.weight, slot = data.fromSlot, count = data.oldslotItem.count, description = data.oldslotItem.description, metadata = data.oldslotItem.metadata, stackable = data.oldslotItem.stackable, closeonuse = ESXItems[data.oldslotItem.name].closeonuse}
Trunks[plate].inventory[data.toSlot] = {name = data.newslotItem.name ,label = data.newslotItem.label, weight = data.newslotItem.weight, slot = data.toSlot, count = data.newslotItem.count, description = data.newslotItem.description, metadata = data.newslotItem.metadata, stackable = data.newslotItem.stackable, closeonuse = ESXItems[data.newslotItem.name].closeonuse}
end
elseif data.frominv == data.toinv and (data.frominv == "glovebox") then
local plate = data.invid
if data.type == 'swap' then
Gloveboxes[plate].inventory[data.toslot] = {name = data.toItem.name ,label = data.toItem.label, weight = data.toItem.weight, slot = data.toslot, count = data.toItem.count, description = data.toItem.description, metadata = data.toItem.metadata, stackable = data.toItem.stackable, closeonuse = ESXItems[data.toItem.name].closeonuse}
Gloveboxes[plate].inventory[data.fromslot] = {name = data.fromItem.name ,label = data.fromItem.label, weight = data.fromItem.weight, slot = data.fromslot, count = data.fromItem.count, description = data.fromItem.description, metadata = data.fromItem.metadata, stackable = data.fromItem.stackable, closeonuse = ESXItems[data.fromItem.name].closeonuse}
elseif data.type == 'freeslot' then
Gloveboxes[plate].inventory[data.emptyslot] = nil
Gloveboxes[plate].inventory[data.toslot] = {name = data.item.name ,label = data.item.label, weight = data.item.weight, slot = data.toslot, count = data.item.count, description = data.item.description, metadata = data.item.metadata, stackable = data.item.stackable}
elseif data.type == 'yarimswap' then
Gloveboxes[plate].inventory[data.fromSlot] = {name = data.oldslotItem.name ,label = data.oldslotItem.label, weight = data.oldslotItem.weight, slot = data.fromSlot, count = data.oldslotItem.count, description = data.oldslotItem.description, metadata = data.oldslotItem.metadata, stackable = data.oldslotItem.stackable, closeonuse = ESXItems[data.oldslotItem.name].closeonuse}
Gloveboxes[plate].inventory[data.toSlot] = {name = data.newslotItem.name ,label = data.newslotItem.label, weight = data.newslotItem.weight, slot = data.toSlot, count = data.newslotItem.count, description = data.newslotItem.description, metadata = data.newslotItem.metadata, stackable = data.newslotItem.stackable, closeonuse = ESXItems[data.newslotItem.name].closeonuse}
end
elseif data.frominv ~= data.toinv and (data.toinv == "drop" and data.frominv == 'Playerinv') then
local dropid = data.invid
if dropid == nil then
CreateNewDrop(src,data)
TriggerClientEvent("hsn-inventory:client:closeInventory",src,data.invid)
else
if data.type == 'swap' then
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.toItem)
Drops[dropid].inventory[data.toslot] = {name = data.toItem.name ,label = data.toItem.label, weight = data.toItem.weight, slot = data.toslot, count = data.toItem.count, description = data.toItem.description, metadata = data.toItem.metadata, stackable = data.toItem.stackable, closeonuse = ESXItems[data.toItem.name].closeonuse}
playerInventory[Player.identifier][data.fromslot] = {name = data.fromItem.name ,label = data.fromItem.label, weight = data.fromItem.weight, slot = data.fromslot, count = data.fromItem.count, description = data.fromItem.description, metadata = data.fromItem.metadata, stackable = data.fromItem.stackable, closeonuse = ESXItems[data.fromItem.name].closeonuse}
TriggerEvent("hsn-inventory:onRemoveInventoryItem",src,data.toItem.name,data.toItem.count)
TriggerEvent("hsn-inventory:onAddInventoryItem",src,data.fromItem.name,data.fromItem.count)
elseif data.type == 'freeslot' then
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.item)
playerInventory[Player.identifier][data.emptyslot] = nil
Drops[dropid].inventory[data.toslot] = {name = data.item.name ,label = data.item.label, weight = data.item.weight, slot = data.toslot, count = data.item.count, description = data.item.description, metadata = data.item.metadata, stackable = data.item.stackable, closeonuse = ESXItems[data.item.name].closeonuse}
TriggerEvent("hsn-inventory:onRemoveInventoryItem",src,data.item.name,data.item.count)
elseif data.type == 'yarimswap' then
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.newslotItem)
playerInventory[Player.identifier][data.fromSlot] = {name = data.oldslotItem.name ,label = data.oldslotItem.label, weight = data.oldslotItem.weight, slot = data.fromSlot, count = data.oldslotItem.count, description = data.oldslotItem.description, metadata = data.oldslotItem.metadata, stackable = data.oldslotItem.stackable, closeonuse = ESXItems[data.oldslotItem.name].closeonuse}
Drops[dropid].inventory[data.toSlot] = {name = data.newslotItem.name ,label = data.newslotItem.label, weight = data.newslotItem.weight, slot = data.toSlot, count = data.newslotItem.count, description = data.newslotItem.description, metadata = data.newslotItem.metadata, stackable = data.newslotItem.stackable, closeonuse = ESXItems[data.newslotItem.name].closeonuse}
end
end
elseif data.frominv ~= data.toinv and (data.toinv == 'Playerinv' and data.frominv == 'drop') then
local dropid = data.invid2
if data.type == 'swap' then
if IfInventoryCanCarry(playerInventory[Player.identifier],ESX.GetConfig().MaxWeight, (data.toItem.weight * data.toItem.count)) then
playerInventory[Player.identifier][data.toslot] = {name = data.toItem.name ,label = data.toItem.label, weight = data.toItem.weight, slot = data.toslot, count = data.toItem.count, description = data.toItem.description, metadata = data.toItem.metadata, stackable = data.toItem.stackable, closeonuse = ESXItems[data.toItem.name].closeonuse}
Drops[dropid].inventory[data.fromslot] = {name = data.fromItem.name ,label = data.fromItem.label, weight = data.fromItem.weight, slot = data.fromslot, count = data.fromItem.count, description = data.fromItem.description, metadata = data.fromItem.metadata, stackable = data.fromItem.stackable, closeonuse = ESXItems[data.fromItem.name].closeonuse}
TriggerEvent("hsn-inventory:onAddInventoryItem",src,data.toItem.name,data.toItem.count)
TriggerEvent("hsn-inventory:onRemoveInventoryItem",src,data.fromItem.name,data.fromItem.count)
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
elseif data.type == 'freeslot' then
if IfInventoryCanCarry(playerInventory[Player.identifier],ESX.GetConfig().MaxWeight, (data.item.weight * data.item.count)) then
Drops[dropid].inventory[data.emptyslot] = nil
playerInventory[Player.identifier][data.toslot] = {name = data.item.name ,label = data.item.label, weight = data.item.weight, slot = data.toslot, count = data.item.count, description = data.item.description, metadata = data.item.metadata, stackable = data.item.stackable, closeonuse = ESXItems[data.item.name].closeonuse}
TriggerEvent("hsn-inventory:onAddInventoryItem",src,data.item.name,data.item.count)
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
elseif data.type == 'yarimswap' then
if IfInventoryCanCarry(playerInventory[Player.identifier],ESX.GetConfig().MaxWeight, (data.newslotItem.weight * data.newslotItem.count)) then
Drops[dropid].inventory[data.fromSlot] = {name = data.oldslotItem.name ,label = data.oldslotItem.label, weight = data.oldslotItem.weight, slot = data.fromSlot, count = data.oldslotItem.count, description = data.oldslotItem.description, metadata = data.oldslotItem.metadata, stackable = data.oldslotItem.stackable, closeonuse = ESXItems[data.oldslotItem.name].closeonuse}
playerInventory[Player.identifier][data.toSlot] = {name = data.newslotItem.name ,label = data.newslotItem.label, weight = data.newslotItem.weight, slot = data.toSlot, count = data.newslotItem.count, description = data.newslotItem.description, metadata = data.newslotItem.metadata, stackable = data.newslotItem.stackable, closeonuse = ESXItems[data.newslotItem.name].closeonuse}
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
end
if next(Drops[dropid].inventory) == nil then
TriggerClientEvent("hsn-inventory:client:removeDrop",-1,dropid)
TriggerClientEvent("hsn-inventory:client:closeInventory",src,dropid) --
end
elseif data.frominv ~= data.toinv and (data.toinv == "stash" and data.frominv == 'Playerinv') then
local stashId = data.invid
if data.type == 'swap' then
TriggerEvent("hsn-inventory:onRemoveInventoryItem",src,data.toItem.name,data.toItem.count)
TriggerEvent("hsn-inventory:onAddInventoryItem",src,data.fromItem.name,data.fromItem.count)
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.toItem)
Stashs[stashId].inventory[data.toslot] = {name = data.toItem.name ,label = data.toItem.label, weight = data.toItem.weight, slot = data.toslot, count = data.toItem.count, description = data.toItem.description, metadata = data.toItem.metadata, stackable = data.toItem.stackable, closeonuse = ESXItems[data.toItem.name].closeonuse}
playerInventory[Player.identifier][data.fromslot] = {name = data.fromItem.name ,label = data.fromItem.label, weight = data.fromItem.weight, slot = data.fromslot, count = data.fromItem.count, description = data.fromItem.description, metadata = data.fromItem.metadata, stackable = data.fromItem.stackable, closeonuse = ESXItems[data.fromItem.name].closeonuse}
elseif data.type == 'freeslot' then
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.item)
playerInventory[Player.identifier][data.emptyslot] = nil
Stashs[stashId].inventory[data.toslot] = {name = data.item.name ,label = data.item.label, weight = data.item.weight, slot = data.toslot, count = data.item.count, description = data.item.description, metadata = data.item.metadata, stackable = data.item.stackable, closeonuse = ESXItems[data.item.name].closeonuse}
TriggerEvent("hsn-inventory:onRemoveInventoryItem",src,data.item.name,data.item.count)
elseif data.type == 'yarimswap' then
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.newslotItem)
playerInventory[Player.identifier][data.fromSlot] = {name = data.oldslotItem.name ,label = data.oldslotItem.label, weight = data.oldslotItem.weight, slot = data.fromSlot, count = data.oldslotItem.count, description = data.oldslotItem.description, metadata = data.oldslotItem.metadata, stackable = data.oldslotItem.stackable, closeonuse = ESXItems[data.oldslotItem.name].closeonuse}
Stashs[stashId].inventory[data.toSlot] = {name = data.newslotItem.name ,label = data.newslotItem.label, weight = data.newslotItem.weight, slot = data.toSlot, count = data.newslotItem.count, description = data.newslotItem.description, metadata = data.newslotItem.metadata, stackable = data.newslotItem.stackable, closeonuse = ESXItems[data.newslotItem.name].closeonuse}
end
elseif data.frominv ~= data.toinv and (data.toinv == "trunk" and data.frominv == "Playerinv") then
local plate = data.invid
if data.type == 'swap' then
TriggerEvent("hsn-inventory:onRemoveInventoryItem",src,data.toItem.name,data.toItem.count)
TriggerEvent("hsn-inventory:onAddInventoryItem",src,data.fromItem.name,data.fromItem.count)
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.toItem)
Trunks[plate].inventory[data.toslot] = {name = data.toItem.name ,label = data.toItem.label, weight = data.toItem.weight, slot = data.toslot, count = data.toItem.count, description = data.toItem.description, metadata = data.toItem.metadata, stackable = data.toItem.stackable, closeonuse = ESXItems[data.toItem.name].closeonuse}
playerInventory[Player.identifier][data.fromslot] = {name = data.fromItem.name ,label = data.fromItem.label, weight = data.fromItem.weight, slot = data.fromslot, count = data.fromItem.count, description = data.fromItem.description, metadata = data.fromItem.metadata, stackable = data.fromItem.stackable, closeonuse = ESXItems[data.fromItem.name].closeonuse}
elseif data.type == 'freeslot' then
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.item)
TriggerEvent("hsn-inventory:onRemoveInventoryItem",src,data.item.name,data.item.count)
playerInventory[Player.identifier][data.emptyslot] = nil
Trunks[plate].inventory[data.toslot] = {name = data.item.name ,label = data.item.label, weight = data.item.weight, slot = data.toslot, count = data.item.count, description = data.item.description, metadata = data.item.metadata, stackable = data.item.stackable, closeonuse = ESXItems[data.item.name].closeonuse}
elseif data.type == 'yarimswap' then
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.newslotItem)
playerInventory[Player.identifier][data.fromSlot] = {name = data.oldslotItem.name ,label = data.oldslotItem.label, weight = data.oldslotItem.weight, slot = data.fromSlot, count = data.oldslotItem.count, description = data.oldslotItem.description, metadata = data.oldslotItem.metadata, stackable = data.oldslotItem.stackable, closeonuse = ESXItems[data.oldslotItem.name].closeonuse}
Trunks[plate].inventory[data.toSlot] = {name = data.newslotItem.name ,label = data.newslotItem.label, weight = data.newslotItem.weight, slot = data.toSlot, count = data.newslotItem.count, description = data.newslotItem.description, metadata = data.newslotItem.metadata, stackable = data.newslotItem.stackable, closeonuse = ESXItems[data.newslotItem.name].closeonuse}
end
elseif data.frominv ~= data.toinv and (data.toinv == "Playerinv" and data.frominv == "trunk") then
local plate = data.invid2
if data.type == 'swap' then
if IfInventoryCanCarry(playerInventory[Player.identifier],ESX.GetConfig().MaxWeight, (data.toItem.weight * data.toItem.count)) then
playerInventory[Player.identifier][data.toslot] = {name = data.toItem.name ,label = data.toItem.label, weight = data.toItem.weight, slot = data.toslot, count = data.toItem.count, description = data.toItem.description, metadata = data.toItem.metadata, stackable = data.toItem.stackable, closeonuse = ESXItems[data.toItem.name].closeonuse}
Trunks[plate].inventory[data.fromslot] = {name = data.fromItem.name ,label = data.fromItem.label, weight = data.fromItem.weight, slot = data.fromslot, count = data.fromItem.count, description = data.fromItem.description, metadata = data.fromItem.metadata, stackable = data.fromItem.stackable, closeonuse = ESXItems[data.fromItem.name].closeonuse}
TriggerEvent("hsn-inventory:onAddInventoryItem",src,data.toItem.name,data.toItem.count)
TriggerEvent("hsn-inventory:onRemoveInventoryItem",src,data.fromItem.name,data.fromItem.count)
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
elseif data.type == 'freeslot' then
if IfInventoryCanCarry(playerInventory[Player.identifier],ESX.GetConfig().MaxWeight, (data.item.weight * data.item.count)) then
Trunks[plate].inventory[data.emptyslot] = nil
playerInventory[Player.identifier][data.toslot] = {name = data.item.name ,label = data.item.label, weight = data.item.weight, slot = data.toslot, count = data.item.count, description = data.item.description, metadata = data.item.metadata, stackable = data.item.stackable, closeonuse = ESXItems[data.item.name].closeonuse}
TriggerEvent("hsn-inventory:onAddInventoryItem",src,data.item.name,data.item.count)
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
elseif data.type == 'yarimswap' then
if IfInventoryCanCarry(playerInventory[Player.identifier],ESX.GetConfig().MaxWeight, (data.newslotItem.weight * data.newslotItem.count)) then
Trunks[plate].inventory[data.fromSlot] = {name = data.oldslotItem.name ,label = data.oldslotItem.label, weight = data.oldslotItem.weight, slot = data.fromSlot, count = data.oldslotItem.count, description = data.oldslotItem.description, metadata = data.oldslotItem.metadata, stackable = data.oldslotItem.stackable, closeonuse = ESXItems[data.oldslotItem.name].closeonuse}
playerInventory[Player.identifier][data.toSlot] = {name = data.newslotItem.name ,label = data.newslotItem.label, weight = data.newslotItem.weight, slot = data.toSlot, count = data.newslotItem.count, description = data.newslotItem.description, metadata = data.newslotItem.metadata, stackable = data.newslotItem.stackable, closeonuse = ESXItems[data.newslotItem.name].closeonuse}
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
end
elseif data.frominv ~= data.toinv and (data.toinv == "glovebox" and data.frominv == "Playerinv") then
local plate = data.invid
if data.type == 'swap' then
TriggerEvent("hsn-inventory:onRemoveInventoryItem",src,data.toItem.name,data.toItem.count)
TriggerEvent("hsn-inventory:onAddInventoryItem",src,data.fromItem.name,data.fromItem.count)
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.toItem)
Gloveboxes[plate].inventory[data.toslot] = {name = data.toItem.name ,label = data.toItem.label, weight = data.toItem.weight, slot = data.toslot, count = data.toItem.count, description = data.toItem.description, metadata = data.toItem.metadata, stackable = data.toItem.stackable, closeonuse = ESXItems[data.toItem.name].closeonuse}
playerInventory[Player.identifier][data.fromslot] = {name = data.fromItem.name ,label = data.fromItem.label, weight = data.fromItem.weight, slot = data.fromslot, count = data.fromItem.count, description = data.fromItem.description, metadata = data.fromItem.metadata, stackable = data.fromItem.stackable, closeonuse = ESXItems[data.fromItem.name].closeonuse}
elseif data.type == 'freeslot' then
TriggerEvent("hsn-inventory:onRemoveInventoryItem",src,data.item.name,data.item.count)
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.item)
playerInventory[Player.identifier][data.emptyslot] = nil
Gloveboxes[plate].inventory[data.toslot] = {name = data.item.name ,label = data.item.label, weight = data.item.weight, slot = data.toslot, count = data.item.count, description = data.item.description, metadata = data.item.metadata, stackable = data.item.stackable, closeonuse = ESXItems[data.item.name].closeonuse}
elseif data.type == 'yarimswap' then
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.newslotItem)
playerInventory[Player.identifier][data.fromSlot] = {name = data.oldslotItem.name ,label = data.oldslotItem.label, weight = data.oldslotItem.weight, slot = data.fromSlot, count = data.oldslotItem.count, description = data.oldslotItem.description, metadata = data.oldslotItem.metadata, stackable = data.oldslotItem.stackable, closeonuse = ESXItems[data.oldslotItem.name].closeonuse}
Gloveboxes[plate].inventory[data.toSlot] = {name = data.newslotItem.name ,label = data.newslotItem.label, weight = data.newslotItem.weight, slot = data.toSlot, count = data.newslotItem.count, description = data.newslotItem.description, metadata = data.newslotItem.metadata, stackable = data.newslotItem.stackable, closeonuse = ESXItems[data.newslotItem.name].closeonuse}
end
elseif data.frominv ~= data.toinv and (data.toinv == "Playerinv" and data.frominv == "glovebox") then
local plate = data.invid2
if data.type == 'swap' then
if IfInventoryCanCarry(playerInventory[Player.identifier],ESX.GetConfig().MaxWeight, (data.toItem.weight * data.toItem.count)) then
playerInventory[Player.identifier][data.toslot] = {name = data.toItem.name ,label = data.toItem.label, weight = data.toItem.weight, slot = data.toslot, count = data.toItem.count, description = data.toItem.description, metadata = data.toItem.metadata, stackable = data.toItem.stackable, closeonuse = ESXItems[data.toItem.name].closeonuse}
Gloveboxes[plate].inventory[data.fromslot] = {name = data.fromItem.name ,label = data.fromItem.label, weight = data.fromItem.weight, slot = data.fromslot, count = data.fromItem.count, description = data.fromItem.description, metadata = data.fromItem.metadata, stackable = data.fromItem.stackable, closeonuse = ESXItems[data.fromItem.name].closeonuse}
TriggerEvent("hsn-inventory:onAddInventoryItem",src,data.toItem.name,data.toItem.count)
TriggerEvent("hsn-inventory:onRemoveInventoryItem",src,data.fromItem.name,data.fromItem.count)
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
elseif data.type == 'freeslot' then
TriggerEvent("hsn-inventory:onAddInventoryItem",src,data.item.name,data.item.count)
if IfInventoryCanCarry(playerInventory[Player.identifier],ESX.GetConfig().MaxWeight, (data.item.weight * data.item.count)) then
Gloveboxes[plate].inventory[data.emptyslot] = nil
playerInventory[Player.identifier][data.toslot] = {name = data.item.name ,label = data.item.label, weight = data.item.weight, slot = data.toslot, count = data.item.count, description = data.item.description, metadata = data.item.metadata, stackable = data.item.stackable, closeonuse = ESXItems[data.item.name].closeonuse}
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
elseif data.type == 'yarimswap' then
if IfInventoryCanCarry(playerInventory[Player.identifier],ESX.GetConfig().MaxWeight, (data.oldslotItem.weight * data.oldslotItem.count)) then
Gloveboxes[plate].inventory[data.fromSlot] = {name = data.oldslotItem.name ,label = data.oldslotItem.label, weight = data.oldslotItem.weight, slot = data.fromSlot, count = data.oldslotItem.count, description = data.oldslotItem.description, metadata = data.oldslotItem.metadata, stackable = data.oldslotItem.stackable, closeonuse = ESXItems[data.oldslotItem.name].closeonuse}
playerInventory[Player.identifier][data.toSlot] = {name = data.newslotItem.name ,label = data.newslotItem.label, weight = data.newslotItem.weight, slot = data.toSlot, count = data.newslotItem.count, description = data.newslotItem.description, metadata = data.newslotItem.metadata, stackable = data.newslotItem.stackable, closeonuse = ESXItems[data.newslotItem.name].closeonuse}
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
end
elseif data.frominv ~= data.toinv and (data.toinv == "Playerinv" and data.frominv == 'stash') then
local stashId = data.invid2
if data.type == 'swap' then
if IfInventoryCanCarry(playerInventory[Player.identifier],ESX.GetConfig().MaxWeight, (data.toItem.weight * data.toItem.count)) then
TriggerEvent("hsn-inventory:onAddInventoryItem",src,data.toItem.name,data.toItem.count)
TriggerEvent("hsn-inventory:onRemoveInventoryItem",src,data.fromItem.name,data.fromItem.count)
playerInventory[Player.identifier][data.toslot] = {name = data.toItem.name ,label = data.toItem.label, weight = data.toItem.weight, slot = data.toslot, count = data.toItem.count, description = data.toItem.description, metadata = data.toItem.metadata, stackable = data.toItem.stackable, closeonuse = ESXItems[data.toItem.name].closeonuse}
Stashs[stashId].inventory[data.fromslot] = {name = data.fromItem.name ,label = data.fromItem.label, weight = data.fromItem.weight, slot = data.fromslot, count = data.fromItem.count, description = data.fromItem.description, metadata = data.fromItem.metadata, stackable = data.fromItem.stackable, closeonuse = ESXItems[data.fromItem.name].closeonuse}
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
elseif data.type == 'freeslot' then
if IfInventoryCanCarry(playerInventory[Player.identifier],ESX.GetConfig().MaxWeight, (data.item.weight * data.item.count)) then
Stashs[stashId].inventory[data.emptyslot] = nil
playerInventory[Player.identifier][data.toslot] = {name = data.item.name ,label = data.item.label, weight = data.item.weight, slot = data.toslot, count = data.item.count, description = data.item.description, metadata = data.item.metadata, stackable = data.item.stackable, closeonuse = ESXItems[data.item.name].closeonuse}
TriggerEvent("hsn-inventory:onAddInventoryItem",src,data.item.name,data.item.count)
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
elseif data.type == 'yarimswap' then
if IfInventoryCanCarry(playerInventory[Player.identifier],ESX.GetConfig().MaxWeight, (data.newslotItem.weight * data.newslotItem.count)) then
Stashs[stashId].inventory[data.fromSlot] = {name = data.oldslotItem.name ,label = data.oldslotItem.label, weight = data.oldslotItem.weight, slot = data.fromSlot, count = data.oldslotItem.count, description = data.oldslotItem.description, metadata = data.oldslotItem.metadata, stackable = data.oldslotItem.stackable, closeonuse = ESXItems[data.oldslotItem.name].closeonuse}
playerInventory[Player.identifier][data.toSlot] = {name = data.newslotItem.name ,label = data.newslotItem.label, weight = data.newslotItem.weight, slot = data.toSlot, count = data.newslotItem.count, description = data.newslotItem.description, metadata = data.newslotItem.metadata, stackable = data.newslotItem.stackable, closeonuse = ESXItems[data.newslotItem.name].closeonuse}
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
end
elseif data.frominv ~= data.toinv and (data.toinv == "Playerinv" and data.frominv == 'shop') then
if data.type == 'swap' then
return TriggerClientEvent("hsn-inventory:notification",src,'You can not return your items',2)
elseif data.type == 'freeslot' then
if IfInventoryCanCarry(playerInventory[Player.identifier],ESX.GetConfig().MaxWeight, (data.item.weight * data.item.count)) then
local money = Player.getMoney()
if (money >= (data.item.price * data.item.count)) then
Player.removeMoney(data.item.price * data.item.count)
TriggerEvent("hsn-inventory:onAddInventoryItem",src,data.item.name,data.item.count)
if data.item.name:find('WEAPON_') then
if not data.item.metadata then data.item.metadata = {} end
data.item.metadata.weaponlicense = GetRandomLicense(data.item.metadata.weaponlicense)
if data.item.metadata.registered == 'setname' then data.item.metadata.registered = Player.getName() end
if not data.item.metadata.components then data.item.metadata.components = {} end
data.item.metadata.ammo = 0
data.item.metadata.durability = 100
elseif data.item.name:find('identification') then
data.item.metadata = {}
data.item.metadata.description = getPlayerIdentification(Player)
end
playerInventory[Player.identifier][data.toslot] = {name = data.item.name ,label = data.item.label, weight = data.item.weight, slot = data.toslot, count = data.item.count, description = data.item.description, metadata = data.item.metadata, stackable = data.item.stackable, closeonuse = ESXItems[data.item.name].closeonuse}
TriggerClientEvent("hsn-inventory:client:refreshInventory",src,playerInventory[Player.identifier])
else
TriggerClientEvent("hsn-inventory:notification",src,'You can not afford this item ('..data.item.price * data.item.count..'$)',2)
TriggerClientEvent("hsn-inventory:client:refreshInventory",src,playerInventory[Player.identifier])
end
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
elseif data.type == 'yarimswap' then
local money = Player.getMoney()
if IfInventoryCanCarry(playerInventory[Player.identifier],ESX.GetConfig().MaxWeight, (data.newslotItem.weight * data.newslotItem.count)) then
if (money >= (data.newslotItem.price * data.newslotItem.count)) then
if data.newslotItem.name:find('WEAPON_') then
if not data.newslotItem.metadata then data.newslotItem.metadata = {} end
if data.newslotItem.metadata.registered == 'setname' then data.newslotItem.metadata.registered = Player.getName() end
data.newslotItem.metadata.weaponlicense = GetRandomLicense(data.newslotItem.metadata.weaponlicense)
if not data.newslotItem.metadata.components then data.newslotItem.metadata.components = {} end
data.newslotItem.metadata.ammo = 0
data.newslotItem.metadata.durability = 100
elseif data.newslotItem.name:find('identification') then
data.newslotItem.metadata = {}
data.newslotItem.metadata.description = getPlayerIdentification(Player)
end
Player.removeMoney(data.newslotItem.price * data.newslotItem.count)
playerInventory[Player.identifier][data.toSlot] = {name = data.newslotItem.name ,label = data.newslotItem.label, weight = data.newslotItem.weight, slot = data.toSlot, count = data.newslotItem.count, description = data.newslotItem.description, metadata = data.newslotItem.metadata, stackable = data.newslotItem.stackable, closeonuse = ESXItems[data.newslotItem.name].closeonuse}
TriggerEvent("hsn-inventory:onAddInventoryItem",src,data.newslotItem.name,data.newslotItem.count)
else
Citizen.Wait(5)
TriggerClientEvent("hsn-inventory:client:refreshInventory",src,playerInventory[Player.identifier])
TriggerClientEvent("hsn-inventory:notification",src,'You can not afford this item ('..data.newslotItem.price * data.newslotItem.count..'$)',2)
end
else
TriggerClientEvent("hsn-inventory:notification",src,"You can not carry this item",2)
end
end
elseif data.frominv ~= data.toinv and (data.toinv == "shop" and data.frominv == 'Playerinv') then
TriggerClientEvent("hsn-inventory:client:refreshInventory",src,playerInventory[Player.identifier])
return TriggerClientEvent("hsn-inventory:notification",src,'You can not return your items',2)
end
-- Sync ESX money with hsn-inventory
local money = exports["hsn-inventory"]:getItemCount(src,'money')
Player.setMoney(money)
local blackmoney = exports["hsn-inventory"]:getItemCount(src,'black_money')
Player.setAccountMoney('black_money', blackmoney)
end
end)
CreateNewDrop = function(source,data)
local src = source
local dropid = RandomDropId()
local Player = ESX.GetPlayerFromId(src)
Drops[dropid] = {}
Drops[dropid].inventory = {}
Drops[dropid].name = dropid
Drops[dropid].slots = 50
if data.type == 'swap' then
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.toItem)
Drops[dropid].inventory[data.toslot] = {name = data.toItem.name ,label = data.toItem.label, weight = data.toItem.weight, slot = data.toslot, count = data.toItem.count, description = data.toItem.description, metadata = data.toItem.metadata, stackable = data.toItem.stackable, closeonuse = ESXItems[data.toItem.name].closeonuse}
playerInventory[Player.identifier][data.fromslot] = {name = data.fromItem.name ,label = data.fromItem.label, weight = data.fromItem.weight, slot = data.fromslot, count = data.fromItem.count, description = data.fromItem.description, metadata = data.fromItem.metadata, stackable = data.fromItem.stackable, closeonuse = ESXItems[data.fromItem.name].closeonuse}
elseif data.type == 'freeslot' then
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.item)
playerInventory[Player.identifier][data.emptyslot] = nil
Drops[dropid].inventory[data.toslot] = {name = data.item.name ,label = data.item.label, weight = data.item.weight, slot = data.toslot, count = data.item.count, description = data.item.description, metadata = data.item.metadata, stackable = data.item.stackable, closeonuse = ESXItems[data.item.name].closeonuse}
TriggerEvent("hsn-inventory:onRemoveInventoryItem",src,data.item.name,data.item.count)
elseif data.type == 'yarimswap' then
TriggerClientEvent("hsn-inventory:client:checkweapon",src,data.newslotItem)
playerInventory[Player.identifier][data.fromSlot] = {name = data.oldslotItem.name ,label = data.oldslotItem.label, weight = data.oldslotItem.weight, slot = data.fromSlot, count = data.oldslotItem.count, description = data.oldslotItem.description, metadata = data.oldslotItem.metadata, stackable = data.oldslotItem.stackable, closeonuse = ESXItems[data.oldslotItem.name].closeonuse}
Drops[dropid].inventory[data.toSlot] = {name = data.newslotItem.name ,label = data.newslotItem.label, weight = data.newslotItem.weight, slot = data.toSlot, count = data.newslotItem.count, description = data.newslotItem.description, metadata = data.newslotItem.metadata, stackable = data.newslotItem.stackable, closeonuse = ESXItems[data.newslotItem.name].closeonuse}
end
local ped = GetPlayerPed(src)
local coords = GetEntityCoords(ped)
TriggerClientEvent("hsn-inventory:Client:addnewDrop", -1, coords, dropid)
end
-- Override the default ESX command (only works on ESX 1.2+ and EXM)
ESX.RegisterCommand({'giveitem', 'additem'}, 'admin', function(xPlayer, args, showError)
args.playerId.addInventoryItem(args.item, args.count)
end, true, {help = 'give an item to a player', validate = true, arguments = {
{name = 'playerId', help = 'player id', type = 'player'},
{name = 'item', help = 'item name', type = 'string'},
{name = 'count', help = 'item count', type = 'number'}
}})
--[[ Use this command instead for ESX 1.1
RegisterCommand("addItem",function(source,args)
if source == 0 then
return
end
local src = source
local Player = ESX.GetPlayerFromId(src)
if Player.getGroup() == "superadmin" or Player.getGroup() == "admin" then
local tPlayerId = tonumber(args[1])
local item = args[2]
local count = tonumber(args[3])
local tPlayer = ESX.GetPlayerFromId(tPlayerId)
if tPlayer == nil then
return
end
tPlayer.addInventoryItem(item, count)
end
end)
]]
RegisterCommand("fixinv", function(source, args, rawCommand)
local Player = ESX.GetPlayerFromId(source)
TriggerClientEvent("hsn-inventory:client:refreshInventory",source,playerInventory[Player.identifier])
end)
RegisterServerEvent("hsn-inventory:server:refreshInventory")
AddEventHandler("hsn-inventory:server:refreshInventory",function()
local Player = ESX.GetPlayerFromId(source)
TriggerClientEvent("hsn-inventory:client:refreshInventory",source,playerInventory[Player.identifier])
end)
RegisterServerEvent("hsn-inventory:server:openInventory")
AddEventHandler("hsn-inventory:server:openInventory",function(data)
local src = source
local Player = ESX.GetPlayerFromId(src)
if data ~= nil then
if data.type == 'drop' then
if Drops[data.id] ~= nil then
if checkOpenable(src,data.id) then
TriggerClientEvent("hsn-inventory:client:openInventory",src,playerInventory[Player.identifier],Drops[data.id])
end
else
TriggerClientEvent("hsn-inventory:client:openInventory",src,playerInventory[Player.identifier])
end
elseif data.type == 'shop' then
Shops[data.id.name] = {}
Shops[data.id.name].inventory = SetupShopItems(data.id)
Shops[data.id.name].name = data.id.name or 'Shop'
Shops[data.id.name].type = 'shop'
Shops[data.id.name].slots = #Shops[data.id.name].inventory + 1
if not data.id.job or data.id.job == Player.job.name then
TriggerClientEvent("hsn-inventory:client:openInventory",src,playerInventory[Player.identifier],Shops[data.id.name])
end
elseif data.type == "glovebox" then
if checkOpenable(src,data.id) then
Gloveboxes[data.id] = {}
Gloveboxes[data.id].inventory = GetItems(data.id)
Gloveboxes[data.id].name = data.id
Gloveboxes[data.id].type = 'glovebox'
Gloveboxes[data.id].slots = 100
TriggerClientEvent("hsn-inventory:client:openInventory",src,playerInventory[Player.identifier],Gloveboxes[data.id])
end
elseif data.type == "trunk" then
if checkOpenable(src,data.id) then
Trunks[data.id] = {}
Trunks[data.id].inventory = GetItems(data.id)
Trunks[data.id].name = data.id
Trunks[data.id].type = 'trunk'
Trunks[data.id].slots = 100
TriggerClientEvent("hsn-inventory:client:openInventory",src,playerInventory[Player.identifier],Trunks[data.id])
end
end
else
TriggerClientEvent("hsn-inventory:client:openInventory",src,playerInventory[Player.identifier])
end
end)
RegisterServerEvent("hsn-inventory:server:openStash")
AddEventHandler("hsn-inventory:server:openStash",function(stash)
local src = source
local Player = ESX.GetPlayerFromId(src)
if Stashs[stash.id.name] == nil then
Stashs[stash.id.name] = {}
Stashs[stash.id.name].inventory = GetItems(stash.id.name)
Stashs[stash.id.name].name = stash.id.name
Stashs[stash.id.name].type = 'stash'
Stashs[stash.id.name].slots = stash.slots
end
if checkOpenable(src,stash.id.name,stash.id.coords) then
if not stash.id.job or stash.id.job == Player.job.name then
TriggerClientEvent("hsn-inventory:client:openInventory",src,playerInventory[Player.identifier], Stashs[stash.id.name])
end
else
TriggerClientEvent("hsn-inventory:notification",src,'You can not open this inventory',2)
end
end)
RegisterServerEvent("hsn-inventory:server:openTargetInventory")
AddEventHandler("hsn-inventory:server:openTargetInventory",function(TargetId)
local Player = ESX.GetPlayerFromId(source)
tPlayer = ESX.GetPlayerFromId(TargetId)
if source == TargetId then tPlayer = nil end -- Don't allow source and targetid to match
if playerInventory[tPlayer.identifier] == nil then
playerInventory[tPlayer.identifier] = {}
end
if tPlayer and Player then
if checkOpenable(source,'Player'..TargetId,GetEntityCoords(GetPlayerPed(TargetId))) then
local data = {}
data.name = 'Player'..TargetId -- do not touch
data.type = "TargetPlayer"
data.slots = Config.PlayerSlot
data.inventory = playerInventory[tPlayer.identifier]
TriggerClientEvent("hsn-inventory:client:openInventory",source,playerInventory[Player.identifier], data)
end
end
end)
RegisterServerEvent("hsn-inventory:server:saveInventory")
AddEventHandler("hsn-inventory:server:saveInventory",function(data)
SaveItems(data.type,data.invid)
end)
checkOpenable = function(source,id,coords)
local src = source
local returnData = false
if coords then
local srcCoords = GetEntityCoords(GetPlayerPed(src))
if #(coords - srcCoords) > 5 then return false end
end
if openedinventories[id] == nil then
openedinventories[id] = {}
openedinventories[id].opened = true
openedinventories[id].owner = src
returnData = true
end
return returnData
end
SetupShopItems = function(shopid)
local inventory = {}
for k,v in pairs(shopid.inventory) do
if ESXItems[v.name] ~= nil then
inventory[k] = {name = v.name ,label = ESXItems[v.name].label, weight = ESXItems[v.name].weight, slot = k, count = v.count, description = ESXItems[v.name].description, metadata = v.metadata or {}, stackable = ESXItems[v.name].stackable,price = v.price}
else
print("^1[hsn-inventory]^1 Item Not Found Check config.lua/Config.Shops and your items table^7")
end
end
return inventory
end
GetItems = function(id)
local returnData = {}
local result = exports.ghmattimysql:executeSync('SELECT data FROM hsn_inventory WHERE name = @name', {
['@name'] = id
})
if result[1] ~= nil then
if result[1].data ~= nil then
local Inventory = json.decode(result[1].data)
for k,v in pairs(Inventory) do
returnData[v.slot] = {name = v.name ,label = ESXItems[v.name].label, weight = ESXItems[v.name].weight, slot = v.slot, count = v.count, description = ESXItems[v.name].description, metadata = v.metadata or {}, stackable = ESXItems[v.name].stackable}
end
end
end
return returnData
end
GetInventory = function(inventory)
local returnData = {}
for k,v in pairs(inventory) do
returnData[k] = {
name = v.name,
count = v.count,
metadata = v.metadata,
slot = k
}
end
return returnData
end
SaveItems = function(type,id)
if type == "stash" then
local result = exports.ghmattimysql:executeSync('SELECT data FROM hsn_inventory WHERE name = @name', {
['@name'] = id
})
if result[1] == nil then
local inventory = GetInventory(Stashs[id].inventory)
exports.ghmattimysql:execute('INSERT INTO hsn_inventory (name, data) VALUES (@name, @data)', {
['@name'] = id,
['@data'] = json.encode(inventory)
})
else
local inventory = GetInventory(Stashs[id].inventory)
exports.ghmattimysql:execute('UPDATE hsn_inventory SET data = @data WHERE name = @name', {
['@data'] = json.encode(inventory),
['@name'] = id
})
end
elseif type == "glovebox" then
local result = exports.ghmattimysql:executeSync('SELECT data FROM hsn_inventory WHERE name = @name', {
['@name'] = id
})
if result[1] == nil then
local inventory = GetInventory(Gloveboxes[id].inventory)
exports.ghmattimysql:execute('INSERT INTO hsn_inventory (name, data) VALUES (@name, @data)', {
['@name'] = id,
['@data'] = json.encode(inventory)
})
else
local inventory = GetInventory(Gloveboxes[id].inventory)
exports.ghmattimysql:execute('UPDATE hsn_inventory SET data = @data WHERE name = @name', {
['@data'] = json.encode(inventory),
['@name'] = id
})
end
elseif type == "trunk" then
local result = exports.ghmattimysql:executeSync('SELECT data FROM hsn_inventory WHERE name = @name', {
['@name'] = id
})
if result[1] == nil then
local inventory = GetInventory(Trunks[id].inventory)
exports.ghmattimysql:execute('INSERT INTO hsn_inventory (name, data) VALUES (@name, @data)', {
['@name'] = id,
['@data'] = json.encode(inventory)
})
else
local inventory = GetInventory(Trunks[id].inventory)
exports.ghmattimysql:execute('UPDATE hsn_inventory SET data = @data WHERE name = @name', {
['@data'] = json.encode(inventory),
['@name'] = id
})
end
end
end
RegisterServerEvent("hsn-inventory:setcurrentInventory")
AddEventHandler("hsn-inventory:setcurrentInventory",function(other)
local src = source
if other ~= nil then
invopened[src] = {
curInventory = other.name,
type = other.type,
invopened = true
}
end
end)
RegisterServerEvent("hsn-inventory:removecurrentInventory")
AddEventHandler("hsn-inventory:removecurrentInventory",function(name)
local src = source
if invopened[src] ~= nil then
invopened[src] = nil
end
if openedinventories[name] ~= nil then
openedinventories[name] = nil
end
end)
AddEventHandler('playerDropped', function(reason) -- https://github.com/CylexVII <3
local src = source
if invopened[src] ~= nil then
if invopened[src].curInventory ~= nil and invopened[src].invopened then
SaveItems(invopened[src].type,invopened[src].curInventory)
invopened[src] = nil
print("^1[hsn-inventory]^1 One player left the game when his inventory open and inventory saved ^1[DUPE Alert]^1 ")
end
end
for k,v in pairs(openedinventories) do
if openedinventories[k].owner == src then
openedinventories[k] = nil -- :)
break
end
end
end)
RegisterNetEvent("hsn-inventory:onAddInventoryItem")
AddEventHandler("hsn-inventory:onAddInventoryItem",function(source,item,count)
TriggerClientEvent("hsn-inventory:client:addItemNotify",source,ESXItems[item],'Added '..count..'x')
end)
RegisterNetEvent("hsn-inventory:onRemoveInventoryItem")
AddEventHandler("hsn-inventory:onRemoveInventoryItem",function(source,item,count)
TriggerClientEvent("hsn-inventory:client:addItemNotify",source,ESXItems[item],'Removed '..count..'x')
end)
RegisterServerEvent("hsn-inventory:server:useItem")
AddEventHandler("hsn-inventory:server:useItem",function(item,slot)
local src = source
local Player = ESX.GetPlayerFromId(src)
if playerInventory[Player.identifier][item.slot] ~= nil and playerInventory[Player.identifier][item.slot].name ~= nil then
if item.name:find("WEAPON_") then
if item.metadata.durability ~= nil then
if item.metadata.durability > 0 then
TriggerClientEvent("hsn-inventory:client:weapon",src,item)
else
TriggerClientEvent("hsn-inventory:notification",src,'This weapon is broken',2)
end
end
else
if item.name:find("hsn") then
local weps = Config.Ammos[item.name]
TriggerClientEvent("hsn-inventory:addAmmo",src,weps,item.name)
return
end
Player.useItem(item)
end
end
end)
RegisterServerEvent("hsn-inventory:server:useItemfromSlot")
AddEventHandler("hsn-inventory:server:useItemfromSlot",function(slot)
local src = source
local Player = ESX.GetPlayerFromId(src)
if playerInventory[Player.identifier] ~= nil then
if playerInventory[Player.identifier][slot] == nil then
return
end
if playerInventory[Player.identifier][slot] ~= nil and playerInventory[Player.identifier][slot].name ~= nil then
if playerInventory[Player.identifier][slot].name:find("WEAPON_") then
if playerInventory[Player.identifier][slot].metadata.durability > 0 then
TriggerClientEvent("hsn-inventory:client:weapon",src,playerInventory[Player.identifier][slot])
--TriggerClientEvent("hsn-inventory:client:addItemNotify",source,ESXItems[playerInventory[Player.identifier][slot].name],1,'use')
else
TriggerClientEvent("hsn-inventory:notification",src,'This weapon is broken',2)
end
else
if playerInventory[Player.identifier][slot].name:find("hsn") then
local weps = Config.Ammos[playerInventory[Player.identifier][slot].name]
TriggerClientEvent("hsn-inventory:addAmmo",src,weps,playerInventory[Player.identifier][slot].name)
return
end
Player.useItem(playerInventory[Player.identifier][slot])
--TriggerClientEvent("hsn-inventory:client:addItemNotify",source,ESXItems[playerInventory[Player.identifier][slot].name],'Used 1x')
end
end
end
end)
RegisterServerEvent("hsn-inventory:server:decreasedurability")
AddEventHandler("hsn-inventory:server:decreasedurability",function(slot, amount)
local src = source
local Player = ESX.GetPlayerFromId(src)
local decreaseamount = 0
if type(slot) == "number" then
if playerInventory[Player.identifier][slot] ~= nil then
if playerInventory[Player.identifier][slot].metadata.durability ~= nil then
if playerInventory[Player.identifier][slot].metadata.durability <= 0 then
TriggerClientEvent("hsn-inventory:client:checkweapon",src,playerInventory[Player.identifier][slot])
TriggerClientEvent("hsn-inventory:notification",src,'This weapon is broken',2)
return
end
if Config.DurabilityDecreaseAmount[playerInventory[Player.identifier][slot].name] == nil and not amount then
decreaseamount = 0.5
elseif Config.DurabilityDecreaseAmount[playerInventory[Player.identifier][slot].name] then
decreaseamount = Config.DurabilityDecreaseAmount[playerInventory[Player.identifier][slot].name]
else
decreaseamount = amount
end
playerInventory[Player.identifier][slot].metadata.durability = playerInventory[Player.identifier][slot].metadata.durability - decreaseamount
if playerInventory[Player.identifier][slot].metadata.durability == 0 then
TriggerServerEvent('hsn-inventory:server:removeItem', src, data.item, 1)
end
end
if playerInventory[Player.identifier][slot].metadata.ammo ~= nil then
playerInventory[Player.identifier][slot].metadata.ammo = playerInventory[Player.identifier][slot].metadata.ammo - 1
end
end
end
end)
RegisterServerEvent("hsn-inventory:server:addweaponAmmo")
AddEventHandler("hsn-inventory:server:addweaponAmmo",function(slot,count)
local src = source
local Player = ESX.GetPlayerFromId(src)
if playerInventory[Player.identifier][slot] ~= nil then
if playerInventory[Player.identifier][slot].metadata.ammo ~= nil then
playerInventory[Player.identifier][slot].metadata.ammo = playerInventory[Player.identifier][slot].metadata.ammo + count
end
end
end)
RegisterServerEvent("hsn-inventory:server:removeItem")
AddEventHandler("hsn-inventory:server:removeItem",function(source, item, count)
if count == 0 then return end
local src = source
local Player = ESX.GetPlayerFromId(src)
if item == nil then
return
end
if count == nil then
count = 1
end
TriggerClientEvent("hsn-inventory:client:addItemNotify",src,ESXItems[item],'Removed '..count..'x')
RemovePlayerInventory(Player.identifier,item,count)
end)
RegisterServerEvent("hsn-inventory:server:addItem")
AddEventHandler("hsn-inventory:server:addItem",function(src, item, count)
local Player = ESX.GetPlayerFromId(src)
if item == nil then
return
end
if count == nil then
count = 1
end
if playerInventory[Player.identifier] == nil then
playerInventory[Player.identifier] = {}
end
AddPlayerInventory(Player.identifier, item, count)
TriggerClientEvent("hsn-inventory:client:addItemNotify",src,ESXItems[item],'Added '..count..'x')
end)
RegisterServerEvent("hsn-inventory:client:removeItem")
AddEventHandler("hsn-inventory:client:removeItem",function(item, count)
local src = source
local Player = ESX.GetPlayerFromId(src)
Player.removeInventoryItem(item, count)
end)
RegisterServerEvent("hsn-inventory:client:addItem")
AddEventHandler("hsn-inventory:client:addItem",function(item, count)
local src = source
local Player = ESX.GetPlayerFromId(src)
if item == nil then
return
end
if count == nil then
count = 1
end
if playerInventory[Player.identifier] == nil then
playerInventory[Player.identifier] = {}
end
AddPlayerInventory(Player.identifier, item, count)
TriggerClientEvent("hsn-inventory:client:addItemNotify",src,ESXItems[item],'Added '..count..'x')
end)
exports("removeItem", function(src, item, count)
local Player = ESX.GetPlayerFromId(src)
if item == nil then
return
end
if count == nil then
count = 1
end
RemovePlayerInventory(Player.identifier,item,count)
TriggerClientEvent("hsn-inventory:client:addItemNotify",src,ESXItems[item],'Removed '..count..'x')
end)
exports("addItem", function(src, item, count, metadata)
local Player = ESX.GetPlayerFromId(src)
if item == nil then
return
end
if count == nil then
count = 1
end
if playerInventory[Player.identifier] == nil then
playerInventory[Player.identifier] = {}
end
AddPlayerInventory(Player.identifier, item, count, nil, metadata)
TriggerClientEvent("hsn-inventory:client:addItemNotify",src,ESXItems[item],'Added '..count..'x')
end)
exports("getItemCount",function(src, item)
local Player = ESX.GetPlayerFromId(src)
if playerInventory[Player.identifier] == nil then
return
end
local ItemCount = GetItemCount(Player.identifier, item)
return ItemCount
end)
exports("getItem",function(src, item)
local Player = ESX.GetPlayerFromId(src)
if playerInventory[Player.identifier] == nil then
return
end
local ESXItem = ESXItems[item]
ESXItem.count = GetItemCount(Player.identifier, item)
return ESXItem
end)
exports('useItem', function(src, item)
if Config.ItemList[item.name] then
if not next(Config.ItemList[item.name]) then return end
TriggerClientEvent('hsn-inventory:useItem', src, item)
elseif ESX.UsableItemsCallbacks[item.name] ~= nil then
TriggerEvent("esx:useItem", src, item.name)
end
end)
--[[ Example to retrieve items and count from player inventory
RegisterCommand("getitems", function(source, args, rawCommand)
local Player = ESX.GetPlayerFromId(source)
for k, v in pairs(ESXItems) do
v.count = GetItemCount(Player.identifier, v.name)
if v.count > 0 then print(v.name.. ' ' ..v.count) end
end
end)]]
RegisterNetEvent("hsn-inventory:server:getItemCount")
AddEventHandler("hsn-inventory:server:getItemCount",function(source,cb,item)
local src = source
local Player = ESX.GetPlayerFromId(src)
if playerInventory[Player.identifier] == nil then
return
end
local ItemCount = GetItemCount(Player.identifier, item)
if cb then
cb(tonumber(ItemCount))
end
end)
ESX.RegisterServerCallback("hsn-inventory:getItemCount",function(source, cb, item)
local src = source
local Player = ESX.GetPlayerFromId(src)
if playerInventory[Player.identifier] == nil then
return
end
local ItemCount = GetItemCount(Player.identifier, item)
cb(tonumber(ItemCount))
end)
ESX.RegisterServerCallback("hsn-inventory:getItem",function(source, cb, item)
local src = source
local Player = ESX.GetPlayerFromId(src)
if playerInventory[Player.identifier] == nil then
return
end
local ESXItem = ESXItems[item]
ESXItem.count = GetItemCount(Player.identifier, item)
cb(ESXItem)
end)
ESX.RegisterServerCallback("hsn-inventory:getPlayerInventory",function(source,cb,playerId)
local TargetPlayer = ESX.GetPlayerFromId(playerId)
if playerInventory[TargetPlayer.identifier] == nil then
playerInventory[TargetPlayer.identifier] = {}
end
cb(playerInventory[TargetPlayer.identifier])
end)
-- ESX.RegisterServerCallback("hsn-inventory:server:gethottbarItems",function(source,cb)
-- local src = source
-- local Player = ESX.GetPlayerFromId(src)
-- if playerInventory[Player.identifier] == nil then
-- playerInventory[Player.identifier] = {}
-- end
-- local cbData = {
-- [1] = playerInventory[Player.identifier][1],
-- [2] = playerInventory[Player.identifier][2],
-- [3] = playerInventory[Player.identifier][3],
-- [4] = playerInventory[Player.identifier][4],
-- [5] = playerInventory[Player.identifier][5]
-- }
-- cb(cbData)
-- end)
RegisterNetEvent("hsn-inventory:getplayerInventory")
AddEventHandler("hsn-inventory:getplayerInventory",function(cb,identifier)
if playerInventory[identifier] == nil then
playerInventory[identifier] = {}
end
if cb then
cb(GetInventory(playerInventory[identifier]))
end
end)
RegisterNetEvent("hsn-inventory:setplayerInventory")
AddEventHandler("hsn-inventory:setplayerInventory",function(identifier,inventory)
playerInventory[identifier] = {}
local returnData = {}
for k,v in pairs (inventory) do
playerInventory[identifier][v.slot] = {name = v.name ,label = ESXItems[v.name].label, weight = ESXItems[v.name].weight, slot = v.slot, count = v.count, description = ESXItems[v.name].description, metadata = v.metadata or {}, stackable = ESXItems[v.name].stackable}
end
end)
AddEventHandler('onResourceStop', function(resourceName)
if (GetCurrentResourceName() == resourceName) then
local Players = ESX.GetPlayers()
for k,v in pairs(Players) do
local Player = ESX.GetPlayerFromId(v)
local inventory = {}
inventory = json.encode(GetInventory(playerInventory[Player.identifier]))
exports.ghmattimysql:execute('UPDATE users SET inventory = @inventory WHERE identifier = @identifier', {
['@inventory'] = inventory,
['@identifier'] = Player.identifier
})
end
end
end)
AddEventHandler('onResourceStart', function(resourceName)
if (GetCurrentResourceName() == resourceName) then
Citizen.Wait(100)
local Players = ESX.GetPlayers()
for k,v in pairs(Players) do
local Player = ESX.GetPlayerFromId(v)
playerInventory[Player.identifier] = {}
exports.ghmattimysql:ready(function()
exports.ghmattimysql:execute('SELECT inventory FROM users WHERE identifier = @identifier', {
['@identifier'] = Player.identifier
}, function(result)
local inventory = {}
if result[1].inventory and result[1].inventory ~= '' then
inventory = json.decode(result[1].inventory)
end
TriggerEvent('hsn-inventory:setplayerInventory', Player.identifier, inventory)
end)
end)
end
end
end)
function getPlayerIdentification(xPlayer)
return ('Name: %s | Sex: %s | Height: %s<br>DOB: %s (%s)'):format( xPlayer.getName(), xPlayer.get('sex'), xPlayer.get('height'), xPlayer.get('dateofbirth'), xPlayer.getIdentifier() )
end
|
return Def.ActorFrame{
Def.Quad{
InitCommand=cmd(setsize,SCREEN_WIDTH,SCREEN_HEIGHT/2;diffuse,color("0,0,0,1");xy,SCREEN_CENTER_X,SCREEN_CENTER_Y;valign,1);
OnCommand=cmd(y,SCREEN_CENTER_Y;linear,0.3;y,SCREEN_CENTER_Y-SCREEN_HEIGHT/2);
};
Def.Quad{
InitCommand=cmd(setsize,SCREEN_WIDTH,SCREEN_HEIGHT/2;diffuse,color("0,0,0,1");xy,SCREEN_CENTER_X,SCREEN_CENTER_Y;valign,0);
OnCommand=cmd(y,SCREEN_CENTER_Y;linear,0.3;y,SCREEN_CENTER_Y+SCREEN_HEIGHT/2);
};
};
|
local M = {}
M.file_browser = function()
local cwd = require('telescope.utils').buffer_dir()
-- https://github.com/nvim-telescope/telescope-file-browser.nvim#mappings
require('telescope').extensions.file_browser.file_browser({
cwd = cwd,
follow = true,
hidden = true,
no_ignore = true,
})
end
M.find_files = function()
require('telescope.builtin').find_files({
follow = true,
hidden = true,
})
end
M.setup = function()
local telescope = require('telescope')
local themes = require('telescope.themes')
local actions = require('telescope.actions')
local fb_actions = require('telescope').extensions.file_browser.actions
telescope.setup({
['ui-select'] = {
themes.get_dropdown(),
},
defaults = {
-- path_display = { truncate = 3 },
file_ignore_patterns = { '.git/' },
-- https://github.com/nvim-telescope/telescope.nvim/blob/master/lua/telescope/mappings.lua#L9
-- https://github.com/nvim-telescope/telescope.nvim#default-mappings
mappings = {
i = {
['<C-n>'] = actions.cycle_history_next,
['<C-p>'] = actions.cycle_history_prev,
['<C-c>'] = actions.close,
['<c-x>'] = actions.delete_buffer,
},
n = {
['q'] = actions.close,
['x'] = actions.delete_buffer,
['d'] = fb_actions.remove,
},
},
},
pickers = {
buffers = {
path_display = { truncate = 3 },
},
find_files = {
path_display = { truncate = 3 },
},
file_browser = {
path_display = { truncate = 3 },
},
},
})
telescope.load_extension('fzf')
telescope.load_extension('file_browser')
telescope.load_extension('gh')
telescope.load_extension('harpoon')
telescope.load_extension('git_worktree')
telescope.load_extension('ui-select')
-- mappings
vim.cmd([[
:nnoremap <Leader>fb :lua require('telescope.builtin').buffers{}<CR>
:nnoremap <Leader>fe :lua require('plugins.telescope').file_browser{}<CR>
:nnoremap <Leader>ff :lua require('plugins.telescope').find_files{}<CR>
:nnoremap <Leader>fg :lua require('telescope.builtin').live_grep{}<CR>
:vnoremap <leader>fs "zy:Telescope grep_string search=<C-r>z<CR>
:nnoremap <Leader>fs :lua require('telescope.builtin').grep_string{}<CR>
:nnoremap <Leader>fc :lua require('telescope.builtin').command_history{}<CR>
:nnoremap <Leader>fh :lua require('telescope.builtin').search_history{}<CR>
:nnoremap <Leader>fo :lua require('telescope.builtin').oldfiles{}<CR>
:nnoremap <Leader>fr :Telescope resume<CR>
:nnoremap <leader>f/ :lua require("telescope").extensions.live_grep_raw.live_grep_raw()<CR>
:nnoremap <leader>wt :lua require("telescope").extensions.git_worktree.git_worktrees()<CR>
:nnoremap <leader>cw :lua require("telescope").extensions.git_worktree.create_git_worktree()<CR>
]])
end
return M
|
---- -*- Mode: Lua; -*-
----
----
----
---- © Copyright IBM Corporation 2016.
---- LICENSE: MIT License (https://opensource.org/licenses/mit-license.html)
---- AUTHOR: Jamie A. Jennings
function luac(name)
local luac_bin = ROSIE_HOME .. "/bin/luac"
return os.execute(luac_bin .. " -o bin/" .. name .. ".luac src/" .. name .. ".lua")
end
function compile_system()
luac("api")
luac("bootstrap")
luac("color-output")
luac("common")
luac("compile")
luac("engine")
luac("eval")
luac("grep")
luac("lapi")
luac("list")
luac("manifest")
luac("parse")
luac("recordtype")
luac("repl")
luac("syntax")
luac("util")
end
compile_system()
|
function characterExist(cid)
if not cid then return false end
local exist = MySQL.scalar.await([[
SELECT id
FROM characters
WHERE id = ?
]],
{ cid })
if not exist then return false end
return true
end
function getCharacter(cid, info)
if not cid then return 0 end
local info = MySQL.scalar.await([[
SELECT ??
FROM characters
WHERE id = ?
]],
{ info, cid })
if not info then return 0 end
return info
end
|
return
function()
local Person = {
new = function(self)
local o = {}
setmetatable(o, self)
o.addedToPop = false
o.age = 0
o.ancName = ""
o.ancRoyal = false
o.birth = 0
o.birthplace = ""
o.cbelief = 0
o.children = {}
o.cIndex = 0
o.city = nil
o.death = 0
o.deathplace = ""
o.def = true -- A utility variable used to set whether this person has been destroyed.
o.descRoyal = false
o.descWrite = 0
o.ebelief = 0
o.ethnicity = {}
o.famc = ""
o.fams = {}
o.father = nil
o.frugality = math.random(5, 85)/100
o.gender = ""
o.gIndex = 0
o.gString = ""
o.income = 0
o.isRuler = false
o.LastRoyalAncestor = ""
o.level = 2
o.lines = {}
o.maternalLineTimes = math.huge
o.military = false
o.militaryTraining = 0
o.mother = nil
o.name = ""
o.nationality = ""
o.nativeLang = {}
o.number = 0
o.parentRuler = false
o.party = ""
o.pbelief = 0
o.pIndex = 0
o.prevtitle = "Citizen"
o.recentbirth = false
o.region = nil
o.royalGenerations = math.huge
o.royalSystem = ""
o.ruledCountry = ""
o.rulerName = ""
o.rulerTitle = ""
o.spokenLang = {}
o.spouse = nil
o.surname = ""
o.title = "Citizen"
o.wealth = 0
return o
end,
destroy = function(self, parent, nl)
self.age = nil
self.cbelief = nil
local chilCount = 0
for i, j in pairs(self.children) do if j and j.def then chilCount = chilCount+1 end end
for i, j in pairs(self.children) do if j and j.def then j.wealth = j.wealth+(self.wealth/chilCount) end end
chilCount = nil
self.children = nil
if not self.deathplace or self.deathplace == "" then
self.deathplace = nl.name
if self.region and self.region.cities then self.deathplace = self.region.name..", "..self.deathplace end
if self.city then self.deathplace = self.city.name..", "..self.deathplace end
end
for i, j in pairs(self.lines) do if parent.final[j] and parent.final[j].locIndices[self.gString] then
if parent.final[j].lineOfSuccession[parent.final[j].locIndices[self.gString]] and parent.final[j].lineOfSuccession[parent.final[j].locIndices[self.gString]].gString == self.gString then parent.final[j]:successionRemove(parent, self) end
parent.final[j].locIndices[self.gString] = nil
end end
self.city = nil
self.death = parent.years
if not parent.places[self.deathplace] then
parent.places[self.deathplace] = self.gIndex
parent.gedFile:write("y "..tostring(self.gIndex).." "..tostring(self.deathplace).."\n")
end
parent.gedFile:write(tostring(self.gIndex).." d "..tostring(self.death).."\n")
parent.gedFile:write("e "..tostring(parent.places[self.deathplace]).."\n")
parent.gedFile:write("w "..tostring(math.floor(self.wealth*1000)).."\n")
parent.gedFile:flush()
self.city = nil
self.def = nil -- See above.
self.ebelief = nil
parent:deepnil(self.ethnicity)
self.father = nil
self.frugality = nil
self.income = nil
self.isRuler = nil
self.level = nil
self.lines = nil
self.military = nil
self.militaryTraining = nil
self.mother = nil
self.nationality = nil
self.parentRuler = nil
self.party = nil
self.pbelief = nil
self.prevtitle = nil
self.recentbirth = nil
self.region = nil
self.royalSystem = nil
self.ruledCountry = nil
if self.spouse and self.spouse.def then self.spouse.spouse = nil end
self.spouse = nil
self.title = nil
self.wealth = nil
end,
dobirth = function(self, parent, nl)
local t0 = _time()
if not self.spouse or not self.spouse.def then return nil end
if self.age < 15 or self.age > (self.gender == "M" and 65 or 55) then return nil end
if self.spouse.age < 15 or self.spouse.age > (self.spouse.gender == "M" and 65 or 55) then return nil end
local nn = Person:new()
local nFound = true
while nFound do
nn:makename(parent, nl)
nFound = false
for i, j in pairs(self.children) do if j.name == nn.name then nFound = true end end
for i, j in pairs(self.spouse.children) do if j.name == nn.name then nFound = true end end
end
if self.gender == "M" then
nn.surname = self.surname
nn.ancName = self.ancName
self.region = self.spouse.region or self.region
self.city = self.spouse.city or self.city
self.spouse.region = self.region or self.spouse.region
self.spouse.city = self.city or self.spouse.city
nn.region = self.region
nn.city = self.city
else
nn.surname = self.spouse.surname
nn.ancName = self.spouse.ancName
self.spouse.region = self.region or self.spouse.region
self.spouse.city = self.city or self.spouse.city
self.region = self.spouse.region or self.region
self.city = self.spouse.city or self.city
nn.region = self.spouse.region
nn.city = self.spouse.city
end
if self.royalGenerations < 8 and self.spouse.royalGenerations < 8 and self.surname ~= self.spouse.surname then
local surnames = {}
if self.royalGenerations < self.spouse.royalGenerations then surnames = {self.surname:gmatch("%a+")(), self.spouse.surname:gmatch("%a+")()}
elseif self.royalGenerations > self.spouse.royalGenerations then surnames = {self.spouse.surname:gmatch("%a+")(), self.surname:gmatch("%a+")()}
else
if self.gender == "M" then surnames = {self.surname:gmatch("%a+")(), self.spouse.surname:gmatch("%a+")()}
else surnames = {self.spouse.surname:gmatch("%a+")(), self.surname:gmatch("%a+")()} end
end
if surnames[1] ~= surnames[2] and self.ancName ~= self.spouse.ancName then nn.surname = surnames[1].."-"..surnames[2] else nn.surname = surnames[1] end
end
local modChance = math.random(1, 50000)
if modChance > 1024 and modChance < 1206 then
local op = parent:randomChoice{Language.consonants, Language.vowels}
local o1, o2 = -1, -1
while o1 == o2 do
o1 = parent:randomChoice(op, true)
o2 = parent:randomChoice(op, true)
end
local segments = {}
for x in nn.surname:gmatch("%a+") do table.insert(segments, parent:namecheck(x:gsub(op[o1], op[o2], 1))) end
nn.surname = ""
for x=1,#segments-1 do nn.surname = nn.surname..segments[x].."-" end
nn.surname = string.stripDiphs(nn.surname..segments[#segments])
end
if self.royalGenerations < math.huge or self.spouse.royalGenerations < math.huge then
if self.spouse.royalGenerations < self.royalGenerations then
nn.royalGenerations = self.spouse.royalGenerations+1
nn.royalSystem = self.spouse.royalSystem
nn.LastRoyalAncestor = self.spouse.LastRoyalAncestor
if self.spouse.gender == "F" then nn.maternalLineTimes = self.spouse.maternalLineTimes+1 end
else
nn.royalGenerations = self.royalGenerations+1
nn.royalSystem = self.royalSystem
nn.LastRoyalAncestor = self.LastRoyalAncestor
if self.gender == "F" then nn.maternalLineTimes = self.maternalLineTimes+1 end
end
end
if self.royalGenerations == 0 then
if self.gender == "M" then nn.maternalLineTimes = 0 end
nn.royalGenerations = 1
nn.royalSystem = self.royalSystem
nn.LastRoyalAncestor = self.rulerTitle.." "..self.rulerName.." "..parent:roman(self.number).." of "..self.ruledCountry
elseif self.spouse.royalGenerations == 0 then
if self.gender == "F" then nn.maternalLineTimes = 0 end
nn.royalGenerations = 1
nn.royalSystem = self.spouse.royalSystem
nn.LastRoyalAncestor = self.spouse.rulerTitle.." "..self.spouse.rulerName.." "..parent:roman(self.spouse.number).." of "..self.spouse.ruledCountry
end
local sys = parent.systems[nl.system]
if nn.gender == "M" or not sys.dynastic then nn.title = sys.ranks[nn.level] else nn.title = sys.franks[nn.level] end
for i, j in pairs(self.ethnicity) do nn.ethnicity[i] = j end
for i, j in pairs(self.spouse.ethnicity) do
if not nn.ethnicity[i] then nn.ethnicity[i] = 0 end
nn.ethnicity[i] = nn.ethnicity[i]+j
end
for i, j in pairs(nn.ethnicity) do nn.ethnicity[i] = nn.ethnicity[i]/2 end
nn.birthplace = nl.name
if nn.region then nn.birthplace = nn.region.name..", "..nn.birthplace end
if nn.city then nn.birthplace = nn.city.name..", "..nn.birthplace end
nn.age = 0
nn.gString = nn.gender.." "..nn.name.." "..nn.surname.." "..nn.birth.." "..nn.birthplace
nn.nationality = nl.name
nn.gIndex = parent:nextGIndex()
if self.gender == "F" then nn:SetFamily(self.spouse, self, nl, parent)
else nn:SetFamily(self, self.spouse, nl, parent) end
nl:add(parent, nn)
if self.isRuler or self.spouse.isRuler then
nn.level = self.level-1
nn.parentRuler = true
elseif self.level > self.spouse.level then nn.level = self.level else nn.level = self.spouse.level end
for i, j in pairs(self.lines) do if parent.final[j] and parent.final[j].locIndices[self.gString] then
if self.spouse.lines[i] and parent.final[j].locIndices[self.spouse.gString] and parent.final[j].locIndices[self.spouse.gString] < parent.final[j].locIndices[self.gString] then parent.final[j]:recurseRoyalChildren(self.spouse)
else parent.final[j]:recurseRoyalChildren(self) end
end end
if not parent.places[nn.birthplace] then
parent.places[nn.birthplace] = nn.gIndex
parent.gedFile:write("y "..tostring(nn.gIndex).." "..tostring(nn.birthplace).."\n")
end
parent.gedFile:write(tostring(nn.gIndex).." b "..tostring(parent.years).."\n")
parent.gedFile:write("c "..tostring(parent.places[nn.birthplace]).."\n")
parent.gedFile:write("g "..tostring(nn.gender).."\n")
parent.gedFile:write("n "..tostring(nn.name).."\n")
parent.gedFile:write("s "..tostring(nn.surname).."\n")
for i, j in pairs(nn.ethnicity) do
if not parent.demonyms[i] then
parent.demonyms[i] = nn.gIndex
parent.gedFile:write("z "..tostring(nn.gIndex).." "..tostring(i).."\n")
end
if j > 0.08 then
local pct = string.format("%.2f", j)
for k=1,3 do if pct:sub(pct:len(), pct:len()) == "0" or pct:sub(pct:len(), pct:len()) == "." then pct = pct:sub(1, pct:len()-1) end end
parent.gedFile:write("l "..pct.."% "..tostring(parent.demonyms[i]).."\n")
end
end
parent.gedFile:flush()
if _DEBUG then
if not debugTimes["Person.dobirth"] then debugTimes["Person.dobirth"] = 0 end
debugTimes["Person.dobirth"] = debugTimes["Person.dobirth"]+_time()-t0
end
end,
makename = function(self, parent, nl)
local t0 = _time()
self.name = parent:name(true)
self.surname = parent:name(true)
if math.random(1, 1000) < 501 then self.gender = "M" else self.gender = "F" end
self.pbelief = math.random(1, 100)
self.ebelief = math.random(1, 100)
self.cbelief = math.random(1, 100)
self.birth = parent.years
if self.title == "" then
self.level = 2
self.title = "Citizen"
end
if _DEBUG then
if not debugTimes["Person.makename"] then debugTimes["Person.makename"] = 0 end
debugTimes["Person.makename"] = debugTimes["Person.makename"]+_time()-t0
end
end,
SetFamily = function(self, father, mother, nl, parent)
table.insert(father.children, self)
table.insert(mother.children, self)
self.father = father
self.mother = mother
parent.gedFile:write(tostring(self.gIndex).." m "..tostring(mother.gIndex).."\n")
parent.gedFile:write("f "..tostring(father.gIndex).."\n")
parent.gedFile:flush()
local natLang = {}
local spokeLang = {}
local natLangs = 0
local spokeLangs = 0
if father.nativeLang then for i=1,#father.nativeLang do if father.nativeLang[i] and not natLang[father.nativeLang[i].name] then natLangs = natLangs+1 natLang[father.nativeLang[i].name] = parent:getLanguage(father.nativeLang[i], nl, true) end end end
if father.spokenLang then for i=1,#father.spokenLang do if father.spokenLang[i] and not spokeLang[father.spokenLang[i].name] then spokeLangs = spokeLangs+1 spokeLang[father.spokenLang[i].name] = parent:getLanguage(father.spokenLang[i], nl, true) end end end
if mother.nativeLang then for i=1,#mother.nativeLang do if mother.nativeLang[i] and not natLang[mother.nativeLang[i].name] then natLangs = natLangs+1 natLang[mother.nativeLang[i].name] = parent:getLanguage(mother.nativeLang[i], nl, true) end end end
if mother.spokenLang then for i=1,#mother.spokenLang do if mother.spokenLang[i] and not spokeLang[mother.spokenLang[i].name] then spokeLangs = spokeLangs+1 spokeLang[mother.spokenLang[i].name] = parent:getLanguage(mother.spokenLang[i], nl, true) end end end
if self.region then
local flString = self.region.language.name.." ("..(self.region.language.eml == 1 and "E." or (self.region.language.eml == 2 and "M." or "L.")).."P. "..tostring(self.region.language.period)..")"
if not parent.fileLangs[flString] then
local lCount = 0
for i, j in pairs(parent.fileLangs) do lCount = lCount+1 end
parent.fileLangs[flString] = lCount+1
parent.gedFile:write("j "..tostring(parent.fileLangs[flString]).." "..flString.."\n")
end
table.insert(self.nativeLang, self.region.language)
parent.gedFile:write(tostring(self.gIndex).." i "..tostring(parent.fileLangs[flString]).."\n")
end
local maxNatLangs = math.min(math.random(1, 2), natLangs)
local maxSpokenLangs = math.min(math.random(0, 3-maxNatLangs), spokeLangs)
local cycles = 0
while #self.nativeLang < maxNatLangs do
local choice = parent:getLanguage(parent:randomChoice(natLang), nl, true)
if choice and not table.contains(self.nativeLang, choice) and not table.contains(self.spokenLang, choice) then
local flString = choice.name.." ("..(choice.eml == 1 and "E." or (choice.eml == 2 and "M." or "L.")).."P. "..tostring(choice.period)..")"
local inherit = math.random(1, 100)
if inherit < 81 then
inherit = math.random(1, 100)
if inherit < 21 then
table.insert(self.spokenLang, choice)
if not parent.fileLangs[flString] then
local lCount = 0
for i, j in pairs(parent.fileLangs) do lCount = lCount+1 end
parent.fileLangs[flString] = lCount+1
parent.gedFile:write("j "..tostring(parent.fileLangs[flString]).." "..flString.."\n")
end
parent.gedFile:write("h "..tostring(parent.fileLangs[flString]).."\n")
maxNatLangs = maxNatLangs-1
natLang[choice.name] = nil
else
table.insert(self.nativeLang, choice)
if not parent.fileLangs[flString] then
local lCount = 0
for i, j in pairs(parent.fileLangs) do lCount = lCount+1 end
parent.fileLangs[flString] = lCount+1
parent.gedFile:write("j "..tostring(parent.fileLangs[flString]).." "..flString.."\n")
end
parent.gedFile:write("i "..tostring(parent.fileLangs[flString]).."\n")
natLang[choice.name] = nil
end
end
end
cycles = cycles+1
if cycles >= 20 then maxNatLangs = -1 end
end
cycles = 0
while #self.spokenLang < maxSpokenLangs do
local choice = parent:getLanguage(parent:randomChoice(spokeLang), nl, true)
if choice and not table.contains(self.nativeLang, choice) and not table.contains(self.spokenLang, choice) then
local flString = choice.name.." ("..(choice.eml == 1 and "E." or (choice.eml == 2 and "M." or "L.")).."P. "..tostring(choice.period)..")"
local inherit = math.random(1, 100)
if inherit < 21 then
inherit = math.random(1, 100)
if inherit < 51 then
table.insert(self.nativeLang, choice)
if not parent.fileLangs[flString] then
local lCount = 0
for i, j in pairs(parent.fileLangs) do lCount = lCount+1 end
parent.fileLangs[flString] = lCount+1
parent.gedFile:write("j "..tostring(parent.fileLangs[flString]).." "..flString.."\n")
end
parent.gedFile:write("i "..tostring(parent.fileLangs[flString]).."\n")
maxSpokenLangs = maxSpokenLangs-1
spokeLang[choice.name] = nil
else
table.insert(self.spokenLang, choice)
if not parent.fileLangs[flString] then
local lCount = 0
for i, j in pairs(parent.fileLangs) do lCount = lCount+1 end
parent.fileLangs[flString] = lCount+1
parent.gedFile:write("j "..tostring(parent.fileLangs[flString]).." "..flString.."\n")
end
parent.gedFile:write("h "..tostring(parent.fileLangs[flString]).."\n")
spokeLang[choice.name] = nil
end
end
end
cycles = cycles+1
if cycles >= 20 then maxSpokenLangs = -1 end
end
end,
update = function(self, parent, nl)
local t0 = _time()
if not self.def then return end
if not self.addedToPop then
parent.popCount = parent.popCount+1
self.addedToPop = true
end
self.age = parent.years-self.birth
if self.birth <= -1 then self.age = self.age-1 end
if not self.birthplace or self.birthplace == "" then self.birthplace = nl.name end
self.deathplace = nl.name
if not self.surname or self.surname == "" then self.surname = parent:name(true) end
if not self.ancName or self.ancName == "" then self.ancName = self.surname end
if self.age > 14 then
if math.random(1, self.age < 28 and 600 or 3200) == 435 then self.city = nil end
if math.random(1, self.age < 28 and 1800 or 8400) == 435 then self.region = nil end
end
if not self.region or not self.region.cities or not self.city then
self.region = parent:randomChoice(nl.regions)
self.city = nil
end
if self.region and not self.city then self.city = parent:randomChoice(self.region.cities) end
if self.region then
self.region.population = self.region.population+1
self.deathplace = self.region.name..", "..self.deathplace
end
if self.city then
self.city.population = self.city.population+1
self.deathplace = self.city.name..", "..self.deathplace
if self.spouse then
self.spouse.region = self.region
self.spouse.city = self.city
end
end
if self.isRuler then
self.region = nl.capitalregion or self.region
self.city = nl.capitalcity or self.city
if self.spouse then
self.spouse.region = self.region
self.spouse.city = self.city
end
end
if self.region and not self.region.language then self.region.language = parent:getLanguage(self.region, nl) end
if self.region and self.region.language then if not self.nativeLang or #self.nativeLang == 0 then
self.nativeLang = {self.region.language}
local flString = self.region.language.name.." ("..(self.region.language.eml == 1 and "E." or (self.region.language.eml == 2 and "M." or "L.")).."P. "..tostring(self.region.language.period)..")"
if not parent.fileLangs[flString] then
local lCount = 0
for i, j in pairs(parent.fileLangs) do lCount = lCount+1 end
parent.fileLangs[flString] = lCount+1
parent.gedFile:write("j "..tostring(parent.fileLangs[flString]).." "..flString.."\n")
end
parent.gedFile:write(tostring(self.gIndex).." i "..tostring(parent.fileLangs[flString]).."\n")
end end
if self.region and self.nativeLang and #self.nativeLang > 0 then
local langFound = false
for i=1,#self.nativeLang do if self.nativeLang[i].name == self.region.language.name then langFound = true end end
if not langFound then for i=1,#self.spokenLang do if self.spokenLang[i].name == self.region.language.name then langFound = true end end end
if not langFound then
local langChance = math.random(1, 10)
if langChance == 5 then
table.insert(self.spokenLang, self.region.language)
local flString = self.region.language.name.." ("..(self.region.language.eml == 1 and "E." or (self.region.language.eml == 2 and "M." or "L.")).."P. "..tostring(self.region.language.period)..")"
if not parent.fileLangs[flString] then
local lCount = 0
for i, j in pairs(parent.fileLangs) do lCount = lCount+1 end
parent.fileLangs[flString] = lCount+1
parent.gedFile:write("j "..tostring(parent.fileLangs[flString]).." "..flString.."\n")
end
parent.gedFile:write(tostring(self.gIndex).." h "..tostring(parent.fileLangs[flString]).."\n")
end
end
end
local sys = parent.systems[nl.system]
local rankLim = 2
if not sys.dynastic then rankLim = 1 end
local ranks = sys.ranks
if sys.dynastic and self.gender == "F" then ranks = sys.franks end
if self.title and self.level then
if self.level < #ranks-rankLim then
local x = math.random(-100+#ranks-self.level, 100-self.level)
if x < -85 then
self.prevtitle = self.title
self.level = self.level-1
elseif x > 85 then
self.prevtitle = self.title
self.level = self.level+1
end
end
self.level = math.max(1, self.level)
if self.level >= #ranks-rankLim then self.level = #ranks-rankLim end
if self.isRuler then self.level = #ranks end
if self.parentRuler and sys.dynastic then self.level = #ranks-1 end
else self.level = 2 end
self.title = ranks[self.level]
self.income = (self.level == 1 and 0 or 0.1*(self.level-1))+((nl.oldIncome[self.level-1] or 0)/(nl.oldIncomeLevels[self.level] or 1))
self.income = self.income*math.random(0.7, 1.3)
self.wealth = (self.wealth+self.income*(1-nl.taxRate))*self.frugality
nl.income[self.level] = (nl.income[self.level] or 0)+self.income*nl.taxRate
nl.incomeLevels[self.level] = (nl.incomeLevels[self.level] or 0)+1
if not self.spouse or not self.spouse.def or not self.spouse.spouse or not self.spouse.spouse.def or self.spouse.spouse.gString ~= self.gString then self.spouse = nil end
if not self.spouse or not self.spouse.def then if self.age > 15 and math.random(1, 8) == 4 then
local m = parent:randomChoice(nl.people)
if m.def and m.age > 15 and not m.spouse and self.gender ~= m.gender then
local found = false
if self.surname == m.surname then found = true end
if not found then for i, j in pairs(self.children) do if j.gString == m.gString or j.surname == m.surname then found = true end end end
if not found then for i, j in pairs(m.children) do if j.gString == self.gString or j.surname == self.surname then found = true end end end
if not found then
self.spouse = m
m.spouse = self
end
end
end end
if not self.recentbirth and self.spouse and math.random(1, nl.birthrate) == 2 then
self:dobirth(parent, nl)
self.spouse.recentbirth = true
end
self.recentbirth = false
if not self.party or self.party == "" then
local pmatch = nil
for i, j in pairs(nl.parties) do if j and not pmatch then
pmatch = j
if math.abs(j.pfreedom-self.pbelief) > 35 then pmatch = nil end
if math.abs(j.efreedom-self.ebelief) > 35 then pmatch = nil end
if math.abs(j.cfreedom-self.cbelief) > 35 then pmatch = nil end
end end
if not pmatch then
local newp = Party:new()
newp:makename(parent, nl)
newp.cfreedom = self.cbelief
newp.efreedom = self.ebelief
newp.pfreedom = self.pbelief
local belieftotal = newp.cfreedom+newp.efreedom+newp.pfreedom
if belieftotal > 200 then newp.radical = true end
nl.parties[newp.name] = newp
pmatch = nl.parties[newp.name]
end
self.party = pmatch.name
end
if self.isRuler then
nl.rulers[#nl.rulers].party = self.party
nl.rulerParty = nl.parties[self.party]
end
if nl.rulerParty then
local pTotal = nl.rulerParty.pfreedom-self.pbelief
local eTotal = nl.rulerParty.efreedom-self.ebelief
local cTotal = nl.rulerParty.cfreedom-self.cbelief
local diffTotal = math.abs(pTotal)+math.abs(eTotal)+math.abs(cTotal)
nl.rulerPopularity = nl.rulerPopularity+((100-diffTotal)/#nl.people)
end
if self.military then
self.militaryTraining = self.militaryTraining+1
nl.strength = nl.strength+self.militaryTraining
else
if not military and self.age > 14 and self.age < 35 then
if math.random(1, 250) < nl.milThreshold then
self.military = true
self.militaryTraining = 0
end
elseif self.age > 55 then self.military = false end
end
local lEth = parent:randomChoice(self.ethnicity, true)
local lEthVal = self.ethnicity[lEth]
for i, j in pairs(self.ethnicity) do
if not nl.ethnicities[i] then nl.ethnicities[i] = 0 end
if j >= lEthVal then
lEth = i
lEthVal = j
end
end
nl.ethnicities[lEth] = nl.ethnicities[lEth]+1
for i, j in pairs(self.nativeLang) do
j.l1Speakers = j.l1Speakers+1
for k=1,#parent.languages do if parent.languages[k].name == j.name and parent.languages[k].eml ~= j.eml then parent.languages[k].l1Speakers = parent.languages[k].l1Speakers+1 end end
end
for i, j in pairs(self.spokenLang) do
j.l2Speakers = j.l2Speakers+1
for k=1,#parent.languages do if parent.languages[k].name == j.name and parent.languages[k].eml ~= j.eml then parent.languages[k].l2Speakers = parent.languages[k].l2Speakers+1 end end
end
if _DEBUG then
if not debugTimes["Person.update"] then debugTimes["Person.update"] = 0 end
debugTimes["Person.update"] = debugTimes["Person.update"]+_time()-t0
end
end
}
Person.__index = Person
Person.__call = function() return Person:new() end
return Person
end
|
-- Decompiled using luadec 2.2 rev: for Lua 5.2 from https://github.com/viruscamp/luadec
-- Command line: A:\Work\MODDING\Github\TTDS-NoOutlines\WDC_pc_WalkingDead403_data\RiverShorelineNight_temp.lua
-- params : ...
-- function num : 0 , upvalues : _ENV
require("AI_PlayerProjectile.lua")
local kScript = "RiverShorelineNight"
local kScene = "adv_riverShorelineNight"
local mFlashlightThread, mFlashlightController = nil, nil
local OnLogicReady = function()
-- function num : 0_0 , upvalues : _ENV
if Game_GetLoaded() then
return
end
local debugID = LogicGet("Debug ID")
if debugID > 0 then
Game_SetSceneDialog("env_riverShorelineNight_act2Action")
if debugID == 1 then
Game_SetSceneDialogNode("cs_followMe")
else
Game_SetSceneDialogNode("cs_climbPier")
end
end
end
--a custom function that makes it easier to change properties on a scene agent
Custom_AgentSetProperty = function(agentName, propertyString, propertyValue, sceneObject)
--find the agent within the scene
local agent = AgentFindInScene(agentName, sceneObject)
--get the runtime properties of that agent
local agent_props = AgentGetRuntimeProperties(agent)
--set the given (propertyString) on the agent to (propertyValue)
PropertySet(agent_props, propertyString, propertyValue)
end
--removes an agent from a scene
Custom_RemoveAgent = function(agentName, sceneObj)
--check if the agent exists
if AgentExists(AgentGetName(agentName)) then
--find the agent
local agent = AgentFindInScene(agentName, sceneObj)
--destroy the agent
AgentDestroy(agent)
end
end
--our main function which we will do our scene modifications in
ModifyScene = function(sceneObj)
--set some properties on the scene
local sceneName = sceneObj .. ".scene"
Custom_AgentSetProperty(sceneName, "Generate NPR Lines", false, sceneObj)
Custom_AgentSetProperty(sceneName, "Screen Space Lines - Enabled", false, sceneObj)
--removes the green-brown graduated filter on the scene
Custom_RemoveAgent("module_post_effect", sceneObj)
--force graphic black off in this scene
local prefs = GetPreferences()
PropertySet(prefs, "Enable Graphic Black", false)
PropertySet(prefs, "Render - Graphic Black Enabled", false)
end
RiverShorelineNight = function()
-- function num : 0_1 , upvalues : _ENV
ModifyScene(kScene)
Episode_SetClemButton()
end
RiverShorelineNight_EnableFlashlightTracking = function(bEnable)
-- function num : 0_2 , upvalues : _ENV, mFlashlightController
if bEnable == ControllerIsPlaying(mFlashlightController) then
return
end
local scene = Game_GetScene()
if bEnable then
mFlashlightController = ChorePlay("adv_riverShorelineNight_flashlightPointAtClem.chore", 9910)
ControllerSetLooping(mFlashlightController, true)
ControllerSetContribution(mFlashlightController, 0)
local t = 0
while t <= 1 do
ControllerSetContribution(mFlashlightController, (math.min)(1, t))
t = t + GetFrameTime() * SceneGetTimeScale(scene)
WaitForNextFrame()
end
else
do
local t = 1
while t > 0 do
ControllerSetContribution(mFlashlightController, (math.max)(0, t))
t = t - GetFrameTime() * SceneGetTimeScale(scene)
WaitForNextFrame()
end
mFlashlightController = ControllerKill(mFlashlightController)
end
end
end
RiverShorelineNight_FlashlightChoreIsPlaying = function()
-- function num : 0_3 , upvalues : _ENV, mFlashlightController
return ControllerIsPlaying(mFlashlightController)
end
if IsDebugBuild() then
Callback_OnLogicReady:Add(OnLogicReady)
end
Game_SceneOpen(kScene, kScript)
SceneAdd("ui_notification")
|
return {
include = function()
includedirs "../vendor/enet/include/"
links { 'ws2_32', 'winmm' }
end,
run = function()
language "C"
kind "StaticLib"
files_project "../vendor/enet/" {
"*.c"
}
end
}
|
require 'torch'
require 'nn'
require 'image'
require 'optim'
local loadcaffe_wrap = require 'loadcaffe_wrapper'
--------------------------------------------------------------------------------
local cmd = torch.CmdLine()
-- Basic options
cmd:option('-style_image', 'examples/inputs/seated-nude.jpg',
'Style target image')
cmd:option('-content_image', 'examples/inputs/tubingen.jpg',
'Content target image')
cmd:option('-image_size', 128, 'Maximum height / width of generated image')
cmd:option('-gpu', 0, 'Zero-indexed ID of the GPU to use; for CPU mode set -gpu = -1')
-- Optimization options
cmd:option('-content_weight', 5e0)
cmd:option('-style_weight', 10000)
cmd:option('-tv_weight', 1e-3)
cmd:option('gamma',0.5)
cmd:option('-num_iterations', 1000)
cmd:option('-normalize_gradients', false)
cmd:option('-init', 'random', 'random|image')
cmd:option('-optimizer', 'lbfgs', 'lbfgs|adam')
cmd:option('-learning_rate', 1e1)
-- Output options
cmd:option('-print_iter', 50)
cmd:option('-save_iter', 100)
cmd:option('-output_image', 'out.png')
-- Other options
cmd:option('-style_scale', 1.0)
cmd:option('-pooling', 'max', 'max|avg')
cmd:option('-proto_file', 'models/VGG_ILSVRC_19_layers_deploy.prototxt')
cmd:option('-model_file', 'models/VGG_ILSVRC_19_layers.caffemodel')
cmd:option('-backend', 'nn', 'nn|cudnn')
local function main(params)
if params.gpu >= 0 then
require 'cutorch'
require 'cunn'
cutorch.setDevice(params.gpu + 1)
else
params.backend = 'nn-cpu'
end
if params.backend == 'cudnn' then
require 'cudnn'
end
local cnn = loadcaffe_wrap.load(params.proto_file, params.model_file, params.backend):float()
if params.gpu >= 0 then
cnn:cuda()
end
local content_image = image.load(params.content_image, 3)
content_image = image.scale(content_image, params.image_size, 'bilinear')
local content_image_caffe = preprocess(content_image):float()
local style_image = image.load(params.style_image, 3)
local style_size = math.ceil(params.style_scale * params.image_size)
style_image = image.scale(style_image, style_size, 'bilinear')
--local style_size_h,style_size_w=content_image:size(2),content_image:size(3)
--style_image = image.scale(style_image, style_size_w,style_size_h, 'bilinear')
local style_image_caffe = preprocess(style_image):float()
if params.gpu >= 0 then
content_image_caffe = content_image_caffe:cuda()
style_image_caffe = style_image_caffe:cuda()
end
-- Hardcode these for now
local content_layers = {23}
local style_layers = {2, 7, 12, 21, 30}
local style_layer_weights = {1e0, 1e0, 1e0, 1e0, 1e0}
-- Set up the network, inserting style and content loss modules
local content_losses, style_losses = {}, {}
local next_content_idx, next_style_idx = 1, 1
local net = nn.Sequential()
if params.tv_weight > 0 then
local tv_mod = nn.TVLoss(params.tv_weight):float()
if params.gpu >= 0 then
tv_mod:cuda()
end
net:add(tv_mod)
end
for i = 1, #cnn do
if next_content_idx <= #content_layers or next_style_idx <= #style_layers then
local layer = cnn:get(i)
local layer_type = torch.type(layer)
local is_pooling = (layer_type == 'cudnn.SpatialMaxPooling' or layer_type == 'nn.SpatialMaxPooling')
if is_pooling and params.pooling == 'avg' then
assert(layer.padW == 0 and layer.padH == 0)
local kW, kH = layer.kW, layer.kH
local dW, dH = layer.dW, layer.dH
local avg_pool_layer = nn.SpatialAveragePooling(kW, kH, dW, dH):float()
if params.gpu >= 0 then avg_pool_layer:cuda() end
local msg = 'Replacing max pooling at layer %d with average pooling'
print(string.format(msg, i))
net:add(avg_pool_layer)
else
net:add(layer)
end
if i == content_layers[next_content_idx] then
local target = net:forward(content_image_caffe):clone()
local norm = params.normalize_gradients
local loss_module = nn.ContentLoss(params.content_weight, target, norm):float()
if params.gpu >= 0 then
loss_module:cuda()
end
net:add(loss_module)
table.insert(content_losses, loss_module)
next_content_idx = next_content_idx + 1
end
if i == style_layers[next_style_idx] then
local target_features = net:forward(style_image_caffe):clone()
local Gamma = params.gamma
--local C=target_features:size(1)
local gram = GramMatrix(Gamma):float()
if params.gpu >= 0 then
gram = gram:cuda()
end
local target = gram:forward(target_features)
target:div(target_features:nElement())
local weight = params.style_weight * style_layer_weights[next_style_idx]
local norm = params.normalize_gradients
local loss_module = nn.StyleLoss(weight, Gamma, target, norm):float()
if params.gpu >= 0 then
loss_module:cuda()
end
net:add(loss_module)
table.insert(style_losses, loss_module)
next_style_idx = next_style_idx + 1
end
end
end
-- We don't need the base CNN anymore, so clean it up to save memory.
cnn = nil
collectgarbage()
-- Initialize the image
local img = nil
if params.init == 'random' then
img = torch.randn(content_image:size()):float():mul(0.001)
elseif params.init == 'image' then
img = content_image_caffe:clone():float()
else
error('Invalid init type')
end
if params.gpu >= 0 then
img = img:cuda()
end
-- Run it through the network once to get the proper size for the gradient
-- All the gradients will come from the extra loss modules, so we just pass
-- zeros into the top of the net on the backward pass.
local y = net:forward(img)
local dy = img.new(#y):zero()
-- Declaring this here lets us access it in maybe_print
local optim_state = nil
if params.optimizer == 'lbfgs' then
optim_state = {
maxIter = params.num_iterations,
verbose=true,
}
elseif params.optimizer == 'adam' then
optim_state = {
learningRate = params.learning_rate,
}
else
error(string.format('Unrecognized optimizer "%s"', params.optimizer))
end
local function maybe_print(t, loss)
local verbose = (params.print_iter > 0 and t % params.print_iter == 0)
if verbose then
print(string.format('Iteration %d / %d', t, params.num_iterations))
for i, loss_module in ipairs(content_losses) do
print(string.format(' Content %d loss: %f', i, loss_module.loss))
end
for i, loss_module in ipairs(style_losses) do
print(string.format(' Style %d loss: %f', i, loss_module.loss))
end
print(string.format(' Total loss: %f', loss))
end
end
local function maybe_save(t)
local should_save = params.save_iter > 0 and t % params.save_iter == 0
should_save = should_save or t == params.num_iterations
if should_save then
local disp = deprocess(img:double())
disp = image.minmax{tensor=disp, min=0, max=1}
local filename = build_filename(params.output_image, t)
if t == params.num_iterations then
filename = params.output_image
end
image.save(filename, disp)
end
end
-- Function to evaluate loss and gradient. We run the net forward and
-- backward to get the gradient, and sum up losses from the loss modules.
-- optim.lbfgs internally handles iteration and calls this fucntion many
-- times, so we manually count the number of iterations to handle printing
-- and saving intermediate results.
local num_calls = 0
local function feval(x)
num_calls = num_calls + 1
net:forward(x)
local grad = net:backward(x, dy)
local loss = 0
for _, mod in ipairs(content_losses) do
loss = loss + mod.loss
end
for _, mod in ipairs(style_losses) do
loss = loss + mod.loss
end
maybe_print(num_calls, loss)
maybe_save(num_calls)
collectgarbage()
-- optim.lbfgs expects a vector for gradients
return loss, grad:view(grad:nElement())
end
-- Run optimization.
if params.optimizer == 'lbfgs' then
print('Running optimization with L-BFGS')
local x, losses = optim.lbfgs(feval, img, optim_state)
elseif params.optimizer == 'adam' then
print('Running optimization with ADAM')
for t = 1, params.num_iterations do
local x, losses = optim.adam(feval, img, optim_state)
end
end
end
function build_filename(output_image, iteration)
local idx = string.find(output_image, '%.')
local basename = string.sub(output_image, 1, idx - 1)
local ext = string.sub(output_image, idx)
return string.format('%s_%d%s', basename, iteration, ext)
end
-- Preprocess an image before passing it to a Caffe model.
-- We need to rescale from [0, 1] to [0, 255], convert from RGB to BGR,
-- and subtract the mean pixel.
function preprocess(img)
local mean_pixel = torch.DoubleTensor({103.939, 116.779, 123.68})
local perm = torch.LongTensor{3, 2, 1}
img = img:index(1, perm):mul(256.0)
mean_pixel = mean_pixel:view(3, 1, 1):expandAs(img)
img:add(-1, mean_pixel)
return img
end
-- Undo the above preprocessing.
function deprocess(img)
local mean_pixel = torch.DoubleTensor({103.939, 116.779, 123.68})
mean_pixel = mean_pixel:view(3, 1, 1):expandAs(img)
img = img + mean_pixel
local perm = torch.LongTensor{3, 2, 1}
img = img:index(1, perm):div(256.0)
return img
end
-- Define an nn Module to compute content loss in-place
local ContentLoss, parent = torch.class('nn.ContentLoss', 'nn.Module')
function ContentLoss:__init(strength, target, normalize)
parent.__init(self)
self.strength = strength
self.target = target
self.normalize = normalize or false
self.loss = 0
self.crit = nn.MSECriterion()
end
function ContentLoss:updateOutput(input)
if input:nElement() == self.target:nElement() then
self.loss = self.crit:forward(input, self.target) * self.strength
else
print('WARNING: Skipping content loss')
end
self.output = input
return self.output
end
function ContentLoss:updateGradInput(input, gradOutput)
if input:nElement() == self.target:nElement() then
self.gradInput = self.crit:backward(input, self.target)
end
if self.normalize then
self.gradInput:div(torch.norm(self.gradInput, 1) + 1e-8)
end
self.gradInput:mul(self.strength)
self.gradInput:add(gradOutput)
return self.gradInput
end
-- Returns a network that computes the CxC Gram matrix from inputs
-- of size C x H x W
function GramMatrix(gamma)
local g = (-1)*gamma
local net = nn.Sequential()
net:add(nn.View(-1):setNumInputDims(2))
local Gram = nn.Sequential()
local concat_1 = nn.ConcatTable()
concat_1:add(nn.Identity())
concat_1:add(nn.Identity())
Gram:add(concat_1)
Gram:add(nn.MM(false,true))
local concat_2= nn.ConcatTable()
concat_2:add(Gram)
concat_2:add(nn.RBF(g))
net:add(concat_2)
net:add(nn.CMulTable())
return net
end
-- Define an nn Module to compute style loss in-place
local StyleLoss, parent = torch.class('nn.StyleLoss', 'nn.Module')
function StyleLoss:__init(strength, Gamma, target, normalize)
parent.__init(self)
self.normalize = normalize or false
self.strength = strength
self.target = target
self.loss = 0
-- self.c = C
self.gamma = Gamma
self.gram = GramMatrix(self.gamma)
self.G = nil
self.crit = nn.MSECriterion()
end
function StyleLoss:updateOutput(input)
self.G = self.gram:forward(input)
self.G:div(input:nElement())
self.loss = self.crit:forward(self.G, self.target)
self.loss = self.loss * self.strength
self.output = input
return self.output
end
function StyleLoss:updateGradInput(input, gradOutput)
local dG = self.crit:backward(self.G, self.target)
dG:div(input:nElement())
self.gradInput = self.gram:backward(input, dG)
if self.normalize then
self.gradInput:div(torch.norm(self.gradInput, 1) + 1e-8)
end
self.gradInput:mul(self.strength)
self.gradInput:add(gradOutput)
return self.gradInput
end
local TVLoss, parent = torch.class('nn.TVLoss', 'nn.Module')
function TVLoss:__init(strength)
parent.__init(self)
self.strength = strength
self.x_diff = torch.Tensor()
self.y_diff = torch.Tensor()
end
function TVLoss:updateOutput(input)
self.output = input
return self.output
end
-- TV loss backward pass inspired by kaishengtai/neuralart
function TVLoss:updateGradInput(input, gradOutput)
self.gradInput:resizeAs(input):zero()
local C, H, W = input:size(1), input:size(2), input:size(3)
self.x_diff:resize(3, H - 1, W - 1)
self.y_diff:resize(3, H - 1, W - 1)
self.x_diff:copy(input[{{}, {1, -2}, {1, -2}}])
self.x_diff:add(-1, input[{{}, {1, -2}, {2, -1}}])
self.y_diff:copy(input[{{}, {1, -2}, {1, -2}}])
self.y_diff:add(-1, input[{{}, {2, -1}, {1, -2}}])
self.gradInput[{{}, {1, -2}, {1, -2}}]:add(self.x_diff):add(self.y_diff)
self.gradInput[{{}, {1, -2}, {2, -1}}]:add(-1, self.x_diff)
self.gradInput[{{}, {2, -1}, {1, -2}}]:add(-1, self.y_diff)
self.gradInput:mul(self.strength)
self.gradInput:add(gradOutput)
return self.gradInput
end
local RBF, parent = torch.class('nn.RBF', 'nn.Module')
function RBF:__init(gamma)
parent.__init(self)
self.gamma = gamma or (-0.5)
--self.tmp =nil
-- self.tmp_gradInput= torch.Tensor()
--self.N=nil
end
function RBF:updateOutput(input)
local a = input
assert(a:nDimension() == 2, 'input tensor must be 2D')
local N = a:size(1)
self.output:resize(N,N)
local tmp
for i = 1 , N do
tmp = a[{{i},{}}]:repeatTensor(N,1)-a
tmp:pow(2)
self.output[{{},{i}}] = torch.sum(tmp,2)*self.gamma
end
self.output:exp()
return self.output
end
function RBF:updateGradInput(input, gradOutput)
self.gradInput:resizeAs(input)
assert(gradOutput:nDimension() == 2, 'arguments must be a 2D Tensor')
assert(gradOutput:size(1)==gradOutput:size(2), 'arguments must be a n*n Tensor')
-- local tmp=torch.CudaTensor()
--local gradInput=torch.CudaTensor(input:size(2))
local tmp,N, gradInput
--self.tmp_gradInput:resizeAs(input[1])
self.gradInput:resizeAs(input)
tmp=torch.cmul(self.output,gradOutput)
tmp:mul(self.gamma)
--tmp:pow(2-1)
tmp:cmul(tmp):mul(2)
N = tmp:size(1)
for i = 1, N do
gradInput=input[{{i},{}}]:repeatTensor(N,1)-input
self.gradInput[{{i},{}}] = tmp[{{i},{}}]*gradInput *2
end
--[[for i = 1, N do
for j = 1, N do
self.tmp_gradInput:copy(input[i])
self.tmp_gradInput:add(-1,input[j])
self.tmp_gradInput:mul(tmp[i][j])
self.gradInput[i]:add(1,self.tmp_gradInput)
end
end--]]
return self.gradInput
end
local params = cmd:parse(arg)
main(params)
|
AddCSLuaFile()
if( CLIENT ) then
SWEP.PrintName = "Entity Position Helper";
SWEP.Slot = 0;
SWEP.SlotPos = 0;
SWEP.CLMode = 0
end
SWEP.HoldType = "fists"
SWEP.Category = "Nutscript"
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.ViewModel = "models/weapons/v_pistol.mdl"
SWEP.WorldModel = "models/weapons/w_pistol.mdl"
SWEP.Primary.Delay = 1
SWEP.Primary.Recoil = 0
SWEP.Primary.Damage = 0
SWEP.Primary.NumShots = 0
SWEP.Primary.Cone = 0
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.Delay = 0.9
SWEP.Secondary.Recoil = 0
SWEP.Secondary.Damage = 0
SWEP.Secondary.NumShots = 1
SWEP.Secondary.Cone = 0
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = true
SWEP.Secondary.Ammo = "none"
function SWEP:Initialize()
self:SetWeaponHoldType("knife")
end
function SWEP:Deploy()
return true
end
function SWEP:Think()
end
local gridsize = 1
if SERVER then
function SWEP:PrimaryAttack()
end
function SWEP:Reload()
end
function SWEP:SecondaryAttack()
end
end
if CLIENT then
local PANEL = {}
local vTxt = "xyz"
local aTxt = "pyr"
function PANEL:Init()
self:SetTitle("HELPER")
self:SetSize(300, 390)
self:Center()
self:MakePopup()
self.list = self:Add("DPanel")
self.list:Dock(FILL)
self.list:DockMargin(0, 0, 0, 0)
for i = 1, 3 do
local cfg = self.list:Add("DNumSlider")
cfg:Dock(TOP)
cfg:SetText("VECTOR" .. vTxt[i])
cfg:SetMin(-100)
cfg:SetMax(100)
cfg:SetDecimals(3)
cfg:SetValue(HELPER_INFO.renderPos[i])
cfg:DockMargin(10, 0, 0, 5)
function cfg:OnValueChanged(value)
HELPER_INFO.renderPos[i] = value
end
end
for i = 1, 3 do
local cfg = self.list:Add("DNumSlider")
cfg:Dock(TOP)
cfg:SetText("ANGLE" .. aTxt[i])
cfg:SetMin(-180)
cfg:SetMax(180)
cfg:SetDecimals(3)
cfg:SetValue(HELPER_INFO.renderAng[i])
cfg:DockMargin(10, 0, 0, 5)
function cfg:OnValueChanged(value)
HELPER_INFO.renderAng[i] = value
end
end
local textBox = self.list:Add("DTextEntry")
textBox:SetFont("Default")
textBox:Dock(TOP)
textBox:SetTall(30)
textBox:DockMargin(10, 0, 10, 0)
textBox:SetValue(HELPER_INFO.modelName)
function textBox:OnEnter(value)
HELPER_INFO.modelName = textBox:GetText()
if (HELPER_INFO.modelObject and IsValid(HELPER_INFO.modelObject)) then
HELPER_INFO.modelObject:SetModel(HELPER_INFO.modelName)
end
end
local changeModel = self.list:Add("DButton")
changeModel:SetFont("Default")
changeModel:Dock(TOP)
changeModel:SetTall(25)
changeModel:DockMargin(10, 5, 10, 0)
changeModel:SetText("Change Model")
function changeModel:DoClick()
HELPER_INFO.modelName = textBox:GetText()
if (HELPER_INFO.modelObject and IsValid(HELPER_INFO.modelObject)) then
HELPER_INFO.modelObject:SetModel(HELPER_INFO.modelName)
end
end
local toggleZ = self.list:Add("DButton")
toggleZ:SetFont("Default")
toggleZ:Dock(TOP)
toggleZ:SetTall(25)
toggleZ:DockMargin(10, 5, 10, 0)
toggleZ:SetText("Toggle IgnoreZ")
function toggleZ:DoClick()
HELPER_INFO.ignoreZ = !HELPER_INFO.ignoreZ
end
local cpyInfo = self.list:Add("DButton")
cpyInfo:SetFont("Default")
cpyInfo:Dock(TOP)
cpyInfo:SetTall(25)
cpyInfo:DockMargin(10, 5, 10, 0)
cpyInfo:SetText("Copy Informations")
function cpyInfo:DoClick()
SetClipboardText(Format(
[[Local Pos, Ang:
Pos = Vector(%s, %s, %s)
Ang = Angle(%s, %s, %s)]]
, HELPER_INFO.renderPos[1], HELPER_INFO.renderPos[2], HELPER_INFO.renderPos[3]
, HELPER_INFO.renderAng[1], HELPER_INFO.renderAng[2], HELPER_INFO.renderAng[3]))
end
end
vgui.Register("nutHelperFrame", PANEL, "DFrame")
function SWEP:PrimaryAttack()
if IsFirstTimePredicted() then
local trace = LocalPlayer():GetEyeTraceNoCursor()
local ent = trace.Entity
if (ent and IsValid(ent)) then
HELPER_INFO.entity = ent
end
end
end
function SWEP:Reload()
if (!self.menuOpen) then
self.menuOpen = true
local a = vgui.Create("nutHelperFrame")
timer.Simple(.3, function()
self.menuOpen = false
end)
end
end
function SWEP:SecondaryAttack()
return false
end
function SWEP:Deploy()
end
function SWEP:Holster()
HELPER_INFO.renderPos = Vector()
HELPER_INFO.renderAng = Angle()
HELPER_INFO.modelAng = Angle()
HELPER_INFO.entity = nil
if (HELPER_INFO.modelObject and IsValid(HELPER_INFO.modelObject)) then
HELPER_INFO.modelObject:Remove()
end
return true
end
function SWEP:OnRemove()
end
function SWEP:Think()
end
HELPER_INFO = HELPER_INFO or {}
HELPER_INFO.renderPos = Vector()
HELPER_INFO.renderAng = Angle()
HELPER_INFO.modelAng = Angle()
HELPER_INFO.modelName = "models/props_junk/PopCan01a.mdl"
HELPER_INFO.ignoreZ = false
function SWEP:DrawHUD()
local w, h = ScrW(), ScrH()
local cury = h/4*3
local tx, ty = draw.SimpleText("Left Click: Select Entity", "nutMediumFont", w/2, cury, color_white, 1, 1)
cury = cury + ty
local tx, ty = draw.SimpleText("Right Click: Deselect Entity", "nutMediumFont", w/2, cury, color_white, 1, 1)
cury = cury + ty
local tx, ty = draw.SimpleText("Reload: Register Area", "nutMediumFont", w/2, cury, color_white, 1, 1)
end
hook.Add("PostDrawOpaqueRenderables", "helperDrawModel", function()
local ent = HELPER_INFO.entity
if (ent and IsValid(ent)) then
if (HELPER_INFO.modelObject and IsValid(HELPER_INFO.modelObject)) then
local dPos, dAng = ent:GetPos(), ent:GetAngles()
dPos, dAng = LocalToWorld(HELPER_INFO.renderPos, HELPER_INFO.renderAng, dPos, dAng)
HELPER_INFO.modelObject:SetRenderOrigin(dPos)
HELPER_INFO.modelObject:SetRenderAngles(dAng)
if (HELPER_INFO.ignoreZ) then
cam.IgnoreZ(true)
end
HELPER_INFO.modelObject:DrawModel()
if (HELPER_INFO.ignoreZ) then
cam.IgnoreZ(false)
end
else
HELPER_INFO.modelObject = ClientsideModel(HELPER_INFO.modelName, RENDERGROUP_TRANSLUCENT)
HELPER_INFO.modelObject:SetNoDraw(true)
end
else
if (HELPER_INFO.modelObject and IsValid(HELPER_INFO.modelObject)) then
HELPER_INFO.modelObject:Remove()
end
end
end)
end
|
require("imlua")
require("iuplua")
require("iupluaimglib")
require("iupluaim")
require("cdlua")
require("iupluacd")
--********************************** Images *****************************************
function load_image_PaintLine()
local PaintLine = iup.imagergba
{
width = 16,
height = 16,
pixels = {
0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 12, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 239, 0, 0, 0, 60, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 84, 0, 0, 0, 239, 0, 0, 0, 60, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 84, 0, 0, 0, 239, 0, 0, 0, 60, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 84, 0, 0, 0, 239, 0, 0, 0, 60, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 84, 0, 0, 0, 239, 0, 0, 0, 60, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 84, 0, 0, 0, 239, 0, 0, 0, 60, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 84, 0, 0, 0, 239, 0, 0, 0, 60, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 84, 0, 0, 0, 239, 0, 0, 0, 60, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 84, 0, 0, 0, 239, 0, 0, 0, 60, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 84, 0, 0, 0, 239, 0, 0, 0, 60, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 84, 0, 0, 0, 239, 0, 0, 0, 60, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 84, 0, 0, 0, 227, 0, 0, 0, 8, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 16, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
},
}
return PaintLine
end
function load_image_PaintPointer()
local PaintPointer = iup.imagergba
{
width = 16,
height = 16,
pixels = {
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 162, 180, 203, 255, 162, 180, 203, 84, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 162, 180, 203, 255, 162, 180, 203, 255, 162, 180, 203, 84, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 162, 180, 203, 255, 240, 243, 246, 255, 162, 180, 203, 255, 162, 180, 203, 69, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 162, 180, 203, 255, 255, 255, 255, 255, 241, 244, 247, 255, 161, 179, 202, 255, 161, 179, 202, 57, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 158, 176, 200, 255, 255, 255, 255, 255, 255, 255, 255, 255, 240, 242, 246, 255, 147, 165, 189, 255, 134, 152, 176, 57, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 153, 172, 195, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 227, 231, 236, 255, 129, 147, 171, 255, 115, 134, 158, 48, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 148, 166, 189, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 253, 253, 254, 255, 213, 218, 226, 255, 111, 130, 154, 255, 96, 115, 140, 57, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 141, 159, 183, 255, 254, 255, 255, 255, 252, 253, 254, 255, 250, 251, 253, 255, 247, 248, 251, 255, 243, 246, 250, 255, 206, 213, 223, 255, 91, 110, 136, 255, 73, 92, 118, 48, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 134, 152, 176, 255, 249, 250, 252, 255, 246, 247, 251, 255, 242, 245, 249, 255, 238, 242, 247, 255, 92, 111, 137, 255, 56, 76, 102, 255, 60, 80, 106, 255, 73, 92, 118, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 127, 145, 170, 255, 241, 244, 249, 255, 205, 212, 221, 255, 88, 108, 133, 255, 229, 234, 243, 255, 105, 124, 148, 255, 105, 124, 148, 83, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 119, 138, 163, 255, 203, 209, 220, 255, 63, 83, 109, 255, 102, 121, 145, 255, 197, 206, 221, 255, 187, 197, 214, 255, 89, 108, 133, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 112, 131, 156, 255, 82, 101, 127, 255, 55, 75, 101, 81, 102, 121, 145, 123, 102, 121, 145, 255, 206, 215, 233, 255, 79, 99, 124, 255, 79, 99, 124, 45, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 105, 124, 150, 255, 255, 255, 255, 0, 255, 255, 255, 0, 102, 121, 145, 18, 95, 115, 140, 255, 190, 202, 223, 255, 152, 167, 189, 255, 67, 87, 112, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 95, 115, 140, 150, 84, 104, 129, 255, 164, 178, 202, 255, 58, 78, 104, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 95, 115, 140, 6, 70, 90, 116, 255, 59, 79, 105, 255, 55, 75, 101, 87, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
},
}
return PaintPointer
end
function load_image_PaintPencil()
local PaintPencil = iup.imagergba
{
width = 16,
height = 16,
pixels = {
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 194, 126, 104, 73, 173, 108, 94, 255, 173, 108, 94, 255, 188, 121, 101, 48, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 175, 158, 120, 66, 173, 108, 94, 255, 235, 159, 129, 255, 208, 118, 94, 255, 173, 108, 94, 255, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 175, 158, 120, 66, 187, 176, 125, 255, 172, 184, 202, 255, 209, 133, 115, 255, 173, 108, 94, 255, 144, 53, 53, 255, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 175, 158, 120, 66, 185, 172, 115, 255, 238, 224, 140, 255, 217, 196, 108, 255, 134, 134, 125, 255, 144, 53, 53, 255, 131, 57, 47, 78, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 175, 158, 120, 66, 183, 166, 101, 255, 238, 224, 140, 255, 215, 191, 98, 255, 178, 154, 73, 255, 22, 18, 14, 255, 102, 85, 40, 48, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 175, 158, 120, 66, 185, 172, 115, 255, 238, 224, 140, 255, 215, 191, 98, 255, 178, 154, 73, 255, 22, 18, 14, 255, 117, 98, 45, 59, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 175, 158, 120, 66, 183, 166, 101, 255, 238, 224, 140, 255, 215, 191, 98, 255, 178, 154, 73, 255, 22, 18, 14, 255, 117, 98, 45, 59, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 175, 158, 120, 66, 181, 160, 87, 255, 238, 224, 140, 255, 215, 191, 98, 255, 178, 154, 73, 255, 22, 18, 14, 255, 117, 98, 45, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 175, 158, 120, 66, 179, 156, 77, 255, 238, 224, 140, 255, 215, 191, 98, 255, 178, 154, 73, 255, 22, 18, 14, 255, 117, 98, 45, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 152, 157, 163, 255, 199, 183, 136, 255, 226, 206, 116, 255, 178, 154, 73, 255, 22, 18, 14, 255, 82, 68, 37, 40, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 152, 157, 163, 118, 152, 157, 163, 255, 254, 254, 253, 255, 169, 147, 81, 255, 22, 18, 14, 255, 117, 98, 45, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 118, 110, 113, 117, 255, 81, 84, 87, 255, 0, 0, 0, 255, 82, 68, 37, 40, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 224, 0, 0, 0, 118, 81, 84, 87, 104, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
},
}
return PaintPencil
end
function load_image_PaintColorPicker()
local PaintColorPicker = iup.imagergba
{
width = 16,
height = 16,
pixels = {
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 1, 1, 1, 85, 0, 0, 1, 192, 0, 0, 0, 192, 0, 0, 0, 85,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 7, 11, 15, 37, 8, 12, 16, 70, 79, 81, 83, 224, 205, 205, 205, 255, 136, 138, 142, 255, 11, 13, 15, 203,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 9, 15, 21, 119, 18, 26, 37, 255, 68, 70, 72, 255, 88, 93, 99, 255, 117, 120, 126, 255, 84, 86, 91, 255, 2, 2, 2, 194,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 15, 21, 30, 31, 23, 34, 49, 235, 49, 56, 65, 255, 70, 72, 72, 255, 54, 56, 58, 255, 21, 22, 22, 199, 0, 0, 0, 85,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 152, 166, 185, 255, 20, 30, 42, 42, 21, 32, 45, 237, 49, 56, 65, 255, 7, 9, 13, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 152, 166, 185, 255, 255, 255, 255, 255, 202, 208, 222, 255, 173, 183, 202, 255, 6, 10, 15, 236, 2, 4, 5, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 152, 166, 185, 255, 255, 255, 255, 255, 202, 208, 222, 255, 143, 156, 181, 255, 68, 88, 114, 255, 1, 1, 3, 33, 0, 0, 0, 111, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 152, 166, 185, 255, 255, 255, 255, 255, 214, 220, 230, 255, 143, 156, 181, 255, 68, 88, 114, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 152, 166, 185, 255, 255, 255, 255, 255, 215, 221, 231, 255, 143, 156, 181, 255, 65, 85, 112, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 152, 166, 185, 255, 255, 255, 255, 255, 216, 220, 231, 255, 143, 156, 181, 255, 65, 85, 112, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 152, 166, 185, 255, 216, 220, 231, 218, 143, 156, 181, 255, 66, 86, 113, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 43, 134, 240, 46, 43, 134, 240, 107, 152, 166, 185, 255, 255, 255, 255, 255, 69, 89, 114, 255, 51, 72, 99, 255, 43, 134, 240, 236, 43, 134, 240, 204, 43, 133, 240, 161, 43, 132, 239, 107, 43, 130, 239, 46, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 43, 133, 239, 170, 43, 133, 240, 255, 87, 105, 130, 255, 79, 97, 123, 255, 43, 134, 240, 255, 43, 134, 240, 255, 43, 135, 240, 255, 43, 134, 240, 255, 43, 134, 240, 255, 43, 134, 240, 255, 43, 133, 239, 170, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 42, 120, 237, 46, 42, 124, 238, 107, 42, 125, 238, 161, 42, 126, 238, 204, 42, 128, 238, 236, 43, 130, 239, 253, 43, 131, 239, 236, 43, 131, 239, 204, 43, 131, 239, 161, 43, 129, 239, 107, 42, 127, 238, 46, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
},
}
return PaintColorPicker
end
function load_image_PaintEllipse()
local PaintEllipse = iup.imagergba
{
width = 16,
height = 16,
pixels = {
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 20, 0, 0, 0, 84, 0, 0, 0, 128, 0, 0, 0, 128, 0, 0, 0, 84, 0, 0, 0, 20, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 16, 0, 0, 0, 155, 0, 0, 0, 239, 0, 0, 0, 175, 0, 0, 0, 131, 0, 0, 0, 131, 0, 0, 0, 175, 0, 0, 0, 239, 0, 0, 0, 155, 0, 0, 0, 16, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 24, 0, 0, 0, 215, 0, 0, 0, 143, 0, 0, 0, 16, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 16, 0, 0, 0, 143, 0, 0, 0, 215, 0, 0, 0, 24, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 199, 0, 0, 0, 120, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 120, 0, 0, 0, 199, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 0, 0, 0, 60, 0, 0, 0, 211, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 211, 0, 0, 0, 60, 255, 255, 255, 0,
255, 255, 255, 0, 0, 0, 0, 120, 0, 0, 0, 139, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 139, 0, 0, 0, 120, 255, 255, 255, 0,
255, 255, 255, 0, 0, 0, 0, 120, 0, 0, 0, 135, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 135, 0, 0, 0, 120, 255, 255, 255, 0,
255, 255, 255, 0, 0, 0, 0, 68, 0, 0, 0, 211, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 211, 0, 0, 0, 68, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 199, 0, 0, 0, 120, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 120, 0, 0, 0, 199, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 36, 0, 0, 0, 231, 0, 0, 0, 135, 0, 0, 0, 12, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 12, 0, 0, 0, 135, 0, 0, 0, 231, 0, 0, 0, 36, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 20, 0, 0, 0, 163, 0, 0, 0, 239, 0, 0, 0, 171, 0, 0, 0, 131, 0, 0, 0, 131, 0, 0, 0, 171, 0, 0, 0, 239, 0, 0, 0, 163, 0, 0, 0, 20, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 24, 0, 0, 0, 88, 0, 0, 0, 128, 0, 0, 0, 128, 0, 0, 0, 88, 0, 0, 0, 24, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
},
}
return PaintEllipse
end
function load_image_PaintRect()
local PaintRect = iup.imagergba
{
width = 16,
height = 16,
pixels = {
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 254, 0, 0, 0, 247, 0, 0, 0, 239, 0, 0, 0, 247, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
},
}
return PaintRect
end
function load_image_PaintOval()
local PaintOval = iup.imagergba
{
width = 16,
height = 16,
pixels = {
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 24, 0, 0, 0, 135, 0, 0, 0, 211, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 211, 0, 0, 0, 135, 0, 0, 0, 24, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 80, 0, 0, 0, 239, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 239, 0, 0, 0, 80, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 48, 0, 0, 0, 251, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 251, 0, 0, 0, 48, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 183, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 183, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 247, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 247, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 247, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 247, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 183, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 183, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 56, 0, 0, 0, 251, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 251, 0, 0, 0, 56, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 84, 0, 0, 0, 243, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 243, 0, 0, 0, 84, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 24, 0, 0, 0, 139, 0, 0, 0, 211, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 211, 0, 0, 0, 139, 0, 0, 0, 24, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
},
}
return PaintOval
end
function load_image_PaintBox()
local PaintBox = iup.imagergba
{
width = 16,
height = 16,
pixels = {
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 254, 0, 0, 0, 247, 0, 0, 0, 239, 0, 0, 0, 247, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
},
}
return PaintBox
end
function load_image_PaintZoomGrid()
local PaintZoomGrid = iup.imagergba
{
width = 16,
height = 16,
pixels = {
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 110, 155, 223, 255, 255, 255, 255, 0, 255, 255, 255, 0, 106, 151, 219, 255, 255, 255, 255, 0, 255, 255, 255, 0, 95, 142, 210, 255, 255, 255, 255, 0, 255, 255, 255, 0, 84, 129, 201, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 110, 155, 223, 255, 255, 255, 255, 0, 255, 255, 255, 0, 102, 147, 217, 255, 255, 255, 255, 0, 255, 255, 255, 0, 92, 137, 207, 255, 255, 255, 255, 0, 255, 255, 255, 0, 80, 125, 197, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 110, 155, 223, 255, 110, 155, 223, 255, 107, 152, 222, 255, 104, 151, 219, 255, 103, 148, 216, 255, 100, 145, 213, 255, 97, 142, 210, 255, 93, 138, 206, 255, 88, 133, 203, 255, 84, 129, 201, 255, 80, 125, 197, 255, 76, 121, 193, 255, 72, 117, 189, 255, 68, 113, 183, 255, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 106, 149, 219, 255, 255, 255, 255, 0, 255, 255, 255, 0, 97, 142, 210, 255, 255, 255, 255, 0, 255, 255, 255, 0, 84, 131, 199, 255, 255, 255, 255, 0, 255, 255, 255, 0, 72, 117, 187, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 103, 148, 216, 255, 255, 255, 255, 0, 255, 255, 255, 0, 92, 137, 207, 255, 255, 255, 255, 0, 255, 255, 255, 0, 81, 125, 196, 255, 255, 255, 255, 0, 255, 255, 255, 0, 68, 113, 185, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 104, 151, 219, 255, 104, 148, 216, 255, 100, 145, 213, 255, 97, 142, 210, 255, 92, 137, 207, 255, 88, 135, 203, 255, 84, 129, 199, 255, 80, 125, 195, 255, 76, 121, 193, 255, 70, 117, 189, 255, 68, 112, 183, 255, 62, 109, 181, 255, 60, 105, 177, 255, 57, 102, 174, 255, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 97, 142, 210, 255, 255, 255, 255, 0, 255, 255, 255, 0, 84, 129, 199, 255, 255, 255, 255, 0, 255, 255, 255, 0, 72, 117, 187, 255, 255, 255, 255, 0, 255, 255, 255, 0, 60, 105, 177, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 93, 138, 206, 255, 255, 255, 255, 0, 255, 255, 255, 0, 80, 125, 195, 255, 255, 255, 255, 0, 255, 255, 255, 0, 66, 113, 185, 255, 255, 255, 255, 0, 255, 255, 255, 0, 56, 103, 173, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 95, 140, 212, 255, 92, 137, 207, 255, 88, 133, 203, 255, 84, 129, 199, 255, 80, 125, 195, 255, 76, 121, 193, 255, 72, 117, 187, 255, 68, 113, 185, 255, 64, 107, 181, 255, 59, 105, 178, 255, 55, 101, 174, 255, 53, 98, 170, 255, 49, 95, 168, 255, 48, 91, 165, 255, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 84, 131, 199, 255, 255, 255, 255, 0, 255, 255, 255, 0, 70, 117, 189, 255, 255, 255, 255, 0, 255, 255, 255, 0, 60, 105, 177, 255, 255, 255, 255, 0, 255, 255, 255, 0, 49, 95, 168, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 82, 125, 195, 255, 255, 255, 255, 0, 255, 255, 255, 0, 68, 113, 185, 255, 255, 255, 255, 0, 255, 255, 255, 0, 57, 102, 174, 255, 255, 255, 255, 0, 255, 255, 255, 0, 46, 92, 165, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 84, 129, 199, 255, 80, 125, 195, 255, 76, 121, 191, 255, 72, 117, 189, 255, 66, 113, 185, 255, 64, 109, 181, 255, 60, 105, 177, 255, 55, 102, 174, 255, 52, 98, 171, 255, 49, 95, 168, 255, 46, 91, 166, 255, 44, 90, 163, 255, 42, 88, 161, 255, 42, 88, 161, 255, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 72, 117, 187, 255, 255, 255, 255, 0, 255, 255, 255, 0, 60, 107, 177, 255, 255, 255, 255, 0, 255, 255, 255, 0, 50, 95, 167, 255, 255, 255, 255, 0, 255, 255, 255, 0, 42, 88, 161, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 68, 113, 185, 255, 255, 255, 255, 0, 255, 255, 255, 0, 56, 101, 173, 255, 255, 255, 255, 0, 255, 255, 255, 0, 46, 92, 165, 255, 255, 255, 255, 0, 255, 255, 255, 0, 42, 88, 161, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
},
}
return PaintZoomGrid
end
function load_image_PaintFill()
local PaintFill = iup.imagergba
{
width = 16,
height = 16,
pixels = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 53, 53, 86, 59, 59, 59, 111, 108, 108, 108, 82, 127, 127, 127, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 54, 54, 122, 72, 72, 72, 7, 119, 122, 124, 117, 124, 124, 130, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 77, 76, 154, 144, 166, 188, 23, 158, 169, 181, 191, 144, 151, 159, 194, 134, 147, 174, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 124, 126, 129, 197, 141, 160, 183, 179, 212, 219, 225, 254, 157, 162, 166, 254, 163, 180, 200, 168, 159, 175, 191, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 130, 141, 158, 45, 130, 143, 155, 245, 218, 225, 232, 250, 222, 232, 239, 255, 136, 139, 142, 255, 205, 217, 227, 252, 148, 167, 189, 163, 155, 155, 184, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 148, 170, 24, 134, 155, 174, 172, 213, 220, 227, 254, 218, 233, 243, 255, 197, 207, 217, 255, 149, 149, 150, 255, 232, 241, 245, 255, 179, 196, 213, 252, 129, 147, 172, 164, 75, 103, 144, 37, 17, 51, 102, 15, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 134, 147, 174, 19, 122, 146, 168, 179, 216, 223, 228, 252, 217, 231, 242, 255, 213, 227, 238, 255, 159, 162, 164, 255, 128, 129, 128, 255, 228, 235, 239, 255, 171, 197, 218, 255, 136, 162, 190, 253, 87, 116, 156, 227, 37, 75, 150, 183, 0, 31, 107, 57, 0, 0, 0, 0,
0, 0, 0, 0, 120, 134, 161, 19, 126, 147, 168, 157, 209, 217, 225, 245, 217, 231, 241, 255, 203, 217, 232, 255, 242, 244, 245, 255, 192, 192, 191, 255, 164, 166, 169, 255, 202, 213, 223, 255, 158, 176, 194, 255, 126, 154, 184, 255, 103, 134, 168, 255, 76, 110, 169, 255, 49, 93, 175, 201, 37, 66, 132, 27,
122, 132, 160, 27, 102, 124, 149, 172, 194, 209, 220, 241, 213, 228, 239, 246, 204, 218, 232, 249, 241, 242, 244, 255, 247, 245, 245, 255, 243, 244, 243, 255, 222, 228, 234, 255, 192, 203, 214, 255, 159, 172, 185, 255, 138, 152, 168, 255, 84, 116, 151, 248, 74, 104, 158, 246, 83, 129, 213, 243, 77, 108, 169, 92,
125, 134, 152, 55, 111, 131, 154, 211, 189, 201, 214, 255, 214, 223, 234, 254, 238, 240, 243, 236, 248, 246, 245, 241, 242, 243, 243, 254, 221, 228, 234, 255, 192, 203, 214, 255, 165, 178, 192, 255, 142, 155, 169, 255, 98, 117, 137, 243, 77, 94, 120, 121, 46, 82, 158, 171, 87, 131, 209, 247, 85, 114, 171, 122,
0, 255, 255, 1, 134, 140, 167, 38, 137, 155, 179, 206, 218, 223, 230, 254, 244, 242, 243, 252, 242, 244, 243, 239, 220, 228, 234, 252, 192, 202, 214, 255, 164, 176, 190, 255, 140, 154, 168, 255, 92, 112, 132, 243, 75, 91, 114, 111, 102, 102, 153, 5, 29, 61, 136, 140, 68, 109, 192, 244, 84, 113, 170, 94,
0, 0, 0, 0, 0, 0, 255, 1, 157, 173, 195, 47, 148, 166, 191, 205, 204, 210, 220, 248, 227, 231, 235, 253, 193, 204, 216, 255, 163, 175, 189, 255, 138, 151, 166, 255, 95, 113, 134, 242, 74, 88, 113, 110, 95, 127, 127, 8, 0, 0, 0, 0, 35, 66, 135, 145, 72, 109, 182, 239, 91, 120, 178, 53,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 142, 165, 34, 103, 124, 151, 197, 158, 172, 187, 252, 164, 176, 189, 255, 134, 148, 162, 254, 96, 113, 133, 245, 75, 87, 110, 122, 102, 102, 102, 5, 0, 0, 0, 0, 0, 0, 0, 0, 60, 91, 151, 173, 84, 115, 173, 195, 98, 117, 176, 13,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 102, 110, 119, 30, 73, 96, 120, 204, 107, 126, 144, 255, 106, 123, 141, 255, 102, 115, 135, 152, 139, 150, 162, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 92, 154, 173, 85, 115, 173, 119, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 82, 115, 31, 49, 79, 109, 212, 92, 110, 134, 169, 143, 159, 175, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 93, 154, 163, 63, 89, 153, 20, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 118, 140, 58, 85, 106, 148, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 61, 92, 154, 33, 0, 0, 0, 0, 0, 0, 0, 0,
},
}
return PaintFill
end
function load_image_PaintText()
local PaintText = iup.imagergba
{
width = 16,
height = 16,
pixels = {
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 36, 0, 0, 0, 96, 0, 0, 0, 96, 0, 0, 0, 96, 0, 0, 0, 96, 0, 0, 0, 96, 0, 0, 0, 96, 0, 0, 0, 96, 0, 0, 0, 96, 0, 0, 0, 96, 0, 0, 0, 96, 0, 0, 0, 72, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 96, 0, 0, 0, 255, 0, 0, 0, 203, 0, 0, 0, 124, 0, 0, 0, 135, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 215, 0, 0, 0, 96, 0, 0, 0, 131, 0, 0, 0, 243, 0, 0, 0, 191, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 96, 0, 0, 0, 163, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 64, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 191, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 44, 0, 0, 0, 191, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 96, 0, 0, 0, 48, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 64, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 191, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 116, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 64, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 191, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 64, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 191, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 64, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 191, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 64, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 191, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 64, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 191, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 64, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 191, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 64, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 191, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 64, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 191, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 96, 0, 0, 0, 187, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 243, 0, 0, 0, 116, 0, 0, 0, 48, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
},
}
return PaintText
end
--********************************** Utilities *****************************************
function str_splitfilename(filename)
return string.match(filename, "(.-)([^\\/]-%.?([^%.\\/]*))$")
end
function str_fileext(filename)
local path, title, ext = str_splitfilename(filename)
return ext
end
function str_filetitle(filename)
local path, title, ext = str_splitfilename(filename)
return title
end
function show_error(message, is_error)
local dlg = iup.messagedlg{
parentdialog = iup.GetGlobal("PARENTDIALOG"),
buttons = "OK",
value = message,
}
if (is_error) then
dlg.dialogtype = "ERROR"
dlg.title = "Error"
else
dlg.dialogtype = "WARNING"
dlg.title = "Warning"
end
dlg:popup(iup.CENTERPARENT, iup.CENTERPARENT)
dlg:destroy()
end
function read_file(filename)
local image, err = im.FileImageLoadBitmap(filename, 0)
if (err) then
show_error(im.ErrorStr(err), true)
end
return image
end
function write_file(filename, image)
local format = image:GetAttribString("FileFormat")
local err = im.FileImageSave(filename, format, image)
if (err ~= im.ERR_NONE) then
show_error(im.ErrorStr(err), true)
return false
end
return true
end
-- extracted from the SCROLLBAR attribute documentation
function scrollbar_update(ih, view_width, view_height)
-- view_width and view_height is the virtual space size
-- here we assume XMIN=0, XMAX=1, YMIN=0, YMAX=1
local scrollbar_size = tonumber(iup.GetGlobal("SCROLLBARSIZE"))
local border = 1
if (ih.border ~= "YES") then
border = 0
end
local elem_width, elem_height = string.match(ih.rastersize, "(%d*)x(%d*)")
-- if view is greater than canvas in one direction,
-- then it has scrollbars,
-- but this affects the opposite direction
elem_width = elem_width - 2 * border -- remove BORDER (always size=1)
elem_height = elem_height - 2 * border
local canvas_width = elem_width
local canvas_height = elem_height
if (view_width > elem_width) then -- check for horizontal scrollbar
canvas_height = canvas_height - scrollbar_size -- affect vertical size
end
if (view_height > elem_height) then
canvas_width = canvas_width - scrollbar_size
end
if (view_width <= elem_width and view_width > canvas_width) then -- check if still has horizontal scrollbar
canvas_height = canvas_height - scrollbar_size
end
if (view_height <= elem_height and view_height > canvas_height) then
canvas_width = canvas_width - scrollbar_size
end
if (canvas_width < 0) then canvas_width = 0 end
if (canvas_height < 0) then canvas_height = 0 end
ih.dx = canvas_width / view_width
ih.dy = canvas_height / view_height
end
function scroll_calc_center(canvas)
local x = tonumber(canvas.posx) + tonumber(canvas.dx) / 2
local y = tonumber(canvas.posy) + tonumber(canvas.dy) / 2
return x, y
end
function scroll_center(canvas, old_center_x, old_center_y)
-- always update the scroll position
-- keeping it proportional to the old position
-- relative to the center of the canvas.
local dx = tonumber(canvas.dx)
local dy = tonumber(canvas.dy)
local posx = old_center_x - dx / 2
local posy = old_center_y - dy / 2
if (posx < 0) then posx = 0 end
if (posx > 1 - dx) then posx = 1 - dx end
if (posy < 0) then posy = 0 end
if (posy > 1 - dy) then posy = 1 - dy end
canvas.posx = posx
canvas.posy = posy
end
void scroll_move(Ihandle* canvas, int canvas_width, int canvas_height, int move_x, int move_y, int view_width, int view_height)
{
float posy = 0;
float posx = 0;
if (move_x == 0 && move_y == 0)
return;
if (canvas_height < view_height)
{
posy = IupGetFloat(canvas, "POSY");
posy -= (float)move_y / (float)view_height;
}
if (canvas_width < view_width)
{
posx = IupGetFloat(canvas, "POSX");
posx -= (float)move_x / (float)view_width;
}
if (posx != 0 || posy != 0)
{
IupSetFloat(canvas, "POSX", posx);
IupSetFloat(canvas, "POSY", posy);
IupUpdate(canvas);
}
}
function zoom_update(ih, zoom_index)
local zoom_lbl = iup.GetDialogChild(ih, "ZOOMLABEL")
local dlg = iup.GetDialog(ih)
local canvas = dlg.canvas
local image = canvas.image
local zoom_factor = 2^zoom_index
zoom_lbl.title = string.format("%.0f%%", math.floor(zoom_factor * 100))
if (image) then
local view_width = math.floor(zoom_factor * image:Width())
local view_height = math.floor(zoom_factor * image:Height())
local old_center_x, old_center_y = scroll_calc_center(canvas)
scrollbar_update(canvas, view_width, view_height)
scroll_center(canvas, old_center_x, old_center_y)
end
iup.Update(canvas)
end
typedef struct _xyStack
{
int x, y;
struct _xyStack* next;
} xyStack;
xyStack* xy_stack_push(xyStack* q, int x, int y)
{
xyStack* new_q = malloc(sizeof(xyStack));
new_q->x = x;
new_q->y = y;
new_q->next = q;
return new_q;
}
xyStack* xy_stack_pop(xyStack* q)
{
xyStack* next_q = q->next;
free(q);
return next_q;
}
int color_is_similar(long color1, long color2, int tol)
{
int diff_r = cdRed(color1) - cdRed(color2);
int diff_g = cdGreen(color1) - cdGreen(color2);
int diff_b = cdBlue(color1) - cdBlue(color2);
int sqr_dist = diff_r*diff_r + diff_g*diff_g + diff_b*diff_b;
/* max value = 255*255*3 = 195075 */
/* sqrt(195075)=441 */
if (sqr_dist < tol)
return 1;
else
return 0;
}
void image_flood_fill(imImage* image, int start_x, int start_y, long replace_color, double tol_percent)
{
unsigned char** data = (unsigned char**)image->data;
unsigned char *r = data[0], *g = data[1], *b = data[2];
int offset, tol, cur_x, cur_y;
long target_color, color;
xyStack* q = NULL;
offset = start_y * image->width + start_x;
target_color = cdEncodeColor(r[offset], g[offset], b[offset]);
if (target_color == replace_color)
return;
tol = (int)(441 * tol_percent) / 100;
tol = tol*tol; /* this is too high */
tol = tol / 50; /* empirical reduce. TODO: What is the best formula? */
/* very simple 4 neighbors stack based flood fill */
/* a color in the xy_stack is always similar to the target color,
and it was already replaced */
q = xy_stack_push(q, start_x, start_y);
cdDecodeColor(replace_color, r + offset, g + offset, b + offset);
while (q)
{
cur_x = q->x;
cur_y = q->y;
q = xy_stack_pop(q);
/* right */
if (cur_x < image->width - 1)
{
offset = cur_y * image->width + cur_x+1;
color = cdEncodeColor(r[offset], g[offset], b[offset]);
if (color != replace_color && color_is_similar(color, target_color, tol))
{
q = xy_stack_push(q, cur_x+1, cur_y);
cdDecodeColor(replace_color, r + offset, g + offset, b + offset);
}
}
/* left */
if (cur_x > 0)
{
offset = cur_y * image->width + cur_x-1;
color = cdEncodeColor(r[offset], g[offset], b[offset]);
if (color != replace_color && color_is_similar(color, target_color, tol))
{
q = xy_stack_push(q, cur_x-1, cur_y);
cdDecodeColor(replace_color, r + offset, g + offset, b + offset);
}
}
/* top */
if (cur_y < image->height - 1)
{
offset = (cur_y+1) * image->width + cur_x;
color = cdEncodeColor(r[offset], g[offset], b[offset]);
if (color != replace_color && color_is_similar(color, target_color, tol))
{
q = xy_stack_push(q, cur_x, cur_y+1);
cdDecodeColor(replace_color, r + offset, g + offset, b + offset);
}
}
/* bottom */
if (cur_y > 0)
{
offset = (cur_y-1) * image->width + cur_x;
color = cdEncodeColor(r[offset], g[offset], b[offset]);
if (color != replace_color && color_is_similar(color, target_color, tol))
{
q = xy_stack_push(q, cur_x, cur_y-1);
cdDecodeColor(replace_color, r + offset, g + offset, b + offset);
}
}
}
}
void image_fill_white(imImage* image)
{
unsigned char** data = (unsigned char**)image->data;
int x, y, offset;
for (y = 0; y < image->height; y++)
{
for (x = 0; x < image->width; x++)
{
offset = y * image->width + x;
data[0][offset] = 255;
data[1][offset] = 255;
data[2][offset] = 255;
}
}
}
function set_new_image(canvas, image, filename, dirty)
local dlg = iup.GetDialog(canvas)
local old_image = canvas.image
local size_lbl = iup.GetDialogChild(canvas, "SIZELABEL")
local zoom_val = iup.GetDialogChild(canvas, "ZOOMVAL")
if (filename) then
canvas.filename = filename
dlg.title = str_filetitle(filename).." - Simple Paint"
else
dlg.title = "Untitled - Simple Paint"
canvas.filename = nil
end
-- we are going to support only RGB images with no alpha
image:RemoveAlpha()
if (image:ColorSpace() ~= im.RGB) then
local new_image = im.ImageCreateBased(image, nil, nil, im.RGB, nil)
im.ConvertColorSpace(image, new_image)
image:Destroy()
image = new_image
end
-- default file format
local format = image:GetAttribString("FileFormat")
if (not format) then
image:SetAttribString("FileFormat", "JPEG")
end
canvas.dirty = dirty
canvas.image = image
size_lbl.title = image:Width().." x "..image:Height().." px"
if (old_image) then
old_image:Destroy()
end
zoom_val.value = 0
zoom_update(canvas, 0)
end
function check_new_file(dlg)
local canvas = dlg.canvas
local image = canvas.image
if (not image) then
local config = canvas.config
local width = config:GetVariableDef("NewImage", "Width", 640)
local height = config:GetVariableDef("NewImage", "Height", 480)
local image = im.ImageCreate(width, height, im.RGB, im.BYTE)
set_new_image(canvas, image, nil, nil)
end
end
function open_file(ih, filename)
local image = read_file(filename)
if (image) then
local dlg = iup.GetDialog(ih)
local canvas = dlg.canvas
local config = canvas.config
set_new_image(canvas, image, filename, nil)
config:RecentUpdate(filename)
end
end
function save_file(canvas)
if (write_file(canvas.filename, canvas.image)) then
canvas.dirty = nil
end
end
function set_file_format(image, filename)
local ext = str_fileext(filename)
ext:lower()
local format = "JPEG"
if (ext == "jpg" or ext == "jpeg") then
format = "JPEG"
elseif (ext == "bmp") then
format = "BMP"
elseif (ext == "png") then
format = "PNG"
elseif (ext == "tga") then
format = "TGA"
elseif (ext == "tif" or ext == "tiff") then
format = "TIFF"
end
image:SetAttribString("FileFormat", format)
end
function saveas_file(canvas, filename)
local image = canvas.image
set_file_format(image, filename)
if (write_file(filename, image)) then
local dlg = iup.GetDialog(canvas)
local config = canvas.config
dlg.title = str_filetitle(filename).." - Simple Paint"
canvas.filename = filename
canvas.dirty = nil
config:RecentUpdate(filename)
end
end
function save_check(ih)
local dlg = iup.GetDialog(ih)
local canvas = dlg.canvas
if (canvas.dirty) then
local resp = iup.Alarm("Warning", "File not saved! Save it now?", "Yes", "No", "Cancel")
if resp == 1 then -- save the changes and continue
save_file(canvas)
elseif resp == 3 then -- cancel
return false
else -- ignore the changes and continue
end
end
return true
end
function toggle_bar_visibility(item, bar)
if (item.value == "ON") then
bar.floating = "YES"
bar.visible = "NO"
item.value = "OFF"
else
bar.floating = "NO"
bar.visible = "YES"
item.value = "ON"
end
iup.Refresh(bar) -- refresh the dialog layout
end
function select_file(parent_dlg, is_open)
local filedlg = iup.filedlg{
extfilter="Image Files|*.bmp;*.jpg;*.png;*.tif;*.tga|All Files|*.*|",
parentdialog = parent_dlg,
directory = config:GetVariable("MainWindow", "LastDirectory"),
}
if (is_open) then
filedlg.dialogtype = "OPEN"
else
filedlg.dialogtype = "SAVE"
filedlg.file = canvas.filename
end
filedlg:popup(iup.CENTERPARENT, iup.CENTERPARENT)
if (tonumber(filedlg.status) ~= -1) then
local filename = filedlg.value
if (is_open) then
open_file(parent_dlg, filename)
else
saveas_file(canvas, filename)
end
config:SetVariable("MainWindow", "LastDirectory", filedlg.directory)
end
filedlg:destroy()
end
function view_fit_rect(canvas_width, canvas_height, image_width, image_height)
local view_width = canvas_width
local view_height = (canvas_width * image_height) / image_width
if (view_height > canvas_height) then
view_height = canvas_height
view_width = (canvas_height * image_width) / image_height
end
return view_width, view_height
end
function view_zoom_rect(ih, image_width, image_height)
local zoom_val = iup.GetDialogChild(ih, "ZOOMVAL")
local zoom_index = tonumber(zoom_val.value)
local zoom_factor = 2^zoom_index
local x, y
local posy = tonumber(ih.posy)
local posx = tonumber(ih.posx)
local canvas_width, canvas_height = string.match(ih.drawsize,"(%d*)x(%d*)")
local view_width = math.floor(zoom_factor * image:Width())
local view_height = math.floor(zoom_factor * image:Height())
if (canvas_width < view_width) then
x = math.floor(-posx * view_width)
else
x = (canvas_width - view_width) / 2
end
if (canvas_height < view_height) then
-- posy is top-bottom, CD is bottom-top.
-- invert posy reference (YMAX-DY - POSY)
dy = tonumber(canvas.dy)
posy = 1 - dy - posy
y = math.floor(-posy * view_height)
else
y = (canvas_height - view_height) / 2
end
return zoom_factor, x, y, view_width, view_height
end
int tool_get_text_enter_cb(void)
{
return IUP_CLOSE;
}
void tool_get_text(Ihandle* toolbox)
{
Ihandle *text, *dlg;
char* value = IupGetAttribute(toolbox, "TOOLTEXT");
char* font = IupGetAttribute(toolbox, "TOOLFONT");
text = IupText(NULL);
IupSetAttribute(text, "EXPAND", "YES");
IupSetStrAttribute(text, "VALUE", value);
IupSetStrAttribute(text, "FONT", font);
IupSetAttribute(text, "VISIBLECOLUMNS", "20");
dlg = IupDialog(text);
IupSetStrAttribute(dlg, "TITLE", "Enter Text:");
IupSetAttribute(dlg, "MINBOX", "NO");
IupSetAttribute(dlg, "MAXBOX", "NO");
IupSetCallback(dlg, "K_CR", (Icallback)tool_get_text_enter_cb);
IupSetAttributeHandle(dlg, "PARENTDIALOG", toolbox);
IupPopup(dlg, IUP_MOUSEPOS, IUP_MOUSEPOS);
value = IupGetAttribute(text, "VALUE");
IupSetStrAttribute(toolbox, "TOOLTEXT", value);
IupDestroy(dlg);
}
--********************************** Main (Part 1/2) *****************************************
-- create all the elements that will have callbacks in Lua prior to callbacks definition
config = iup.config{}
config.app_name = "simple_paint"
config:Load()
canvas = iup.canvas{
scrollbar = "Yes",
config = config, -- custom attribute
dirty = nil, -- custom attribute
zoomfactor = 1, -- custom attribute
dx = 0,
dy = 0,
}
item_new = iup.item{title = "&New...\tCtrl+N", image = "IUP_FileNew"}
item_open = iup.item{title = "&Open...\tCtrl+O", image = "IUP_FileOpen"}
item_save = iup.item{title="&Save\tCtrl+S"}
item_saveas = iup.item{title="Save &As...", image = "IUP_FileSave"}
item_revert = iup.item{title="&Revert"}
item_pagesetup = iup.item{title="Page Set&up..."}
item_print = iup.item{title="&Print\tCtrl+P"}
item_exit = iup.item{title="E&xit"}
item_copy = iup.item{title="&Copy\tCtrl+C", image = "IUP_EditCopy"}
item_paste = iup.item{title="&Paste\tCtrl+V", image = "IUP_EditPaste"}
item_background = iup.item{title="&Background..."}
item_zoomin = iup.item{title="Zoom &In\tCtrl++", image = "IUP_ZoomIn"}
item_zoomout = iup.item{title="Zoom &Out\tCtrl+-", image = "IUP_ZoomOut"}
item_actualsize = iup.item{title="&Actual Size\tCtrl+0", image = "IUP_ZoomActualSize"}
item_toolbar = iup.item{title="&Toobar", value="ON"}
item_statusbar = iup.item{title="&Statusbar", value="ON"}
item_help = iup.item{title="&Help..."}
item_about = iup.item{title="&About..."}
item_zoomgrid = IupItem("&Zoom Grid", NULL);
IupSetCallback(item_zoomgrid, "ACTION", (Icallback)item_zoomgrid_action_cb);
IupSetAttribute(item_zoomgrid, "VALUE", "ON");
IupSetAttribute(item_zoomgrid, "NAME", "ZOOMGRID");
item_toolbox = IupItem("&Toobox", NULL);
IupSetCallback(item_toolbox, "ACTION", (Icallback)item_toolbox_action_cb);
IupSetAttribute(item_toolbox, "NAME", "TOOLBOXMENU");
recent_menu = iup.menu{}
file_menu = iup.menu{
item_new,
item_open,
item_save,
item_saveas,
item_revert,
iup.separator{},
item_pagesetup,
item_print,
iup.separator{},
iup.submenu{title="Recent &Files", recent_menu},
iup.separator{},
item_exit
}
edit_menu = iup.menu{
item_copy,
item_paste,
}
view_menu = iup.menu{
item_zoomin,
item_zoomout,
item_actualsize,
item_zoomgrid,
iup.separator{},
item_background,
iup.separator{},
item_toolbar,
item_toolbox,
item_statusbar,
}
help_menu = iup.menu{item_help, item_about}
sub_menu_file = iup.submenu{file_menu, title = "&File"}
sub_menu_edit = iup.submenu{edit_menu, title = "&Edit"}
sub_menu_view = iup.submenu{title = "&View", view_menu}
sub_menu_help = iup.submenu{help_menu, title = "&Help"}
menu = iup.menu{
sub_menu_file,
sub_menu_edit,
sub_menu_view,
sub_menu_help,
}
--********************************** Callbacks *****************************************
function canvas:action()
local image = canvas.image
local canvas_width, canvas_height = string.match(canvas.drawsize,"(%d*)x(%d*)")
local cd_canvas = canvas.cdCanvas
canvas_width = tonumber(canvas_width)
canvas_height = tonumber(canvas_height)
cd_canvas:Activate()
-- draw the background
local background = config:GetVariableDef("MainWindow", "Background", "208 208 208")
local r, g, b = string.match(background, "(%d*) (%d*) (%d*)")
cd_canvas:Background(cd.EncodeColor(r, g, b))
cd_canvas:Clear()
-- draw the image at the center of the canvas
if (image) then
local zoom_factor, x, y, view_width, view_height = view_zoom_rect(canvas, image:Width(), image:Height())
-- black line around the image
cd_canvas:Foreground(cd.BLACK)
cd_canvas:Rect(x - 1, x + view_width, y - 1, y + view_height)
image:cdCanvasPutImageRect(cd_canvas, x, y, view_width, view_height, 0, 0, 0, 0)
if (IupConfigGetVariableInt(config, "MainWindow", "ZoomGrid"))
{
Ihandle* zoom_val = IupGetDialogChild(canvas, "ZOOMVAL");
double zoom_index = IupGetDouble(zoom_val, "VALUE");
if (zoom_index > 1)
{
int ix, iy;
double zoom_factor = pow(2, zoom_index);
cdCanvasForeground(cd_canvas, CD_GRAY);
for (ix = 0; ix < image->width; ix++)
{
int gx = (int)(ix * zoom_factor);
cdCanvasLine(cd_canvas, gx + x, y, gx + x, y + view_height);
}
for (iy = 0; iy < image->height; iy++)
{
int gy = (int)(iy * zoom_factor);
cdCanvasLine(cd_canvas, x, gy + y, x + view_width, gy + y);
}
}
}
if (IupGetAttribute(canvas, "OVERLAY"))
{
Ihandle* toolbox = (Ihandle*)IupGetAttribute(canvas, "TOOLBOX");
int start_x = IupGetInt(canvas, "START_X");
int start_y = IupGetInt(canvas, "START_Y");
int end_x = IupGetInt(canvas, "END_X");
int end_y = IupGetInt(canvas, "END_Y");
int line_width = IupGetInt(toolbox, "TOOLWIDTH");
int line_style = IupGetInt(toolbox, "TOOLSTYLE") - 1;
unsigned char r, g, b;
IupGetRGB(toolbox, "TOOLCOLOR", &r, &g, &b);
cdCanvasTransformTranslate(cd_canvas, x, y);
cdCanvasTransformScale(cd_canvas, (double)view_width / (double)image->width, view_height / (double)image->height);
cdCanvasForeground(cd_canvas, cdEncodeColor(r, g, b));
cdCanvasLineWidth(cd_canvas, line_width);
if (line_width == 1)
cdCanvasLineStyle(cd_canvas, line_style);
if (strcmp(IupGetAttribute(canvas, "OVERLAY"), "LINE") == 0)
cdCanvasLine(cd_canvas, start_x, start_y, end_x, end_y);
else if (strcmp(IupGetAttribute(canvas, "OVERLAY"), "RECT") == 0)
cdCanvasRect(cd_canvas, start_x, end_x, start_y, end_y);
else if (strcmp(IupGetAttribute(canvas, "OVERLAY"), "BOX") == 0)
cdCanvasBox(cd_canvas, start_x, end_x, start_y, end_y);
else if (strcmp(IupGetAttribute(canvas, "OVERLAY"), "ELLIPSE") == 0)
cdCanvasArc(cd_canvas, (end_x + start_x) / 2, (end_y + start_y) / 2, abs(end_x - start_x), abs(end_y - start_y), 0, 360);
else if (strcmp(IupGetAttribute(canvas, "OVERLAY"), "OVAL") == 0)
cdCanvasSector(cd_canvas, (end_x + start_x) / 2, (end_y + start_y) / 2, abs(end_x - start_x), abs(end_y - start_y), 0, 360);
else if (strcmp(IupGetAttribute(canvas, "OVERLAY"), "TEXT") == 0)
{
cdCanvasTextAlignment(cd_canvas, CD_SOUTH_WEST);
cdCanvasNativeFont(cd_canvas, IupGetAttribute(toolbox, "TOOLFONT"));
cdCanvasText(cd_canvas, end_x, end_y, IupGetAttribute(toolbox, "TOOLTEXT"));
}
cdCanvasTransform(cd_canvas, NULL);
}
end
cd_canvas:Flush()
end
function canvas:map_cb()
cd_canvas = cd.CreateCanvas(cd.IUPDBUFFER, canvas)
canvas.cdCanvas = cd_canvas
end
function canvas:unmap_cb()
local cd_canvas = canvas.cdCanvas
cd_canvas:Kill()
end
function round(x)
if (x < 0) then
return math.ceil(x - 0.5)
else
return math.floor(x + 0.5)
end
end
function item_zoomout:action()
local zoom_val = iup.GetDialogChild(self, "ZOOMVAL")
local zoom_index = tonumber(zoom_val.value)
zoom_index = zoom_index - 1
if (zoom_index < -6) then
zoom_index = -6
end
zoom_val.value = round(zoom_index) -- fixed increments when using buttons
zoom_update(self, zoom_index)
end
function item_zoomin:action()
local zoom_val = iup.GetDialogChild(self, "ZOOMVAL")
local zoom_index = tonumber(zoom_val.value)
zoom_index = zoom_index + 1
if (zoom_index > 6) then
zoom_index = 6
end
zoom_val.value = round(zoom_index) -- fixed increments when using buttons
zoom_update(self, zoom_index)
end
function item_actualsize:action()
local zoom_val = iup.GetDialogChild(self, "ZOOMVAL")
zoom_val.value = 0
zoom_update(self, 0)
end
function canvas:resize_cb()
local image = canvas.image
if (image) then
local zoom_val = iup.GetDialogChild(self, "ZOOMVAL")
local zoom_index = tonumber(zoom_val.value)
local zoom_factor = 2^zoom_index
local view_width = math.floor(zoom_factor * image:Width())
local view_height = math.floor(zoom_factor * image:Height())
local old_center_x, old_center_y = scroll_calc_center(canvas)
scrollbar_update(canvas, view_width, view_height)
scroll_center(canvas, old_center_x, old_center_y)
end
end
function canvas:wheel_cb(delta)
if (iup.GetGlobal("CONTROLKEY") == "ON") then
if (delta < 0) then
item_zoomout:action()
else
item_zoomin:action()
end
else
local posy = tonumber(canvas.posy)
posy = posy - delta * tonumber(canvas.dy) / 10
canvas.posy = posy
iup.Update(canvas)
end
end
int canvas_button_cb(Ihandle* canvas, int button, int pressed, int x, int y)
{
imImage* image = (imImage*)IupGetAttribute(canvas, "IMAGE");
if (image)
{
int cursor_x = x, cursor_y = y;
int view_x, view_y, view_width, view_height;
double zoom_factor = view_zoom_rect(canvas, image->width, image->height, &view_x, &view_y, &view_width, &view_height);
/* y is top-down in IUP */
int canvas_height = IupGetInt2(canvas, "DRAWSIZE");
y = canvas_height - y - 1;
/* inside image area */
if (x > view_x && y > view_y && x < view_x + view_width && y < view_y + view_height)
{
x -= view_x;
y -= view_y;
x = (int)(x / zoom_factor);
y = (int)(y / zoom_factor);
if (x < 0) x = 0;
if (y < 0) y = 0;
if (x > image->width - 1) x = image->width - 1;
if (y > image->height - 1) y = image->height - 1;
if (button == IUP_BUTTON1)
{
if (pressed)
{
IupSetInt(canvas, "START_X", x);
IupSetInt(canvas, "START_Y", y);
IupSetInt(canvas, "START_CURSOR_X", cursor_x);
IupSetInt(canvas, "START_CURSOR_Y", cursor_y);
}
else
{
Ihandle* toolbox = (Ihandle*)IupGetAttribute(canvas, "TOOLBOX");
int tool_index = IupGetInt(toolbox, "TOOLINDEX");
if (tool_index == 1) /* Color Picker */
{
Ihandle* color = IupGetDialogChild(toolbox, "COLOR");
unsigned char** data = (unsigned char**)image->data;
unsigned char r, g, b;
int offset;
offset = y * image->width + x;
r = data[0][offset];
g = data[1][offset];
b = data[2][offset];
IupSetRGB(color, "BGCOLOR", r, g, b);
IupSetRGB(toolbox, "TOOLCOLOR", r, g, b);
}
else if (tool_index == 2) /* Pencil */
{
int start_x = IupGetInt(canvas, "START_X");
int start_y = IupGetInt(canvas, "START_Y");
double res = IupGetDouble(NULL, "SCREENDPI") / 25.4;
unsigned char** data = (unsigned char**)image->data;
unsigned char r, g, b;
int line_width = IupGetInt(toolbox, "TOOLWIDTH");
IupGetRGB(toolbox, "TOOLCOLOR", &r, &g, &b);
/* do not use line style here */
cdCanvas* cd_canvas = cdCreateCanvasf(CD_IMAGERGB, "%dx%d %p %p %p -r%g", image->width, image->height, data[0], data[1], data[2], res);
cdCanvasForeground(cd_canvas, cdEncodeColor(r, g, b));
cdCanvasLineWidth(cd_canvas, line_width);
cdCanvasLine(cd_canvas, start_x, start_y, x, y);
cdKillCanvas(cd_canvas);
IupSetAttribute(canvas, "DIRTY", "Yes");
IupUpdate(canvas);
IupSetInt(canvas, "START_X", x);
IupSetInt(canvas, "START_Y", y);
}
else if (tool_index >= 3 && tool_index <= 8) /* Shapes */
{
if (IupGetAttribute(canvas, "OVERLAY"))
{
int start_x = IupGetInt(canvas, "START_X");
int start_y = IupGetInt(canvas, "START_Y");
int line_width = IupGetInt(toolbox, "TOOLWIDTH");
int line_style = IupGetInt(toolbox, "TOOLSTYLE") - 1;
double res = IupGetDouble(NULL, "SCREENDPI") / 25.4;
unsigned char** data = (unsigned char**)image->data;
unsigned char r, g, b;
IupGetRGB(toolbox, "TOOLCOLOR", &r, &g, &b);
cdCanvas* cd_canvas = cdCreateCanvasf(CD_IMAGERGB, "%dx%d %p %p %p -r%g", image->width, image->height, data[0], data[1], data[2], res);
cdCanvasForeground(cd_canvas, cdEncodeColor(r, g, b));
cdCanvasLineWidth(cd_canvas, line_width);
if (line_width == 1)
cdCanvasLineStyle(cd_canvas, line_style);
if (strcmp(IupGetAttribute(canvas, "OVERLAY"), "LINE") == 0)
cdCanvasLine(cd_canvas, start_x, start_y, x, y);
else if (strcmp(IupGetAttribute(canvas, "OVERLAY"), "RECT") == 0)
cdCanvasRect(cd_canvas, start_x, x, start_y, y);
else if (strcmp(IupGetAttribute(canvas, "OVERLAY"), "BOX") == 0)
cdCanvasBox(cd_canvas, start_x, x, start_y, y);
else if (strcmp(IupGetAttribute(canvas, "OVERLAY"), "ELLIPSE") == 0)
cdCanvasArc(cd_canvas, (x + start_x) / 2, (y + start_y) / 2, abs(x - start_x), abs(y - start_y), 0, 360);
else if (strcmp(IupGetAttribute(canvas, "OVERLAY"), "OVAL") == 0)
cdCanvasSector(cd_canvas, (x + start_x) / 2, (y + start_y) / 2, abs(x - start_x), abs(y - start_y), 0, 360);
else if (strcmp(IupGetAttribute(canvas, "OVERLAY"), "TEXT") == 0)
{
cdCanvasTextAlignment(cd_canvas, CD_SOUTH_WEST);
cdCanvasNativeFont(cd_canvas, IupGetAttribute(toolbox, "TOOLFONT"));
cdCanvasText(cd_canvas, x, y, IupGetAttribute(toolbox, "TOOLTEXT"));
}
cdKillCanvas(cd_canvas);
IupSetAttribute(canvas, "OVERLAY", NULL);
IupSetAttribute(canvas, "DIRTY", "Yes");
IupUpdate(canvas);
}
}
else if (tool_index == 9) /* Fill Color */
{
double tol_percent = IupGetDouble(toolbox, "TOOLFILLTOL");
unsigned char r, g, b;
IupGetRGB(toolbox, "TOOLCOLOR", &r, &g, &b);
image_flood_fill(image, x, y, cdEncodeColor(r, g, b), tol_percent);
IupSetAttribute(canvas, "DIRTY", "Yes");
IupUpdate(canvas);
}
}
}
else if (button == IUP_BUTTON3)
{
if (!pressed)
{
Ihandle* toolbox = (Ihandle*)IupGetAttribute(canvas, "TOOLBOX");
int tool_index = IupGetInt(toolbox, "TOOLINDEX");
if (tool_index == 8) /* Text */
tool_get_text(toolbox);
}
}
}
}
return IUP_DEFAULT;
}
int canvas_motion_cb(Ihandle* canvas, int x, int y, char *status)
{
imImage* image = (imImage*)IupGetAttribute(canvas, "IMAGE");
if (image)
{
int cursor_x = x, cursor_y = y;
int view_x, view_y, view_width, view_height;
double zoom_factor = view_zoom_rect(canvas, image->width, image->height, &view_x, &view_y, &view_width, &view_height);
/* y is top-down in IUP */
int canvas_height = IupGetInt2(canvas, "DRAWSIZE");
y = canvas_height - y - 1;
/* inside image area */
if (x > view_x && y > view_y && x < view_x + view_width && y < view_y + view_height)
{
Ihandle* status_lbl = IupGetDialogChild(canvas, "STATUSLABEL");
unsigned char** data = (unsigned char**)image->data;
unsigned char r, g, b;
int offset;
x -= view_x;
y -= view_y;
x = (int)(x / zoom_factor);
y = (int)(y / zoom_factor);
if (x < 0) x = 0;
if (y < 0) y = 0;
if (x > image->width - 1) x = image->width - 1;
if (y > image->height - 1) y = image->height - 1;
offset = y * image->width + x;
r = data[0][offset];
g = data[1][offset];
b = data[2][offset];
IupSetStrf(status_lbl, "TITLE", "(%4d, %4d) = %3d %3d %3d", x, y, (int)r, (int)g, (int)b);
if (iup_isbutton1(status)) /* button1 is pressed */
{
Ihandle* toolbox = (Ihandle*)IupGetAttribute(canvas, "TOOLBOX");
int tool_index = IupGetInt(toolbox, "TOOLINDEX");
if (tool_index == 0) /* Pointer */
{
int start_cursor_x = IupGetInt(canvas, "START_CURSOR_X");
int start_cursor_y = IupGetInt(canvas, "START_CURSOR_Y");
int canvas_width = IupGetInt(canvas, "DRAWSIZE");
scroll_move(canvas, canvas_width, canvas_height, cursor_x - start_cursor_x, cursor_y - start_cursor_y, view_width, view_height);
IupSetInt(canvas, "START_CURSOR_X", cursor_x);
IupSetInt(canvas, "START_CURSOR_Y", cursor_y);
}
else if (tool_index == 2) /* Pencil */
{
int start_x = IupGetInt(canvas, "START_X");
int start_y = IupGetInt(canvas, "START_Y");
double res = IupGetDouble(NULL, "SCREENDPI") / 25.4;
int line_width = IupGetInt(toolbox, "TOOLWIDTH");
IupGetRGB(toolbox, "TOOLCOLOR", &r, &g, &b);
/* do not use line style here */
cdCanvas* cd_canvas = cdCreateCanvasf(CD_IMAGERGB, "%dx%d %p %p %p -r%g", image->width, image->height, data[0], data[1], data[2], res);
cdCanvasForeground(cd_canvas, cdEncodeColor(r, g, b));
cdCanvasLineWidth(cd_canvas, line_width);
cdCanvasLine(cd_canvas, start_x, start_y, x, y);
cdKillCanvas(cd_canvas);
IupSetAttribute(canvas, "DIRTY", "Yes");
IupUpdate(canvas);
IupSetInt(canvas, "START_X", x);
IupSetInt(canvas, "START_Y", y);
}
else if (tool_index >= 3 && tool_index <= 8) /* Shapes */
{
const char* shapes[] = { "LINE", "RECT", "BOX", "ELLIPSE", "OVAL", "TEXT" };
IupSetInt(canvas, "END_X", x);
IupSetInt(canvas, "END_Y", y);
IupSetAttribute(canvas, "OVERLAY", shapes[tool_index - 3]);
IupUpdate(canvas);
}
}
}
}
return IUP_DEFAULT;
}
function zoom_valuechanged_cb(val)
local zoom_index = tonumber(val.value)
zoom_update(val, zoom_index)
end
function canvas:dropfiles_cb(filename)
if (save_check(self)) then
open_file(self, filename)
end
end
function file_menu:open_cb()
if (canvas.dirty) then
item_save.active = "YES"
else
item_save.active = "NO"
end
if (canvas.dirty and canvas.filename) then
item_revert.active = "YES"
else
item_revert.active = "NO"
end
end
function edit_menu:open_cb()
local clipboard = iup.clipboard{}
if (not clipboard.textavailable) then
item_paste.active = "NO"
else
item_paste.active = "YES"
end
clipboard:destroy()
end
function config:recent_cb()
if (save_check(self)) then
local filename = self.title
open_file(self, filename)
end
end
function item_new:action()
if save_check(self) then
local width = config:GetVariableDef("NewImage", "Width", 640)
local height = config:GetVariableDef("NewImage", "Height", 480)
local ret, new_width, new_height = iup.GetParam("New Image", nil, "Width: %i[1,]\nHeight: %i[1,]\n", width, height)
if (ret) then
local canvas = dlg.canvas
local new_image = im.ImageCreate(new_width, new_height, im.RGB, im.BYTE)
config:SetVariable("NewImage", "Width", new_width)
config:SetVariable("NewImage", "Height", new_height)
set_new_image(canvas, new_image, nil, nil)
end
end
end
function item_open:action()
if not save_check(self) then
return
end
select_file(dlg, true)
end
function item_saveas:action()
select_file(dlg, false)
end
function item_save:action()
if (not canvas.filename) then
item_saveas:action()
else
-- test again because in can be called using the hot key
if (canvas.dirty) then
save_file(canvas)
end
end
end
function item_revert:action()
open_file(self, canvas.filename)
end
function item_pagesetup:action()
local width = config:GetVariableDef("Print", "MarginWidth", 20)
local height = config:GetVariableDef("Print", "MarginHeight", 20)
local ret, new_width, new_height = iup.GetParam("Page Setup", nil, "nMargin Width (mm): %i[1,]\nnMargin Height (mm): %i[1,]\n", width, height)
if (ret) then
config:SetVariable("Print", "MarginWidth", new_width)
config:SetVariable("Print", "MarginHeight", new_height)
end
end
function item_print:action()
local title = dlg.title
local cd_canvas = cd.CreateCanvas(cd.PRINTER, title.." -d")
if (not cd_canvas) then
return
end
-- do NOT draw the background, use the paper color
-- draw the image at the center of the canvas
local image = canvas.image
if (image) then
local margin_width = config:GetVariableDef("Print", "MarginWidth", 20)
local margin_height = config:GetVariableDef("Print", "MarginHeight", 20)
local canvas_width, canvas_height, canvas_width_mm, canvas_height_mm = cd_canvas:GetSize()
-- convert to pixels
margin_width = math.floor((margin_width * canvas_width) / canvas_width_mm)
margin_height = math.floor((margin_height * canvas_height) / canvas_height_mm)
local view_width, view_height = view_fit_rect(
canvas_width - 2 * margin_width, canvas_height - 2 * margin_height,
image:Width(), image:Height())
local x = (canvas_width - view_width) / 2
local y = (canvas_height - view_height) / 2
image:cdCanvasPutImageRect(cd_canvas, x, y, view_width, view_height, 0, 0, 0, 0)
end
cd_canvas:Kill()
end
function item_exit:action()
local image = canvas.image
if not save_check(self) then
return iup.IGNORE -- to abort the CLOSE_CB callback
end
if (toolbox.visible == "YES") then
config:DialogClosed(toolbox, "Toolbox")
toolbox:hide()
end
if (image) then
image:Destroy()
end
config:DialogClosed(iup.GetDialog(self), "MainWindow")
config:Save()
config:destroy()
return iup.CLOSE
end
function item_copy:action()
local clipboard = iup.clipboard{}
clipboard.nativeimage = iup.GetImageNativeHandle(image)
clipboard:destroy()
end
function item_paste:action()
if save_check(self) then
local clipboard = iup.clipboard{}
local image = iup.GetNativeHandleImage(clipboard.nativeimage)
clipboard:destroy()
if (not image) then
show_error("Invalid Clipboard Data", 1)
return
end
set_new_image(canvas, image, nil, "Yes")
end
end
function item_background:action()
local colordlg = iup.colordlg{}
local background = config:GetVariableDef("MainWindow", "Background", "255 255 255")
colordlg.value = background
colordlg.parentdialog = iup.GetDialog(self)
colordlg:popup(iup.CENTERPARENT, iup.CENTERPARENT)
if (tonumber(colordlg.status) == 1) then
background = colordlg.value
config:SetVariable("MainWindow", "Background", background)
iup.Update(canvas)
end
colordlg:destroy()
end
int item_zoomgrid_action_cb(Ihandle* ih)
{
Ihandle* item_zoomgrid = IupGetDialogChild(ih, "ZOOMGRID");
Ihandle* canvas = IupGetDialogChild(ih, "CANVAS");
Ihandle* config = (Ihandle*)IupGetAttribute(ih, "CONFIG");
if (IupGetInt(item_zoomgrid, "VALUE"))
IupSetAttribute(item_zoomgrid, "VALUE", "OFF");
else
IupSetAttribute(item_zoomgrid, "VALUE", "ON");
IupConfigSetVariableStr(config, "MainWindow", "ZoomGrid", IupGetAttribute(item_zoomgrid, "VALUE"));
IupUpdate(canvas);
return IUP_DEFAULT;
}
function item_toolbar:action()
toggle_bar_visibility(self, toolbar)
config:SetVariable("MainWindow", "Toolbar", item_toolbar.value)
end
int item_toolbox_action_cb(Ihandle* item_toolbox)
{
Ihandle* toolbox = (Ihandle*)IupGetAttribute(item_toolbox, "TOOLBOX");
Ihandle* config = (Ihandle*)IupGetAttribute(item_toolbox, "CONFIG");
if (IupGetInt(toolbox, "VISIBLE"))
{
IupSetAttribute(item_toolbox, "VALUE", "OFF");
IupConfigDialogClosed(config, toolbox, "Toolbox");
IupHide(toolbox);
}
else
{
IupSetAttribute(item_toolbox, "VALUE", "ON");
IupConfigDialogShow(config, toolbox, "Toolbox");
}
IupConfigSetVariableStr(config, "MainWindow", "Toolbox", IupGetAttribute(item_toolbox, "VALUE"));
return IUP_DEFAULT;
}
function item_statusbar:action()
toggle_bar_visibility(self, statusbar)
config:SetVariable("MainWindow", "Statusbar", item_statusbar.value)
end
function item_help:action()
iup.Help("http://www.tecgraf.puc-rio.br/iup")
end
function item_about:action()
iup.Message("About", " Simple Paint\n\nAutors:\n Gustavo Lyrio\n Antonio Scuri")
end
int toolbox_close_cb(Ihandle* toolbox)
{
Ihandle* config = (Ihandle*)IupGetAttribute(toolbox, "CONFIG");
Ihandle* item_toolbox = (Ihandle*)IupGetAttribute(toolbox, "TOOLBOXMENU");
IupConfigDialogClosed(config, toolbox, "Toolbox");
IupSetAttribute(item_toolbox, "VALUE", "OFF");
IupConfigSetVariableStr(config, "MainWindow", "Toolbox", "OFF");
return IUP_DEFAULT;
}
int tool_action_cb(Ihandle* ih, int state)
{
if (state == 1)
{
Ihandle* canvas = (Ihandle*)IupGetAttribute(ih, "CANVAS");
int tool_index = IupGetInt(ih, "TOOLINDEX");
IupSetInt(IupGetDialog(ih), "TOOLINDEX", tool_index);
if (tool_index == 0)
IupSetAttribute(canvas, "CURSOR", "ARROW");
else
IupSetAttribute(canvas, "CURSOR", "CROSS");
if (tool_index == 8)
tool_get_text(IupGetDialog(ih));
}
return IUP_DEFAULT;
}
int toolcolor_action_cb(Ihandle* ih)
{
Ihandle* canvas = (Ihandle*)IupGetAttribute(ih, "CANVAS");
Ihandle* colordlg = IupColorDlg();
const char* color = IupGetAttribute(ih, "BGCOLOR");
IupSetStrAttribute(colordlg, "VALUE", color);
IupSetAttributeHandle(colordlg, "PARENTDIALOG", IupGetDialog(ih));
IupPopup(colordlg, IUP_CENTER, IUP_CENTER);
if (IupGetInt(colordlg, "STATUS") == 1)
{
color = IupGetAttribute(colordlg, "VALUE");
IupSetStrAttribute(ih, "BGCOLOR", color);
IupSetStrAttribute(IupGetDialog(ih), "TOOLCOLOR", color);
IupUpdate(canvas);
}
IupDestroy(colordlg);
return IUP_DEFAULT;
}
int toolwidth_valuechanged_cb(Ihandle* ih)
{
char* value = IupGetAttribute(ih, "VALUE");
IupSetStrAttribute(IupGetDialog(ih), "TOOLWIDTH", value);
return IUP_DEFAULT;
}
int toolstyle_valuechanged_cb(Ihandle* ih)
{
char* value = IupGetAttribute(ih, "VALUE");
IupSetStrAttribute(IupGetDialog(ih), "TOOLSTYLE", value);
return IUP_DEFAULT;
}
int toolfont_action_cb(Ihandle* ih)
{
Ihandle* font_dlg = IupFontDlg();
IupSetAttributeHandle(font_dlg, "PARENTDIALOG", IupGetDialog(ih));
char* font = IupGetAttribute(ih, "TOOLFONT");
IupSetStrAttribute(font_dlg, "VALUE", font);
IupPopup(font_dlg, IUP_CENTER, IUP_CENTER);
if (IupGetInt(font_dlg, "STATUS") == 1)
{
font = IupGetAttribute(font_dlg, "VALUE");
IupSetStrAttribute(IupGetDialog(ih), "TOOLFONT", font);
}
IupDestroy(font_dlg);
return IUP_DEFAULT;
}
int toolfilltol_valuechanged_cb(Ihandle* ih)
{
Ihandle* filltol_label = IupGetDialogChild(ih, "FILLTOLLABEL");
double value = IupGetDouble(ih, "VALUE");
IupSetStrf(filltol_label, "TITLE", "Tol.: %.0f%%", value);
IupSetDouble(IupGetDialog(ih), "TOOLFILLTOL", value);
return IUP_DEFAULT;
}
int main_dlg_move_cb(Ihandle* dlg, int x, int y)
{
Ihandle* toolbox = (Ihandle*)IupGetAttribute(dlg, "TOOLBOX");
int old_x = IupGetInt(dlg, "_OLD_X");
int old_y = IupGetInt(dlg, "_OLD_Y");
if (old_x == x && old_y == y)
return IUP_DEFAULT;
if (IupGetInt(toolbox, "VISIBLE"))
{
int tb_x = IupGetInt(toolbox, "X");
int tb_y = IupGetInt(toolbox, "Y");
tb_x += x - old_x;
tb_y += y - old_y;
IupShowXY(toolbox, tb_x, tb_y);
}
IupSetInt(dlg, "_OLD_X", x);
IupSetInt(dlg, "_OLD_Y", y);
return IUP_DEFAULT;
}
--********************************** Main (Part 2/2) *****************************************
void create_toolbox(Ihandle* parent_dlg, Ihandle *config)
{
Ihandle *toolbox, *gbox, *vbox;
Ihandle* item_toolbox = IupGetDialogChild(parent_dlg, "TOOLBOXMENU");
Ihandle* canvas = IupGetDialogChild(parent_dlg, "CANVAS");
IupSetHandle("PaintPointer", load_image_Pointer());
IupSetHandle("PaintColorPicker", load_image_PaintColorPicker());
IupSetHandle("PaintPencil", load_image_PaintPencil());
IupSetHandle("PaintLine", load_image_PaintLine());
IupSetHandle("PaintEllipse", load_image_PaintEllipse());
IupSetHandle("PaintRect", load_image_PaintRect());
IupSetHandle("PaintOval", load_image_PaintOval());
IupSetHandle("PaintBox", load_image_PaintBox());
IupSetHandle("PaintFill", load_image_PaintFill());
IupSetHandle("PaintText", load_image_PaintText());
gbox = IupGridBox(
IupSetCallbacks(IupSetAttributes(IupToggle(NULL, NULL), "TOOLINDEX=0, IMAGE=PaintPointer, VALUE=ON, FLAT=Yes, TIP=\"Pointer\""), "ACTION", (Icallback)tool_action_cb, NULL),
IupSetCallbacks(IupSetAttributes(IupToggle(NULL, NULL), "TOOLINDEX=1, IMAGE=PaintColorPicker, FLAT=Yes, TIP=\"Color Picker\""), "ACTION", (Icallback)tool_action_cb, NULL),
IupSetCallbacks(IupSetAttributes(IupToggle(NULL, NULL), "TOOLINDEX=2, IMAGE=PaintPencil, FLAT=Yes, TIP=\"Pencil\""), "ACTION", (Icallback)tool_action_cb, NULL),
IupSetCallbacks(IupSetAttributes(IupToggle(NULL, NULL), "TOOLINDEX=3, IMAGE=PaintLine, FLAT=Yes, TIP=\"Line\""), "ACTION", (Icallback)tool_action_cb, NULL),
IupSetCallbacks(IupSetAttributes(IupToggle(NULL, NULL), "TOOLINDEX=4, IMAGE=PaintRect, FLAT=Yes, TIP=\"Hollow Rectangle\""), "ACTION", (Icallback)tool_action_cb, NULL),
IupSetCallbacks(IupSetAttributes(IupToggle(NULL, NULL), "TOOLINDEX=5, IMAGE=PaintBox, FLAT=Yes, TIP=\"Box (Filled Rectangle)\""), "ACTION", (Icallback)tool_action_cb, NULL),
IupSetCallbacks(IupSetAttributes(IupToggle(NULL, NULL), "TOOLINDEX=6, IMAGE=PaintEllipse, FLAT=Yes, TIP=\"Hollow Ellipse\""), "ACTION", (Icallback)tool_action_cb, NULL),
IupSetCallbacks(IupSetAttributes(IupToggle(NULL, NULL), "TOOLINDEX=7, IMAGE=PaintOval, FLAT=Yes, TIP=\"Oval (Filled Ellipse)\""), "ACTION", (Icallback)tool_action_cb, NULL),
IupSetCallbacks(IupSetAttributes(IupToggle(NULL, NULL), "TOOLINDEX=8, IMAGE=PaintText, FLAT=Yes, TIP=\"Text\""), "ACTION", (Icallback)tool_action_cb, NULL),
IupSetCallbacks(IupSetAttributes(IupToggle(NULL, NULL), "TOOLINDEX=9, IMAGE=PaintFill, FLAT=Yes, TIP=\"Fill Color\""), "ACTION", (Icallback)tool_action_cb, NULL),
NULL);
IupSetAttribute(gbox, "GAPCOL", "2");
IupSetAttribute(gbox, "GAPLIN", "2");
IupSetAttribute(gbox, "MARGIN", "5x10");
IupSetAttribute(gbox, "NUMDIV", "2");
vbox = IupVbox(
IupRadio(gbox),
IupFrame(IupSetAttributes(IupVbox(
IupSetAttributes(IupLabel("Color:"), "EXPAND=HORIZONTAL"),
IupSetCallbacks(IupSetAttributes(IupButton(NULL, NULL), "NAME=COLOR, BGCOLOR=\"0 0 0\", RASTERSIZE=28x21"), "ACTION", toolcolor_action_cb, NULL),
IupSetAttributes(IupLabel("Width:"), "EXPAND=HORIZONTAL"),
IupSetCallbacks(IupSetAttributes(IupText(NULL), "SPIN=Yes, SPINMIN=1, RASTERSIZE=48x"), "VALUECHANGED_CB", toolwidth_valuechanged_cb, NULL),
IupSetAttributes(IupLabel("Style:"), "EXPAND=HORIZONTAL"),
IupSetCallbacks(IupSetAttributes(IupList(NULL), "DROPDOWN=Yes, VALUE=1, 1=\"____\", 2=\"----\", 3=\"....\", 4=\"-.-.\", 5=\"-..-..\""), "VALUECHANGED_CB", toolstyle_valuechanged_cb, NULL),
IupSetAttributes(IupLabel("Tol.: 50%"), "EXPAND=HORIZONTAL, NAME=FILLTOLLABEL"),
IupSetCallbacks(IupSetAttributes(IupVal(NULL), "NAME=FILLTOL, RASTERSIZE=60x30, VALUE=50, MAX=100"), "VALUECHANGED_CB", toolfilltol_valuechanged_cb, NULL),
IupSetAttributes(IupLabel("Font:"), "EXPAND=HORIZONTAL"),
IupSetCallbacks(IupSetAttributes(IupButton("F", NULL), "NAME=FONT, RASTERSIZE=21x21, FONT=\"Times, Bold Italic 11\""), "ACTION", toolfont_action_cb, NULL),
NULL), "MARGIN=3x2, GAP=2, ALIGNMENT=ACENTER")),
NULL);
IupSetAttribute(vbox, "NMARGIN", "2x2");
IupSetAttribute(vbox, "ALIGNMENT", "ACENTER");
toolbox = IupDialog(vbox);
IupSetAttribute(toolbox, "DIALOGFRAME", "Yes");
IupSetAttribute(toolbox, "TITLE", "Tools");
IupSetAttribute(toolbox, "FONTSIZE", "8");
IupSetAttribute(toolbox, "TOOLBOX", "Yes");
IupSetCallback(toolbox, "CLOSE_CB", (Icallback)toolbox_close_cb);
IupSetAttributeHandle(toolbox, "PARENTDIALOG", parent_dlg);
IupSetAttribute(toolbox, "TOOLCOLOR", "0 0 0");
IupSetAttribute(toolbox, "TOOLWIDTH", "1");
IupSetAttribute(toolbox, "TOOLSTYLE", "1");
IupSetAttribute(toolbox, "TOOLFILLTOL", "50");
IupSetStrAttribute(toolbox, "TOOLFONT", IupGetAttribute(parent_dlg, "FONT"));
IupSetAttribute(toolbox, "CONFIG", (char*)config);
IupSetAttribute(toolbox, "TOOLBOXMENU", (char*)item_toolbox);
IupSetAttribute(toolbox, "CANVAS", (char*)canvas);
IupSetAttribute(parent_dlg, "TOOLBOX", (char*)toolbox);
/* Initialize variables from the configuration file */
if (IupConfigGetVariableIntDef(config, "MainWindow", "Toolbox", 1))
{
/* configure the very first time to be aligned with the main window */
if (!IupConfigGetVariableStr(config, "Toolbox", "X"))
{
Ihandle* canvas = IupGetDialogChild(parent_dlg, "CANVAS");
int x = IupGetInt(canvas, "X");
int y = IupGetInt(canvas, "Y");
IupConfigSetVariableInt(config, "Toolbox", "X", x);
IupConfigSetVariableInt(config, "Toolbox", "Y", y);
}
IupSetAttribute(item_toolbox, "VALUE", "ON");
IupConfigDialogShow(config, toolbox, "Toolbox");
}
}
btn_new = iup.button{image = "IUP_FileNew", flat = "Yes", action = item_new.action, canfocus="No", tip = "New (Ctrl+N)"}
btn_open = iup.button{image = "IUP_FileOpen", flat = "Yes", action = item_open.action, canfocus="No", tip = "Open (Ctrl+O)"}
btn_save = iup.button{image = "IUP_FileSave", flat = "Yes", action = item_save.action, canfocus="No", tip = "Save (Ctrl+S)"}
btn_copy = iup.button{image = "IUP_EditCopy", flat = "Yes", action = item_copy.action, canfocus="No", tip = "Copy (Ctrl+C)"}
btn_paste = iup.button{image = "IUP_EditPaste", flat = "Yes", action = item_paste.action, canfocus="No", tip = "Paste (Ctrl+V)"}
btn_zoomgrid = IupButton(NULL, NULL);
IupSetAttribute(btn_zoomgrid, "IMAGE", "PaintZoomGrid");
IupSetAttribute(btn_zoomgrid, "FLAT", "Yes");
IupSetCallback(btn_zoomgrid, "ACTION", (Icallback)item_zoomgrid_action_cb);
IupSetAttribute(btn_zoomgrid, "TIP", "Zoom Grid");
IupSetAttribute(btn_paste, "CANFOCUS", "No");
toolbar = iup.hbox{
btn_new,
btn_open,
btn_save,
iup.label{separator="VERTICAL"},
btn_copy,
btn_paste,
iup.label{separator="VERTICAL"},
margin = "5x5",
btn_zoomgrid,
gap = 2,
}
statusbar = iup.hbox{
iup.label{title = "(0, 0) = 0 0 0", expand="HORIZONTAL", padding="10x5"},
iup.label{separator="VERTICAL"},
iup.label{title = "0 x 0", size="70x", padding="10x5", name="SIZELABEL", alignment="ACENTER"},
iup.label{SEPARATOR="VERTICAL"},
iup.label{title = "100%", size="30x", padding="10x5", name="ZOOMLABEL", alignment="ARIGHT"},
iup.button{IMAGE="IUP_ZoomOut", flat="Yes", tip="Zoom Out (Ctrl+-)", action = item_zoomout.action},
iup.val{value=0, min=-6, max=6, rastersize="150x25", name="ZOOMVAL", valuechanged_cb = zoom_valuechanged_cb},
iup.button{image="IUP_ZoomIn", flat="Yes", tip="Zoom In (Ctrl++)", action = item_zoomin.action},
iup.button{image="IUP_ZoomActualSize", flat="Yes", tip="Actual Size (Ctrl+0)", action = item_actualsize.action},
alignment = "ACENTER",
}
vbox = iup.vbox{
toolbar,
canvas,
statusbar,
}
dlg = iup.dialog{
vbox,
title = "Simple Paint",
size = "HALFxHALF",
menu = menu,
close_cb = item_exit.action,
canvas = canvas,
dropfiles_cb = canvas.dropfiles_cb,
}
function dlg:k_any(c)
if (c == iup.K_cN) then
item_new:action()
elseif (c == iup.K_cO) then
item_open:action()
elseif (c == iup.K_cS) then
item_save:action()
elseif (c == iup.K_cV) then
item_paste:action()
elseif (c == iup.K_cC) then
item_copy:action()
elseif (c == iup.K_cP) then
item_print:action()
elseif (c == iup.K_cMinus) then
item_zoomout:action()
elseif (c == iup.K_cPlus or c == iup.K_cEqual) then
item_zoomin:action()
elseif (c == iup.K_c0) then
item_actualsize:action()
end
end
-- parent for pre-defined dialogs in closed functions (IupMessage and IupAlarm)
iup.SetGlobal("PARENTDIALOG", iup.SetHandleName(dlg))
-- Initialize variables from the configuration file
config:RecentInit(recent_menu, 10)
local show_statusbar = config:GetVariableDef("MainWindow", "Statusbar", "ON")
if (show_statusbar == "OFF") then
item_statusbar.value = "OFF"
statusbar.floating = "YES"
statusbar.visible = "NO"
end
local show_toolbar = config:GetVariableDef("MainWindow", "Toolbar", "ON")
if (show_toolbar == "OFF") then
item_toolbar.value = "OFF"
toolbar.floating = "YES"
toolbar.visible = "NO"
end
local show_toolbox = config:GetVariableDef("MainWindow", "Toolbox", "ON")
if (show_toolbox == "OFF") then
/* configure the very first time to be aligned with the main window */
if (!IupConfigGetVariableStr(config, "Toolbox", "X"))
{
Ihandle* canvas = IupGetDialogChild(parent_dlg, "CANVAS");
int x = IupGetInt(canvas, "X");
int y = IupGetInt(canvas, "Y");
IupConfigSetVariableInt(config, "Toolbox", "X", x);
IupConfigSetVariableInt(config, "Toolbox", "Y", y);
}
IupSetAttribute(item_toolbox, "VALUE", "ON");
IupConfigDialogShow(config, toolbox, "Toolbox");
end
-- show the dialog at the last position, with the last size
config:DialogShow(dlg, "MainWindow")
-- open a file from the command line (allow file association in Windows)
if (arg and arg[1]) then
filename = arg[1]
open_file(dlg, filename)
end
-- initialize the current file, if not already loaded
check_new_file(dlg)
-- to be able to run this script inside another context
if (iup.MainLoopLevel()==0) then
iup.MainLoop()
iup.Close()
end
|
---------------------------------------------------------------------------
-- lm_monst.lua
-- Create a monster on certain events
--------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- This marker creates a monster on certain events. It uses the following
-- parameters:
--
-- * death_monster: The name of the monster who's death triggers the creation
-- of the new monster.
--
-- * new_monster: The name of the monster to create.
--
-- * message: Message to give when monster is created, regardless of whether
-- or not the player can see the marker.
--
-- * message_seen: Message to give if the player can see the marker.
--
-- * message_unseen: Message to give if the player can't see the marker.
--
-- NOTE: If the feature where the marker is isn't habitable by the new monster,
-- the feature will be changed to the monster's primary habitat.
-------------------------------------------------------------------------------
-- TODO:
-- * Place more than one monster.
-- * Place monster displaced from marker.
-- * Be triggered more than once.
require('dlua/lm_trig.lua')
MonsterOnTrigger = util.subclass(Triggerable)
MonsterOnTrigger.CLASS = "MonsterOnTrigger"
function MonsterOnTrigger:new(pars)
pars = pars or { }
if not pars.new_monster or pars.new_monster == "" then
error("Must provide new_monster")
end
pars.message_seen = pars.message_seen or pars.message or ""
pars.message_unseen = pars.message_unseen or pars.message or ""
local mot = self.super.new(self)
mot.message_seen = pars.message_seen
mot.message_unseen = pars.message_unseen
mot.death_monster = pars.death_monster
mot.new_monster = pars.new_monster
mot.props = util.cathash(mot.props or { }, pars)
return mot
end
function MonsterOnTrigger:write(marker, th)
MonsterOnTrigger.super.write(self, marker, th)
file.marshall(th, self.message_seen)
file.marshall(th, self.message_unseen)
file.marshall(th, self.new_monster)
lmark.marshall_table(th, self.props)
end
function MonsterOnTrigger:read(marker, th)
MonsterOnTrigger.super.read(self, marker, th)
self.message_seen = file.unmarshall_string(th)
self.message_unseen = file.unmarshall_string(th)
self.new_monster = file.unmarshall_string(th)
self.props = lmark.unmarshall_table(th)
setmetatable(self, MonsterOnTrigger)
return self
end
function MonsterOnTrigger:on_trigger(triggerer, marker, ev)
local x, y = marker:pos()
local you_x, you_y = you.pos()
if x == you_x and y == you_y then
return
end
if dgn.mons_at(x, y) then
return
end
local wanted_feat = self.props.monster_place_feature
if wanted_feat and wanted_feat ~= dgn.grid(x, y) then
return
end
local see_cell = you.see_cell(x, y)
if (not dgn.create_monster(x, y, self.new_monster)) then
return
elseif self.message_seen ~= "" and see_cell then
crawl.mpr(self.message_seen)
elseif self.message_unseen ~= "" and not see_cell then
crawl.mpr(self.message_unseen)
end
self:remove(marker)
end
function monster_on_death(pars)
local death_monster = pars.death_monster or pars.target
pars.death_monster = nil
pars.target = nil
local mod = MonsterOnTrigger:new(pars)
mod:add_triggerer(
DgnTriggerer:new {
type = "monster_dies",
target = death_monster
}
)
return mod
end
|
------------------------------------------------------------------------------------------------------
-- Local variables
------------------------------------------------------------------------------------------------------
local Cryolysis3 = Cryolysis3;
local L = LibStub("AceLocale-3.0"):GetLocale("Cryolysis3");
------------------------------------------------------------------------------------------------------
-- Slash Options
------------------------------------------------------------------------------------------------------
Cryolysis3.slashopts = {
type = "group",
args = {
menu = {
type = "execute",
name = L["Show Menu"],
desc = L["Open the configuration menu."],
func = function()
Cryolysis3:OpenMenu();
end
}
}
};
------------------------------------------------------------------------------------------------------
-- Menu options
------------------------------------------------------------------------------------------------------
Cryolysis3.options = {
name = "Cryolysis 3",
type = 'group',
args = {
gen = {
type = "group",
name = L["General Settings"],
desc = L["Adjust various settings for Cryolysis 3."],
order = 10,
args = {
lock = {
type = "toggle",
name = L["Lock Sphere and Buttons"],
desc = L["Lock the main sphere and buttons so they can't be moved."],
width = "full",
get = function(info) return Cryolysis3.db.char.lockSphere; end,
set = function(info, v) Cryolysis3.db.char.lockSphere = v; end,
order = 10
},
constrict = {
type = "toggle",
name = L["Constrict Buttons to Sphere"],
desc = L["Lock the buttons in place around the main sphere."],
width = "full",
get = function(info) return Cryolysis3.db.char.lockButtons end,
set = function(info, v)
Cryolysis3.db.char.lockButtons = v;
Cryolysis3:UpdateAllButtonPositions();
end,
order = 20
},
tooltips = {
type = "toggle",
name = L["Hide Tooltips"],
desc = L["Hide the main sphere and button tooltips."],
get = function(info) return Cryolysis3.db.char.HideTooltips; end,
set = function(info, v) Cryolysis3.db.char.HideTooltips = v; end,
order = 30
},
quiet = {
type = "toggle",
name = L["Silent Mode"],
desc = L["Hide the information messages on AddOn/module load/disable."],
get = function(info) return Cryolysis3.db.char.silentMode; end,
set = function(info, v) Cryolysis3.db.char.silentMode = v; end,
order = 35
},
skinSelect = {
type = "select",
name = L["Sphere Skin"],
desc = L["Choose the skin displayed by the Cryolysis sphere."],
width = "full",
get = function(info) return Cryolysis3.db.char.skin; end,
set = function(info, v)
Cryolysis3.db.char.skin = v;
Cryolysis3:UpdateSphere("outerSphere");
end,
values = {
["666"] = "666",
["Blue"] = "Blue",
["Orange"] = "Orange",
["Rose"] = "Rose",
["Turquoise"] = "Turquoise",
["Violet"] = "Violet",
["X"] = "X"
},
order = 40
},
outsphere = {
type = "select",
name = L["Outer Sphere Skin Behavior"],
desc = L["Choose how fast you want the outer sphere skin to deplete/replenish."],
width = "full",
get = function(info) return Cryolysis3.db.char.outerSphereSkin end,
set = function(info, v)
Cryolysis3.db.char.outerSphereSkin = v;
Cryolysis3:UpdateSphere("outerSphere");
end,
values = {
L["Slow"],
L["Fast"]
},
order = 50
},
}
},
graphicalsettings = {
type = "group",
name = L["Button Settings"],
desc = L["Adjust various settings for each button."],
order = 20,
args = {
middlekey = {
type = "select",
name = L["Middle-Click Key"],
desc = L["Adjusts the key used as an alternative to a middle click."],
width = "full",
get = function(info) return Cryolysis3.db.char.middleKey end,
set = function(info, v)
Cryolysis3.db.char.middleKey = v;
Cryolysis3:ChangeMiddleKey();
end,
order = 10,
values = {
["alt"] = L["Alt"],
["shift"] = L["Shift"],
["ctrl"] = L["Ctrl"]
}
},
msbutton = {
type = "group",
name = L["Main Sphere"],
desc = L["Adjust various settings for the main sphere."],
order = 20,
args = {
mshide = {
type = "toggle",
name = L["Hide"],
desc = L["Show or hide the main sphere."],
width = "full",
get = function(info) return Cryolysis3.db.char.hidden["Sphere"] end,
set = function(info, v)
Cryolysis3.db.char.hidden["Sphere"] = v;
Cryolysis3:UpdateVisibility();
end,
order = 10
},
insphere = {
type = "select",
name = L["Sphere Text"],
desc = L["Adjust what information is displayed on the sphere."],
width = "full",
get = function(info) return Cryolysis3.db.char.sphereText end,
set = function(info, v)
Cryolysis3.db.char.sphereText = v;
Cryolysis3:UpdateSphere("sphereText");
end,
values = {
L["Nothing"],
L["Current Health"],
L["Health %"],
L["Current Mana/Energy/Rage"],
L["Mana/Energy/Rage %"]
},
order = 20
},
outsphere = {
type = "select",
name = L["Outer Sphere"],
desc = L["Adjust what information is displayed using the outer sphere."],
width = "full",
get = function(info) return Cryolysis3.db.char.outerSphere end,
set = function(info, v)
Cryolysis3.db.char.outerSphere = v;
Cryolysis3:UpdateSphere("outerSphere");
end,
values = {
L["Nothing"],
L["Health"],
L["Mana"],
},
order = 25
},
--[[
spheremb = {
type = "select",
name = L["Inner Sphere"],
desc = L["Adjust what clicking the inner sphere does."],
width = "full",
get = function(info) return Cryolysis3.db.char.sphereAttribute end,
set = function(info, v)
Cryolysis3.db.char.sphereAttribute = v;
Cryolysis3:UpdateSphereAttributes();
end,
values = {
L["Nothing"],
L["Eat and drink"]
},
order = 40
},
angleadj = {
type = "range",
name = L["Angle"],
desc = L["Adjust the position of the buttons around the sphere."],
width = "full",
get = function(info) return Cryolysis3.db.char.angle end,
set = function(info, v)
Cryolysis3.db.char.angle = v;
Cryolysis3:UpdateAllButtonPositions();
end,
min = 0,
max = 360,
step = 18,
order = 50
}, ]]
scalems = {
type = "range",
name = L["Scale"],
desc = L["Scale the size of the main sphere."],
width = "full",
get = function(info) return Cryolysis3.db.char.scale.frame["Sphere"] end,
set = function(info, v)
Cryolysis3.db.char.scale.frame["Sphere"] = v;
Cryolysis3:UpdateScale("frame", "Sphere", v)
--Cryolysis3:UpdateAllButtonPositions();
--Cryolysis3:UpdateAllButtonSizes();
end,
min = .5,
max = 2,
step = .1,
isPercent = true,
order = 90
},
buttontype = {
type = "select",
name = L["Button Type"],
desc = L["Choose whether this button casts a spell, uses a macro, or uses an item."],
width = "full",
get = function(info) return Cryolysis3.db.char.buttonTypes["Sphere"] end,
set = function(info, v)
Cryolysis3.db.char.buttonTypes["Sphere"] = v;
end,
values = {
["spell"] = L["Spell"],
["macro"] = L["Macro"],
["item"] = L["Item"]
},
order = 30
},
leftclick = {
type = "input",
name = L["Left Click Action"],
desc = L["Type in the name of the action that will be cast when left clicking this button."],
usage = L["Enter a spell, macro, or item name and PRESS ENTER. Capitalization matters."],
get = function(info) return Cryolysis3.db.char.buttonFunctions["Sphere"].left; end,
set = function(info, v)
Cryolysis3.db.char.buttonFunctions["Sphere"].left = v;
Cryolysis3:UpdateButton("Sphere", "left");
end,
order = 40
},
--~ rightclick = {
--~ type = "input",
--~ name = L["Right Click Action"],
--~ desc = L["Type in the name of the action that will be cast when right clicking this button."],
--~ usage = L["Enter a spell, macro, or item name and PRESS ENTER. Capitalization matters."],
--~ get = function(info) return Cryolysis3.db.char.buttonFunctions["Sphere"].right; end,
--~ set = function(info, v)
--~ Cryolysis3.db.char.buttonFunctions["Sphere"].right = v;
--~ Cryolysis3:UpdateButton("Sphere", "right");
--~ end,
--~ order = 50
--~ },
middleclick = {
type = "input",
name = L["Middle Click Action"],
desc = L["Type in the name of the action that will be cast when middle clicking this button."],
usage = L["Enter a spell, macro, or item name and PRESS ENTER. Capitalization matters."],
get = function(info) return Cryolysis3.db.char.buttonFunctions["Sphere"].middle; end,
set = function(info, v)
Cryolysis3.db.char.buttonFunctions["Sphere"].middle = v;
Cryolysis3:UpdateButton("Sphere", "middle");
end,
order = 60
},
--~ scalebuttons = {
--~ type = "range",
--~ name = L["Scale All Buttons"],
--~ desc = L["Scale the size of all of the buttons at once."],
--~ width = "full",
--~ get = function(info) return Cryolysis3.db.char.buttonScale end,
--~ set = function(info, v)
--~ Cryolysis3.db.char.buttonScale = v;
--~ Cryolysis3:UpdateAllButtonPositions();
--~ Cryolysis3:UpdateAllButtonSizes();
--~ end,
--~ min = .5,
--~ max = 2,
--~ step = .1,
--~ isPercent = true,
--~ order = 70
--~ }
}
},
custom1 = {
type = "group",
name = L["First Custom Button"],
desc = L["Adjust various settings for this button."],
order = 30,
args = {
hidecustom1 = {
type = "toggle",
name = L["Hide"],
desc = L["Show or hide this button."],
width = "full",
get = function(info) return Cryolysis3.db.char.hidden["CustomButton1"] end,
set = function(info, v)
Cryolysis3.db.char.hidden["CustomButton1"] = v;
Cryolysis3:UpdateVisibility();
end,
order = 10
},
movecustom1 = {
type = "execute",
name = L["Move Clockwise"],
desc = L["Move this button one position clockwise."],
func = function() Cryolysis3:IncrementButton("CustomButton1"); end,
order = 20
},
buttontypecustom1 = {
type = "select",
name = L["Button Type"],
desc = L["Choose whether this button casts a spell, uses a macro, or uses an item."],
width = "full",
get = function(info) return Cryolysis3.db.char.buttonTypes["CustomButton1"] end,
set = function(info, v)
Cryolysis3.db.char.buttonTypes["CustomButton1"] = v;
end,
values = {
["spell"] = L["Spell"],
["macro"] = L["Macro"],
["item"] = L["Item"]
},
order = 30
},
leftclickcustom1 = {
type = "input",
name = L["Left Click Action"],
desc = L["Type in the name of the action that will be cast when left clicking this button."],
usage = L["Enter a spell, macro, or item name and PRESS ENTER. Capitalization matters."],
get = function(info) return Cryolysis3.db.char.buttonFunctions["CustomButton1"].left; end,
set = function(info, v)
Cryolysis3.db.char.buttonFunctions["CustomButton1"].left = v;
Cryolysis3:UpdateButton("CustomButton1", "left");
end,
order = 40
},
rightclickcustom1 = {
type = "input",
name = L["Right Click Action"],
desc = L["Type in the name of the action that will be cast when right clicking this button."],
usage = L["Enter a spell, macro, or item name and PRESS ENTER. Capitalization matters."],
get = function(info) return Cryolysis3.db.char.buttonFunctions["CustomButton1"].right; end,
set = function(info, v)
Cryolysis3.db.char.buttonFunctions["CustomButton1"].right = v;
Cryolysis3:UpdateButton("CustomButton1", "right");
end,
order = 50
},
middleclickcustom1 = {
type = "input",
name = L["Middle Click Action"],
desc = L["Type in the name of the action that will be cast when middle clicking this button."],
usage = L["Enter a spell, macro, or item name and PRESS ENTER. Capitalization matters."],
get = function(info) return Cryolysis3.db.char.buttonFunctions["CustomButton1"].middle; end,
set = function(info, v)
Cryolysis3.db.char.buttonFunctions["CustomButton1"].middle = v;
Cryolysis3:UpdateButton("CustomButton1", "middle");
end,
order = 60
},
scalecustom1 = {
type = "range",
name = L["Scale"],
desc = L["Scale the size of this button."],
width = "full",
get = function(info) return Cryolysis3.db.char.scale.button["CustomButton1"]; end,
set = function(info, v)
Cryolysis3.db.char.scale.button["CustomButton1"] = v;
Cryolysis3:UpdateScale("button", "CustomButton1", v)
--Cryolysis3:UpdateAllButtonPositions()
--Cryolysis3:UpdateAllButtonSizes()
end,
min = .5,
max = 2,
step = .1,
isPercent = true,
order = 70
}
}
},
custom2 = {
type = "group",
name = L["Second Custom Button"],
desc = L["Adjust various settings for this button."],
order = 30,
args = {
hidecustom2 = {
type = "toggle",
name = L["Hide"],
desc = L["Show or hide this button."],
width = "full",
get = function(info) return Cryolysis3.db.char.hidden["CustomButton2"] end,
set = function(info, v)
Cryolysis3.db.char.hidden["CustomButton2"] = v;
Cryolysis3:UpdateVisibility();
end,
order = 10
},
movecustom2 = {
type = "execute",
name = L["Move Clockwise"],
desc = L["Move this button one position clockwise."],
func = function() Cryolysis3:IncrementButton("CustomButton2"); end,
order = 20
},
buttontypecustom2 = {
type = "select",
name = L["Button Type"],
desc = L["Choose whether this button casts a spell, uses a macro, or uses an item."],
width = "full",
get = function(info) return Cryolysis3.db.char.buttonTypes["CustomButton2"] end,
set = function(info, v)
Cryolysis3.db.char.buttonTypes["CustomButton2"] = v;
end,
values = {
["spell"] = L["Spell"],
["macro"] = L["Macro"],
["item"] = L["Item"]
},
order = 30
},
leftclickcustom2 = {
type = "input",
name = L["Left Click Action"],
desc = L["Type in the name of the action that will be cast when left clicking this button."],
usage = L["Enter a spell, macro, or item name and PRESS ENTER. Capitalization matters."],
get = function(info) return Cryolysis3.db.char.buttonFunctions["CustomButton2"].left; end,
set = function(info, v)
Cryolysis3.db.char.buttonFunctions["CustomButton2"].left = v;
Cryolysis3:UpdateButton("CustomButton2", "left");
end,
order = 40
},
rightclickcustom2 = {
type = "input",
name = L["Right Click Action"],
desc = L["Type in the name of the action that will be cast when right clicking this button."],
usage = L["Enter a spell, macro, or item name and PRESS ENTER. Capitalization matters."],
get = function(info) return Cryolysis3.db.char.buttonFunctions["CustomButton2"].right; end,
set = function(info, v)
Cryolysis3.db.char.buttonFunctions["CustomButton2"].right = v;
Cryolysis3:UpdateButton("CustomButton2", "right");
end,
order = 50
},
middleclickcustom2 = {
type = "input",
name = L["Middle Click Action"],
desc = L["Type in the name of the action that will be cast when middle clicking this button."],
usage = L["Enter a spell, macro, or item name and PRESS ENTER. Capitalization matters."],
get = function(info) return Cryolysis3.db.char.buttonFunctions["CustomButton2"].middle; end,
set = function(info, v)
Cryolysis3.db.char.buttonFunctions["CustomButton2"].middle = v;
Cryolysis3:UpdateButton("CustomButton2", "middle");
end,
order = 60
},
scalecustom2 = {
type = "range",
name = L["Scale"],
desc = L["Scale the size of this button."],
width = "full",
get = function(info) return Cryolysis3.db.char.scale.button["CustomButton2"]; end,
set = function(info, v)
Cryolysis3.db.char.scale.button["CustomButton2"] = v;
Cryolysis3:UpdateScale("button", "CustomButton2", v)
--Cryolysis3:UpdateAllButtonPositions()
--Cryolysis3:UpdateAllButtonSizes()
end,
min = .5,
max = 2,
step = .1,
isPercent = true,
order = 70
}
}
},
custom3 = {
type = "group",
name = L["Third Custom Button"],
desc = L["Adjust various settings for this button."],
order = 30,
args = {
hidecustom3 = {
type = "toggle",
name = L["Hide"],
desc = L["Show or hide this button."],
width = "full",
get = function(info) return Cryolysis3.db.char.hidden["CustomButton3"] end,
set = function(info, v)
Cryolysis3.db.char.hidden["CustomButton3"] = v;
Cryolysis3:UpdateVisibility();
end,
order = 10
},
movecustom3 = {
type = "execute",
name = L["Move Clockwise"],
desc = L["Move this button one position clockwise."],
func = function() Cryolysis3:IncrementButton("CustomButton3"); end,
order = 20
},
buttontypecustom3 = {
type = "select",
name = L["Button Type"],
desc = L["Choose whether this button casts a spell, uses a macro, or uses an item."],
width = "full",
get = function(info) return Cryolysis3.db.char.buttonTypes["CustomButton3"] end,
set = function(info, v)
Cryolysis3.db.char.buttonTypes["CustomButton3"] = v;
end,
values = {
["spell"] = L["Spell"],
["macro"] = L["Macro"],
["item"] = L["Item"]
},
order = 30
},
leftclickcustom3 = {
type = "input",
name = L["Left Click Action"],
desc = L["Type in the name of the action that will be cast when left clicking this button."],
usage = L["Enter a spell, macro, or item name and PRESS ENTER. Capitalization matters."],
get = function(info) return Cryolysis3.db.char.buttonFunctions["CustomButton3"].left; end,
set = function(info, v)
Cryolysis3.db.char.buttonFunctions["CustomButton3"].left = v;
Cryolysis3:UpdateButton("CustomButton3", "left");
end,
order = 40
},
rightclickcustom3 = {
type = "input",
name = L["Right Click Action"],
desc = L["Type in the name of the action that will be cast when right clicking this button."],
usage = L["Enter a spell, macro, or item name and PRESS ENTER. Capitalization matters."],
get = function(info) return Cryolysis3.db.char.buttonFunctions["CustomButton3"].right; end,
set = function(info, v)
Cryolysis3.db.char.buttonFunctions["CustomButton3"].right = v;
Cryolysis3:UpdateButton("CustomButton3", "right");
end,
order = 50
},
middleclickcustom3 = {
type = "input",
name = L["Middle Click Action"],
desc = L["Type in the name of the action that will be cast when middle clicking this button."],
usage = L["Enter a spell, macro, or item name and PRESS ENTER. Capitalization matters."],
get = function(info) return Cryolysis3.db.char.buttonFunctions["CustomButton3"].middle; end,
set = function(info, v)
Cryolysis3.db.char.buttonFunctions["CustomButton3"].middle = v;
Cryolysis3:UpdateButton("CustomButton3", "middle");
end,
order = 60
},
scalecustom3 = {
type = "range",
name = L["Scale"],
desc = L["Scale the size of this button."],
width = "full",
get = function(info) return Cryolysis3.db.char.scale.button["CustomButton3"]; end,
set = function(info, v)
Cryolysis3.db.char.scale.button["CustomButton3"] = v;
Cryolysis3:UpdateScale("button", "CustomButton3", v)
--Cryolysis3:UpdateAllButtonPositions()
--Cryolysis3:UpdateAllButtonSizes()
end,
min = .5,
max = 2,
step = .1,
isPercent = true,
order = 70
}
}
},
mount = {
type = "group",
name = L["Mount Button"],
desc = L["Adjust various settings for this button."],
order = 40,
args = {
hidemount = {
type = "toggle",
name = L["Hide"],
desc = L["Show or hide this button."],
width = "full",
get = function(info) return Cryolysis3.db.char.hidden["MountButton"] end,
set = function(info, v)
Cryolysis3.db.char.hidden["MountButton"] = v;
Cryolysis3:UpdateVisibility();
end,
order = 5
},
mode = {
type = "select",
name = L["Button Behavior"],
width = "full",
get = function(info) return Cryolysis3.db.char.mountBehavior; end,
set = function(info, v)
Cryolysis3.db.char.mountBehavior = v;
if v == 1 then
Cryolysis3.options.args.graphicalsettings.args.mount.args.left.name = L["Left Click Mount"];
Cryolysis3.db.char.leftMountText = L["Left Click Mount"];
Cryolysis3.options.args.graphicalsettings.args.mount.args.right.name = L["Right Click Mount"];
Cryolysis3.db.char.rightMountText = L["Right Click Mount"];
else
Cryolysis3.options.args.graphicalsettings.args.mount.args.left.name = L["Ground Mount"];
Cryolysis3.db.char.leftMountText = L["Ground Mount"];
Cryolysis3.options.args.graphicalsettings.args.mount.args.right.name = L["Flying Mount"];
Cryolysis3.db.char.rightMountText = L["Flying Mount"];
end
Cryolysis3:UpdateMountButtonMacro();
end,
values = {L["Manual"], L["Automatic"]},
order = 7
},
left = {
type = "select",
name = function() return Cryolysis3.db.char.leftMountText end,
width = "full",
get = function(info) return Cryolysis3.db.char.chosenMount.normal; end,
set = function(info, v)
Cryolysis3.db.char.chosenMount.normal = v;
Cryolysis3:UpdateMountButtonMacro();
end,
values = function() return Cryolysis3.Private.mounts; end,
order = 10
},
right = {
type = "select",
name = function() return Cryolysis3.db.char.rightMountText end,
width = "full",
get = function(info) return Cryolysis3.db.char.chosenMount.flying; end,
set = function(info, v)
Cryolysis3.db.char.chosenMount.flying = v;
Cryolysis3:UpdateMountButtonMacro();
end,
values = function() return Cryolysis3.Private.mounts; end,
order = 15
},
movemountbutton = {
type = "execute",
name = L["Move Clockwise"],
desc = L["Move this button one position clockwise."],
func = function() Cryolysis3:IncrementButton("MountButton"); end,
order = 20
},
rescanmount = {
type = "execute",
name = L["Re-scan Mounts"],
desc = L["Click this when you've added new mounts to your bags."],
func = function() Cryolysis3:FindMounts(true); end,
order = 25
},
scalebuffbutton = {
type = "range",
name = L["Scale"],
desc = L["Scale the size of this button."],
width = "full",
get = function(info) return Cryolysis3.db.char.scale.button["MountButton"]; end,
set = function(info, v)
Cryolysis3.db.char.scale.button["MountButton"] = v;
Cryolysis3:UpdateScale("button", "MountButton", v)
--Cryolysis3:UpdateAllButtonPositions()
--Cryolysis3:UpdateAllButtonSizes()
end,
min = .5,
max = 2,
step = .1,
isPercent = true,
order = 70
}
}
},
},
},
modules = {
type = "group",
name = L["Modules Options"],
desc = L["Cryolysis allows you to enable and disable parts of it. This section gives you the ability to do so."],
order = 20,
args = {
}
},
profile = {
type = "group",
order = 25,
name = L["Profile Options"],
args = {
desc = {
order = 1,
type = "description",
name = L["Cryolysis' saved variables are organized so you can have shared options across all your characters, while having different sets of custom buttons for each. These options sections allow you to change the saved variable configurations so you can set up per-character options, or even share custom button setups between characters"],
}
}
}
}
}
|
-- function readCSV(filename, itemnames)
-- read CSV file if itemnames is set, use the first line as item name
-- returns table[1..nlines] of tables with items,
-- and returns table with ordered heading (needed to rewrite)
-- function writeCSV(t, filename, heads)
-- write table t as CSV file; if heads passed use heads as first line and
-- each row in t contains names items; if not it contains numbered items
-- mvh 20151126 Fix for tables with empty header cells
-- mvh 20151130 Fix for tables with booleans
-- mvh/AM 20160329 Fix for using ulua
-- mvh 20160907 Convert to number if possible, local f; support reading bool and nil
-- mvh 20170524 Note: readCSV(file, false) does not return unstructured table
-- mvh 20180105 Fix reading unstructured CSV file
-- mvh+amw 20180209 Fix reading structured CSV file
function escapeCSV (s)
if s==nil or s=='nil' then
return nil
end
if type(s)~='string' then
s = tostring(s)
end
if string.find(s, '[,"]') then
s = '"' .. string.gsub(s, '"', '""') .. '"'
end
return s
end
-- Convert from CSV string to table (converts a single line of a CSV file)
function fromCSV (s)
s = s .. ',' -- ending comma
local t = {} -- table to collect fields
local fieldstart = 1
repeat
-- next field is quoted? (start with `"'?)
if string.find(s, '^"', fieldstart) then
local a, c
local i = fieldstart
repeat
-- find closing quote
a, i, c = string.find(s, '"("?)', i+1)
until c ~= '"' -- quote not followed by quote?
if not i then error('unmatched "') end
local f = string.sub(s, fieldstart+1, i-1)
if f=='nil' then f='' end
table.insert(t, (string.gsub(f, '""', '"')))
fieldstart = string.find(s, ',', i) + 1
else -- unquoted; find next comma
local nexti = string.find(s, ',', fieldstart)
local f = string.sub(s, fieldstart, nexti-1) or ''
if f=='nil' then f = '' end
if f=='TRUE' then f = true end
if f=='FALSE' then f = false end
table.insert(t, f)
fieldstart = nexti + 1
end
until fieldstart > string.len(s)
return t
end
-- Convert from table to CSV string
function toCSV (tt)
local s = ""
for _,p in ipairs(tt) do
s = s .. "," .. escapeCSV(p)
end
return string.sub(s, 2) -- remove first comma
end
-- read CSV file if itemnames is set, use the first line as item name
-- returns table[1..nlines] of tables with items,
-- and returns table with ordered heading (needed to rewrite)
function readCSV(filename, itemnames)
if itemnames==nil then itemnames=true end
local t = {}
local heads
local f = io.open(filename, 'rt')
for s in f:lines() do
if itemnames==true then
heads = fromCSV (s)
for k,v in ipairs(heads) do
if v=='' then v = 'Column'..k end
heads[k] = v
end
itemnames = false
else
t[#t+1] = {}
s = fromCSV (s)
for k,v in ipairs(s) do
if v~='' then
if tonumber(v) then
v = tonumber(v)
end
if heads then
t[#t][heads[k]] = v
else
t[#t][k] = v
end
end
end
end
end
f:close()
return t, heads
end
-- write table t as CSV file; if heads passed use heads as first line and
-- each row in t contains names items; if not it contains numbered items
function writeCSV(t, filename, heads)
local f = io.open(filename, 'wt')
if heads then
f:write(toCSV(heads)..'\n')
end
for k, v in ipairs(t) do
if heads then
local w = {}
for k2,v2 in ipairs(heads) do
w[#w+1]=v[v2] or ''
end
f:write(toCSV(w)..'\n')
else
f:write(toCSV(v)..'\n')
end
end
f:close()
end
|
require( "utils" )
medusa_mystic_snake_dm2017 = class({})
--------------------------------------------------------------------------------
function medusa_mystic_snake_dm2017:OnSpellStart()
local hTarget = self:GetCursorTarget()
if hTarget == nil or hTarget:IsInvulnerable() then
return
end
self.radius = self:GetSpecialValueFor( "radius" )
self.initial_speed = self:GetSpecialValueFor( "initial_speed" )
self.snake_damage = self:GetSpecialValueFor( "snake_damage" )
self.snake_mana_steal = self:GetSpecialValueFor( "snake_mana_steal" )
self.snake_scale = self:GetSpecialValueFor( "snake_scale" )
self.snake_jumps = self:GetSpecialValueFor( "snake_jumps" )
self.return_speed = self:GetSpecialValueFor( "return_speed" )
self.stone_duration = self:GetSpecialValueFor( "stone_duration" )
local info = {
EffectName = "particles/units/heroes/hero_medusa/medusa_mystic_snake_projectile_initial.vpcf",
Ability = self,
iMoveSpeed = self.initial_speed,
Source = self:GetCaster(),
Target = self:GetCursorTarget(),
bDodgeable = false,
iSourceAttachment = DOTA_PROJECTILE_ATTACHMENT_ATTACK_2,
bProvidesVision = true,
iVisionTeamNumber = self:GetCaster():GetTeamNumber(),
iVisionRadius = 300,
}
ProjectileManager:CreateTrackingProjectile( info )
EmitSoundOn( "Hero_Medusa.MysticSnake.Cast", self:GetCaster() )
self.nCurJumpCount = 0;
self.nTotalMana = 0;
self.hHitEntities = {}
local nFXIndex = ParticleManager:CreateParticle( "particles/units/heroes/hero_medusa/medusa_mystic_snake_cast.vpcf", PATTACH_CUSTOMORIGIN, nil )
ParticleManager:SetParticleControlEnt( nFXIndex, 0, self:GetCaster(), PATTACH_POINT_FOLLOW, "attach_attack1", self:GetCaster():GetOrigin(), true )
ParticleManager:SetParticleControlEnt( nFXIndex, 1, self:GetCaster(), PATTACH_POINT_FOLLOW, "attach_attack2", self:GetCaster():GetOrigin(), true )
ParticleManager:ReleaseParticleIndex( nFXIndex )
end
--------------------------------------------------------------------------------
function medusa_mystic_snake_dm2017:OnProjectileHit( hTarget, vLocation )
if IsServer() then
if hTarget ~= nil and not ( hTarget == self:GetCaster() ) then
-- Do damage and mana steal
if ( hTarget:GetMaxMana() > 0 ) and hTarget:IsAlive() and not hTarget:IsIllusion() then
local flManaSteal = math.min( hTarget:GetMana(), hTarget:GetMaxMana() * self.snake_mana_steal / 100 )
hTarget:ReduceMana( flManaSteal )
self.nTotalMana = self.nTotalMana + flManaSteal
end
local iDamageType = DAMAGE_TYPE_MAGICAL;
if ( hTarget:FindModifierByName( "modifier_medusa_stone_gaze_stone" ) ) then
iDamageType = DAMAGE_TYPE_PURE;
end
local damage = {
victim = hTarget,
attacker = self:GetCaster(),
ability = self,
damage = self.snake_damage,
damage_type = iDamageType,
}
ApplyDamage( damage )
-- turn unit to stone
hTarget:AddNewModifier( self:GetCaster(), self, "modifier_medusa_stone_gaze_stone", { duration = self.stone_duration } )
-- Scale up the damage now
self.snake_damage = self.snake_damage + ( self.snake_damage * self.snake_scale ) / 100;
self.nCurJumpCount = self.nCurJumpCount + 1
table.insert( self.hHitEntities, hTarget )
EmitSoundOn( "Hero_Medusa.MysticSnake.Target", hTarget )
end
-- Snake is hitting Medusa, give her the collected mana
if ( hTarget == self:GetCaster() ) then
hTarget:GiveMana( self.nTotalMana )
SendOverheadEventMessage( self:GetCaster():GetPlayerOwner(), OVERHEAD_ALERT_MANA_ADD, hTarget, self.nTotalMana, nil )
for k in pairs( self.hHitEntities ) do
self.hHitEntities[ k ] = nil
end
EmitSoundOn( "Hero_Medusa.MysticSnake.Return", self:GetCaster() )
return true
end
self:LaunchNextProjectile( hTarget )
end
return false
end
--------------------------------------------------------------------------------
function medusa_mystic_snake_dm2017:LaunchNextProjectile( hTarget )
-- Find a new target
if hTarget and self.nCurJumpCount < self.snake_jumps then
local enemies = FindUnitsInRadius( self:GetCaster():GetTeamNumber(), hTarget:GetAbsOrigin(), self:GetCaster(), self.radius, DOTA_UNIT_TARGET_TEAM_ENEMY, DOTA_UNIT_TARGET_HERO + DOTA_UNIT_TARGET_BASIC, DOTA_UNIT_TARGET_FLAG_NO_INVIS + DOTA_UNIT_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES, FIND_CLOSEST, false )
local hJumpTarget
while #enemies > 0 do
local hPotentialJumpTarget = enemies[ 1 ]
if hPotentialJumpTarget == nil or TableContains( self.hHitEntities, hPotentialJumpTarget ) then
table.remove( enemies, 1 )
else
hJumpTarget = hPotentialJumpTarget
break
end
end
-- We didn't find any jump targets, return to Medusa
if #enemies == 0 then
local info = {
EffectName = "particles/units/heroes/hero_medusa/medusa_mystic_snake_projectile_return.vpcf",
Ability = self,
iMoveSpeed = self.return_speed,
Source = hTarget,
Target = self:GetCaster(),
bDodgeable = false,
iSourceAttachment = DOTA_PROJECTILE_ATTACHMENT_HITLOCATION,
bProvidesVision = true,
iVisionTeamNumber = self:GetCaster():GetTeamNumber(),
iVisionRadius = 300,
}
ProjectileManager:CreateTrackingProjectile( info )
return
end
-- Go to another target
if hJumpTarget then
local info = {
EffectName = "particles/units/heroes/hero_medusa/medusa_mystic_snake_projectile.vpcf",
Ability = self,
iMoveSpeed = self.initial_speed,
Source = hTarget,
Target = hJumpTarget,
bDodgeable = false,
iSourceAttachment = DOTA_PROJECTILE_ATTACHMENT_HITLOCATION,
bProvidesVision = true,
iVisionTeamNumber = self:GetCaster():GetTeamNumber(),
iVisionRadius = 300,
}
ProjectileManager:CreateTrackingProjectile( info )
return
end
-- Should be impossible to not trigger one of the above conditions.
Assert( false )
end
-- We're out of jump targets, so return to the caster from here.
self:LaunchReturnProjectile( hTarget );
end
--------------------------------------------------------------------------------
function medusa_mystic_snake_dm2017:LaunchReturnProjectile( hSource )
local info = {
EffectName = "particles/units/heroes/hero_medusa/medusa_mystic_snake_projectile_return.vpcf",
Ability = self,
iMoveSpeed = self.return_speed,
Source = hSource,
Target = self:GetCaster(),
bDodgeable = false,
iSourceAttachment = DOTA_PROJECTILE_ATTACHMENT_HITLOCATION,
bProvidesVision = true,
iVisionTeamNumber = self:GetCaster():GetTeamNumber(),
iVisionRadius = 300,
}
ProjectileManager:CreateTrackingProjectile( info )
end
--------------------------------------------------------------------------------
|
--
-- Copyright (c) 2017-2018 Nicholas Corgan (n.corgan@gmail.com)
--
-- Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
-- or copy at http://opensource.org/licenses/MIT)
--
local pkmn = require("pkmn")
local pkmntest_utils = require("pkmntest_utils")
local luaunit = require("luaunit")
local pokemon_pc_tests = {}
pokemon_pc_tests.pokemon_box = {}
pokemon_pc_tests.pokemon_pc = {}
-- Stupid hacky functions to be able to test indexing and attributes
function pokemon_pc_tests.pokemon_box.get_pokemon(box, index)
local pokemon = box[index]
end
function pokemon_pc_tests.pokemon_box.set_pokemon(box, index, pokemon)
party[index] = pokemon
end
function pokemon_pc_tests.pokemon_box.set_name(box, name)
box.name = name
end
function pokemon_pc_tests.pokemon_pc.get_box(pc, index)
local box = pc[index]
end
-- Actual test functions
function pokemon_pc_tests.test_empty_pokemon_box(box, game)
local generation = pkmntest_utils.GAME_TO_GENERATION[game]
luaunit.assertEquals(box.game, game)
luaunit.assertEquals(box.name, "")
for box_index = 1, #box
do
luaunit.assertEquals(box[box_index].species, pkmn.species.NONE)
luaunit.assertEquals(box[box_index].game, game)
for move_index = 1, #box[box_index].moves
do
luaunit.assertEquals(box[box_index].moves[move_index].move, pkmn.move.NONE)
luaunit.assertEquals(box[box_index].moves[move_index].pp, 0)
end
end
-- Make sure trying to get a Pokémon at an invalid index fails.
luaunit.assertError(
pokemon_pc_tests.pokemon_box.get_pokemon,
box,
0
)
luaunit.assertError(
pokemon_pc_tests.pokemon_box.get_pokemon,
box,
#box+1
)
end
function pokemon_pc_tests.test_box_name(box)
local generation = pkmntest_utils.GAME_TO_GENERATION[box.game]
if generation == 1
then
luaunit.assertEquals(box.name, "")
luaunit.assertError(
pokemon_pc_tests.pokemon_box.set_name,
box,
"ABCDEFGH"
)
else
luaunit.assertError(
pokemon_pc_tests.pokemon_box.set_name,
box,
"ABCDEFGHI"
)
box.name = "ABCDEFGH"
luaunit.assertEquals(box.name, "ABCDEFGH")
end
end
function pokemon_pc_tests.test_setting_pokemon(box)
local game = box.game
local generation = pkmntest_utils.GAME_TO_GENERATION[game]
local original_first = box[1]
local original_second = box[2]
-- Make sure we can't set Pokémon at invalid indices.
luaunit.assertError(
pokemon_pc_tests.pokemon_box.set_pokemon,
box,
0,
original_first
)
luaunit.assertError(
pokemon_pc_tests.pokemon_box.set_pokemon,
box,
#box+1,
original_second
)
-- Create Pokémon and place in box. The original variables should
-- still have the same underlying Pokémon.
local bulbasaur = pkmn.pokemon(pkmn.species.BULBASAUR, game, "", 5)
local charmander = pkmn.pokemon(pkmn.species.CHARMANDER, game, "", 5)
local squirtle = pkmn.pokemon(pkmn.species.SQUIRTLE, game, "", 5)
box[1] = bulbasaur
luaunit.assertEquals(box.num_pokemon, 1)
box[2] = charmander
luaunit.assertEquals(box.num_pokemon, 2)
-- Replace one of the new ones.
box[1] = squirtle
luaunit.assertEquals(box.num_pokemon, 2)
-- Make sure we can't copy a Pokémon to itself.
luaunit.assertError(
pokemon_pc_tests.pokemon_box.set_pokemon,
box,
2,
box[2]
)
luaunit.assertEquals(box.num_pokemon, 2)
-- Copy a Pokémon whose memory is already part of the box.
box[3] = box[2]
luaunit.assertEquals(box.num_pokemon, 3)
-- We should always be able to clear the last contiguous Pokémon.
box[3] = original_first
luaunit.assertEquals(box.num_pokemon, 2)
luaunit.assertEquals(box[3].species, pkmn.species.NONE)
-- Put it back.
box[3] = box[2]
luaunit.assertEquals(box.num_pokemon, 3)
-- Check that Pokémon can be placed non-contiguously in the correct games.
if generation <= 2
then
luaunit.assertError(
pokemon_pc_tests.pokemon_box.set_pokemon,
box,
2,
original_first
)
luaunit.assertEquals(box.num_pokemon, 3)
luaunit.assertEquals(box[2].species, pkmn.species.CHARMANDER)
luaunit.assertError(
pokemon_pc_tests.pokemon_box.set_pokemon,
box,
5,
bulbasaur
)
luaunit.assertEquals(box.num_pokemon, 3)
luaunit.assertEquals(box[5].species, pkmn.species.NONE)
else
box[2] = original_first
luaunit.assertEquals(box.num_pokemon, 2)
luaunit.assertEquals(box[2].species, pkmn.species.NONE)
box[5] = bulbasaur
luaunit.assertEquals(box.num_pokemon, 3)
luaunit.assertEquals(box[5].species, pkmn.species.BULBASAUR)
-- Restore it to how it was.
box[2] = charmander
box[5] = original_first
luaunit.assertEquals(box[2].species, pkmn.species.CHARMANDER)
luaunit.assertEquals(box[5].species, pkmn.species.NONE)
end
-- Now check everything we've created. Each variable should have
-- the same underlying Pokémon.
luaunit.assertEquals(box[1].species, pkmn.species.SQUIRTLE)
luaunit.assertEquals(box[2].species, pkmn.species.CHARMANDER)
luaunit.assertEquals(box[3].species, pkmn.species.CHARMANDER)
luaunit.assertEquals(original_first.species, pkmn.species.NONE)
luaunit.assertEquals(original_second.species, pkmn.species.NONE)
luaunit.assertEquals(bulbasaur.species, pkmn.species.BULBASAUR)
luaunit.assertEquals(charmander.species, pkmn.species.CHARMANDER)
luaunit.assertEquals(squirtle.species, pkmn.species.SQUIRTLE)
end
function pokemon_pc_tests.test_pokemon_box(box, game)
pokemon_pc_tests.test_empty_pokemon_box(box, game)
pokemon_pc_tests.test_box_name(box)
pokemon_pc_tests.test_setting_pokemon(box)
end
function pokemon_pc_tests.test_empty_pokemon_pc(pc, game)
luaunit.assertEquals(pc.game, game)
for i = 1, #pc
do
pokemon_pc_tests.test_empty_pokemon_box(pc[i], game)
end
end
function pokemon_pc_tests.test_box_names(pc)
local generation = pkmntest_utils.GAME_TO_GENERATION[pc.game]
if generation == 1
then
luaunit.assertError(
pokemon_pc_tests.pokemon_box.set_name,
pc[1],
"ABCDEFGH"
)
else
for i = 1, #pc
do
local box_name = string.format("BOX%d", i)
pc[i].name = box_name
end
for i = 1, #pc.box_names
do
local expected_box_name = string.format("BOX%d", i)
luaunit.assertEquals(pc.box_names[i], expected_box_name)
end
end
end
function pokemon_pc_tests.test_setting_pokemon_in_boxes(pc)
for i = 1, #pc
do
pokemon_pc_tests.test_setting_pokemon(pc[i])
luaunit.assertEquals(pc[i][1].species, pkmn.species.SQUIRTLE)
luaunit.assertEquals(pc[i][2].species, pkmn.species.CHARMANDER)
end
end
function pokemon_pc_tests.test_pokemon_pc(pc, game)
pokemon_pc_tests.test_empty_pokemon_pc(pc, game)
pokemon_pc_tests.test_box_names(pc)
pokemon_pc_tests.test_setting_pokemon_in_boxes(pc)
end
return pokemon_pc_tests
|
local M = {}
local server
wifi.ap.config({ssid = "TomatoHeart"})
print("\nCurrent SoftAP configuration:")
for k,v in pairs(wifi.ap.getconfig(true)) do
print(" "..k.." :",v)
end
print(" IP:", wifi.ap.getip())
function M.start(cb)
if wifi.getmode() ~= wifi.STATIONAP then
wifi.setmode(wifi.STATIONAP)
print("Switching to STATIONAP mode")
end
if not server then
print("\nStarting config server..")
server = net.createServer(net.TCP, 5)
server:listen(80, function(conn)
conn:on("receive", function(sck, data) M.receiver(sck, data, cb) end)
end)
local port, ip = server:getaddr()
print("Listening to "..ip..":"..port)
else
print("Config server already running.")
end
end
function M.stop()
if server then
print("Closing config sever")
server:close()
server = nil
end
wifi.setmode(wifi.STATION)
end
function M.receiver(sck, data, callback)
if string.find(data, "^POST") then
local body = data:match("\n[^\n]*$")
local ssid = body:match("ssid=([^\&]+)")
local pwd = body:match("pwd=([^\&]+)")
local new_uri = body:match("uri=([^\&]+)"):gsub("%%3A", ":"):gsub("%%2F", "/")
if ssid and pwd and uri then
callback(ssid, pwd, new_uri)
print("\nUpdating hard settings to:\n\tssid="..ssid.." pwd="..pwd.." uri="..uri)
sck:send("<!DOCTYPE html>\n<h1>Settings updated</h1>");
sck:on("sent", function(conn)
conn:close()
tmr.create():alarm(300, tmr.ALARM_SINGLE, function()
callback(ssid, pwd, new_uri)
end)
end)
else
sck:send("bad request");
end
else
print("http get/?")
local index = "can't read html"
if file.open("index.html", "r") then
index = file.read(4096)
file.close()
end
sck:send(string.format(index, sta_config and sta_config.ssid or "", sta_config and sta_config.pwd or "", uri or ""))
sck:on("sent", function(conn) conn:close() end)
end
end
return M
|
function Clone_Copy(slot0, slot1)
if type(slot0) ~= "table" then
return slot0
elseif slot1[slot0] then
return slot1[slot0]
end
slot1[slot0] = {}
slot3 = type(slot0) == "table" and slot0.__ctype == 2
for slot7, slot8 in pairs(slot0) do
if slot3 and slot7 == "class" then
slot2[slot7] = slot8
else
slot2[Clone_Copy(slot7, slot1)] = Clone_Copy(slot8, slot1)
end
end
return setmetatable(slot2, getmetatable(slot0))
end
function Clone(slot0)
return Clone_Copy(slot0, {})
end
function class(slot0, slot1)
slot3 = nil
if type(slot1) ~= "function" and slot2 ~= "table" then
slot2 = nil
slot1 = nil
end
if slot2 == "function" or (slot1 and slot1.__ctype == 1) then
slot3 = {}
if slot2 == "table" then
for slot7, slot8 in pairs(slot1) do
slot3[slot7] = slot8
end
slot3.__create = slot1.__create
slot3.super = slot1
else
slot3.__create = slot1
end
slot3.Ctor = function ()
return
end
slot3.__cname = slot0
slot3.__ctype = 1
slot3.New = function (...)
for slot4, slot5 in pairs(slot0) do
slot0[slot4] = slot5
end
slot0.class = slot0
slot0:Ctor(...)
return slot0
end
else
if slot1 then
setmetatable({}, slot1).super = slot1
else
slot4 = {
Ctor = function ()
return
end
}
slot3 = slot4
end
slot3.__cname = slot0
slot3.__ctype = 2
slot3.__index = slot3
slot3.New = function (...)
slot0 = setmetatable({}, setmetatable)
slot0.class = slot0
slot0:Ctor(...)
return slot0
end
end
return slot3
end
function isa(slot0, slot1)
slot2 = getmetatable(slot0)
while slot2 ~= nil do
if slot2 == slot1 then
return true
else
slot2 = getmetatable(slot2)
end
end
return false
end
function instanceof(slot0, slot1)
return superof(slot0.class, slot1)
end
function superof(slot0, slot1)
while slot0 ~= nil do
if slot0 == slot1 then
return true
else
slot0 = slot0.super
end
end
return false
end
function singletonClass(slot0, slot1)
slot2 = class(slot0, slot1)
slot2._new = slot2.New
rawset(slot2, "_singletonInstance", nil)
slot2.New = function ()
if not slot0._singletonInstance then
return slot0.GetInstance()
end
error("singleton class can not new. Please use " .. .. ".GetInstance() to get it", 2)
end
slot2.GetInstance = function ()
if rawget(rawget, "_singletonInstance") == nil then
rawset(rawset, "_singletonInstance", slot0._new())
end
return slot0._singletonInstance
end
return slot2
end
function removeSingletonInstance(slot0)
if slot0 and rawget(slot0, "_singletonInstance") then
rawset(slot0, "_singletonInstance", nil)
return true
end
return false
end
function tracebackex()
slot1 = 2
slot0 = "" .. "stack traceback:\n"
while true do
if not debug.getinfo(slot1, "Sln") then
break
end
if slot2.what == "C" then
slot0 = slot0 .. tostring(slot1) .. "\tC function\n"
else
slot0 = slot0 .. string.format("\t[%s]:%d in function `%s`\n", slot2.short_src, slot2.currentline, slot2.name or "")
end
slot3 = 1
while true do
slot4, slot5 = debug.getlocal(slot1, slot3)
if not slot4 then
break
end
slot0 = slot0 .. "\t\t" .. slot4 .. " =\t" .. tostringex(slot5, 3) .. "\n"
slot3 = slot3 + 1
end
slot1 = slot1 + 1
end
return slot0
end
function tostringex(slot0, slot1)
if slot1 == nil then
slot1 = 0
end
slot2 = string.rep("\t", slot1)
slot3 = ""
if type(slot0) == "table" and slot1 > 5 then
return "\t{ ... }"
slot4 = ""
for slot8, slot9 in pairs(slot0) do
slot4 = slot4 .. "\n\t" .. slot2 .. tostring(slot8) .. ":" .. tostringex(slot9, slot1 + 1)
end
return (slot4 == "" and slot3 .. slot2 .. "{ }\t(" .. tostring(slot0) .. ")") or slot3 .. slot2 .. "{" .. slot4 .. "\n" .. slot2 .. "}" or slot3 .. slot2 .. tostring(slot0) .. "\t(" .. type(slot0) .. ")"
end
end
return
|
-- Manually converted to Lua from:
-- https://github.com/w3c/web-platform-tests/blob/8c07290db5014705e7daa45e3690a54018d27bd5/dom/nodes/Element-getElementsByClassName.html
local gumbo = require "gumbo"
local ElementList = require "gumbo.dom.ElementList"
local NodeList = require "gumbo.dom.NodeList"
local input = [[
<!DOCTYPE html>
<title>Element.getElementsByClassName</title>
<div id="log"></div>
]]
local document = assert(gumbo.parse(input))
do -- getElementsByClassName should work on disconnected subtrees
local a = document:createElement("a")
local b = document:createElement("b")
b.className = "foo"
a:appendChild(b)
local list = assert(a:getElementsByClassName("foo"))
assert(list.length == 1)
assert(list[1] == b)
end
do -- Interface should be correct
local list = assert(document:getElementsByClassName("foo"))
local mt = assert(getmetatable(list))
assert(mt ~= NodeList)
assert(mt == ElementList)
end
|
return {
mod_name = {
en = "Weapon Switch Fix"
},
mod_description = {
en = "Fix for all the weapon switching foibles."
},
}
|
-----------------------------------
--
-- Zone: Bostaunieux_Oubliette (167)
--
-----------------------------------
local ID = require("scripts/zones/Bostaunieux_Oubliette/IDs")
require("scripts/globals/conquest")
-----------------------------------
function onInitialize(zone)
UpdateNMSpawnPoint(ID.mob.DREXERION_THE_CONDEMNED)
GetMobByID(ID.mob.DREXERION_THE_CONDEMNED):setRespawnTime(math.random(900, 10800))
UpdateNMSpawnPoint(ID.mob.PHANDURON_THE_CONDEMNED)
GetMobByID(ID.mob.PHANDURON_THE_CONDEMNED):setRespawnTime(math.random(900, 10800))
UpdateNMSpawnPoint(ID.mob.BLOODSUCKER)
GetMobByID(ID.mob.BLOODSUCKER):setRespawnTime(3600)
end
function onZoneIn(player, prevZone)
local cs = -1
if player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0 then
player:setPos(99.978, -25.647, 72.867, 61)
end
return cs
end
function onConquestUpdate(zone, updatetype)
tpz.conq.onConquestUpdate(zone, updatetype)
end
function onRegionEnter(player, region)
end
function onConquestUpdate(zone, updatetype)
tpz.conq.onConquestUpdate(zone, updatetype)
end
function onEventUpdate(player, csid, option)
end
function onEventFinish(player, csid, option)
end
|
local screen = require("OS2D.screens.screen")
local screenmanager = {
states = {};
current = screen:new();
}
function screenmanager:registerstate(name, state)
state = state or screen:new()
state.screenmanager = self
self.states[name] = state
return state
end
function screenmanager:switchstates(name, ...)
self.current:unload()
local newstate = self.states[name]
self.current = newstate or screenmanager:registerstate(name, screen:new())
self.current:load(...)
end
function screenmanager:init(...)
self.current:init(...)
end
function screenmanager:close(...)
self.current:close(...)
end
function screenmanager:receive(...)
self.current:recieve(...)
end
function screenmanager:directorydropped(...)
self.current:directorydropped(...)
end
function screenmanager:draw(...)
self.current:draw(...)
end
function screenmanager:filedropped(...)
self.current:filedropped(...)
end
function screenmanager:focus(...)
self.current:focus(...)
end
function screenmanager:keypressed(...)
self.current:keypressed(...)
end
function screenmanager:keyreleased(...)
self.current:keyreleased(...)
end
function screenmanager:lowmemory(...)
self.current:lowmemory(...)
end
function screenmanager:mousefocus(...)
self.current:mousefocus(...)
end
function screenmanager:mousemoved(...)
self.current:mousemoved(...)
end
function screenmanager:mousepressed(...)
self.current:mousepressed(...)
end
function screenmanager:mousereleased(...)
self.current:mousereleased(...)
end
function screenmanager:quit(...)
self.current:quit(...)
end
function screenmanager:resize(...)
self.current:resize(...)
end
function screenmanager:textedited(...)
self.current:textedited(...)
end
function screenmanager:textinput(...)
self.current:textinput(...)
end
function screenmanager:threaderror(...)
self.current:threaderror(...)
end
function screenmanager:touchmoved(...)
self.current:touchmoved(...)
end
function screenmanager:touchpressed(...)
self.current:touchpressed(...)
end
function screenmanager:touchreleased(...)
self.current:touchreleased(...)
end
function screenmanager:update(...)
self.current:update(...)
end
function screenmanager:visible(...)
self.current:visible(...)
end
function screenmanager:wheelmoved(...)
self.current:wheelmoved(...)
end
function screenmanager:gamepadaxis(...)
self.current:gamepadaxis(...)
end
function screenmanager:gamepadpressed(...)
self.current:gamepadpressed(...)
end
function screenmanager:gamepadreleased(...)
self.current:gamepadreleased(...)
end
function screenmanager:joystickadded(...)
self.current:joystickadded(...)
end
function screenmanager:joystickaxis(...)
self.current:jotstickaxis(...)
end
function screenmanager:joystickhat(...)
self.current:joystickhat(...)
end
function screenmanager:joystickpressed(...)
self.current:joystickpressed(...)
end
function screenmanager:joystickreleased(...)
self.current:joystickreleased(...)
end
function screenmanager:joystickremoved(...)
self.current:joystickremoved(...)
end
return screenmanager
|
-- TODO: not sure if this warrants its own library... perhaps make it more full-featured?
-- Functionality to disable our custom UI listeners.
local custom_ui_listeners_enabled = true
local custom_ui_listeners = {}
-- Disables our custom UI listeners while calling given func with no arguments.
-- If return_pcall_rvs is true, then directly returns the return vals of the internal pcall.
function custom_ui_listeners.disable_during_call(func, return_pcall_rvs)
local old_enabled = custom_ui_listeners_enabled
custom_ui_listeners_enabled = false
local ret_status, val = pcall(func)
custom_ui_listeners_enabled = old_enabled
if return_pcall_rvs then
return ret_status, val
else
if ret_status then
return val
else
error(val)
end
end
end
-- Custom UI listeners should use this function as their condition.
function custom_ui_listeners.enabled()
return custom_ui_listeners_enabled
end
return custom_ui_listeners
|
---------------------------------------------------------------------
CLASS: SQNodeMoveTo ( SQNode )
:MODEL{
Field 'target' :type( 'vec2' ) :getset( 'Target' )
}
function SQNodeMoveTo:__init()
self.target = { 0, 0 }
end
function SQNodeMoveTo:getTarget()
return unpack( self.target )
end
function SQNodeMoveTo:setTarget( x, y )
self.target = { x, y }
end
---------------------------------------------------------------------
CLASS: SQNodeTalk ( SQNode )
:MODEL{
Field 'text' :string() :widget( 'textbox' );
}
function SQNodeTalk:enter()
self.text = 'Hello!'
end
function SQNodeTalk:update( dt )
end
function SQNodeTalk:enter()
end
|
--[[
=== test_moe.lua
]]
------------------------------------------------------------------------
local moe = require "he.moe"
local he = require"he"
--~ he.pp(moe)
--~ print("crypto and nonce generation: ", moe.use())
local a, b = moe.use()
assert(a == "plc" or a == "luazen")
assert(b == "randombytes" or b == "/dev/urandom")
local k = ('k'):rep(32)
local p, p2, c, msg, clen, x, y, z
--
-- string en/decryption
p = "hello"
c = moe.encrypt(k, p, true)
p2 = moe.decrypt(k, c, true)
assert(p2 == p)
--~ print("#c, c:", #c, c)
-- switch to plc-based crypto for decryption
--~ print(moe.use("plc"))
assert(moe.use("plc"), "cannot use plc")
a, b = moe.use()
assert(a == "plc")
assert(b == "/dev/urandom")
--~ print("crypto and nonce generation: ", moe.use())
assert(moe.decrypt(k, c, true) == p)
-- string en/decryption (simplified API)
p = "hello"
c = moe.sencrypt("keyfile content", p)
p2 = moe.sdecrypt("keyfile content", c)
assert(p2 == p)
--~ print("#c, c:", #c, c)
-- file names
local fbase = "/tmp/" .. os.getenv("USER") .. "-moetest"
local fnp = fbase .. ".p"
local fnc = fbase .. ".c"
local fnp2 = fbase .. ".p2"
local fnp3 = fbase .. ".p3"
--
-- test file handle en/decrypt
x=1200000
p = ("a"):rep(x)
he.fput(fnp, p)
local fhi = io.open(fnp)
local fho = io.open(fnc, "w")
y, msg = moe.fhencrypt(k, fhi, fho)
assert(y == x + (moe.noncelen + moe.maclen) * 2)
fhi:close()
fho:close()
local fhi = io.open(fnc)
local fho = io.open(fnp2, "w")
z, msg = moe.fhdecrypt(k, fhi, fho)
assert(z and (z == x), msg)
--~ print("moedat.p2", x, msg)
fhi:close()
fho:close()
assert(he.fget(fnp2) == he.fget(fnp))
--
-- test file en/decrypt
assert(moe.fileencrypt(k, fnp, fnc))
assert(moe.filedecrypt(k, fnc, fnp3))
assert(he.fget(fnp3) == he.fget(fnp))
--
-- cleanup test files
os.remove(fnp)
os.remove(fnp2)
os.remove(fnp3)
os.remove(fnc)
|
-- HTTP-message = start-line
-- *( header-field CRLF )
-- CRLF
-- [ message-body ]
--
-- start-line = request-line / status-line
--
-- request-target = origin-form
-- / absolute-form
-- / authority-form
-- / asterisk-form
--
-- request-target too long, response with 414 URI Too Long
--
-- > Various ad hoc limitations on request-line length are found in practice.
-- > It is RECOMMENDED that all HTTP senders and recipients support, at a minimum,
-- > request-line lengths of 8000 octets.
local ParserErrors = require "atlas.server.parser_errors"
local utils = require "atlas.utils"
local in_table = utils.in_table
local Parser = {}
Parser.__index = Parser
-- request-line = method SP request-target SP HTTP-version CRLF
local REQUEST_LINE_PATTERN = "^(%u+) ([^ ]+) HTTP/([%d.]+)\r\n"
-- Currrently unsupported: CONNECT, OPTIONS, TRACE
-- PATCH is defined in RFC 5789
local SUPPORTED_METHODS = {"GET", "POST", "HEAD", "DELETE", "PUT", "PATCH"}
-- These are the versions supported by ASGI HTTP 2.3.
local SUPPORTED_VERSIONS = {"1.0", "1.1", "2"}
-- An HTTP 1.1 parser
--
-- This parser focuses on HTTP *request* parsing.
local function _init(_)
local self = setmetatable({}, Parser)
return self
end
setmetatable(Parser, {__call = _init})
-- Parse the request data.
--
-- data: Raw network data
--
-- Returns:
-- meta: The non-body portion of the request (a strict subset of an ASGI scope)
-- body: The body data
-- err: Non-nil if an error exists
function Parser.parse(_, data) -- self, data
local meta = {type = "http"}
local method, target, version = string.match(data, REQUEST_LINE_PATTERN)
if not method then return nil, nil, ParserErrors.INVALID_REQUEST_LINE end
meta.method = method
if not in_table(method, SUPPORTED_METHODS) then
return meta, nil, ParserErrors.METHOD_NOT_IMPLEMENTED
end
meta.path = target
meta.raw_path = target
meta.http_version = version
if not in_table(version, SUPPORTED_VERSIONS) then
return meta, nil, ParserErrors.VERSION_NOT_SUPPORTED
end
return meta, nil, nil
end
return Parser
|
-- vim : ft=lua ts=2 sw=2 et:
local _,ne,nw,nw4,sw,sw4,ne46,w26,sw46
_ = 0
ne={{_,_,_,1,2,_}, -- bad if lohi
{_,_,_,_,1,_},
{_,_,_,_,_,_},
{_,_,_,_,_,_},
{_,_,_,_,_,_},
{_,_,_,_,_,_}}
nw={{2,1,_,_,_,_}, -- bad if lolo
{1,_,_,_,_,_},
{_,_,_,_,_,_},
{_,_,_,_,_,_},
{_,_,_,_,_,_},
{_,_,_,_,_,_}}
nw4={{4,2,1,_,_,_}, -- very bad if lolo
{2,1,_,_,_,_},
{1,_,_,_,_,_},
{_,_,_,_,_,_},
{_,_,_,_,_,_},
{_,_,_,_,_,_}}
sw={{_,_,_,_,_,_}, -- bad if hilo
{_,_,_,_,_,_},
{_,_,_,_,_,_},
{1,_,_,_,_,_},
{2,1,_,_,_,_},
{_,_,_,_,_,_}}
sw4={{_,_,_,_,_,_}, -- very bad if hilo
{_,_,_,_,_,_},
{1,_,_,_,_,_},
{2,1,_,_,_,_},
{4,2,1,_,_,_},
{_,_,_,_,_,_}}
-- bounded by 1..6
ne46={{_,_,_,1,2,4}, -- very bad if lohi
{_,_,_,_,1,2},
{_,_,_,_,_,1},
{_,_,_,_,_,_},
{_,_,_,_,_,_},
{_,_,_,_,_,_}}
sw26={{_,_,_,_,_,_}, -- bad if hilo
{_,_,_,_,_,_},
{_,_,_,_,_,_},
{_,_,_,_,_,_},
{1,_,_,_,_,_},
{2,1,_,_,_,_}}
sw46={{_,_,_,_,_,_}, -- very bad if hilo
{_,_,_,_,_,_},
{_,_,_,_,_,_},
{1,_,_,_,_,_},
{2,1,_,_,_,_},
{4,2,1,_,_,_}}
return {
cplx= {acap=sw46, pcap=sw46, tool=sw46}, --12
ltex= {pcap=nw4}, -- 4
pmat= {acap=nw, pcap=sw46}, -- 6
pvol= {plex=sw}, --2
rely= {acap=sw4, pcap=sw4, pmat=sw4}, -- 12
ruse= {aexp=sw46, ltex=sw46}, --8
sced= {cplx=ne46, time=ne46, pcap=nw4, aexp=nw4, acap=nw4,
plex=nw4, ltex=nw, pmat=nw, rely=ne, pvol=ne, tool=nw}, -- 34
stor= {acap=sw46, pcap=sw46}, --8
team= {aexp=nw, sced=nw, site=nw}, --6
time= {acap=sw46, pcap=sw46, tool=sw26}, --10
tool= {acap=nw, pcap=nw, pmat=nw} -- 6
}
|
--[[
@Authors: Ben Dol (BeniS)
@Details: Paths bot module handler for module registration
and control.
]]
dofile('paths.lua')
-- required by the event handler
function PathsModule.getModuleId()
return "PathsModule"
end
PathsModule.dependencies = {
"BotModule"
}
--[[ Default Options ]]
PathsModule.options = {
['AutoPath'] = false,
['SmartPath'] = false
}
--[[ Register Events ]]
table.merge(PathsModule, {
autoPath = 1
})
PathsModule.events = {
[PathsModule.autoPath] = {
option = "AutoPath",
callback = PathsModule.AutoPath.Event
}
}
--[[ Register Listeners ]]
table.merge(PathsModule, {
smartPath = 1
})
PathsModule.listeners = {
[PathsModule.smartPath] = {
option = "SmartPath",
connect = PathsModule.SmartPath.ConnectListener,
disconnect = PathsModule.SmartPath.DisconnectListener
}
}
--[[ Functions ]]
function PathsModule.stop()
EventHandler.stopEvents(PathsModule.getModuleId())
ListenerHandler.stopListeners(PathsModule.getModuleId())
end
-- Start Module
PathsModule.init()
|
-- Initialize I2C bus with SDA on GPIO0, SCL on GPIO2
-- https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en#new_gpio_map
i2c.setup(0, 3, 4, i2c.SLOW)
-- Initialize PCA9685 PWM controller
-- Args:
-- i2c bus id (should be 0)
-- i2c address (see pca9685 datasheet)
-- mode - 16-bit value, low byte is MODE1, high is MODE2 (see datasheet)
require('pca9685')
pca9685.init(0, 0x40, 0)
for i=0,100,5 do
set_chan_percent(0, i)
end
|
--------------------------------
-- @module Scene
-- @extend Node
-- @parent_module cc
--------------------------------
-- @function [parent=#Scene] getPhysicsWorld
-- @param self
-- @return PhysicsWorld#PhysicsWorld ret (return value: cc.PhysicsWorld)
--------------------------------
-- @function [parent=#Scene] createWithSize
-- @param self
-- @param #size_table size
-- @return Scene#Scene ret (return value: cc.Scene)
--------------------------------
-- @function [parent=#Scene] create
-- @param self
-- @return Scene#Scene ret (return value: cc.Scene)
--------------------------------
-- @function [parent=#Scene] createWithPhysics
-- @param self
-- @return Scene#Scene ret (return value: cc.Scene)
--------------------------------
-- @function [parent=#Scene] getDescription
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#Scene] getScene
-- @param self
-- @return Scene#Scene ret (return value: cc.Scene)
--------------------------------
-- @function [parent=#Scene] update
-- @param self
-- @param #float float
--------------------------------
-- @overload self, cc.Node, int, string
-- @overload self, cc.Node, int, int
-- @function [parent=#Scene] addChild
-- @param self
-- @param #cc.Node node
-- @param #int int
-- @param #int int
return nil
|
------------------------------------------ Библиотеки -----------------------------------------------------------------
local component = require("component")
local colorlib = require("colorlib")
local event = require("event")
local gpu = component.gpu
local printer = component.printer3d
local hologram = component.hologram
------------------------------------------ Переменные -----------------------------------------------------------------
local pixels = {}
local model = {
label = "Sosi hui",
tooltip = "mamu ebal",
buttonMode = true,
redstoneEmitter = true,
active = {
{x = 1, y = 1, z = 1, x2 = 1, y2 = 1, z2 = 12},
{x = 1, y = 8, z = 1, x2 = 8, y2 = 8, z2 = 16},
{x = 16, y = 16, z = 16, x2 = 16, y2 = 16, z2 = 16},
},
passive = {}
}
local colors = {
objects = 0x3349FF,
points = 0xFFFFFF,
border = 0xFFFF00,
background = 0x262626,
rightBar = 0x383838,
lines = 0x222222,
}
local countOfShapes = printer.getMaxShapeCount()
local adder = 360 / countOfShapes
local hue = 0
colors.shapes = {}
for i = 1, countOfShapes do
table.insert(colors.shapes, colorlib.HSBtoHEX(hue, 100, 100))
hue = hue + adder
end
local sizes = {}
sizes.oldResolutionWidth, sizes.oldResolutionHeight = gpu.getResolution()
sizes.xSize, sizes.ySize = gpu.maxResolution()
--
sizes.widthOfRightBar, sizes.heightOfRightBar = 36, sizes.ySize
sizes.xStartOfRightBar, sizes.yStartOfRightBar = sizes.xSize - sizes.widthOfRightBar + 1, 1
--
sizes.widthOfHorizontal = sizes.xSize - sizes.widthOfRightBar
sizes.xStartOfVertical, sizes.yStartOfVertical = math.floor(sizes.widthOfHorizontal / 2), 1
sizes.xStartOfHorizontal, sizes.yStartOfHorizontal = 1, math.floor(sizes.ySize / 2)
--
sizes.widthOfPixel, sizes.heightOfPixel = 2, 1
sizes.image = {}
sizes.image[1] = {x = math.floor(sizes.xStartOfVertical / 2 - (sizes.widthOfPixel * 16) / 2), y = math.floor(sizes.yStartOfHorizontal / 2 - (sizes.heightOfPixel * 16) / 2)}
sizes.image[2] = {x = sizes.xStartOfVertical + sizes.image[1].x + 1, y = sizes.image[1].y}
sizes.image[3] = {x = sizes.image[1].x, y = sizes.yStartOfHorizontal + sizes.image[1].y + 1}
sizes.image[4] = {x = sizes.image[2].x, y = sizes.image[3].y}
local holoOutlineX, holoOutlineY, holoOutlineZ = 16, 24, 16
local currentShape = 1
local currentLayer = 1
------------------------------------------ Функции -----------------------------------------------------------------
local function drawTransparentBackground(x, y, color1, color2)
local xPos, yPos = x, y
local color
for j = 1, 16 do
for i = 1, 16 do
if i % 2 == 0 then
if j % 2 == 0 then
color = color1
else
color = color2
end
else
if j % 2 == 0 then
color = color2
else
color = color1
end
end
ecs.square(xPos, yPos, sizes.widthOfPixel, sizes.heightOfPixel, color)
xPos = xPos + sizes.widthOfPixel
end
xPos = x
yPos = yPos + sizes.heightOfPixel
end
end
local function changePalette()
hologram.setPaletteColor(1, colors.objects)
hologram.setPaletteColor(2, colors.points)
hologram.setPaletteColor(3, colors.border)
end
local function drawShapesList(x, y)
local xPos, yPos = x, y
local color
for i = 1, countOfShapes do
color = 0x000000
if i == currentShape then color = colors.shapes[i] end
ecs.drawButton(xPos, yPos, 4, 1, tostring(i), color, 0xFFFFFF )
xPos = xPos + 5
if i % 6 == 0 then xPos = x; yPos = yPos + 2 end
end
end
local function drawInfo(y, info)
ecs.square(sizes.xStartOfRightBar, y, sizes.widthOfRightBar, 1, 0x000000)
ecs.colorText(sizes.xStartOfRightBar + 2, y, 0xFFFFFF, info)
end
local function drawRightBar()
local xPos, yPos = sizes.xStartOfRightBar, sizes.yStartOfRightBar
ecs.square(xPos, yPos, sizes.widthOfRightBar, sizes.heightOfRightBar, colors.rightBar)
drawInfo(yPos, "Работа с моделью"); yPos = yPos + 2
yPos = yPos + 5
drawInfo(yPos, "Работа с объектом"); yPos = yPos + 2
yPos = yPos + 5
drawInfo(yPos, "Выбор объекта"); yPos = yPos + 3
drawShapesList(xPos + 2, yPos); yPos = yPos + (countOfShapes / 6 * 2) + 1
drawInfo(yPos, "Управление голограммой"); yPos = yPos + 2
yPos = yPos + 5
drawInfo(yPos, "Управление принтером"); yPos = yPos + 2
yPos = yPos + 5
end
local function drawLines()
ecs.square(sizes.xStartOfVertical, sizes.yStartOfVertical, 2, sizes.ySize,colors.lines)
ecs.square(sizes.xStartOfHorizontal, sizes.yStartOfHorizontal, sizes.widthOfHorizontal , 1, colors.lines)
end
local function drawViewArray(x, y, massiv)
local xPos, yPos = x, y
for i = 1, #massiv do
for j = 1, #massiv[i] do
if massiv[i][j] ~= "#" then
ecs.square(xPos, yPos, sizes.widthOfPixel, sizes.heightOfPixel, massiv[i][j])
end
xPos = xPos + sizes.widthOfPixel
end
xPos = x
yPos = yPos + sizes.heightOfPixel
end
end
--Нарисовать вид спереди
local function drawFrontView()
local massiv = {}
for i = 1, 16 do
massiv[i] = {}
for j = 1, 16 do
massiv[i][j] = "#"
end
end
for x = 1, #pixels do
for y = 1, #pixels[x] do
for z = 1, #pixels[x][y] do
if pixels[x][y][z] ~= "#" then
massiv[y][x] = pixels[x][y][z]
end
end
end
end
drawViewArray(sizes.image[1].x, sizes.image[1].y, massiv)
end
--Нарисовать вид сверху
local function drawTopView()
local massiv = {}
for i = 1, 16 do
massiv[i] = {}
for j = 1, 16 do
massiv[i][j] = "#"
end
end
for x = 1, #pixels do
for y = 1, #pixels[x] do
for z = 1, #pixels[x][y] do
if pixels[x][y][z] ~= "#" then
massiv[z][x] = pixels[x][y][z]
end
end
end
end
drawViewArray(sizes.image[3].x, sizes.image[3].y, massiv)
end
--Нарисовать вид сбоку
local function drawSideView()
local massiv = {}
for i = 1, 16 do
massiv[i] = {}
for j = 1, 16 do
massiv[i][j] = "#"
end
end
for x = 1, #pixels do
for y = 1, #pixels[x] do
for z = 1, #pixels[x][y] do
if pixels[x][y][z] ~= "#" then
massiv[y][z] = pixels[x][y][z]
end
end
end
end
drawViewArray(sizes.image[2].x, sizes.image[2].y, massiv)
end
--Сконвертировать массив объектов в трехмерный массив 3D-изображения
local function render()
pixels = {}
for x = 1, 16 do
pixels[x] = {}
for y = 1, 16 do
pixels[x][y] = {}
for z = 1, 16 do
pixels[x][y][z] = "#"
end
end
end
for x = 1, 16 do
for y = 1, 16 do
for z = 1, 16 do
for i = 1, #model.active do
if (x >= model.active[i].x and x <= model.active[i].x2) and (y >= model.active[i].y and y <= model.active[i].y2) and (z >= model.active[i].z and z <= model.active[i].z2) then
pixels[x][y][z] = colors.shapes[i]
--hologram.set(x, y, z, 1)
end
end
end
end
end
end
local function drawBorder()
for i = 0, 17 do
hologram.set(i + holoOutlineX, holoOutlineY - currentLayer, holoOutlineZ, 3)
hologram.set(i + holoOutlineX, holoOutlineY - currentLayer, 17 + holoOutlineZ, 3)
hologram.set(holoOutlineX, holoOutlineY - currentLayer, i + holoOutlineZ, 3)
hologram.set(17 + holoOutlineX, holoOutlineY - currentLayer, i + holoOutlineZ, 3)
end
end
local function drawFrame()
--Верхний левый
for i = 1, 2 do hologram.set(i + holoOutlineX - 1, holoOutlineY - 1, holoOutlineZ, 2) end
hologram.set(holoOutlineX, holoOutlineY - 1, holoOutlineZ + 1, 2)
hologram.set(holoOutlineX, holoOutlineY - 2, holoOutlineZ, 2)
--Верхний левый
for i = 1, 2 do hologram.set(i + holoOutlineX - 1, holoOutlineY - 16, holoOutlineZ, 2) end
hologram.set(holoOutlineX, holoOutlineY - 16, holoOutlineZ + 1, 2)
hologram.set(holoOutlineX, holoOutlineY - 15, holoOutlineZ, 2)
end
local function drawModelOnHolo()
hologram.clear()
for x = 1, #pixels do
for y = 1, #pixels[x] do
for z = 1, #pixels[x][y] do
if pixels[x][y][z] ~= "#" then
hologram.set(x + holoOutlineX, holoOutlineY - y, z + holoOutlineZ, 1)
end
end
end
end
drawBorder()
--drawFrame()
end
local function drawAllViews()
render()
drawModelOnHolo()
drawFrontView()
drawTopView()
drawSideView()
drawTransparentBackground(sizes.image[4].x, sizes.image[4].y, 0xFFFFFF, 0xDDDDDD)
end
local function drawAll()
drawLines()
drawAllViews()
drawRightBar()
end
------------------------------------------ Программа -----------------------------------------------------------------
if sizes.xSize < 150 then ecs.error("Этой программе требуется монитор и видеокарта 3 уровня."); return end
gpu.setResolution(sizes.xSize, sizes.ySize)
ecs.prepareToExit()
changePalette()
drawAll()
while true do
local e = {event.pull()}
if e[1] == "scroll" then
if e[5] == 1 then
if currentLayer > 1 then currentLayer = currentLayer - 1;drawModelOnHolo() end
else
if currentLayer < 16 then currentLayer = currentLayer + 1;drawModelOnHolo() end
end
end
end
------------------------------------------ Выход из программы -----------------------------------------------------------------
gpu.setResolution(sizes.oldResolutionWidth, sizes.oldResolutionHeight)
|
--[[
An implementation of Promises similar to Promise/A+.
]]
local tutils = require(script.Parent.tutils)
local PROMISE_DEBUG = true
-- If promise debugging is on, use a version of pcall that warns on failure.
-- This is useful for finding errors that happen within Promise itself.
local wpcall
if PROMISE_DEBUG then
wpcall = function(f, ...)
local result = { pcall(f, ...) }
if not result[1] then
warn(result[2])
end
return unpack(result)
end
else
wpcall = pcall
end
--[[
Creates a function that invokes a callback with correct error handling and
resolution mechanisms.
]]
local function createAdvancer(callback, resolve, reject)
return function(...)
local result = { wpcall(callback, ...) }
local ok = table.remove(result, 1)
if ok then
resolve(unpack(result))
else
reject(unpack(result))
end
end
end
local function isEmpty(t)
return next(t) == nil
end
local Promise = {}
Promise.__index = Promise
Promise.Status = {
Started = "Started",
Resolved = "Resolved",
Rejected = "Rejected",
}
--[[
Constructs a new Promise with the given initializing callback.
This is generally only called when directly wrapping a non-promise API into
a promise-based version.
The callback will receive 'resolve' and 'reject' methods, used to start
invoking the promise chain.
For example:
local function get(url)
return Promise.new(function(resolve, reject)
spawn(function()
resolve(HttpService:GetAsync(url))
end)
end)
end
get("https://google.com")
:andThen(function(stuff)
print("Got some stuff!", stuff)
end)
]]
function Promise.new(callback)
local promise = {
-- Used to locate where a promise was created
_source = debug.traceback(),
-- A tag to identify us as a promise
_type = "Promise",
_status = Promise.Status.Started,
-- A table containing a list of all results, whether success or failure.
-- Only valid if _status is set to something besides Started
_value = nil,
-- If an error occurs with no observers, this will be set.
_unhandledRejection = false,
-- Queues representing functions we should invoke when we update!
_queuedResolve = {},
_queuedReject = {},
}
setmetatable(promise, Promise)
local function resolve(...)
promise:_resolve(...)
end
local function reject(...)
promise:_reject(...)
end
local ok, err = wpcall(callback, resolve, reject)
if not ok and promise._status == Promise.Status.Started then
reject(err)
end
return promise
end
--[[
Create a promise that represents the immediately resolved value.
]]
function Promise.resolve(value)
return Promise.new(function(resolve)
resolve(value)
end)
end
--[[
Create a promise that represents the immediately rejected value.
]]
function Promise.reject(value)
return Promise.new(function(_, reject)
reject(value)
end)
end
--[[
Returns a new promise that:
* is resolved when all input promises resolve
* is rejected if ANY input promises reject
]]
function Promise.all(...)
local promises = {...}
-- check if we've been given a list of promises, not just a variable number of promises
if type(promises[1]) == "table" and promises[1]._type ~= "Promise" then
-- we've been given a table of promises already
promises = promises[1]
end
return Promise.new(function(resolve, reject)
local isResolved = false
local results = {}
local totalCompleted = 0
local function promiseCompleted(index, result)
if isResolved then
return
end
results[index] = result
totalCompleted = totalCompleted + 1
if totalCompleted == #promises then
resolve(results)
isResolved = true
end
end
if #promises == 0 then
resolve(results)
isResolved = true
return
end
for index, promise in ipairs(promises) do
-- if a promise isn't resolved yet, add listeners for when it does
if promise._status == Promise.Status.Started then
promise:andThen(function(result)
promiseCompleted(index, result)
end):catch(function(reason)
isResolved = true
reject(reason)
end)
-- if a promise is already resolved, move on
elseif promise._status == Promise.Status.Resolved then
promiseCompleted(index, unpack(promise._value))
-- if a promise is rejected, reject the whole chain
else --if promise._status == Promise.Status.Rejected then
isResolved = true
reject(unpack(promise._value))
end
end
end)
end
--[[
Is the given object a Promise instance?
]]
function Promise.is(object)
if type(object) ~= "table" then
return false
end
return object._type == "Promise"
end
--[[
Creates a new promise that receives the result of this promise.
The given callbacks are invoked depending on that result.
]]
function Promise:andThen(successHandler, failureHandler)
-- Even if we haven't specified a failure handler, the rejection will be automatically
-- passed on by the advancer; other promises in the chain may have unhandled rejections,
-- but this one is taken care of as soon as any andThen is connected
self._unhandledRejection = false
-- Create a new promise to follow this part of the chain
return Promise.new(function(resolve, reject)
-- Our default callbacks just pass values onto the next promise.
-- This lets success and failure cascade correctly!
local successCallback = resolve
if successHandler then
successCallback = createAdvancer(successHandler, resolve, reject)
end
local failureCallback = reject
if failureHandler then
failureCallback = createAdvancer(failureHandler, resolve, reject)
end
if self._status == Promise.Status.Started then
-- If we haven't resolved yet, put ourselves into the queue
table.insert(self._queuedResolve, successCallback)
table.insert(self._queuedReject, failureCallback)
elseif self._status == Promise.Status.Resolved then
-- This promise has already resolved! Trigger success immediately.
successCallback(unpack(self._value))
elseif self._status == Promise.Status.Rejected then
-- This promise died a terrible death! Trigger failure immediately.
failureCallback(unpack(self._value))
end
end)
end
--[[
Used to catch any errors that may have occurred in the promise.
]]
function Promise:catch(failureCallback)
return self:andThen(nil, failureCallback)
end
--[[
Yield until the promise is completed.
This matches the execution model of normal Roblox functions.
]]
function Promise:await()
self._unhandledRejection = false
if self._status == Promise.Status.Started then
local result
local bindable = Instance.new("BindableEvent")
self:andThen(function(...)
result = {...}
bindable:Fire(true)
end, function(...)
result = {...}
bindable:Fire(false)
end)
local ok = bindable.Event:Wait()
bindable:Destroy()
if not ok then
error(tostring(result[1]), 2)
end
return unpack(result)
elseif self._status == Promise.Status.Resolved then
return unpack(self._value)
elseif self._status == Promise.Status.Rejected then
error(tostring(self._value[1]), 2)
end
end
function Promise:_resolve(...)
if self._status ~= Promise.Status.Started then
return
end
-- If the resolved value was a Promise, we chain onto it!
if Promise.is((...)) then
-- Without this warning, arguments sometimes mysteriously disappear
if select("#", ...) > 1 then
local message = ("When returning a Promise from andThen, extra arguments are discarded! See:\n\n%s"):format(
self._source
)
warn(message)
end
(...):andThen(function(...)
self:_resolve(...)
end, function(...)
self:_reject(...)
end)
return
end
self._status = Promise.Status.Resolved
self._value = {...}
-- We assume that these callbacks will not throw errors.
for _, callback in ipairs(self._queuedResolve) do
callback(...)
end
end
function Promise:_reject(...)
if self._status ~= Promise.Status.Started then
return
end
self._status = Promise.Status.Rejected
self._value = {...}
-- If there are any rejection handlers, call those!
if not isEmpty(self._queuedReject) then
-- We assume that these callbacks will not throw errors.
for _, callback in ipairs(self._queuedReject) do
callback(...)
end
else
-- At this point, no one was able to observe the error.
-- An error handler might still be attached if the error occurred
-- synchronously. We'll wait one tick, and if there are still no
-- observers, then we should put a message in the console.
self._unhandledRejection = true
-- Rather than trying to figure out how to pack/represent the rejection values,
-- we just stringify the first value and leave the rest alone
local err = tutils.toString((...))
spawn(function()
-- Someone observed the error, hooray!
if not self._unhandledRejection then
return
end
-- Build a reasonable message
local message = ("Unhandled promise rejection:\n\n%s\n\n%s"):format(
err,
self._source
)
warn(message)
end)
end
end
return Promise
|
-- @Date : 2016-04-19 17:21:31
-- @Author : MiaoLian (mlian@ulucu.com)
-- @Version : 1.0
-- @Description :
local ngx_re_match = ngx.re.match
local lib_printable = require("application.lib.sim_printable_lib")
local _M = { _VERSION = '0.01' }
local mt = { __index = _M }
function _M.check_number(self,...)
local num_arg = {...}
if next(num_arg) == nil then
return false
end
local num
for _,value in pairs(num_arg) do
if type(value) == "table" then
for _,value_value in pairs(value) do
num = tonumber(value_value)
if nil == num then
return false
end
end
else
num = tonumber(value)
if nil == num then
return false
end
end
end
return true
end
function _M.check_ipinfo(self,ip)
if not ip then
return false,"nil info"
end
local match,match_err = ngx_re_match(ip, [[^((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))$]],"jo")
if not match or not match[0] then
if match_err then
return false,match_err
end
return false,"wrong ip format"
end
return true,nil
end
function _M.print_r(self,para_tab)
local type_tab = type(para_tab)
if type_tab == "table" then
setmetatable(para_tab, lib_printable)
ngx.say(tostring(para_tab))
elseif type_tab == "string" then
ngx.say(para_tab)
elseif type_tab == "nil" then
ngx.say("nil")
else
ngx.say(tostring(para_tab))
end
end
function _M.say_r(self,ar,sp)
if sp == nil then
sp="";
end
if type(ar)=="table" then
local k,v;
ngx.say("{\n");
for k,v in pairs(ar) do
if type(v)=="table" then
ngx.print(sp," ",k,"=");
self:say_r(v,sp.." ");
else
ngx.say(sp," ",k,"=\"",v,"\",\n");
end
end
ngx.say(sp,"}\n");
else
ngx.say(sp,ar,"\n");
end
end
-- 参数:待分割的字符串,分割字符
-- 返回:子串表.(含有空串)
function _M.split(self, str, split_char)
local sub_str_tab = {};
if split_char == "" then
return sub_str_tab
end
while (true) do
local pos = string.find(str, split_char, 1, true);
if (not pos) then
sub_str_tab[#sub_str_tab + 1] = str;
break;
end
local sub_str = string.sub(str, 1, pos - 1);
sub_str_tab[#sub_str_tab + 1] = sub_str;
str = string.sub(str, pos + 1, #str);
end
return sub_str_tab;
end
function _M.get_keys(self,tab_info)
local tab_keys = {}
local tab_info = tab_info or {}
if type(tab_info) ~= "table" or not next(tab_info) then
return tab_keys
end
for key,_ in pairs(tab_info) do
if key then
table.insert(tab_keys,key)
end
end
return tab_keys
end
function _M.get_uniq_values(self,tab_info)
local tab_keys = {}
local tab_info = tab_info or {}
if type(tab_info) ~= "table" or not next(tab_info) then
return tab_keys
end
for _,value in pairs(tab_info) do
if value then
tab_keys[value] = true
end
end
return self:get_keys(tab_keys)
end
function _M.is_array(self,t)
if type(t) ~= "table" then return false end
local i = 0
for _,_ in pairs(t) do
i = i + 1
if t[i] == nil and t[tostring(i)] == nil then return false end
end
return true
end
function _M.merge_table(self,tab_a,tab_b)
if type(tab_b) ~= "table" then return tab_a end
for k,v in pairs(tab_b) do
tab_a[k] = v
end
return tab_a
end
function _M.new(self)
return setmetatable({}, mt)
end
return _M
|
getgenv().Color = Color3.fromRGB(141, 115, 245)
getgenv().Material = Enum.Material.ForceField
game.RunService.Heartbeat:Connect(function()
if (workspace.CurrentCamera["Left Arm"] ~= nil) then
for i, v in pairs(workspace.CurrentCamera:GetChildren()) do
if (v:IsA("Model") and v.Name:find("Arm")) then
for i2, v2 in pairs(v:GetChildren()) do
if (v2:IsA("MeshPart") or v2:IsA("BasePart")) then
v2.Color = getgenv().Color
v2.Material = getgenv().Material
end
end
end
end
for i, v in pairs(workspace.CurrentCamera:GetChildren()) do
if (v.Name ~= "Left Arm" or v.Name ~= "Right Arm") then
if (v:IsA("Model")) then
for i2, v2 in pairs(v:GetChildren()) do
if (v2:IsA("MeshPart") or v2:IsA("BasePart")) then
v2.Color = getgenv().Color
v2.Material = getgenv().Material
end
end
end
end
end
end
end)
|
-- Change the target FPS here. See README.md for notes on choosing a value.
local targetFps = 50
-- Change this if you want the addon to mess with the FPS counter. This is turned off by default because it's hacky
-- and ugly.
local hackTheFpsCounter = false
local DDPID = {}
DDPID.version = 1
DDPID.name = "DDPID"
function DDPID:New(control)
instance = {}
instance.control = control
setmetatable(instance, { __index = DDPID })
instance:Initialise()
return instance
end
function DDPID:Initialise()
-- PID control terms.
self.Kp = 1
self.Ki = 0.8
self.Kd = 0
self.outMax = 100
self.outMin = 40
self:InitialiseSetPoint(targetFps)
self.enabled = false
if hackTheFpsCounter then
-- Make some vanilla UI controls wider.
local dW = 20
ZO_PerformanceMetersFramerateMeter:SetWidth(ZO_PerformanceMetersFramerateMeter:GetWidth() + dW)
ZO_PerformanceMetersBg:SetWidth(ZO_PerformanceMetersBg:GetWidth() + dW)
ZO_PerformanceMeters:SetWidth(ZO_PerformanceMeters:GetWidth() + dW)
-- Alter the layout. FPS and ping meters are centre-anchored in their parent; switch them to left and right.
ZO_PerformanceMetersFramerateMeter:SetAnchor(LEFT, ZO_PerformanceMeters, LEFT, 0, 0)
ZO_PerformanceMetersLatencyMeter:SetAnchor(LEFT, ZO_PerformanceMetersFramerateMeter, RIGHT, 0, 0)
-- Replace FPS counter setText with our own which delegates to the original.
local SetFpsText = ZO_PerformanceMetersFramerateMeterLabel["SetText"]
local SurrogateSetFpsText = function(it, text)
local stext = string.format("%s/%2.0f", text, self.output or -1)
SetFpsText(it, stext)
end
ZO_PerformanceMetersFramerateMeterLabel["SetText"] = SurrogateSetFpsText
end
end
-- Init or re-init the set point.
function DDPID:InitialiseSetPoint(sp)
self.setPoint = sp
self.output = zo_lerp(self.outMin, self.outMax, 0.5)
self.iTerm = 0 -- Accumulator for integral term.
self.lastT = GetGameTimeMilliseconds() -- Do not initialise at 0 to avoid big time leap on first tick.
self.lastInput = GetFramerate() -- Initial measurement.
end
-- Set draw distance, should be in the range 0..100 which is mapped onto 0.4..2.0 (the measured range of the slider).
function DDPID:ChangeDD(output)
local value = zo_lerp(0.4, 2.0, output/100)
SetSetting(SETTING_TYPE_GRAPHICS, GRAPHICS_SETTING_VIEW_DISTANCE, value, 1)
end
-- Handles the slash command.
function DDPID:SlashCommand(arg)
if arg == nil or arg == '' then
self.enabled = not self.enabled
d("View distance PID control is now " .. (self.enabled and "ON" or "OFF"))
else
local sp = math.max(25, math.floor(tonumber(arg)))
d("View distance control target FPS is now " .. sp)
self:InitialiseSetPoint(sp)
end
end
function DDPID:OnUpdate(_)
if not self.enabled then return end
local t = GetGameTimeMilliseconds()
local dT = t - self.lastT
-- Framerate only updates once per second, so only respond to changes.
local input = GetFramerate()
if (input == self.lastInput) then return end
-- Remainder of this func runs approx 1/sec.
local e = input - self.setPoint
self.iTerm = self.iTerm + (self.Ki * e)
-- Clamp the integral term to prevent wind-up.
if (self.iTerm > self.outMax) then
self.iTerm = self.outMax
elseif self.iTerm < self.outMin then
self.iTerm = self.outMin
end
local dInput = input - self.lastInput
self.output = self.Kp * e + self.iTerm - self.Kd * dInput
if (self.output > self.outMax) then
self.output = self.outMax
elseif self.output < self.outMin then
self.output = self.outMin
end
--d(string.format("input=%.3f, e=%.3f, iTerm=%.3f, dI=%.3f => %.1f", input, e, self.iTerm, dInput, self.output))
self:ChangeDD(self.output)
self.lastInput = input
self.lastT = t
end
function DDPID_OnInitialized(self)
DrawDistancePID = DDPID:New(self)
SLASH_COMMANDS["/ddpid"] = function(arg) DrawDistancePID:SlashCommand(arg) end
DrawDistancePID:SlashCommand()
end
|
local NeP, g = NeP, NeP._G
local KEYBINDS = {
-- Shift
['shift'] = function() return g.IsShiftKeyDown() end,
['lshift'] = function() return g.IsLeftShiftKeyDown() end,
['rshift'] = function() return g.IsRightShiftKeyDown() end,
-- Control
['control'] = function() return g.IsControlKeyDown() end,
['lcontrol'] = function() return g.IsLeftControlKeyDown() end,
['rcontrol'] = function() return g.IsRightControlKeyDown() end,
-- Alt
['alt'] = function() return g.IsAltKeyDown() end,
['lalt'] = function() return g.IsLeftAltKeyDown() end,
['ralt'] = function() return g.IsRightAltKeyDown() end,
}
NeP.DSL:Register("keybind", function(_, Arg)
Arg = Arg:lower()
return (KEYBINDS[Arg] and KEYBINDS[Arg]() or g.IsKeyDown(Arg:upper())) and not g.GetCurrentKeyBoardFocus()
end)
NeP.DSL:Register("mouse", function(_, Arg)
Arg = tonumber(Arg:lower())
return g.IsMouseButtonDown(Arg) and not g.GetCurrentKeyBoardFocus()
end)
|
-- This script was generated by Lokasenna_Show only specified tracks.lua
local settings = {
showsiblings = false,
showparents = false,
tcp = false,
mcp = true,
matchonlytop = true,
search = "Guitar",
showchildren = true,
matchmultiple = true,
}
local info = debug.getinfo(1,'S');
script_path = info.source:match[[^@?(.*[\/])[^\/]-$]]
local script_filename = ({reaper.get_action_context()})[2]:match("([^/\\]+)$")
local function Msg(str)
reaper.ShowConsoleMsg(tostring(str) .. "\n")
end
------------------------------------
-------- Search Functions ----------
------------------------------------
-- Returns true if the individual words of str_b all appear in str_a
local function fuzzy_match(str_a, str_b)
if not (str_a and str_b) then return end
str_a, str_b = string.lower(tostring(str_a)), string.lower(tostring(str_b))
--Msg("\nfuzzy match, looking for:\n\t" .. str_b .. "\nin:\n\t" .. str_a .. "\n")
for word in string.gmatch(str_b, "[^%s]+") do
--Msg( tostring(word) .. ": " .. tostring( string.match(str_a, word) ) )
if not string.match(str_a, word) then return end
end
return true
end
local function is_match(str, tr_name, tr_idx)
if str:sub(1, 1) == "#" then
-- Force an integer until/unless I come up with some sort of multiple track syntax
str = tonumber(str:sub(2, -1))
return str and (math.floor( tonumber(str) ) == tr_idx)
elseif tostring(str) then
return fuzzy_match(tr_name, tostring(str))
end
end
local function merge_tables(...)
local tables = {...}
local ret = {}
for i = #tables, 1, -1 do
if tables[i] then
for k, v in pairs(tables[i]) do
if v then ret[k] = v end
end
end
end
return ret
end
-- Returns an array of MediaTrack == true for all parents of the given MediaTrack
local function recursive_parents(track)
if reaper.GetTrackDepth(track) == 0 then
return {[track] = true}
else
local ret = recursive_parents( reaper.GetParentTrack(track) )
ret[track] = true
return ret
end
end
local function get_children(tracks)
local children = {}
for idx in pairs(tracks) do
local tr = reaper.GetTrack(0, idx - 1)
local i = idx + 1
while i <= reaper.CountTracks(0) do
children[i] = recursive_parents( reaper.GetTrack(0, i-1) )[tr] == true
if not children[i] then break end
i = i + 1
end
end
return children
end
local function get_parents(tracks)
local parents = {}
for idx in pairs(tracks) do
local tr = reaper.GetTrack(0, idx - 1)
for nextParent in pairs( recursive_parents(tr)) do
parents[ math.floor( reaper.GetMediaTrackInfo_Value(nextParent, "IP_TRACKNUMBER") ) ] = true
end
end
return parents
end
local function get_top_level_tracks()
local top = {}
for i = 1, reaper.CountTracks() do
if reaper.GetTrackDepth( reaper.GetTrack(0, i-1) ) == 0 then
top[i] = true
end
end
return top
end
local function get_siblings(tracks)
local siblings = {}
for idx in pairs(tracks) do
local tr = reaper.GetTrack(0, idx - 1)
local sibling_depth = reaper.GetTrackDepth(tr)
if sibling_depth > 0 then
local parent = reaper.GetParentTrack(tr)
local children = get_children( {[reaper.GetMediaTrackInfo_Value(parent, "IP_TRACKNUMBER")] = true} )
for child_idx in pairs(children) do
-- Can't use siblings[idx] = ___ here because we don't want to set existing
-- siblings to false
if reaper.GetTrackDepth( reaper.GetTrack(0, child_idx-1) ) == sibling_depth then
siblings[child_idx] = true
end
end
else
-- Find all top-level tracks
siblings = merge_tables(siblings, get_top_level_tracks())
end
end
return siblings
end
local function get_tracks_to_show(settings)
--[[
settings = {
search = str,
matchmultiple = bool,
matchonlytop = bool,
showchildren = bool,
showparents = bool,
mcp = bool,
tcp = bool
}
]]--
local matches = {}
-- Abort if we don't need to be doing this
if not (settings.tcp or settings.mcp) then return nil end
-- Find all matches
for i = 1, reaper.CountTracks(0) do
local tr = reaper.GetTrack(0, i - 1)
local _, name = reaper.GetTrackName(tr, "")
local idx = math.floor( reaper.GetMediaTrackInfo_Value(tr, "IP_TRACKNUMBER") )
local ischild = reaper.GetTrackDepth(tr) > 0
if is_match(settings.search, name, idx) and not (ischild and settings.matchonlytop) then
matches[idx] = true
if not settings.matchmultiple then break end
end
end
-- Hacky way to check if length of a hash table == 0
for k in pairs(matches) do
if not k then return {} end
end
local parents = settings.showparents and get_parents(matches)
local children = settings.showchildren and get_children(matches)
local siblings = settings.showsiblings and get_siblings(matches)
return merge_tables(matches, parents, children, siblings)
end
local function select_first_visible_MCP()
for i = 1, reaper.CountTracks(0) do
local tr = reaper.GetTrack(0, i - 1)
if reaper.IsTrackVisible(tr, true) then
reaper.SetOnlyTrackSelected(tr)
break
end
end
end
local function set_visibility(tracks, settings)
if not tracks then return end
--if not tracks or #tracks == 0 then return end
reaper.Undo_BeginBlock()
reaper.PreventUIRefresh(1)
for i = 1, reaper.CountTracks(0) do
local tr = reaper.GetTrack(0, i - 1)
if settings.tcp then
reaper.SetMediaTrackInfo_Value(tr, "B_SHOWINTCP", tracks[i] and 1 or 0)
end
if settings.mcp then
reaper.SetMediaTrackInfo_Value(tr, "B_SHOWINMIXER", tracks[i] and 1 or 0)
end
end
if settings.mcp then
select_first_visible_MCP()
end
reaper.PreventUIRefresh(-1)
reaper.Undo_EndBlock("Show only specified tracks", -1)
reaper.TrackList_AdjustWindows(false)
reaper.UpdateArrange()
end
------------------------------------
-------- Standalone startup --------
------------------------------------
if script_filename ~= "Lokasenna_Show only specified tracks.lua" then
local tracks = settings and get_tracks_to_show(settings)
if tracks then
set_visibility( tracks, settings )
else
reaper.MB(
"Error reading the script's settings. Make sure you haven't edited the script or changed its filename.", "Whoops!", 0)
end
return
end
|
return {
-- Polar Night
dark_black = '#2e3440', -- bg
black = '#3b4252',
dark_black_inactive = "#353B49",
bright_black = '#434c5e',
gray = '#4c566a',
-- Custom
darkish_black = '#3B414D',
-- grayish = '#667084',
grayish = '#7b88a1',
dark_black_alt = '#2B303B',
-- Snow Storm
dark_white = '#d8dee9',
white = '#e5e9f0',
bright_white = '#eceff4',
-- Frost
cyan = '#8fbcbb',
bright_cyan = '#88c0d0',
blue = '#81a1c1',
intense_blue = '#5e81ac',
-- Aurora
red = '#bf616a',
orange = '#d08770',
yellow = '#ebcb8b',
green = '#a3be8c',
purple = '#b48ead',
pink = '#d1b3c4'
}
|
object_tangible_quest_outbreak_group_boss_fight_terminal = object_tangible_quest_outbreak_shared_group_boss_fight_terminal:new {
}
ObjectTemplates:addTemplate(object_tangible_quest_outbreak_group_boss_fight_terminal, "object/tangible/quest/outbreak/group_boss_fight_terminal.iff")
|
local serpent = require("nes.libs.serpent")
local UTILS = require("nes.utils")
local CPU = require("nes.cpu")
local band, bor, bxor, bnot, lshift, rshift = bit.band, bit.bor, bit.bxor, bit.bnot, bit.lshift, bit.rshift
local map, rotatePositiveIdx, nthBitIsSet, nthBitIsSetInt, range, bind =
UTILS.map,
UTILS.rotatePositiveIdx,
UTILS.nthBitIsSet,
UTILS.nthBitIsSetInt,
UTILS.range,
UTILS.bind
local ROM = {}
ROM._mt = {__index = ROM}
--[[
There are different ROM mappers that map the ROM PRG and CHR memory to CP addresses.
There's a code in the header for each mapper. MAPPER_DB is a mapping of codes into ROM classes.
The base class uses the most common one (NROM).
]]
ROM.MAPPER_DB = {
[0x00] = ROM
}
function ROM:initialize(conf, cpu, ppu, basename, bytes, str)
self.conf = conf or {}
self.cpu = cpu
self.ppu =
ppu or
{
set_chr_mem = function()
end
}
self.basename = basename
local idx = 0
local prg_count, chr_count, wrk_count
do
local header_size = 16
prg_count, chr_count, wrk_count = self:parse_header({table.unpack(bytes, idx + 1, idx + header_size)}, str)
idx = header_size
end
self.prg_banks = {}
do
local prg_bank_size = 0x4000
if #bytes < prg_bank_size * prg_count then
error "EOF in ROM bank data"
end
for i = 1, prg_count do
self.prg_banks[i] = UTILS.copy(bytes, prg_bank_size, idx)
idx = idx + prg_bank_size
end
end
self.chr_banks = {}
do
local chr_bank_size = 0x2000
if #bytes < chr_bank_size * chr_count + 0x4000 * prg_count then
error "EOF in CHR bank data"
end
for i = 1, chr_count do
self.chr_banks[i] = UTILS.copy(bytes, chr_bank_size, idx)
idx = idx + chr_bank_size
end
end
self.prg_ref = {}
UTILS.fill(self.prg_ref, 0, 0x10000)
for i = 0x8000 + 1, 0x4000 + 0x8000 do
self.prg_ref[i] = self.prg_banks[1][i - 0x8000]
end
for i = 0xc000 + 1, 0x4000 + 0xc000 do
self.prg_ref[i] = self.prg_banks[#(self.prg_banks)][i - 0xc000]
end
self.chr_ram = chr_count == 0 -- No CHR bank implies CHR-RAM (writable CHR bank)
self.chr_ref = self.chr_ram and (UTILS.fill({}, 0, 0x2000)) or UTILS.copy(self.chr_banks[1])
self.wrk_readable = wrk_count > 0
self.wrk_writable = false
self.wrk =
wrk_count > 0 and
UTILS.map(
range(0x6000, 0x7fff),
function(n)
return rshift(n, 8)
end
) or
nil
self:init()
self.ppu:nametables(self.mirroring)
self.ppu:set_chr_mem(self.chr_ref, self.chr_ram)
end
function ROM:init()
end
function ROM:reset()
self.cpu:add_mappings(range(0x8000, 0xffff), UTILS.tGetter(self.prg_ref), CPU.UNDEFINED)
end
function ROM:peek_6000(addr)
return self.wrk_readable and self.wrk[addr - 0x6000] or rshift(addr, 8)
end
function ROM:poke_6000(addr, data)
if self.wrk_writable then
self.wrk[addr - 0x6000] = data
end
end
function ROM:vsync()
end
function ROM:load_battery()
if not self.battery then
return
end
local sav = self.basename + ".sav"
self.wrk.replace(sav.bytes)
local inp = assert(io.open(sav, "rb"))
self.wrk = serpent.load(inp:read("*all"))
assert(inp:close())
end
function ROM:save_battery()
if not self.battery then
return
end
local sav = self.basename + ".sav"
print("Saving: " .. sav)
local out = assert(io.open(sav, "wb"))
out:write(serpent.dump(self.wrk))
assert(out:close())
end
function ROM:new(conf, cpu, ppu, basename, bytes, str)
local rom = {}
setmetatable(rom, ROM._mt)
rom:initialize(conf, cpu, ppu, basename, bytes, str)
return rom
end
function ROM.load(conf, cpu, ppu)
local filename = conf.romfile
local path, basename, extension = string.match(filename, "(.-)([^\\]-([^\\%.]+))$")
local inp = assert(io.open(filename, "rb"))
local str = inp:read("*all")
assert(inp:close())
local blob = {}
for i = 1, str:len() do
blob[i] = str:byte(i, i)
end
local mapper = bor(rshift(blob[7], 4), band(blob[8], 0xf0))
local klass = ROM.MAPPER_DB[mapper]
if not klass then
error(string.format("Unsupported mapper type 0x%02x", mapper))
end
return klass:new(conf, cpu, ppu, basename, blob, str)
end
function ROM:parse_header(buf, str)
if #buf < 16 then
error "Missing 16-byte header"
end
local header = {
check = str:sub(1, 4),
trainer = nthBitIsSet(buf[7], 2),
VS = nthBitIsSet(buf[8], 0),
PAl = nthBitIsSet(buf[10], 0),
prg_pages = buf[5],
chr_pages = buf[6],
battery = nthBitIsSet(buf[7], 1),
mapper = bor(rshift(buf[7], 4), band(buf[8], 0xf0)),
mapping = not nthBitIsSet(buf[7], 0) and "horizontal" or "vertical"
}
if header.check ~= "NES\x1a" then
error "Missing 'NES' constant in header"
end
if header.trainer then
error "trainer not supported"
end
if header.VS then
error "VS cart not supported"
end
if header.PAL then
error "PAL not supported"
end
local prg_banks = buf[5] -- program page count
local chr_banks = buf[6] --vrom page count
self.mirroring = not nthBitIsSet(buf[7], 0) and "horizontal" or "vertical"
if nthBitIsSet(buf[7], 3) then
self.mirroring = "four_screen"
end
self.battery = nthBitIsSet(buf[7], 1)
self.mapper = bor(rshift(buf[7], 4), band(buf[8], 0xf0))
local ram_banks = math.max(1, buf[9])
return prg_banks, chr_banks, ram_banks
end
local UxROM = {}
UxROM._mt = {__index = UxROM}
setmetatable(UxROM, {__index = ROM})
function UxROM:new(...)
local rom = ROM:new(unpack(...))
setmetatable(rom, UxROM._mt)
return rom
end
function UxROM:reset()
self.cpu:add_mappings(range(0x8000, 0xffff), UTILS.tGetter(self.prg_ref), bind(self.poke_8000, self))
end
function UxROM:poke_8000(_addr, data)
local j = band(data, 7)
for i = 0x8000 + 1, 0x4000 do
self.prg_ref[i] = self.prg_banks[j][i - 0x8000]
end
end
ROM.MAPPER_DB[0x02] = UxROM
local CNROM = {}
CNROM._mt = {__index = CNROM}
setmetatable(CNROM, {__index = ROM})
function CNROM:new(...)
local rom = ROM:new(unpack(...))
setmetatable(rom, CNROM._mt)
return rom
end
function CNROM:reset()
self.cpu:add_mappings(
range(0x8000, 0xffff),
UTILS.tGetter(self.prg_ref),
self.chr_ram and bind(self.poke_8000, self) or CPU.UNDEFINED
)
end
function CNROM:poke_8000(_addr, data)
local j = band(data, 3)
self.chr_ref = {unpack(self.chr_banks[j])}
end
ROM.MAPPER_DB[0x03] = CNROM
local MMC1 = {}
MMC1._mt = {__index = MMC1}
setmetatable(MMC1, {__index = ROM})
function MMC1:new(...)
local rom = {}
setmetatable(rom, MMC1._mt)
rom:initialize(...)
return rom
end
local NMT_MODE = {"first", "second", "vertical", "horizontal"}
local PRG_MODE = {"conseq", "conseq", "fix_first", "fix_last"}
local CHR_MODE = {"conseq", "noconseq"}
function MMC1:init()
self.chr_mode = nil
self.nmt_mode = nil
self.prg_mode = nil
self.prg_bank = 0
self.chr_bank_0 = 0
self.chr_bank_1 = 0
end
function MMC1:reset()
self.shift = 0
self.shift_count = 0
--self.chr_banks = self.chr_banks.flatten.each_slice(0x1000).to_a
local chr = self.chr_banks
local old = UTILS.copy(self.chr_banks)
for i = 2, #chr do
chr[i] = nil
end
chr[1] = {}
local j, k = 1, 1
for i = 1, #old do
local bank = old[i]
for h = 1, #bank do
local x = bank[h]
if x then
chr[j][k] = x
k = k + 1
if k == 0x1000 + 1 then
j = j + 1
k = 1
if not chr[j] then
chr[j] = {}
end
end
end
end
end
self.wrk_readable = true
self.wrk_writable = true
self.cpu:add_mappings(range(0x6000, 0x7fff), bind(self.peek_6000, self), bind(self.poke_6000, self))
self.cpu:add_mappings(range(0x8000, 0xffff), UTILS.tGetter(self.prg_ref), bind(self.poke_prg, self))
self:update_nmt("horizontal")
self:update_prg("fix_last", 0, 0)
self:update_chr("conseq", 0, 0)
end
function MMC1:poke_prg(addr, val)
if nthBitIsSetInt(val, 7) == 1 then
self.shift = 0
self.shift_count = 0
return
end
self.shift = bor(self.shift, lshift(nthBitIsSetInt(val, 0), self.shift_count))
self.shift_count = self.shift_count + 1
if self.shift_count == 0x05 then
local x = band(rshift(addr, 13), 0x3)
if x == 0 then -- control
local nmt_mode = NMT_MODE[1 + band(self.shift, 3)]
local prg_mode = PRG_MODE[1 + band(rshift(self.shift, 2), 3)]
local chr_mode = CHR_MODE[1 + band(rshift(self.shift, 4), 1)]
self:update_nmt(nmt_mode)
self:update_prg(prg_mode, self.prg_bank, self.chr_bank_0)
self:update_chr(chr_mode, self.chr_bank_0, self.chr_bank_1)
elseif x == 1 then -- change chr_bank_0
-- update_prg might modify self.chr_bank_0 and prevent updating chr bank,
-- so keep current value.
local bak_chr_bank_0 = self.chr_bank_0
self:update_prg(self.prg_mode, self.prg_bank, self.shift)
self.chr_bank_0 = bak_chr_bank_0
self:update_chr(self.chr_mode, self.shift, self.chr_bank_1)
elseif x == 2 then -- change chr_bank_1
self:update_chr(self.chr_mode, self.chr_bank_0, self.shift)
elseif x == 3 then -- change png_bank
self:update_prg(self.prg_mode, self.shift, self.chr_bank_0)
end
self.shift = 0
self.shift_count = 0
end
end
function MMC1:update_nmt(nmt_mode)
if self.nmt_mode == nmt_mode then
return
end
self.nmt_mode = nmt_mode
self.ppu:nametables(self.nmt_mode)
end
function MMC1:update_prg(prg_mode, prg_bank, chr_bank_0)
if prg_mode == self.prg_mode and prg_bank == self.prg_bank and chr_bank_0 == self.chr_bank_0 then
return
end
self.prg_mode, self.prg_bank, self.chr_bank_0 = prg_mode, prg_bank, chr_bank_0
local high_bit = band(chr_bank_0, 0x10, #self.prg_banks - 1)
local prg_bank_ex = band(bor(band(self.prg_bank, 0x0f), high_bit), #self.prg_banks - 1)
local lower
local upper
if self.prg_mode == "conseq" then
lower = band(prg_bank_ex, bnot(1))
upper = lower + 1
elseif self.prg_mode == "fix_first" then
lower = 0
upper = prg_bank_ex
elseif self.prg_mode == "fix_last" then
lower = prg_bank_ex
upper = bor(band(#self.prg_banks - 1, 0x0f), high_bit)
end
for i = 1, 0x4000 + 1 do
self.prg_ref[i + 0x8000] = self.prg_banks[1 + lower][i]
end
for i = 1, 0x4000 + 1 do
self.prg_ref[i + 0xc000] = self.prg_banks[1 + upper][i]
end
end
function MMC1:update_chr(chr_mode, chr_bank_0, chr_bank_1)
if chr_mode == self.chr_mode and chr_bank_0 == self.chr_bank_0 and chr_bank_1 == self.chr_bank_1 then
return
end
self.chr_mode, self.chr_bank_0, self.chr_bank_1 = chr_mode, chr_bank_0, chr_bank_1
if self.chr_ram then
return
end
local lower
local upper
self.ppu:update(0)
if self.chr_mode == "conseq" then
lower = band(self.chr_bank_0, 0x1e) + 1
upper = lower + 1
else
lower = self.chr_bank_0 + 1
upper = self.chr_bank_1 + 1
end
for i = 1, 0x1000 do
self.chr_ref[i] = self.chr_banks[lower][i]
end
for i = 1, 0x1000 do
self.chr_ref[i + 0x1000] = self.chr_banks[upper][i]
end
end
ROM.MAPPER_DB[0x01] = MMC1
local MMC3 = {}
MMC3._mt = {__index = MMC3}
setmetatable(MMC3, {__index = ROM})
function MMC3:new(...)
local rom = ROM:new(unpack(...))
setmetatable(rom, MMC3._mt)
return rom
end
function MMC3:init(rev) -- rev = :A or :B or :C
rev = rev or "B"
self.persistant = rev ~= "A"
self.prg_banks = self.prg_banks.flatten.each_slice(0x2000).to_a
self.prg_bank_swap = false
self.chr_banks = self.chr_banks.flatten.each_slice(0x0400).to_a
self.chr_bank_mapping = UTILS.fill({}, nil, 8)
self.chr_bank_swap = false
end
function MMC3:reset()
self.wrk_readable = true
self.wrk_writable = false
local poke_a000 = self.mirroring ~= "FourScreen" and bind(self.poke_a000, self) or CPU.UNDEFINED
self.cpu:add_mappings(range(0x6000, 0x7fff), bind(self.peek_6000, self), bind(self.poke_6000, self))
local g = UTILS.tGetter(self.prg_ref)
self.cpu:add_mappings(range(0x8000, 0x9fff, 2), g, bind(self.poke_8000, self))
self.cpu:add_mappings(range(0x8001, 0x9fff, 2), g, bind(self.poke_8001, self))
self.cpu:add_mappings(range(0xa000, 0xbfff, 2), g, poke_a000)
self.cpu:add_mappings(range(0xa001, 0xbfff, 2), g, bind(self.poke_a001, self))
self.cpu:add_mappings(range(0xc000, 0xdfff, 2), g, bind(self.poke_c000, self))
self.cpu:add_mappings(range(0xc001, 0xdfff, 2), g, bind(self.poke_c001, self))
self.cpu:add_mappings(range(0xe000, 0xffff, 2), g, bind(self.poke_e000, self))
self.cpu:add_mappings(range(0xe001, 0xffff, 2), g, bind(self.poke_e001, self))
self:update_prg(0x8000, 0)
self:update_prg(0xa000, 1)
self:update_prg(0xc000, -2)
self:update_prg(0xe000, -1)
for i = 0, 7 do
self:update_chr(i * 0x400, i)
end
self.clock = 0
if PPU then
self.hold = PPU.RP2C02_CC * 16
end
self.ppu:monitor_a12_rising_edge(self)
self.cpu.ppu_sync = true
self.count = 0
self.latch = 0
self.reload = false
self.enabled = false
end
-- prg_bank_swap = F T
-- 0x8000..0x9fff: 0 2
-- 0xa000..0xbfff: 1 1
-- 0xc000..0xdfff: 2 0
-- 0xe000..0xffff: 3 3
function MMC3:update_prg(addr, bank)
bank = bank % (#self.prg_banks)
if self.prg_bank_swap and addr[13] == 0 then
addr = bxor(addr, 0x4000)
end
for i = addr + 1, addr + 0x2000 + 1 do
self.prg_ref[i] = self.prg_banks[bank][i - addr]
end
end
function MMC3:update_chr(addr, bank)
if self.chr_ram then
return
end
local idx = addr / 0x400
bank = bank % (#self.chr_banks)
if self.chr_bank_mapping[idx] == bank then
return
end
if self.chr_bank_swap then
addr = bxor(addr, 0x1000)
end
self.ppu:update(0)
for i = 1, 0x400 + 1 do
self.chr_ref[i + addr] = self.chr_banks[bank][i]
end
self.chr_bank_mapping[idx] = bank
end
function MMC3:poke_8000(_addr, data)
self.reg_select = band(data, 7)
local prg_bank_swap = data[6] == 1
local chr_bank_swap = data[7] == 1
if prg_bank_swap ~= self.prg_bank_swap then
self.prg_bank_swap = prg_bank_swap
for i = 0x8000 + 1, 0x8000 + 0x2000 + 1 do
self.prg_ref[i] = self.prg_ref[bank][i - 0x8000 + 0xc000]
end
for i = 0xc000 + 1, 0xc000 + 0x2000 + 1 do
self.chr_ref[i] = self.prg_ref[bank][i - 0xc000 + 0x8000]
end
--self.prg_ref[0x8000, 0x2000], self.prg_ref[0xc000, 0x2000] = self.prg_ref[0xc000, 0x2000], self.prg_ref[0x8000, 0x2000]
end
if chr_bank_swap ~= self.chr_bank_swap then
self.chr_bank_swap = chr_bank_swap
if not self.chr_ram then
self.ppu.update(0)
self.chr_ref = UTILS.rotate(self.chr_ref, 0x1000)
self.chr_bank_mapping = UTILS.rotate(self.chr_bank_mapping, 4)
end
end
end
function MMC3:poke_8001(_addr, data)
if self.reg_select < 6 then
if self.reg_select < 2 then
self:update_chr(self.reg_select * 0x0800, band(data, 0xfe))
self:update_chr(self.reg_select * 0x0800 + 0x0400, bor(data, 0x01))
else
self:update_chr((self.reg_select - 2) * 0x0400 + 0x1000, data)
end
else
self:update_prg((self.reg_select - 6) * 0x2000 + 0x8000, band(data, 0x3f))
end
end
function MMC3:poke_a000(_addr, data)
self.ppu:nametables(data[0] == 1 and "horizontal" or "vertical")
end
function MMC3:poke_a001(_addr, data)
self.wrk_readable = data[7] == 1
self.wrk_writable = data[6] == 0 and self.wrk_readable
end
function MMC3:poke_c000(_addr, data)
self.ppu:update(0)
self.latch = data
end
function MMC3:poke_c001(_addr, _data)
self.ppu:update(0)
self.reload = true
end
function MMC3:poke_e000(_addr, _data)
self.ppu:update(0)
self.enabled = false
self.cpu:clear_irq(CPU.IRQ_EXT)
end
function MMC3:poke_e001(_addr, _data)
self.ppu:update(0)
self.enabled = true
end
function MMC3:vsync()
self.clock = self.clock > self.cpu.next_frame_clock and self.clock - self.cpu.next_frame_clock or 0
end
function MMC3:a12_signaled(cycle)
local clk = self.clock
self.clock = cycle + self.hold
if cycle < clk then
return
end
local flag = self.persistant or self.count > 0
if self.reload then
self.reload = false
self.count = self.latch
elseif self.count == 0 then
self.count = self.latch
else
self.count = self.count - 1
end
if flag and self.count == 0 and self.enabled then
self.cpu:do_irq(CPU.IRQ_EXT, cycle)
end
end
ROM.MAPPER_DB[0x04] = MMC3
return ROM
|
-- Online Player List Soft Module
-- Displays a list of current players
-- Uses locale player-list.cfg
-- @usage require('modules/common/online-player-list')
-- ------------------------------------------------------- --
-- @author Denis Zholob (DDDGamer)
-- github: https://github.com/deniszholob/factorio-softmod-pack
-- ======================================================= --
-- Dependencies --
-- ======================================================= --
local mod_gui = require('mod-gui') -- From `Factorio\data\core\lualib`
local GUI = require('stdlib/GUI')
local Sprites = require('util/Sprites')
local Math = require('util/Math')
local Time = require('util/Time')
-- Constants --
-- ======================================================= --
local Player_List = {
MENU_BTN_NAME = 'btn_menu_playerlist',
MASTER_FRAME_NAME = 'frame_playerlist',
CHECKBOX_OFFLINE_PLAYERS = 'chbx_playerlist_players',
SPRITE_NAMES = {
menu = Sprites.character,
inventory = Sprites.item_editor_icon,
inventory_empty = Sprites.slot_icon_armor
-- inventory_alt = Sprites.grey_rail_signal_placement_indicator,
},
-- Utf shapes https://www.w3schools.com/charsets/ref_utf_geometric.asp
-- Utf symbols https://www.w3schools.com/charsets/ref_utf_symbols.asp
ONLINE_SYMBOL = '●',
OFFLINE_SYMBOL = '○',
ADMIN_SYMBOL = '★',
OWNER = 'hidden_relic',
BTN_INVENTORY_OWNER_ONLY = false, -- Only owner can open inventory or all admins
BTN_INVENTORY_TAGET_ADMINS = true, -- Can only open reg players or target admins too
PROGRESS_BAR_HEIGHT = 4,
}
-- Event Functions --
-- ======================================================= --
-- When new player joins add the playerlist btn to their GUI
-- Redraw the playerlist frame to update with the new player
-- @param event on_player_joined_game
function Player_List.on_player_joined_game(event)
local player = game.players[event.player_index]
Player_List.draw_playerlist_btn(player)
Player_List.draw_playerlist_frame()
end
-- On Player Leave
-- Clean up the GUI in case this mod gets removed next time
-- Redraw the playerlist frame to update
-- @param event on_player_left_game
function Player_List.on_player_left_game(event)
local player = game.players[event.player_index]
GUI.destroy_element(mod_gui.get_button_flow(player)[Player_List.MENU_BTN_NAME])
GUI.destroy_element(mod_gui.get_frame_flow(player)[Player_List.MASTER_FRAME_NAME])
Player_List.draw_playerlist_frame()
end
-- Toggle playerlist is called if gui element is playerlist button
-- @param event on_gui_click
function Player_List.on_gui_click(event)
local player = game.players[event.player_index]
local el_name = event.element.name
-- Window toggle
if el_name == Player_List.MENU_BTN_NAME then
GUI.toggle_element(mod_gui.get_frame_flow(player)[Player_List.MASTER_FRAME_NAME])
end
-- Checkbox toggle to display only online players or not
if (el_name == Player_List.CHECKBOX_OFFLINE_PLAYERS) then
player_config = Player_List.getConfig(player)
player_config.show_offline_players = not player_config.show_offline_players
Player_List.draw_playerlist_frame()
end
-- LMB will open the map view to the clicked player
if (string.find(el_name, "lbl_player_") and
event.button == defines.mouse_button_type.left) then
local target_player = game.players[string.sub(el_name, 12)]
player.zoom_to_world(target_player.position, 2)
end
end
function Player_List.getLblPlayerName(player)
return 'lbl_player_' .. player.name
end
-- Refresh the playerlist after 10 min
-- @param event on_tick
function Player_List.on_tick(event)
local refresh_period = 1 --(min)
if (Time.tick_to_min(game.tick) % refresh_period == 0) then
Player_List.draw_playerlist_frame()
end
end
-- When new player uses decon planner
-- @param event on_player_deconstructed_area
function Player_List.on_player_deconstructed_area(event)
local player = game.players[event.player_index]
Player_List.getConfig(player).decon = true
end
-- When new player mines something
-- @param event on_player_mined_item
function Player_List.on_player_mined_item(event)
local player = game.players[event.player_index]
Player_List.getConfig(player).mine = true
end
-- Event Registration --
-- ======================================================= --
Event.register(defines.events.on_gui_checked_state_changed, Player_List.on_gui_click)
Event.register(defines.events.on_gui_click, Player_List.on_gui_click)
Event.register(defines.events.on_player_joined_game, Player_List.on_player_joined_game)
Event.register(defines.events.on_player_left_game, Player_List.on_player_left_game)
Event.register(defines.events.on_tick, Player_List.on_tick)
Event.register(defines.events.on_player_deconstructed_area, Player_List.on_player_deconstructed_area)
Event.register(defines.events.on_player_mined_item, Player_List.on_player_mined_item)
-- Helper Functions --
-- ======================================================= --
-- Create button for player if doesnt exist already
-- @param player LuaPlayer
function Player_List.draw_playerlist_btn(player)
if mod_gui.get_button_flow(player)[Player_List.MENU_BTN_NAME] == nil then
mod_gui.get_button_flow(player).add(
{
type = 'sprite-button',
name = Player_List.MENU_BTN_NAME,
sprite = Player_List.SPRITE_NAMES.menu,
-- caption = 'Online Players',
tooltip = {'player_list.btn_tooltip'}
}
)
end
end
-- Draws a pane on the left listing all of the players currentely on the server
function Player_List.draw_playerlist_frame()
local player_list = {}
-- Copy player list into local list
for i, player in pairs(game.players) do
table.insert(player_list, player)
end
-- Sort players based on admin role, and time played
-- Admins first, highest playtime first
table.sort(player_list, Player_List.sort_players)
for i, player in pairs(game.players) do
local master_frame = mod_gui.get_frame_flow(player)[Player_List.MASTER_FRAME_NAME]
-- Draw the vertical frame on the left if its not drawn already
if master_frame == nil then
master_frame =
mod_gui.get_frame_flow(player).add(
{type = 'frame', name = Player_List.MASTER_FRAME_NAME, direction = 'vertical'}
)
end
-- Clear and repopulate player list
GUI.clear_element(master_frame)
-- Flow
local flow_header = master_frame.add({type = 'flow', direction = 'horizontal'})
flow_header.style.horizontal_spacing = 20
-- Draw checkbox
flow_header.add(
{
type = 'checkbox',
name = Player_List.CHECKBOX_OFFLINE_PLAYERS,
caption = {'player_list.checkbox_caption'},
tooltip = {'player_list.checkbox_tooltip'},
state = Player_List.getConfig(player).show_offline_players or false
}
)
-- Draw total number
flow_header.add(
{
type = 'label',
caption = {'player_list.total_players', #game.players, #game.connected_players}
}
)
-- Add scrollable section to content frame
local scrollable_content_frame =
master_frame.add(
{
type = 'scroll-pane',
vertical_scroll_policy = 'auto-and-reserve-space',
horizontal_scroll_policy = 'never'
}
)
scrollable_content_frame.style.maximal_height = 600
-- List all players
for j, list_player in pairs(player_list) do
if (list_player.connected or Player_List.getConfig(player).show_offline_players) then
Player_List.add_player_to_list(scrollable_content_frame, player, list_player)
end
end
end
end
-- @tparam LuaPlayer player the one who is doing the opening (display the other player inventory for this player)
-- @tparam LuaPlayer target_player who's inventory to open
function Player_List.open_player_inventory(player, target_player)
player.opened = target_player
-- Tried to do a toggle, but cant close; for some reason opened is always nil even after setting
-- if(player.opened == game.players[target_player.name]) then
-- player.opened = nil
-- elseif(not player.opened) then
-- player.opened = game.players[target_player.name]
-- end
end
function Player_List.canDisplay(player, target_player)
if (
-- Only for owners
((Player_List.BTN_INVENTORY_OWNER_ONLY and player.name == Player_List.OWNER) and
-- Reg players or both reg players and admins
(Player_List.BTN_INVENTORY_TAGET_ADMINS or not target_player.admin)) or
-- For all admins
((not Player_List.BTN_INVENTORY_OWNER_ONLY and player.admin == true) and
-- Reg players or both reg players and admins
(Player_List.BTN_INVENTORY_TAGET_ADMINS or not target_player.admin))
) then
return true
end
return false
end
-- Add a player to the GUI list
-- @param player
-- @param target_player
-- @param color
-- @param tag
function Player_List.add_player_to_list(container, player, target_player)
local played_hrs = Time.tick_to_hour(target_player.online_time)
played_hrs = tostring(Math.round(played_hrs, 1))
local played_percentage = 1
if (game.tick > 0) then
played_percentage = target_player.online_time / game.tick
end
local color = {
r = target_player.color.r,
g = target_player.color.g,
b = target_player.color.b,
a = 1
}
-- Player list entry
local player_online_status = ''
local player_admin_status = ''
if (target_player.admin) then
player_admin_status = ' ' .. Player_List.ADMIN_SYMBOL
end
if (Player_List.getConfig(player).show_offline_players) then
player_online_status = Player_List.OFFLINE_SYMBOL
if (target_player.connected) then
player_online_status = Player_List.ONLINE_SYMBOL
end
player_online_status = player_online_status .. ' '
end
local caption_str =
string.format('%s%s hr - %s%s', player_online_status, played_hrs, target_player.name, player_admin_status)
local flow = container.add({type = 'flow', direction = 'horizontal'})
-- Add an inventory open button for those with privilages
if (Player_List.canDisplay(player, target_player)) then
local inventoryIconName = Player_List.SPRITE_NAMES.inventory
if(target_player and
target_player.get_main_inventory() and -- So this one is nil sometimes
target_player.get_main_inventory().is_empty()) then
inventoryIconName = Player_List.SPRITE_NAMES.inventory_empty
end
local btn_sprite = GUI.add_sprite_button(
flow,
{
type = 'sprite-button',
name = 'btn_open_inventory_'..target_player.name,
sprite = GUI.get_safe_sprite_name(player, inventoryIconName),
tooltip = {'player_list.player_tooltip_inventory', target_player.name}
},
-- On Click callback function
function(event)
Player_List.open_player_inventory(player, target_player)
end
)
GUI.element_apply_style(btn_sprite, Styles.small_button)
end
-- Add in the entry to the player list
local entry = flow.add(
{
type = 'label',
name = Player_List.getLblPlayerName(target_player),
caption = caption_str,
tooltip= {'player_list.player_tooltip'}
}
)
entry.style.font_color = color
entry.style.font = 'default-bold'
-- Griefer icons: mined/deconed flags
if (Player_List.canDisplay(player, target_player)) then
-- Add decon planner icon if player deconed something
if(Player_List.getConfig(target_player).decon) then
local sprite = flow.add({
type = 'sprite-button',
tooltip = {'player_list.player_tooltip_decon'},
sprite = GUI.get_safe_sprite_name(player, Sprites.deconstruction_planner)
})
GUI.element_apply_style(sprite, Styles.small_button)
end
-- Add axe icon if player mined something
if(Player_List.getConfig(target_player).mine) then
local sprite = flow.add({
type = 'sprite-button',
tooltip = {'player_list.player_tooltip_mine'},
sprite = GUI.get_safe_sprite_name(player, Sprites.steel_axe)
})
GUI.element_apply_style(sprite, Styles.small_button)
end
end
local entry_bar =
container.add(
{
type = 'progressbar',
name = 'bar_' .. target_player.name,
-- style = 'achievement_progressbar',
value = played_percentage,
tooltip = {'player_list.player_tooltip_playtime', Math.round(played_percentage * 100, 2)}
}
)
entry_bar.style.color = color
entry_bar.style.height = Player_List.PROGRESS_BAR_HEIGHT
end
-- Returns the playerlist config for specified player, creates default config if none exist
-- @tparam LuaPlayer player
function Player_List.getConfig(player)
if (not global.playerlist_config) then
global.playerlist_config = {}
end
if (not global.playerlist_config[player.name]) then
global.playerlist_config[player.name] = {
show_offline_players = false,
mine = false,
decon = false
}
end
return global.playerlist_config[player.name]
end
-- Sort players based on connection, admin role, and time played
-- Connected first, Admins first, highest playtime first
-- @tparam LuaPlayer a
-- @tparam LuaPlayer b
function Player_List.sort_players(a, b)
if ((a.connected and b.connected) or (not a.connected and not b.connected)) then
if ((a.admin and b.admin) or (not a.admin and not b.admin)) then
return a.online_time > b.online_time
else
return a.admin
end
else
return a.connected
end
end
|
local cm = require("codim")
cm.set_video_opts {
width = 1920,
height = 1080,
output = "out.mp4",
fps = 24,
}
cm.fill_frame("#000")
cm.draw_rect {
x = 10,
y = 10,
width = 1920 - 20,
height = 20,
color = "#0055ff",
}
local function read_file(file_path)
local f = io.open(file_path, "r")
local content = f:read("*all")
f:close()
return content
end
cm.draw_text {
font_file = cm.font_mono(),
font_size = 50,
text = read_file("test.c"),
x = 10,
y = 20,
color = "#00FF00",
animated = true,
animation_speed = 3,
}
cm.wait(50)
|
local EdgeListMap = {}
function EdgeListMap:new(o)
if not (o and o.edgeLists) then
error("Required Property edgeLists is missing")
end
setmetatable(o, self)
self.__index = self
self.edgeListMap = {}
for _, edgeList in ipairs(o.edgeLists) do
if edgeList.type and edgeList.params and edgeList.params.type then
if edgeList.params.catenary ~= nil then
self:registerEdgeList(edgeList, edgeList.type, edgeList.params.type, edgeList.params.catenary)
elseif edgeList.params.tramTrackType then
self:registerEdgeList(edgeList, edgeList.type, edgeList.params.type, edgeList.params.tramTrackType)
end
end
end
return o
end
function EdgeListMap:registerEdgeList(edgeList, edgeListType, typeParam, catenaryOrTram)
if not self.edgeListMap[edgeListType] then
self.edgeListMap[edgeListType] = {}
end
if not self.edgeListMap[edgeListType][typeParam] then
self.edgeListMap[edgeListType][typeParam] = {}
end
self.edgeListMap[edgeListType][typeParam][catenaryOrTram] = edgeList
end
function EdgeListMap:getTypeAndParamKey(paramValue)
if paramValue == true or paramValue == false then
return 'TRACK', 'catenary'
end
if paramValue == 'YES' or paramValue == 'NO' or paramValue == 'ELECTRIC' then
return 'STREET', 'tramTrackType'
end
error('No supported catenaryOrTram param given. The param MUST be true/false for Track types or YES/NO/ELECTRIC for Street types')
end
function EdgeListMap:getEdgeList(edgeListType, typeParam, catenaryOrTram)
if not self.edgeListMap[edgeListType] then
return nil
end
if not self.edgeListMap[edgeListType][typeParam] then
return nil
end
return self.edgeListMap[edgeListType][typeParam][catenaryOrTram]
end
function EdgeListMap:createEdgeList(edgeListType, typeParam, catenaryOrTram, paramKey)
local newEdgeList = {
type = edgeListType,
params = {
["type"] = typeParam,
[paramKey] = catenaryOrTram
},
edges = {},
snapNodes = {},
tag2nodes = {},
freeNodes = {}
}
table.insert(self.edgeLists, newEdgeList)
self:registerEdgeList(newEdgeList, edgeListType, typeParam, catenaryOrTram)
return newEdgeList
end
function EdgeListMap:getOrCreateEdgeList(typeParam, catenaryOrTram)
local edgeListType, paramKey = self:getTypeAndParamKey(catenaryOrTram)
return self:getEdgeList(edgeListType, typeParam, catenaryOrTram) or self:createEdgeList(edgeListType, typeParam, catenaryOrTram, paramKey)
end
function EdgeListMap:getEdgeLists()
return self.edgeLists
end
function EdgeListMap:getIndexOfFirstNodeInEdgeList(typeParam, catenaryOrTram)
local edgeListType, paramKey = self:getTypeAndParamKey(catenaryOrTram)
local nodesBeforFirstNode = 0
for i, edgeList in ipairs(self.edgeLists) do
if edgeList.type == edgeListType and edgeList.params.type == typeParam and edgeList.params[paramKey] == catenaryOrTram then
return nodesBeforFirstNode
end
nodesBeforFirstNode = nodesBeforFirstNode + #edgeList.edges
end
return 0
end
return EdgeListMap
|
-- Copyright (c) 2017-present, Facebook, Inc.
-- All rights reserved.
-- This source code is licensed under the BSD-style license found in the
-- LICENSE file in the root directory of this source tree. An additional grant
-- of patent rights can be found in the PATENTS file in the same directory.
local tnt = require 'torchnet.env'
local argcheck = require 'argcheck'
local lfs = require 'lfs'
local NumberedFilesDataset =
torch.class('tnt.NumberedFilesDataset', 'tnt.Dataset', tnt)
NumberedFilesDataset.__init = argcheck{
{name='self', type='tnt.NumberedFilesDataset'},
{name='path', type='string'},
{name='features', type='table'},
{name='maxload', type='number', opt=true},
call =
function(self, path, features, maxload)
maxload = (maxload and maxload > 0) and maxload or math.huge
self.__path = path
self.__features = {}
self.__aliases = {}
self.__readers = {}
assert(#features > 0, 'features should be a list of {name=<string>, reader=<function>, [alias=<string]}')
for _, feature in ipairs(features) do
assert(type(feature) == 'table'
and type(feature.name) == 'string'
and type(feature.reader) == 'function',
'features should be a list of {name=<string>, reader=<function>, [alias=<string]}')
table.insert(self.__features, feature.name)
table.insert(self.__readers, feature.reader)
table.insert(self.__aliases, feature.alias or feature.name)
end
io.stderr:write(string.format("| dataset <%s>: ", path))
io.stderr:flush()
local pattern = "^(%d%d%d%d%d%d%d%d%d)%." .. features[1].name .. "$"
local startidx
for filename in lfs.dir(path) do
if lfs.attributes(paths.concat(path, filename), "mode") == "file" then
local idx = filename:match(pattern)
if idx then
idx = tonumber(idx)
startidx = startidx or idx
startidx = math.min(startidx, idx)
end
end
end
if not startidx then
startidx = 0
self.__subdir = true
end
self.__startidx = startidx
for i=1,maxload do
local f = io.open(
self:filename(i, features[1].name)
)
if f then
f:close()
else
self.__size = i-1
break
end
end
self.__size = self.__size or maxload
io.stderr:write(string.format("%d files found\n", self.__size))
io.stderr:flush()
assert(self.__size > 0, string.format("no file found in <%s/?????????.%s> nor in <%s/00000/?????????.%s>", path, features[1].name, path, features[1].name))
end
}
NumberedFilesDataset.filename = argcheck{
{name='self', type='tnt.NumberedFilesDataset'},
{name='idx', type='number'},
{name='feature', type='string'},
call =
function(self, idx, feature)
local path = self.__path
if self.__subdir then
path = paths.concat(
path,
string.format('%05d', math.floor((idx-1) / 10000))
)
end
return paths.concat(
path,
string.format("%09d.%s", idx-1+self.__startidx, feature)
)
end
}
NumberedFilesDataset.size = argcheck{
{name='self', type='tnt.NumberedFilesDataset'},
call =
function(self)
return self.__size
end
}
NumberedFilesDataset.get = argcheck{
{name='self', type='tnt.NumberedFilesDataset'},
{name='idx', type='number'},
call =
function(self, idx)
local sample = {}
for i, feature in ipairs(self.__features) do
local alias = self.__aliases[i]
local reader = self.__readers[i]
sample[alias] = reader(
self:filename(idx, feature)
)
end
return sample
end
}
|
---@class CS.FairyEditor.ComponentAsset.DisplayListItem
---@field public packageItem CS.FairyEditor.FPackageItem
---@field public pkg CS.FairyEditor.FPackage
---@field public type string
---@field public desc CS.FairyGUI.Utils.XML
---@field public missingInfo CS.FairyEditor.MissingInfo
---@field public existingInstance CS.FairyEditor.FObject
---@type CS.FairyEditor.ComponentAsset.DisplayListItem
CS.FairyEditor.ComponentAsset.DisplayListItem = { }
---@return CS.FairyEditor.ComponentAsset.DisplayListItem
function CS.FairyEditor.ComponentAsset.DisplayListItem.New() end
return CS.FairyEditor.ComponentAsset.DisplayListItem
|
CampDialogLayer = class("CampDialogLayer", function ( )
return cc.Layer:create()
end)
CampDialogLayer.instance = nil
local function buySoldierTemple(self, prefix)
local goldCount = GM:getGoldCount()
local ui = self:getChildByName("UI")
local campLevel = GM:getLevel("Camp")
local cost = GM:getSoldierCost(prefix)
local soldierNum = GM:getSoldierNum(prefix)
local soldierLimit = GM:getSoldierLimit(prefix)
if soldierNum >= soldierLimit then
GM:showNotice("请升级兵营。", self)
return
end
if goldCount < cost then
GM:showNotice("金币不足。", self)
return
end
GM:setGoldChange(-cost)
GM:setSoldierNum(prefix)
local soldierCount = ccui.Helper:seekWidgetByName(ui, prefix .. "Count")
soldierCount:setString((soldierNum + 1) .. "/" .. soldierLimit)
local wgGoldCount = ccui.Helper:seekWidgetByName(ui, "GoldCount")
wgGoldCount:setString(GM:getGoldCount())
end
function CampDialogLayer.buyCallback(self, sender)
local labLevel = researchLabSprite.level
local name = sender:getName()
if name == "BuyFighterButton" then
buySoldierTemple(self, "Fighter")
elseif name == "BuyBowmanButton" then
if labLevel < 2 then
GM:showNotice("请升级研究所。", self)
return
end
buySoldierTemple(self, "Bowman")
elseif name == "BuyGunnerButton" then
if labLevel < 3 then
GM:showNotice("请升级研究所。", self)
return
end
buySoldierTemple(self, "Gunner")
elseif name == "BuyMeatShieldButton" then
if labLevel < 4 then
GM:showNotice("请升级研究所。", self)
return
end
buySoldierTemple(self, "MeatShield")
end
end
function CampDialogLayer.infoCallback(sender)
-- 设置当前Layer以便关闭SoldierInfoDialogLayer时,把scene._dialogLayer设置回来
local campDialogLayer = scene._dialogLayer
campDialogLayer:setName("CampDialogLayer")
local name = sender:getName()
if name == "FighterInfoButton" then
GM:showDialogLayer(SoldierInfoDialogLayer, 1)
elseif name == "BowmanInfoButton" then
GM:showDialogLayer(SoldierInfoDialogLayer, 2)
elseif name == "GunnerInfoButton" then
GM:showDialogLayer(SoldierInfoDialogLayer, 3)
elseif name == "MeatShieldInfoButton" then
GM:showDialogLayer(SoldierInfoDialogLayer, 4)
end
end
function CampDialogLayer:addListener( )
local ui = self:getChildByName("UI")
-- 关闭按钮
local btnClose = ccui.Helper:seekWidgetByName(ui, "CloseButton")
btnClose:addClickEventListener(GM.closeDialogLayer)
-- 信息按钮
local btnFighterInfo = ccui.Helper:seekWidgetByName(ui, "FighterInfoButton")
local btnBowmanInfo = ccui.Helper:seekWidgetByName(ui, "BowmanInfoButton")
local btnGunnerInfo = ccui.Helper:seekWidgetByName(ui, "GunnerInfoButton")
local btnMeatInfo = ccui.Helper:seekWidgetByName(ui, "MeatShieldInfoButton")
btnFighterInfo:addClickEventListener(CampDialogLayer.infoCallback)
btnBowmanInfo:addClickEventListener(CampDialogLayer.infoCallback)
btnGunnerInfo:addClickEventListener(CampDialogLayer.infoCallback)
btnMeatInfo:addClickEventListener(CampDialogLayer.infoCallback)
-- 训练按钮
local btnFighterBuy = ccui.Helper:seekWidgetByName(ui, "BuyFighterButton")
local btnBowmanBuy = ccui.Helper:seekWidgetByName(ui, "BuyBowmanButton")
local btnGunnerBuy = ccui.Helper:seekWidgetByName(ui, "BuyGunnerButton")
local btnMeatBuy = ccui.Helper:seekWidgetByName(ui, "BuyMeatShieldButton")
btnFighterBuy:addClickEventListener(function (...)
CampDialogLayer.buyCallback(self, ...)
end)
btnBowmanBuy:addClickEventListener(function (...)
CampDialogLayer.buyCallback(self, ...)
end)
btnGunnerBuy:addClickEventListener(function (...)
CampDialogLayer.buyCallback(self, ...)
end)
btnMeatBuy:addClickEventListener(function (...)
CampDialogLayer.buyCallback(self, ...)
end)
end
local function showSoldierPanelTemple(ui, self, prefix, minLabLevel)
local labLevel = researchLabSprite.level
local wgCost = ccui.Helper:seekWidgetByName(ui, prefix .. "GoldRequire")
local soldierLevel = GM:getLevel(prefix)
local cost = DM[prefix .. "Info"].cost[soldierLevel]
local wgLevel = ccui.Helper:seekWidgetByName(ui, prefix .. "Level")
wgCost:setString(cost)
wgLevel:setString(soldierLevel)
if labLevel < minLabLevel then
local soldier = ccui.Helper:seekWidgetByName(ui, "Soldier_" .. prefix)
local btnInfo = ccui.Helper:seekWidgetByName(ui, prefix .. "InfoButton")
local btnBuy = ccui.Helper:seekWidgetByName(ui, "Buy" .. prefix .. "Button")
local children = soldier:getChildren()
for i = 1, #children do
children[i]:setColor(cc.c3b(160, 160, 160))
end
btnBuy:setColor(cc.c3b(160, 160, 160))
btnInfo:setColor(cc.c3b(160, 160, 160))
else
local wgCount = ccui.Helper:seekWidgetByName(ui, prefix .. "Count")
local campLevel = self.instance:getLevel()
wgCount:setString(GM:getSoldierNum(prefix) .. "/" .. GM:getSoldierLimit(prefix))
end
end
function CampDialogLayer:showDialog( )
-- Action
local scale = cc.ScaleTo:create(0.3, 1)
local act = cc.EaseBackOut:create(scale)
self:runAction(act)
local ui = ccs.GUIReader:getInstance():widgetFromJsonFile(UI_DIALOG_CAMP)
local bg = cc.Sprite:create(IMG_GRAY_BG)
bg:setScale(size.width / 1000, size.height / 1000)
bg:setOpacity(128)
bg:setPosition(size.width / 2, size.height / 2)
self:addChild(bg, ORD_BG)
self:addChild(ui, ORD_BOTTOM, "UI")
-- 资源数量
local goldCount = ccui.Helper:seekWidgetByName(ui, "GoldCount")
local woodCount = ccui.Helper:seekWidgetByName(ui, "WoodCount")
goldCount:setString(GM:getGoldCount())
woodCount:setString(DM.Resource.woodCount)
-- 士兵数量
showSoldierPanelTemple(ui, self, "Fighter", 1)
showSoldierPanelTemple(ui, self, "Bowman", 2)
showSoldierPanelTemple(ui, self, "Gunner", 3)
showSoldierPanelTemple(ui, self, "MeatShield", 4)
end
function CampDialogLayer:onEnter()
self:setScale(0)
self:showDialog()
self:addListener()
end
function CampDialogLayer:create(instance)
local campDialogLayer = CampDialogLayer.new()
self.instance = instance
campDialogLayer:onEnter()
return campDialogLayer
end
|
----------------------------------------------------------------------
-- CGAL multi delaunay ipelet description
----------------------------------------------------------------------
label = "k order Delaunay"
about = [[
This ipelet is part of the CGAL_ipelet package. See www.cgal.org.
]]
-- this variable will store the C++ ipelet when it has been loaded
ipelet = false
function run(model, num)
if not ipelet then ipelet = assert(ipe.Ipelet(dllname)) end
model:runIpelet(methods[num].label, ipelet, num)
end
methods = {
{ label= "Delaunay" },
{ label= "Delaunay 2" },
{ label= "Delaunay 3" },
{ label= "Delaunay n-1" },
{ label= "Delaunay k" },
{ label= "Voronoi" },
{ label= "Voronoi 2" },
{ label= "Voronoi 3" },
{ label= "Voronoi n-1" },
{ label= "Voronoi k" },
{ label="Help" },
}
----------------------------------------------------------------------
|
---
-- @module ParcelGrid
--
-- ------------------------------------------------
-- Required Modules
-- ------------------------------------------------
local Class = require( 'lib.Middleclass' )
local Parcel = require( 'src.map.procedural.Parcel' )
-- ------------------------------------------------
-- Module
-- ------------------------------------------------
local ParcelGrid = Class( 'ParcelGrid' )
-- ------------------------------------------------
-- Constants
-- ------------------------------------------------
local DIRECTION = require( 'src.constants.DIRECTION' )
-- ------------------------------------------------
-- Private Methods
-- ------------------------------------------------
---
-- Creates an empty parcel grid.
-- @tparam number w The parcel grid's width.
-- @tparam number h The parcel grid's height.
-- @tparam table The new parcel grid.
--
local function createGrid( w, h )
local parcels = {}
for x = 0, w-1 do
for y = 0, h-1 do
parcels[x] = parcels[x] or {}
parcels[x][y] = Parcel( 'empty' )
end
end
return parcels
end
-- ------------------------------------------------
-- Public Methods
-- ------------------------------------------------
---
-- Initializes the ParcelGrid.
-- @tparam number w The parcel grid's width.
-- @tparam number h The parcel grid's height.
--
function ParcelGrid:initialize( w, h )
self.parcels = createGrid( w, h )
end
---
-- Adds a prefab to the ParcelGrid.
-- @tparam number x The prefab's position on the grid along the x-axis.
-- @tparam number y The prefab's position on the grid along the y-axis.
-- @tparam number w The prefab's width.
-- @tparam number h The prefab's height.
-- @tparam string type The prefab's type.
--
function ParcelGrid:addPrefab( x, y, w, h, type )
for px = 0, w-1 do
for py = 0, h-1 do
self.parcels[px+x][py+y]:setType( type )
end
end
end
---
-- Gives each parcel in the grid a reference to its neighbours.
--
function ParcelGrid:createNeighbours()
for x = 0, #self.parcels do
for y = 0, #self.parcels[x] do
local neighbours = {}
neighbours[DIRECTION.NORTH] = self:getParcelAt( x , y - 1 ) or false
neighbours[DIRECTION.SOUTH] = self:getParcelAt( x , y + 1 ) or false
neighbours[DIRECTION.NORTH_EAST] = self:getParcelAt( x + 1, y - 1 ) or false
neighbours[DIRECTION.NORTH_WEST] = self:getParcelAt( x - 1, y - 1 ) or false
neighbours[DIRECTION.SOUTH_EAST] = self:getParcelAt( x + 1, y + 1 ) or false
neighbours[DIRECTION.SOUTH_WEST] = self:getParcelAt( x - 1, y + 1 ) or false
neighbours[DIRECTION.EAST] = self:getParcelAt( x + 1, y ) or false
neighbours[DIRECTION.WEST] = self:getParcelAt( x - 1, y ) or false
self.parcels[x][y]:setNeighbours( neighbours )
end
end
end
---
-- Returns the Parcel at the given coordinates.
-- @tparam number x The position along the x-axis.
-- @tparam number y The position along the y-axis.
-- @treturn Parcel The Parcel at the given position.
--
function ParcelGrid:getParcelAt( x, y )
return self.parcels[x] and self.parcels[x][y]
end
---
-- Iterates over all tiles and performs the callback function on them.
-- @param callback (function) The operation to perform on each tile.
--
function ParcelGrid:iterate( callback )
for x = 0, #self.parcels do
for y = 0, #self.parcels[x] do
callback( self.parcels[x][y], x, y )
end
end
end
return ParcelGrid
|
local _, class = UnitClass("player")
local returndata = {}
local summeddata = {}
local function findpattern(text, pattern, start)
if (text and pattern and (string.find(text, pattern, start))) then
return string.sub(text, string.find(text, pattern, start))
else
return ""
end
end
local function round(arg1, decplaces)
if (decplaces == nil) then decplaces = 0 end
if arg1 == nil then arg1 = 0 end
return string.format ("%."..decplaces.."f", arg1)
end
local function TheoryCraft_AddData(arg1, data, summeddata)
if data == nil then return end
summeddata["tmpincrease"] = summeddata["tmpincrease"] + (data[arg1.."modifier"] or 0)
summeddata["tmpincreaseupfront"] = summeddata["tmpincreaseupfront"] + (data[arg1.."UpFrontmodifier"] or 0)
if summeddata["baseincrease"] ~= 0 then
summeddata["baseincrease"] = summeddata["baseincrease"] * ((data[arg1.."baseincrease"] or 0)+1)
else
summeddata["baseincrease"] = summeddata["baseincrease"] + (data[arg1.."baseincrease"] or 0)
end
if summeddata["baseincreaseupfront"] ~= 0 then
summeddata["baseincreaseupfront"] = summeddata["baseincreaseupfront"] * ((data[arg1.."UpFrontbaseincrease"] or 0)+1)
else
summeddata["baseincreaseupfront"] = summeddata["baseincreaseupfront"] + (data[arg1.."UpFrontbaseincrease"] or 0)
end
summeddata["talentmod"] = summeddata["talentmod"] + (data[arg1.."talentmod"] or 0)
summeddata["talentmodupfront"] = summeddata["talentmodupfront"] + (data[arg1.."UpFronttalentmod"] or 0)
if (summeddata["doshatter"] ~= 0) then
summeddata["critchance"] = summeddata["critchance"] + (data[arg1.."shatter"] or 0)
end
summeddata["illum"] = summeddata["illum"] + (data[arg1.."illum"] or 0)
summeddata["plusdam"] = summeddata["plusdam"] + (data[arg1] or 0)
summeddata["manacostmod"] = summeddata["manacostmod"] + (data[arg1.."manacost"] or 0)
summeddata["critchance"] = summeddata["critchance"] + (data[arg1.."critchance"] or 0)
summeddata["critbonus"] = summeddata["critbonus"] + (data[arg1.."critbonus"] or 0)
summeddata["ignitemodifier"] = summeddata["ignitemodifier"] + (data[arg1.."ignitemodifier"] or 0)
summeddata["sepignite"] = summeddata["sepignite"] + (data[arg1.."sepignite"] or 0)
summeddata["hitbonus"] = summeddata["hitbonus"] - (data[arg1.."hitchance"] or 0)
summeddata["casttime"] = summeddata["casttime"] + (data[arg1.."casttime"] or 0)
summeddata["regencasttime"] = summeddata["regencasttime"] + (data[arg1.."casttime"] or 0)
summeddata["penetration"] = summeddata["penetration"] + (data[arg1.."penetration"] or 0)
summeddata["grace"] = summeddata["grace"] + (data[arg1.."grace"] or 0)
summeddata["threat"] = summeddata["threat"] + (data[arg1.."threat"] or 0)
if data[arg1.."Netherwind"] == 1 then
summeddata["netherwind"] = 1
end
end
local function TheoryCraft_DoSchool(arg1, summeddata)
if TheoryCraft_Data.Testing then
TheoryCraft_AddData(arg1, TheoryCraft_Data.TalentsTest, summeddata)
else
TheoryCraft_AddData(arg1, TheoryCraft_Data.Talents, summeddata)
end
TheoryCraft_AddData(arg1, TheoryCraft_Data.BaseData, summeddata)
TheoryCraft_AddData(arg1, TheoryCraft_Data.Stats, summeddata)
TheoryCraft_AddData(arg1, TheoryCraft_Data.PlayerBuffs, summeddata)
TheoryCraft_AddData(arg1, TheoryCraft_Data.TargetBuffs, summeddata)
TheoryCraft_AddData(arg1, TheoryCraft_Data.EquipEffects, summeddata)
TheoryCraft_AddData(arg1, TheoryCraft_Data.Target, summeddata)
end
local function SummateData(name, schools)
TheoryCraft_DeleteTable(summeddata)
summeddata["doshatter"] = (TheoryCraft_Data.TargetBuffs["doshatter"] or 0)
summeddata["tmpincrease"] = 0
summeddata["tmpincreaseupfront"] = 0
summeddata["baseincrease"] = 0
summeddata["baseincreaseupfront"] = 0
summeddata["talentmod"] = 0
summeddata["talentmodupfront"] = 0
summeddata["critchance"] = (TheoryCraft_Data.Stats["critchance"] or 0)
summeddata["illum"] = 0
summeddata["plusdam"] = 0
summeddata["manacostmod"] = 1
summeddata["critbonus"] = 0
summeddata["ignitemodifier"] = 0
summeddata["sepignite"] = 0
summeddata["hitbonus"] = 0
summeddata["casttime"] = 0
summeddata["regencasttime"] = 0
summeddata["penetration"] = 0
summeddata["grace"] = 0
summeddata["netherwind"] = 0
summeddata["threat"] = 0
for k, v in pairs (schools) do
TheoryCraft_DoSchool(v, summeddata)
end
TheoryCraft_DoSchool(name, summeddata)
end
local function getcooldown(frame)
index = 1
local rtext = getglobal(frame:GetName().."TextRight"..index):GetText()
local cooldown = 1.5
while (rtext) do
if (getglobal(frame:GetName().."TextRight"..index):IsVisible()) then
if (strfind(rtext, "%d+.%d+"..TheoryCraft_Locale.Cooldown)) then
cooldown = findpattern(rtext, "%d+.%d+");
elseif (strfind(rtext, "%d+"..TheoryCraft_Locale.Cooldown)) then
cooldown = findpattern(rtext, "%d+");
end
end
index = index + 1;
rtext = getglobal(frame:GetName().."TextRight"..index):GetText()
end
return cooldown
end
local function getlifetap(returndata)
local i2 = 1
local spellname = 1
local spellrank = 1
local quit = 0
local found = 0
while (spellname) do
spellname, spellrank = GetSpellBookItemName(i2,BOOKTYPE_SPELL)
spellrank = tonumber(findpattern(spellrank, "%d+"))
if (spellname == TheoryCraft_Locale.lifetap) then
found = 1
elseif (found == 1) then
TCTooltip:SetOwner(UIParent,"ANCHOR_NONE")
TCTooltip:SetSpellByID(i2-1)
if (TCTooltip:NumLines() > 0) then
local description = getglobal("TCTooltipTextLeft"..TCTooltip:NumLines()):GetText()
returndata["lifetapHealth"] = findpattern(description, "%d+ health")
returndata["lifetapMana"] = findpattern(description, "%d+ mana")
if returndata["lifetapHealth"] then
returndata["lifetapHealth"] = tonumber(findpattern(returndata["lifetapHealth"], "%d+"))
end
if returndata["lifetapMana"] then
returndata["lifetapMana"] = tonumber(findpattern(returndata["lifetapMana"], "%d+"))
end
end
return
end
i2 = i2 + 1
end
end
function TheoryCraft_GetStat(statname)
if TheoryCraft_Data.testing then
return (TheoryCraft_Data.BaseData[statname] or 0)+
(TheoryCraft_Data.TalentsTest[statname] or 0)+
(TheoryCraft_Data.Stats[statname] or 0)+
(TheoryCraft_Data.PlayerBuffs[statname] or 0)+
(TheoryCraft_Data.TargetBuffs[statname] or 0)+
(TheoryCraft_Data.EquipEffects[statname] or 0)+
(TheoryCraft_Data.Target[statname] or 0)
else
return (TheoryCraft_Data.BaseData[statname] or 0)+
(TheoryCraft_Data.Talents[statname] or 0)+
(TheoryCraft_Data.Stats[statname] or 0)+
(TheoryCraft_Data.PlayerBuffs[statname] or 0)+
(TheoryCraft_Data.TargetBuffs[statname] or 0)+
(TheoryCraft_Data.EquipEffects[statname] or 0)+
(TheoryCraft_Data.Target[statname] or 0)
end
end
local function agipercrit()
if TheoryCraft_agipercrit then
return TheoryCraft_agipercrit
else
return TheoryCraft_CritChance[class][1]
end
end
function TheoryCraft_intpercrit()
local critdivider
local agipercrit = agipercrit()
if agipercrit == TheoryCraft_CritChance[class][1] then
critdivider = UnitLevel("player")/60*TheoryCraft_CritChance[class][2]
if (critdivider < 5) then
critdivider = 5
end
else
critdivider = agipercrit/TheoryCraft_CritChance[class][1]*TheoryCraft_CritChance[class][2]
end
return critdivider
end
--- Returns the cast time from the spell tooltip ---
local function getcasttime(frame)
index = 1;
local ltext = getglobal(frame:GetName().."TextLeft"..index):GetText()
local castTime = 0
while (ltext) do
ltext = string.gsub(ltext, ",", ".")
if (strfind(ltext, "%d+.%d+"..TheoryCraft_Locale.SecCast)) then
castTime = findpattern(findpattern(ltext, "%d+.%d+"..TheoryCraft_Locale.SecCast), "%d+.%d+")
elseif (strfind(ltext, "%d+"..TheoryCraft_Locale.SecCast)) then
castTime = findpattern(findpattern(ltext, "%d+"..TheoryCraft_Locale.SecCast), "%d+")
end
index = index + 1
ltext = getglobal(frame:GetName().."TextLeft"..index):GetText()
end
castTime = tonumber(castTime)
return castTime
end
--- Returns the dot duration from the spell tooltip ---
local function TheoryCraft_getDotDuration(description)
local i = 1
local _, found
while TheoryCraft_DotDurations[i] do
if (strfind(description, TheoryCraft_DotDurations[i].text)) then
if TheoryCraft_DotDurations[i].amount == "n" then
_, _, found = strfind(description, TheoryCraft_DotDurations[i].text)
return found
else
return TheoryCraft_DotDurations[i].amount
end
end
i = i + 1
end
return 1
end
local function getmanacost(frame)
index = 1
local ltext = getglobal(frame:GetName().."TextLeft"..index):GetText()
local manaCost = 0
while (ltext) do
if (strfind(ltext, TheoryCraft_Locale.Mana)) then
manaCost = findpattern(ltext, "%d+")
end
index = index + 1;
ltext = getglobal(frame:GetName().."TextLeft"..index):GetText()
end
manaCost = tonumber(manaCost)
if manaCost then
return manaCost
else
return 0
end
end
local function TheoryCraft_GetRangedSpeed()
TheoryCraftTooltip:SetOwner(UIParent,"ANCHOR_NONE")
TheoryCraftTooltip:SetInventoryItem ("player", GetInventorySlotInfo("RangedSlot"))
local index = 1
ltext = getglobal(TheoryCraftTooltip:GetName().."TextLeft"..index)
rtext = getglobal(TheoryCraftTooltip:GetName().."TextRight"..index)
if ltext then
ltext = ltext:GetText()
end
if rtext then
if not (getglobal(TheoryCraftTooltip:GetName().."TextRight"..index):IsVisible()) then
rtext = nil
else
rtext = rtext:GetText()
end
end
while (ltext ~= nil) do
if (rtext) then
for k, v in pairs(TheoryCraft_EquipEveryRight) do
if (v.slot == nil) or (v.slot == "Ranged") then
_, start, found = strfind(rtext, v.text)
if found then
if v.amount then
TheoryCraftTooltip:ClearLines()
return v.amount
else
TheoryCraftTooltip:ClearLines()
return found
end
end
end
end
end
index = index + 1;
ltext = getglobal(TheoryCraftTooltip:GetName().."TextLeft"..index)
rtext = getglobal(TheoryCraftTooltip:GetName().."TextRight"..index)
if ltext then
ltext = ltext:GetText()
end
if rtext then
if not (getglobal(TheoryCraftTooltip:GetName().."TextRight"..index):IsVisible()) then
rtext = nil
else
rtext = rtext:GetText()
end
end
end
TheoryCraftTooltip:ClearLines()
return 2.8
end
local function GetCritChance(critreport)
local critChance, iCritInfo, critNum
local remove = 0
local id = 1
local attackSpell = GetSpellBookItemName(id,BOOKTYPE_SPELL)
if (attackSpell ~= TheoryCraft_Locale.Attack) then
name, texture, offset, numSpells = GetSpellTabInfo(1)
for i=1, numSpells do
if (GetSpellBookItemName(i,BOOKTYPE_SPELL) == TheoryCraft_Locale.Attack) then
id = i
end
end
end
if GetSpellBookItemName(id,BOOKTYPE_SPELL) ~= TheoryCraft_Locale.Attack then
return 0
end
TheoryCraftTooltip:SetOwner(UIParent,"ANCHOR_NONE")
TheoryCraftTooltip:SetSpellByID(id)
local spellName = TheoryCraftTooltipTextLeft2:GetText()
if not spellName then return 0 end
iCritInfo = string.find(spellName, "%s")
critNum = string.sub(spellName,0,(iCritInfo -2))
critChance = string.gsub(critNum, ",", ".")
critChance = tonumber(critChance)
if critreport == nil then critreport = 0 end
if (critChance) and (critChance ~= critreport) then
local doweaponskill = true
if class == "DRUID" then
local _, _, active = GetShapeshiftFormInfo(1)
if active then doweaponskill = nil end
local _, _, active = GetShapeshiftFormInfo(3)
if active then doweaponskill = nil end
end
if doweaponskill then
TheoryCraftTooltip:SetOwner(UIParent,"ANCHOR_NONE")
TheoryCraftTooltip:SetInventoryItem ("player", GetInventorySlotInfo("MainHandSlot"))
local i, i2 = 1
local ltext = getglobal(TheoryCraftTooltip:GetName().."TextLeft"..i):GetText()
local rtext = getglobal(TheoryCraftTooltip:GetName().."TextRight"..i):GetText()
local skill = TheoryCraft_WeaponSkillOther
local english = "Unarmed"
while ltext do
ltext = getglobal(TheoryCraftTooltip:GetName().."TextLeft"..i):GetText()
rtext = getglobal(TheoryCraftTooltip:GetName().."TextRight"..i):GetText()
if (rtext) and (getglobal(TheoryCraftTooltip:GetName().."TextRight"..i):IsVisible()) then
i2 = 1
while TheoryCraft_WeaponSkills[i2] do
if (((TheoryCraft_WeaponSkills[i2].ltext) and (TheoryCraft_WeaponSkills[i2].ltext == ltext)) or (TheoryCraft_WeaponSkills[i2].ltext == nil)) and (TheoryCraft_WeaponSkills[i2].text == rtext) then
skill = TheoryCraft_WeaponSkills[i2].skill
english = TheoryCraft_WeaponSkills[i2].english
break
end
i2 = i2 + 1
end
end
if skill ~= TheoryCraft_WeaponSkillOther then
break
end
i = i + 1
end
local i = 1
local skillTitle, header, isExpanded, skillRank
while GetSkillLineInfo(i) do
skillTitle, header, isExpanded, skillRank = GetSkillLineInfo(i)
if (skillTitle == skill) then
critChance = critChance + (UnitLevel("player")*5 - skillRank)*0.04
break
end
i = i + 1
end
-- remove weapon specs
critChance = critChance - TheoryCraft_GetStat(english.."specreal")
end
critChance = critChance - (TheoryCraft_GetStat("CritChangeTalents") or 0)
if doweaponskill == nil then
critChance = critChance - (TheoryCraft_Data.Talents["Formcritchancereal"] or 0)
remove = -1*(TheoryCraft_Data.Talents["Formcritchancereal"] or 0)
end
local critchance2 = critChance-TheoryCraft_GetStat("CritReport")
if doweaponskill == nil then
critChance = critChance + (TheoryCraft_Data.Talents["Formcritchance"] or 0)
end
if class == "WARRIOR" then
local _, _, active = GetShapeshiftFormInfo(3)
if active then
critchance2 = critchance2 - 3
remove = -3
end
end
if UnitLevel("player") == 60 then
if (class == "DRUID") then
if doweaponskill == nil then
remove = -1*(TheoryCraft_Data.Talents["Formcritchance"] or 0)
end
end
TheoryCraft_agipercrit = TheoryCraft_CritChance[class][1]
else
if (TheoryCraft_Data["outfit"] == nil) or (TheoryCraft_Data["outfit"] == 1) then
local _, agi = UnitStat("player", 2)
TheoryCraft_agipercrit = agi/(critchance2-TheoryCraft_CritChance[class][3])
end
end
return (critChance or 0), remove
else
return 0, remove
end
end
function TheoryCraft_LoadStats(talents)
if talents == nil then talents = TheoryCraft_Data.Talents end
TheoryCraft_DeleteTable(TheoryCraft_Data.Stats)
local remove
TheoryCraft_Data.Stats["meleecritchance"], remove = GetCritChance()
TheoryCraft_Data.Stats["Rangedhastebonus"] = UnitRangedDamage("player")/TheoryCraft_GetRangedSpeed()
local outfit = (TheoryCraft_Data["outfit"] or 1)
if outfit == -1 then
outfit = 1
end
local _, tmp = UnitStat("player", 1)
TheoryCraft_Data.Stats["strength"] = tmp
_, tmp = UnitStat("player", 2)
TheoryCraft_Data.Stats["agility"] = tmp
_, tmp = UnitStat("player", 3)
TheoryCraft_Data.Stats["stamina"] = tmp
_, tmp = UnitStat("player", 4)
TheoryCraft_Data.Stats["intellect"] = tmp
_, tmp = UnitStat("player", 5)
TheoryCraft_Data.Stats["spirit"] = tmp
TheoryCraft_Data.Stats["agipercrit"] = agipercrit()
local _, catform, bearform
if class == "DRUID" then
_, _, bearform = GetShapeshiftFormInfo(1)
_, _, catform = GetShapeshiftFormInfo(3)
TheoryCraft_Data.Stats["agilityapranged"] = 2
TheoryCraft_Data.Stats["strengthapmelee"] = 2
if catform then
TheoryCraft_Data.Stats["agilityapmelee"] = 1
else
TheoryCraft_Data.Stats["agilityapmelee"] = 0
end
elseif (class == "WARRIOR") or (class == "PALADIN") or (class == "SHAMAN") then
TheoryCraft_Data.Stats["agilityapranged"] = 2
TheoryCraft_Data.Stats["strengthapmelee"] = 2
TheoryCraft_Data.Stats["agilityapmelee"] = 0
elseif (class == "ROGUE") or (class == "HUNTER") then
TheoryCraft_Data.Stats["agilityapranged"] = 2
TheoryCraft_Data.Stats["strengthapmelee"] = 1
TheoryCraft_Data.Stats["agilityapmelee"] = 1
else
TheoryCraft_Data.Stats["agilityapranged"] = 0
TheoryCraft_Data.Stats["strengthapmelee"] = 1
TheoryCraft_Data.Stats["agilityapmelee"] = 0
end
local base, pos, neg = UnitAttackPower("player")
TheoryCraft_Data.Stats["attackpower"] = base+pos+neg-TheoryCraft_Data.Stats["strengthapmelee"]*TheoryCraft_Data.Stats["strength"]-TheoryCraft_Data.Stats["agilityapmelee"]*TheoryCraft_Data.Stats["agility"]+(talents["AttackPowerTalents"] or 0)
base, pos, neg = UnitRangedAttackPower("player")
TheoryCraft_Data.Stats["rangedattackpower"] = (TheoryCraft_Data.TargetBuffs["huntersmark"] or 0)+base+pos+neg-TheoryCraft_Data.Stats["agilityapranged"]*TheoryCraft_Data.Stats["agility"]
TheoryCraft_Data.Stats["totalmana"] = UnitPowerMax("player", Enum.PowerType.Mana)/talents["manamultiplierreal"]
TheoryCraft_Data.Stats["totalhealth"] = UnitHealthMax("player")/talents["healthmultiplierreal"]
TheoryCraft_Data.Stats["meleecritchance"] = TheoryCraft_Data.Stats["meleecritchance"]-TheoryCraft_Data.Stats["agility"]/TheoryCraft_Data.Stats["agipercrit"]
TheoryCraft_Data.Stats["totalhealth"] = TheoryCraft_Data.Stats["totalhealth"] - TheoryCraft_Data.Stats["stamina"]*10
TheoryCraft_Data.Stats["totalmana"] = TheoryCraft_Data.Stats["totalmana"] - TheoryCraft_Data.Stats["intellect"]*15
TheoryCraft_Data.Stats["strength"] = TheoryCraft_Data.Stats["strength"]/talents["strmultiplierreal"]
TheoryCraft_Data.Stats["agility"] = TheoryCraft_Data.Stats["agility"]/talents["agimultiplierreal"]
TheoryCraft_Data.Stats["stamina"] = TheoryCraft_Data.Stats["stamina"]/talents["stammultiplierreal"]
TheoryCraft_Data.Stats["intellect"] = TheoryCraft_Data.Stats["intellect"]/talents["intmultiplierreal"]
TheoryCraft_Data.Stats["spirit"] = TheoryCraft_Data.Stats["spirit"]/talents["spiritmultiplierreal"]
TheoryCraft_Data.Stats["formattackpower"] = 0
if (TheoryCraft_Outfits[outfit].meleecritchance) then TheoryCraft_Data.Stats["meleecritchance"] = TheoryCraft_Data.Stats["meleecritchance"]+TheoryCraft_Outfits[outfit].meleecritchance end
if (TheoryCraft_Outfits[outfit].rangedattackpower) then TheoryCraft_Data.Stats["rangedattackpower"] = TheoryCraft_Data.Stats["rangedattackpower"]+TheoryCraft_Outfits[outfit].rangedattackpower end
if (TheoryCraft_Outfits[outfit].attackpower) then TheoryCraft_Data.Stats["attackpower"] = TheoryCraft_Data.Stats["attackpower"]+TheoryCraft_Outfits[outfit].attackpower end
if (TheoryCraft_Outfits[outfit].formattackpower) then TheoryCraft_Data.Stats["formattackpower"] = TheoryCraft_Data.Stats["formattackpower"]+TheoryCraft_Outfits[outfit].formattackpower end
if (TheoryCraft_Outfits[outfit].strength) then TheoryCraft_Data.Stats["strength"] = TheoryCraft_Data.Stats["strength"]+TheoryCraft_Outfits[outfit].strength end
if (TheoryCraft_Outfits[outfit].agility) then TheoryCraft_Data.Stats["agility"] = TheoryCraft_Data.Stats["agility"]+TheoryCraft_Outfits[outfit].agility end
if (TheoryCraft_Outfits[outfit].stamina) then TheoryCraft_Data.Stats["stamina"] = TheoryCraft_Data.Stats["stamina"]+TheoryCraft_Outfits[outfit].stamina end
if (TheoryCraft_Outfits[outfit].intellect) then TheoryCraft_Data.Stats["intellect"] = TheoryCraft_Data.Stats["intellect"]+TheoryCraft_Outfits[outfit].intellect end
if (TheoryCraft_Outfits[outfit].spirit) then TheoryCraft_Data.Stats["spirit"] = TheoryCraft_Data.Stats["spirit"]+TheoryCraft_Outfits[outfit].spirit end
if (TheoryCraft_Outfits[outfit].totalmana) then TheoryCraft_Data.Stats["totalmana"] = TheoryCraft_Data.Stats["totalmana"]+TheoryCraft_Outfits[outfit].totalmana end
if (TheoryCraft_Outfits[outfit].totalhealth) then TheoryCraft_Data.Stats["totalhealth"] = TheoryCraft_Data.Stats["totalhealth"]+TheoryCraft_Outfits[outfit].totalhealth end
local i = 1
TheoryCraft_Data.DequippedSets = {}
while (TheoryCraft_Outfits[outfit].destat[i]) do
TheoryCraft_Data.Stats = TheoryCraft_DequipEffect(TheoryCraft_Outfits[outfit].destat[i], TheoryCraft_Data.Stats, TheoryCraft_Data.DequippedSets)
i = i + 1
end
local returndata
for k,count in pairs(TheoryCraft_Data.DequippedSets) do
if TheoryCraft_SetBonuses[k] then
for k,v in pairs(TheoryCraft_SetBonuses[k]) do
if (v["pieces"] <= count) then
returndata = {}
returndata = TheoryCraft_DequipLine(v["text"], returndata)
for k,v in pairs(returndata) do
TheoryCraft_Data.Stats[k] = (TheoryCraft_Data.Stats[k] or 0) + v
end
returndata = {}
returndata = TheoryCraft_DequipSpecial(v["text"], returndata)
for k,v in pairs(returndata) do
TheoryCraft_Data.Stats[k] = (TheoryCraft_Data.Stats[k] or 0) + v
end
end
end
end
end
if catform or bearform then TheoryCraft_Data.Stats["attackpower"] = TheoryCraft_Data.Stats["attackpower"] + TheoryCraft_Data.Stats["formattackpower"] end
TheoryCraft_Data.Stats["strength"] = math.floor(TheoryCraft_Data.Stats["strength"] * talents["strmultiplier"])
TheoryCraft_Data.Stats["agility"] = math.floor(TheoryCraft_Data.Stats["agility"] * talents["agimultiplier"])
TheoryCraft_Data.Stats["rangedattackpower"] = math.floor(TheoryCraft_Data.Stats["rangedattackpower"]+TheoryCraft_Data.Stats["agilityapranged"]*TheoryCraft_Data.Stats["agility"])
TheoryCraft_Data.Stats["attackpower"] = math.floor(TheoryCraft_Data.Stats["attackpower"]+TheoryCraft_Data.Stats["strengthapmelee"]*TheoryCraft_Data.Stats["strength"]+TheoryCraft_Data.Stats["agilityapmelee"]*TheoryCraft_Data.Stats["agility"])
TheoryCraft_Data.Stats["intellect"] = math.floor(TheoryCraft_Data.Stats["intellect"] * talents["intmultiplier"])
TheoryCraft_Data.Stats["stamina"] = math.floor(TheoryCraft_Data.Stats["stamina"] * talents["stammultiplier"])
TheoryCraft_Data.Stats["spirit"] = math.floor(TheoryCraft_Data.Stats["spirit"] * talents["spiritmultiplier"])
TheoryCraft_Data.Stats["totalhealth"] = (TheoryCraft_Data.Stats["totalhealth"] + TheoryCraft_Data.Stats["stamina"]*10)*talents["healthmultiplier"]
TheoryCraft_Data.Stats["totalmana"] = (TheoryCraft_Data.Stats["totalmana"] + TheoryCraft_Data.Stats["intellect"]*15)*talents["manamultiplier"]
TheoryCraft_Data.Stats["meleecritchance"] = TheoryCraft_Data.Stats["meleecritchance"]+TheoryCraft_Data.Stats["agility"]/TheoryCraft_Data.Stats["agipercrit"]
TheoryCraft_Data.Stats["rangedcritchance"] = TheoryCraft_Data.Stats["meleecritchance"]+(talents["Huntercritchance"] or 0)
TheoryCraft_Data.Stats["critchance"] = TheoryCraft_Data.Stats["intellect"]/TheoryCraft_intpercrit()+TheoryCraft_CritChance[class][4]
if class == "MAGE" then
TheoryCraft_Data.Stats["regenfromspirit"] = TheoryCraft_Data.Stats["spirit"]/8+6.25
elseif class == "PRIEST" then
TheoryCraft_Data.Stats["regenfromspirit"] = TheoryCraft_Data.Stats["spirit"]/8+6.25
elseif class == "WARLOCK" then
TheoryCraft_Data.Stats["regenfromspirit"] = TheoryCraft_Data.Stats["spirit"]/10+7.5
elseif class == "DRUID" then
TheoryCraft_Data.Stats["regenfromspirit"] = TheoryCraft_Data.Stats["spirit"]/10+7.5
elseif class == "SHAMAN" then
TheoryCraft_Data.Stats["regenfromspirit"] = TheoryCraft_Data.Stats["spirit"]/10+8.5
elseif class == "HUNTER" then
TheoryCraft_Data.Stats["regenfromspirit"] = TheoryCraft_Data.Stats["spirit"]/10+7.5
elseif class == "PALADIN" then
TheoryCraft_Data.Stats["regenfromspirit"] = TheoryCraft_Data.Stats["spirit"]/10+7.5
elseif class == "ROGUE" then
TheoryCraft_Data.Stats["regenfromspirit"] = 0
elseif class == "WARRIOR" then
TheoryCraft_Data.Stats["regenfromspirit"] = 0
end
TheoryCraft_Data.Stats["meleecritchancereal"] = TheoryCraft_Data.Stats["meleecritchance"]+(remove or 0)
if (TheoryCraft_Data.EquipEffects["FistEquipped"] or 0) >= 1 then
TheoryCraft_Data.Stats["meleecritchance"] = TheoryCraft_Data.Stats["meleecritchance"]+TheoryCraft_GetStat("Fistspec")
end
if (TheoryCraft_Data.EquipEffects["DaggerEquipped"] or 0) >= 1 then
TheoryCraft_Data.Stats["meleecritchance"] = TheoryCraft_Data.Stats["meleecritchance"]+TheoryCraft_GetStat("Daggerspec")
end
if (TheoryCraft_Data.EquipEffects["AxeEquipped"] or 0) >= 1 then
TheoryCraft_Data.Stats["meleecritchance"] = TheoryCraft_Data.Stats["meleecritchance"]+TheoryCraft_GetStat("Axespec")
end
if (TheoryCraft_Data.EquipEffects["PolearmEquipped"] or 0) >= 1 then
TheoryCraft_Data.Stats["meleecritchance"] = TheoryCraft_Data.Stats["meleecritchance"]+TheoryCraft_GetStat("Polearmspec")
end
local meleeapmult = TheoryCraft_GetStat("MeleeAPMult")
if meleeapmult > 3 then
TheoryCraft_Data.Stats["Meleemodifier"] = (talents["Twohandmodifier"] or 0)+(talents["Twohandtalentmod"] or 0)
elseif meleeapmult > 1 then
TheoryCraft_Data.Stats["Meleemodifier"] = (talents["Onehandmodifier"] or 0)+(talents["Onehandtalentmod"] or 0)
end
local manaregen = TheoryCraft_GetStat("manaperfive")/5
manaregen = manaregen+TheoryCraft_Data.Stats["totalmana"]*TheoryCraft_GetStat("FelEnergy")/4
TheoryCraft_Data.Stats["regen"] = manaregen+TheoryCraft_Data.Stats["regenfromspirit"]
TheoryCraft_Data.Stats["icregen"] = manaregen+(TheoryCraft_Data.Stats["regenfromspirit"])*TheoryCraft_GetStat("ICPercent")
if (class == "MAGE") then
TheoryCraft_Data.Stats["maxtotalmana"] = TheoryCraft_Data.Stats["totalmana"]+TheoryCraft_Data.Stats["regenfromspirit"]*15*8+1100+manaregen*8
end
if (class == "WARLOCK") then
getlifetap(TheoryCraft_Data.Stats)
end
TheoryCraft_Data.Stats["All"] = math.floor(TheoryCraft_Data.Stats["spirit"]*(talents["Allspiritual"] or 0))
TheoryCraft_Data.Stats["BlockValue"] = TheoryCraft_GetStat("BlockValueReport")+(TheoryCraft_Data.Stats["strength"]/20) - 1
end
local function AddProcs(casttime, returndata, spelldata)
TheoryCraft_Data.Procs = {}
if TheoryCraft_Settings["procs"] == nil then return end
if (spelldata == nil) or (spelldata.Schools == nil) then return end
if TheoryCraft_Data.EquipEffects["procs"] then
local i = 1
local amount, procduration
while TheoryCraft_Data.EquipEffects["procs"][i] do
amount = TheoryCraft_Data.EquipEffects["procs"][i].amount
if TheoryCraft_Data.EquipEffects["procs"][i].exact then
procduration = 1 - (1 - TheoryCraft_Data.EquipEffects["procs"][i].proc)^math.floor(TheoryCraft_Data.EquipEffects["procs"][i].duration/casttime)
else
procduration = 1 - (1 - TheoryCraft_Data.EquipEffects["procs"][i].proc)^(TheoryCraft_Data.EquipEffects["procs"][i].duration/casttime)
end
TheoryCraft_Data.Procs[TheoryCraft_Data.EquipEffects["procs"][i].type] = (TheoryCraft_Data.Procs[TheoryCraft_Data.EquipEffects["procs"][i].type] or 0)+amount*procduration
i = i + 1
end
i = 1
while (spelldata.Schools[i]) do
TheoryCraft_AddData(spelldata.Schools[i], TheoryCraft_Data.Procs, returndata)
i = i+1
end
if TheoryCraft_Data.Procs["ICPercent"] then
TheoryCraft_Data.Stats["icregen"] = TheoryCraft_GetStat("manaperfive")/5+(TheoryCraft_Data.Stats["regenfromspirit"])*(TheoryCraft_GetStat("ICPercent")+TheoryCraft_Data.Procs["ICPercent"])
end
end
end
local function CleanUp(spelldata, returndata)
if spelldata.percent == 0 then
returndata["plusdam"] = nil
returndata["damfinal"] = nil
returndata["damcoef"] = nil
end
if spelldata.ismelee then
returndata["manacost"] = nil
returndata["plusdam"] = nil
end
if spelldata.isheal then
returndata["penetration"] = nil
end
if spelldata.armor then
returndata["plusdam"] = nil
returndata["penetration"] = nil
end
if spelldata.dodps == nil then
returndata["hps"] = nil
returndata["withhothps"] = nil
returndata["hpsdam"] = nil
returndata["hpsdampercent"] = nil
returndata["dps"] = nil
returndata["withdotdps"] = nil
returndata["dpsdam"] = nil
returndata["dpsdampercent"] = nil
end
if (spelldata.usemelee) or (spelldata.petspell) then
returndata["nextpendam"] = nil
returndata["nextpen"] = nil
returndata["penetration"] = nil
end
if spelldata.petspell then
returndata["damcoef"] = nil
returndata["dpsdam"] = nil
returndata["dpsdampercent"] = nil
returndata["plusdam"] = nil
returndata["dameff"] = nil
returndata["damfinal"] = nil
returndata["lifetapdps"] = nil
returndata["lifetapdpm"] = nil
returndata["nextagidps"] = nil
returndata["nexthitdps"] = nil
returndata["nextcritdps"] = nil
returndata["nextstrdpsequive"] = nil
returndata["nextagidpsequive"] = nil
returndata["nexthitdpsequive"] = nil
returndata["nextcritdpsequive"] = nil
returndata["nextagidam"] = nil
returndata["nextpendam"] = nil
returndata["nexthitdam"] = nil
returndata["nextcritdam"] = nil
returndata["nextstrdamequive"] = nil
returndata["nextagidamequive"] = nil
returndata["nextpendamequive"] = nil
returndata["nexthitdamequive"] = nil
returndata["nextcritdamequive"] = nil
returndata["regendam"] = nil
returndata["icregendam"] = nil
returndata["nextcritheal"] = nil
returndata["nextcrithealequive"] = nil
returndata["hpsdam"] = nil
returndata["hpsdampercent"] = nil
returndata["regenheal"] = nil
returndata["icregenheal"] = nil
end
if (spelldata.dontdpsafterresists) then
returndata["nexthitdam"] = nil
end
if (spelldata.cancrit == nil) then
returndata["nextcritdam"] = nil
returndata["nextcritdamequive"] = nil
returndata["nextcritdps"] = nil
returndata["nextcritdpsequive"] = nil
returndata["critchance"] = nil
returndata["critdmgchance"] = nil
returndata["crithealchance"] = nil
returndata["critdmgmin"] = nil
returndata["critdmgmax"] = nil
returndata["critdmgminminusignite"] = nil
returndata["critdmgmaxminusignite"] = nil
returndata["crithealmin"] = nil
returndata["crithealmax"] = nil
end
end
local function GenerateTooltip(frame, returndata, spelldata, spellrank)
returndata["RangedAPMult"] = 2.8
if (frame == nil) or (frame:NumLines() == 0) then
CleanUp(spelldata, returndata)
return
end
if spelldata.evocation then
CleanUp(spelldata, returndata)
returndata["evocation"] = TheoryCraft_GetStat("maxtotalmana")-TheoryCraft_GetStat("totalmana")-1100
return
end
if (spelldata.isranged) then
if TheoryCraft_Data.EquipEffects["RangedSpeed"] == nil then
CleanUp(spelldata, returndata)
return
end
end
if (spelldata.isseal) then
if TheoryCraft_Data.EquipEffects["MainSpeed"] == nil then
CleanUp(spelldata, returndata)
return
end
end
if (spelldata.id == "Backstab") then
if TheoryCraft_GetStat("DaggerEquipped") == 0 then
CleanUp(spelldata, returndata)
return
end
end
if (spelldata.ismelee) then
if TheoryCraft_Data.EquipEffects["MainSpeed"] == nil then
CleanUp(spelldata, returndata)
return
end
local i = 1
returndata["critchance"] = TheoryCraft_Data.Stats["meleecritchance"]+TheoryCraft_GetStat(spelldata.id.."critchance")
while spelldata.Schools[i] do
returndata["critchance"] = returndata["critchance"]+TheoryCraft_GetStat(spelldata.Schools[i].."critchance")
i = i + 1
end
end
if (spelldata.bearform) then
local _, _, active = GetShapeshiftFormInfo(1)
if active == nil then
CleanUp(spelldata, returndata)
return
end
end
if (spelldata.catform) then
local _, _, active = GetShapeshiftFormInfo(3)
if active == nil then
CleanUp(spelldata, returndata)
return
end
end
if (spelldata.usemelee) then
returndata["critchance"] = (TheoryCraft_Data.Stats["meleecritchance"] or 0)+TheoryCraft_GetStat("Holycritchance")
returndata["critbonus"] = 1
end
if (spelldata.isranged) or ((class == "HUNTER") and (spelldata.ismelee == nil)) then
returndata["critchance"] = TheoryCraft_Data.Stats["rangedcritchance"]
end
returndata["description"] = getglobal(frame:GetName().."TextLeft"..frame:NumLines()):GetText()
returndata["casttime"] = getcasttime(frame)+(returndata["casttime"] or 0)
returndata["manacost"] = getmanacost(frame)
if not (spelldata.shoot or spelldata.ismelee or spelldata.isranged) then
returndata["basemanacost"] = returndata["manacost"]
end
if returndata["casttime"] < 1.5 then
returndata["casttime"] = 1.5
end
returndata["regencasttime"] = returndata["casttime"]
if (spelldata.casttime) then
returndata["casttime"] = spelldata.casttime
end
AddProcs(returndata["casttime"], returndata, spelldata)
if (spelldata.regencasttime) then
returndata["regencasttime"] = spelldata.regencasttime
end
if (returndata["netherwind"] == 1) and (TheoryCraft_Settings["procs"]) then
if (returndata["casttime"] > 1.5) then returndata["casttime"] = (returndata["casttime"]-1.5)*0.9+1.5 end
if (returndata["regencasttime"] > 1.5) then returndata["regencasttime"] = (returndata["regencasttime"]-1.5)*0.9+1.5 end
end
local spelllevel = 60
local levelpercent = 1
returndata["manamultiplier"] = spelldata.manamultiplier
if (spelldata["level"..spellrank]) then spelllevel = spelldata["level"..spellrank] end
if (spelldata["level"..spellrank.."per"]) then levelpercent = spelldata["level"..spellrank.."per"] end
if (spelldata["level"..spellrank.."manamult"]) then returndata["manamultiplier"] = spelldata["level"..spellrank.."manamult"] end
if (spelldata["level"..spellrank.."ct"]) then
returndata["casttime"] = spelldata["level"..spellrank.."ct"]
returndata["regencasttime"] = spelldata["level"..spellrank.."ct"]
end
if (spelllevel < 20) then
levelpercent = levelpercent*(0.0375*spelllevel+0.25)
end
returndata["dotduration"] = TheoryCraft_getDotDuration(returndata["description"])
returndata["basedotduration"] = spelldata.basedotduration
if (spelldata.ismelee == nil) and (spelldata.isranged == nil) then
if (spelldata.isheal == nil) and (spelldata.talentsbeforegear == nil) then
returndata["damcoef"] = spelldata.percent*returndata["tmpincrease"]*returndata["tmpincreaseupfront"]*levelpercent
else
returndata["damcoef"] = spelldata.percent*levelpercent
end
if (spelldata.righteousness) then
if (TheoryCraft_Data.EquipEffects["MeleeAPMult"] >= 3) then
returndata["damcoef"] = spelldata.percent2*returndata["tmpincrease"]*levelpercent
end
end
if (spelldata.hasdot == 1) then
returndata["damcoef2"] = spelldata.percentdot
returndata["plusdam2"] = math.floor(returndata["plusdam"] * returndata["damcoef2"] * levelpercent)
end
if (newcasttime) and (spelldata.isdot) then
returndata["damcoef"] = returndata["damcoef"]*newcasttime/returndata["basedotduration"]
returndata["casttime"] = newcasttime
end
returndata["damfinal"] = returndata["plusdam"] * returndata["damcoef"]
end
if returndata["critchance"] > 100 then
returndata["critchance"] = 100
end
returndata["critbonus"] = returndata["critbonus"]+returndata["sepignite"]*(returndata["baseincrease"]+returndata["ignitemodifier"]-1)
returndata["sepignite"] = returndata["sepignite"]*returndata["baseincrease"]
returndata["talentbaseincrease"] = (1/returndata["tmpincrease"])*(returndata["talentmod"]+returndata["tmpincrease"])
returndata["talentbaseincreaseupfront"] = (1/returndata["tmpincreaseupfront"])*(returndata["talentmodupfront"]+returndata["tmpincreaseupfront"])
if (spelldata.talentsbeforegear == nil) and (returndata["damcoef"]) then
returndata["damcoef"] = returndata["damcoef"]*returndata["talentbaseincrease"]*returndata["talentbaseincreaseupfront"]
end
if class == "DRUID" then
local _, bearform, catform
_, _, bearform = GetShapeshiftFormInfo(1)
_, _, catform = GetShapeshiftFormInfo(3)
if catform then
TheoryCraft_Data.EquipEffects["MeleeAPMult"] = 1
TheoryCraft_Data.EquipEffects["MainSpeed"] = 1
elseif bearform then
TheoryCraft_Data.EquipEffects["MeleeAPMult"] = 2.5
TheoryCraft_Data.EquipEffects["MainSpeed"] = 2.5
end
if (bearform) or (catform) then
local lowDmg, hiDmg, offlowDmg, offhiDmg, posBuff, negBuff, percentmod = UnitDamage("player")
local base, pos, neg = UnitAttackPower("player")
base = (base+pos+neg)/14*TheoryCraft_Data.EquipEffects["MeleeAPMult"]
TheoryCraft_Data.EquipEffects["MeleeMin"] = lowDmg-base
TheoryCraft_Data.EquipEffects["MeleeMax"] = hiDmg-lowDmg+TheoryCraft_Data.EquipEffects["MeleeMin"]
end
end
TheoryCraft_getMinMax(spelldata, returndata, frame)
if spelldata.cancrit then
if spelldata.drain then
returndata["critdmgchance"] = returndata["critchance"]
returndata["crithealchance"] = returndata["critchance"]
elseif spelldata.isheal then
returndata["crithealchance"] = returndata["critchance"]
else
returndata["critdmgchance"] = returndata["critchance"]
end
end
if spelldata.isheal == nil then
returndata["manacost"] = returndata["manacost"]-returndata["manacost"]*(TheoryCraft_Data.Talents["clearcast"] or 0)
end
if (returndata["manamultiplier"]) then
returndata["manacost"] = returndata["manacost"]*returndata["manamultiplier"]
end
returndata["manacost"] = returndata["manacost"]-TheoryCraft_Data.Stats["icregen"]*returndata["regencasttime"]
returndata["manacost"] = returndata["manacost"]*returndata["manacostmod"]
if (returndata["crithealchance"]) and (returndata["crithealchance"] > 100) then
returndata["crithealchance"] = 100
end
if (returndata["critdmgchance"]) and (returndata["critdmgchance"] > 100) then
returndata["critdmgchance"] = 100
end
if spelldata.dontusemelee then
returndata["critbonus"] = 0.5
end
if (spelldata.isseal) or (spelldata.ismelee) or (spelldata.isranged) then
if (returndata["mindamage"] and returndata["maxdamage"] and (spelldata.isseal == nil)) and (spelldata.block == nil) then
returndata["critdmgmin"] = returndata["mindamage"]*(returndata["critbonus"]+1)
returndata["critdmgmax"] = returndata["maxdamage"]*(returndata["critbonus"]+1)
returndata["averagedamnocrit"] = (returndata["maxdamage"]+returndata["mindamage"])/2
returndata["averagecritdam"] = returndata["averagedamnocrit"]*returndata["critbonus"]
returndata["averagedam"] = returndata["averagedamnocrit"]+returndata["averagecritdam"]*returndata["critdmgchance"]/100
returndata["nextagidam"] = 10*TheoryCraft_Data.Talents["agimultiplier"]
if spelldata.ismelee then
if spelldata.nextattack then
local attackpower = 10*TheoryCraft_Data.Talents["agimultiplier"]*TheoryCraft_Data.Stats["agilityapmelee"]
local addeddamage = attackpower*(TheoryCraft_Data.EquipEffects["MainSpeed"])*returndata["backstabmult"]*returndata["baseincrease"]*TheoryCraft_GetStat("Meleemodifier")/14
local addedcritpercent = 10*TheoryCraft_Data.Talents["agimultiplier"]/TheoryCraft_Data.Stats["agipercrit"]/100
returndata["nextagidam"] = addedcritpercent*returndata["averagecritdam"]+addeddamage*(addedcritpercent+returndata["critdmgchance"]/100)*returndata["critbonus"]+addeddamage
returndata["damworth"] = (1+(returndata["critchance"]/100)*returndata["critbonus"])*(TheoryCraft_Data.EquipEffects["MainSpeed"])/14*returndata["backstabmult"]*returndata["baseincrease"]*TheoryCraft_GetStat("Meleemodifier")
elseif returndata["bloodthirstmult"] then
local attackpower = 10*TheoryCraft_Data.Talents["agimultiplier"]*TheoryCraft_Data.Stats["agilityapmelee"]
local addeddamage = attackpower*returndata["bloodthirstmult"]*returndata["backstabmult"]*returndata["baseincrease"]*TheoryCraft_GetStat("Meleemodifier")/14
local addedcritpercent = 10*TheoryCraft_Data.Talents["agimultiplier"]/TheoryCraft_Data.Stats["agipercrit"]/100
returndata["nextagidam"] = addedcritpercent*returndata["averagecritdam"]+addeddamage*(addedcritpercent+returndata["critdmgchance"]/100)*returndata["critbonus"]+addeddamage
returndata["damworth"] = (1+(returndata["critchance"]/100)*returndata["critbonus"])*returndata["bloodthirstmult"]*returndata["backstabmult"]*returndata["baseincrease"]*TheoryCraft_GetStat("Meleemodifier")
else
local attackpower = 10*TheoryCraft_Data.Talents["agimultiplier"]*TheoryCraft_Data.Stats["agilityapmelee"]
local addeddamage = attackpower*TheoryCraft_Data.EquipEffects["MeleeAPMult"]*returndata["backstabmult"]*returndata["baseincrease"]*TheoryCraft_GetStat("Meleemodifier")/14
local addedcritpercent = 10*TheoryCraft_Data.Talents["agimultiplier"]/TheoryCraft_Data.Stats["agipercrit"]/100
returndata["nextagidam"] = addedcritpercent*returndata["averagecritdam"]+addeddamage*(addedcritpercent+returndata["critdmgchance"]/100)*returndata["critbonus"]+addeddamage
returndata["damworth"] = (1+(returndata["critchance"]/100)*returndata["critbonus"])*TheoryCraft_Data.EquipEffects["MeleeAPMult"]/14*returndata["backstabmult"]*returndata["baseincrease"]*TheoryCraft_GetStat("Meleemodifier")
end
returndata["nextstrdam"] = 10*TheoryCraft_Data.Talents["strmultiplier"]*TheoryCraft_Data.Stats["strengthapmelee"]*returndata["damworth"]
else
local attackpower = 10*TheoryCraft_Data.Talents["agimultiplier"]*TheoryCraft_Data.Stats["agilityapranged"]
local addeddamage = attackpower*returndata["RangedAPMult"]*returndata["backstabmult"]*returndata["baseincrease"]*TheoryCraft_GetStat("Rangedmodifier")/14
local addedcritpercent = 10*TheoryCraft_Data.Talents["agimultiplier"]/TheoryCraft_Data.Stats["agipercrit"]/100
returndata["nextagidam"] = addedcritpercent*returndata["averagecritdam"]+addeddamage*(addedcritpercent+returndata["critdmgchance"]/100)*returndata["critbonus"]+addeddamage
returndata["damworth"] = (1+(returndata["critchance"]/100)*returndata["critbonus"])*returndata["RangedAPMult"]/14*returndata["backstabmult"]*returndata["baseincrease"]*TheoryCraft_GetStat("Rangedmodifier")
end
returndata["nextcritdam"] = returndata["averagecritdam"]/100
returndata["nexthitdam"] = returndata["averagedamnocrit"]/100
if (returndata["damworth"] ~= 0) then
if returndata["nextstrdam"] then
returndata["nextstrdamequive"] = returndata["nextstrdam"]/returndata["damworth"]
end
returndata["nexthitdamequive"] = returndata["nexthitdam"]/returndata["damworth"]
returndata["nextcritdamequive"] = returndata["nextcritdam"]/returndata["damworth"]
returndata["nextagidamequive"] = returndata["nextagidam"]/returndata["damworth"]
end
if (spelldata.isranged) and (spelldata.shoot == nil) then
if (spelldata.autoshot) then
returndata["dpm"] = returndata["msrotationlength"]*returndata["msrotationdps"]/returndata["manacost"]
returndata["maxoomdam"] = (TheoryCraft_Data.Stats["totalmana"]+TheoryCraft_GetStat("manarestore"))*returndata["dpm"]
returndata["maxoomdamtime"] = returndata["maxoomdam"]/returndata["dps"]
returndata["regendam"] = TheoryCraft_Data.Stats["regen"]*10*returndata["dpm"]
returndata["icregendam"] = TheoryCraft_Data.Stats["icregen"]*10*returndata["dpm"]
else
if TheoryCraft_Settings["dontcritdpm"] then
returndata["dpm"] = returndata["averagedamnocrit"]/returndata["manacost"]
else
returndata["dpm"] = returndata["averagedam"]/returndata["manacost"]
end
returndata["regendam"] = TheoryCraft_Data.Stats["regen"]*10*returndata["dpm"]
returndata["icregendam"] = TheoryCraft_Data.Stats["icregen"]*10*returndata["dpm"]
end
end
end
else
if class == "DRUID" then
if (spelldata.cancrit) and (returndata["grace"] ~= 0) and (not TheoryCraft_Settings["dontcrit"]) then
returndata["casttime"] = returndata["casttime"]-(returndata["critchance"]/100)*returndata["grace"]
if returndata["casttime"] < 1.5 then
returndata["casttime"] = 1.5
end
end
end
if (class == "MAGE") then
if (returndata["critdmgchance"]) and (not TheoryCraft_Settings["dontcrit"]) then
returndata["manacost"] = returndata["manacost"]-returndata["manacost"]*((returndata["critdmgchance"]/100)*returndata["illum"])
end
end
if returndata["mindamage"] then
if returndata["maxdamage"] == nil then
returndata["maxdamage"] = returndata["mindamage"]
end
returndata["critdmgmin"] = returndata["mindamage"]*(returndata["critbonus"]+1)
returndata["critdmgmax"] = returndata["maxdamage"]*(returndata["critbonus"]+1)
returndata["averagedamnocrit"] = (returndata["maxdamage"]+returndata["mindamage"])/2
returndata["averagedpsdamnocrit"] = returndata["damfinal"]
if spelldata.cancrit then
returndata["critdmgmin"] = returndata["mindamage"]*(returndata["critbonus"]+1)
returndata["critdmgmax"] = returndata["maxdamage"]*(returndata["critbonus"]+1)
if (returndata["sepignite"] ~= 0) then
returndata["critdmgminminusignite"] = ((returndata["critdmgmin"]/(returndata["critbonus"]+1))*(1+returndata["critbonus"]-returndata["sepignite"]))
returndata["critdmgmaxminusignite"] = ((returndata["critdmgmax"]/(returndata["critbonus"]+1))*(1+returndata["critbonus"]-returndata["sepignite"]))
end
if (TheoryCraft_Settings["rollignites"]) and (not spelldata.dontdomax) and (returndata["sepignite"] ~= 0) and (returndata["critdmgchance"] < 99) then
local ignitecritmin = returndata["critdmgmin"]-(returndata["critdmgmin"]/(returndata["critbonus"]+1))*(1+returndata["critbonus"]-returndata["sepignite"])
local ignitecritmax = returndata["critdmgmax"]-(returndata["critdmgmax"]/(returndata["critbonus"]+1))*(1+returndata["critbonus"]-returndata["sepignite"])
local igniteaverage = (ignitecritmax-ignitecritmin)/2+ignitecritmin
local noignitecritmin = returndata["critdmgmin"]-ignitecritmin-returndata["mindamage"]
local noignitecritmax = returndata["critdmgmax"]-ignitecritmax-returndata["maxdamage"]
local noigniteaverage = (noignitecritmin+noignitecritmax)/2
local rollchance = (returndata["critdmgchance"]/100)
local ignitelength = 4+rollchance*4+(rollchance^2)*4+(rollchance^3)*4+(rollchance^4)*4+(rollchance^5)*4+(rollchance^6)*4
returndata["averagecritdam"] = noigniteaverage+ignitelength*igniteaverage/4
rollchance = ((returndata["critdmgchance"]+1)/100)
local newignitelength = 4+rollchance*4+(rollchance^2)*4+(rollchance^3)*4+(rollchance^4)*4+(rollchance^5)*4+(rollchance^6)*4
-- Average Crit Damage
returndata["nextcritdam"] = noigniteaverage+newignitelength*igniteaverage/4
-- Damage from extra ignite length
returndata["nextcritdam"] = (returndata["nextcritdam"]+(newignitelength-ignitelength)*igniteaverage/4*returndata["critdmgchance"])/100
else
returndata["averagecritdam"] = returndata["averagedamnocrit"]*returndata["critbonus"]
returndata["nextcritdam"] = returndata["averagecritdam"]/100
end
returndata["damhitworth"] = returndata["damcoef"]
returndata["damcritworth"] = returndata["damcoef"]*(returndata["critbonus"]+1)
returndata["damworth"] = returndata["damcoef"]*(1+returndata["critdmgchance"]*returndata["critbonus"]/100)
returndata["averagedam"] = returndata["averagedamnocrit"]+returndata["averagecritdam"]*returndata["critdmgchance"]/100
returndata["nextcritdam"] = returndata["nextcritdam"] + returndata["averagedam"]*returndata["grace"]
returndata["nextcritdamequive"] = returndata["nextcritdam"]/returndata["damworth"]
else
returndata["averagecritdam"] = 0
returndata["averagedam"] = returndata["averagedamnocrit"]
returndata["damhitworth"] = returndata["damcoef"]
returndata["damcritworth"] = 0
returndata["damworth"] = returndata["damcoef"]
end
returndata["averagedamthreat"] = returndata["averagedam"]*returndata["threat"]
returndata["averagedamthreatpercent"] = returndata["averagedamthreat"]/returndata["averagedam"]*100
if (not TheoryCraft_Settings["dontcrit"]) then
returndata["averagedpsdam"] = returndata["averagedpsdamnocrit"]*(returndata["averagedam"]/returndata["averagedamnocrit"])
else
returndata["averagedpsdam"] = returndata["averagedpsdamnocrit"]
end
if spelldata.tickinterval then
if (spelldata.hasdot) and (returndata["dotdamage"]) then
returndata["averagedamtick"] = returndata["dotdamage"]/returndata["dotduration"]*spelldata.tickinterval
returndata["averagedamticknocrit"] = returndata["dotdamage"]/returndata["dotduration"]*spelldata.tickinterval
else
if returndata["manamultiplier"] then
if (TheoryCraft_Settings["dontcrit"]) then
returndata["averagedamtick"] = returndata["averagedamnocrit"]/returndata["manamultiplier"]/returndata["dotduration"]*spelldata.tickinterval
else
returndata["averagedamtick"] = returndata["averagedam"]/returndata["manamultiplier"]/returndata["dotduration"]*spelldata.tickinterval
end
else
if (TheoryCraft_Settings["dontcrit"]) then
returndata["averagedamtick"] = returndata["averagedamnocrit"]/returndata["dotduration"]*spelldata.tickinterval
else
returndata["averagedamtick"] = returndata["averagedam"]/returndata["dotduration"]*spelldata.tickinterval
end
end
end
end
if spelldata.coa then
local tick1 = round(((returndata["averagedam"]-returndata["damfinal"]*returndata["baseincrease"])/24*2+returndata["damfinal"]*returndata["baseincrease"]/12)/2)
local tick2 = round((returndata["averagedam"]-returndata["damfinal"]*returndata["baseincrease"])/24*2+returndata["damfinal"]*returndata["baseincrease"]/12)
local tick3 = round(((returndata["averagedam"]-returndata["damfinal"]*returndata["baseincrease"])/24*2+returndata["damfinal"]*returndata["baseincrease"]/12)*1.5)
returndata["averagedamtick"] = tick1..", "..tick2..", "..tick3
end
if spelldata.starshards then
local tick1 = round((returndata["averagedam"]-returndata["damfinal"]*returndata["baseincrease"])/10+returndata["damfinal"]*returndata["baseincrease"]/6)
local tick2 = round((returndata["averagedam"]-returndata["damfinal"]*returndata["baseincrease"])/6+returndata["damfinal"]*returndata["baseincrease"]/6)
local tick3 = round((returndata["averagedam"]-returndata["damfinal"]*returndata["baseincrease"])/4.5+returndata["damfinal"]*returndata["baseincrease"]/6)
returndata["averagedamtick"] = tick1..", "..tick2..", "..tick3
end
if (TheoryCraft_Settings["dontcrit"]) then
returndata["dpm"] = returndata["averagedamnocrit"]/returndata["manacost"]
else
returndata["dpm"] = returndata["averagedam"]/returndata["manacost"]
end
if (TheoryCraft_Data.Stats["lifetapMana"]) and (TheoryCraft_Data.Stats["lifetapHealth"]) then
returndata["lifetapdpm"] = returndata["dpm"]*returndata["manacost"]/(returndata["manacost"]/TheoryCraft_Data.Stats["lifetapMana"]*TheoryCraft_Data.Stats["lifetapHealth"])
end
if (spelldata.overcooldown) then
if (TheoryCraft_Settings["dontcrit"]) then
returndata["dps"] = returndata["averagedamnocrit"]/getcooldown(frame)
else
returndata["dps"] = returndata["averagedam"]/getcooldown(frame)
end
returndata["dpsdam"] = returndata["averagedpsdam"]/getcooldown(frame)
else
if (TheoryCraft_Settings["dotoverct"]) and (spelldata.isdot) then
if (TheoryCraft_Settings["dontcrit"]) then
returndata["dps"] = returndata["averagedamnocrit"]/returndata["casttime"]
else
returndata["dps"] = returndata["averagedam"]/returndata["casttime"]
end
returndata["dpsdam"] = returndata["averagedpsdam"]/returndata["casttime"]
else
if spelldata.isdot then
if (TheoryCraft_Settings["dontcrit"]) then
returndata["dps"] = returndata["averagedamnocrit"]/returndata["dotduration"]
else
returndata["dps"] = returndata["averagedam"]/returndata["dotduration"]
end
returndata["dpsdam"] = returndata["averagedpsdam"]/returndata["dotduration"]
else
if (TheoryCraft_Settings["dontcrit"]) then
returndata["dps"] = returndata["averagedamnocrit"]/returndata["casttime"]
else
returndata["dps"] = returndata["averagedam"]/returndata["casttime"]
end
returndata["dpsdam"] = returndata["averagedpsdam"]/returndata["casttime"]
if TheoryCraft_Data.Stats["lifetapMana"] then
if (TheoryCraft_Settings["dontcrit"]) then
returndata["lifetapdps"] = returndata["averagedamnocrit"]/(returndata["casttime"]+(returndata["manacost"]/TheoryCraft_Data.Stats["lifetapMana"])*1.5)
else
returndata["lifetapdps"] = returndata["averagedam"]/(returndata["casttime"]+(returndata["manacost"]/TheoryCraft_Data.Stats["lifetapMana"])*1.5)
end
end
end
end
end
if returndata["dotdamage"] then
returndata["withdotdpm"] = (returndata["dpm"]*returndata["manacost"]+returndata["dotdamage"])/returndata["manacost"]
if (TheoryCraft_Settings["combinedot"]) then
if (TheoryCraft_Settings["dontcrit"]) then
returndata["withdotdps"] = (returndata["averagedamnocrit"]+returndata["dotdamage"])/returndata["casttime"]
else
returndata["withdotdps"] = (returndata["averagedam"]+returndata["dotdamage"])/returndata["casttime"]
end
else
returndata["withdotdps"] = returndata["dotdamage"]/returndata["dotduration"]
end
end
if spelldata.isdot then
returndata["dameff"] = returndata["damcoef"]*returndata["baseincrease"]/returndata["dotduration"]*3.5
else
if returndata["damcoef2"] then
returndata["dameff"] = ((returndata["damcoef"]+returndata["damcoef2"])*returndata["baseincrease"])/returndata["casttime"]*3.5
else
returndata["dameff"] = returndata["damcoef"]*returndata["baseincrease"]/returndata["casttime"]*3.5
end
end
if spelldata.dontdomax == nil then
returndata["maxoomdam"] = (TheoryCraft_Data.Stats["totalmana"]+TheoryCraft_GetStat("manarestore"))*returndata["dpm"]
returndata["maxoomdamtime"] = returndata["maxoomdam"]/returndata["dps"]
if TheoryCraft_Data.Stats["maxtotalmana"] then
returndata["maxevocoomdam"] = (TheoryCraft_Data.Stats["maxtotalmana"]+TheoryCraft_GetStat("manarestore"))*returndata["dpm"]
returndata["maxevocoomdamtime"] = returndata["maxevocoomdam"]/returndata["dps"]+8
end
end
if (spelldata.isdot == nil) then
returndata["nexthitdam"] = returndata["averagedamnocrit"]/100
returndata["nexthitdamequive"] = returndata["nexthitdam"]/returndata["damworth"]
end
returndata["nextpendam"] = returndata["averagedam"]*UnitLevel("player")/2400
returndata["nextpendamequive"] = returndata["nextpendam"]/returndata["damworth"]
returndata["regendam"] = TheoryCraft_Data.Stats["regen"]*10*returndata["dpm"]
returndata["icregendam"] = TheoryCraft_Data.Stats["icregen"]*10*returndata["dpm"]
returndata["penetration"] = returndata["penetration"]/((20/3)*UnitLevel("player"))*returndata["dps"]
if (returndata["manamultiplier"]) and (spelldata.lightningshield == nil) then
returndata["averagedam"] = returndata["averagedam"]/returndata["manamultiplier"]
returndata["averagedamnocrit"] = returndata["averagedamnocrit"]/returndata["manamultiplier"]
returndata["averagedamthreat"] = returndata["averagedamthreat"]/returndata["manamultiplier"]
end
end
if (returndata["minheal"]) then
if (class == "PALADIN") or (class == "MAGE") then
if (returndata["crithealchance"]) then
if (returndata["illum"] ~= 0) and (returndata["mindamage"]) then
returndata["manacost2"] = returndata["manacost"]
end
returndata["manacost"] = returndata["manacost"]-returndata["manacost"]*((returndata["crithealchance"]/100)*returndata["illum"])
end
end
if returndata["maxheal"] == nil then
returndata["maxheal"] = returndata["minheal"]
end
returndata["averagehealnocrit"] = (returndata["maxheal"]-returndata["minheal"])/2+returndata["minheal"]
returndata["averagehpsdamnocrit"] = returndata["damfinal"]
if spelldata.cancrit then
if returndata["crithealchance"] == nil then returndata["crithealchance"] = 0 end
returndata["crithealmin"] = returndata["minheal"]*(returndata["critbonus"]+1)
returndata["crithealmax"] = returndata["maxheal"]*(returndata["critbonus"]+1)
returndata["averagecritheal"] = returndata["averagehealnocrit"]*returndata["critbonus"]
returndata["nextcrit"] = returndata["averagecritheal"]/100
returndata["healworth"] = returndata["damcoef"]*(1+returndata["crithealchance"]*returndata["critbonus"]/100)
returndata["averageheal"] = returndata["averagehealnocrit"]+returndata["averagecritheal"]*returndata["crithealchance"]/100
returndata["nextcritheal"] = returndata["averagecritheal"]/100
returndata["nextcrithealequive"] = returndata["nextcritheal"]/returndata["healworth"]
else
returndata["averagecritheal"] = 0
returndata["averageheal"] = returndata["averagehealnocrit"]
returndata["healworth"] = returndata["damcoef"]
end
returndata["averagehealthreat"] = returndata["averageheal"]*returndata["threat"]
returndata["averagehealthreatpercent"] = returndata["averagehealthreat"]/returndata["averageheal"]*100
returndata["averagehpsdam"] = returndata["averagehpsdamnocrit"]*(returndata["averageheal"]/returndata["averagehealnocrit"])
if spelldata.tickinterval then
if (spelldata.hasdot) and (returndata["hotheal"]) then
returndata["averagehealtick"] = returndata["hotheal"]/returndata["dotduration"]*spelldata.tickinterval
else
if returndata["manamultiplier"] then
returndata["averagehealtick"] = returndata["averageheal"]/returndata["manamultiplier"]/returndata["dotduration"]*spelldata.tickinterval
else
returndata["averagehealtick"] = returndata["averageheal"]/returndata["dotduration"]*spelldata.tickinterval
end
end
end
if TheoryCraft_Settings["dontcrithpm"] then
returndata["hpm"] = returndata["averagehealnocrit"]/returndata["manacost"]
else
returndata["hpm"] = returndata["averageheal"]/returndata["manacost"]
end
if (TheoryCraft_Data.Stats["lifetapMana"]) and (TheoryCraft_Data.Stats["lifetapHealth"]) then
returndata["lifetaphpm"] = returndata["hpm"]*returndata["manacost"]/(returndata["manacost"]/TheoryCraft_Data.Stats["lifetapMana"]*TheoryCraft_Data.Stats["lifetapHealth"])
end
if (TheoryCraft_Settings["dotoverct"]) and (spelldata.isdot) then
returndata["hps"] = returndata["averageheal"]/returndata["casttime"]
returndata["hpsdam"] = returndata["averagehpsdam"]/returndata["casttime"]
else
if spelldata.isdot then
returndata["hps"] = returndata["averageheal"]/returndata["dotduration"]
returndata["hpsdam"] = returndata["averagehpsdam"]/returndata["dotduration"]
else
returndata["hps"] = returndata["averageheal"]/returndata["casttime"]
returndata["hpsdam"] = returndata["averagehpsdam"]/returndata["casttime"]
end
end
if TheoryCraft_Data.Stats["lifetapMana"] then
returndata["lifetaphps"] = returndata["averageheal"]/(returndata["casttime"]+(returndata["manacost"]/TheoryCraft_Data.Stats["lifetapMana"])*1.5)
end
if returndata["hotheal"] then
returndata["withhothpm"] = (returndata["hpm"]*returndata["manacost"]+returndata["hotheal"])/returndata["manacost"]
if (TheoryCraft_Settings["combinedot"]) then
returndata["withhothps"] = (returndata["averageheal"]+returndata["hotheal"])/returndata["casttime"]
else
returndata["withhothps"] = returndata["hotheal"]/returndata["dotduration"]
end
end
if spelldata.isdot then
returndata["dameff"] = returndata["damcoef"]*returndata["baseincrease"]/returndata["dotduration"]*3.5
else
if returndata["damcoef2"] then
returndata["dameff"] = ((returndata["damcoef"]+returndata["damcoef2"])*returndata["baseincrease"])/returndata["casttime"]*3.5
else
returndata["dameff"] = returndata["damcoef"]*returndata["baseincrease"]/returndata["casttime"]*3.5
end
end
if spelldata.dontdomax == nil then
returndata["maxoomheal"] = (TheoryCraft_Data.Stats["totalmana"]+TheoryCraft_GetStat("manarestore"))*returndata["hpm"]
returndata["maxoomhealtime"] = returndata["maxoomheal"]/returndata["hps"]
if returndata["maxtotalmana"] then
returndata["maxevocoomheal"] = TheoryCraft_Data.Stats["maxtotalmana"]*returndata["hpm"]
returndata["maxevocoomhealtime"] = returndata["maxevocoomheal"]/returndata["hps"]+8
end
end
returndata["regenheal"] = TheoryCraft_Data.Stats["regen"]*10*returndata["hpm"]
returndata["icregenheal"] = TheoryCraft_Data.Stats["icregen"]*10*returndata["hpm"]
if returndata["manamultiplier"] then
returndata["averageheal"] = returndata["averageheal"]/returndata["manamultiplier"]
returndata["averagehealnocrit"] = returndata["averagehealnocrit"]/returndata["manamultiplier"]
returndata["averagehealthreat"] = returndata["averagehealthreat"]/returndata["manamultiplier"]
end
end
end
if (returndata["dps"]) then
if (returndata["dpsdam"]) then
returndata["dpsdampercent"] = returndata["dpsdam"]/returndata["dps"]*100
end
end
if (returndata["hps"]) then
if (returndata["hpsdam"]) then
returndata["hpsdampercent"] = returndata["hpsdam"]/returndata["hps"]*100
end
end
if (returndata["manamultiplier"]) then
returndata["manacost"] = returndata["manacost"]/returndata["manamultiplier"]
end
if (spelldata.manamultiplier) and (returndata["damcoef"]) and (spelldata.lightningshield == nil) then
returndata["damcoef"] = returndata["damcoef"]/spelldata.manamultiplier
end
if (returndata["nextcritdam"]) and (returndata["critdmgchance"]) and (returndata["critdmgchance"] > 99) then
if returndata["critdmgchance"] < 100 then
returndata["nextcritdam"] = returndata["nextcritdam"]*(1 - (returndata["critdmgchance"] - 99))
returndata["nextcritdamequive"] = returndata["nextcritdamequive"]*(1 - (returndata["critdmgchance"] - 99))
else
returndata["nextcritdam"] = 0
returndata["nextcritdamequive"] = 0
end
end
if (returndata["nextcritheal"]) and (returndata["crithealchance"]) and (returndata["crithealchance"] > 99) then
if returndata["crithealchance"] < 100 then
returndata["nextcritheal"] = returndata["nextcritheal"]*(1 - (returndata["crithealchance"] - 99))
returndata["nextcrithealequive"] = returndata["nextcrithealequive"]*(1 - (returndata["crithealchance"] - 99))
else
returndata["nextcritheal"] = 0
returndata["nextcrithealequive"] = 0
end
end
CleanUp(spelldata, returndata)
if returndata["basemindamage"] then
if returndata["basemaxdamage"] == nil then
returndata["basemaxdamage"] = returndata["basemindamage"]
end
returndata["damtodouble"] = (returndata["basemindamage"]+returndata["basemaxdamage"])/2/returndata["damcoef"]
end
if returndata["damcoef"] then returndata["damcoef"] = returndata["damcoef"]*100 end
if returndata["dameff"] then returndata["dameff"] = returndata["dameff"]*100 end
if returndata["dps"] and returndata["manacost"] then
returndata["dpsmana"] = returndata["dps"]/returndata["manacost"]
end
if returndata["manacost"] then
returndata["maxspellcasts"] = 1+math.floor((TheoryCraft_GetStat("totalmana")-(returndata["basemanacost"] or returndata["manacost"]))/returndata["manacost"])
if returndata["maxoomdam"] then
returndata["maxoomdamfloored"] = returndata["dpm"]*returndata["manacost"]*returndata["maxspellcasts"]
end
if returndata["maxoomheal"] then
returndata["maxoomhealfloored"] = returndata["hpm"]*returndata["manacost"]*returndata["maxspellcasts"]
end
end
return
end
function TheoryCraft_GenerateTooltip(frame, spellname, spellrank, i2, showonbutton, macro, force)
local timer = GetTime()
local oldspellname = spellname
local olddesc
if i2 == nil then
if (frame) and (frame ~= TCTooltip2) then
if frame:NumLines() == 0 then return end
i2 = 1
if getglobal(frame:GetName().."TextRight1") and getglobal(frame:GetName().."TextRight1"):IsVisible() then
spellrank = getglobal(frame:GetName().."TextRight1"):GetText()
spellrank = tonumber(findpattern(spellrank, "%d+"))
if spellrank == nil then spellrank = 0 end
else
spellrank = nil
end
if getglobal(frame:GetName().."TextLeft1") and getglobal(frame:GetName().."TextLeft1"):GetText() then
spellname = getglobal(frame:GetName().."TextLeft1"):GetText()
else
spellname = ""
end
local spellname2, spellrank2
while (true) do
spellname2, spellrank2 = GetSpellBookItemName(i2,BOOKTYPE_SPELL)
if spellname2 == nil then return end
spellrank2 = tonumber(findpattern(spellrank2, "%d+"))
if spellrank2 == nil then spellrank2 = 0 end
if (spellname == spellname2) and ((spellrank == nil) or (spellrank == spellrank2)) then break end
i2 = i2 + 1
end
if spellname ~= spellname2 then return end
if (spellrank) and (spellrank ~= spellrank2) then return end
if (spellname == "Attack") then spellrank = 0 end
if (spellrank == nil) then
olddesc = getglobal(frame:GetName().."TextLeft"..frame:NumLines()):GetText()
while (spellname == spellname2) do
spellname2, spellrank = GetSpellBookItemName(i2,BOOKTYPE_SPELL)
if spellname == nil then return end
spellrank = tonumber(findpattern(spellrank, "%d+"))
if spellrank == nil then spellrank = 0 end
TCTooltip:SetOwner(UIParent,"ANCHOR_NONE")
TCTooltip:SetSpellByID(i2)
if (getglobal("TCTooltipTextLeft"..TCTooltip:NumLines())) and (getglobal("TCTooltipTextLeft"..TCTooltip:NumLines()):GetText() == olddesc) then
break
end
i2 = i2 + 1
end
if (TCTooltip) and (getglobal("TCTooltipTextLeft"..TCTooltip:NumLines())) and (getglobal("TCTooltipTextLeft"..TCTooltip:NumLines()):GetText() ~= olddesc) then
return
end
end
else
i2 = 1
local spellname2, spellrank2
if (string.len(spellrank) == 1) and (string.len(spellname) ~= 13) then
macro = nil
end
if (string.len(spellrank) == 2) and (string.len(spellname) ~= 12) then
macro = nil
end
while (true) do
spellname2, spellrank2 = GetSpellBookItemName(i2,BOOKTYPE_SPELL)
if spellname2 == nil then return end
spellrank2 = tonumber(findpattern(spellrank2, "%d+"))
if spellrank2 == nil then spellrank2 = 0 end
if (spellname == spellname2) or ((macro) and (spellname == string.sub(spellname2, 1, string.len(spellname)))) then
spellname = spellname2
if spellrank == spellrank2 then
break
end
end
i2 = i2 + 1
end
if spellname ~= spellname2 then return end
if spellrank ~= spellrank2 then return end
if frame == nil then
frame = TCTooltip
end
frame:SetOwner(UIParent,"ANCHOR_NONE")
frame:SetSpellByID(i2)
if frame:NumLines() == 0 then return end
end
end
if spellname == TheoryCraft_Locale.MinMax.autoshotname then
local highestaimed, highestmulti, highestarcane
local i2 = 1
local spellname, spellrank = GetSpellBookItemName(i2,BOOKTYPE_SPELL)
while (spellname) do
spellrank = tonumber(findpattern((spellrank or "0"), "%d+"))
if (spellname == TheoryCraft_Locale.MinMax.aimedshotname) and ((highestaimed == nil) or (highestaimed < spellrank)) then
highestaimed = spellrank
end
if (spellname == TheoryCraft_Locale.MinMax.multishotname) and ((highestmulti == nil) or (highestmulti < spellrank)) then
highestmulti = spellrank
end
if (spellname == TheoryCraft_Locale.MinMax.arcaneshotname) and ((highestarcane == nil) or (highestarcane < spellrank)) then
highestarcane = spellrank
end
i2 = i2 + 1
spellname, spellrank = GetSpellBookItemName(i2,BOOKTYPE_SPELL)
end
if (highestaimed) and (TheoryCraft_TooltipData[TheoryCraft_Locale.MinMax.aimedshotname.."("..highestaimed..")"] == nil) then
TheoryCraft_GenerateTooltip(TCTooltip2, TheoryCraft_Locale.MinMax.aimedshotname, highestaimed, nil, nil, nil, true)
end
if (highestmulti) and (TheoryCraft_TooltipData[TheoryCraft_Locale.MinMax.multishotname.."("..highestmulti..")"] == nil) then
TheoryCraft_GenerateTooltip(TCTooltip2, TheoryCraft_Locale.MinMax.multishotname, highestmulti, nil, nil, nil, true)
end
if (highestarcane) and (TheoryCraft_TooltipData[TheoryCraft_Locale.MinMax.arcaneshotname.."("..highestarcane..")"] == nil) then
TheoryCraft_GenerateTooltip(TCTooltip2, TheoryCraft_Locale.MinMax.arcaneshotname, highestarcane, nil, nil, nil, true)
end
end
if (not force) and (TheoryCraft_Settings["GenerateList"] ~= "") and (not string.find(TheoryCraft_Settings["GenerateList"], string.gsub(spellname, "-", "%%-").."%("..spellrank.."%)")) then
return
end
local i
for k, v in pairs(TheoryCraft_Spells[class]) do
if v.name == spellname then
i = v
break
end
end
if not i then return end
-- TheoryCraft_Data.Testing = nil
SummateData(i.id, i.Schools)
olddesc = getglobal(frame:GetName().."TextLeft"..frame:NumLines()):GetText()
if TheoryCraft_TooltipData[olddesc] == nil then
TheoryCraft_TooltipData[olddesc] = {}
end
TheoryCraft_DeleteTable(TheoryCraft_TooltipData[olddesc])
TheoryCraft_CopyTable(summeddata, TheoryCraft_TooltipData[olddesc])
if TheoryCraft_TooltipData[olddesc]["schools"] == nil then
TheoryCraft_TooltipData[olddesc]["schools"] = {}
end
TheoryCraft_CopyTable(i.Schools, TheoryCraft_TooltipData[olddesc]["schools"])
GenerateTooltip(frame, TheoryCraft_TooltipData[olddesc], i, spellrank)
if macro then
TheoryCraft_TooltipData[oldspellname.."MACRO("..spellrank..")"] = olddesc
end
TheoryCraft_TooltipData[spellname.."("..spellrank..")"] = olddesc
TheoryCraft_TooltipData[olddesc]["basedescription"] = olddesc
if (i.shoot) or (i.ismelee) or (i.isranged) then
if getglobal(frame:GetName().."TextLeft2") then
TheoryCraft_TooltipData[olddesc]["wandlineleft2"] = getglobal(frame:GetName().."TextLeft2"):GetText()
end
if getglobal(frame:GetName().."TextRight2") and getglobal(frame:GetName().."TextRight2"):IsVisible() then
TheoryCraft_TooltipData[olddesc]["wandlineright2"] = getglobal(frame:GetName().."TextRight2"):GetText()
end
if getglobal(frame:GetName().."TextLeft3") and getglobal(frame:GetName().."TextLeft3"):IsVisible() then
TheoryCraft_TooltipData[olddesc]["wandlineleft3"] = getglobal(frame:GetName().."TextLeft3"):GetText()
end
if getglobal(frame:GetName().."TextRight3") and getglobal(frame:GetName().."TextRight3"):IsVisible() then
TheoryCraft_TooltipData[olddesc]["wandlineright3"] = getglobal(frame:GetName().."TextRight3"):GetText()
end
if getglobal(frame:GetName().."TextLeft4") then
if getglobal(frame:GetName().."TextLeft4"):GetText() ~= olddesc then
TheoryCraft_TooltipData[olddesc]["wandlineleft4"] = getglobal(frame:GetName().."TextLeft4"):GetText()
end
end
else
if getglobal(frame:GetName().."TextLeft3") then
if (getglobal(frame:GetName().."TextLeft3"):GetText()) then
if (getglobal(frame:GetName().."TextLeft3"):GetText() ~= olddesc) and (strfind(getglobal(frame:GetName().."TextLeft3"):GetText(), (TheoryCraft_Locale.CooldownRem) or "Cooldown remaining: ") == nil) then
TheoryCraft_TooltipData[olddesc]["basecasttime"] = getglobal(frame:GetName().."TextLeft3"):GetText()
end
end
end
if getglobal(frame:GetName().."TextRight2") and getglobal(frame:GetName().."TextRight2"):IsVisible() then
TheoryCraft_TooltipData[olddesc]["spellrange"] = getglobal(frame:GetName().."TextRight2"):GetText()
end
if getglobal(frame:GetName().."TextRight3") and getglobal(frame:GetName().."TextRight3"):IsVisible() then
TheoryCraft_TooltipData[olddesc]["cooldown"] = getglobal(frame:GetName().."TextRight3"):GetText()
if (i.overcooldown) and (TheoryCraft_TooltipData[olddesc]["averagedam"]) then
if (strfind(TheoryCraft_TooltipData[olddesc]["cooldown"], "%d+.%d+"..TheoryCraft_Locale.Cooldown)) then
TheoryCraft_TooltipData[olddesc]["dps"] = TheoryCraft_TooltipData[olddesc]["averagedam"]/tonumber(findpattern(TheoryCraft_TooltipData[olddesc]["cooldown"], "%d+.%d+"))
elseif (strfind(TheoryCraft_TooltipData[olddesc]["cooldown"], "%d+"..TheoryCraft_Locale.Cooldown)) then
TheoryCraft_TooltipData[olddesc]["dps"] = TheoryCraft_TooltipData[olddesc]["averagedam"]/tonumber(findpattern(TheoryCraft_TooltipData[olddesc]["cooldown"], "%d+"))
end
end
end
end
TheoryCraft_TooltipData[olddesc]["spellname"] = spellname
TheoryCraft_TooltipData[olddesc]["spellrank"] = spellrank
TheoryCraft_TooltipData[olddesc]["spellnumber"] = i2
TheoryCraft_TooltipData[olddesc]["dontdpsafterresists"] = i.dontdpsafterresists
TheoryCraft_TooltipData[olddesc]["isheal"] = i.isheal
TheoryCraft_TooltipData[olddesc]["iscombo"] = i.iscombo
TheoryCraft_TooltipData[olddesc]["cancrit"] = i.cancrit
TheoryCraft_TooltipData[olddesc]["shoot"] = i.shoot
TheoryCraft_TooltipData[olddesc]["ismelee"] = i.ismelee
TheoryCraft_TooltipData[olddesc]["isranged"] = i.isranged
TheoryCraft_TooltipData[olddesc]["autoshot"] = i.autoshot
TheoryCraft_TooltipData[olddesc]["armor"] = i.armor
TheoryCraft_TooltipData[olddesc]["binary"] = i.binary
TheoryCraft_TooltipData[olddesc]["dodps"] = i.dodps
TheoryCraft_TooltipData[olddesc]["isseal"] = i.isseal
TheoryCraft_TooltipData[olddesc]["drain"] = i.drain
TheoryCraft_TooltipData[olddesc]["holynova"] = i.holynova
TheoryCraft_TooltipData[olddesc]["dontdomax"] = i.dontdomax
TheoryCraft_TooltipData[olddesc]["overcd"] = i.overcooldown
if (TheoryCraft_Settings["GenerateList"] == "") or (string.find(TheoryCraft_Settings["GenerateList"], string.gsub(spellname, "-", "%%-").."%("..spellrank.."%)")) then
TheoryCraft_TooltipData[olddesc]["showonbutton"] = true
end
if TheoryCraft_Data["reporttimes"] then
TheoryCraft_Data["buttonsgenerated"] = TheoryCraft_Data["buttonsgenerated"]+1
TheoryCraft_Data["timetaken"] = TheoryCraft_Data["timetaken"]+GetTime()-timer
end
end
local data2 = {}
local function UpdateTarget(data)
local function UnitMana(unit)
return UnitPower(unit, Enum.PowerType.Mana)
end
if data == nil then return end
data["resistscore"] = 0
if data["basemanacost"] and data["manacost"] then
if UnitMana("player") >= data["basemanacost"] then
data["spellcasts"] = 1+math.floor((UnitMana("player")-(data["basemanacost"] or data["manacost"]))/data["manacost"])
if data["dpm"] and data["maxoomdam"] then
data["maxoomdamremaining"] = data["dpm"]*data["manacost"]*data["spellcasts"]
end
if data["hpm"] and data["maxoomheal"] then
data["maxoomhealremaining"] = data["hpm"]*data["manacost"]*data["spellcasts"]
end
else
data["spellcasts"] = 0
if data["maxoomdam"] then
data["maxoomdamremaining"] = 0
end
if data["maxoomheal"] then
data["maxoomdamremaining"] = 0
end
end
end
if data.iscombo then
if data["description"] == nil then return end
local points = GetComboPoints("player")
data["mindamage"] = data["combo"..points.."mindamage"] or 0
data["maxdamage"] = data["combo"..points.."maxdamage"] or 0
if (data["comboconvert"]) and (points > 0) then
local add = (UnitMana("player")-35)*data["comboconvert"]
data["mindamage"] = data["mindamage"]+add
data["maxdamage"] = data["maxdamage"]+add
end
data["critdmgmin"] = data["mindamage"]*(data["critbonus"]+1)
data["critdmgmax"] = data["maxdamage"]*(data["critbonus"]+1)
data["averagedamnocrit"] = (data["maxdamage"]+data["mindamage"])/2
data["averagecritdam"] = data["averagedamnocrit"]*data["critbonus"]
data["averagedam"] = data["averagedamnocrit"]+data["averagecritdam"]*(data["critdmgchance"] or 0)/100
data["description"] = data["beforecombo"]
local search = TheoryCraft_MeleeComboReader
search = string.gsub(search, "%(%%d%+%)", points, 1)
local replace = TheoryCraft_MeleeComboReplaceWith
replace = "%*"..string.gsub(replace, "%$points%$", points).."%*"
data["description"] = string.gsub(data["description"], search, replace)
end
if data["isheal"] then return end
if data["armor"] and TheoryCraft_Settings["mitigation"] then
TheoryCraft_DeleteTable(data2)
TheoryCraft_CopyTable(data, data2)
data = data2
local armormult = TheoryCraft_Data.armormultinternal
if data["description"] then
if data["mindamage"] then
data["description"] = string.gsub(data["description"], round(data["mindamage"]), round(data["mindamage"]*armormult))
end
if data["maxdamage"] then
data["description"] = string.gsub(data["description"], round(data["maxdamage"]), round(data["maxdamage"]*armormult))
end
end
if data["mindamage"] then data["mindamage"] = data["mindamage"]*armormult end
if data["maxdamage"] then data["maxdamage"] = data["maxdamage"]*armormult end
if data["critdmgmin"] then data["critdmgmin"] = data["critdmgmin"]*armormult end
if data["critdmgmax"] then data["critdmgmax"] = data["critdmgmax"]*armormult end
if data["nextstrdam"] then data["nextstrdam"] = data["nextstrdam"]*armormult end
if data["nextagidam"] then data["nextagidam"] = data["nextagidam"]*armormult end
if data["nexthitdam"] then data["nexthitdam"] = data["nexthitdam"]*armormult end
if data["nextcritdam"] then data["nextcritdam"] = data["nextcritdam"]*armormult end
if data["dpm"] then data["dpm"] = data["dpm"]*armormult end
if data["dps"] then data["dps"] = data["dps"]*armormult end
if data["averagedam"] then data["averagedam"] = data["averagedam"]*armormult end
if data["averagedamnocrit"] then data["averagedamnocrit"] = data["averagedamnocrit"]*armormult end
if data["maxoomdam"] then data["maxoomdam"] = data["maxoomdam"]*armormult end
if data["maxoomdamremaining"] then data["maxoomdamremaining"] = data["maxoomdamremaining"]*armormult end
if data["maxoomdamfloored"] then data["maxoomdamfloored"] = data["maxoomdamfloored"]*armormult end
if data["asrotationdps"] then data["asrotationdps"] = data["asrotationdps"]*armormult end
if data["msrotationdps"] then data["asrotationdps"] = data["asrotationdps"]*armormult end
if data["arcrotationdps"] then data["arcrotationdps"] = (data["arcrotationdps"] - (data["arcmagicdps"] or 0))*armormult + (data["arcmagicdps"] or 0) end
return data
end
if data["ismelee"] then return end
if data["isseal"] then return end
if data["autoshot"] then return end
local penamount = 0
if data["schools"] then
for k, v in pairs(data["schools"]) do
penamount = penamount + TheoryCraft_GetStat(v.."penetration")
for k, v2 in pairs(TheoryCraft_PrimarySchools) do
if (type(v2) == "table") and (v2.name == v) and (TheoryCraft_Settings["resistscores"][v2.name]) then
if TheoryCraft_Settings["resistscores"][v2.name] == "~" then
data["resistscore"] = data["resistscore"]+1000
else
data["resistscore"] = data["resistscore"]+TheoryCraft_Settings["resistscores"][v2.name]
end
end
end
end
end
if data["resistscore"] > 0 then
if data["resistscore"] < penamount then
data["resistscore"] = 0
else
data["resistscore"] = data["resistscore"]-penamount
end
end
penamount = data["resistscore"]
if penamount < 0 then
penamount = 0
end
data["resistscore"] = data["resistscore"]/(UnitLevel("player")*20/3)
if (data["resistscore"] > 0.75) and (data["resistscore"] < 2.5) then
data["resistscore"] = 0.75
end
data["resistlevel"] = UnitLevel("target")
local playerlevel = UnitLevel("player")
if data["resistlevel"] == -1 then
data["resistlevel"] = 63
end
if data["resistlevel"] == 0 then
data["resistlevel"] = playerlevel
end
data["resistrate"] = data["resistlevel"]-playerlevel
if UnitIsPlayer("target") then
if (data["resistrate"] < -2) then
data["resistrate"] = 1
elseif (data["resistrate"] == -2) then
data["resistrate"] = 2
elseif (data["resistrate"] == -1) then
data["resistrate"] = 3
elseif (data["resistrate"] == 0) then
data["resistrate"] = 4
elseif (data["resistrate"] == 1) then
data["resistrate"] = 5
elseif (data["resistrate"] == 2) then
data["resistrate"] = 6
elseif (data["resistrate"] > 2) then
data["resistrate"] = 13+(data["resistrate"]-3)*7
end
else
if (data["resistrate"] < -2) then
data["resistrate"] = 1
elseif (data["resistrate"] == -2) then
data["resistrate"] = 2
elseif (data["resistrate"] == -1) then
data["resistrate"] = 3
elseif (data["resistrate"] == 0) then
data["resistrate"] = 4
elseif (data["resistrate"] == 1) then
data["resistrate"] = 5
elseif (data["resistrate"] == 2) then
data["resistrate"] = 6
elseif (data["resistrate"] > 2) then
data["resistrate"] = 17+(data["resistrate"]-3)*11
end
end
if (data["resistrate"] > 99) then
data["resistrate"] = 99
end
data["resistrate"] = data["resistrate"]+(data["hitbonus"] or 0)
local toomuchhit
if (data["resistrate"] < 2) then
toomuchhit = 1
data["resistrate"] = 1
end
local damworth
if (data["nexthitdam"]) and (not data["dontdpsafterresists"]) then
local misschance = data["resistrate"]
local critchance = (data["critchance"] or 0)
if (misschance + critchance) > 100 then
critchance = 100-misschance
end
local hitchance = 100-critchance-misschance
local averagehitdam = (data["averagedamnocrit"] or 0)*(data["manamultiplier"] or 1)
local averagecritdam = ((data["averagedamnocrit"] or 0)*(data["manamultiplier"] or 1)+(data["averagecritdam"] or 0))
if TheoryCraft_Settings["dontcrit"] then
hitchance = hitchance + critchance
critchance = 0
end
hitchance = hitchance/100*averagehitdam
critchance = critchance/100*averagecritdam
data["dpsafterresists"] = round((hitchance+critchance)/data["casttime"], 1)
end
if not TheoryCraft_Settings["dontresist"] then
return
end
TheoryCraft_DeleteTable(data2)
TheoryCraft_CopyTable(data, data2)
data = data2
local resistmult = (1-data["resistscore"])
if data["binary"] then
if resistmult > 1 then
resistmult = 1
end
end
if resistmult < 0 then
resistmult = 0
penamount = 0
end
if data["nextcritdam"] then data["nextcritdam"] = data["nextcritdam"] * resistmult end
if data["nexthitdam"] then data["nexthitdam"] = data["nexthitdam"] * resistmult end
if data["overcd"] == nil then
if data["dps"] and data["dpsafterresists"] then
resistmult = resistmult * data["dpsafterresists"]/data["dps"]
data["dps"] = data["dpsafterresists"]
end
end
if data["binary"] then
data["resistrate"] = data["resistrate"] + data["resistscore"]*100
if data["resistrate"] > 100 then
data["resistrate"] = 100
end
end
if data["damworth"] then data["damworth"] = data["damworth"] * resistmult end
if penamount < 10 then
if data["nextpendam"] then
data["nextpendam"] = data["nextpendam"] * (penamount/10)
end
end
data["dontshowupto"] = ""
if data["nexthitdamequive"] and data["nexthitdam"] and data["damworth"] then data["nexthitdamequive"] = data["nexthitdam"] / data["damworth"] end
if data["nextcritdamequive"] and data["nextcritdam"] and data["damworth"] then data["nextcritdamequive"] = data["nextcritdam"] / data["damworth"] end
if data["nextpendamequive"] and data["nextpendam"] and data["damworth"] then data["nextpendamequive"] = data["nextpendam"] / data["damworth"] end
if data["damworth"] == 0 then data["nexthitdamequive"] = 0 end
if data["damworth"] == 0 then data["nextcritdamequive"] = 0 end
if data["dps"] then data["dps"] = data["dps"] * resistmult end
if data["withdotdps"] then data["withdotdps"] = data["withdotdps"] * resistmult end
if data["dpsdam"] then data["dpsdam"] = data["dpsdam"] * resistmult end
if data["averagedam"] then data["averagedam"] = data["averagedam"] * resistmult end
if data["averagedamnocrit"] then data["averagedamnocrit"] = data["averagedamnocrit"] * resistmult end
if data["dpm"] then data["dpm"] = data["dpm"] * resistmult end
if data["withdotdpm"] then data["withdotdpm"] = data["withdotdpm"] * resistmult end
if data["maxoomdam"] then data["maxoomdam"] = data["maxoomdam"] * resistmult end
if data["maxevocoomdam"] then data["maxevocoomdam"] = data["maxevocoomdam"] * resistmult end
if toomuchhit then data["nexthitdam"] = 0 data["nexthitdamequive"] = "At max, 0.00" end
if penamount == 0 then data["nextpendamequive"] = "At max, 0.00" end
return data
end
function TheoryCraft_GetSpellDataByFrame(frame, force)
if frame == nil then return nil end
if frame:NumLines() == 0 then return nil end
if getglobal(frame:GetName().."TextLeft"..frame:NumLines()) == nil then return nil end
local desc = getglobal(frame:GetName().."TextLeft"..frame:NumLines()):GetText()
if (frame:NumLines() == 1) and (desc ~= "Attack") then
local pos = strfind(desc, "%(%d+%)")
if not pos then return nil end
local data = TheoryCraft_GetSpellDataByName(string.sub(desc, 1, pos-1), tonumber(string.sub(desc, pos+1, string.len(desc)-1)), force, true)
if data == nil then return nil end
if data.spellnumber == nil then return nil end
frame:SetSpellByID(data.spellnumber)
return data
end
if TheoryCraft_TooltipData[desc] and TheoryCraft_TooltipData[desc].spellname then
return UpdateTarget(TheoryCraft_TooltipData[desc]) or TheoryCraft_TooltipData[desc]
end
TheoryCraft_GenerateTooltip(frame, nil, nil, nil, true, nil, force)
return UpdateTarget(TheoryCraft_TooltipData[desc]) or TheoryCraft_TooltipData[desc]
end
function TheoryCraft_GetSpellDataByName(spellname, spellrank, force, macro)
if spellrank == nil then spellrank = 0 end
local description = TheoryCraft_TooltipData[spellname.."("..spellrank..")"] or (macro and TheoryCraft_TooltipData[spellname.."MACRO("..spellrank..")"])
if (description) then
if TheoryCraft_TooltipData[description] and TheoryCraft_TooltipData[description].spellname then
return UpdateTarget(TheoryCraft_TooltipData[description]) or TheoryCraft_TooltipData[description]
end
end
TheoryCraft_GenerateTooltip(nil, spellname, spellrank, nil, true, macro)
if TheoryCraft_TooltipData[TheoryCraft_TooltipData[spellname.."("..spellrank..")"]] and TheoryCraft_TooltipData[TheoryCraft_TooltipData[spellname.."("..spellrank..")"]].spellname then
return UpdateTarget(TheoryCraft_TooltipData[TheoryCraft_TooltipData[spellname.."("..spellrank..")"]]) or TheoryCraft_TooltipData[TheoryCraft_TooltipData[spellname.."("..spellrank..")"]]
elseif TheoryCraft_TooltipData[TheoryCraft_TooltipData[spellname.."MACRO("..spellrank..")"]] and TheoryCraft_TooltipData[TheoryCraft_TooltipData[spellname.."MACRO("..spellrank..")"]].spellname then
return UpdateTarget(TheoryCraft_TooltipData[TheoryCraft_TooltipData[spellname.."MACRO("..spellrank..")"]]) or TheoryCraft_TooltipData[TheoryCraft_TooltipData[spellname.."MACRO("..spellrank..")"]]
end
end
function TheoryCraft_GetSpellDataByDescription(description, force)
if TheoryCraft_TooltipData[description] and TheoryCraft_TooltipData[description].spellname then
return UpdateTarget(TheoryCraft_TooltipData[description]) or TheoryCraft_TooltipData[description]
end
if (force ~= true) and (TheoryCraft_Settings["GenerateList"] ~= "") then
return
end
local i = 1
local spellname, spellrank
local testdesc
while (true) do
spellname, spellrank = GetSpellBookItemName(i,BOOKTYPE_SPELL)
if spellname == nil then break end
spellrank = tonumber(findpattern(spellrank, "%d+"))
if spellrank == nil then spellrank = 0 end
TCTooltip:SetOwner(UIParent,"ANCHOR_NONE")
TCTooltip:SetSpellByID(i)
if(getglobal("TCTooltipTextLeft"..TCTooltip:NumLines())) then
testdesc = getglobal("TCTooltipTextLeft"..TCTooltip:NumLines()):GetText()
end
if testdesc == description then
TheoryCraft_GenerateTooltip(TCTooltip, spellname, spellrank, i, true)
return UpdateTarget(TheoryCraft_TooltipData[description]) or TheoryCraft_TooltipData[description]
end
i = i + 1
end
end
function TheoryCraft_GenerateAll()
TheoryCraft_DeleteTable(TheoryCraft_TooltipData)
TheoryCraft_DeleteTable(TheoryCraft_UpdatedButtons)
if TheoryCraft_UpdateOutfitTab then TheoryCraft_UpdateOutfitTab() end
end
|
--[[
Notify players of enabled mutators via chat and tab menu
--]]
local vmf = get_mod("VMF")
local _were_enabled_before = false
-- #####################################################################################################################
-- ##### Local functions ###############################################################################################
-- #####################################################################################################################
-- Assembles a list of enabled mutators
local function add_enabled_mutators_titles_to_string(separator, is_short)
local enabled_mutators = {}
for _, mutator in ipairs(vmf.mutators) do
if mutator:is_enabled() then
table.insert(enabled_mutators, mutator)
end
end
return vmf.add_mutator_titles_to_string(enabled_mutators, separator, is_short)
end
-- Sets the lobby name
local function set_lobby_data()
if not Managers.matchmaking or
not Managers.matchmaking.lobby or
not Managers.matchmaking.lobby.set_lobby_data or
not Managers.matchmaking.lobby.get_stored_lobby_data
then
return
end
local name = add_enabled_mutators_titles_to_string(" ", true) -- @TODO: change separator?
local default_name = LobbyAux.get_unique_server_name()
if string.len(name) > 0 then
name = "||" .. name .. "|| " .. default_name
else
name = default_name
end
local lobby_data = Managers.matchmaking.lobby:get_stored_lobby_data()
lobby_data.unique_server_name = name
Managers.matchmaking.lobby:set_lobby_data(lobby_data)
end
local function get_peer_id_from_cookie(client_cookie)
return string.match(client_cookie, "%[(.-)%]")
end
-- #####################################################################################################################
-- ##### Hooks #########################################################################################################
-- #####################################################################################################################
-- Append difficulty name with enabled mutators' titles
vmf:hook_origin(IngamePlayerListUI, "update_difficulty", function(self)
local difficulty_settings = Managers.state.difficulty:get_difficulty_settings()
local difficulty_name = difficulty_settings.display_name
local name = add_enabled_mutators_titles_to_string(", ", true)
local localized_difficulty_name = not self.is_in_inn and Localize(difficulty_name) or ""
if name == "" then -- no mutators
name = localized_difficulty_name
elseif localized_difficulty_name ~= "" then -- it can be "" if player is in the inn with no selected level
name = name .. " (" .. localized_difficulty_name .. ")"
end
self.set_difficulty_name(self, name)
self.current_difficulty_name = difficulty_name
end)
-- Notify everybody about enabled/disabled mutators when Play button is pressed on the map screen
vmf:hook_safe(MatchmakingStateHostGame, "host_game", function()
set_lobby_data()
local names = add_enabled_mutators_titles_to_string(", ")
if names ~= "" then
vmf:chat_broadcast(vmf:localize("broadcast_enabled_mutators") .. ": " .. names)
_were_enabled_before = true
elseif _were_enabled_before then
vmf:chat_broadcast(vmf:localize("broadcast_all_disabled"))
_were_enabled_before = false
end
end)
-- @TODO: can't I do it with hook_safe? Also can't I just use 'sender' intead of extracting peer_id form cookie?
-- Send special messages with enabled mutators list to players just joining the lobby
vmf:hook(MatchmakingManager, "rpc_matchmaking_request_join_lobby", function(func, self, sender, client_cookie, ...)
local name = add_enabled_mutators_titles_to_string(", ")
if name ~= "" then
local message = vmf:localize("whisper_enabled_mutators") .. ": " .. name
vmf:chat_whisper(get_peer_id_from_cookie(client_cookie), message)
end
func(self, sender, client_cookie, ...)
end)
-- #####################################################################################################################
-- ##### Return ########################################################################################################
-- #####################################################################################################################
return set_lobby_data
|
--hookshit
-- self explanatory
local hooknum = 0
function hook.RunOnce(str, func)
hooknum = hooknum + 1
local c = "temporary_hook_" .. hooknum
hook.Add( str, c, function( ... )
func( ... )
hook.Remove(str, c)
end)
end
-- ever have some retarded code that executes once in a while or a print statement but you forget where it's from?
-- use this to find it!
-- note: incredibly resource-intensive, don't be stupid when calling this
function hook.FnSearch( needle, printfn )
for k, v in SortedPairs(hook.GetTable()) do
for w, g in pairs(v) do
local t = debug.getinfo(g)
local last, first, source = t.lastlinedefined, t.linedefined, t.source
local f = file.Open(t.source:sub(2), "r", "GAME")
if not f then continue end
local str = ""
for i = 0, last + 1 do
local st = f:ReadLine()
if i >= first - 1 then
str = str .. i .. " " .. ( st or "" )
end
end
if str:lower():find( needle:lower() ) then
print( source, "lines " .. first .. " - " .. last )
print( "::::" )
if printfn then
print( str )
end
end
end
end
end
-- useful for debugging certain conditions/hooks - don't be stupid with this
function hook.Flush( st )
local h = hook.GetTable()[ st ]
assert( istable( h ), "The hook you have attempted to flush is nil and invalid!" )
for k, v in pairs( h ) do
hook.Remove( st, k )
end
end
|
---@diagnostic disable: undefined-global
local palette = require 'nord-palette'
local base = require 'base'
-- vim-startify
-- > mhinz/vim-startify
local clrs = palette.clrs
local pkg = function()
return {
StartifyFile {fg = clrs.nord11},
StartifyFooter {fg = clrs.nord7},
StartifyHeader {fg = clrs.nord15},
StartifyNumber {fg = clrs.nord13},
StartifyPath {fg = clrs.nord8},
StartifyBracket {base.Delimiter},
StartifySlash {base.Normal},
StartifySpecial {base.Comment},
}
end
return pkg
-- vi:nowrap
|
--[[------------------------------------------------------------------------------------------------------
Edit this
--------------------------------------------------------------------------------------------------------]]
local addon_name = 'CQB Base'
local required_version = 2.1
--[[------------------------------------------------------------------------------------------------------
Do not touch
--------------------------------------------------------------------------------------------------------]]
local text = 'Requires CQB version ' .. required_version .. ' or higher\nYou need to download it from Workshop/Github'
local hookname = '_' .. string.Replace(addon_name, ' ', '_') .. '_CheckDamnBase'
local function _RemoveCheck()
timer.Simple(0, function() hook.Remove('InitPostEntity', hookname) end)
end
local function _CheckDamnBase()
if CQB_VER and CQB_VER >= required_version then
if not CLIENT then
MsgC(Color(50, 255, 50), addon_name, ' base check is fine', '\n')
end
return _RemoveCheck()
end
if CLIENT then
local function workshop()
gui.OpenURL('https://steamcommunity.com/sharedfiles/filedetails/?id=2176251364')
end
local function github()
gui.OpenURL('https://github.com/JFAexe/Gmod-Custom-Quake-Base')
end
Derma_Query(text, addon_name .. ' notify' , 'Workshop', workshop, 'Github', github, 'Close', nil)
else
MsgC(Color(255, 50, 50), addon_name .. ' notify', text, '\n')
end
_RemoveCheck()
end
-- Uncomment to run check
-- hook.Add('InitPostEntity', hookname, _CheckDamnBase)
|
GhostBan = GhostBan or {}
--[[-------------------------------------------------------------------------
DON'T CHANGE CONFIG IN THIS FILE, USE IN-GAME CONFIG MENU
---------------------------------------------------------------------------]]
GhostBan.CanHurt = false -- Ghost can hurt other players / entities ( Amityville is back )
GhostBan.CanSpawnProps = false -- Ghost can spawn props
GhostBan.CanProperty = false -- Ghost can use property, such as 'remove', 'weld' etc...
GhostBan.CanTool = false -- Ghost can use tools ( Builder Ghost )
GhostBan.CanTalkVoice = false -- Ghost can talk with their voice ( spoopy )
GhostBan.CanTalkChat = false -- Ghost can talk with the chat ( when you're behind a screen, nobody knows you're a ghost )
GhostBan.Loadouts = true -- Ghost have their loadouts ( weapons at start )
GhostBan.CanPickupItem = false -- Ghost can pickup items
GhostBan.CanPickupWep = false -- Ghost can pickup weapons ( The GhostFather )
GhostBan.CanEnterVehicle = false -- Ghost can enter vehicles ( Google Car but it's a ghost driving )
GhostBan.CanSuicide = false -- Ghost can suicide ( Ghosts are already dead but don't tell them )
GhostBan.CanCollide = 2 -- Ghost don't collide with players (0), Ghost don't collide with anything (1), Ghost collide with everything (2) ( warning: if not 2, ghost can't be hurt )
GhostBan.DisplayReason = true -- Display text at the bottom of the screen with reason and time left
GhostBan.CanOpenContextMenu = false -- Ghost can open context menu
GhostBan.CanOpenPropsMenu = false -- Ghost can open props menu
GhostBan.CanOpenGameMenu = true -- Ghost can open game menu
GhostBan.DisplayCyanGhost = true -- Display 'GHOST' above the ghost
GhostBan.ReplaceULXBan = false -- ulx ban is replaced with ulx ghostban
GhostBan.CantSeeMe = false -- Ghosts are invisible ( great with CanCollide to 1 )
GhostBan.material = "models/props_combine/portalball001_sheet"
GhostBan.freezeGhost = false -- Ghost is frozen, it can't move - Thanks http://steamcommunity.com/profiles/76561198150594616 for the idea
GhostBan.jailMode = false -- In jail mode, Ghostban is used to jail instead of banning - Thanks http://steamcommunity.com/profiles/76561198022486540 for the idea
GhostBan.canChangeJob = false -- Ghost can change job (DarkRP)
GhostBan.setPos = Vector(0,0,0)
GhostBan.Language = "EN"
--GhostBan.SuperHot = false -- Time move only when ghosts move
GhostBan.percentKick = 0 -- Percent of before kicking ghosts ( in minutes )
GhostBan.Cleanup = false
-- Translations, text can be replaced by {nick}, {steamid}, {steamid64}
-- Special for urban: {reason} which display reason of ban, and {timeleft} which display time left
GhostBan.Translation = {
["EN"] = {
["noreason"] = "no reason specified",
["ghostingS"] = "(GhostBan) {nick} ({steamid}) is a ghost", -- log message
["ghostText"] = "GHOST", -- text displayed above the ghost, no parsing
["mute"] = "You're a ghost, nobody can hear you", -- chat text when a ghost try to talk
["urban1"] = "You're banned for the following reason:", -- hud first line
["urban2"] = "{reason}", -- hud second line
["urban3"] = "Time left: {timeleft}", -- hud third line
["year"] = "years",
["days"] = "days",
["hours"] = "hours",
["minutes"] = "minutes",
["seconds"] = "seconds",
["eternity"] = "eternity",
["ban_usage"] = "Usage: !ban <nick> [time (minutes)] [reason]",
["ghban_usage"] = "Usage: gh_ban <nick> [time (minutes)] [reason]",
["unban_usage"] = "Usage: !unban <nick>",
["ghunban_usage"] = "Usage: gh_unban <nick>",
["404"] = "(GhostBan) 404: Player not found",
["notWhatUThink"] = "This player isn't a ghost",
["TooMuch4U"] = "Too many players, kicking ghost",
["invalidSteamid"] = "Invalid SteamID",
["ghbanid_usage"] = "Usage: gh_banid \"<SteamID>\" [time (minutes)] [reason]",
["unghbanid_usage"] = "Usage: gh_unbanid \"<SteamID>\"",
},
["FR"] = {
["noreason"] = "pas de raison",
["ghostingS"] = "(GhostBan) {nick} ({steamid}) est un fantome", -- log message
["ghostText"] = "FANTOME", -- text displayed above the ghost, no parsing
["mute"] = "Les fantomes ne parlent pas", -- chat text when a ghost try to talk
["urban1"] = "Vous etes bannis pour la raison suivante:", -- hud first line
["urban2"] = "{reason}", -- hud second line
["urban3"] = "Temps restant: {timeleft}", -- hud third line
["year"] = "années",
["days"] = "jours",
["hours"] = "heures",
["minutes"] = "minutes",
["seconds"] = "secondes",
["eternity"] = "l'éternité",
["ban_usage"] = "Usage: !ban <pseudo> [temps (minutes)] [raison]",
["ghban_usage"] = "Usage: gh_ban <pseudo> [temps (minutes)] [raison]",
["unban_usage"] = "Usage: !unban <pseudo>",
["ghunban_usage"] = "Usage: gh_unban <pseudo>",
["404"] = "(GhostBan) 404: Joueur introuvable",
["notWhatUThink"] = "Ce joueur n'est pas un fantome",
["TooMuch4U"] = "Trop de joueurs, kick des fantomes",
["invalidSteamid"] = "SteamID invalide",
["ghbanid_usage"] = "Usage: gh_banid \"<SteamID>\" [temps (minutes)] [raison]",
["unghbanid_usage"] = "Usage: gh_unbanid \"<SteamID>\"",
},
["RU"] = {
["noreason"] = "причина не указана",
["ghostingS"] = "(GhostBan) {nick} ({steamid}) - призрак", -- log message
["ghostText"] = "призрак", -- text displayed above the ghost, no parsing
["mute"] = "Ты призрак, тебя никто не слышит", -- chat text when a ghost try to talk
["urban1"] = "Вы запрещены по следующей причине:", -- hud first line
["urban2"] = "{reason}", -- hud second line
["urban3"] = "Время вышло: {timeleft}", -- hud third line
["year"] = "лет",
["days"] = "дней",
["hours"] = "часов",
["minutes"] = "минут",
["seconds"] = "секунд",
["eternity"] = "вечность",
["ban_usage"] = "заявка: !ban <прозвище> [время (минут)] [причина]",
["ghban_usage"] = "заявка: gh_ban <прозвище> [время (минут)] [причина]",
["unban_usage"] = "заявка: !unban <прозвище>",
["ghunban_usage"] = "заявка: gh_unban <прозвище>",
["404"] = "(GhostBan) 404: Игрок не найден",
["notWhatUThink"] = "Этот игрок не призрак",
["TooMuch4U"] = "Слишком много игроков, kick призраки",
["invalidSteamid"] = "недействительный SteamID",
["ghbanid_usage"] = "заявка: gh_banid \"<SteamID>\" [время (минут)] [причина]",
["unghbanid_usage"] = "заявка: gh_unbanid \"<SteamID>\"",
},
}
|
local mtint = require("mtint")
local _, err = pcall(function()
mtint.interrupt(1)
end)
assert(err:match(mtint.error.unknown_object))
assert(mtint.error.unknown_object == "mtint.error.unknown_object")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.