repo_name stringlengths 6 69 | path stringlengths 6 178 | copies stringclasses 278
values | size stringlengths 4 7 | content stringlengths 671 917k | license stringclasses 15
values |
|---|---|---|---|---|---|
imeteora/cocos2d-x-3.x-Qt | tests/lua-tests/src/AssetsManagerTest/AssetsManagerModule.lua | 17 | 1398 | local AssetManagerModule = {}
function AssetManagerModule.newScene(backfunc)
local winSize = cc.Director:getInstance():getWinSize()
local newScene = cc.Scene:create()
local layer = cc.Layer:create()
local function backToUpdate()
local scene = backfunc()
if scene ~= nil then
cc.Director:getInstance():replaceScene(scene)
end
end
--Create BackMneu
cc.MenuItemFont:setFontName("Arial")
cc.MenuItemFont:setFontSize(24)
local backMenuItem = cc.MenuItemFont:create("Back")
backMenuItem:setPosition(cc.p(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25))
backMenuItem:registerScriptTapHandler(backToUpdate)
local backMenu = cc.Menu:create()
backMenu:setPosition(0, 0)
backMenu:addChild(backMenuItem)
layer:addChild(backMenu,6)
local helloLabel = cc.Label:createWithTTF("Hello World", s_arialPath, 38)
helloLabel:setAnchorPoint(cc.p(0.5, 0.5))
helloLabel:setPosition(cc.p(winSize.width / 2, winSize.height - 40))
layer:addChild(helloLabel, 5)
local sprite = cc.Sprite:create("Images/background.png")
sprite:setAnchorPoint(cc.p(0.5, 0.5))
sprite:setPosition(cc.p(winSize.width / 2, winSize.height / 2))
layer:addChild(sprite, 0)
newScene:addChild(layer)
cc.Director:getInstance():replaceScene(newScene)
end
return AssetManagerModule
| gpl-2.0 |
CarabusX/Zero-K | units/shipassault.lua | 3 | 6022 | return { shipassault = {
unitname = [[shipassault]],
name = [[Siren]],
description = [[Riot/Assault Destroyer (Anti-Sub)]],
acceleration = 0.46,
activateWhenBuilt = true,
brakeRate = 0.6,
buildCostMetal = 600,
builder = false,
buildPic = [[shipassault.png]],
canGuard = true,
canMove = true,
canPatrol = true,
category = [[SHIP]],
collisionVolumeOffsets = [[0 6 0]],
collisionVolumeScales = [[55 55 110]],
collisionVolumeType = [[ellipsoid]],
corpse = [[DEAD]],
--Core_color.dds Core_other.dds
customParams = {
bait_level_default = 0,
modelradius = [[55]],
turnatfullspeed = [[1]],
extradrawrange = 800,
},
explodeAs = [[BIG_UNITEX]],
floater = true,
footprintX = 4,
footprintZ = 4,
iconType = [[shipassault]],
idleAutoHeal = 5,
idleTime = 1800,
losEmitHeight = 25,
maxDamage = 5200,
maxVelocity = 2.0,
minWaterDepth = 5,
movementClass = [[BOAT4]],
noAutoFire = false,
noChaseCategory = [[TERRAFORM FIXEDWING SATELLITE SUB SINK TURRET]],
objectName = [[shipassault.s3o]],
script = [[shipassault.lua]],
selfDestructAs = [[BIG_UNITEX]],
sfxtypes = {
explosiongenerators = {
[[custom:sonicfire_80]],
[[custom:emg_shells_l]],
},
},
sightDistance = 440,
sonarDistance = 440,
turninplace = 0,
turnRate = 384,
workerTime = 0,
weapons = {
{
def = [[SONIC]],
badTargetCategory = [[FIXEDWING]],
onlyTargetCategory = [[FIXEDWING LAND SINK TURRET SHIP SWIM FLOAT GUNSHIP HOVER]],
mainDir = [[0 -1 0]],
maxAngleDif = 240,
},
{
def = [[MISSILE]],
badTargetCategory = [[SWIM LAND SHIP HOVER]],
onlyTargetCategory = [[SWIM LAND SINK TURRET FLOAT SHIP HOVER]],
},
},
weaponDefs = {
SONIC = {
name = [[Sonic Blaster]],
areaOfEffect = 190,
avoidFeature = true,
avoidFriendly = true,
burnblow = true,
craterBoost = 0,
craterMult = 0,
customParams = {
force_ignore_ground = [[1]],
slot = [[5]],
muzzleEffectFire = [[custom:HEAVY_CANNON_MUZZLE]],
miscEffectFire = [[custom:RIOT_SHELL_L]],
lups_explodelife = 1.5,
lups_explodespeed = 0.8,
light_radius = 240,
},
damage = {
default = 280.01,
},
cegTag = [[sonictrail]],
cylinderTargeting = 5.0,
explosionGenerator = [[custom:sonic_80]],
edgeEffectiveness = 0.5,
fireStarter = 150,
impulseBoost = 300,
impulseFactor = 0.5,
interceptedByShieldType = 1,
myGravity = 0.01,
noSelfDamage = true,
range = 270,
reloadtime = 1.7,
size = 64,
sizeDecay = 0.2,
soundStart = [[weapon/sonicgun2]],
soundHit = [[weapon/sonicgun_hit]],
soundStartVolume = 6,
soundHitVolume = 10,
stages = 1,
texture1 = [[sonic_glow2]],
texture2 = [[null]],
texture3 = [[null]],
rgbColor = {0.2, 0.6, 0.8},
turret = true,
weaponType = [[Cannon]],
weaponVelocity = 700,
waterweapon = true,
duration = 0.15,
},
MISSILE = {
name = [[Destroyer Missiles]],
areaOfEffect = 48,
cegTag = [[missiletrailyellow]],
collideFriendly = false,
craterBoost = 1,
craterMult = 2,
customParams = {
combatRange = 265,
},
damage = {
default = 400.01,
},
edgeEffectiveness = 0.5,
fireStarter = 100,
fixedLauncher = true,
flightTime = 4,
impulseBoost = 0,
impulseFactor = 0.4,
interceptedByShieldType = 2,
model = [[wep_m_hailstorm.s3o]],
noSelfDamage = true,
range = 800,
reloadtime = 16,
smokeTrail = true,
soundHit = [[weapon/missile/missile_fire12]],
soundStart = [[weapon/missile/missile_fire10]],
startVelocity = 100,
tolerance = 4000,
turnrate = 30000,
turret = true,
--waterWeapon = true,
weaponAcceleration = 300,
weaponTimer = 1,
weaponType = [[StarburstLauncher]],
weaponVelocity = 1800,
},
},
featureDefs = {
DEAD = {
blocking = false,
featureDead = [[HEAP]],
footprintX = 4,
footprintZ = 4,
object = [[shipassault_dead.s3o]],
},
HEAP = {
blocking = false,
footprintX = 4,
footprintZ = 4,
object = [[debris4x4a.s3o]],
},
},
} }
| gpl-2.0 |
rafael/kong | kong/tools/responses.lua | 7 | 3860 | --- Kong helper methods to send HTTP responses to clients.
-- Can be used in the proxy, plugins or admin API.
-- Most used status codes and responses are implemented as helper methods.
--
-- @author thibaultcha
-- Define the most used HTTP status codes through Kong
local _M = {
status_codes = {
HTTP_OK = 200,
HTTP_CREATED = 201,
HTTP_NO_CONTENT = 204,
HTTP_BAD_REQUEST = 400,
HTTP_UNAUTHORIZED = 401,
HTTP_FORBIDDEN = 403,
HTTP_NOT_FOUND = 404,
HTTP_METHOD_NOT_ALLOWED = 405,
HTTP_CONFLICT = 409,
HTTP_UNSUPPORTED_MEDIA_TYPE = 415,
HTTP_INTERNAL_SERVER_ERROR = 500
}
}
-- Define some rules that will ALWAYS be applied to some status codes.
-- Ex: 204 must not have content, but if 404 has no content then "Not found" will be set.
local response_default_content = {
[_M.status_codes.HTTP_UNAUTHORIZED] = function(content)
return content or "Unauthorized"
end,
[_M.status_codes.HTTP_NO_CONTENT] = function(content)
return nil
end,
[_M.status_codes.HTTP_NOT_FOUND] = function(content)
return content or "Not found"
end,
[_M.status_codes.HTTP_INTERNAL_SERVER_ERROR] = function(content)
return "An unexpected error occurred"
end,
[_M.status_codes.HTTP_METHOD_NOT_ALLOWED] = function(content)
return "Method not allowed"
end
}
-- Return a closure which will be usable to respond with a certain status code.
-- @param `status_code` The status for which to define a function
--
-- Send a JSON response for the closure's status code with the given content.
-- If the content happens to be an error (>500), it will be logged by ngx.log as an ERR.
-- @see http://wiki.nginx.org/HttpLuaModule
-- @param `content` (Optional) The content to send as a response.
-- @param `raw` (Optional) A boolean defining if the `content` should not be serialized to JSON
-- This useed to send text as JSON in some edge-cases of cjson.
-- @return `ngx.exit()`
local function send_response(status_code)
local constants = require "kong.constants"
local cjson = require "cjson"
return function(content, raw, headers)
if status_code >= _M.status_codes.HTTP_INTERNAL_SERVER_ERROR then
if content then
ngx.log(ngx.ERR, tostring(content))
end
ngx.ctx.stop_phases = true -- interrupt other phases of this request
end
ngx.status = status_code
ngx.header["Content-Type"] = "application/json; charset=utf-8"
ngx.header["Server"] = constants.NAME.."/"..constants.VERSION
if headers then
for k, v in pairs(headers) do
ngx.header[k] = v
end
end
if type(response_default_content[status_code]) == "function" then
content = response_default_content[status_code](content)
end
if raw then
-- When we want to send an empty array, such as "{\"data\":[]}"
-- cjson has a flaw and encodes a Lua `{}` as a JSON `{}`.
-- This allows to send plain string JSON as "[]".
ngx.say(content)
elseif (type(content) == "table") then
ngx.say(cjson.encode(content))
elseif content then
ngx.say(cjson.encode({ message = content }))
end
return ngx.exit(status_code)
end
end
-- Generate sugar methods (closures) for the most used HTTP status codes.
for status_code_name, status_code in pairs(_M.status_codes) do
_M["send_"..status_code_name] = send_response(status_code)
end
local closure_cache = {}
-- Sends any status code as a response. This is useful for plugins which want to
-- send a response when the status code is not defined in `_M.status_codes` and thus
-- has no sugar method on `_M`.
function _M.send(status_code, content, raw, headers)
local res = closure_cache[status_code]
if not res then
res = send_response(status_code)
closure_cache[status_code] = res
end
return res(content, raw, headers)
end
return _M
| apache-2.0 |
jenisteam/AghayeKhas | plugins/wen.lua | 1 | 28564 | function string:split(sep)
local sep, fields = sep or ":", {}
local pattern = string.format("([^%s]+)", sep)
self:gsub(pattern, function(c) fields[#fields+1] = c end)
return fields
end
local function run(msg, matches)
if #matches < 2 then
return "•• بعد از این دستور، با قید یک فاصله کلمه یا کلمه ی مورد نظر را جهت زیبا نویسی وارد کنید 💠"
end
if string.len(matches[2]) > 30 then
tdcli.sendMessage(msg.chat_id_, 0, 1, "حداکثر حروف مجاز 30 کاراکتر انگلیسی و عدد است 💠", 1, 'html')
end
local font_base = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,9,8,7,6,5,4,3,2,1,.,_"
local font_hash = "z,y,x,w,v,u,t,s,r,q,p,o,n,m,l,k,j,i,h,g,f,e,d,c,b,a,Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C,B,A,0,1,2,3,4,5,6,7,8,9,.,_"
local fonts = {
"ⓐ,ⓑ,ⓒ,ⓓ,ⓔ,ⓕ,ⓖ,ⓗ,ⓘ,ⓙ,ⓚ,ⓛ,ⓜ,ⓝ,ⓞ,ⓟ,ⓠ,ⓡ,ⓢ,ⓣ,ⓤ,ⓥ,ⓦ,ⓧ,ⓨ,ⓩ,ⓐ,ⓑ,ⓒ,ⓓ,ⓔ,ⓕ,ⓖ,ⓗ,ⓘ,ⓙ,ⓚ,ⓛ,ⓜ,ⓝ,ⓞ,ⓟ,ⓠ,ⓡ,ⓢ,ⓣ,ⓤ,ⓥ,ⓦ,ⓧ,ⓨ,ⓩ,⓪,➈,➇,➆,➅,➄,➃,➂,➁,➀,●,_",
"⒜,⒝,⒞,⒟,⒠,⒡,⒢,⒣,⒤,⒥,⒦,⒧,⒨,⒩,⒪,⒫,⒬,⒭,⒮,⒯,⒰,⒱,⒲,⒳,⒴,⒵,⒜,⒝,⒞,⒟,⒠,⒡,⒢,⒣,⒤,⒥,⒦,⒧,⒨,⒩,⒪,⒫,⒬,⒭,⒮,⒯,⒰,⒱,⒲,⒳,⒴,⒵,⓪,⑼,⑻,⑺,⑹,⑸,⑷,⑶,⑵,⑴,.,_",
"α,в,c,∂,є,ƒ,g,н,ι,נ,к,ℓ,м,η,σ,ρ,q,я,ѕ,т,υ,ν,ω,χ,у,z,α,в,c,∂,є,ƒ,g,н,ι,נ,к,ℓ,м,η,σ,ρ,q,я,ѕ,т,υ,ν,ω,χ,у,z,0,9,8,7,6,5,4,3,2,1,.,_",
"α,в,c,d,e,ғ,ɢ,н,ι,j,ĸ,l,м,ɴ,o,p,q,r,ѕ,т,υ,v,w,х,y,z,α,в,c,d,e,ғ,ɢ,н,ι,j,ĸ,l,м,ɴ,o,p,q,r,ѕ,т,υ,v,w,х,y,z,0,9,8,7,6,5,4,3,2,1,.,_",
"α,в,¢,đ,e,f,g,ħ,ı,נ,κ,ł,м,и,ø,ρ,q,я,š,т,υ,ν,ω,χ,ч,z,α,в,¢,đ,e,f,g,ħ,ı,נ,κ,ł,м,и,ø,ρ,q,я,š,т,υ,ν,ω,χ,ч,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ą,ҍ,ç,ժ,ҽ,ƒ,ց,հ,ì,ʝ,ҟ,Ӏ,ʍ,ղ,օ,ք,զ,ɾ,ʂ,է,մ,ѵ,ա,×,վ,Հ,ą,ҍ,ç,ժ,ҽ,ƒ,ց,հ,ì,ʝ,ҟ,Ӏ,ʍ,ղ,օ,ք,զ,ɾ,ʂ,է,մ,ѵ,ա,×,վ,Հ,⊘,९,𝟠,7,Ϭ,Ƽ,५,Ӡ,ϩ,𝟙,.,_", "ค,ც,८,ძ,૯,Բ,૭,Һ,ɿ,ʆ,қ,Ն,ɱ,Ո,૦,ƿ,ҩ,Ր,ς,੮,υ,౮,ω,૪,ע,ઽ,ค,ც,८,ძ,૯,Բ,૭,Һ,ɿ,ʆ,қ,Ն,ɱ,Ո,૦,ƿ,ҩ,Ր,ς,੮,υ,౮,ω,૪,ע,ઽ,0,9,8,7,6,5,4,3,2,1,.,_",
"α,ß,ς,d,ε,ƒ,g,h,ï,յ,κ,レ,m,η,⊕,p,Ω,r,š,†,u,∀,ω,x,ψ,z,α,ß,ς,d,ε,ƒ,g,h,ï,յ,κ,レ,m,η,⊕,p,Ω,r,š,†,u,∀,ω,x,ψ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ค,๒,ς,๔,є,Ŧ,ɠ,ђ,เ,ן,к,l,๓,ภ,๏,թ,ợ,г,ร,t,ย,v,ฬ,x,ץ,z,ค,๒,ς,๔,є,Ŧ,ɠ,ђ,เ,ן,к,l,๓,ภ,๏,թ,ợ,г,ร,t,ย,v,ฬ,x,ץ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ム,乃,ζ,Ð,乇,キ,Ǥ,ん,ノ,フ,ズ,レ,ᄊ,刀,Ծ,ア,Q,尺,ㄎ,イ,Ц,Џ,Щ,メ,リ,乙,ム,乃,ζ,Ð,乇,キ,Ǥ,ん,ノ,フ,ズ,レ,ᄊ,刀,Ծ,ア,q,尺,ㄎ,イ,Ц,Џ,Щ,メ,リ,乙,ᅙ,9,8,ᆨ,6,5,4,3,ᆯ,1,.,_",
"α,β,c,δ,ε,Ŧ,ĝ,h,ι,j,κ,l,ʍ,π,ø,ρ,φ,Ʀ,$,†,u,υ,ω,χ,ψ,z,α,β,c,δ,ε,Ŧ,ĝ,h,ι,j,κ,l,ʍ,π,ø,ρ,φ,Ʀ,$,†,u,υ,ω,χ,ψ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ձ,ъ,ƈ,ժ,ε,բ,ց,հ,ﻨ,յ,ĸ,l,ო,ռ,օ,թ,զ,г,ร,է,ս,ν,ա,×,ყ,২,ձ,ъ,ƈ,ժ,ε,բ,ց,հ,ﻨ,յ,ĸ,l,ო,ռ,օ,թ,զ,г,ร,է,ս,ν,ա,×,ყ,২,0,9,8,7,6,5,4,3,2,1,.,_",
"Λ,ɓ,¢,Ɗ,£,ƒ,ɢ,ɦ,ĩ,ʝ,Қ,Ł,ɱ,ה,ø,Ṗ,Ҩ,Ŕ,Ş,Ŧ,Ū,Ɣ,ω,Ж,¥,Ẑ,Λ,ɓ,¢,Ɗ,£,ƒ,ɢ,ɦ,ĩ,ʝ,Қ,Ł,ɱ,ה,ø,Ṗ,Ҩ,Ŕ,Ş,Ŧ,Ū,Ɣ,ω,Ж,¥,Ẑ,0,9,8,7,6,5,4,3,2,1,.,_",
"Λ,Б,Ͼ,Ð,Ξ,Ŧ,G,H,ł,J,К,Ł,M,Л,Ф,P,Ǫ,Я,S,T,U,V,Ш,Ж,Џ,Z,Λ,Б,Ͼ,Ð,Ξ,Ŧ,g,h,ł,j,К,Ł,m,Л,Ф,p,Ǫ,Я,s,t,u,v,Ш,Ж,Џ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ɐ,q,ɔ,p,ǝ,ɟ,ɓ,ɥ,ı,ſ,ʞ,ๅ,ɯ,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,ɐ,q,ɔ,p,ǝ,ɟ,ɓ,ɥ,ı,ſ,ʞ,ๅ,ɯ,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ɒ,d,ɔ,b,ɘ,ʇ,ϱ,н,i,į,ʞ,l,м,и,o,q,p,я,ƨ,т,υ,v,w,x,γ,z,ɒ,d,ɔ,b,ɘ,ʇ,ϱ,н,i,į,ʞ,l,м,и,o,q,p,я,ƨ,т,υ,v,w,x,γ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"A̴,̴B̴,̴C̴,̴D̴,̴E̴,̴F̴,̴G̴,̴H̴,̴I̴,̴J̴,̴K̴,̴L̴,̴M̴,̴N̴,̴O̴,̴P̴,̴Q̴,̴R̴,̴S̴,̴T̴,̴U̴,̴V̴,̴W̴,̴X̴,̴Y̴,̴Z̴,̴a̴,̴b̴,̴c̴,̴d̴,̴e̴,̴f̴,̴g̴,̴h̴,̴i̴,̴j̴,̴k̴,̴l̴,̴m̴,̴n̴,̴o̴,̴p̴,̴q̴,̴r̴,̴s̴,̴t̴,̴u̴,̴v̴,̴w̴,̴x̴,̴y̴,̴z̴,̴0̴,̴9̴,̴8̴,̴7̴,̴6̴,̴5̴,̴4̴,̴3̴,̴2̴,̴1̴,̴.̴,̴_̴",
"ⓐ,ⓑ,ⓒ,ⓓ,ⓔ,ⓕ,ⓖ,ⓗ,ⓘ,ⓙ,ⓚ,ⓛ,ⓜ,ⓝ,ⓞ,ⓟ,ⓠ,ⓡ,ⓢ,ⓣ,ⓤ,ⓥ,ⓦ,ⓧ,ⓨ,ⓩ,ⓐ,ⓑ,ⓒ,ⓓ,ⓔ,ⓕ,ⓖ,ⓗ,ⓘ,ⓙ,ⓚ,ⓛ,ⓜ,ⓝ,ⓞ,ⓟ,ⓠ,ⓡ,ⓢ,ⓣ,ⓤ,ⓥ,ⓦ,ⓧ,ⓨ,ⓩ,⓪,➈,➇,➆,➅,➄,➃,➂,➁,➀,●,_",
"⒜,⒝,⒞,⒟,⒠,⒡,⒢,⒣,⒤,⒥,⒦,⒧,⒨,⒩,⒪,⒫,⒬,⒭,⒮,⒯,⒰,⒱,⒲,⒳,⒴,⒵,⒜,⒝,⒞,⒟,⒠,⒡,⒢,⒣,⒤,⒥,⒦,⒧,⒨,⒩,⒪,⒫,⒬,⒭,⒮,⒯,⒰,⒱,⒲,⒳,⒴,⒵,⓪,⑼,⑻,⑺,⑹,⑸,⑷,⑶,⑵,⑴,.,_",
"α,в,c,∂,є,ƒ,g,н,ι,נ,к,ℓ,м,η,σ,ρ,q,я,ѕ,т,υ,ν,ω,χ,у,z,α,в,c,∂,є,ƒ,g,н,ι,נ,к,ℓ,м,η,σ,ρ,q,я,ѕ,т,υ,ν,ω,χ,у,z,0,9,8,7,6,5,4,3,2,1,.,_",
"α,в,c,ɗ,є,f,g,н,ι,נ,к,Ɩ,м,η,σ,ρ,q,я,ѕ,т,υ,ν,ω,x,у,z,α,в,c,ɗ,є,f,g,н,ι,נ,к,Ɩ,м,η,σ,ρ,q,я,ѕ,т,υ,ν,ω,x,у,z,0,9,8,7,6,5,4,3,2,1,.,_",
"α,в,c,d,e,ғ,ɢ,н,ι,j,ĸ,l,м,ɴ,o,p,q,r,ѕ,т,υ,v,w,х,y,z,α,в,c,d,e,ғ,ɢ,н,ι,j,ĸ,l,м,ɴ,o,p,q,r,ѕ,т,υ,v,w,х,y,z,0,9,8,7,6,5,4,3,2,1,.,_",
"α,Ⴆ,ƈ,ԃ,ҽ,ϝ,ɠ,ԋ,ι,ʝ,ƙ,ʅ,ɱ,ɳ,σ,ρ,ϙ,ɾ,ʂ,ƚ,υ,ʋ,ɯ,x,ყ,ȥ,α,Ⴆ,ƈ,ԃ,ҽ,ϝ,ɠ,ԋ,ι,ʝ,ƙ,ʅ,ɱ,ɳ,σ,ρ,ϙ,ɾ,ʂ,ƚ,υ,ʋ,ɯ,x,ყ,ȥ,0,9,8,7,6,5,4,3,2,1,.,_",
"α,в,¢,đ,e,f,g,ħ,ı,נ,κ,ł,м,и,ø,ρ,q,я,š,т,υ,ν,ω,χ,ч,z,α,в,¢,đ,e,f,g,ħ,ı,נ,κ,ł,м,и,ø,ρ,q,я,š,т,υ,ν,ω,χ,ч,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ą,ɓ,ƈ,đ,ε,∱,ɠ,ɧ,ï,ʆ,ҡ,ℓ,ɱ,ŋ,σ,þ,ҩ,ŗ,ş,ŧ,ų,√,щ,х,γ,ẕ,ą,ɓ,ƈ,đ,ε,∱,ɠ,ɧ,ï,ʆ,ҡ,ℓ,ɱ,ŋ,σ,þ,ҩ,ŗ,ş,ŧ,ų,√,щ,х,γ,ẕ,0,9,8,7,6,5,4,3,2,1,.,_",
"ą,ҍ,ç,ժ,ҽ,ƒ,ց,հ,ì,ʝ,ҟ,Ӏ,ʍ,ղ,օ,ք,զ,ɾ,ʂ,է,մ,ѵ,ա,×,վ,Հ,ą,ҍ,ç,ժ,ҽ,ƒ,ց,հ,ì,ʝ,ҟ,Ӏ,ʍ,ղ,օ,ք,զ,ɾ,ʂ,է,մ,ѵ,ա,×,վ,Հ,⊘,९,𝟠,7,Ϭ,Ƽ,५,Ӡ,ϩ,𝟙,.,_",
"მ,ჩ,ƈ,ძ,ε,բ,ց,հ,ἶ,ʝ,ƙ,l,ო,ղ,օ,ր,գ,ɾ,ʂ,է,մ,ν,ω,ჯ,ყ,z,მ,ჩ,ƈ,ძ,ε,բ,ց,հ,ἶ,ʝ,ƙ,l,ო,ղ,օ,ր,գ,ɾ,ʂ,է,մ,ν,ω,ჯ,ყ,z,0,Գ,Ց,Դ,6,5,Վ,Յ,Զ,1,.,_",
"ค,ც,८,ძ,૯,Բ,૭,Һ,ɿ,ʆ,қ,Ն,ɱ,Ո,૦,ƿ,ҩ,Ր,ς,੮,υ,౮,ω,૪,ע,ઽ,ค,ც,८,ძ,૯,Բ,૭,Һ,ɿ,ʆ,қ,Ն,ɱ,Ո,૦,ƿ,ҩ,Ր,ς,੮,υ,౮,ω,૪,ע,ઽ,0,9,8,7,6,5,4,3,2,1,.,_",
"α,ß,ς,d,ε,ƒ,g,h,ï,յ,κ,レ,m,η,⊕,p,Ω,r,š,†,u,∀,ω,x,ψ,z,α,ß,ς,d,ε,ƒ,g,h,ï,յ,κ,レ,m,η,⊕,p,Ω,r,š,†,u,∀,ω,x,ψ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ª,b,¢,Þ,È,F,૬,ɧ,Î,j,Κ,Ļ,м,η,◊,Ƿ,ƍ,r,S,⊥,µ,√,w,×,ý,z,ª,b,¢,Þ,È,F,૬,ɧ,Î,j,Κ,Ļ,м,η,◊,Ƿ,ƍ,r,S,⊥,µ,√,w,×,ý,z,0,9,8,7,6,5,4,3,2,1,.,_",
"Δ,Ɓ,C,D,Σ,F,G,H,I,J,Ƙ,L,Μ,∏,Θ,Ƥ,Ⴓ,Γ,Ѕ,Ƭ,Ʊ,Ʋ,Ш,Ж,Ψ,Z,λ,ϐ,ς,d,ε,ғ,ɢ,н,ι,ϳ,κ,l,ϻ,π,σ,ρ,φ,г,s,τ,υ,v,ш,ϰ,ψ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ค,๒,ς,๔,є,Ŧ,ɠ,ђ,เ,ן,к,l,๓,ภ,๏,թ,ợ,г,ร,t,ย,v,ฬ,x,ץ,z,ค,๒,ς,๔,є,Ŧ,ɠ,ђ,เ,ן,к,l,๓,ภ,๏,թ,ợ,г,ร,t,ย,v,ฬ,x,ץ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"Λ,ß,Ƈ,D,Ɛ,F,Ɠ,Ĥ,Ī,Ĵ,Ҡ,Ŀ,M,И,♡,Ṗ,Ҩ,Ŕ,S,Ƭ,Ʊ,Ѵ,Ѡ,Ӿ,Y,Z,Λ,ß,Ƈ,D,Ɛ,F,Ɠ,Ĥ,Ī,Ĵ,Ҡ,Ŀ,M,И,♡,Ṗ,Ҩ,Ŕ,S,Ƭ,Ʊ,Ѵ,Ѡ,Ӿ,Y,Z,0,9,8,7,6,5,4,3,2,1,.,_",
"ム,乃,ζ,Ð,乇,キ,Ǥ,ん,ノ,フ,ズ,レ,ᄊ,刀,Ծ,ア,Q,尺,ㄎ,イ,Ц,Џ,Щ,メ,リ,乙,ム,乃,ζ,Ð,乇,キ,Ǥ,ん,ノ,フ,ズ,レ,ᄊ,刀,Ծ,ア,q,尺,ㄎ,イ,Ц,Џ,Щ,メ,リ,乙,ᅙ,9,8,ᆨ,6,5,4,3,ᆯ,1,.,_",
"α,β,c,δ,ε,Ŧ,ĝ,h,ι,j,κ,l,ʍ,π,ø,ρ,φ,Ʀ,$,†,u,υ,ω,χ,ψ,z,α,β,c,δ,ε,Ŧ,ĝ,h,ι,j,κ,l,ʍ,π,ø,ρ,φ,Ʀ,$,†,u,υ,ω,χ,ψ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ค,๖,¢,໓,ē,f,ງ,h,i,ว,k,l,๓,ຖ,໐,p,๑,r,Ş,t,น,ง,ຟ,x,ฯ,ຊ,ค,๖,¢,໓,ē,f,ງ,h,i,ว,k,l,๓,ຖ,໐,p,๑,r,Ş,t,น,ง,ຟ,x,ฯ,ຊ,0,9,8,7,6,5,4,3,2,1,.,_",
"ձ,ъ,ƈ,ժ,ε,բ,ց,հ,ﻨ,յ,ĸ,l,ო,ռ,օ,թ,զ,г,ร,է,ս,ν,ա,×,ყ,২,ձ,ъ,ƈ,ժ,ε,բ,ց,հ,ﻨ,յ,ĸ,l,ო,ռ,օ,թ,զ,г,ร,է,ս,ν,ա,×,ყ,২,0,9,8,7,6,5,4,3,2,1,.,_",
"Â,ß,Ĉ,Ð,Є,Ŧ,Ǥ,Ħ,Ī,ʖ,Қ,Ŀ,♏,И,Ø,P,Ҩ,R,$,ƚ,Ц,V,Щ,X,¥,Ẕ,Â,ß,Ĉ,Ð,Є,Ŧ,Ǥ,Ħ,Ī,ʖ,Қ,Ŀ,♏,И,Ø,P,Ҩ,R,$,ƚ,Ц,V,Щ,X,¥,Ẕ,0,9,8,7,6,5,4,3,2,1,.,_",
"Λ,ɓ,¢,Ɗ,£,ƒ,ɢ,ɦ,ĩ,ʝ,Қ,Ł,ɱ,ה,ø,Ṗ,Ҩ,Ŕ,Ş,Ŧ,Ū,Ɣ,ω,Ж,¥,Ẑ,Λ,ɓ,¢,Ɗ,£,ƒ,ɢ,ɦ,ĩ,ʝ,Қ,Ł,ɱ,ה,ø,Ṗ,Ҩ,Ŕ,Ş,Ŧ,Ū,Ɣ,ω,Ж,¥,Ẑ,0,9,8,7,6,5,4,3,2,1,.,_",
"Λ,Б,Ͼ,Ð,Ξ,Ŧ,G,H,ł,J,К,Ł,M,Л,Ф,P,Ǫ,Я,S,T,U,V,Ш,Ж,Џ,Z,Λ,Б,Ͼ,Ð,Ξ,Ŧ,g,h,ł,j,К,Ł,m,Л,Ф,p,Ǫ,Я,s,t,u,v,Ш,Ж,Џ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"Թ,Յ,Շ,Ժ,ȝ,Բ,Գ,ɧ,ɿ,ʝ,ƙ,ʅ,ʍ,Ռ,Ծ,ρ,φ,Ր,Տ,Ե,Մ,ע,ա,Ճ,Վ,Հ,Թ,Յ,Շ,Ժ,ȝ,Բ,Գ,ɧ,ɿ,ʝ,ƙ,ʅ,ʍ,Ռ,Ծ,ρ,φ,Ր,Տ,Ե,Մ,ע,ա,Ճ,Վ,Հ,0,9,8,7,6,5,4,3,2,1,.,_",
"Æ,þ,©,Ð,E,F,ζ,Ħ,Ї,¿,ズ,ᄂ,M,Ñ,Θ,Ƿ,Ø,Ґ,Š,τ,υ,¥,w,χ,y,շ,Æ,þ,©,Ð,E,F,ζ,Ħ,Ї,¿,ズ,ᄂ,M,Ñ,Θ,Ƿ,Ø,Ґ,Š,τ,υ,¥,w,χ,y,շ,0,9,8,7,6,5,4,3,2,1,.,_",
"ɐ,q,ɔ,p,ǝ,ɟ,ɓ,ɥ,ı,ſ,ʞ,ๅ,ɯ,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,ɐ,q,ɔ,p,ǝ,ɟ,ɓ,ɥ,ı,ſ,ʞ,ๅ,ɯ,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ɒ,d,ɔ,b,ɘ,ʇ,ϱ,н,i,į,ʞ,l,м,и,o,q,p,я,ƨ,т,υ,v,w,x,γ,z,ɒ,d,ɔ,b,ɘ,ʇ,ϱ,н,i,į,ʞ,l,м,и,o,q,p,я,ƨ,т,υ,v,w,x,γ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"4,8,C,D,3,F,9,H,!,J,K,1,M,N,0,P,Q,R,5,7,U,V,W,X,Y,2,4,8,C,D,3,F,9,H,!,J,K,1,M,N,0,P,Q,R,5,7,U,V,W,X,Y,2,0,9,8,7,6,5,4,3,2,1,.,_",
"Λ,M,X,ʎ,Z,ɐ,q,ɔ,p,ǝ,ɟ,ƃ,ɥ,ı,ɾ,ʞ,l,ա,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,Λ,M,X,ʎ,Z,ɐ,q,ɔ,p,ǝ,ɟ,ƃ,ɥ,ı,ɾ,ʞ,l,ա,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,0,9,8,7,6,5,4,3,2,1,.,‾",
"A̴,̴B̴,̴C̴,̴D̴,̴E̴,̴F̴,̴G̴,̴H̴,̴I̴,̴J̴,̴K̴,̴L̴,̴M̴,̴N̴,̴O̴,̴P̴,̴Q̴,̴R̴,̴S̴,̴T̴,̴U̴,̴V̴,̴W̴,̴X̴,̴Y̴,̴Z̴,̴a̴,̴b̴,̴c̴,̴d̴,̴e̴,̴f̴,̴g̴,̴h̴,̴i̴,̴j̴,̴k̴,̴l̴,̴m̴,̴n̴,̴o̴,̴p̴,̴q̴,̴r̴,̴s̴,̴t̴,̴u̴,̴v̴,̴w̴,̴x̴,̴y̴,̴z̴,̴0̴,̴9̴,̴8̴,̴7̴,̴6̴,̴5̴,̴4̴,̴3̴,̴2̴,̴1̴,̴.̴,̴_̴",
"A̱,̱Ḇ,̱C̱,̱Ḏ,̱E̱,̱F̱,̱G̱,̱H̱,̱I̱,̱J̱,̱Ḵ,̱Ḻ,̱M̱,̱Ṉ,̱O̱,̱P̱,̱Q̱,̱Ṟ,̱S̱,̱Ṯ,̱U̱,̱V̱,̱W̱,̱X̱,̱Y̱,̱Ẕ,̱a̱,̱ḇ,̱c̱,̱ḏ,̱e̱,̱f̱,̱g̱,̱ẖ,̱i̱,̱j̱,̱ḵ,̱ḻ,̱m̱,̱ṉ,̱o̱,̱p̱,̱q̱,̱ṟ,̱s̱,̱ṯ,̱u̱,̱v̱,̱w̱,̱x̱,̱y̱,̱ẕ,̱0̱,̱9̱,̱8̱,̱7̱,̱6̱,̱5̱,̱4̱,̱3̱,̱2̱,̱1̱,̱.̱,̱_̱",
"A̲,̲B̲,̲C̲,̲D̲,̲E̲,̲F̲,̲G̲,̲H̲,̲I̲,̲J̲,̲K̲,̲L̲,̲M̲,̲N̲,̲O̲,̲P̲,̲Q̲,̲R̲,̲S̲,̲T̲,̲U̲,̲V̲,̲W̲,̲X̲,̲Y̲,̲Z̲,̲a̲,̲b̲,̲c̲,̲d̲,̲e̲,̲f̲,̲g̲,̲h̲,̲i̲,̲j̲,̲k̲,̲l̲,̲m̲,̲n̲,̲o̲,̲p̲,̲q̲,̲r̲,̲s̲,̲t̲,̲u̲,̲v̲,̲w̲,̲x̲,̲y̲,̲z̲,̲0̲,̲9̲,̲8̲,̲7̲,̲6̲,̲5̲,̲4̲,̲3̲,̲2̲,̲1̲,̲.̲,̲_̲",
"Ā,̄B̄,̄C̄,̄D̄,̄Ē,̄F̄,̄Ḡ,̄H̄,̄Ī,̄J̄,̄K̄,̄L̄,̄M̄,̄N̄,̄Ō,̄P̄,̄Q̄,̄R̄,̄S̄,̄T̄,̄Ū,̄V̄,̄W̄,̄X̄,̄Ȳ,̄Z̄,̄ā,̄b̄,̄c̄,̄d̄,̄ē,̄f̄,̄ḡ,̄h̄,̄ī,̄j̄,̄k̄,̄l̄,̄m̄,̄n̄,̄ō,̄p̄,̄q̄,̄r̄,̄s̄,̄t̄,̄ū,̄v̄,̄w̄,̄x̄,̄ȳ,̄z̄,̄0̄,̄9̄,̄8̄,̄7̄,̄6̄,̄5̄,̄4̄,̄3̄,̄2̄,̄1̄,̄.̄,̄_̄",
"A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,9,8,7,6,5,4,3,2,1,.,_",
"a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,9,8,7,6,5,4,3,2,1,.,_",
"@,♭,ḉ,ⓓ,℮,ƒ,ℊ,ⓗ,ⓘ,נ,ⓚ,ℓ,ⓜ,η,ø,℘,ⓠ,ⓡ,﹩,т,ⓤ,√,ω,ж,૪,ℨ,@,♭,ḉ,ⓓ,℮,ƒ,ℊ,ⓗ,ⓘ,נ,ⓚ,ℓ,ⓜ,η,ø,℘,ⓠ,ⓡ,﹩,т,ⓤ,√,ω,ж,૪,ℨ,0,➈,➑,➐,➅,➄,➃,➌,➁,➊,.,_",
"@,♭,¢,ⅾ,ε,ƒ,ℊ,ℌ,ї,נ,к,ℓ,м,п,ø,ρ,ⓠ,ґ,﹩,⊥,ü,√,ω,ϰ,૪,ℨ,@,♭,¢,ⅾ,ε,ƒ,ℊ,ℌ,ї,נ,к,ℓ,м,п,ø,ρ,ⓠ,ґ,﹩,⊥,ü,√,ω,ϰ,૪,ℨ,0,9,8,7,6,5,4,3,2,1,.,_",
"α,♭,ḉ,∂,ℯ,ƒ,ℊ,ℌ,ї,ʝ,ḱ,ℓ,м,η,ø,℘,ⓠ,я,﹩,⊥,ц,ṽ,ω,ჯ,૪,ẕ,α,♭,ḉ,∂,ℯ,ƒ,ℊ,ℌ,ї,ʝ,ḱ,ℓ,м,η,ø,℘,ⓠ,я,﹩,⊥,ц,ṽ,ω,ჯ,૪,ẕ,0,9,8,7,6,5,4,3,2,1,.,_",
"@,ß,¢,ḓ,℮,ƒ,ℊ,ℌ,ї,נ,ḱ,ʟ,м,п,◎,℘,ⓠ,я,﹩,т,ʊ,♥️,ẘ,✄,૪,ℨ,@,ß,¢,ḓ,℮,ƒ,ℊ,ℌ,ї,נ,ḱ,ʟ,м,п,◎,℘,ⓠ,я,﹩,т,ʊ,♥️,ẘ,✄,૪,ℨ,0,9,8,7,6,5,4,3,2,1,.,_",
"@,ß,¢,ḓ,℮,ƒ,ℊ,н,ḯ,נ,к,ℓμ,п,☺️,℘,ⓠ,я,﹩,⊥,υ,ṽ,ω,✄,૪,ℨ,@,ß,¢,ḓ,℮,ƒ,ℊ,н,ḯ,נ,к,ℓμ,п,☺️,℘,ⓠ,я,﹩,⊥,υ,ṽ,ω,✄,૪,ℨ,0,9,8,7,6,5,4,3,2,1,.,_",
"@,ß,ḉ,ḓ,є,ƒ,ℊ,ℌ,ї,נ,ḱ,ʟ,ღ,η,◎,℘,ⓠ,я,﹩,⊥,ʊ,♥️,ω,ϰ,૪,ẕ,@,ß,ḉ,ḓ,є,ƒ,ℊ,ℌ,ї,נ,ḱ,ʟ,ღ,η,◎,℘,ⓠ,я,﹩,⊥,ʊ,♥️,ω,ϰ,૪,ẕ,0,9,8,7,6,5,4,3,2,1,.,_",
"@,ß,ḉ,∂,ε,ƒ,ℊ,ℌ,ї,נ,ḱ,ł,ღ,и,ø,℘,ⓠ,я,﹩,т,υ,√,ω,ჯ,૪,ẕ,@,ß,ḉ,∂,ε,ƒ,ℊ,ℌ,ї,נ,ḱ,ł,ღ,и,ø,℘,ⓠ,я,﹩,т,υ,√,ω,ჯ,૪,ẕ,0,9,8,7,6,5,4,3,2,1,.,_",
"α,♭,¢,∂,ε,ƒ,❡,н,ḯ,ʝ,ḱ,ʟ,μ,п,ø,ρ,ⓠ,ґ,﹩,т,υ,ṽ,ω,ж,૪,ẕ,α,♭,¢,∂,ε,ƒ,❡,н,ḯ,ʝ,ḱ,ʟ,μ,п,ø,ρ,ⓠ,ґ,﹩,т,υ,ṽ,ω,ж,૪,ẕ,0,9,8,7,6,5,4,3,2,1,.,_",
"α,♭,ḉ,∂,℮,ⓕ,ⓖ,н,ḯ,ʝ,ḱ,ℓ,м,п,ø,ⓟ,ⓠ,я,ⓢ,ⓣ,ⓤ,♥️,ⓦ,✄,ⓨ,ⓩ,α,♭,ḉ,∂,℮,ⓕ,ⓖ,н,ḯ,ʝ,ḱ,ℓ,м,п,ø,ⓟ,ⓠ,я,ⓢ,ⓣ,ⓤ,♥️,ⓦ,✄,ⓨ,ⓩ,0,➒,➑,➐,➏,➄,➍,➂,➁,➀,.,_",
"@,♭,ḉ,ḓ,є,ƒ,ⓖ,ℌ,ⓘ,נ,к,ⓛ,м,ⓝ,ø,℘,ⓠ,я,﹩,ⓣ,ʊ,√,ω,ჯ,૪,ⓩ,@,♭,ḉ,ḓ,є,ƒ,ⓖ,ℌ,ⓘ,נ,к,ⓛ,м,ⓝ,ø,℘,ⓠ,я,﹩,ⓣ,ʊ,√,ω,ჯ,૪,ⓩ,0,➒,➇,➆,➅,➄,➍,➌,➋,➀,.,_",
"α,♭,ⓒ,∂,є,ⓕ,ⓖ,ℌ,ḯ,ⓙ,ḱ,ł,ⓜ,и,ⓞ,ⓟ,ⓠ,ⓡ,ⓢ,⊥,ʊ,ⓥ,ⓦ,ж,ⓨ,ⓩ,α,♭,ⓒ,∂,є,ⓕ,ⓖ,ℌ,ḯ,ⓙ,ḱ,ł,ⓜ,и,ⓞ,ⓟ,ⓠ,ⓡ,ⓢ,⊥,ʊ,ⓥ,ⓦ,ж,ⓨ,ⓩ,0,➒,➑,➆,➅,➎,➍,➌,➁,➀,.,_",
"ⓐ,ß,ḉ,∂,℮,ⓕ,❡,ⓗ,ї,נ,ḱ,ł,μ,η,ø,ρ,ⓠ,я,﹩,ⓣ,ц,√,ⓦ,✖️,૪,ℨ,ⓐ,ß,ḉ,∂,℮,ⓕ,❡,ⓗ,ї,נ,ḱ,ł,μ,η,ø,ρ,ⓠ,я,﹩,ⓣ,ц,√,ⓦ,✖️,૪,ℨ,0,➒,➑,➐,➅,➄,➍,➂,➁,➊,.,_",
"α,ß,ⓒ,ⅾ,ℯ,ƒ,ℊ,ⓗ,ї,ʝ,к,ʟ,ⓜ,η,ⓞ,℘,ⓠ,ґ,﹩,т,υ,ⓥ,ⓦ,ж,ⓨ,ẕ,α,ß,ⓒ,ⅾ,ℯ,ƒ,ℊ,ⓗ,ї,ʝ,к,ʟ,ⓜ,η,ⓞ,℘,ⓠ,ґ,﹩,т,υ,ⓥ,ⓦ,ж,ⓨ,ẕ,0,➈,➇,➐,➅,➎,➍,➌,➁,➊,.,_",
"@,♭,ḉ,ⅾ,є,ⓕ,❡,н,ḯ,נ,ⓚ,ⓛ,м,ⓝ,☺️,ⓟ,ⓠ,я,ⓢ,⊥,υ,♥️,ẘ,ϰ,૪,ⓩ,@,♭,ḉ,ⅾ,є,ⓕ,❡,н,ḯ,נ,ⓚ,ⓛ,м,ⓝ,☺️,ⓟ,ⓠ,я,ⓢ,⊥,υ,♥️,ẘ,ϰ,૪,ⓩ,0,➒,➑,➆,➅,➄,➃,➂,➁,➀,.,_",
"ⓐ,♭,ḉ,ⅾ,є,ƒ,ℊ,ℌ,ḯ,ʝ,ḱ,ł,μ,η,ø,ⓟ,ⓠ,ґ,ⓢ,т,ⓤ,√,ⓦ,✖️,ⓨ,ẕ,ⓐ,♭,ḉ,ⅾ,є,ƒ,ℊ,ℌ,ḯ,ʝ,ḱ,ł,μ,η,ø,ⓟ,ⓠ,ґ,ⓢ,т,ⓤ,√,ⓦ,✖️,ⓨ,ẕ,0,➈,➇,➐,➅,➄,➃,➂,➁,➀,.,_",
"ձ,ъƈ,ժ,ε,բ,ց,հ,ﻨ,յ,ĸ,l,ო,ռ,օ,թ,զ,г,ร,է,ս,ν,ա,×,ყ,২,ձ,ъƈ,ժ,ε,բ,ց,հ,ﻨ,յ,ĸ,l,ო,ռ,օ,թ,զ,г,ร,է,ս,ν,ա,×,ყ,২,0,9,8,7,6,5,4,3,2,1,.,_",
"λ,ϐ,ς,d,ε,ғ,ϑ,ɢ,н,ι,ϳ,κ,l,ϻ,π,σ,ρ,φ,г,s,τ,υ,v,ш,ϰ,ψ,z,λ,ϐ,ς,d,ε,ғ,ϑ,ɢ,н,ι,ϳ,κ,l,ϻ,π,σ,ρ,φ,г,s,τ,υ,v,ш,ϰ,ψ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ค,๒,ς,๔,є,Ŧ,ɠ,ђ,เ,ן,к,l,๓,ภ,๏,թ,ợ,г,ร,t,ย,v,ฬ,x,ץ,z,ค,๒,ς,๔,є,Ŧ,ɠ,ђ,เ,ן,к,l,๓,ภ,๏,թ,ợ,г,ร,t,ย,v,ฬ,x,ץ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"მ,ჩ,ƈძ,ε,բ,ց,հ,ἶ,ʝ,ƙ,l,ო,ղ,օ,ր,գ,ɾ,ʂ,է,մ,ν,ω,ჯ,ყ,z,მ,ჩ,ƈძ,ε,բ,ց,հ,ἶ,ʝ,ƙ,l,ო,ղ,օ,ր,գ,ɾ,ʂ,է,մ,ν,ω,ჯ,ყ,z,0,Գ,Ց,Դ,6,5,Վ,Յ,Զ,1,.,_",
"ค,ც,८,ძ,૯,Բ,૭,Һ,ɿ,ʆ,қ,Ն,ɱ,Ո,૦,ƿ,ҩ,Ր,ς,੮,υ,౮,ω,૪,ע,ઽ,ค,ც,८,ძ,૯,Բ,૭,Һ,ɿ,ʆ,қ,Ն,ɱ,Ո,૦,ƿ,ҩ,Ր,ς,੮,υ,౮,ω,૪,ע,ઽ,0,9,8,7,6,5,4,3,2,1,.,_",
"Λ,Б,Ͼ,Ð,Ξ,Ŧ,g,h,ł,j,К,Ł,m,Л,Ф,p,Ǫ,Я,s,t,u,v,Ш,Ж,Џ,z,Λ,Б,Ͼ,Ð,Ξ,Ŧ,g,h,ł,j,К,Ł,m,Л,Ф,p,Ǫ,Я,s,t,u,v,Ш,Ж,Џ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"λ,ß,Ȼ,ɖ,ε,ʃ,Ģ,ħ,ί,ĵ,κ,ι,ɱ,ɴ,Θ,ρ,ƣ,ર,Ș,τ,Ʋ,ν,ώ,Χ,ϓ,Հ,λ,ß,Ȼ,ɖ,ε,ʃ,Ģ,ħ,ί,ĵ,κ,ι,ɱ,ɴ,Θ,ρ,ƣ,ર,Ș,τ,Ʋ,ν,ώ,Χ,ϓ,Հ,0,9,8,7,6,5,4,3,2,1,.,_",
"ª,b,¢,Þ,È,F,૬,ɧ,Î,j,Κ,Ļ,м,η,◊,Ƿ,ƍ,r,S,⊥,µ,√,w,×,ý,z,ª,b,¢,Þ,È,F,૬,ɧ,Î,j,Κ,Ļ,м,η,◊,Ƿ,ƍ,r,S,⊥,µ,√,w,×,ý,z,0,9,8,7,6,5,4,3,2,1,.,_",
"Թ,Յ,Շ,Ժ,ȝ,Բ,Գ,ɧ,ɿ,ʝ,ƙ,ʅ,ʍ,Ռ,Ծ,ρ,φ,Ր,Տ,Ե,Մ,ע,ա,Ճ,Վ,Հ,Թ,Յ,Շ,Ժ,ȝ,Բ,Գ,ɧ,ɿ,ʝ,ƙ,ʅ,ʍ,Ռ,Ծ,ρ,φ,Ր,Տ,Ե,Մ,ע,ա,Ճ,Վ,Հ,0,9,8,7,6,5,4,3,2,1,.,_",
"Λ,Ϧ,ㄈ,Ð,Ɛ,F,Ɠ,н,ɪ,フ,Қ,Ł,௱,Л,Ø,þ,Ҩ,尺,ら,Ť,Ц,Ɣ,Ɯ,χ,Ϥ,Ẕ,Λ,Ϧ,ㄈ,Ð,Ɛ,F,Ɠ,н,ɪ,フ,Қ,Ł,௱,Л,Ø,þ,Ҩ,尺,ら,Ť,Ц,Ɣ,Ɯ,χ,Ϥ,Ẕ,0,9,8,7,6,5,4,3,2,1,.,_",
"Ǟ,в,ट,D,ę,բ,g,৸,i,j,κ,l,ɱ,П,Φ,Р,q,Я,s,Ʈ,Ц,v,Щ,ж,ყ,ւ,Ǟ,в,ट,D,ę,բ,g,৸,i,j,κ,l,ɱ,П,Φ,Р,q,Я,s,Ʈ,Ц,v,Щ,ж,ყ,ւ,0,9,8,7,6,5,4,3,2,1,.,_",
"ɒ,d,ɔ,b,ɘ,ʇ,ϱ,н,i,į,ʞ,l,м,и,o,q,p,я,ƨ,т,υ,v,w,x,γ,z,ɒ,d,ɔ,b,ɘ,ʇ,ϱ,н,i,į,ʞ,l,м,и,o,q,p,я,ƨ,т,υ,v,w,x,γ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"Æ,þ,©,Ð,E,F,ζ,Ħ,Ї,¿,ズ,ᄂ,M,Ñ,Θ,Ƿ,Ø,Ґ,Š,τ,υ,¥,w,χ,y,շ,Æ,þ,©,Ð,E,F,ζ,Ħ,Ї,¿,ズ,ᄂ,M,Ñ,Θ,Ƿ,Ø,Ґ,Š,τ,υ,¥,w,χ,y,շ,0,9,8,7,6,5,4,3,2,1,.,_",
"ª,ß,¢,ð,€,f,g,h,¡,j,k,|,m,ñ,¤,Þ,q,®,$,t,µ,v,w,×,ÿ,z,ª,ß,¢,ð,€,f,g,h,¡,j,k,|,m,ñ,¤,Þ,q,®,$,t,µ,v,w,×,ÿ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"ɐ,q,ɔ,p,ǝ,ɟ,ɓ,ɥ,ı,ſ,ʞ,ๅ,ɯ,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,ɐ,q,ɔ,p,ǝ,ɟ,ɓ,ɥ,ı,ſ,ʞ,ๅ,ɯ,u,o,d,b,ɹ,s,ʇ,n,ʌ,ʍ,x,ʎ,z,0,9,8,7,6,5,4,3,2,1,.,_",
"⒜,⒝,⒞,⒟,⒠,⒡,⒢,⒣,⒤,⒥,⒦,⒧,⒨,⒩,⒪,⒫,⒬,⒭,⒮,⒯,⒰,⒱,⒲,⒳,⒴,⒵,⒜,⒝,⒞,⒟,⒠,⒡,⒢,⒣,⒤,⒥,⒦,⒧,⒨,⒩,⒪,⒫,⒬,⒭,⒮,⒯,⒰,⒱,⒲,⒳,⒴,⒵,⒪,⑼,⑻,⑺,⑹,⑸,⑷,⑶,⑵,⑴,.,_",
"ɑ,ʙ,c,ᴅ,є,ɻ,მ,ʜ,ι,ɿ,ĸ,г,w,и,o,ƅϭ,ʁ,ƨ,⊥,n,ʌ,ʍ,x,⑃,z,ɑ,ʙ,c,ᴅ,є,ɻ,მ,ʜ,ι,ɿ,ĸ,г,w,и,o,ƅϭ,ʁ,ƨ,⊥,n,ʌ,ʍ,x,⑃,z,0,9,8,7,6,5,4,3,2,1,.,_",
"4,8,C,D,3,F,9,H,!,J,K,1,M,N,0,P,Q,R,5,7,U,V,W,X,Y,2,4,8,C,D,3,F,9,H,!,J,K,1,M,N,0,P,Q,R,5,7,U,V,W,X,Y,2,0,9,8,7,6,5,4,3,2,1,.,_",
"Λ,ßƇ,D,Ɛ,F,Ɠ,Ĥ,Ī,Ĵ,Ҡ,Ŀ,M,И,♡,Ṗ,Ҩ,Ŕ,S,Ƭ,Ʊ,Ѵ,Ѡ,Ӿ,Y,Z,Λ,ßƇ,D,Ɛ,F,Ɠ,Ĥ,Ī,Ĵ,Ҡ,Ŀ,M,И,♡,Ṗ,Ҩ,Ŕ,S,Ƭ,Ʊ,Ѵ,Ѡ,Ӿ,Y,Z,0,9,8,7,6,5,4,3,2,1,.,_",
"α,в,¢,đ,e,f,g,ħ,ı,נ,κ,ł,м,и,ø,ρ,q,я,š,т,υ,ν,ω,χ,ч,z,α,в,¢,đ,e,f,g,ħ,ı,נ,κ,ł,м,и,ø,ρ,q,я,š,т,υ,ν,ω,χ,ч,z,0,9,8,7,6,5,4,3,2,1,.,_",
"α,в,c,ɔ,ε,ғ,ɢ,н,ı,נ,κ,ʟ,м,п,σ,ρ,ǫ,я,ƨ,т,υ,ν,ш,х,ч,z,α,в,c,ɔ,ε,ғ,ɢ,н,ı,נ,κ,ʟ,м,п,σ,ρ,ǫ,я,ƨ,т,υ,ν,ш,х,ч,z,0,9,8,7,6,5,4,3,2,1,.,_",
"【a】,【b】,【c】,【d】,【e】,【f】,【g】,【h】,【i】,【j】,【k】,【l】,【m】,【n】,【o】,【p】,【q】,【r】,【s】,【t】,【u】,【v】,【w】,【x】,【y】,【z】,【a】,【b】,【c】,【d】,【e】,【f】,【g】,【h】,【i】,【j】,【k】,【l】,【m】,【n】,【o】,【p】,【q】,【r】,【s】,【t】,【u】,【v】,【w】,【x】,【y】,【z】,【0】,【9】,【8】,【7】,【6】,【5】,【4】,【3】,【2】,【1】,.,_",
"[̲̲̅̅a̲̅,̲̅b̲̲̅,̅c̲̅,̲̅d̲̲̅,̅e̲̲̅,̅f̲̲̅,̅g̲̅,̲̅h̲̲̅,̅i̲̲̅,̅j̲̲̅,̅k̲̅,̲̅l̲̲̅,̅m̲̅,̲̅n̲̅,̲̅o̲̲̅,̅p̲̅,̲̅q̲̅,̲̅r̲̲̅,̅s̲̅,̲̅t̲̲̅,̅u̲̅,̲̅v̲̅,̲̅w̲̅,̲̅x̲̅,̲̅y̲̅,̲̅z̲̅,[̲̲̅̅a̲̅,̲̅b̲̲̅,̅c̲̅,̲̅d̲̲̅,̅e̲̲̅,̅f̲̲̅,̅g̲̅,̲̅h̲̲̅,̅i̲̲̅,̅j̲̲̅,̅k̲̅,̲̅l̲̲̅,̅m̲̅,̲̅n̲̅,̲̅o̲̲̅,̅p̲̅,̲̅q̲̅,̲̅r̲̲̅,̅s̲̅,̲̅t̲̲̅,̅u̲̅,̲̅v̲̅,̲̅w̲̅,̲̅x̲̅,̲̅y̲̅,̲̅z̲̅,̲̅0̲̅,̲̅9̲̲̅,̅8̲̅,̲̅7̲̅,̲̅6̲̅,̲̅5̲̅,̲̅4̲̅,̲̅3̲̲̅,̅2̲̲̅,̅1̲̲̅̅],.,_",
"[̺͆a̺͆͆,̺b̺͆͆,̺c̺͆,̺͆d̺͆,̺͆e̺͆,̺͆f̺͆͆,̺g̺͆,̺͆h̺͆,̺͆i̺͆,̺͆j̺͆,̺͆k̺͆,̺l̺͆͆,̺m̺͆͆,̺n̺͆͆,̺o̺͆,̺͆p̺͆͆,̺q̺͆͆,̺r̺͆͆,̺s̺͆͆,̺t̺͆͆,̺u̺͆͆,̺v̺͆͆,̺w̺͆,̺͆x̺͆,̺͆y̺͆,̺͆z̺,[̺͆a̺͆͆,̺b̺͆͆,̺c̺͆,̺͆d̺͆,̺͆e̺͆,̺͆f̺͆͆,̺g̺͆,̺͆h̺͆,̺͆i̺͆,̺͆j̺͆,̺͆k̺͆,̺l̺͆͆,̺m̺͆͆,̺n̺͆͆,̺o̺͆,̺͆p̺͆͆,̺q̺͆͆,̺r̺͆͆,̺s̺͆͆,̺t̺͆͆,̺u̺͆͆,̺v̺͆͆,̺w̺͆,̺͆x̺͆,̺͆y̺͆,̺͆z̺,̺͆͆0̺͆,̺͆9̺͆,̺͆8̺̺͆͆7̺͆,̺͆6̺͆,̺͆5̺͆,̺͆4̺͆,̺͆3̺͆,̺͆2̺͆,̺͆1̺͆],.,_",
"̛̭̰̃ã̛̰̭,̛̭̰̃b̛̰̭̃̃,̛̭̰c̛̛̰̭̃̃,̭̰d̛̰̭̃,̛̭̰̃ḛ̛̭̃̃,̛̭̰f̛̰̭̃̃,̛̭̰g̛̰̭̃̃,̛̭̰h̛̰̭̃,̛̭̰̃ḭ̛̛̭̃̃,̭̰j̛̰̭̃̃,̛̭̰k̛̰̭̃̃,̛̭̰l̛̰̭,̛̭̰̃m̛̰̭̃̃,̛̭̰ñ̛̛̰̭̃,̭̰ỡ̰̭̃,̛̭̰p̛̰̭̃,̛̭̰̃q̛̰̭̃̃,̛̭̰r̛̛̰̭̃̃,̭̰s̛̰̭,̛̭̰̃̃t̛̰̭̃,̛̭̰̃ữ̰̭̃,̛̭̰ṽ̛̰̭̃,̛̭̰w̛̛̰̭̃̃,̭̰x̛̰̭̃,̛̭̰̃ỹ̛̰̭̃,̛̭̰z̛̰̭̃̃,̛̛̭̰ã̛̰̭,̛̭̰̃b̛̰̭̃̃,̛̭̰c̛̛̰̭̃̃,̭̰d̛̰̭̃,̛̭̰̃ḛ̛̭̃̃,̛̭̰f̛̰̭̃̃,̛̭̰g̛̰̭̃̃,̛̭̰h̛̰̭̃,̛̭̰̃ḭ̛̛̭̃̃,̭̰j̛̰̭̃̃,̛̭̰k̛̰̭̃̃,̛̭̰l̛̰̭,̛̭̰̃m̛̰̭̃̃,̛̭̰ñ̛̛̰̭̃,̭̰ỡ̰̭̃,̛̭̰p̛̰̭̃,̛̭̰̃q̛̰̭̃̃,̛̭̰r̛̛̰̭̃̃,̭̰s̛̰̭,̛̭̰̃̃t̛̰̭̃,̛̭̰̃ữ̰̭̃,̛̭̰ṽ̛̰̭̃,̛̭̰w̛̛̰̭̃̃,̭̰x̛̰̭̃,̛̭̰̃ỹ̛̰̭̃,̛̭̰z̛̰̭̃̃,̛̭̰0̛̛̰̭̃̃,̭̰9̛̰̭̃̃,̛̭̰8̛̛̰̭̃̃,̭̰7̛̰̭̃̃,̛̭̰6̛̰̭̃̃,̛̭̰5̛̰̭̃,̛̭̰̃4̛̰̭̃,̛̭̰̃3̛̰̭̃̃,̛̭̰2̛̰̭̃̃,̛̭̰1̛̰̭̃,.,_",
"a,ะb,ะc,ะd,ะe,ะf,ะg,ะh,ะi,ะj,ะk,ะl,ะm,ะn,ะo,ะp,ะq,ะr,ะs,ะt,ะu,ะv,ะw,ะx,ะy,ะz,a,ะb,ะc,ะd,ะe,ะf,ะg,ะh,ะi,ะj,ะk,ะl,ะm,ะn,ะo,ะp,ะq,ะr,ะs,ะt,ะu,ะv,ะw,ะx,ะy,ะz,ะ0,ะ9,ะ8,ะ7,ะ6,ะ5,ะ4,ะ3,ะ2,ะ1ะ,.,_",
"̑ȃ,̑b̑,̑c̑,̑d̑,̑ȇ,̑f̑,̑g̑,̑h̑,̑ȋ,̑j̑,̑k̑,̑l̑,̑m̑,̑n̑,̑ȏ,̑p̑,̑q̑,̑ȓ,̑s̑,̑t̑,̑ȗ,̑v̑,̑w̑,̑x̑,̑y̑,̑z̑,̑ȃ,̑b̑,̑c̑,̑d̑,̑ȇ,̑f̑,̑g̑,̑h̑,̑ȋ,̑j̑,̑k̑,̑l̑,̑m̑,̑n̑,̑ȏ,̑p̑,̑q̑,̑ȓ,̑s̑,̑t̑,̑ȗ,̑v̑,̑w̑,̑x̑,̑y̑,̑z̑,̑0̑,̑9̑,̑8̑,̑7̑,̑6̑,̑5̑,̑4̑,̑3̑,̑2̑,̑1̑,.,_",
"~a,͜͝b,͜͝c,͜͝d,͜͝e,͜͝f,͜͝g,͜͝h,͜͝i,͜͝j,͜͝k,͜͝l,͜͝m,͜͝n,͜͝o,͜͝p,͜͝q,͜͝r,͜͝s,͜͝t,͜͝u,͜͝v,͜͝w,͜͝x,͜͝y,͜͝z,~a,͜͝b,͜͝c,͜͝d,͜͝e,͜͝f,͜͝g,͜͝h,͜͝i,͜͝j,͜͝k,͜͝l,͜͝m,͜͝n,͜͝o,͜͝p,͜͝q,͜͝r,͜͝s,͜͝t,͜͝u,͜͝v,͜͝w,͜͝x,͜͝y,͜͝z,͜͝0,͜͝9,͜͝8,͜͝7,͜͝6,͜͝5,͜͝4,͜͝3,͜͝2͜,͝1͜͝~,.,_",
"̤̈ä̤,̤̈b̤̈,̤̈c̤̈̈,̤d̤̈,̤̈ë̤,̤̈f̤̈,̤̈g̤̈̈,̤ḧ̤̈,̤ï̤̈,̤j̤̈,̤̈k̤̈̈,̤l̤̈,̤̈m̤̈,̤̈n̤̈,̤̈ö̤,̤̈p̤̈,̤̈q̤̈,̤̈r̤̈,̤̈s̤̈̈,̤ẗ̤̈,̤ṳ̈,̤̈v̤̈,̤̈ẅ̤,̤̈ẍ̤,̤̈ÿ̤,̤̈z̤̈,̤̈ä̤,̤̈b̤̈,̤̈c̤̈̈,̤d̤̈,̤̈ë̤,̤̈f̤̈,̤̈g̤̈̈,̤ḧ̤̈,̤ï̤̈,̤j̤̈,̤̈k̤̈̈,̤l̤̈,̤̈m̤̈,̤̈n̤̈,̤̈ö̤,̤̈p̤̈,̤̈q̤̈,̤̈r̤̈,̤̈s̤̈̈,̤ẗ̤̈,̤ṳ̈,̤̈v̤̈,̤̈ẅ̤,̤̈ẍ̤,̤̈ÿ̤,̤̈z̤̈,̤̈0̤̈,̤̈9̤̈,̤̈8̤̈,̤̈7̤̈,̤̈6̤̈,̤̈5̤̈,̤̈4̤̈,̤̈3̤̈,̤̈2̤̈̈,̤1̤̈,.,_",
"≋̮̑ȃ̮,̮̑b̮̑,̮̑c̮̑,̮̑d̮̑,̮̑ȇ̮,̮̑f̮̑,̮̑g̮̑,̮̑ḫ̑,̮̑ȋ̮,̮̑j̮̑,̮̑k̮̑,̮̑l̮̑,̮̑m̮̑,̮̑n̮̑,̮̑ȏ̮,̮̑p̮̑,̮̑q̮̑,̮̑r̮,̮̑̑s̮,̮̑̑t̮,̮̑̑u̮,̮̑̑v̮̑,̮̑w̮̑,̮̑x̮̑,̮̑y̮̑,̮̑z̮̑,≋̮̑ȃ̮,̮̑b̮̑,̮̑c̮̑,̮̑d̮̑,̮̑ȇ̮,̮̑f̮̑,̮̑g̮̑,̮̑ḫ̑,̮̑ȋ̮,̮̑j̮̑,̮̑k̮̑,̮̑l̮̑,̮̑m̮̑,̮̑n̮̑,̮̑ȏ̮,̮̑p̮̑,̮̑q̮̑,̮̑r̮,̮̑̑s̮,̮̑̑t̮,̮̑̑u̮,̮̑̑v̮̑,̮̑w̮̑,̮̑x̮̑,̮̑y̮̑,̮̑z̮̑,̮̑0̮̑,̮̑9̮̑,̮̑8̮̑,̮̑7̮̑,̮̑6̮̑,̮̑5̮̑,̮̑4̮̑,̮̑3̮̑,̮̑2̮̑,̮̑1̮̑≋,.,_",
"a̮,̮b̮̮,c̮̮,d̮̮,e̮̮,f̮̮,g̮̮,ḫ̮,i̮,j̮̮,k̮̮,l̮,̮m̮,̮n̮̮,o̮,̮p̮̮,q̮̮,r̮̮,s̮,̮t̮̮,u̮̮,v̮̮,w̮̮,x̮̮,y̮̮,z̮̮,a̮,̮b̮̮,c̮̮,d̮̮,e̮̮,f̮̮,g̮̮,ḫ̮i,̮̮,j̮̮,k̮̮,l̮,̮m̮,̮n̮̮,o̮,̮p̮̮,q̮̮,r̮̮,s̮,̮t̮̮,u̮̮,v̮̮,w̮̮,x̮̮,y̮̮,z̮̮,0̮̮,9̮̮,8̮̮,7̮̮,6̮̮,5̮̮,4̮̮,3̮̮,2̮̮,1̮,.,_",
"A̲,̲B̲,̲C̲,̲D̲,̲E̲,̲F̲,̲G̲,̲H̲,̲I̲,̲J̲,̲K̲,̲L̲,̲M̲,̲N̲,̲O̲,̲P̲,̲Q̲,̲R̲,̲S̲,̲T̲,̲U̲,̲V̲,̲W̲,̲X̲,̲Y̲,̲Z̲,̲a̲,̲b̲,̲c̲,̲d̲,̲e̲,̲f̲,̲g̲,̲h̲,̲i̲,̲j̲,̲k̲,̲l̲,̲m̲,̲n̲,̲o̲,̲p̲,̲q̲,̲r̲,̲s̲,̲t̲,̲u̲,̲v̲,̲w̲,̲x̲,̲y̲,̲z̲,̲0̲,̲9̲,̲8̲,̲7̲,̲6̲,̲5̲,̲4̲,̲3̲,̲2̲,̲1̲,̲.̲,̲_̲",
"Â,ß,Ĉ,Ð,Є,Ŧ,Ǥ,Ħ,Ī,ʖ,Қ,Ŀ,♏,И,Ø,P,Ҩ,R,$,ƚ,Ц,V,Щ,X,¥,Ẕ,Â,ß,Ĉ,Ð,Є,Ŧ,Ǥ,Ħ,Ī,ʖ,Қ,Ŀ,♏,И,Ø,P,Ҩ,R,$,ƚ,Ц,V,Щ,X,¥,Ẕ,0,9,8,7,6,5,4,3,2,1,.,_",
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
local result = {}
i=0
for k=1,#fonts do
i=i+1
local tar_font = fonts[i]:split(",")
local text = matches[2]
local text = text:gsub("A",tar_font[1])
local text = text:gsub("B",tar_font[2])
local text = text:gsub("C",tar_font[3])
local text = text:gsub("D",tar_font[4])
local text = text:gsub("E",tar_font[5])
local text = text:gsub("F",tar_font[6])
local text = text:gsub("G",tar_font[7])
local text = text:gsub("H",tar_font[8])
local text = text:gsub("I",tar_font[9])
local text = text:gsub("J",tar_font[10])
local text = text:gsub("K",tar_font[11])
local text = text:gsub("L",tar_font[12])
local text = text:gsub("M",tar_font[13])
local text = text:gsub("N",tar_font[14])
local text = text:gsub("O",tar_font[15])
local text = text:gsub("P",tar_font[16])
local text = text:gsub("Q",tar_font[17])
local text = text:gsub("R",tar_font[18])
local text = text:gsub("S",tar_font[19])
local text = text:gsub("T",tar_font[20])
local text = text:gsub("U",tar_font[21])
local text = text:gsub("V",tar_font[22])
local text = text:gsub("W",tar_font[23])
local text = text:gsub("X",tar_font[24])
local text = text:gsub("Y",tar_font[25])
local text = text:gsub("Z",tar_font[26])
local text = text:gsub("a",tar_font[27])
local text = text:gsub("b",tar_font[28])
local text = text:gsub("c",tar_font[29])
local text = text:gsub("d",tar_font[30])
local text = text:gsub("e",tar_font[31])
local text = text:gsub("f",tar_font[32])
local text = text:gsub("g",tar_font[33])
local text = text:gsub("h",tar_font[34])
local text = text:gsub("i",tar_font[35])
local text = text:gsub("j",tar_font[36])
local text = text:gsub("k",tar_font[37])
local text = text:gsub("l",tar_font[38])
local text = text:gsub("m",tar_font[39])
local text = text:gsub("n",tar_font[40])
local text = text:gsub("o",tar_font[41])
local text = text:gsub("p",tar_font[42])
local text = text:gsub("q",tar_font[43])
local text = text:gsub("r",tar_font[44])
local text = text:gsub("s",tar_font[45])
local text = text:gsub("t",tar_font[46])
local text = text:gsub("u",tar_font[47])
local text = text:gsub("v",tar_font[48])
local text = text:gsub("w",tar_font[49])
local text = text:gsub("x",tar_font[50])
local text = text:gsub("y",tar_font[51])
local text = text:gsub("z",tar_font[52])
local text = text:gsub("0",tar_font[53])
local text = text:gsub("9",tar_font[54])
local text = text:gsub("8",tar_font[55])
local text = text:gsub("7",tar_font[56])
local text = text:gsub("6",tar_font[57])
local text = text:gsub("5",tar_font[58])
local text = text:gsub("4",tar_font[59])
local text = text:gsub("3",tar_font[60])
local text = text:gsub("2",tar_font[61])
local text = text:gsub("1",tar_font[62])
table.insert(result, text)
end
local result_text = "\n➖➖➖➖➖➖➖➖➖➖➖\n "
a=0
for v=1,#result do
a=a+1
result_text = result_text..a.."- "..result[a].."\n➖➖➖➖➖➖➖➖➖➖➖\n"
end
tdcli.sendMessage(msg.chat_id_, 0, 1, result_text, 1, 'html')
end
return {
patterns = {
},
patterns_fa = {
"^(زیباسازی انگلیسی) (.*)",
"^(زیباسازی انگلیسی)$",
},
run = run
} | gpl-3.0 |
luciouskami/YDWE | Development/Component/plugin/w3x2lni/script/core/slk/backend_obj.lua | 2 | 7816 | local w3xparser = require 'w3xparser'
local lang = require 'lang'
local table_insert = table.insert
local table_sort = table.sort
local table_concat = table.concat
local string_char = string.char
local math_type = math.type
local math_floor = math.floor
local wtonumber = w3xparser.tonumber
local float2bin = w3xparser.float2bin
local type = type
local pairs = pairs
local setmetatable = setmetatable
local os_clock = os.clock
local w2l
local has_level
local metadata
local default
local hexs
local wts
local ttype
local displaytype = {
unit = lang.script.UNIT,
ability = lang.script.ABILITY,
item = lang.script.ITEM,
buff = lang.script.BUFF,
upgrade = lang.script.UPGRADE,
doodad = lang.script.DOODAD,
destructable = lang.script.DESTRUCTABLE,
}
local function get_displayname(o)
local name
if o._type == 'buff' then
name = o.bufftip or o.editorname or ''
elseif o._type == 'upgrade' then
name = o.name[1] or ''
elseif o._type == 'doodad' or o._type == 'destructable' then
name = w2l:get_editstring(o.name or '')
else
name = o.name or ''
end
return o._id, (name:sub(1, 100):gsub('\r\n', ' '))
end
local function format_value(value)
if type(value) == 'table' then
local tbl = {}
for i = 1, 4 do
if value[i] then
tbl[i] = ('[%d]: %s'):format(i, tostring(value[i]):sub(1, 25):gsub('\r\n', ' '))
end
end
return table_concat(tbl, ' ')
else
return tostring(value):sub(1, 100):gsub('\r\n', ' ')
end
end
local function report(reason, obj, key, tip)
w2l.messager.report(reason, 6, ('%s %s %s'):format(displaytype[ttype], get_displayname(obj)), ('[%s]: %s'):format(key, format_value(tip)))
end
local function write(format, ...)
hexs[#hexs+1] = (format):pack(...)
end
local function write_value(meta, level, obj, value)
local id = meta.id
local tp = meta.type
write('c4l', id .. ('\0'):rep(4 - #id), tp)
if has_level then
write('l', level)
write('l', meta.data or 0)
end
if tp == 0 then
if math_type(value) ~= 'integer' then
value = math_floor(wtonumber(value))
end
write('l', value)
elseif tp == 1 or tp == 2 then
write('c4', float2bin(value)) -- obj 的浮点数用api转换为二进制
else
if type(value) ~= 'string' then
value = ''
end
if value:find('\0', 1, true) then
report(lang.report.INVALID_OBJECT_DATA, obj, id, value)
value = ''
end
if #value > 1023 then
value = w2l:save_wts(wts, value, lang.script.TEXT_TOO_LONG_IN_OBJ)
end
write('z', value)
end
write('c4', '\0\0\0\0')
end
local function write_data(key, obj, data, meta)
if meta['repeat'] then
if type(data) ~= 'table' then
data = {data}
end
end
if type(data) == 'table' then
local max_level = 0
for level in pairs(data) do
if level > max_level then
max_level = level
end
end
for level = 1, max_level do
if data[level] then
write_value(meta, level, obj, data[level])
end
end
else
write_value(meta, 0, obj, data)
end
end
local function write_object(chunk, name, obj)
local keys = {}
local metas = {}
for key in pairs(obj) do
if key:sub(1, 1) ~= '_' then
keys[#keys+1] = key
end
end
local code = obj._code
if metadata[ttype] then
for key, meta in pairs(metadata[ttype]) do
metas[key] = meta
end
end
if metadata[code] then
for key, meta in pairs(metadata[code]) do
metas[key] = meta
end
end
table_sort(keys)
local count = 0
for _, key in ipairs(keys) do
local data = obj[key]
if data then
if metas[key] then
if type(data) == 'table' then
for _ in pairs(data) do
count = count + 1
end
else
count = count + 1
end
else
if type(data) == 'table' then
if next(data) then
report(lang.report.INVALID_OBJECT_DATA, obj, key, obj[key])
end
else
report(lang.report.INVALID_OBJECT_DATA, obj, key, obj[key])
end
end
end
end
local parent = obj._parent
if name == parent or obj._slk then
write('c4', name)
write('c4', '\0\0\0\0')
else
write('c4', parent)
write('c4', name)
end
write('l', count)
for _, key in ipairs(keys) do
local data = obj[key]
if data then
if metas[key] then
write_data(key, obj, obj[key], metas[key])
end
end
end
end
local function write_chunk(names, data, n, max)
local clock = os_clock()
write('l', #names)
for i, name in ipairs(names) do
write_object(data, name, data[name])
if os_clock() - clock > 0.1 then
clock = os_clock()
w2l.progress((i+n) / max)
w2l.messager.text(lang.script.CONVERT_FILE:format(ttype, data[name]._id, i+n, max))
end
end
end
local function write_head()
write('l', 2)
end
local function is_enable_obj(name, obj, remove_unuse_object)
if remove_unuse_object and not obj._mark then
return false
end
if #name ~= 4 then
w2l.messager.report(lang.report.INVALID_OBJECT, 6, ('[%s] %s'):format(name, lang.report.INVALID_OBJECT_ID))
return false
end
if not default[obj._parent] then
w2l.messager.report(lang.report.INVALID_OBJECT, 6, ('[%s:%s] %s'):format(name, obj._parent, lang.report.INVALID_OBJECT_PARENT))
return false
end
if not obj._slk and obj._id ~= obj._parent then
return true
end
if obj._keep_obj then
return true
end
for key, value in pairs(obj) do
if key:sub(1, 1) ~= '_' then
if type(value) == 'table' then
if next(value) then
return true
end
else
return true
end
end
end
return false
end
local function sort_chunk(chunk, remove_unuse_object)
local origin = {}
local user = {}
for name, obj in pairs(chunk) do
if is_enable_obj(name, obj, remove_unuse_object) then
local parent = obj._parent
if name == parent or obj._slk then
origin[#origin+1] = name
else
user[#user+1] = name
end
end
end
-- 大写ID的对象必须在小写ID的对象前面,否则同ID单位时,英雄的数据会出错
table_sort(origin, function (id1, id2)
return id1 > id2
end)
table_sort(user, function (id1, id2)
return id1 > id2
end)
return origin, user
end
return function (w2l_, type, data, wts_)
w2l = w2l_
if not data then
return
end
if type == 'misc' then
return w2l:backend_misc(data)
end
wts = wts_
ttype = type
has_level = w2l.info.key.max_level[type]
metadata = w2l:we_metadata()
default = w2l:get_default()[type]
local origin_id, user_id = sort_chunk(data, w2l.setting.remove_unuse_object)
local max = #origin_id + #user_id
if max == 0 then
return
end
hexs = {}
write_head()
write_chunk(origin_id, data, 0, max)
write_chunk(user_id, data, #origin_id, max)
return table_concat(hexs), report
end
| gpl-3.0 |
mattyx14/otxserver | data/monster/quests/ferumbras_ascendant/bosses/ferumbras_soul_splinter.lua | 2 | 3358 | local mType = Game.createMonsterType("Ferumbras Soul Splinter")
local monster = {}
monster.description = "Ferumbras Soul Splinter"
monster.experience = 12000
monster.outfit = {
lookType = 843,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.health = 150000
monster.maxHealth = 150000
monster.race = "venom"
monster.corpse = 0
monster.speed = 390
monster.manaCost = 0
monster.changeTarget = {
interval = 5000,
chance = 8
}
monster.strategiesTarget = {
nearest = 70,
health = 10,
damage = 10,
random = 10,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = true,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = true,
canWalkOnFire = true,
canWalkOnPoison = true
}
monster.events = {
"FerumbrasSoulSplinter"
}
monster.light = {
level = 0,
color = 0
}
monster.summon = {
maxSummons = 3,
summons = {
{name = "Demon", chance = 11, interval = 2000, count = 3}
}
}
monster.voices = {
interval = 5000,
chance = 10,
}
monster.loot = {
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, skill = 90, attack = 200},
-- poison
{name ="condition", type = CONDITION_POISON, interval = 2000, chance = 20, minDamage = -250, maxDamage = -520, radius = 6, effect = CONST_ME_POISONAREA, target = false},
{name ="ferumbras electrify", interval = 2000, chance = 18, target = false},
{name ="combat", interval = 2000, chance = 16, type = COMBAT_MANADRAIN, minDamage = -225, maxDamage = -410, radius = 6, effect = CONST_ME_MAGIC_RED, target = false},
{name ="combat", interval = 2000, chance = 21, type = COMBAT_LIFEDRAIN, minDamage = -200, maxDamage = -450, radius = 6, effect = CONST_ME_POFF, target = false},
{name ="ferumbras soulfire", interval = 2000, chance = 20, range = 7, target = false},
{name ="combat", interval = 2000, chance = 17, type = COMBAT_LIFEDRAIN, minDamage = -590, maxDamage = -1050, length = 8, spread = 3, effect = CONST_ME_HITBYPOISON, target = false}
}
monster.defenses = {
defense = 120,
armor = 100,
{name ="combat", interval = 2000, chance = 23, type = COMBAT_HEALING, minDamage = 600, maxDamage = 2490, effect = CONST_ME_MAGIC_GREEN, target = false},
{name ="combat", interval = 2000, chance = 3, type = COMBAT_HEALING, minDamage = 20000, maxDamage = 35000, effect = CONST_ME_MAGIC_GREEN, target = false},
{name ="speed", interval = 2000, chance = 14, speedChange = 700, effect = CONST_ME_MAGIC_BLUE, target = false, duration = 7000}
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = -50},
{type = COMBAT_ENERGYDAMAGE, percent = 0},
{type = COMBAT_EARTHDAMAGE, percent = 0},
{type = COMBAT_FIREDAMAGE, percent = 90},
{type = COMBAT_LIFEDRAIN, percent = 100},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = -10},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = true},
{type = "outfit", condition = true},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
mattyx14/otxserver | data/monster/quests/cults_of_tibia/bosses/pillars/pillar_of_death.lua | 2 | 1688 | local mType = Game.createMonsterType("Pillar Of Death")
local monster = {}
monster.description = "a pillar of death"
monster.experience = 0
monster.outfit = {
lookTypeEx = 11427
}
monster.health = 20000
monster.maxHealth = 20000
monster.race = "undead"
monster.corpse = 0
monster.speed = 0
monster.manaCost = 0
monster.changeTarget = {
interval = 4000,
chance = 20
}
monster.strategiesTarget = {
nearest = 70,
health = 10,
damage = 10,
random = 10,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = true,
staticAttackChance = 95,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
}
monster.loot = {
}
monster.defenses = {
defense = 50,
armor = 35
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = 0},
{type = COMBAT_EARTHDAMAGE, percent = 0},
{type = COMBAT_FIREDAMAGE, percent = 0},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = false},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
CarabusX/Zero-K | effects/weapexp_puff.lua | 7 | 4514 | -- weapexp_puff
-- puff_fire2
return {
["weapexp_puff"] = {
fire = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
underwater = 0,
water = false,
properties = {
airdrag = 0.93,
colormap = [[1.00 1.00 1.00 0.250
1.00 0.80 0.50 0.250
0.08 0.08 0.08 0.300
0.00 0.00 0.00 0.001]],
directional = false,
emitrot = 52,
emitrotspread = 38,
emitvector = [[0, 1, 0]],
gravity = [[0, 0.05, 0]],
numparticles = 9,
particlelife = 20,
particlelifespread = 40,
particlesize = 7,
particlesizespread = 3,
particlespeed = 0.5,
particlespeedspread = 1.5,
pos = [[0, 0, 0]],
sizegrowth = 0.7,
sizemod = 1.0,
texture = [[orangesmoke3]],
},
},
fire2 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
underwater = 0,
water = false,
properties = {
delay = 5,
explosiongenerator = [[custom:puff_fire2]],
pos = [[0, 0, 0]],
},
},
groundflash = {
circlealpha = 0,
circlegrowth = 0,
flashalpha = 0.35,
flashsize = 80,
ttl = 50,
color = {
[1] = 1,
[2] = 0.89999997615814,
[3] = 0.34999999403954,
},
},
pikes = {
air = true,
class = [[explspike]],
count = 8,
ground = true,
water = true,
properties = {
alpha = 1,
alphadecay = 0.1,
color = [[1.0,0.9,0.6]],
dir = [[-5 r10,-5 r10,-5 r10]],
length = 4.5,
width = 3,
},
},
sparks = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
useairlos = true,
water = true,
properties = {
airdrag = 0.97,
colormap = [[1 0.5 0.0 0.05
1 0.7 0.5 0.05
0 0.0 0.0 0.01]],
directional = true,
emitrot = 0,
emitrotspread = 80,
emitvector = [[0, 1, 0]],
gravity = [[0, -0.4, 0]],
numparticles = 5,
particlelife = 15,
particlelifespread = 0,
particlesize = 4,
particlesizespread = 5,
particlespeed = 6,
particlespeedspread = 4,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[plasma]],
},
},
},
["puff_fire2"] = {
fire2 = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
underwater = 0,
water = false,
properties = {
airdrag = 0.96,
colormap = [[0.00 0.00 0.00 0.001
0.00 0.00 0.00 0.001
0.10 0.10 0.10 0.100
0.10 0.10 0.10 0.200
0.05 0.05 0.05 0.200
0.00 0.00 0.00 0.001]],
directional = false,
emitrot = 80,
emitrotspread = 10,
emitvector = [[0, 1, 0]],
gravity = [[0, 0.05, 0]],
numparticles = 4,
particlelife = 15,
particlelifespread = 35,
particlesize = 3,
particlesizespread = 2,
particlespeed = 0.6,
particlespeedspread = 1,
pos = [[0, 0, 0]],
sizegrowth = 0.7,
sizemod = 0.985,
texture = [[orangesmoke3]],
},
},
},
}
| gpl-2.0 |
mattyx14/otxserver | data/monster/aquatics/quara_pincher.lua | 2 | 2978 | local mType = Game.createMonsterType("Quara Pincher")
local monster = {}
monster.description = "a quara pincher"
monster.experience = 1200
monster.outfit = {
lookType = 77,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.raceId = 245
monster.Bestiary = {
class = "Aquatic",
race = BESTY_RACE_AQUATIC,
toKill = 1000,
FirstUnlock = 50,
SecondUnlock = 500,
CharmsPoints = 25,
Stars = 3,
Occurrence = 0,
Locations = "Calassa, Frozen Trench, Yalahar (Sunken Quarter)."
}
monster.health = 1800
monster.maxHealth = 1800
monster.race = "blood"
monster.corpse = 6063
monster.speed = 396
monster.manaCost = 0
monster.changeTarget = {
interval = 4000,
chance = 10
}
monster.strategiesTarget = {
nearest = 100,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = false,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = true,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "Clank! Clank!", yell = false},
{text = "Clap!", yell = false},
{text = "Crrrk! Crrrk!", yell = false}
}
monster.loot = {
{name = "gold coin", chance = 50000, maxCount = 100},
{name = "gold coin", chance = 50000, maxCount = 50},
{name = "platinum coin", chance = 40000},
{name = "quara pincers", chance = 14285},
{name = "great health potion", chance = 10630},
{name = "small ruby", chance = 7761, maxCount = 2},
{name = "halberd", chance = 6861},
{name = "shrimp", chance = 5245, maxCount = 5},
{name = "fish fin", chance = 1600},
{name = "warrior helmet", chance = 1460},
{name = "crown armor", chance = 280},
{name = "glacier robe", chance = 120},
{name = "giant shrimp", chance = 40}
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -342, effect = CONST_ME_DRAWBLOOD},
{name ="speed", interval = 2000, chance = 20, speedChange = -600, range = 1, effect = CONST_ME_MAGIC_RED, target = false, duration = 3000}
}
monster.defenses = {
defense = 50,
armor = 50
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = -25},
{type = COMBAT_EARTHDAMAGE, percent = -10},
{type = COMBAT_FIREDAMAGE, percent = 100},
{type = COMBAT_LIFEDRAIN, percent = 100},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 100},
{type = COMBAT_ICEDAMAGE, percent = 100},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
mattyx14/otxserver | data/monster/magicals/flying_book.lua | 2 | 2237 | local mType = Game.createMonsterType("Flying Book")
local monster = {}
monster.description = "a flying book"
monster.experience = 200
monster.outfit = {
lookType = 1060,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.raceId = 1654
monster.Bestiary = {
class = "Magical",
race = BESTY_RACE_MAGICAL,
toKill = 1000,
FirstUnlock = 50,
SecondUnlock = 500,
CharmsPoints = 25,
Stars = 3,
Occurrence = 1,
Locations = "Secret Library."
}
monster.health = 500
monster.maxHealth = 500
monster.race = "ink"
monster.corpse = 28586
monster.speed = 240
monster.manaCost = 0
monster.changeTarget = {
interval = 5000,
chance = 8
}
monster.strategiesTarget = {
nearest = 100,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = true,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = true
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
}
monster.loot = {
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = -100, maxDamage = -200},
{name ="combat", interval = 1000, chance = 15, type = COMBAT_ICEDAMAGE, minDamage = -100, maxDamage = -180, range = 7, shootEffect = CONST_ANI_ICE, target = false}
}
monster.defenses = {
defense = 45,
armor = 45
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 10},
{type = COMBAT_ENERGYDAMAGE, percent = 5},
{type = COMBAT_EARTHDAMAGE, percent = 50},
{type = COMBAT_FIREDAMAGE, percent = 15},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 30},
{type = COMBAT_HOLYDAMAGE , percent = 90},
{type = COMBAT_DEATHDAMAGE , percent = 20}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
CarabusX/Zero-K | effects/ingeborg.lua | 25 | 15516 | -- ingeborg_2
-- ingeborg_3
-- ingeborg_9
-- ingeborg_7
-- ingeborg_8
-- ingeborg_ani
-- ingeborg_5
-- ingeborg_10
-- ingeborg_6
-- ingeborg
-- ingeborg_1
-- ingeborg_4
return {
["ingeborg_2"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
alwaysvisible = true,
colormap = [[0 0 0 0.01 1 1 1 0.01 0 0 0 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 2,
particlelifespread = 0,
particlesize = 15,
particlesizespread = 0,
particlespeed = 0,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[exp00_2]],
},
},
},
["ingeborg_3"] = {
groundflash = {
circlealpha = 1,
circlegrowth = 0,
flashalpha = 0.9,
flashsize = 30,
ttl = 13,
color = {
[1] = 1,
[2] = 0.80000001192093,
[3] = 0.20000000298023,
},
},
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
alwaysvisible = true,
colormap = [[0 0 0 0.01 1 1 1 0.01 0 0 0 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 2,
particlelifespread = 0,
particlesize = 15,
particlesizespread = 0,
particlespeed = 0,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[exp00_3]],
},
},
},
["ingeborg_9"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
alwaysvisible = true,
colormap = [[0 0 0 0.01 1 1 1 0.01 0 0 0 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 2,
particlelifespread = 0,
particlesize = 15,
particlesizespread = 0,
particlespeed = 0,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[exp00_9]],
},
},
},
["ingeborg_7"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
alwaysvisible = true,
colormap = [[0 0 0 0.01 1 1 1 0.01 0 0 0 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 2,
particlelifespread = 0,
particlesize = 15,
particlesizespread = 0,
particlespeed = 0,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[exp00_7]],
},
},
},
["ingeborg_8"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
alwaysvisible = true,
colormap = [[0 0 0 0.01 1 1 1 0.01 0 0 0 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 2,
particlelifespread = 0,
particlesize = 15,
particlesizespread = 0,
particlespeed = 0,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[exp00_8]],
},
},
},
["ingeborg_ani"] = {
frame1 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 1,
explosiongenerator = [[custom:INGEBORG_1]],
pos = [[0, 5, 0]],
},
},
frame10 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 10,
explosiongenerator = [[custom:INGEBORG_10]],
pos = [[0, 5, 0]],
},
},
frame2 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 2,
explosiongenerator = [[custom:INGEBORG_2]],
pos = [[0, 5, 0]],
},
},
frame3 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 3,
explosiongenerator = [[custom:INGEBORG_3]],
pos = [[0, 5, 0]],
},
},
frame4 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 4,
explosiongenerator = [[custom:INGEBORG_4]],
pos = [[0, 5, 0]],
},
},
frame5 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 5,
explosiongenerator = [[custom:INGEBORG_5]],
pos = [[0, 5, 0]],
},
},
frame6 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 6,
explosiongenerator = [[custom:INGEBORG_6]],
pos = [[0, 5, 0]],
},
},
frame7 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 7,
explosiongenerator = [[custom:INGEBORG_7]],
pos = [[0, 5, 0]],
},
},
frame8 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 8,
explosiongenerator = [[custom:INGEBORG_8]],
pos = [[0, 5, 0]],
},
},
frame9 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 9,
explosiongenerator = [[custom:INGEBORG_9]],
pos = [[0, 5, 0]],
},
},
},
["ingeborg_5"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
alwaysvisible = true,
colormap = [[0 0 0 0.01 1 1 1 0.01 0 0 0 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 2,
particlelifespread = 0,
particlesize = 15,
particlesizespread = 0,
particlespeed = 0,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[exp00_5]],
},
},
},
["ingeborg_10"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
alwaysvisible = true,
colormap = [[0 0 0 0.01 1 1 1 0.01 0 0 0 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 2,
particlelifespread = 0,
particlesize = 15,
particlesizespread = 0,
particlespeed = 0,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[exp00_10]],
},
},
},
["ingeborg_6"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
alwaysvisible = true,
colormap = [[0 0 0 0.01 1 1 1 0.01 0 0 0 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 2,
particlelifespread = 0,
particlesize = 15,
particlesizespread = 0,
particlespeed = 0,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[exp00_6]],
},
},
},
["ingeborg"] = {
animation = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 0,
explosiongenerator = [[custom:INGEBORG_ANI]],
pos = [[0, 0, 0]],
},
},
pikes = {
air = true,
class = [[explspike]],
count = 15,
ground = true,
water = true,
properties = {
alpha = 0.8,
alphadecay = 0.2,
color = [[1.0,0.7,0.5]],
dir = [[-15 r30,-15 r30,-15 r30]],
length = 15,
width = 3,
},
},
sparks = {
air = true,
class = [[CSimpleParticleSystem]],
count = 2,
ground = true,
water = true,
properties = {
airdrag = 0.97,
alwaysvisible = true,
colormap = [[1 1 0 0.01 1 0.7 0.5 0.01 0 0 0 0.01]],
directional = true,
emitrot = 0,
emitrotspread = 80,
emitvector = [[0, 1, 0]],
gravity = [[0, -0.4, 0]],
numparticles = 20,
particlelife = 7.5,
particlelifespread = 0,
particlesize = 1,
particlesizespread = 2.5,
particlespeed = 3,
particlespeedspread = 2,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[plasma]],
},
},
},
["ingeborg_1"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
alwaysvisible = true,
colormap = [[0 0 0 0.01 1 1 1 0.01 0 0 0 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 2,
particlelifespread = 0,
particlesize = 15,
particlesizespread = 0,
particlespeed = 0,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[exp00_1]],
},
},
},
["ingeborg_4"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
alwaysvisible = true,
colormap = [[0 0 0 0.01 1 1 1 0.01 0 0 0 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 2,
particlelifespread = 0,
particlesize = 15,
particlesizespread = 0,
particlespeed = 0,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[exp00_4]],
},
},
},
}
| gpl-2.0 |
jucor/lua-sci | dist/_gamma.lua | 1 | 3270 | --------------------------------------------------------------------------------
-- Gamma statistical distribution.
--
-- Copyright (C) 2011-2013 Stefano Peluchetti. All rights reserved.
--
-- Features, documention and more: http://www.scilua.org .
--
-- This file is part of the SciLua library, which is released under the MIT
-- license: full text in file LICENSE.TXT in the library's root folder.
--------------------------------------------------------------------------------
local xsys = require "xsys"
local ffi = require "ffi"
local math = require "sci.math"
local normd = require "sci.dist._normal"
local expod = require "sci.dist._exponential"
local M = {}
local err, chk = xsys.handlers("sci.dist")
local exp, log, sqrt, min, gamma, logabsgamma, max, ceil = xsys.from(math,
"exp, log, sqrt, min, gamma, logabsgamma, max, ceil")
local gamm_mt, gamm_ct = {}
gamm_mt.__index = gamm_mt
function gamm_mt:range()
return 0, math.huge
end
function gamm_mt:pdf(x)
if x < 0 then return 0 end
local a, b = self._a, self._b
return b^a * x^(a - 1) * exp(-b*x) / gamma(a)
end
function gamm_mt:logpdf(x)
if x < 0 then return -math.huge end
local a, b = self._a, self._b
return a*log(b) - logabsgamma(a) + (a - 1)*log(x) - b*x
end
function gamm_mt:mean()
return self._a/self._b
end
function gamm_mt:variance()
return self._a/self._b^2
end
local nd01 = normd.normal(0, 1)
-- Based on Marsaglia-Tsang method, valid for a >= 1, see:
-- http://www.cparity.com/projects/AcmClassification/samples/358414.pdf .
-- PERF: not worth checking for v <= 0 separately.
local function sample(a, b, rng)
local d = a - 1/3
local c = 1/sqrt(9*d)
do -- PERF: avoid (>95% of the time) problematic loop below with this:
local x = nd01:sample(rng)
local v = (1 + c*x)^3
local u = rng:sample()
if min(v, 1 - 0.0331*x^4 - u) > 0 -- Squeeze, around 92% of the time.
or min(v, -log(u) + 0.5*x^2 + d*(1 - v + log(v))) > 0 then
return v*d/b -- v*d ~ gamma(a), scaling: v*d/b ~ gamma(a, b).
end
end
-- PERF: better this than 'repeat until' alternative, as it allows to return
-- PERF: directly from whithin the loop:
while true do
local x = nd01:sample(rng)
local v = (1 + c*x)^3
-- PERF: squeeze step not worth here.
if min(v, -log(rng:sample()) + 0.5*x^2 + d*(1 - v + log(v))) > 0 then
return v*d/b -- v*d ~ gamma(a), scaling: v*d/b ~ gamma(a, b).
end
end
end
local sample_disp = {
[false] = function(a, b, rng)
return sample(a, b, rng)
end,
[true] = function(a, b, rng)
local y = sample(a + 1, b, rng)
return rng:sample()^(1/a)*y
end,
}
M._sample_disp = sample_disp
-- TODO: Assert prng!
function gamm_mt:sample(rng)
return sample_disp[self._i](self._a, self._b, rng)
end
function gamm_mt:copy()
return gamm_ct(self)
end
gamm_ct = ffi.metatype("struct { double _a; double _b; bool _i; }", gamm_mt)
function M.gamma(alpha, beta)
alpha = alpha or 1
beta = beta or 1
chk(alpha > 0 and beta > 0, "constraint",
"alpha and beta must be positive, alpha=", alpha, ", beta=", beta)
return gamm_ct(alpha, beta, alpha < 1)
end
return M | mit |
mattyx14/otxserver | data/monster/mammals/enraged_squirrel.lua | 2 | 1900 | local mType = Game.createMonsterType("Enraged Squirrel")
local monster = {}
monster.description = "an enraged squirrel"
monster.experience = 15
monster.outfit = {
lookType = 274,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.health = 35
monster.maxHealth = 35
monster.race = "blood"
monster.corpse = 276
monster.speed = 300
monster.manaCost = 220
monster.changeTarget = {
interval = 4000,
chance = 0
}
monster.strategiesTarget = {
nearest = 100,
}
monster.flags = {
summonable = true,
attackable = true,
hostile = true,
convinceable = true,
pushable = true,
rewardBoss = false,
illusionable = true,
canPushItems = false,
canPushCreatures = false,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 2,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "Chchch", yell = false}
}
monster.loot = {
{id = 836, chance = 2680} -- walnut
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, skill = 10, attack = 10}
}
monster.defenses = {
defense = 5,
armor = 5
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = 0},
{type = COMBAT_EARTHDAMAGE, percent = 0},
{type = COMBAT_FIREDAMAGE, percent = 0},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = false},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
mattyx14/otxserver | data/monster/quests/dark_trails/death_priest_shargon.lua | 2 | 3195 | local mType = Game.createMonsterType("Death Priest Shargon")
local monster = {}
monster.description = "Death Priest Shargon"
monster.experience = 20000
monster.outfit = {
lookType = 278,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 3,
lookMount = 0
}
monster.health = 65000
monster.maxHealth = 65000
monster.race = "blood"
monster.corpse = 21123
monster.speed = 340
monster.manaCost = 0
monster.changeTarget = {
interval = 5000,
chance = 8
}
monster.strategiesTarget = {
nearest = 70,
health = 10,
damage = 10,
random = 10,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = true,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.events = {
"DeathPriestShargonDeath"
}
monster.light = {
level = 0,
color = 0
}
monster.summon = {
maxSummons = 2,
summons = {
{name = "Lesser Death Minion", chance = 30, interval = 2000, count = 2},
{name = "Superior Death Minion", chance = 30, interval = 2000, count = 2},
{name = "Greater Death Minion", chance = 30, interval = 2000, count = 2}
}
}
monster.voices = {
interval = 5000,
chance = 10,
}
monster.loot = {
{id = 3031, chance = 100000, maxCount = 99}, -- gold coin
{id = 239, chance = 100000, maxCount = 3}, -- great health potion
{id = 3069, chance = 100000}, -- necrotic rod
{id = 3035, chance = 100000, maxCount = 13}, -- platinum coin
{id = 238, chance = 10000, maxCount = 4}, -- great mana potion
{id = 9058, chance = 25000}, -- gold ingot
{id = 9056, chance = 9090}, -- black skull
{id = 8531, chance = 9090} -- blood goblet
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, skill = 200, attack = 150},
{name ="combat", interval = 2000, chance = 12, type = COMBAT_DEATHDAMAGE, minDamage = 0, maxDamage = -660, range = 7, radius = 6, shootEffect = CONST_ANI_DEATH, effect = CONST_ME_MORTAREA, target = false},
{name ="combat", interval = 2000, chance = 18, type = COMBAT_HOLYDAMAGE, minDamage = -350, maxDamage = -1000, length = 6, spread = 2, effect = CONST_ME_PURPLEENERGY, target = false}
}
monster.defenses = {
defense = 30,
armor = 25,
{name ="combat", interval = 2000, chance = 20, type = COMBAT_HEALING, minDamage = 0, maxDamage = 699, effect = CONST_ME_MAGIC_BLUE, target = false}
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = 0},
{type = COMBAT_EARTHDAMAGE, percent = 0},
{type = COMBAT_FIREDAMAGE, percent = 0},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 100}
}
monster.immunities = {
{type = "paralyze", condition = true},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
mattyx14/otxserver | data/monster/quests/dangerous_depth/bosses/the_duke_of_the_depths.lua | 2 | 4796 | local mType = Game.createMonsterType("The Duke Of The Depths")
local monster = {}
monster.description = "The Duke Of The Depths"
monster.experience = 40000
monster.outfit = {
lookType = 1047,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.health = 50000
monster.maxHealth = 50000
monster.race = "blood"
monster.corpse = 27641
monster.speed = 270
monster.manaCost = 0
monster.changeTarget = {
interval = 5000,
chance = 50
}
monster.strategiesTarget = {
nearest = 70,
health = 10,
damage = 10,
random = 10,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = true,
illusionable = false,
canPushItems = true,
canPushCreatures = true,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = true,
canWalkOnFire = true,
canWalkOnPoison = true
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
}
monster.loot = {
{id = 3035, chance = 67610, maxCount = 58}, -- platinum coin
{id = 3043, chance = 67610}, -- crystal coin
{id = 16119, chance = 14710, maxCount = 4}, -- blue crystal shard
{id = 3032, chance = 13160, maxCount = 12}, -- small emerald
{id = 9057, chance = 11480, maxCount = 12}, -- small topaz
{id = 3033, chance = 14520, maxCount = 12}, -- small amethyst
{id = 238, chance = 14520, maxCount = 18}, -- great mana potion
{id = 3028, chance = 14520, maxCount = 2}, -- small diamond
{id = 3030, chance = 14520, maxCount = 12}, -- small ruby
{id = 239, chance = 14520, maxCount = 8}, -- great health potion
{id = 7642, chance = 14520, maxCount = 10}, -- great spirit potion
{id = 7643, chance = 14520, maxCount = 8}, -- ultimate health potion
{id = 7440, chance = 10060}, -- mastermind potion
{id = 3039, chance = 14520}, -- red gem
{id = 3037, chance = 14520}, -- yellow gem
{id = 27619, chance = 10000}, -- giant tentacle
{id = 8900, chance = 17230}, -- heavily rusted shield
{id = 5892, chance = 14520}, -- huge chunk of crude iron
{id = 3071, chance = 14520}, -- wand of inferno
{id = 3320, chance = 15810}, -- fire axe
{id = 3280, chance = 14520}, -- fire sword
{id = 811, chance = 14520}, -- terra mantle
{id = 11454, chance = 14520}, -- luminous orb
{id = 3081, chance = 14520}, -- stone skin amulet
{id = 8908, chance = 14520}, -- slightly rusted helmet
{id = 5904, chance = 14520}, -- magic sulphur
{id = 27657, chance = 1000}, -- crude wood planks
{id = 27651, chance = 600}, -- gnome sword
{id = 27649, chance = 510}, -- gnome legs
{id = 27650, chance = 560}, -- gnome shield
{id = 22721, chance = 580}, -- gold token
{id = 27526, chance = 520}, -- mallet pommel
{id = 27648, chance = 400} -- gnome armor
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -800},
{name ="combat", interval = 2000, chance = 15, type = COMBAT_FIREDAMAGE, minDamage = 0, maxDamage = -1000, range = 3, length = 6, spread = 8, effect = CONST_ME_FIREAREA, target = false},
{name ="combat", interval = 2000, chance = 20, type = COMBAT_FIREDAMAGE, minDamage = 0, maxDamage = -1000, range = 3, length = 9, spread = 4, effect = CONST_ME_HITBYFIRE, target = false},
{name ="combat", interval = 2000, chance = 15, type = COMBAT_PHYSICALDAMAGE, minDamage = -135, maxDamage = -1000, radius = 2, effect = CONST_ME_EXPLOSIONAREA, target = false},
{name ="combat", interval = 2000, chance = 15, type = COMBAT_PHYSICALDAMAGE, minDamage = 0, maxDamage = -1000, radius = 8, effect = CONST_ME_HITAREA, target = false}
}
monster.defenses = {
defense = 40,
armor = 40
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 60},
{type = COMBAT_ENERGYDAMAGE, percent = 60},
{type = COMBAT_EARTHDAMAGE, percent = 60},
{type = COMBAT_FIREDAMAGE, percent = 100},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 60},
{type = COMBAT_HOLYDAMAGE , percent = 60},
{type = COMBAT_DEATHDAMAGE , percent = 60}
}
monster.immunities = {
{type = "paralyze", condition = true},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
monster.heals = {
{type = COMBAT_FIREDAMAGE, percent = 100},
}
mType.onThink = function(monster, interval)
end
mType.onAppear = function(monster, creature)
if monster:getType():isRewardBoss() then
monster:setReward(true)
end
end
mType.onDisappear = function(monster, creature)
end
mType.onMove = function(monster, creature, fromPosition, toPosition)
end
mType.onSay = function(monster, creature, type, message)
end
mType:register(monster)
| gpl-2.0 |
nitheeshkl/kln_awesome | awesome_3.4/vicious/hddtemp.lua | 1 | 1084 | ---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2009, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- {{{ Grab environment
local tonumber = tonumber
local io = { popen = io.popen }
local setmetatable = setmetatable
local string = { gmatch = string.gmatch }
-- }}}
-- Hddtemp: provides hard drive temperatures using the hddtemp daemon
module("vicious.hddtemp")
-- {{{ HDD Temperature widget type
local function worker(format, port)
-- Fallback to default hddtemp port
if port == nil then port = 7634 end
-- Get info from the hddtemp daemon
local f = io.popen("curl --connect-timeout 1 -fsm 3 telnet://127.0.0.1:" .. port)
local hdd_temp = {}
for line in f:lines() do
for disk, temp in string.gmatch(line, "|([%/%a%d]+)|.-|([%d]+)|[CF]+|")
do
hdd_temp["{"..disk.."}"] = tonumber(temp)
end
end
f:close()
return hdd_temp
end
-- }}}
setmetatable(_M, { __call = function(_, ...) return worker(...) end })
| gpl-2.0 |
jucor/lua-sci | dist/_lognormal.lua | 1 | 1814 | --------------------------------------------------------------------------------
-- Lognormal statistical distribution.
--
-- Copyright (C) 2011-2013 Stefano Peluchetti. All rights reserved.
--
-- Features, documention and more: http://www.scilua.org .
--
-- This file is part of the SciLua library, which is released under the MIT
-- license: full text in file LICENSE.TXT in the library's root folder.
--------------------------------------------------------------------------------
local xsys = require "xsys"
local ffi = require "ffi"
local normd = require "sci.dist._normal"
local M = {}
local err, chk = xsys.handlers("sci.dist")
local exp, log, sqrt, pi = xsys.from(math, "exp, log, sqrt, pi")
local logn_mt, logn_ct = {}
logn_mt.__index = logn_mt
function logn_mt:range()
return 0, math.huge
end
function logn_mt:pdf(x)
if x < 0 then return 0 end
local mu, sigma = self._mu, self._sigma
return exp(-(log(x) - mu)^2/(2*sigma^2)) / (x*sqrt(2*pi)*sigma)
end
function logn_mt:logpdf(x)
if x < 0 then return -math.huge end
local mu, sigma = self._mu, self._sigma
return -(log(x) - mu)^2/(2*sigma^2) - log(x*sqrt(2*pi)*sigma)
end
function logn_mt:mean()
return exp(self._mu + 0.5*self._sigma^2)
end
function logn_mt:variance()
return (exp(self._sigma^2) - 1)*exp(2*self._mu + self._sigma^2)
end
local sample = normd._normal_mt.sample
function logn_mt:sample(rng)
return exp(sample(self, rng))
end
function logn_mt:copy()
return logn_ct(self)
end
logn_ct = ffi.metatype("struct { double _mu; double _sigma; }", logn_mt)
function M.lognormal(mu, sigma)
mu = mu or 0
sigma = sigma or 1
chk(sigma > 0, "constraint", "sigma must be positive, sigma=", sigma)
return logn_ct(mu, sigma)
end
return M | mit |
black123456789/man | plugins/inpm.lua | 59 | 3138 | do
local function pairsByKeys (t, f)
local a = {}
for n in pairs(t) do table.insert(a, n) end
table.sort(a, f)
local i = 0 -- iterator variable
local iter = function () -- iterator function
i = i + 1
if a[i] == nil then return nil
else return a[i], t[a[i]]
end
end
return iter
end
local function chat_list(msg)
local data = load_data(_config.moderation.data)
local groups = 'groups'
if not data[tostring(groups)] then
return 'No groups at the moment'
end
local message = 'List of Groups:\n*Use /join (ID) to join*\n\n '
for k,v in pairs(data[tostring(groups)]) do
local settings = data[tostring(v)]['settings']
for m,n in pairsByKeys(settings) do
if m == 'set_name' then
name = n
end
end
message = message .. '👥 '.. name .. ' (ID: ' .. v .. ')\n\n '
end
local file = io.open("./groups/lists/listed_groups.txt", "w")
file:write(message)
file:flush()
file:close()
return message
end
local function run(msg, matches)
if msg.to.type ~= 'chat' or is_sudo(msg) or is_admin(msg) and is_realm(msg) then
local data = load_data(_config.moderation.data)
if matches[1] == 'join' and data[tostring(matches[2])] then
if is_banned(msg.from.id, matches[2]) then
return 'You are banned.'
end
if is_gbanned(msg.from.id) then
return 'You are globally banned.'
end
if data[tostring(matches[2])]['settings']['lock_member'] == 'yes' and not is_owner2(msg.from.id, matches[2]) then
return 'Group is private.'
end
local chat_id = "chat#id"..matches[2]
local user_id = "user#id"..msg.from.id
chat_add_user(chat_id, user_id, ok_cb, false)
local group_name = data[tostring(matches[2])]['settings']['set_name']
return "Added you to chat:\n\n👥"..group_name.." (ID:"..matches[2]..")"
elseif matches[1] == 'join' and not data[tostring(matches[2])] then
return "Chat not found."
end
if matches[1] == 'chats'then
if is_admin(msg) and msg.to.type == 'chat' then
return chat_list(msg)
elseif msg.to.type ~= 'chat' then
return chat_list(msg)
end
end
if matches[1] == 'chatlist'then
if is_admin(msg) and msg.to.type == 'chat' then
send_document("chat#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false)
elseif msg.to.type ~= 'chat' then
send_document("user#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false)
end
end
end
end
return {
patterns = {
"^[/!](chats)$",
"^[/!](chatlist)$",
"^[/!](join) (.*)$",
"^[/!](kickme) (.*)$",
"^!!tgservice (chat_add_user)$"
},
run = run,
}
end
--Copyright; @behroozyaghi
--Persian Translate; @behroozyaghi
--ch : @nod32team
--کپی بدون ذکر منبع حرام است
| gpl-2.0 |
mnemnion/loon | src/mods/peg/ast-node.lua | 1 | 6708 | --AST tools
local lpeg = require "lpeg"
local clu = require "clu/prelude"
local ansi = clu.ansi
local walker = require "peg/walker"
local Forest = require "peg/forest"
local cyan = tostring(ansi.cyan)
local blue = tostring(ansi.blue)
local magenta = tostring(ansi.magenta)
local clear = tostring(ansi.clear)
local green = tostring(ansi.green)
local red = tostring(ansi.red)
local grey = tostring(ansi.dim)..tostring(ansi.white)
local function root(node)
if node.parent() == node then
return node
else
return root(node.parent())
end
end
local function ast_range(node)
local root = node:root()
local first, last, _ = root.index(node)
return root.index, first, last
end
local c = { id = magenta,
range = grey,
str = red,
num = blue,
span = clear,
val = green,}
local function node_pr(node, depth, str)
if node.isnode then
local phrase = ""
local prefix = (" "):rep(depth-1)
if node.isrecursive then
phrase = red.."*"..prefix:sub(1,-2)..clear
else
phrase = prefix
end
if node.last then
phrase = phrase..
-- blue,node.parent().id," ",
c.id..node.id.." "..
c.range..node.first..
"-"..c.range..node.last..clear.."\n"
end
if node.val then
phrase = phrase..prefix..'"'..c.val..node.val..clear..'"'.."\n"
end
if node.tok then
phrase = phrase..prefix..tostring(node.tok)
end
for i,v in ipairs(node) do
--[[ fixing this is off the critical path.
if type(v) == "string" then
phrase = phrase..prefix..c.num..i..clear.." "..'"'..c.str..v..clear..'"'.."\n"
end
--]]
if type(v) == "table" and v.span and not node.val then
phrase = phrase..prefix..c.span..str:sub(v[1],v[2])..clear.."\n"
end
end
return phrase
end
end
local function ast_tostring(ast)
-- now we can print an AST.
local ndx, first, last = ast:range()
local og = ndx(1).str
local phrase = ""
for i= first,last do
local node,_,depth = ndx(i)
phrase = phrase..node_pr(node,depth,og)
end
return phrase
end
local function ast_pr(ast)
io.write(ast_tostring(ast))
end
local function deepcopy(orig) -- from luafun
local orig_type = type(orig)
local copy
if orig_type == 'table' and orig.isnode then
copy = setmetatable({},getmetatable(orig))
for orig_key, orig_value in next, orig, nil do
copy[deepcopy(orig_key)] = deepcopy(orig_value)
end
elseif orig_type ~= "function" then
copy = orig
end
return copy
end
local function ast_copy(ast)
local clone = deepcopy(ast)
return walker.walk_ast(clone)
end
local forest = {}
local function select_node (ast,pred)
local catch = setmetatable({},Forest)
local ndx, first, last = ast:range()
if type(pred) == "string" then
for i = first, last do
if ndx[i].id == pred then
catch[#catch+1] = ndx[i]
end
end
elseif type(pred) == "function" then
for i = first, last do
if pred(ndx[i]) then
catch[#catch+1] = ndx[i]
end
end
end
return catch
end
function forest.select(ast,id)
local catch = setmetatable({},Forest)
for i = 1, #ast do
local nursery = select_node(ast[i],id)
for j = 1, #nursery do
catch[#catch+1] = nursery[1]
end
end
return catch
end
local function select_rule(ast,id)
local catch = {}
if type(ast) == "table" and ast.isnode then
catch = select_node(ast,id)
elseif type(ast) == "table" and ast.isforest then
catch = forest.select(ast,id)
else error "select: First argument must be of type Node or Forest" end
return catch
end
local function select_with_node(ast,pred)
local catch = setmetatable({},Forest)
local ndx, first, last = ast:range()
if type(pred) == "string" then
for i = first, last do
if ndx[i].id == pred then
catch[#catch+1] = ndx[first]
end
end
elseif type(pred) == "function" then
for i = first, last do
if pred(ndx[i]) then
catch[#catch+1] = ndx[first]
end
end
end
return catch
end
function forest.select_with (ast,id)
local catch = setmetatable({},Forest)
for i = 1, #ast do
local nursery = select_with_node(ast[i],id)
for j = 1, #nursery do
catch[#catch+1] = nursery[1]
end
end
return catch
end
local function select_with(ast,id)
local catch = {}
if type(ast) == "table" and ast.isnode then
catch = select_with_node(ast,id)
elseif type(ast) == "table" and ast.isforest then
catch = forest.select_with(ast,id)
else
error "with: First argument must be of type Node or Forest"
end
return catch
end
-- add: select_without
local function pick_tostring(table)
local phrase = ""
for i,v in ipairs(table) do
phrase = phrase..tostring(v)
end
return phrase
end
local function toks_tostring(table)
local phrase = "["
for i,v in ipairs(table) do
phrase = phrase..
grey.."'"..clear..
tostring(v):gsub("\n",blue.."\\n"..clear)..
grey.."'"..red..","..clear
end
return phrase.."]".."\n"
end
local function tokenize(ast)
if ast.tok then return ast.tok end
local ndx, first, last = ast:range()
local tokens = setmetatable({},{__tostring = toks_tostring})
for i = first, last do -- reap leaves
if ndx[i].val then
tokens[#tokens+1] = ndx[i].val
ndx[i].val = nil
elseif ndx[i].tok then
for j = 1, #ndx[i].tok do
tokens[#tokens+1] = ndx[i].tok[j]
end
ndx[i].tok = nil
end
end
for i,v in ipairs(ast) do -- destroy children
ast[i] = nil
end
ast.tok = tokens
walker.walk_ast(ast:root()) -- this should be triggered by
-- next index operation
return tokens
end
local function flatten(ast)
local phrase = ""
ast:tokens()
if ast.tok then
for i = 1, #ast.tok do
phrase = phrase..ast.tok[i]
end
else error "auto-tokenizing has failed"
end
ast.flat = phrase
return phrase
end
function forest.pick(ast,id)
-- similar to select, :pick returns a bare vector of Forests,
-- rather than a flattened Forest.
local catch = setmetatable({},{["__tostring"] = pick_tostring})
for i = 1, #ast do
catch[#catch+1] = select_node(ast[i],id)
end
return catch
end
Forest["select"] = select_rule
Forest["with"] = forest.select_with
Forest["pick"] = forest.pick
local function parse(grammar, str)
if grammar == nil then
error "grammar failed to generate"
end
local ast = lpeg.match(grammar,str)
if type(ast) == "table" then
ast.str = str
ast.grammar = grammar
return walker.walk_ast(ast)
else
error "lpeg did not match grammar"
end
end
return {
select = select_rule ,
__select_with_node = select_with_node,
__select_node = select_node,
with = select_with ,
tostring = ast_tostring,
pr = ast_pr,
lift = walker.lift,
root = root,
tokenize = tokenize,
flatten = flatten,
range= ast_range,
copy = ast_copy,
walk = walker.walk_ast,
parse = parse
} | mit |
EvilHero90/tfstemp | data/spells/scripts/party/train.lua | 15 | 1869 | local combat = createCombatObject()
local area = createCombatArea(AREA_CROSS5X5)
setCombatArea(combat, area)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_SUBID, 1)
setConditionParam(condition, CONDITION_PARAM_BUFF_SPELL, 1)
setConditionParam(condition, CONDITION_PARAM_TICKS, 2 * 60 * 1000)
setConditionParam(condition, CONDITION_PARAM_SKILL_MELEE, 3)
setConditionParam(condition, CONDITION_PARAM_SKILL_DISTANCE, 3)
local baseMana = 60
function onCastSpell(cid, var)
local pos = getCreaturePosition(cid)
local membersList = getPartyMembers(cid)
if(membersList == nil or type(membersList) ~= 'table' or #membersList <= 1) then
doPlayerSendCancel(cid, "No party members in range.")
doSendMagicEffect(pos, CONST_ME_POFF)
return LUA_ERROR
end
local affectedList = {}
for _, pid in ipairs(membersList) do
if(getDistanceBetween(getCreaturePosition(pid), pos) <= 36) then
table.insert(affectedList, pid)
end
end
local tmp = #affectedList
if(tmp <= 1) then
doPlayerSendCancel(cid, "No party members in range.")
doSendMagicEffect(pos, CONST_ME_POFF)
return LUA_ERROR
end
local mana = math.ceil((0.9 ^ (tmp - 1) * baseMana) * tmp)
if(getPlayerMana(cid) < mana) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHMANA)
doSendMagicEffect(pos, CONST_ME_POFF)
return LUA_ERROR
end
if(doCombat(cid, combat, var) ~= LUA_NO_ERROR) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
doSendMagicEffect(pos, CONST_ME_POFF)
return LUA_ERROR
end
doPlayerAddMana(cid, -(mana - baseMana), FALSE)
doPlayerAddManaSpent(cid, (mana - baseMana))
for _, pid in ipairs(affectedList) do
doAddCondition(pid, condition)
end
return LUA_NO_ERROR
end
| gpl-2.0 |
christopherjwang/rackspace-monitoring-agent | runners/check_runner.lua | 3 | 2786 | --[[
Copyright 2015 Rackspace
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 async = require('async')
local Emitter = require('core').Emitter
local checks = require('../check')
local CheckRunner = Emitter:extend()
function CheckRunner:initialize(checkType)
self._checkType = checkType
self._cr = nil
self._details = nil
end
function CheckRunner:getDetails(callback)
local ENV_PREFIX = 'RAX_'
local details = {}
self._id = process.env[ENV_PREFIX .. 'CHECK_ID']
self._period = process.env[ENV_PREFIX .. 'CHECK_PERIOD']
if self._period == nil then
self._period = 30
else
self._period = tonumber(self._period)
end
for k,v in pairs(process.env) do
local found, offset = k:find('^' .. ENV_PREFIX ..'DETAILS_')
if found then
local nk = k:sub(offset + 1)
details[nk:lower()] = v
end
end
self._details = details
callback(nil)
end
function CheckRunner:run(callback)
local checkParams = {
period = self._period,
id = self._id,
type = self._checkType,
details = self._details,
}
local check = checks.create(checkParams)
if not check then
p(checkParams)
print('Invalid Check Parameters')
process:exit(1)
end
check:_runCheckInChild(function(cr)
self._cr = cr
callback(nil)
end)
end
function CheckRunner:reportError(err, callback)
local out = ''
if self._cr and self._cr:getState() ~= nil then
-- Hrm... we have an error, but check already failed, fall through with the 'upper' error?
out = self._cr:serializeAsPluginOutput()
else
out = out + 'state unavailable\n'
out = out + 'status err ' .. tostring(err) .. '\n'
end
process.stdout:write(out)
callback()
end
function CheckRunner:report(callback)
local out = self._cr:serializeAsPluginOutput()
process.stdout:write(out)
process.nextTick(callback)
end
local function run(argv)
local checkType = argv.x
local cr = CheckRunner:new(checkType)
async.series({
function(callback)
cr:getDetails(callback)
end,
function(callback)
cr:run(callback)
end,
},
function (err)
if err then
cr:reportError(err, function ()
process:exit(1)
end)
else
cr:report(function ()
process:exit(0)
end)
end
end)
end
return {
run = run
}
| apache-2.0 |
focusworld/nn | bot/utils.lua | 473 | 24167 | URL = require "socket.url"
http = require "socket.http"
https = require "ssl.https"
ltn12 = require "ltn12"
serpent = require "serpent"
feedparser = require "feedparser"
json = (loadfile "./libs/JSON.lua")()
mimetype = (loadfile "./libs/mimetype.lua")()
redis = (loadfile "./libs/redis.lua")()
JSON = (loadfile "./libs/dkjson.lua")()
http.TIMEOUT = 10
function get_receiver(msg)
if msg.to.type == 'user' then
return 'user#id'..msg.from.id
end
if msg.to.type == 'chat' then
return 'chat#id'..msg.to.id
end
if msg.to.type == 'encr_chat' then
return msg.to.print_name
end
end
function is_chat_msg( msg )
if msg.to.type == 'chat' then
return true
end
return false
end
function string.random(length)
local str = "";
for i = 1, length do
math.random(97, 122)
str = str..string.char(math.random(97, 122));
end
return str;
end
function string:split(sep)
local sep, fields = sep or ":", {}
local pattern = string.format("([^%s]+)", sep)
self:gsub(pattern, function(c) fields[#fields+1] = c end)
return fields
end
-- DEPRECATED
function string.trim(s)
print("string.trim(s) is DEPRECATED use string:trim() instead")
return s:gsub("^%s*(.-)%s*$", "%1")
end
-- Removes spaces
function string:trim()
return self:gsub("^%s*(.-)%s*$", "%1")
end
function get_http_file_name(url, headers)
-- Eg: foo.var
local file_name = url:match("[^%w]+([%.%w]+)$")
-- Any delimited alphanumeric on the url
file_name = file_name or url:match("[^%w]+(%w+)[^%w]+$")
-- Random name, hope content-type works
file_name = file_name or str:random(5)
local content_type = headers["content-type"]
local extension = nil
if content_type then
extension = mimetype.get_mime_extension(content_type)
end
if extension then
file_name = file_name.."."..extension
end
local disposition = headers["content-disposition"]
if disposition then
-- attachment; filename=CodeCogsEqn.png
file_name = disposition:match('filename=([^;]+)') or file_name
end
return file_name
end
-- Saves file to /tmp/. If file_name isn't provided,
-- will get the text after the last "/" for filename
-- and content-type for extension
function download_to_file(url, file_name)
print("url to download: "..url)
local respbody = {}
local options = {
url = url,
sink = ltn12.sink.table(respbody),
redirect = true
}
-- nil, code, headers, status
local response = nil
if url:starts('https') then
options.redirect = false
response = {https.request(options)}
else
response = {http.request(options)}
end
local code = response[2]
local headers = response[3]
local status = response[4]
if code ~= 200 then return nil end
file_name = file_name or get_http_file_name(url, headers)
local file_path = "/tmp/"..file_name
print("Saved to: "..file_path)
file = io.open(file_path, "w+")
file:write(table.concat(respbody))
file:close()
return file_path
end
function vardump(value)
print(serpent.block(value, {comment=false}))
end
-- taken from http://stackoverflow.com/a/11130774/3163199
function scandir(directory)
local i, t, popen = 0, {}, io.popen
for filename in popen('ls -a "'..directory..'"'):lines() do
i = i + 1
t[i] = filename
end
return t
end
-- http://www.lua.org/manual/5.2/manual.html#pdf-io.popen
function run_command(str)
local cmd = io.popen(str)
local result = cmd:read('*all')
cmd:close()
return result
end
-- User has privileges
function is_sudo(msg)
local var = false
-- Check users id in config
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
-- Returns the name of the sender
function get_name(msg)
local name = msg.from.first_name
if name == nil then
name = msg.from.id
end
return name
end
-- Returns at table of lua files inside plugins
function plugins_names( )
local files = {}
for k, v in pairs(scandir("plugins")) do
-- Ends with .lua
if (v:match(".lua$")) then
table.insert(files, v)
end
end
return files
end
-- Function name explains what it does.
function file_exists(name)
local f = io.open(name,"r")
if f ~= nil then
io.close(f)
return true
else
return false
end
end
-- Save into file the data serialized for lua.
-- Set uglify true to minify the file.
function serialize_to_file(data, file, uglify)
file = io.open(file, 'w+')
local serialized
if not uglify then
serialized = serpent.block(data, {
comment = false,
name = '_'
})
else
serialized = serpent.dump(data)
end
file:write(serialized)
file:close()
end
-- Returns true if the string is empty
function string:isempty()
return self == nil or self == ''
end
-- Returns true if the string is blank
function string:isblank()
self = self:trim()
return self:isempty()
end
-- DEPRECATED!!!!!
function string.starts(String, Start)
print("string.starts(String, Start) is DEPRECATED use string:starts(text) instead")
return Start == string.sub(String,1,string.len(Start))
end
-- Returns true if String starts with Start
function string:starts(text)
return text == string.sub(self,1,string.len(text))
end
-- Send image to user and delete it when finished.
-- cb_function and cb_extra are optionals callback
function _send_photo(receiver, file_path, cb_function, cb_extra)
local cb_extra = {
file_path = file_path,
cb_function = cb_function,
cb_extra = cb_extra
}
-- Call to remove with optional callback
send_photo(receiver, file_path, cb_function, cb_extra)
end
-- Download the image and send to receiver, it will be deleted.
-- cb_function and cb_extra are optionals callback
function send_photo_from_url(receiver, url, cb_function, cb_extra)
-- If callback not provided
cb_function = cb_function or ok_cb
cb_extra = cb_extra or false
local file_path = download_to_file(url, false)
if not file_path then -- Error
local text = 'Error downloading the image'
send_msg(receiver, text, cb_function, cb_extra)
else
print("File path: "..file_path)
_send_photo(receiver, file_path, cb_function, cb_extra)
end
end
-- Same as send_photo_from_url but as callback function
function send_photo_from_url_callback(cb_extra, success, result)
local receiver = cb_extra.receiver
local url = cb_extra.url
local file_path = download_to_file(url, false)
if not file_path then -- Error
local text = 'Error downloading the image'
send_msg(receiver, text, ok_cb, false)
else
print("File path: "..file_path)
_send_photo(receiver, file_path, ok_cb, false)
end
end
-- Send multiple images asynchronous.
-- param urls must be a table.
function send_photos_from_url(receiver, urls)
local cb_extra = {
receiver = receiver,
urls = urls,
remove_path = nil
}
send_photos_from_url_callback(cb_extra)
end
-- Use send_photos_from_url.
-- This function might be difficult to understand.
function send_photos_from_url_callback(cb_extra, success, result)
-- cb_extra is a table containing receiver, urls and remove_path
local receiver = cb_extra.receiver
local urls = cb_extra.urls
local remove_path = cb_extra.remove_path
-- The previously image to remove
if remove_path ~= nil then
os.remove(remove_path)
print("Deleted: "..remove_path)
end
-- Nil or empty, exit case (no more urls)
if urls == nil or #urls == 0 then
return false
end
-- Take the head and remove from urls table
local head = table.remove(urls, 1)
local file_path = download_to_file(head, false)
local cb_extra = {
receiver = receiver,
urls = urls,
remove_path = file_path
}
-- Send first and postpone the others as callback
send_photo(receiver, file_path, send_photos_from_url_callback, cb_extra)
end
-- Callback to remove a file
function rmtmp_cb(cb_extra, success, result)
local file_path = cb_extra.file_path
local cb_function = cb_extra.cb_function or ok_cb
local cb_extra = cb_extra.cb_extra
if file_path ~= nil then
os.remove(file_path)
print("Deleted: "..file_path)
end
-- Finally call the callback
cb_function(cb_extra, success, result)
end
-- Send document to user and delete it when finished.
-- cb_function and cb_extra are optionals callback
function _send_document(receiver, file_path, cb_function, cb_extra)
local cb_extra = {
file_path = file_path,
cb_function = cb_function or ok_cb,
cb_extra = cb_extra or false
}
-- Call to remove with optional callback
send_document(receiver, file_path, rmtmp_cb, cb_extra)
end
-- Download the image and send to receiver, it will be deleted.
-- cb_function and cb_extra are optionals callback
function send_document_from_url(receiver, url, cb_function, cb_extra)
local file_path = download_to_file(url, false)
print("File path: "..file_path)
_send_document(receiver, file_path, cb_function, cb_extra)
end
-- Parameters in ?a=1&b=2 style
function format_http_params(params, is_get)
local str = ''
-- If is get add ? to the beginning
if is_get then str = '?' end
local first = true -- Frist param
for k,v in pairs (params) do
if v then -- nil value
if first then
first = false
str = str..k.. "="..v
else
str = str.."&"..k.. "="..v
end
end
end
return str
end
-- Check if user can use the plugin and warns user
-- Returns true if user was warned and false if not warned (is allowed)
function warns_user_not_allowed(plugin, msg)
if not user_allowed(plugin, msg) then
local text = 'This plugin requires privileged user'
local receiver = get_receiver(msg)
send_msg(receiver, text, ok_cb, false)
return true
else
return false
end
end
-- Check if user can use the plugin
function user_allowed(plugin, msg)
if plugin.privileged and not is_sudo(msg) then
return false
end
return true
end
function send_order_msg(destination, msgs)
local cb_extra = {
destination = destination,
msgs = msgs
}
send_order_msg_callback(cb_extra, true)
end
function send_order_msg_callback(cb_extra, success, result)
local destination = cb_extra.destination
local msgs = cb_extra.msgs
local file_path = cb_extra.file_path
if file_path ~= nil then
os.remove(file_path)
print("Deleted: " .. file_path)
end
if type(msgs) == 'string' then
send_large_msg(destination, msgs)
elseif type(msgs) ~= 'table' then
return
end
if #msgs < 1 then
return
end
local msg = table.remove(msgs, 1)
local new_cb_extra = {
destination = destination,
msgs = msgs
}
if type(msg) == 'string' then
send_msg(destination, msg, send_order_msg_callback, new_cb_extra)
elseif type(msg) == 'table' then
local typ = msg[1]
local nmsg = msg[2]
new_cb_extra.file_path = nmsg
if typ == 'document' then
send_document(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'image' or typ == 'photo' then
send_photo(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'audio' then
send_audio(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'video' then
send_video(destination, nmsg, send_order_msg_callback, new_cb_extra)
else
send_file(destination, nmsg, send_order_msg_callback, new_cb_extra)
end
end
end
-- Same as send_large_msg_callback but friendly params
function send_large_msg(destination, text)
local cb_extra = {
destination = destination,
text = text
}
send_large_msg_callback(cb_extra, true)
end
-- If text is longer than 4096 chars, send multiple msg.
-- https://core.telegram.org/method/messages.sendMessage
function send_large_msg_callback(cb_extra, success, result)
local text_max = 4096
local destination = cb_extra.destination
local text = cb_extra.text
local text_len = string.len(text)
local num_msg = math.ceil(text_len / text_max)
if num_msg <= 1 then
send_msg(destination, text, ok_cb, false)
else
local my_text = string.sub(text, 1, 4096)
local rest = string.sub(text, 4096, text_len)
local cb_extra = {
destination = destination,
text = rest
}
send_msg(destination, my_text, send_large_msg_callback, cb_extra)
end
end
-- Returns a table with matches or nil
function match_pattern(pattern, text, lower_case)
if text then
local matches = {}
if lower_case then
matches = { string.match(text:lower(), pattern) }
else
matches = { string.match(text, pattern) }
end
if next(matches) then
return matches
end
end
-- nil
end
-- Function to read data from files
function load_from_file(file, default_data)
local f = io.open(file, "r+")
-- If file doesn't exists
if f == nil then
-- Create a new empty table
default_data = default_data or {}
serialize_to_file(default_data, file)
print ('Created file', file)
else
print ('Data loaded from file', file)
f:close()
end
return loadfile (file)()
end
-- See http://stackoverflow.com/a/14899740
function unescape_html(str)
local map = {
["lt"] = "<",
["gt"] = ">",
["amp"] = "&",
["quot"] = '"',
["apos"] = "'"
}
new = string.gsub(str, '(&(#?x?)([%d%a]+);)', function(orig, n, s)
var = map[s] or n == "#" and string.char(s)
var = var or n == "#x" and string.char(tonumber(s,16))
var = var or orig
return var
end)
return new
end
--Check if this chat is realm or not
function is_realm(msg)
local var = false
local realms = 'realms'
local data = load_data(_config.moderation.data)
local chat = msg.to.id
if data[tostring(realms)] then
if data[tostring(realms)][tostring(msg.to.id)] then
var = true
end
return var
end
end
--Check if this chat is a group or not
function is_group(msg)
local var = false
local groups = 'groups'
local data = load_data(_config.moderation.data)
local chat = msg.to.id
if data[tostring(groups)] then
if data[tostring(groups)][tostring(msg.to.id)] then
var = true
end
return var
end
end
function savelog(group, logtxt)
local text = (os.date("[ %c ]=> "..logtxt.."\n \n"))
local file = io.open("./groups/logs/"..group.."log.txt", "a")
file:write(text)
file:close()
end
function user_print_name(user)
if user.print_name then
return user.print_name
end
local text = ''
if user.first_name then
text = user.last_name..' '
end
if user.lastname then
text = text..user.last_name
end
return text
end
--Check if user is the owner of that group or not
function is_owner(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['set_owner'] then
if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then
var = true
end
end
end
if data['admins'] then
if data['admins'][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
function is_owner2(user_id, group_id)
local var = false
local data = load_data(_config.moderation.data)
if data[tostring(group_id)] then
if data[tostring(group_id)]['set_owner'] then
if data[tostring(group_id)]['set_owner'] == tostring(user_id) then
var = true
end
end
end
if data['admins'] then
if data['admins'][tostring(user_id)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == user_id then
var = true
end
end
return var
end
--Check if user is admin or not
function is_admin(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
local admins = 'admins'
if data[tostring(admins)] then
if data[tostring(admins)][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
function is_admin2(user_id)
local var = false
local data = load_data(_config.moderation.data)
local user = user_id
local admins = 'admins'
if data[tostring(admins)] then
if data[tostring(admins)][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == user_id then
var = true
end
end
return var
end
--Check if user is the mod of that group or not
function is_momod(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['moderators'] then
if data[tostring(msg.to.id)]['moderators'][tostring(user)] then
var = true
end
end
end
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['set_owner'] then
if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then
var = true
end
end
end
if data['admins'] then
if data['admins'][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
function is_momod2(user_id, group_id)
local var = false
local data = load_data(_config.moderation.data)
local usert = user_id
if data[tostring(group_id)] then
if data[tostring(group_id)]['moderators'] then
if data[tostring(group_id)]['moderators'][tostring(usert)] then
var = true
end
end
end
if data[tostring(group_id)] then
if data[tostring(group_id)]['set_owner'] then
if data[tostring(group_id)]['set_owner'] == tostring(user_id) then
var = true
end
end
end
if data['admins'] then
if data['admins'][tostring(user_id)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == usert then
var = true
end
end
return var
end
-- Returns the name of the sender
function kick_user(user_id, chat_id)
if tonumber(user_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_owner2(user_id, chat_id) then -- Ignore admins
return
end
local chat = 'chat#id'..chat_id
local user = 'user#id'..user_id
chat_del_user(chat, user, ok_cb, true)
end
-- Ban
function ban_user(user_id, chat_id)
if tonumber(user_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_admin2(user_id) then -- Ignore admins
return
end
-- Save to redis
local hash = 'banned:'..chat_id
redis:sadd(hash, user_id)
-- Kick from chat
kick_user(user_id, chat_id)
end
-- Global ban
function banall_user(user_id)
if tonumber(user_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_admin2(user_id) then -- Ignore admins
return
end
-- Save to redis
local hash = 'gbanned'
redis:sadd(hash, user_id)
end
-- Global unban
function unbanall_user(user_id)
--Save on redis
local hash = 'gbanned'
redis:srem(hash, user_id)
end
-- Check if user_id is banned in chat_id or not
function is_banned(user_id, chat_id)
--Save on redis
local hash = 'banned:'..chat_id
local banned = redis:sismember(hash, user_id)
return banned or false
end
-- Check if user_id is globally banned or not
function is_gbanned(user_id)
--Save on redis
local hash = 'gbanned'
local banned = redis:sismember(hash, user_id)
return banned or false
end
-- Returns chat_id ban list
function ban_list(chat_id)
local hash = 'banned:'..chat_id
local list = redis:smembers(hash)
local text = "Ban list !\n\n"
for k,v in pairs(list) do
local user_info = redis:hgetall('user:'..v)
-- vardump(user_info)
if user_info then
if user_info.username then
user = '@'..user_info.username
elseif user_info.print_name and not user_info.username then
user = string.gsub(user_info.print_name, "_", " ")
else
user = ''
end
text = text..k.." - "..user.." ["..v.."]\n"
end
end
return text
end
-- Returns globally ban list
function banall_list()
local hash = 'gbanned'
local list = redis:smembers(hash)
local text = "global bans !\n\n"
for k,v in pairs(list) do
local user_info = redis:hgetall('user:'..v)
-- vardump(user_info)
if user_info then
if user_info.username then
user = '@'..user_info.username
elseif user_info.print_name and not user_info.username then
user = string.gsub(user_info.print_name, "_", " ")
else
user = ''
end
text = text..k.." - "..user.." ["..v.."]\n"
end
end
return text
end
-- /id by reply
function get_message_callback_id(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
send_large_msg(chat, result.from.id)
else
return 'Use This in Your Groups'
end
end
-- kick by reply for mods and owner
function Kick_by_reply(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot
return "I won't kick myself"
end
if is_momod2(result.from.id, result.to.id) then -- Ignore mods,owner,admin
return "you can't kick mods,owner and admins"
end
chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false)
else
return 'Use This in Your Groups'
end
end
-- Kick by reply for admins
function Kick_by_reply_admins(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot
return "I won't kick myself"
end
if is_admin2(result.from.id) then -- Ignore admins
return
end
chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false)
else
return 'Use This in Your Groups'
end
end
--Ban by reply for admins
function ban_by_reply(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot
return "I won't ban myself"
end
if is_momod2(result.from.id, result.to.id) then -- Ignore mods,owner,admin
return "you can't kick mods,owner and admins"
end
ban_user(result.from.id, result.to.id)
send_large_msg(chat, "User "..result.from.id.." Banned")
else
return 'Use This in Your Groups'
end
end
-- Ban by reply for admins
function ban_by_reply_admins(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot
return "I won't ban myself"
end
if is_admin2(result.from.id) then -- Ignore admins
return
end
ban_user(result.from.id, result.to.id)
send_large_msg(chat, "User "..result.from.id.." Banned")
else
return 'Use This in Your Groups'
end
end
-- Unban by reply
function unban_by_reply(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot
return "I won't unban myself"
end
send_large_msg(chat, "User "..result.from.id.." Unbanned")
-- Save on redis
local hash = 'banned:'..result.to.id
redis:srem(hash, result.from.id)
else
return 'Use This in Your Groups'
end
end
function banall_by_reply(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot
return "I won't banall myself"
end
if is_admin2(result.from.id) then -- Ignore admins
return
end
local name = user_print_name(result.from)
banall_user(result.from.id)
chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false)
send_large_msg(chat, "User "..name.."["..result.from.id.."] hammered")
else
return 'Use This in Your Groups'
end
end
| gpl-2.0 |
HeavenIsLost/cast | data/spells/scripts/attack/curse.lua | 27 | 1206 | local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_SMALLCLOUDS)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
local condition = createConditionObject(CONDITION_CURSED)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 1, 3000, -45)
addDamageCondition(condition, 1, 3000, -40)
addDamageCondition(condition, 1, 3000, -35)
addDamageCondition(condition, 1, 3000, -34)
addDamageCondition(condition, 2, 3000, -33)
addDamageCondition(condition, 2, 3000, -32)
addDamageCondition(condition, 2, 3000, -31)
addDamageCondition(condition, 2, 3000, -30)
addDamageCondition(condition, 3, 3000, -29)
addDamageCondition(condition, 3, 3000, -25)
addDamageCondition(condition, 3, 3000, -24)
addDamageCondition(condition, 4, 3000, -23)
addDamageCondition(condition, 4, 3000, -20)
addDamageCondition(condition, 5, 3000, -19)
addDamageCondition(condition, 5, 3000, -15)
addDamageCondition(condition, 6, 3000, -10)
addDamageCondition(condition, 10, 3000, -5)
setCombatCondition(combat, condition)
function onCastSpell(cid, var)
return doCombat(cid, combat, var)
end | gpl-2.0 |
garrysmodlua/wire | lua/entities/gmod_wire_keypad.lua | 3 | 6764 | AddCSLuaFile()
DEFINE_BASECLASS( "base_wire_entity" )
ENT.PrintName = "Wire Keypad"
if CLIENT then
local X = -50
local Y = -100
local W = 100
local H = 200
local KeyPos = {
{X+5 , Y+100 , 25, 25, -2.2, 3.45, 1.3 , 0 }, -- 1
{X+37.5, Y+100 , 25, 25, -0.6, 1.85, 1.3 , 0 }, -- 2
{X+70 , Y+100 , 25, 25, 1.0, 0.25, 1.3 , 0 }, -- 3
{X+5 , Y+132.5, 25, 25, -2.2, 3.45, 2.9 , -1.6}, -- 4
{X+37.5, Y+132.5, 25, 25, -0.6, 1.85, 2.9 , -1.6}, -- 5
{X+70 , Y+132.5, 25, 25, 1.0, 0.25, 2.9 , -1.6}, -- 6
{X+5 , Y+165 , 25, 25, -2.2, 3.45, 4.55, -3.3}, -- 7
{X+37.5, Y+165 , 25, 25, -0.6, 1.85, 4.55, -3.3}, -- 8
{X+70 , Y+165 , 25, 25, 1.0, 0.25, 4.55, -3.3}, -- 9
{X+5 , Y+ 67.5, 40, 25, -2.2, 4.25, -0.3 , 1.6}, -- abort
{X+55 , Y+ 67.5, 40, 25, 0.3, 1.65, -0.3 , 1.6}, -- ok
}
local fontdata = {
font = "Trebuchet",
weight = 400,
antialias = true,
additive = false
}
fontdata.size = 34 surface.CreateFont( "Trebuchet34", fontdata )
fontdata.size = 24 surface.CreateFont( "Trebuchet24", fontdata )
local highlight_key, highlight_until
function ENT:Draw()
self:DrawModel()
local Ply = LocalPlayer()
if (Ply:GetShootPos() - self:GetPos()):Length() > 750 then return end
local pos = self:GetPos() + (self:GetForward() * 1.1)
local ang = self:GetAngles()
local rot = Vector(-90, 90, 0)
ang:RotateAroundAxis(ang:Right(), rot.x)
ang:RotateAroundAxis(ang:Up(), rot.y)
ang:RotateAroundAxis(ang:Forward(), rot.z)
cam.Start3D2D(pos, ang, 0.05)
local trace = Ply:GetEyeTrace()
local pos = self:WorldToLocal(trace.HitPos)
surface.SetDrawColor(0, 0, 0, 255)
surface.DrawRect(X-5, Y-5, W+10, H+10)
surface.SetDrawColor(50, 75, 50, 255)
surface.DrawRect(X+5, Y+5, 90, 50)
for k,v in pairs(KeyPos) do
local text = k
local textx = v[1] + 9
local texty = v[2] + 4
local x = (pos.y - v[5]) / (v[5] + v[6])
local y = 1 - (pos.z + v[7]) / (v[7] + v[8])
local highlight_current_key = highlight_key == k and highlight_until >= CurTime()
if (k == 10) then
text = "ABORT"
textx = v[1] + 2
texty = v[2] + 4
surface.SetDrawColor(150, 25, 25, 255)
elseif (k == 11) then
text = "OK"
textx = v[1] + 12
texty = v[2] + 5
surface.SetDrawColor(25, 150, 25, 255)
else
surface.SetDrawColor(150, 150, 150, 255)
end
if highlight_current_key or (trace.Entity == self and x >= 0 and y >= 0 and x <= 1 and y <= 1) then
if (k <= 9) then
surface.SetDrawColor(200, 200, 200, 255)
elseif (k == 10) then
surface.SetDrawColor(200, 50, 50, 255)
elseif (k == 11) then
surface.SetDrawColor(50, 200, 50, 255)
end
if Ply:KeyDown(IN_USE) and not Ply.KeyOnce and not highlight_current_key then
net.Start("wire_keypad")
net.WriteEntity(self)
net.WriteUInt(k, 4)
net.SendToServer()
Ply.KeyOnce = true
end
end
surface.DrawRect(v[1], v[2], v[3], v[4])
draw.DrawText(text, "Trebuchet18", textx, texty, Color(0, 0, 0, 255))
end
local Display = self:GetNWString("keypad_display", "")
if Display == "y" then
draw.DrawText("ACCESS", "Trebuchet24", X+17, Y+7, Color(0, 255, 0, 255))
draw.DrawText("GRANTED","Trebuchet24", X+7, Y+27, Color(0, 255, 0, 255))
elseif Display == "n" then
draw.DrawText("ACCESS", "Trebuchet24", X+17, Y+7, Color(255, 0, 0, 255))
draw.DrawText("DENIED", "Trebuchet24", X+19, Y+27, Color(255, 0, 0, 255))
else
draw.DrawText(Display, "Trebuchet34", X+17, Y+10, Color(255, 255, 255, 255))
end
cam.End3D2D()
end
hook.Add("KeyRelease", "Keypad_KeyReleased", function(Ply, key)
Ply.KeyOnce = false
end)
local binds = {
["+gm_special 1" ] = 1,
["+gm_special 2" ] = 2,
["+gm_special 3" ] = 3,
["+gm_special 4" ] = 4,
["+gm_special 5" ] = 5,
["+gm_special 6" ] = 6,
["+gm_special 7" ] = 7,
["+gm_special 8" ] = 8,
["+gm_special 9" ] = 9,
["+gm_special 11"] = 11,
["+gm_special 12"] = 10,
}
hook.Add("PlayerBindPress", "keypad_PlayerBindPress", function(ply, bind, pressed)
if not pressed then return end
local command = binds[bind]
if not command then return end
local trace = ply:GetEyeTraceNoCursor()
local ent = trace.Entity
if not IsValid(ent) then return end
if ent:GetClass() ~= "gmod_wire_keypad" then return end
net.Start("wire_keypad")
net.WriteEntity(ent)
net.WriteUInt(command, 4)
net.SendToServer()
highlight_key, highlight_until = command, CurTime()+0.5
return true
end)
return
end -- No more client
util.PrecacheSound("buttons/button8.wav")
util.PrecacheSound("buttons/button9.wav")
util.PrecacheSound("buttons/button14.wav")
util.PrecacheSound("buttons/button15.wav")
function ENT:Initialize()
BaseClass.Initialize(self)
self.Outputs = WireLib.CreateOutputs(self, {"Valid", "Invalid"})
self.CurrentNum = 0
end
function ENT:Setup(password, securemode)
self.Password = password
self.Secure = securemode
end
util.AddNetworkString("wire_keypad")
net.Receive("wire_keypad", function(netlen, ply)
local ent = net.ReadEntity()
if not IsValid(ent) or not ent.Password then return end
if ent.CurrentNum == -1 then return end -- Display still shows ACCESS from a past success
if (ply:GetShootPos() - ent:GetPos()):Length() > 50 then return end
local key = net.ReadUInt(4)
if key == 10 then -- Reset
ent:SetNWString("keypad_display", "")
ent:EmitSound("buttons/button14.wav")
ent.CurrentNum = 0
elseif key == 11 or ent.CurrentNum > 999 then -- Accept
local access = (ent.Password == util.CRC(ent.CurrentNum))
if access then
ent:SetNWString("keypad_display", "y")
Wire_TriggerOutput(ent, "Valid", 1)
ent:EmitSound("buttons/button9.wav")
else
ent:SetNWString("keypad_display", "n")
Wire_TriggerOutput(ent, "Invalid", 1)
ent:EmitSound("buttons/button8.wav")
end
ent.CurrentNum = -1
timer.Create("wire_keypad_"..ent:EntIndex().."_"..tostring(access), 2, 1, function()
if IsValid(ent) then
ent:SetNWString("keypad_display", "")
ent.CurrentNum = 0
if access then
Wire_TriggerOutput(ent, "Valid", 0)
else
Wire_TriggerOutput(ent, "Invalid", 0)
end
end
end)
else
ent.CurrentNum = ent.CurrentNum * 10 + key
if ent.Secure then
ent:SetNWString("keypad_display", string.rep("*", string.len(ent.CurrentNum)))
else
ent:SetNWString("keypad_display", tostring(ent.CurrentNum))
end
ent:EmitSound("buttons/button15.wav")
end
end)
duplicator.RegisterEntityClass("sent_keypad", WireLib.MakeWireEnt, "Data", "Pass", "secure")
duplicator.RegisterEntityClass("gmod_wire_keypad", WireLib.MakeWireEnt, "Data", "Password", "Secure")
scripted_ents.Alias("sent_keypad", "gmod_wire_keypad")
| apache-2.0 |
nlamirault/dotfiles | .config/lvim/plugin/packer_compiled.lua | 1 | 21763 | -- Automatically generated packer.nvim plugin loader code
if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then
vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"')
return
end
vim.api.nvim_command('packadd packer.nvim')
local no_errors, error_msg = pcall(function()
local time
local profile_info
local should_profile = false
if should_profile then
local hrtime = vim.loop.hrtime
profile_info = {}
time = function(chunk, start)
if start then
profile_info[chunk] = hrtime()
else
profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6
end
end
else
time = function(chunk, start) end
end
local function save_profiles(threshold)
local sorted_times = {}
for chunk_name, time_taken in pairs(profile_info) do
sorted_times[#sorted_times + 1] = {chunk_name, time_taken}
end
table.sort(sorted_times, function(a, b) return a[2] > b[2] end)
local results = {}
for i, elem in ipairs(sorted_times) do
if not threshold or threshold and elem[2] > threshold then
results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms'
end
end
_G._packer = _G._packer or {}
_G._packer.profile_output = results
end
time([[Luarocks path setup]], true)
local package_path_str = "/home/nicolas/.cache/lvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/nicolas/.cache/lvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/nicolas/.cache/lvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/nicolas/.cache/lvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/home/nicolas/.cache/lvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so"
if not string.find(package.path, package_path_str, 1, true) then
package.path = package.path .. ';' .. package_path_str
end
if not string.find(package.cpath, install_cpath_pattern, 1, true) then
package.cpath = package.cpath .. ';' .. install_cpath_pattern
end
time([[Luarocks path setup]], false)
time([[try_loadstring definition]], true)
local function try_loadstring(s, component, name)
local success, result = pcall(loadstring(s), name, _G.packer_plugins[name])
if not success then
vim.schedule(function()
vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {})
end)
end
return result
end
time([[try_loadstring definition]], false)
time([[Defining packer_plugins]], true)
_G.packer_plugins = {
["Comment.nvim"] = {
config = { "\27LJ\2\n?\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\22lvim.core.comment\frequire\0" },
loaded = false,
needs_bufread = false,
only_cond = false,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/opt/Comment.nvim",
url = "https://github.com/numToStr/Comment.nvim"
},
LuaSnip = {
config = { "\27LJ\2\nñ\3\0\0\v\0\23\00166\0\0\0'\2\1\0B\0\2\0024\1\0\0006\2\2\0009\2\3\0029\2\4\0029\2\5\0029\2\6\2\15\0\2\0X\3\f\21\2\1\0\22\2\0\0029\3\a\0006\5\b\0B\5\1\2'\6\t\0'\a\n\0'\b\v\0'\t\f\0'\n\r\0B\3\a\2<\3\2\0019\2\a\0006\4\14\0B\4\1\2'\5\15\0B\2\3\0029\3\16\0\18\5\2\0B\3\2\2\15\0\3\0X\4\3\21\3\1\0\22\3\0\3<\2\3\0016\3\0\0'\5\17\0B\3\2\0029\3\18\3B\3\1\0016\3\0\0'\5\19\0B\3\2\0029\3\18\0035\5\20\0=\1\21\5B\3\2\0016\3\0\0'\5\22\0B\3\2\0029\3\18\3B\3\1\1K\0\1\0\"luasnip.loaders.from_snipmate\npaths\1\0\0 luasnip.loaders.from_vscode\14lazy_load\29luasnip.loaders.from_lua\17is_directory\rsnippets\19get_config_dir\22friendly-snippets\nstart\vpacker\tpack\tsite\20get_runtime_dir\15join_paths\22friendly_snippets\fsources\fluasnip\fbuiltin\tlvim\15lvim.utils\frequire\2\0" },
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/LuaSnip",
url = "https://github.com/L3MON4D3/LuaSnip"
},
["alpha-nvim"] = {
config = { "\27LJ\2\n=\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\20lvim.core.alpha\frequire\0" },
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/alpha-nvim",
url = "https://github.com/goolord/alpha-nvim"
},
["bufferline.nvim"] = {
config = { "\27LJ\2\nB\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\25lvim.core.bufferline\frequire\0" },
loaded = false,
needs_bufread = false,
only_cond = false,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/opt/bufferline.nvim",
url = "https://github.com/akinsho/bufferline.nvim"
},
["cmp-buffer"] = {
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/cmp-buffer",
url = "https://github.com/hrsh7th/cmp-buffer"
},
["cmp-nvim-lsp"] = {
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/cmp-nvim-lsp",
url = "https://github.com/hrsh7th/cmp-nvim-lsp"
},
["cmp-path"] = {
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/cmp-path",
url = "https://github.com/hrsh7th/cmp-path"
},
cmp_luasnip = {
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/cmp_luasnip",
url = "https://github.com/saadparwaiz1/cmp_luasnip"
},
["friendly-snippets"] = {
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/friendly-snippets",
url = "https://github.com/rafamadriz/friendly-snippets"
},
["gitsigns.nvim"] = {
config = { "\27LJ\2\n@\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\23lvim.core.gitsigns\frequire\0" },
loaded = false,
needs_bufread = false,
only_cond = false,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/opt/gitsigns.nvim",
url = "https://github.com/lewis6991/gitsigns.nvim"
},
["indent-blankline.nvim"] = {
config = { "\27LJ\2\nC\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\26lvim.core.indentlines\frequire\0" },
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/indent-blankline.nvim",
url = "https://github.com/lukas-reineke/indent-blankline.nvim"
},
["lir.nvim"] = {
config = { "\27LJ\2\n;\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\18lvim.core.lir\frequire\0" },
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/lir.nvim",
url = "https://github.com/christianchiarulli/lir.nvim"
},
["lualine.nvim"] = {
config = { "\27LJ\2\n?\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\22lvim.core.lualine\frequire\0" },
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/lualine.nvim",
url = "https://github.com/nvim-lualine/lualine.nvim"
},
["mason-lspconfig.nvim"] = {
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/mason-lspconfig.nvim",
url = "https://github.com/williamboman/mason-lspconfig.nvim"
},
["mason.nvim"] = {
config = { "\27LJ\2\n=\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\20lvim.core.mason\frequire\0" },
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/mason.nvim",
url = "https://github.com/williamboman/mason.nvim"
},
["neodev.nvim"] = {
loaded = false,
needs_bufread = false,
only_cond = false,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/opt/neodev.nvim",
url = "https://github.com/folke/neodev.nvim"
},
["nlsp-settings.nvim"] = {
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/nlsp-settings.nvim",
url = "https://github.com/tamago324/nlsp-settings.nvim"
},
["null-ls.nvim"] = {
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/null-ls.nvim",
url = "https://github.com/jose-elias-alvarez/null-ls.nvim"
},
["nvim-autopairs"] = {
config = { "\27LJ\2\nA\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\24lvim.core.autopairs\frequire\0" },
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/nvim-autopairs",
url = "https://github.com/windwp/nvim-autopairs"
},
["nvim-cmp"] = {
config = { "\27LJ\2\n`\0\0\3\0\6\0\v6\0\0\0009\0\1\0009\0\2\0\15\0\0\0X\1\56\0\3\0'\2\4\0B\0\2\0029\0\5\0B\0\1\1K\0\1\0\nsetup\18lvim.core.cmp\frequire\bcmp\fbuiltin\tlvim\0" },
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/nvim-cmp",
url = "https://github.com/hrsh7th/nvim-cmp"
},
["nvim-dap"] = {
config = { "\27LJ\2\n;\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\18lvim.core.dap\frequire\0" },
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/nvim-dap",
url = "https://github.com/mfussenegger/nvim-dap"
},
["nvim-dap-ui"] = {
config = { "\27LJ\2\n>\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\rsetup_ui\18lvim.core.dap\frequire\0" },
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/nvim-dap-ui",
url = "https://github.com/rcarriga/nvim-dap-ui"
},
["nvim-lspconfig"] = {
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/nvim-lspconfig",
url = "https://github.com/neovim/nvim-lspconfig"
},
["nvim-navic"] = {
config = { "\27LJ\2\nC\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\26lvim.core.breadcrumbs\frequire\0" },
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/nvim-navic",
url = "https://github.com/SmiteshP/nvim-navic"
},
["nvim-tree.lua"] = {
config = { "\27LJ\2\n@\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\23lvim.core.nvimtree\frequire\0" },
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/nvim-tree.lua",
url = "https://github.com/kyazdani42/nvim-tree.lua"
},
["nvim-treesitter"] = {
config = { "\27LJ\2\nB\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\25lvim.core.treesitter\frequire\0" },
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/nvim-treesitter",
url = "https://github.com/nvim-treesitter/nvim-treesitter"
},
["nvim-ts-context-commentstring"] = {
loaded = false,
needs_bufread = false,
only_cond = false,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/opt/nvim-ts-context-commentstring",
url = "https://github.com/JoosepAlviste/nvim-ts-context-commentstring"
},
["nvim-web-devicons"] = {
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/nvim-web-devicons",
url = "https://github.com/kyazdani42/nvim-web-devicons"
},
["onedarker.nvim"] = {
config = { "\27LJ\2\n\1\0\0\3\0\t\0\0196\0\0\0\15\0\0\0X\1\156\0\0\0009\0\1\0\a\0\2\0X\0\v6\0\3\0'\2\2\0B\0\2\0029\0\4\0B\0\1\0016\0\0\0009\0\5\0009\0\6\0009\0\a\0'\1\2\0=\1\b\0K\0\1\0\ntheme\foptions\flualine\fbuiltin\nsetup\frequire\14onedarker\16colorscheme\tlvim\30\1\0\3\0\2\0\0046\0\0\0003\2\1\0B\0\2\1K\0\1\0\0\npcall\0" },
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/onedarker.nvim",
url = "https://github.com/lunarvim/onedarker.nvim"
},
["packer.nvim"] = {
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/packer.nvim",
url = "https://github.com/wbthomason/packer.nvim"
},
["plenary.nvim"] = {
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/plenary.nvim",
url = "https://github.com/nvim-lua/plenary.nvim"
},
["popup.nvim"] = {
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/popup.nvim",
url = "https://github.com/nvim-lua/popup.nvim"
},
["project.nvim"] = {
config = { "\27LJ\2\n?\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\22lvim.core.project\frequire\0" },
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/project.nvim",
url = "https://github.com/ahmedkhalf/project.nvim"
},
["schemastore.nvim"] = {
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/schemastore.nvim",
url = "https://github.com/b0o/schemastore.nvim"
},
["structlog.nvim"] = {
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/structlog.nvim",
url = "https://github.com/Tastyep/structlog.nvim"
},
["telescope-fzf-native.nvim"] = {
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/telescope-fzf-native.nvim",
url = "https://github.com/nvim-telescope/telescope-fzf-native.nvim"
},
["telescope.nvim"] = {
config = { "\27LJ\2\nA\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\24lvim.core.telescope\frequire\0" },
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/telescope.nvim",
url = "https://github.com/nvim-telescope/telescope.nvim"
},
["toggleterm.nvim"] = {
config = { "\27LJ\2\n@\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\23lvim.core.terminal\frequire\0" },
loaded = false,
needs_bufread = false,
only_cond = false,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/opt/toggleterm.nvim",
url = "https://github.com/akinsho/toggleterm.nvim"
},
["tokyonight.nvim"] = {
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/tokyonight.nvim",
url = "https://github.com/folke/tokyonight.nvim"
},
["vim-illuminate"] = {
config = { "\27LJ\2\nB\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\25lvim.core.illuminate\frequire\0" },
loaded = true,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/start/vim-illuminate",
url = "https://github.com/RRethy/vim-illuminate"
},
["which-key.nvim"] = {
config = { "\27LJ\2\nA\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\24lvim.core.which-key\frequire\0" },
loaded = false,
needs_bufread = false,
only_cond = false,
path = "/home/nicolas/.local/share/lunarvim/site/pack/packer/opt/which-key.nvim",
url = "https://github.com/folke/which-key.nvim"
}
}
time([[Defining packer_plugins]], false)
local module_lazy_loads = {
["^neodev"] = "neodev.nvim"
}
local lazy_load_called = {['packer.load'] = true}
local function lazy_load_module(module_name)
local to_load = {}
if lazy_load_called[module_name] then return nil end
lazy_load_called[module_name] = true
for module_pat, plugin_name in pairs(module_lazy_loads) do
if not _G.packer_plugins[plugin_name].loaded and string.match(module_name, module_pat) then
to_load[#to_load + 1] = plugin_name
end
end
if #to_load > 0 then
require('packer.load')(to_load, {module = module_name}, _G.packer_plugins)
local loaded_mod = package.loaded[module_name]
if loaded_mod then
return function(modname) return loaded_mod end
end
end
end
if not vim.g.packer_custom_loader_enabled then
table.insert(package.loaders, 1, lazy_load_module)
vim.g.packer_custom_loader_enabled = true
end
-- Config for: nvim-dap
time([[Config for nvim-dap]], true)
try_loadstring("\27LJ\2\n;\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\18lvim.core.dap\frequire\0", "config", "nvim-dap")
time([[Config for nvim-dap]], false)
-- Config for: project.nvim
time([[Config for project.nvim]], true)
try_loadstring("\27LJ\2\n?\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\22lvim.core.project\frequire\0", "config", "project.nvim")
time([[Config for project.nvim]], false)
-- Config for: LuaSnip
time([[Config for LuaSnip]], true)
try_loadstring("\27LJ\2\nñ\3\0\0\v\0\23\00166\0\0\0'\2\1\0B\0\2\0024\1\0\0006\2\2\0009\2\3\0029\2\4\0029\2\5\0029\2\6\2\15\0\2\0X\3\f\21\2\1\0\22\2\0\0029\3\a\0006\5\b\0B\5\1\2'\6\t\0'\a\n\0'\b\v\0'\t\f\0'\n\r\0B\3\a\2<\3\2\0019\2\a\0006\4\14\0B\4\1\2'\5\15\0B\2\3\0029\3\16\0\18\5\2\0B\3\2\2\15\0\3\0X\4\3\21\3\1\0\22\3\0\3<\2\3\0016\3\0\0'\5\17\0B\3\2\0029\3\18\3B\3\1\0016\3\0\0'\5\19\0B\3\2\0029\3\18\0035\5\20\0=\1\21\5B\3\2\0016\3\0\0'\5\22\0B\3\2\0029\3\18\3B\3\1\1K\0\1\0\"luasnip.loaders.from_snipmate\npaths\1\0\0 luasnip.loaders.from_vscode\14lazy_load\29luasnip.loaders.from_lua\17is_directory\rsnippets\19get_config_dir\22friendly-snippets\nstart\vpacker\tpack\tsite\20get_runtime_dir\15join_paths\22friendly_snippets\fsources\fluasnip\fbuiltin\tlvim\15lvim.utils\frequire\2\0", "config", "LuaSnip")
time([[Config for LuaSnip]], false)
-- Config for: vim-illuminate
time([[Config for vim-illuminate]], true)
try_loadstring("\27LJ\2\nB\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\25lvim.core.illuminate\frequire\0", "config", "vim-illuminate")
time([[Config for vim-illuminate]], false)
-- Config for: nvim-cmp
time([[Config for nvim-cmp]], true)
try_loadstring("\27LJ\2\n`\0\0\3\0\6\0\v6\0\0\0009\0\1\0009\0\2\0\15\0\0\0X\1\56\0\3\0'\2\4\0B\0\2\0029\0\5\0B\0\1\1K\0\1\0\nsetup\18lvim.core.cmp\frequire\bcmp\fbuiltin\tlvim\0", "config", "nvim-cmp")
time([[Config for nvim-cmp]], false)
-- Config for: lualine.nvim
time([[Config for lualine.nvim]], true)
try_loadstring("\27LJ\2\n?\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\22lvim.core.lualine\frequire\0", "config", "lualine.nvim")
time([[Config for lualine.nvim]], false)
-- Config for: nvim-dap-ui
time([[Config for nvim-dap-ui]], true)
try_loadstring("\27LJ\2\n>\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\rsetup_ui\18lvim.core.dap\frequire\0", "config", "nvim-dap-ui")
time([[Config for nvim-dap-ui]], false)
-- Config for: nvim-treesitter
time([[Config for nvim-treesitter]], true)
try_loadstring("\27LJ\2\nB\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\25lvim.core.treesitter\frequire\0", "config", "nvim-treesitter")
time([[Config for nvim-treesitter]], false)
-- Config for: nvim-autopairs
time([[Config for nvim-autopairs]], true)
try_loadstring("\27LJ\2\nA\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\24lvim.core.autopairs\frequire\0", "config", "nvim-autopairs")
time([[Config for nvim-autopairs]], false)
-- Config for: mason.nvim
time([[Config for mason.nvim]], true)
try_loadstring("\27LJ\2\n=\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\20lvim.core.mason\frequire\0", "config", "mason.nvim")
time([[Config for mason.nvim]], false)
-- Config for: indent-blankline.nvim
time([[Config for indent-blankline.nvim]], true)
try_loadstring("\27LJ\2\nC\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\26lvim.core.indentlines\frequire\0", "config", "indent-blankline.nvim")
time([[Config for indent-blankline.nvim]], false)
-- Config for: nvim-tree.lua
time([[Config for nvim-tree.lua]], true)
try_loadstring("\27LJ\2\n@\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\23lvim.core.nvimtree\frequire\0", "config", "nvim-tree.lua")
time([[Config for nvim-tree.lua]], false)
-- Config for: telescope.nvim
time([[Config for telescope.nvim]], true)
try_loadstring("\27LJ\2\nA\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\24lvim.core.telescope\frequire\0", "config", "telescope.nvim")
time([[Config for telescope.nvim]], false)
-- Config for: lir.nvim
time([[Config for lir.nvim]], true)
try_loadstring("\27LJ\2\n;\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\18lvim.core.lir\frequire\0", "config", "lir.nvim")
time([[Config for lir.nvim]], false)
-- Config for: onedarker.nvim
time([[Config for onedarker.nvim]], true)
try_loadstring("\27LJ\2\n\1\0\0\3\0\t\0\0196\0\0\0\15\0\0\0X\1\156\0\0\0009\0\1\0\a\0\2\0X\0\v6\0\3\0'\2\2\0B\0\2\0029\0\4\0B\0\1\0016\0\0\0009\0\5\0009\0\6\0009\0\a\0'\1\2\0=\1\b\0K\0\1\0\ntheme\foptions\flualine\fbuiltin\nsetup\frequire\14onedarker\16colorscheme\tlvim\30\1\0\3\0\2\0\0046\0\0\0003\2\1\0B\0\2\1K\0\1\0\0\npcall\0", "config", "onedarker.nvim")
time([[Config for onedarker.nvim]], false)
-- Config for: alpha-nvim
time([[Config for alpha-nvim]], true)
try_loadstring("\27LJ\2\n=\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\20lvim.core.alpha\frequire\0", "config", "alpha-nvim")
time([[Config for alpha-nvim]], false)
-- Config for: nvim-navic
time([[Config for nvim-navic]], true)
try_loadstring("\27LJ\2\nC\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\26lvim.core.breadcrumbs\frequire\0", "config", "nvim-navic")
time([[Config for nvim-navic]], false)
vim.cmd [[augroup packer_load_aucmds]]
vim.cmd [[au!]]
-- Event lazy-loads
time([[Defining lazy-load event autocommands]], true)
vim.cmd [[au BufWinEnter * ++once lua require("packer.load")({'toggleterm.nvim', 'which-key.nvim', 'bufferline.nvim'}, { event = "BufWinEnter *" }, _G.packer_plugins)]]
vim.cmd [[au BufRead * ++once lua require("packer.load")({'gitsigns.nvim', 'Comment.nvim'}, { event = "BufRead *" }, _G.packer_plugins)]]
vim.cmd [[au BufReadPost * ++once lua require("packer.load")({'nvim-ts-context-commentstring'}, { event = "BufReadPost *" }, _G.packer_plugins)]]
time([[Defining lazy-load event autocommands]], false)
vim.cmd("augroup END")
if should_profile then save_profiles() end
end)
if not no_errors then
error_msg = error_msg:gsub('"', '\\"')
vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None')
end
| apache-2.0 |
nitheeshkl/kln_awesome | awesome_3.5/themes/holo/theme.lua | 1 | 4935 | --[[
Holo Awesome WM config 2.0
github.com/copycat-killer
--]]
theme = {}
theme.icon_dir = os.getenv("HOME") .. "/.config/awesome/themes/holo/icons"
--theme.wallpaper = os.getenv("HOME") .. "/.config/awesome/themes/holo/wall.png"
theme.topbar_path = "png:" .. theme.icon_dir .. "/topbar/"
theme.font = "Tamsyn 10.5"
theme.taglist_font = "Tamsyn 8"
theme.fg_normal = "#FFFFFF"
theme.fg_focus = "#0099CC"
theme.bg_normal = "#242424"
theme.fg_urgent = "#CC9393"
theme.bg_urgent = "#2A1F1E"
theme.border_width = "0.5"
theme.border_normal = "#252525"
theme.border_focus = "#0099CC"
theme.taglist_fg_focus = "#FFFFFF"
theme.taglist_bg_focus = "png:" .. theme.icon_dir .. "/taglist_bg_focus.png"
theme.tasklist_bg_normal = "#222222"
theme.tasklist_fg_focus = "#4CB7DB"
theme.tasklist_bg_focus = "png:" .. theme.icon_dir .. "/bg_focus_noline.png"
theme.textbox_widget_margin_top = 1
theme.awful_widget_height = 14
theme.awful_widget_margin_top = 2
theme.menu_height = "20"
theme.menu_width = "150"
theme.widget_bg = theme.icon_dir .. "/bg_focus_noline.png"
theme.awesome_icon = theme.icon_dir .. "/awesome_icon.png"
theme.vol_bg = theme.icon_dir .. "/vol_bg.png"
theme.submenu_icon = theme.icon_dir .. "/submenu.png"
theme.taglist_squares_sel = theme.icon_dir .. "/square_sel.png"
theme.taglist_squares_unsel = theme.icon_dir .. "/square_unsel.png"
theme.last = theme.icon_dir .. "/last.png"
theme.spr = theme.icon_dir .. "/spr.png"
theme.spr_small = theme.icon_dir .. "/spr_small.png"
theme.spr_very_small = theme.icon_dir .. "/spr_very_small.png"
theme.spr_right = theme.icon_dir .. "/spr_right.png"
theme.spr_bottom_right = theme.icon_dir .. "/spr_bottom_right.png"
theme.spr_left = theme.icon_dir .. "/spr_left.png"
theme.bar = theme.icon_dir .. "/bar.png"
theme.bottom_bar = theme.icon_dir .. "/bottom_bar.png"
theme.mpd = theme.icon_dir .. "/mpd.png"
theme.mpd_on = theme.icon_dir .. "/mpd_on.png"
theme.prev = theme.icon_dir .. "/prev.png"
theme.nex = theme.icon_dir .. "/next.png"
theme.stop = theme.icon_dir .. "/stop.png"
theme.pause = theme.icon_dir .. "/pause.png"
theme.play = theme.icon_dir .. "/play.png"
theme.clock = theme.icon_dir .. "/clock.png"
theme.calendar = theme.icon_dir .. "/cal.png"
theme.cpu = theme.icon_dir .. "/cpu.png"
theme.net_up = theme.icon_dir .. "/net_up.png"
theme.net_down = theme.icon_dir .. "/net_down.png"
theme.widget_mail_notify = theme.icon_dir .. "/mail_notify.png"
theme.layout_tile = theme.icon_dir .. "/tile.png"
theme.layout_tilegaps = theme.icon_dir .. "/tilegaps.png"
theme.layout_tileleft = theme.icon_dir .. "/tileleft.png"
theme.layout_tilebottom = theme.icon_dir .. "/tilebottom.png"
theme.layout_tiletop = theme.icon_dir .. "/tiletop.png"
theme.layout_fairv = theme.icon_dir .. "/fairv.png"
theme.layout_fairh = theme.icon_dir .. "/fairh.png"
theme.layout_spiral = theme.icon_dir .. "/spiral.png"
theme.layout_dwindle = theme.icon_dir .. "/dwindle.png"
theme.layout_max = theme.icon_dir .. "/max.png"
theme.layout_fullscreen = theme.icon_dir .. "/fullscreen.png"
theme.layout_magnifier = theme.icon_dir .. "/magnifier.png"
theme.layout_floating = theme.icon_dir .. "/floating.png"
theme.reboot_icon = theme.icon_dir .. "/reboot.png"
theme.tasklist_disable_icon = true
theme.tasklist_floating = ""
theme.tasklist_maximized_horizontal = ""
theme.tasklist_maximized_vertical = ""
-- lain related
theme.useless_gap_width = 10
theme.layout_uselesstile = theme.icon_dir .. "/uselesstile.png"
theme.layout_uselesstileleft = theme.icon_dir .. "/uselesstileleft.png"
theme.layout_uselesstiletop = theme.icon_dir .. "/uselesstiletop.png"
return theme
| gpl-2.0 |
luciouskami/YDWE | Development/Component/plugin/w3x2lni/script/core/slk/backend_extra_txt.lua | 2 | 1940 | local function format_keyval(key, val)
if val == '' then
return nil
end
if key == 'EditorSuffix' then
return nil
end
if key == 'EditorName' then
return nil
end
return key .. '=' .. val
end
local function format_value(val)
if type(val) == 'string' then
val = val:gsub('\r\n', '|n'):gsub('[\r\n]', '|n')
if val:find(',', nil, false) then
val = '"' .. val .. '"'
end
end
return val
end
local function add_data(lines, key, data)
if key:find '[^%w_]' then
key = ('%q'):format(key)
end
local len = 0
for k in pairs(data) do
if k > len then
len = k
end
end
if len == 0 then
return
end
if len == 1 then
lines[#lines+1] = format_keyval(key, format_value(data[1]))
return
end
local values = {}
for i = 1, len do
values[i] = format_value(data[i])
end
lines[#lines+1] = format_keyval(key, table.concat(values, ','))
end
local function add_obj(lines, name, obj)
local values = {}
local keys = {}
for key in pairs(obj) do
keys[#keys+1] = key
end
table.sort(keys)
for _, key in ipairs(keys) do
if key:sub(1, 1) ~= '_' then
add_data(values, key, obj[key])
end
end
if #values == 0 then
return
end
lines[#lines+1] = ('[%s]'):format(name)
for _, value in ipairs(values) do
lines[#lines+1] = value
end
lines[#lines+1] = ''
end
local function add_chunk(lines, tbl)
local names = {}
for name in pairs(tbl) do
names[#names+1] = name
end
table.sort(names)
for _, name in ipairs(names) do
add_obj(lines, name, tbl[name])
end
end
return function (w2l, tbl)
if not tbl then
return
end
local lines = {}
add_chunk(lines, tbl)
return table.concat(lines, '\r\n')
end
| gpl-3.0 |
Erfanh/Fighter_Bot | plugins/ingroup.lua | 202 | 31524 | do
local function check_member(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
moderators = {},
set_owner = member_id ,
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes'
}
}
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'You have been promoted as the owner.')
end
end
end
local function check_member_modadd(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
moderators = {},
set_owner = member_id ,
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes'
}
}
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Group is added and you have been promoted as the owner ')
end
end
end
local function automodadd(msg)
local data = load_data(_config.moderation.data)
if msg.action.type == 'chat_created' then
receiver = get_receiver(msg)
chat_info(receiver, check_member,{receiver=receiver, data=data, msg = msg})
end
end
local function check_member_modrem(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration removal
data[tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = nil
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Group has been removed')
end
end
end
local function show_group_settingsmod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['settings']['flood_msg_max'] then
NUM_MSG_MAX = tonumber(data[tostring(msg.to.id)]['settings']['flood_msg_max'])
print('custom'..NUM_MSG_MAX)
else
NUM_MSG_MAX = 5
end
end
local bots_protection = "Yes"
if data[tostring(msg.to.id)]['settings']['lock_bots'] then
bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots']
end
local settings = data[tostring(target)]['settings']
local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nflood sensitivity : "..NUM_MSG_MAX.."\nBot protection : "..bots_protection
return text
end
local function set_descriptionmod(msg, data, target, about)
if not is_momod(msg) then
return "For moderators only!"
end
local data_cat = 'description'
data[tostring(target)][data_cat] = about
save_data(_config.moderation.data, data)
return 'Set group description to:\n'..about
end
local function get_description(msg, data)
local data_cat = 'description'
if not data[tostring(msg.to.id)][data_cat] then
return 'No description available.'
end
local about = data[tostring(msg.to.id)][data_cat]
local about = string.gsub(msg.to.print_name, "_", " ")..':\n\n'..about
return 'About '..about
end
local function lock_group_arabic(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic']
if group_arabic_lock == 'yes' then
return 'Arabic is already locked'
else
data[tostring(target)]['settings']['lock_arabic'] = 'yes'
save_data(_config.moderation.data, data)
return 'Arabic has been locked'
end
end
local function unlock_group_arabic(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic']
if group_arabic_lock == 'no' then
return 'Arabic is already unlocked'
else
data[tostring(target)]['settings']['lock_arabic'] = 'no'
save_data(_config.moderation.data, data)
return 'Arabic has been unlocked'
end
end
local function lock_group_bots(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_bots_lock = data[tostring(target)]['settings']['lock_bots']
if group_bots_lock == 'yes' then
return 'Bots protection is already enabled'
else
data[tostring(target)]['settings']['lock_bots'] = 'yes'
save_data(_config.moderation.data, data)
return 'Bots protection has been enabled'
end
end
local function unlock_group_bots(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_bots_lock = data[tostring(target)]['settings']['lock_bots']
if group_bots_lock == 'no' then
return 'Bots protection is already disabled'
else
data[tostring(target)]['settings']['lock_bots'] = 'no'
save_data(_config.moderation.data, data)
return 'Bots protection has been disabled'
end
end
local function lock_group_namemod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'yes' then
return 'Group name is already locked'
else
data[tostring(target)]['settings']['lock_name'] = 'yes'
save_data(_config.moderation.data, data)
rename_chat('chat#id'..target, group_name_set, ok_cb, false)
return 'Group name has been locked'
end
end
local function unlock_group_namemod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'no' then
return 'Group name is already unlocked'
else
data[tostring(target)]['settings']['lock_name'] = 'no'
save_data(_config.moderation.data, data)
return 'Group name has been unlocked'
end
end
local function lock_group_floodmod(msg, data, target)
if not is_owner(msg) then
return "Only admins can do it for now"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'yes' then
return 'Group flood is locked'
else
data[tostring(target)]['settings']['flood'] = 'yes'
save_data(_config.moderation.data, data)
return 'Group flood has been locked'
end
end
local function unlock_group_floodmod(msg, data, target)
if not is_owner(msg) then
return "Only admins can do it for now"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'no' then
return 'Group flood is not locked'
else
data[tostring(target)]['settings']['flood'] = 'no'
save_data(_config.moderation.data, data)
return 'Group flood has been unlocked'
end
end
local function lock_group_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'yes' then
return 'Group members are already locked'
else
data[tostring(target)]['settings']['lock_member'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Group members has been locked'
end
local function unlock_group_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'no' then
return 'Group members are not locked'
else
data[tostring(target)]['settings']['lock_member'] = 'no'
save_data(_config.moderation.data, data)
return 'Group members has been unlocked'
end
end
local function unlock_group_photomod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'no' then
return 'Group photo is not locked'
else
data[tostring(target)]['settings']['lock_photo'] = 'no'
save_data(_config.moderation.data, data)
return 'Group photo has been unlocked'
end
end
local function set_rulesmod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local data_cat = 'rules'
data[tostring(target)][data_cat] = rules
save_data(_config.moderation.data, data)
return 'Set group rules to:\n'..rules
end
local function modadd(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
return 'Group is already added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_modadd,{receiver=receiver, data=data, msg = msg})
end
local function modrem(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if not data[tostring(msg.to.id)] then
return 'Group is not added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_modrem,{receiver=receiver, data=data, msg = msg})
end
local function get_rules(msg, data)
local data_cat = 'rules'
if not data[tostring(msg.to.id)][data_cat] then
return 'No rules available.'
end
local rules = data[tostring(msg.to.id)][data_cat]
local rules = 'Chat rules:\n'..rules
return rules
end
local function set_group_photo(msg, success, result)
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
if success then
local file = 'data/photos/chat_photo_'..msg.to.id..'.jpg'
print('File downloaded to:', result)
os.rename(result, file)
print('File moved to:', file)
chat_set_photo (receiver, file, ok_cb, false)
data[tostring(msg.to.id)]['settings']['set_photo'] = file
save_data(_config.moderation.data, data)
data[tostring(msg.to.id)]['settings']['lock_photo'] = 'yes'
save_data(_config.moderation.data, data)
send_large_msg(receiver, 'Photo saved!', ok_cb, false)
else
print('Error downloading: '..msg.id)
send_large_msg(receiver, 'Failed, please try again!', ok_cb, false)
end
end
local function promote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
local group = string.gsub(receiver, 'chat#id', '')
if not data[group] then
return send_large_msg(receiver, 'Group is not added.')
end
if data[group]['moderators'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is already a moderator.')
end
data[group]['moderators'][tostring(member_id)] = member_username
save_data(_config.moderation.data, data)
return send_large_msg(receiver, '@'..member_username..' has been promoted.')
end
local function demote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
local group = string.gsub(receiver, 'chat#id', '')
if not data[group] then
return send_large_msg(receiver, 'Group is not added.')
end
if not data[group]['moderators'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is not a moderator.')
end
data[group]['moderators'][tostring(member_id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, '@'..member_username..' has been demoted.')
end
local function username_id(cb_extra, success, result)
local mod_cmd = cb_extra.mod_cmd
local receiver = cb_extra.receiver
local member = cb_extra.member
local text = 'No user @'..member..' in this group.'
for k,v in pairs(result.members) do
vusername = v.username
if vusername == member then
member_username = member
member_id = v.id
if mod_cmd == 'promote' then
return promote(receiver, member_username, member_id)
elseif mod_cmd == 'demote' then
return demote(receiver, member_username, member_id)
end
end
end
send_large_msg(receiver, text)
end
local function modlist(msg)
local data = load_data(_config.moderation.data)
if not data[tostring(msg.to.id)] then
return 'Group is not added.'
end
-- determine if table is empty
if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way
return 'No moderator in this group.'
end
local i = 1
local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n'
for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do
message = message ..i..' - @'..v..' [' ..k.. '] \n'
i = i + 1
end
return message
end
local function callbackres(extra, success, result)
local user = result.id
local name = string.gsub(result.print_name, "_", " ")
local chat = 'chat#id'..extra.chatid
send_large_msg(chat, user..'\n'..name)
return user
end
local function help()
local help_text = tostring(_config.help_text)
return help_text
end
local function cleanmember(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
if success == -1 then
return send_large_msg(receiver, '*Error: Invite link failed* \nReason: Not creator.')
end
for k,v in pairs(result.members) do
kick_user(v.id, result.id)
end
end
local function run(msg, matches)
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
local name_log = user_print_name(msg.from)
local group = msg.to.id
if msg.media then
if msg.media.type == 'photo' and data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' and is_chat_msg(msg) and is_momod(msg) then
load_photo(msg.id, set_group_photo, msg)
end
end
if matches[1] == 'add' then
print("group "..msg.to.print_name.."("..msg.to.id..") added")
return modadd(msg)
end
if matches[1] == 'rem' then
print("group "..msg.to.print_name.."("..msg.to.id..") removed")
return modrem(msg)
end
if matches[1] == 'chat_created' and msg.from.id == 0 then
return automodadd(msg)
end
if msg.to.id and data[tostring(msg.to.id)] then
local settings = data[tostring(msg.to.id)]['settings']
if matches[1] == 'chat_add_user' then
if not msg.service then
return "Are you trying to troll me?"
end
local group_member_lock = settings.lock_member
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
if group_member_lock == 'yes' and not is_owner2(msg.action.user.id, msg.to.id) then
chat_del_user(chat, user, ok_cb, true)
elseif group_member_lock == 'yes' and tonumber(msg.from.id) == tonumber(our_id) then
return nil
elseif group_member_lock == 'no' then
return nil
end
end
if matches[1] == 'chat_add_user' then
if not msg.service then
return "Are you trying to troll me?"
end
local receiver = 'user#id'..msg.action.user.id
local data_cat = 'rules'
if not data[tostring(msg.to.id)][data_cat] then
return false
end
local rules = data[tostring(msg.to.id)][data_cat]
local rules = 'Welcome to "' .. string.gsub(msg.to.print_name, '_', ' ') ..'" this group has rules that you should follow:\n'..rules
savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..msg.action.user.id)
send_large_msg(receiver, rules)
end
if matches[1] == 'chat_del_user' then
if not msg.service then
return "Are you trying to troll me?"
end
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..user)
end
if matches[1] == 'chat_delete_photo' then
if not msg.service then
return "Are you trying to troll me?"
end
local group_photo_lock = settings.lock_photo
if group_photo_lock == 'yes' then
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:incr(picturehash)
---
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
local picprotectionredis = redis:get(picturehash)
if picprotectionredis then
if tonumber(picprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(picprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:set(picturehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to deleted picture but failed ")
chat_set_photo(receiver, settings.set_photo, ok_cb, false)
elseif group_photo_lock == 'no' then
return nil
end
end
if matches[1] == 'chat_change_photo' and msg.from.id ~= 0 then
if not msg.service then
return "Are you trying to troll me?"
end
local group_photo_lock = settings.lock_photo
if group_photo_lock == 'yes' then
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:incr(picturehash)
---
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
local picprotectionredis = redis:get(picturehash)
if picprotectionredis then
if tonumber(picprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(picprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:set(picturehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change picture but failed ")
chat_set_photo(receiver, settings.set_photo, ok_cb, false)
elseif group_photo_lock == 'no' then
return nil
end
end
if matches[1] == 'chat_rename' then
if not msg.service then
return "Are you trying to troll me?"
end
local group_name_set = settings.set_name
local group_name_lock = settings.lock_name
local to_rename = 'chat#id'..msg.to.id
if group_name_lock == 'yes' then
if group_name_set ~= tostring(msg.to.print_name) then
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
redis:incr(namehash)
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
local nameprotectionredis = redis:get(namehash)
if nameprotectionredis then
if tonumber(nameprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(nameprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
redis:set(namehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change name but failed ")
rename_chat(to_rename, group_name_set, ok_cb, false)
end
elseif group_name_lock == 'no' then
return nil
end
end
if matches[1] == 'setname' and is_momod(msg) then
local new_name = string.gsub(matches[2], '_', ' ')
data[tostring(msg.to.id)]['settings']['set_name'] = new_name
save_data(_config.moderation.data, data)
local group_name_set = data[tostring(msg.to.id)]['settings']['set_name']
local to_rename = 'chat#id'..msg.to.id
rename_chat(to_rename, group_name_set, ok_cb, false)
savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]")
end
if matches[1] == 'setphoto' and is_momod(msg) then
data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting'
save_data(_config.moderation.data, data)
return 'Please send me new group photo now'
end
if matches[1] == 'promote' and matches[2] then
if not is_owner(msg) then
return "Only owner can promote"
end
local member = string.gsub(matches[2], "@", "")
local mod_cmd = 'promote'
savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted @".. member)
chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member})
end
if matches[1] == 'demote' and matches[2] then
if not is_owner(msg) then
return "Only owner can demote"
end
if string.gsub(matches[2], "@", "") == msg.from.username then
return "You can't demote yourself"
end
local member = string.gsub(matches[2], "@", "")
local mod_cmd = 'demote'
savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted @".. member)
chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member})
end
if matches[1] == 'modlist' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group modlist")
return modlist(msg)
end
if matches[1] == 'about' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group description")
return get_description(msg, data)
end
if matches[1] == 'rules' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group rules")
return get_rules(msg, data)
end
if matches[1] == 'set' then
if matches[2] == 'rules' then
rules = matches[3]
local target = msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group rules to ["..matches[3].."]")
return set_rulesmod(msg, data, target)
end
if matches[2] == 'about' then
local data = load_data(_config.moderation.data)
local target = msg.to.id
local about = matches[3]
savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group description to ["..matches[3].."]")
return set_descriptionmod(msg, data, target, about)
end
end
if matches[1] == 'lock' then
local target = msg.to.id
if matches[2] == 'name' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked name ")
return lock_group_namemod(msg, data, target)
end
if matches[2] == 'member' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked member ")
return lock_group_membermod(msg, data, target)
end
if matches[2] == 'flood' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked flood ")
return lock_group_floodmod(msg, data, target)
end
if matches[2] == 'arabic' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked arabic ")
return lock_group_arabic(msg, data, target)
end
if matches[2] == 'bots' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked bots ")
return lock_group_bots(msg, data, target)
end
end
if matches[1] == 'unlock' then
local target = msg.to.id
if matches[2] == 'name' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked name ")
return unlock_group_namemod(msg, data, target)
end
if matches[2] == 'member' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked member ")
return unlock_group_membermod(msg, data, target)
end
if matches[2] == 'photo' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked photo ")
return unlock_group_photomod(msg, data, target)
end
if matches[2] == 'flood' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked flood ")
return unlock_group_floodmod(msg, data, target)
end
if matches[2] == 'arabic' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked arabic ")
return unlock_group_arabic(msg, data, target)
end
if matches[2] == 'bots' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked bots ")
return unlock_group_bots(msg, data, target)
end
end
if matches[1] == 'settings' then
local target = msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group settings ")
return show_group_settingsmod(msg, data, target)
end
if matches[1] == 'newlink' then
if not is_momod(msg) then
return "For moderators only!"
end
local function callback (extra , success, result)
local receiver = 'chat#'..msg.to.id
if success == 0 then
return send_large_msg(receiver, '*Error: Invite link failed* \nReason: Not creator.')
end
send_large_msg(receiver, "Created a new link")
data[tostring(msg.to.id)]['settings']['set_link'] = result
save_data(_config.moderation.data, data)
end
local receiver = 'chat#'..msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] revoked group link ")
return export_chat_link(receiver, callback, true)
end
if matches[1] == 'link' then
if not is_momod(msg) then
return "For moderators only!"
end
local group_link = data[tostring(msg.to.id)]['settings']['set_link']
if not group_link then
return "Create a link using /newlink first !"
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group link ["..group_link.."]")
return "Group link:\n"..group_link
end
if matches[1] == 'setowner' then
if not is_owner(msg) then
return "For owner only!"
end
data[tostring(msg.to.id)]['set_owner'] = matches[2]
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set ["..matches[2].."] as owner")
local text = matches[2].." added as owner"
return text
end
if matches[1] == 'owner' then
local group_owner = data[tostring(msg.to.id)]['set_owner']
if not group_owner then
return "no owner,ask admins in support groups to set owner for your group"
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] used /owner")
return "Group owner is ["..group_owner..']'
end
if matches[1] == 'setgpowner' then
local receiver = "chat#id"..matches[2]
if not is_admin(msg) then
return "For admins only!"
end
data[tostring(matches[2])]['set_owner'] = matches[3]
save_data(_config.moderation.data, data)
local text = matches[3].." added as owner"
send_large_msg(receiver, text)
return
end
if matches[1] == 'setflood' then
if not is_momod(msg) then
return "For moderators only!"
end
if tonumber(matches[2]) < 5 or tonumber(matches[2]) > 20 then
return "Wrong number,range is [5-20]"
end
local flood_max = matches[2]
data[tostring(msg.to.id)]['settings']['flood_msg_max'] = flood_max
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set flood to ["..matches[2].."]")
return 'Group flood has been set to '..matches[2]
end
if matches[1] == 'clean' then
if not is_owner(msg) then
return "Only owner can clean"
end
if matches[2] == 'member' then
if not is_owner(msg) then
return "Only admins can clean members"
end
local receiver = get_receiver(msg)
chat_info(receiver, cleanmember, {receiver=receiver})
end
if matches[2] == 'modlist' then
if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way
return 'No moderator in this group.'
end
local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n'
for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do
data[tostring(msg.to.id)]['moderators'][tostring(k)] = nil
save_data(_config.moderation.data, data)
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned modlist")
end
if matches[2] == 'rules' then
local data_cat = 'rules'
data[tostring(msg.to.id)][data_cat] = nil
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned rules")
end
if matches[2] == 'about' then
local data_cat = 'description'
data[tostring(msg.to.id)][data_cat] = nil
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned about")
end
end
if matches[1] == 'help' then
if not is_momod(msg) then
return
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help")
return help()
end
if matches[1] == 'res' and is_momod(msg) then
local cbres_extra = {
chatid = msg.to.id
}
local username = matches[2]
local username = username:gsub("@","")
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username)
return res_user(username, callbackres, cbres_extra)
end
end
end
return {
patterns = {
"^[!/](add)$",
"^[!/](rem)$",
"^[!/](rules)$",
"^[!/](about)$",
"^[!/](setname) (.*)$",
"^[!/](setphoto)$",
"^[!/](promote) (.*)$",
"^[!/](help)$",
"^[!/](clean) (.*)$",
"^[!/](demote) (.*)$",
"^[!/](set) ([^%s]+) (.*)$",
"^[!/](lock) (.*)$",
"^[!/](setowner) (%d+)$",
"^[!/](owner)$",
"^[!/](res) (.*)$",
"^[!/](setgpowner) (%d+) (%d+)$",-- (group id) (owner id)
"^[!/](unlock) (.*)$",
"^[!/](setflood) (%d+)$",
"^[!/](settings)$",
"^[!/](modlist)$",
"^[!/](newlink)$",
"^[!/](link)$",
"%[(photo)%]",
"^!!tgservice (.+)$",
},
run = run
}
end
| gpl-2.0 |
mrjon1/1 | plugins/ingroup.lua | 202 | 31524 | do
local function check_member(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
moderators = {},
set_owner = member_id ,
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes'
}
}
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'You have been promoted as the owner.')
end
end
end
local function check_member_modadd(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration
data[tostring(msg.to.id)] = {
moderators = {},
set_owner = member_id ,
settings = {
set_name = string.gsub(msg.to.print_name, '_', ' '),
lock_name = 'yes',
lock_photo = 'no',
lock_member = 'no',
flood = 'yes'
}
}
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Group is added and you have been promoted as the owner ')
end
end
end
local function automodadd(msg)
local data = load_data(_config.moderation.data)
if msg.action.type == 'chat_created' then
receiver = get_receiver(msg)
chat_info(receiver, check_member,{receiver=receiver, data=data, msg = msg})
end
end
local function check_member_modrem(cb_extra, success, result)
local receiver = cb_extra.receiver
local data = cb_extra.data
local msg = cb_extra.msg
for k,v in pairs(result.members) do
local member_id = v.id
if member_id ~= our_id then
-- Group configuration removal
data[tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = nil
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, 'Group has been removed')
end
end
end
local function show_group_settingsmod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['settings']['flood_msg_max'] then
NUM_MSG_MAX = tonumber(data[tostring(msg.to.id)]['settings']['flood_msg_max'])
print('custom'..NUM_MSG_MAX)
else
NUM_MSG_MAX = 5
end
end
local bots_protection = "Yes"
if data[tostring(msg.to.id)]['settings']['lock_bots'] then
bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots']
end
local settings = data[tostring(target)]['settings']
local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nflood sensitivity : "..NUM_MSG_MAX.."\nBot protection : "..bots_protection
return text
end
local function set_descriptionmod(msg, data, target, about)
if not is_momod(msg) then
return "For moderators only!"
end
local data_cat = 'description'
data[tostring(target)][data_cat] = about
save_data(_config.moderation.data, data)
return 'Set group description to:\n'..about
end
local function get_description(msg, data)
local data_cat = 'description'
if not data[tostring(msg.to.id)][data_cat] then
return 'No description available.'
end
local about = data[tostring(msg.to.id)][data_cat]
local about = string.gsub(msg.to.print_name, "_", " ")..':\n\n'..about
return 'About '..about
end
local function lock_group_arabic(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic']
if group_arabic_lock == 'yes' then
return 'Arabic is already locked'
else
data[tostring(target)]['settings']['lock_arabic'] = 'yes'
save_data(_config.moderation.data, data)
return 'Arabic has been locked'
end
end
local function unlock_group_arabic(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic']
if group_arabic_lock == 'no' then
return 'Arabic is already unlocked'
else
data[tostring(target)]['settings']['lock_arabic'] = 'no'
save_data(_config.moderation.data, data)
return 'Arabic has been unlocked'
end
end
local function lock_group_bots(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_bots_lock = data[tostring(target)]['settings']['lock_bots']
if group_bots_lock == 'yes' then
return 'Bots protection is already enabled'
else
data[tostring(target)]['settings']['lock_bots'] = 'yes'
save_data(_config.moderation.data, data)
return 'Bots protection has been enabled'
end
end
local function unlock_group_bots(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_bots_lock = data[tostring(target)]['settings']['lock_bots']
if group_bots_lock == 'no' then
return 'Bots protection is already disabled'
else
data[tostring(target)]['settings']['lock_bots'] = 'no'
save_data(_config.moderation.data, data)
return 'Bots protection has been disabled'
end
end
local function lock_group_namemod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'yes' then
return 'Group name is already locked'
else
data[tostring(target)]['settings']['lock_name'] = 'yes'
save_data(_config.moderation.data, data)
rename_chat('chat#id'..target, group_name_set, ok_cb, false)
return 'Group name has been locked'
end
end
local function unlock_group_namemod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_name_set = data[tostring(target)]['settings']['set_name']
local group_name_lock = data[tostring(target)]['settings']['lock_name']
if group_name_lock == 'no' then
return 'Group name is already unlocked'
else
data[tostring(target)]['settings']['lock_name'] = 'no'
save_data(_config.moderation.data, data)
return 'Group name has been unlocked'
end
end
local function lock_group_floodmod(msg, data, target)
if not is_owner(msg) then
return "Only admins can do it for now"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'yes' then
return 'Group flood is locked'
else
data[tostring(target)]['settings']['flood'] = 'yes'
save_data(_config.moderation.data, data)
return 'Group flood has been locked'
end
end
local function unlock_group_floodmod(msg, data, target)
if not is_owner(msg) then
return "Only admins can do it for now"
end
local group_flood_lock = data[tostring(target)]['settings']['flood']
if group_flood_lock == 'no' then
return 'Group flood is not locked'
else
data[tostring(target)]['settings']['flood'] = 'no'
save_data(_config.moderation.data, data)
return 'Group flood has been unlocked'
end
end
local function lock_group_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'yes' then
return 'Group members are already locked'
else
data[tostring(target)]['settings']['lock_member'] = 'yes'
save_data(_config.moderation.data, data)
end
return 'Group members has been locked'
end
local function unlock_group_membermod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_member_lock = data[tostring(target)]['settings']['lock_member']
if group_member_lock == 'no' then
return 'Group members are not locked'
else
data[tostring(target)]['settings']['lock_member'] = 'no'
save_data(_config.moderation.data, data)
return 'Group members has been unlocked'
end
end
local function unlock_group_photomod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local group_photo_lock = data[tostring(target)]['settings']['lock_photo']
if group_photo_lock == 'no' then
return 'Group photo is not locked'
else
data[tostring(target)]['settings']['lock_photo'] = 'no'
save_data(_config.moderation.data, data)
return 'Group photo has been unlocked'
end
end
local function set_rulesmod(msg, data, target)
if not is_momod(msg) then
return "For moderators only!"
end
local data_cat = 'rules'
data[tostring(target)][data_cat] = rules
save_data(_config.moderation.data, data)
return 'Set group rules to:\n'..rules
end
local function modadd(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
return 'Group is already added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_modadd,{receiver=receiver, data=data, msg = msg})
end
local function modrem(msg)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
return "You're not admin"
end
local data = load_data(_config.moderation.data)
if not data[tostring(msg.to.id)] then
return 'Group is not added.'
end
receiver = get_receiver(msg)
chat_info(receiver, check_member_modrem,{receiver=receiver, data=data, msg = msg})
end
local function get_rules(msg, data)
local data_cat = 'rules'
if not data[tostring(msg.to.id)][data_cat] then
return 'No rules available.'
end
local rules = data[tostring(msg.to.id)][data_cat]
local rules = 'Chat rules:\n'..rules
return rules
end
local function set_group_photo(msg, success, result)
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
if success then
local file = 'data/photos/chat_photo_'..msg.to.id..'.jpg'
print('File downloaded to:', result)
os.rename(result, file)
print('File moved to:', file)
chat_set_photo (receiver, file, ok_cb, false)
data[tostring(msg.to.id)]['settings']['set_photo'] = file
save_data(_config.moderation.data, data)
data[tostring(msg.to.id)]['settings']['lock_photo'] = 'yes'
save_data(_config.moderation.data, data)
send_large_msg(receiver, 'Photo saved!', ok_cb, false)
else
print('Error downloading: '..msg.id)
send_large_msg(receiver, 'Failed, please try again!', ok_cb, false)
end
end
local function promote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
local group = string.gsub(receiver, 'chat#id', '')
if not data[group] then
return send_large_msg(receiver, 'Group is not added.')
end
if data[group]['moderators'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is already a moderator.')
end
data[group]['moderators'][tostring(member_id)] = member_username
save_data(_config.moderation.data, data)
return send_large_msg(receiver, '@'..member_username..' has been promoted.')
end
local function demote(receiver, member_username, member_id)
local data = load_data(_config.moderation.data)
local group = string.gsub(receiver, 'chat#id', '')
if not data[group] then
return send_large_msg(receiver, 'Group is not added.')
end
if not data[group]['moderators'][tostring(member_id)] then
return send_large_msg(receiver, member_username..' is not a moderator.')
end
data[group]['moderators'][tostring(member_id)] = nil
save_data(_config.moderation.data, data)
return send_large_msg(receiver, '@'..member_username..' has been demoted.')
end
local function username_id(cb_extra, success, result)
local mod_cmd = cb_extra.mod_cmd
local receiver = cb_extra.receiver
local member = cb_extra.member
local text = 'No user @'..member..' in this group.'
for k,v in pairs(result.members) do
vusername = v.username
if vusername == member then
member_username = member
member_id = v.id
if mod_cmd == 'promote' then
return promote(receiver, member_username, member_id)
elseif mod_cmd == 'demote' then
return demote(receiver, member_username, member_id)
end
end
end
send_large_msg(receiver, text)
end
local function modlist(msg)
local data = load_data(_config.moderation.data)
if not data[tostring(msg.to.id)] then
return 'Group is not added.'
end
-- determine if table is empty
if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way
return 'No moderator in this group.'
end
local i = 1
local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n'
for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do
message = message ..i..' - @'..v..' [' ..k.. '] \n'
i = i + 1
end
return message
end
local function callbackres(extra, success, result)
local user = result.id
local name = string.gsub(result.print_name, "_", " ")
local chat = 'chat#id'..extra.chatid
send_large_msg(chat, user..'\n'..name)
return user
end
local function help()
local help_text = tostring(_config.help_text)
return help_text
end
local function cleanmember(cb_extra, success, result)
local receiver = cb_extra.receiver
local chat_id = "chat#id"..result.id
local chatname = result.print_name
if success == -1 then
return send_large_msg(receiver, '*Error: Invite link failed* \nReason: Not creator.')
end
for k,v in pairs(result.members) do
kick_user(v.id, result.id)
end
end
local function run(msg, matches)
local data = load_data(_config.moderation.data)
local receiver = get_receiver(msg)
local name_log = user_print_name(msg.from)
local group = msg.to.id
if msg.media then
if msg.media.type == 'photo' and data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' and is_chat_msg(msg) and is_momod(msg) then
load_photo(msg.id, set_group_photo, msg)
end
end
if matches[1] == 'add' then
print("group "..msg.to.print_name.."("..msg.to.id..") added")
return modadd(msg)
end
if matches[1] == 'rem' then
print("group "..msg.to.print_name.."("..msg.to.id..") removed")
return modrem(msg)
end
if matches[1] == 'chat_created' and msg.from.id == 0 then
return automodadd(msg)
end
if msg.to.id and data[tostring(msg.to.id)] then
local settings = data[tostring(msg.to.id)]['settings']
if matches[1] == 'chat_add_user' then
if not msg.service then
return "Are you trying to troll me?"
end
local group_member_lock = settings.lock_member
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
if group_member_lock == 'yes' and not is_owner2(msg.action.user.id, msg.to.id) then
chat_del_user(chat, user, ok_cb, true)
elseif group_member_lock == 'yes' and tonumber(msg.from.id) == tonumber(our_id) then
return nil
elseif group_member_lock == 'no' then
return nil
end
end
if matches[1] == 'chat_add_user' then
if not msg.service then
return "Are you trying to troll me?"
end
local receiver = 'user#id'..msg.action.user.id
local data_cat = 'rules'
if not data[tostring(msg.to.id)][data_cat] then
return false
end
local rules = data[tostring(msg.to.id)][data_cat]
local rules = 'Welcome to "' .. string.gsub(msg.to.print_name, '_', ' ') ..'" this group has rules that you should follow:\n'..rules
savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..msg.action.user.id)
send_large_msg(receiver, rules)
end
if matches[1] == 'chat_del_user' then
if not msg.service then
return "Are you trying to troll me?"
end
local user = 'user#id'..msg.action.user.id
local chat = 'chat#id'..msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..user)
end
if matches[1] == 'chat_delete_photo' then
if not msg.service then
return "Are you trying to troll me?"
end
local group_photo_lock = settings.lock_photo
if group_photo_lock == 'yes' then
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:incr(picturehash)
---
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
local picprotectionredis = redis:get(picturehash)
if picprotectionredis then
if tonumber(picprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(picprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:set(picturehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to deleted picture but failed ")
chat_set_photo(receiver, settings.set_photo, ok_cb, false)
elseif group_photo_lock == 'no' then
return nil
end
end
if matches[1] == 'chat_change_photo' and msg.from.id ~= 0 then
if not msg.service then
return "Are you trying to troll me?"
end
local group_photo_lock = settings.lock_photo
if group_photo_lock == 'yes' then
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:incr(picturehash)
---
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
local picprotectionredis = redis:get(picturehash)
if picprotectionredis then
if tonumber(picprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(picprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id
redis:set(picturehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change picture but failed ")
chat_set_photo(receiver, settings.set_photo, ok_cb, false)
elseif group_photo_lock == 'no' then
return nil
end
end
if matches[1] == 'chat_rename' then
if not msg.service then
return "Are you trying to troll me?"
end
local group_name_set = settings.set_name
local group_name_lock = settings.lock_name
local to_rename = 'chat#id'..msg.to.id
if group_name_lock == 'yes' then
if group_name_set ~= tostring(msg.to.print_name) then
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
redis:incr(namehash)
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
local nameprotectionredis = redis:get(namehash)
if nameprotectionredis then
if tonumber(nameprotectionredis) == 4 and not is_owner(msg) then
kick_user(msg.from.id, msg.to.id)
end
if tonumber(nameprotectionredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)
local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id
redis:set(namehash, 0)
end
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change name but failed ")
rename_chat(to_rename, group_name_set, ok_cb, false)
end
elseif group_name_lock == 'no' then
return nil
end
end
if matches[1] == 'setname' and is_momod(msg) then
local new_name = string.gsub(matches[2], '_', ' ')
data[tostring(msg.to.id)]['settings']['set_name'] = new_name
save_data(_config.moderation.data, data)
local group_name_set = data[tostring(msg.to.id)]['settings']['set_name']
local to_rename = 'chat#id'..msg.to.id
rename_chat(to_rename, group_name_set, ok_cb, false)
savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]")
end
if matches[1] == 'setphoto' and is_momod(msg) then
data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting'
save_data(_config.moderation.data, data)
return 'Please send me new group photo now'
end
if matches[1] == 'promote' and matches[2] then
if not is_owner(msg) then
return "Only owner can promote"
end
local member = string.gsub(matches[2], "@", "")
local mod_cmd = 'promote'
savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted @".. member)
chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member})
end
if matches[1] == 'demote' and matches[2] then
if not is_owner(msg) then
return "Only owner can demote"
end
if string.gsub(matches[2], "@", "") == msg.from.username then
return "You can't demote yourself"
end
local member = string.gsub(matches[2], "@", "")
local mod_cmd = 'demote'
savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted @".. member)
chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member})
end
if matches[1] == 'modlist' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group modlist")
return modlist(msg)
end
if matches[1] == 'about' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group description")
return get_description(msg, data)
end
if matches[1] == 'rules' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group rules")
return get_rules(msg, data)
end
if matches[1] == 'set' then
if matches[2] == 'rules' then
rules = matches[3]
local target = msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group rules to ["..matches[3].."]")
return set_rulesmod(msg, data, target)
end
if matches[2] == 'about' then
local data = load_data(_config.moderation.data)
local target = msg.to.id
local about = matches[3]
savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group description to ["..matches[3].."]")
return set_descriptionmod(msg, data, target, about)
end
end
if matches[1] == 'lock' then
local target = msg.to.id
if matches[2] == 'name' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked name ")
return lock_group_namemod(msg, data, target)
end
if matches[2] == 'member' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked member ")
return lock_group_membermod(msg, data, target)
end
if matches[2] == 'flood' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked flood ")
return lock_group_floodmod(msg, data, target)
end
if matches[2] == 'arabic' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked arabic ")
return lock_group_arabic(msg, data, target)
end
if matches[2] == 'bots' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked bots ")
return lock_group_bots(msg, data, target)
end
end
if matches[1] == 'unlock' then
local target = msg.to.id
if matches[2] == 'name' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked name ")
return unlock_group_namemod(msg, data, target)
end
if matches[2] == 'member' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked member ")
return unlock_group_membermod(msg, data, target)
end
if matches[2] == 'photo' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked photo ")
return unlock_group_photomod(msg, data, target)
end
if matches[2] == 'flood' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked flood ")
return unlock_group_floodmod(msg, data, target)
end
if matches[2] == 'arabic' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked arabic ")
return unlock_group_arabic(msg, data, target)
end
if matches[2] == 'bots' then
savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked bots ")
return unlock_group_bots(msg, data, target)
end
end
if matches[1] == 'settings' then
local target = msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group settings ")
return show_group_settingsmod(msg, data, target)
end
if matches[1] == 'newlink' then
if not is_momod(msg) then
return "For moderators only!"
end
local function callback (extra , success, result)
local receiver = 'chat#'..msg.to.id
if success == 0 then
return send_large_msg(receiver, '*Error: Invite link failed* \nReason: Not creator.')
end
send_large_msg(receiver, "Created a new link")
data[tostring(msg.to.id)]['settings']['set_link'] = result
save_data(_config.moderation.data, data)
end
local receiver = 'chat#'..msg.to.id
savelog(msg.to.id, name_log.." ["..msg.from.id.."] revoked group link ")
return export_chat_link(receiver, callback, true)
end
if matches[1] == 'link' then
if not is_momod(msg) then
return "For moderators only!"
end
local group_link = data[tostring(msg.to.id)]['settings']['set_link']
if not group_link then
return "Create a link using /newlink first !"
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group link ["..group_link.."]")
return "Group link:\n"..group_link
end
if matches[1] == 'setowner' then
if not is_owner(msg) then
return "For owner only!"
end
data[tostring(msg.to.id)]['set_owner'] = matches[2]
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set ["..matches[2].."] as owner")
local text = matches[2].." added as owner"
return text
end
if matches[1] == 'owner' then
local group_owner = data[tostring(msg.to.id)]['set_owner']
if not group_owner then
return "no owner,ask admins in support groups to set owner for your group"
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] used /owner")
return "Group owner is ["..group_owner..']'
end
if matches[1] == 'setgpowner' then
local receiver = "chat#id"..matches[2]
if not is_admin(msg) then
return "For admins only!"
end
data[tostring(matches[2])]['set_owner'] = matches[3]
save_data(_config.moderation.data, data)
local text = matches[3].." added as owner"
send_large_msg(receiver, text)
return
end
if matches[1] == 'setflood' then
if not is_momod(msg) then
return "For moderators only!"
end
if tonumber(matches[2]) < 5 or tonumber(matches[2]) > 20 then
return "Wrong number,range is [5-20]"
end
local flood_max = matches[2]
data[tostring(msg.to.id)]['settings']['flood_msg_max'] = flood_max
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] set flood to ["..matches[2].."]")
return 'Group flood has been set to '..matches[2]
end
if matches[1] == 'clean' then
if not is_owner(msg) then
return "Only owner can clean"
end
if matches[2] == 'member' then
if not is_owner(msg) then
return "Only admins can clean members"
end
local receiver = get_receiver(msg)
chat_info(receiver, cleanmember, {receiver=receiver})
end
if matches[2] == 'modlist' then
if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way
return 'No moderator in this group.'
end
local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n'
for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do
data[tostring(msg.to.id)]['moderators'][tostring(k)] = nil
save_data(_config.moderation.data, data)
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned modlist")
end
if matches[2] == 'rules' then
local data_cat = 'rules'
data[tostring(msg.to.id)][data_cat] = nil
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned rules")
end
if matches[2] == 'about' then
local data_cat = 'description'
data[tostring(msg.to.id)][data_cat] = nil
save_data(_config.moderation.data, data)
savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned about")
end
end
if matches[1] == 'help' then
if not is_momod(msg) then
return
end
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help")
return help()
end
if matches[1] == 'res' and is_momod(msg) then
local cbres_extra = {
chatid = msg.to.id
}
local username = matches[2]
local username = username:gsub("@","")
savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username)
return res_user(username, callbackres, cbres_extra)
end
end
end
return {
patterns = {
"^[!/](add)$",
"^[!/](rem)$",
"^[!/](rules)$",
"^[!/](about)$",
"^[!/](setname) (.*)$",
"^[!/](setphoto)$",
"^[!/](promote) (.*)$",
"^[!/](help)$",
"^[!/](clean) (.*)$",
"^[!/](demote) (.*)$",
"^[!/](set) ([^%s]+) (.*)$",
"^[!/](lock) (.*)$",
"^[!/](setowner) (%d+)$",
"^[!/](owner)$",
"^[!/](res) (.*)$",
"^[!/](setgpowner) (%d+) (%d+)$",-- (group id) (owner id)
"^[!/](unlock) (.*)$",
"^[!/](setflood) (%d+)$",
"^[!/](settings)$",
"^[!/](modlist)$",
"^[!/](newlink)$",
"^[!/](link)$",
"%[(photo)%]",
"^!!tgservice (.+)$",
},
run = run
}
end
| gpl-2.0 |
tbergeron/love-ludumdare-starter | globals.lua | 1 | 2130 | -- Globals Table
-- Contains all re-usable variables and functions
globals = {}
-- Game Version
globals.version = '0.0.0'
-- Assets relative path
globals.assetsDirectory = 'assets/'
-- Date Format
globals.formatDate = function(days_to_format, full)
local years, months, weeks, days = nil
-- years
years = math.floor(days_to_format / 365) > 0 and math.floor(days_to_format / 365) or nil
if years then
days_to_format = math.floor(days_to_format - math.floor(years * 365))
end
-- months
months = math.floor(days_to_format / 30) > 0 and math.floor(days_to_format / 30) or nil
if months then
days_to_format = math.floor(days_to_format - math.floor(months * 30))
end
-- weeks
weeks = math.floor(days_to_format / 7) > 0 and math.floor(days_to_format / 7) or nil
if weeks then
days_to_format = math.floor(days_to_format - math.floor(weeks * 7))
end
days = days_to_format
local response = ''
if years then
if full then
local s = stringlobals.len(years) > 0 and 's ' or ' '
response = years .. 'year' .. s
else
response = years .. 'y '
end
end
if months then
if full then
local s = stringlobals.len(months) > 0 and 's ' or ' '
response = response .. months .. ' month' .. s
else
response = response .. months .. 'm '
end
end -- todo: AND
if weeks then
if full then
local s = stringlobals.len(weeks) > 0 and 's ' or ' '
response = response .. weeks .. ' week' .. s
else
response = response .. weeks .. 'w '
end
end
if days then
if full then
local s = stringlobals.len(days) > 0 and 's ' or ' '
response = response .. days .. ' day' .. s
else
response = response .. days .. 'd'
end
end
return response
end
-- Paths
globals.getPath = function(filename)
local base_path = globals.assetsDirectory
base_path = base_path .. filename
return base_path
end | mit |
rainfiel/skynet | lualib/redis.lua | 20 | 6194 | local skynet = require "skynet"
local socket = require "socket"
local socketchannel = require "socketchannel"
local table = table
local string = string
local assert = assert
local redis = {}
local command = {}
local meta = {
__index = command,
-- DO NOT close channel in __gc
}
---------- redis response
local redcmd = {}
redcmd[36] = function(fd, data) -- '$'
local bytes = tonumber(data)
if bytes < 0 then
return true,nil
end
local firstline = fd:read(bytes+2)
return true,string.sub(firstline,1,-3)
end
redcmd[43] = function(fd, data) -- '+'
return true,data
end
redcmd[45] = function(fd, data) -- '-'
return false,data
end
redcmd[58] = function(fd, data) -- ':'
-- todo: return string later
return true, tonumber(data)
end
local function read_response(fd)
local result = fd:readline "\r\n"
local firstchar = string.byte(result)
local data = string.sub(result,2)
return redcmd[firstchar](fd,data)
end
redcmd[42] = function(fd, data) -- '*'
local n = tonumber(data)
if n < 0 then
return true, nil
end
local bulk = {}
local noerr = true
for i = 1,n do
local ok, v = read_response(fd)
if not ok then
noerr = false
end
bulk[i] = v
end
return noerr, bulk
end
-------------------
function command:disconnect()
self[1]:close()
setmetatable(self, nil)
end
-- msg could be any type of value
local function make_cache(f)
return setmetatable({}, {
__mode = "kv",
__index = f,
})
end
local header_cache = make_cache(function(t,k)
local s = "\r\n$" .. k .. "\r\n"
t[k] = s
return s
end)
local command_cache = make_cache(function(t,cmd)
local s = "\r\n$"..#cmd.."\r\n"..cmd:upper()
t[cmd] = s
return s
end)
local count_cache = make_cache(function(t,k)
local s = "*" .. k
t[k] = s
return s
end)
local function compose_message(cmd, msg)
local t = type(msg)
local lines = {}
if t == "table" then
lines[1] = count_cache[#msg+1]
lines[2] = command_cache[cmd]
local idx = 3
for _,v in ipairs(msg) do
v= tostring(v)
lines[idx] = header_cache[#v]
lines[idx+1] = v
idx = idx + 2
end
lines[idx] = "\r\n"
else
msg = tostring(msg)
lines[1] = "*2"
lines[2] = command_cache[cmd]
lines[3] = header_cache[#msg]
lines[4] = msg
lines[5] = "\r\n"
end
return lines
end
local function redis_login(auth, db)
if auth == nil and db == nil then
return
end
return function(so)
if auth then
so:request(compose_message("AUTH", auth), read_response)
end
if db then
so:request(compose_message("SELECT", db), read_response)
end
end
end
function redis.connect(db_conf)
local channel = socketchannel.channel {
host = db_conf.host,
port = db_conf.port or 6379,
auth = redis_login(db_conf.auth, db_conf.db),
nodelay = true,
}
-- try connect first only once
channel:connect(true)
return setmetatable( { channel }, meta )
end
setmetatable(command, { __index = function(t,k)
local cmd = string.upper(k)
local f = function (self, v, ...)
if type(v) == "table" then
return self[1]:request(compose_message(cmd, v), read_response)
else
return self[1]:request(compose_message(cmd, {v, ...}), read_response)
end
end
t[k] = f
return f
end})
local function read_boolean(so)
local ok, result = read_response(so)
return ok, result ~= 0
end
function command:exists(key)
local fd = self[1]
return fd:request(compose_message ("EXISTS", key), read_boolean)
end
function command:sismember(key, value)
local fd = self[1]
return fd:request(compose_message ("SISMEMBER", {key, value}), read_boolean)
end
local function compose_table(lines, msg)
local tinsert = table.insert
tinsert(lines, count_cache[#msg])
for _,v in ipairs(msg) do
v = tostring(v)
tinsert(lines,header_cache[#v])
tinsert(lines,v)
end
tinsert(lines, "\r\n")
return lines
end
function command:pipeline(ops,resp)
assert(ops and #ops > 0, "pipeline is null")
local fd = self[1]
local cmds = {}
for _, cmd in ipairs(ops) do
compose_table(cmds, cmd)
end
if resp then
return fd:request(cmds, function (fd)
for i=1, #ops do
local ok, out = read_response(fd)
table.insert(resp, {ok = ok, out = out})
end
return true, resp
end)
else
return fd:request(cmds, function (fd)
local ok, out
for i=1, #ops do
ok, out = read_response(fd)
end
-- return last response
return ok,out
end)
end
end
--- watch mode
local watch = {}
local watchmeta = {
__index = watch,
__gc = function(self)
self.__sock:close()
end,
}
local function watch_login(obj, auth)
return function(so)
if auth then
so:request(compose_message("AUTH", auth), read_response)
end
for k in pairs(obj.__psubscribe) do
so:request(compose_message ("PSUBSCRIBE", k))
end
for k in pairs(obj.__subscribe) do
so:request(compose_message("SUBSCRIBE", k))
end
end
end
function redis.watch(db_conf)
local obj = {
__subscribe = {},
__psubscribe = {},
}
local channel = socketchannel.channel {
host = db_conf.host,
port = db_conf.port or 6379,
auth = watch_login(obj, db_conf.auth),
nodelay = true,
}
obj.__sock = channel
-- try connect first only once
channel:connect(true)
return setmetatable( obj, watchmeta )
end
function watch:disconnect()
self.__sock:close()
setmetatable(self, nil)
end
local function watch_func( name )
local NAME = string.upper(name)
watch[name] = function(self, ...)
local so = self.__sock
for i = 1, select("#", ...) do
local v = select(i, ...)
so:request(compose_message(NAME, v))
end
end
end
watch_func "subscribe"
watch_func "psubscribe"
watch_func "unsubscribe"
watch_func "punsubscribe"
function watch:message()
local so = self.__sock
while true do
local ret = so:response(read_response)
local type , channel, data , data2 = ret[1], ret[2], ret[3], ret[4]
if type == "message" then
return data, channel
elseif type == "pmessage" then
return data2, data, channel
elseif type == "subscribe" then
self.__subscribe[channel] = true
elseif type == "psubscribe" then
self.__psubscribe[channel] = true
elseif type == "unsubscribe" then
self.__subscribe[channel] = nil
elseif type == "punsubscribe" then
self.__psubscribe[channel] = nil
end
end
end
return redis
| mit |
CarabusX/Zero-K | units/chickenwurm.lua | 3 | 4728 | return { chickenwurm = {
unitname = [[chickenwurm]],
name = [[Wurm]],
description = [[Burrowing Flamer (Assault/Riot)]],
acceleration = 1.08,
activateWhenBuilt = true,
brakeRate = 1.23,
buildCostEnergy = 0,
buildCostMetal = 0,
builder = false,
buildPic = [[chickenwurm.png]],
buildTime = 350,
canGuard = true,
canMove = true,
canPatrol = true,
category = [[LAND]],
customParams = {
fireproof = 1,
},
explodeAs = [[jumpraid_PYRO_DEATH]],
footprintX = 4,
footprintZ = 4,
iconType = [[spidergeneric]],
idleAutoHeal = 10,
idleTime = 600,
leaveTracks = true,
maxDamage = 1500,
maxSlope = 90,
maxVelocity = 1.8,
maxWaterDepth = 5000,
movementClass = [[ATKBOT3]],
noAutoFire = false,
noChaseCategory = [[SHIP FLOAT SWIM TERRAFORM FIXEDWING GUNSHIP SATELLITE STUPIDTARGET MINE]],
objectName = [[chickenwurm.s3o]],
power = 350,
reclaimable = false,
script = [[chickenwurm.lua]],
selfDestructAs = [[jumpraid_PYRO_DEATH]],
sfxtypes = {
explosiongenerators = {
[[custom:blood_spray]],
[[custom:blood_explode]],
[[custom:dirt]],
},
},
sightDistance = 384,
sonarDistance = 384,
stealth = true,
turnRate = 967,
upright = false,
workerTime = 0,
weapons = {
{
def = [[NAPALM]],
badTargetCategory = [[GUNSHIP]],
mainDir = [[0 0 1]],
maxAngleDif = 120,
onlyTargetCategory = [[SWIM LAND SINK TURRET FLOAT GUNSHIP SHIP HOVER]],
},
{
def = [[UWGOO]], -- Fired when underwater.
mainDir = [[0 0 1]],
maxAngleDif = 120,
onlyTargetCategory = [[SWIM LAND SINK TURRET FLOAT SUB GUNSHIP SHIP HOVER]],
},
{
def = [[UWGOO]], -- Above water, fired at submerged units.
mainDir = [[0 0 1]],
maxAngleDif = 120,
onlyTargetCategory = [[SINK SUB]],
},
},
weaponDefs = {
NAPALM = {
name = [[Napalm Blob]],
areaOfEffect = 128,
burst = 1,
burstrate = 0.033,
craterBoost = 0,
craterMult = 0,
customParams = {
setunitsonfire = "1",
burntime = 180,
area_damage = 1,
area_damage_radius = 128,
area_damage_dps = 30,
area_damage_duration = 20,
},
damage = {
default = 50,
planes = 50,
},
explosionGenerator = [[custom:napalm_firewalker]],
fireStarter = 120,
impulseBoost = 0,
impulseFactor = 0.2,
intensity = 0.7,
interceptedByShieldType = 1,
range = 300,
reloadtime = 6,
rgbColor = [[0.8 0.3 0]],
size = 4.5,
sizeDecay = 0,
soundHit = [[chickens/acid_hit]],
soundStart = [[chickens/acid_fire]],
sprayAngle = 1024,
tolerance = 5000,
turret = true,
weaponType = [[Cannon]],
weaponVelocity = 200,
},
UWGOO = {
name = [[Blob]],
areaOfEffect = 128,
craterBoost = 0,
craterMult = 0,
customParams = {
},
damage = {
default = 250,
},
explosionGenerator = [[custom:large_green_goo]],
fireStarter = 120,
impulseBoost = 0,
impulseFactor = 0.2,
intensity = 0.7,
interceptedByShieldType = 1,
range = 300,
reloadtime = 6,
rgbColor = [[0.2 0.6 0]],
size = 8,
sizeDecay = 0,
soundHit = [[chickens/acid_hit]],
soundStart = [[chickens/acid_fire]],
tolerance = 9000,
turret = true,
weaponType = [[Cannon]],
weaponVelocity = 600,
waterWeapon = true,
},
},
} }
| gpl-2.0 |
CarabusX/Zero-K | effects/nota_otaplas.lua | 50 | 48727 | -- miniotaplas_fireball11
-- otaplas_fireball3
-- otaplas_fireball16
-- otaplas_fireball14
-- ota_plas
-- miniotaplas_fireball17
-- otaplas_fireball18
-- otaplas_fireball1
-- otaplas_fireball11
-- miniotaplas_fireball13
-- otaplas_fireball10
-- miniotaplas_fireball16
-- otaplas_fireball13
-- miniotaplas_fireball2
-- otaplas_fireball7
-- miniotaplas_fireball14
-- otaplas_fireball12
-- miniotaplas_fireball7
-- otaplas_fireball17
-- miniotaplas_fireball9
-- miniotaplas_fireball18
-- miniota_plas
-- miniotaplas_fireball3
-- otaplas_fireball6
-- otaplas_fireball4
-- miniotaplas_fireball5
-- otaplas_fireball8
-- miniotaplas_fireball15
-- otaplas_fireball2
-- miniotaplas_fireball6
-- otaplas_fireball15
-- otaplas_fireball9
-- miniotaplas_fireball8
-- miniotaplas_fireball4
-- miniotaplas_fireball10
-- miniotaplas_fireball12
-- miniotaplas_fireball1
-- otaplas_fireball5
return {
["miniotaplas_fireball11"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 25,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas11]],
},
},
},
["otaplas_fireball3"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 35,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas3]],
},
},
},
["otaplas_fireball16"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 35,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas16]],
},
},
},
["otaplas_fireball14"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 35,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas14]],
},
},
},
["ota_plas"] = {
frame1 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 0,
explosiongenerator = [[custom:OTAPLAS_FIREBALL1]],
pos = [[0, 0, 0]],
},
},
frame10 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 18,
explosiongenerator = [[custom:OTAPLAS_FIREBALL10]],
pos = [[0, 9, 0]],
},
},
frame11 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 20,
explosiongenerator = [[custom:OTAPLAS_FIREBALL11]],
pos = [[0, 10, 0]],
},
},
frame12 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 22,
explosiongenerator = [[custom:OTAPLAS_FIREBALL12]],
pos = [[0, 11, 0]],
},
},
frame13 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 24,
explosiongenerator = [[custom:OTAPLAS_FIREBALL13]],
pos = [[0, 12, 0]],
},
},
frame14 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 26,
explosiongenerator = [[custom:OTAPLAS_FIREBALL14]],
pos = [[0, 13, 0]],
},
},
frame15 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 28,
explosiongenerator = [[custom:OTAPLAS_FIREBALL15]],
pos = [[0, 14, 0]],
},
},
frame16 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 30,
explosiongenerator = [[custom:OTAPLAS_FIREBALL16]],
pos = [[0, 15, 0]],
},
},
frame17 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 32,
explosiongenerator = [[custom:OTAPLAS_FIREBALL17]],
pos = [[0, 16, 0]],
},
},
frame18 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 34,
explosiongenerator = [[custom:OTAPLAS_FIREBALL18]],
pos = [[0, 17, 0]],
},
},
frame2 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 2,
explosiongenerator = [[custom:OTAPLAS_FIREBALL2]],
pos = [[0, 1, 0]],
},
},
frame3 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 4,
explosiongenerator = [[custom:OTAPLAS_FIREBALL3]],
pos = [[0, 2, 0]],
},
},
frame4 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 6,
explosiongenerator = [[custom:OTAPLAS_FIREBALL4]],
pos = [[0, 3, 0]],
},
},
frame5 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 8,
explosiongenerator = [[custom:OTAPLAS_FIREBALL5]],
pos = [[0, 4, 0]],
},
},
frame6 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 10,
explosiongenerator = [[custom:OTAPLAS_FIREBALL6]],
pos = [[0, 5, 0]],
},
},
frame7 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 12,
explosiongenerator = [[custom:OTAPLAS_FIREBALL7]],
pos = [[0, 6, 0]],
},
},
frame8 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 14,
explosiongenerator = [[custom:OTAPLAS_FIREBALL8]],
pos = [[0, 7, 0]],
},
},
frame9 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 16,
explosiongenerator = [[custom:OTAPLAS_FIREBALL9]],
pos = [[0, 8, 0]],
},
},
groundflash = {
circlealpha = 1,
circlegrowth = 0,
flashalpha = 0.9,
flashsize = 40,
ttl = 20,
color = {
[1] = 1,
[2] = 0.69999998807907,
[3] = 0.69999998807907,
},
},
},
["miniotaplas_fireball17"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 25,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas17]],
},
},
},
["otaplas_fireball18"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0 0 0 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 35,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas18]],
},
},
},
["otaplas_fireball1"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[1 1 1 0.01 1 1 1 0.01 .5 .5 .5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 35,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas1]],
},
},
},
["otaplas_fireball11"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 35,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas11]],
},
},
},
["miniotaplas_fireball13"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 25,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas13]],
},
},
},
["otaplas_fireball10"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 35,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas10]],
},
},
},
["miniotaplas_fireball16"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 25,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas16]],
},
},
},
["otaplas_fireball13"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 35,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas13]],
},
},
},
["miniotaplas_fireball2"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 25,
particlesizespread = 0,
particlespeed = .5,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas2]],
},
},
},
["otaplas_fireball7"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 35,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas7]],
},
},
},
["miniotaplas_fireball14"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 25,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas14]],
},
},
},
["otaplas_fireball12"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 35,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas12]],
},
},
},
["miniotaplas_fireball7"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 25,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas7]],
},
},
},
["otaplas_fireball17"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 35,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas17]],
},
},
},
["miniotaplas_fireball9"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 25,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas9]],
},
},
},
["miniotaplas_fireball18"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0 0 0 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 25,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas18]],
},
},
},
["miniota_plas"] = {
frame1 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 0,
explosiongenerator = [[custom:MINIOTAPLAS_FIREBALL1]],
pos = [[0, 0, 0]],
},
},
frame10 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 18,
explosiongenerator = [[custom:MINIOTAPLAS_FIREBALL10]],
pos = [[0, 9, 0]],
},
},
frame11 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 20,
explosiongenerator = [[custom:MINIOTAPLAS_FIREBALL11]],
pos = [[0, 10, 0]],
},
},
frame12 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 22,
explosiongenerator = [[custom:MINIOTAPLAS_FIREBALL12]],
pos = [[0, 11, 0]],
},
},
frame13 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 24,
explosiongenerator = [[custom:MINIOTAPLAS_FIREBALL13]],
pos = [[0, 12, 0]],
},
},
frame14 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 26,
explosiongenerator = [[custom:MINIOTAPLAS_FIREBALL14]],
pos = [[0, 13, 0]],
},
},
frame15 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 28,
explosiongenerator = [[custom:MINIOTAPLAS_FIREBALL15]],
pos = [[0, 14, 0]],
},
},
frame16 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 30,
explosiongenerator = [[custom:MINIOTAPLAS_FIREBALL16]],
pos = [[0, 15, 0]],
},
},
frame17 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 32,
explosiongenerator = [[custom:MINIOTAPLAS_FIREBALL17]],
pos = [[0, 16, 0]],
},
},
frame18 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 34,
explosiongenerator = [[custom:MINIOTAPLAS_FIREBALL18]],
pos = [[0, 17, 0]],
},
},
frame2 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 2,
explosiongenerator = [[custom:MINIOTAPLAS_FIREBALL2]],
pos = [[0, 1, 0]],
},
},
frame3 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 4,
explosiongenerator = [[custom:MINIOTAPLAS_FIREBALL3]],
pos = [[0, 2, 0]],
},
},
frame4 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 6,
explosiongenerator = [[custom:MINIOTAPLAS_FIREBALL4]],
pos = [[0, 3, 0]],
},
},
frame5 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 8,
explosiongenerator = [[custom:MINIOTAPLAS_FIREBALL5]],
pos = [[0, 4, 0]],
},
},
frame6 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 10,
explosiongenerator = [[custom:MINIOTAPLAS_FIREBALL6]],
pos = [[0, 5, 0]],
},
},
frame7 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 12,
explosiongenerator = [[custom:MINIOTAPLAS_FIREBALL7]],
pos = [[0, 6, 0]],
},
},
frame8 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 14,
explosiongenerator = [[custom:MINIOTAPLAS_FIREBALL8]],
pos = [[0, 7, 0]],
},
},
frame9 = {
air = true,
class = [[CExpGenSpawner]],
count = 1,
ground = true,
water = true,
properties = {
delay = 16,
explosiongenerator = [[custom:MINIOTAPLAS_FIREBALL9]],
pos = [[0, 8, 0]],
},
},
groundflash = {
circlealpha = 1,
circlegrowth = 0,
flashalpha = 0.9,
flashsize = 40,
ttl = 20,
color = {
[1] = 1,
[2] = 0.69999998807907,
[3] = 0.69999998807907,
},
},
},
["miniotaplas_fireball3"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 25,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas3]],
},
},
},
["otaplas_fireball6"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 35,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas6]],
},
},
},
["otaplas_fireball4"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 35,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas4]],
},
},
},
["miniotaplas_fireball5"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 25,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas5]],
},
},
},
["otaplas_fireball8"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 35,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas8]],
},
},
},
["miniotaplas_fireball15"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 25,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas15]],
},
},
},
["otaplas_fireball2"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 35,
particlesizespread = 0,
particlespeed = .5,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas2]],
},
},
},
["miniotaplas_fireball6"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 25,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas6]],
},
},
},
["otaplas_fireball15"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 35,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas15]],
},
},
},
["otaplas_fireball9"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 35,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas9]],
},
},
},
["miniotaplas_fireball8"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 25,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas8]],
},
},
},
["miniotaplas_fireball4"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 25,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas4]],
},
},
},
["miniotaplas_fireball10"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 25,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas10]],
},
},
},
["miniotaplas_fireball12"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 25,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas12]],
},
},
},
["miniotaplas_fireball1"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[1 1 1 0.01 1 1 1 0.01 .5 .5 .5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 25,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas1]],
},
},
},
["otaplas_fireball5"] = {
wezels = {
air = true,
class = [[CSimpleParticleSystem]],
count = 1,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[0.5 0.5 0.5 0.01 1 1 1 0.01 0.5 0.5 0.5 0.01]],
directional = false,
emitrot = 0,
emitrotspread = 1,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 6,
particlelifespread = 0,
particlesize = 35,
particlesizespread = 0,
particlespeed = .3,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[otaplas5]],
},
},
},
}
| gpl-2.0 |
THS56/DEVNOVAR | DevNover/utils.lua | 74 | 30284 | URL = require "socket.url"
http = require "socket.http"
https = require "ssl.https"
ltn12 = require "ltn12"
serpent = (loadfile "./libs/serpent.lua")()
feedparser = (loadfile "./libs/feedparser.lua")()
json = (loadfile "./libs/JSON.lua")()
mimetype = (loadfile "./libs/mimetype.lua")()
redis = (loadfile "./libs/redis.lua")()
JSON = (loadfile "./libs/dkjson.lua")()
http.TIMEOUT = 10
function get_receiver(msg)
if msg.to.type == 'user' then
return 'user#id'..msg.from.id
end
if msg.to.type == 'chat' then
return 'chat#id'..msg.to.id
end
if msg.to.type == 'encr_chat' then
return msg.to.print_name
end
if msg.to.type == 'channel' then
return 'channel#id'..msg.to.id
end
end
function is_chat_msg( msg )
if msg.to.type == 'chat' then
return true
end
return false
end
function string.random(length)
local str = "";
for i = 1, length do
math.random(97, 122)
str = str..string.char(math.random(97, 122));
end
return str;
end
function string.random(length)
local str = "";
for i = 1, length do
math.random(97, 122)
str = str..string.char(math.random(97, 122));
end
return str;
end
function string:split(sep)
local sep, fields = sep or ":", {}
local pattern = string.format("([^%s]+)", sep)
self:gsub(pattern, function(c) fields[#fields+1] = c end)
return fields
end
-- DEPRECATED
function string.trim(s)
print("string.trim(s) is DEPRECATED use string:trim() instead")
return s:gsub("^%s*(.-)%s*$", "%1")
end
-- Removes spaces
function string:trim()
return self:gsub("^%s*(.-)%s*$", "%1")
end
function get_http_file_name(url, headers)
-- Eg: foo.var
local file_name = url:match("[^%w]+([%.%w]+)$")
-- Any delimited alphanumeric on the url
file_name = file_name or url:match("[^%w]+(%w+)[^%w]+$")
-- Random name, hope content-type works
file_name = file_name or str:random(5)
local content_type = headers["content-type"]
local extension = nil
if content_type then
extension = mimetype.get_mime_extension(content_type)
end
if extension then
file_name = file_name.."."..extension
end
local disposition = headers["content-disposition"]
if disposition then
-- attachment; filename=CodeCogsEqn.png
file_name = disposition:match('filename=([^;]+)') or file_name
end
return file_name
end
-- Saves file to /tmp/. If file_name isn't provided,
-- will get the text after the last "/" for filename
-- and content-type for extension
function download_to_file(url, file_name)
print("url to download: "..url)
local respbody = {}
local options = {
url = url,
sink = ltn12.sink.table(respbody),
redirect = true
}
-- nil, code, headers, status
local response = nil
if url:starts('https') then
options.redirect = false
response = {https.request(options)}
else
response = {http.request(options)}
end
local code = response[2]
local headers = response[3]
local status = response[4]
if code ~= 200 then return nil end
file_name = file_name or get_http_file_name(url, headers)
local file_path = "data/tmp/"..file_name
print("Saved to: "..file_path)
file = io.open(file_path, "w+")
file:write(table.concat(respbody))
file:close()
return file_path
end
function vardump(value)
print(serpent.block(value, {comment=false}))
end
-- taken from http://stackoverflow.com/a/11130774/3163199
function scandir(directory)
local i, t, popen = 0, {}, io.popen
for filename in popen('ls -a "'..directory..'"'):lines() do
i = i + 1
t[i] = filename
end
return t
end
-- http://www.lua.org/manual/5.2/manual.html#pdf-io.popen
function run_command(str)
local cmd = io.popen(str)
local result = cmd:read('*all')
cmd:close()
return result
end
-- User has privileges
function is_sudo(msg)
local var = false
-- Check users id in config
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
-- Returns the name of the sender
function get_name(msg)
local name = msg.from.first_name
if name == nil then
name = msg.from.id
end
return name
end
-- Returns at table of lua files inside plugins
function plugins_names( )
local files = {}
for k, v in pairs(scandir("plugins")) do
-- Ends with .lua
if (v:match(".lua$")) then
table.insert(files, v)
end
end
return files
end
-- Function name explains what it does.
function file_exists(name)
local f = io.open(name,"r")
if f ~= nil then
io.close(f)
return true
else
return false
end
end
-- Save into file the data serialized for lua.
-- Set uglify true to minify the file.
function serialize_to_file(data, file, uglify)
file = io.open(file, 'w+')
local serialized
if not uglify then
serialized = serpent.block(data, {
comment = false,
name = '_'
})
else
serialized = serpent.dump(data)
end
file:write(serialized)
file:close()
end
-- Returns true if the string is empty
function string:isempty()
return self == nil or self == ''
end
-- Returns true if the string is blank
function string:isblank()
self = self:trim()
return self:isempty()
end
-- DEPRECATED!!!!!
function string.starts(String, Start)
print("string.starts(String, Start) is DEPRECATED use string:starts(text) instead")
return Start == string.sub(String,1,string.len(Start))
end
-- Returns true if String starts with Start
function string:starts(text)
return text == string.sub(self,1,string.len(text))
end
-- Send image to user and delete it when finished.
-- cb_function and cb_extra are optionals callback
function _send_photo(receiver, file_path, cb_function, cb_extra)
local cb_extra = {
file_path = file_path,
cb_function = cb_function,
cb_extra = cb_extra
}
-- Call to remove with optional callback
send_photo(receiver, file_path, cb_function, cb_extra)
end
-- Download the image and send to receiver, it will be deleted.
-- cb_function and cb_extra are optionals callback
function send_photo_from_url(receiver, url, cb_function, cb_extra)
-- If callback not provided
cb_function = cb_function or ok_cb
cb_extra = cb_extra or false
local file_path = download_to_file(url, false)
if not file_path then -- Error
local text = 'Error downloading the image'
send_msg(receiver, text, cb_function, cb_extra)
else
print("File path: "..file_path)
_send_photo(receiver, file_path, cb_function, cb_extra)
end
end
-- Same as send_photo_from_url but as callback function
function send_photo_from_url_callback(cb_extra, success, result)
local receiver = cb_extra.receiver
local url = cb_extra.url
local file_path = download_to_file(url, false)
if not file_path then -- Error
local text = 'Error downloading the image'
send_msg(receiver, text, ok_cb, false)
else
print("File path: "..file_path)
_send_photo(receiver, file_path, ok_cb, false)
end
end
-- Send multiple images asynchronous.
-- param urls must be a table.
function send_photos_from_url(receiver, urls)
local cb_extra = {
receiver = receiver,
urls = urls,
remove_path = nil
}
send_photos_from_url_callback(cb_extra)
end
-- Use send_photos_from_url.
-- This function might be difficult to understand.
function send_photos_from_url_callback(cb_extra, success, result)
-- cb_extra is a table containing receiver, urls and remove_path
local receiver = cb_extra.receiver
local urls = cb_extra.urls
local remove_path = cb_extra.remove_path
-- The previously image to remove
if remove_path ~= nil then
os.remove(remove_path)
print("Deleted: "..remove_path)
end
-- Nil or empty, exit case (no more urls)
if urls == nil or #urls == 0 then
return false
end
-- Take the head and remove from urls table
local head = table.remove(urls, 1)
local file_path = download_to_file(head, false)
local cb_extra = {
receiver = receiver,
urls = urls,
remove_path = file_path
}
-- Send first and postpone the others as callback
send_photo(receiver, file_path, send_photos_from_url_callback, cb_extra)
end
-- Callback to remove a file
function rmtmp_cb(cb_extra, success, result)
local file_path = cb_extra.file_path
local cb_function = cb_extra.cb_function or ok_cb
local cb_extra = cb_extra.cb_extra
if file_path ~= nil then
os.remove(file_path)
print("Deleted: "..file_path)
end
-- Finally call the callback
cb_function(cb_extra, success, result)
end
-- Send document to user and delete it when finished.
-- cb_function and cb_extra are optionals callback
function _send_document(receiver, file_path, cb_function, cb_extra)
local cb_extra = {
file_path = file_path,
cb_function = cb_function or ok_cb,
cb_extra = cb_extra or false
}
-- Call to remove with optional callback
send_document(receiver, file_path, rmtmp_cb, cb_extra)
end
-- Download the image and send to receiver, it will be deleted.
-- cb_function and cb_extra are optionals callback
function send_document_from_url(receiver, url, cb_function, cb_extra)
local file_path = download_to_file(url, false)
print("File path: "..file_path)
_send_document(receiver, file_path, cb_function, cb_extra)
end
-- Parameters in ?a=1&b=2 style
function format_http_params(params, is_get)
local str = ''
-- If is get add ? to the beginning
if is_get then str = '?' end
local first = true -- Frist param
for k,v in pairs (params) do
if v then -- nil value
if first then
first = false
str = str..k.. "="..v
else
str = str.."&"..k.. "="..v
end
end
end
return str
end
-- Check if user can use the plugin and warns user
-- Returns true if user was warned and false if not warned (is allowed)
function warns_user_not_allowed(plugin, msg)
if not user_allowed(plugin, msg) then
local text = 'This plugin requires privileged user'
local receiver = get_receiver(msg)
send_msg(receiver, text, ok_cb, false)
return true
else
return false
end
end
-- Check if user can use the plugin
function user_allowed(plugin, msg)
if plugin.privileged and not is_sudo(msg) then
return false
end
return true
end
function send_order_msg(destination, msgs)
local cb_extra = {
destination = destination,
msgs = msgs
}
send_order_msg_callback(cb_extra, true)
end
function send_order_msg_callback(cb_extra, success, result)
local destination = cb_extra.destination
local msgs = cb_extra.msgs
local file_path = cb_extra.file_path
if file_path ~= nil then
os.remove(file_path)
print("Deleted: " .. file_path)
end
if type(msgs) == 'string' then
send_large_msg(destination, msgs)
elseif type(msgs) ~= 'table' then
return
end
if #msgs < 1 then
return
end
local msg = table.remove(msgs, 1)
local new_cb_extra = {
destination = destination,
msgs = msgs
}
if type(msg) == 'string' then
send_msg(destination, msg, send_order_msg_callback, new_cb_extra)
elseif type(msg) == 'table' then
local typ = msg[1]
local nmsg = msg[2]
new_cb_extra.file_path = nmsg
if typ == 'document' then
send_document(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'image' or typ == 'photo' then
send_photo(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'audio' then
send_audio(destination, nmsg, send_order_msg_callback, new_cb_extra)
elseif typ == 'video' then
send_video(destination, nmsg, send_order_msg_callback, new_cb_extra)
else
send_file(destination, nmsg, send_order_msg_callback, new_cb_extra)
end
end
end
-- Same as send_large_msg_callback but friendly params
function send_large_msg(destination, text)
local cb_extra = {
destination = destination,
text = text
}
send_large_msg_callback(cb_extra, true)
end
-- If text is longer than 4096 chars, send multiple msg.
-- https://core.telegram.org/method/messages.sendMessage
function send_large_msg_callback(cb_extra, success, result)
local text_max = 4096
local destination = cb_extra.destination
local text = cb_extra.text
if not text or type(text) == 'boolean' then
return
end
local text_len = string.len(text)
local num_msg = math.ceil(text_len / text_max)
if num_msg <= 1 then
send_msg(destination, text, ok_cb, false)
else
local my_text = string.sub(text, 1, 4096)
local rest = string.sub(text, 4096, text_len)
local cb_extra = {
destination = destination,
text = rest
}
send_msg(destination, my_text, send_large_msg_callback, cb_extra)
end
end
function post_large_msg(destination, text)
local cb_extra = {
destination = destination,
text = text
}
post_large_msg_callback(cb_extra, true)
end
function post_large_msg_callback(cb_extra, success, result)
local text_max = 4096
local destination = cb_extra.destination
local text = cb_extra.text
local text_len = string.len(text)
local num_msg = math.ceil(text_len / text_max)
if num_msg <= 1 then
post_msg(destination, text, ok_cb, false)
else
local my_text = string.sub(text, 1, 4096)
local rest = string.sub(text, 4096, text_len)
local cb_extra = {
destination = destination,
text = rest
}
post_msg(destination, my_text, post_large_msg_callback, cb_extra)
end
end
-- Returns a table with matches or nil
function match_pattern(pattern, text, lower_case)
if text then
local matches = {}
if lower_case then
matches = { string.match(text:lower(), pattern) }
else
matches = { string.match(text, pattern) }
end
if next(matches) then
return matches
end
end
-- nil
end
-- Function to read data from files
function load_from_file(file, default_data)
local f = io.open(file, "r+")
-- If file doesn't exists
if f == nil then
-- Create a new empty table
default_data = default_data or {}
serialize_to_file(default_data, file)
print ('Created file', file)
else
print ('Data loaded from file', file)
f:close()
end
return loadfile (file)()
end
-- See http://stackoverflow.com/a/14899740
function unescape_html(str)
local map = {
["lt"] = "<",
["gt"] = ">",
["amp"] = "&",
["quot"] = '"',
["apos"] = "'"
}
new = string.gsub(str, '(&(#?x?)([%d%a]+);)', function(orig, n, s)
var = map[s] or n == "#" and string.char(s)
var = var or n == "#x" and string.char(tonumber(s,16))
var = var or orig
return var
end)
return new
end
-- Workarrond to format the message as previously was received
function backward_msg_format (msg)
for k,name in pairs({'from', 'to'}) do
local longid = msg[name].id
msg[name].id = msg[name].peer_id
msg[name].peer_id = longid
msg[name].type = msg[name].peer_type
end
if msg.action and (msg.action.user or msg.action.link_issuer) then
local user = msg.action.user or msg.action.link_issuer
local longid = user.id
user.id = user.peer_id
user.peer_id = longid
user.type = user.peer_type
end
return msg
end
--Table Sort
function pairsByKeys (t, f)
local a = {}
for n in pairs(t) do table.insert(a, n) end
table.sort(a, f)
local i = 0 -- iterator variable
local iter = function () -- iterator function
i = i + 1
if a[i] == nil then return nil
else return a[i], t[a[i]]
end
end
return iter
end
--End Table Sort
--Check if this chat is realm or not
function is_realm(msg)
local var = false
local realms = 'realms'
local data = load_data(_config.moderation.data)
local chat = msg.to.id
if data[tostring(realms)] then
if data[tostring(realms)][tostring(chat)] then
var = true
end
return var
end
end
--Check if this chat is a group or not
function is_group(msg)
local var = false
local data = load_data(_config.moderation.data)
local groups = 'groups'
local chat = msg.to.id
if data[tostring(groups)] then
if data[tostring(groups)][tostring(chat)] then
if msg.to.type == 'chat' then
var = true
end
end
return var
end
end
function is_super_group(msg)
local var = false
local data = load_data(_config.moderation.data)
local groups = 'groups'
local chat = msg.to.id
if data[tostring(groups)] then
if data[tostring(groups)][tostring(chat)] then
if msg.to.type == 'channel' then
var = true
end
return var
end
end
end
function is_log_group(msg)
local var = false
local data = load_data(_config.moderation.data)
local GBan_log = 'GBan_log'
if data[tostring(GBan_log)] then
if data[tostring(GBan_log)][tostring(msg.to.id)] then
if msg.to.type == 'channel' then
var = true
end
return var
end
end
end
function savelog(group, logtxt)
local text = (os.date("[ %c ]=> "..logtxt.."\n \n"))
local file = io.open("./groups/logs/"..group.."log.txt", "a")
file:write(text)
file:close()
end
function user_print_name(user)
if user.print_name then
return user.print_name
end
local text = ''
if user.first_name then
text = user.last_name..' '
end
if user.lastname then
text = text..user.last_name
end
return text
end
--Check if user is the owner of that group or not
function is_owner(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['set_owner'] then
if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then
var = true
end
end
end
local hash = 'support'
local support = redis:sismember(hash, user)
if support then
var = true
end
if data['admins'] then
if data['admins'][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
function is_owner2(user_id, group_id)
local var = false
local data = load_data(_config.moderation.data)
local user = user_id
if data[tostring(group_id)] then
if data[tostring(group_id)]['set_owner'] then
if data[tostring(group_id)]['set_owner'] == tostring(user_id) then
var = true
end
end
end
local hash = 'support'
local support = redis:sismember(hash, user)
if support then
var = true
end
if data['admins'] then
if data['admins'][tostring(user_id)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == user_id then
var = true
end
end
return var
end
--Check if user is admin or not
function is_admin1(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
local admins = 'admins'
if data[tostring(admins)] then
if data[tostring(admins)][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
function is_admin2(user_id)
local var = false
local data = load_data(_config.moderation.data)
local user = user_id
local admins = 'admins'
if data[tostring(admins)] then
if data[tostring(admins)][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == user_id then
var = true
end
end
return var
end
--Check if user is the mod of that group or not
function is_momod(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['moderators'] then
if data[tostring(msg.to.id)]['moderators'][tostring(user)] then
var = true
end
end
end
if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['set_owner'] then
if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then
var = true
end
end
end
local hash = 'support'
local support = redis:sismember(hash, user)
if support then
var = true
end
if data['admins'] then
if data['admins'][tostring(user)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == msg.from.id then
var = true
end
end
return var
end
function is_momod2(user_id, group_id)
local var = false
local data = load_data(_config.moderation.data)
local usert = user_id
if data[tostring(group_id)] then
if data[tostring(group_id)]['moderators'] then
if data[tostring(group_id)]['moderators'][tostring(usert)] then
var = true
end
end
end
if data[tostring(group_id)] then
if data[tostring(group_id)]['set_owner'] then
if data[tostring(group_id)]['set_owner'] == tostring(user_id) then
var = true
end
end
end
local hash = 'support'
local support = redis:sismember(hash, user_id)
if support then
var = true
end
if data['admins'] then
if data['admins'][tostring(user_id)] then
var = true
end
end
for v,user in pairs(_config.sudo_users) do
if user == usert then
var = true
end
end
return var
end
-- Returns the name of the sender
function kick_user_any(user_id, chat_id)
local channel = 'channel#id'..chat_id
local chat = 'chat#id'..chat_id
local user = 'user#id'..user_id
chat_del_user(chat, user, ok_cb, true)
channel_kick(channel, user, ok_cb, false)
end
-- Returns the name of the sender
function kick_user(user_id, chat_id)
if tonumber(user_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_admin2(user_id) then -- Ignore admins
return
end
local channel = 'channel#id'..chat_id
local chat = 'chat#id'..chat_id
local user = 'user#id'..user_id
chat_del_user(chat, user, ok_cb, false)
channel_kick(channel, user, ok_cb, false)
end
-- Ban
function ban_user(user_id, chat_id)
if tonumber(user_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_admin2(user_id) then -- Ignore admins
return
end
-- Save to redis
local hash = 'banned:'..chat_id
redis:sadd(hash, user_id)
-- Kick from chat
kick_user(user_id, chat_id)
end
-- Global ban
function banall_user(user_id)
if tonumber(user_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_admin2(user_id) then -- Ignore admins
return
end
-- Save to redis
local hash = 'gbanned'
redis:sadd(hash, user_id)
end
-- Global unban
function unbanall_user(user_id)
--Save on redis
local hash = 'gbanned'
redis:srem(hash, user_id)
end
-- Check if user_id is banned in chat_id or not
function is_banned(user_id, chat_id)
--Save on redis
local hash = 'banned:'..chat_id
local banned = redis:sismember(hash, user_id)
return banned or false
end
-- Check if user_id is globally banned or not
function is_gbanned(user_id)
--Save on redis
local hash = 'gbanned'
local banned = redis:sismember(hash, user_id)
return banned or false
end
-- Returns chat_id ban list
function ban_list(chat_id)
local hash = 'banned:'..chat_id
local list = redis:smembers(hash)
local text = "Ban list for: [ID: "..chat_id.." ]:\n\n"
for k,v in pairs(list) do
local user_info = redis:hgetall('user:'..v)
if user_info and user_info.print_name then
local print_name = string.gsub(user_info.print_name, "_", " ")
local print_name = string.gsub(print_name, "", "")
text = text..k.." - "..print_name.." ["..v.."]\n"
else
text = text..k.." - "..v.."\n"
end
end
return text
end
-- Returns globally ban list
function banall_list()
local hash = 'gbanned'
local list = redis:smembers(hash)
local text = "Global bans!\n\n"
for k,v in pairs(list) do
local user_info = redis:hgetall('user:'..v)
if user_info and user_info.print_name then
local print_name = string.gsub(user_info.print_name, "_", " ")
local print_name = string.gsub(print_name, "", "")
text = text..k.." - "..print_name.." ["..v.."]\n"
else
text = text..k.." - "..v.."\n"
end
end
return text
end
-- Support Team
function support_add(support_id)
-- Save to redis
local hash = 'support'
redis:sadd(hash, support_id)
end
function is_support(support_id)
--Save on redis
local hash = 'support'
local support = redis:sismember(hash, support_id)
return support or false
end
function support_remove(support_id)
--Save on redis
local hash = 'support'
redis:srem(hash, support_id)
end
-- Whitelist
function is_whitelisted(user_id)
--Save on redis
local hash = 'whitelist'
local is_whitelisted = redis:sismember(hash, user_id)
return is_whitelisted or false
end
--Begin Chat Mutes
function set_mutes(chat_id)
mutes = {[1]= "Audio: no",[2]= "Photo: no",[3]= "All: no",[4]="Documents: no",[5]="Text: no",[6]= "Video: no",[7]= "Gifs: no"}
local hash = 'mute:'..chat_id
for k,v in pairsByKeys(mutes) do
setting = v
redis:sadd(hash, setting)
end
end
function has_mutes(chat_id)
mutes = {[1]= "Audio: no",[2]= "Photo: no",[3]= "All: no",[4]="Documents: no",[5]="Text: no",[6]= "Video: no",[7]= "Gifs: no"}
local hash = 'mute:'..chat_id
for k,v in pairsByKeys(mutes) do
setting = v
local has_mutes = redis:sismember(hash, setting)
return has_mutes or false
end
end
function rem_mutes(chat_id)
local hash = 'mute:'..chat_id
redis:del(hash)
end
function mute(chat_id, msg_type)
local hash = 'mute:'..chat_id
local yes = "yes"
local no = 'no'
local old_setting = msg_type..': '..no
local setting = msg_type..': '..yes
redis:srem(hash, old_setting)
redis:sadd(hash, setting)
end
function is_muted(chat_id, msg_type)
local hash = 'mute:'..chat_id
local setting = msg_type
local muted = redis:sismember(hash, setting)
return muted or false
end
function unmute(chat_id, msg_type)
--Save on redis
local hash = 'mute:'..chat_id
local yes = 'yes'
local no = 'no'
local old_setting = msg_type..': '..yes
local setting = msg_type..': '..no
redis:srem(hash, old_setting)
redis:sadd(hash, setting)
end
function mute_user(chat_id, user_id)
local hash = 'mute_user:'..chat_id
redis:sadd(hash, user_id)
end
function is_muted_user(chat_id, user_id)
local hash = 'mute_user:'..chat_id
local muted = redis:sismember(hash, user_id)
return muted or false
end
function unmute_user(chat_id, user_id)
--Save on redis
local hash = 'mute_user:'..chat_id
redis:srem(hash, user_id)
end
-- Returns chat_id mute list
function mutes_list(chat_id)
local hash = 'mute:'..chat_id
local list = redis:smembers(hash)
local text = "Mutes for: [ID: "..chat_id.." ]:\n\n"
for k,v in pairsByKeys(list) do
text = text.."Mute "..v.."\n"
end
return text
end
-- Returns chat_user mute list
function muted_user_list(chat_id)
local hash = 'mute_user:'..chat_id
local list = redis:smembers(hash)
local text = "Muted Users for: [ID: "..chat_id.." ]:\n\n"
for k,v in pairsByKeys(list) do
local user_info = redis:hgetall('user:'..v)
if user_info and user_info.print_name then
local print_name = string.gsub(user_info.print_name, "_", " ")
local print_name = string.gsub(print_name, "", "")
text = text..k.." - "..print_name.." ["..v.."]\n"
else
text = text..k.." - [ "..v.." ]\n"
end
end
return text
end
--End Chat Mutes
-- /id by reply
function get_message_callback_id(extra, success, result)
if type(result) == 'boolean' then
print('Old message :(')
return false
end
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.peer_id
send_large_msg(chat, result.from.peer_id)
else
return
end
end
-- kick by reply for mods and owner
function Kick_by_reply(extra, success, result)
if type(result) == 'boolean' then
print('Old message :(')
return false
end
if result.to.type == 'chat' or result.to.type == 'channel' then
local chat = 'chat#id'..result.to.peer_id
if tonumber(result.from.peer_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_momod2(result.from.peer_id, result.to.peer_id) then -- Ignore mods,owner,admin
return "you can't kick mods,owner and admins"
end
chat_del_user(chat, 'user#id'..result.from.peer_id, ok_cb, false)
channel_kick(channel, 'user#id'..result.from.peer_id, ok_cb, false)
else
return
end
end
-- Kick by reply for admins
function Kick_by_reply_admins(extra, success, result)
if type(result) == 'boolean' then
print('Old message :(')
return false
end
if result.to.type == 'chat' or result.to.type == 'channel' then
local chat = 'chat#id'..result.to.peer_id
local channel = 'channel#id'..result.to.peer_id
if tonumber(result.from.peer_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_admin2(result.from.peer_id) then -- Ignore admins
return
end
chat_del_user(chat, 'user#id'..result.from.peer_id, ok_cb, false)
channel_kick(channel, 'user#id'..result.from.peer_id, ok_cb, false)
else
return
end
end
--Ban by reply for admins
function ban_by_reply(extra, success, result)
if type(result) == 'boolean' then
print('Old message :(')
return false
end
if result.to.type == 'chat' or result.to.type == 'channel' then
local chat = 'chat#id'..result.to.peer_id
local channel = 'channel#id'..result.to.peer_id
if tonumber(result.from.peer_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_momod2(result.from.peer_id, result.to.peer_id) then -- Ignore mods,owner,admin
return "you can't kick mods,owner and admins"
end
ban_user(result.from.peer_id, result.to.peer_id)
send_large_msg(chat, "User "..result.from.peer_id.." Banned")
else
return
end
end
-- Ban by reply for admins
function ban_by_reply_admins(extra, success, result)
if type(result) == 'boolean' then
print('Old message :(')
return false
end
if result.to.peer_type == 'chat' or result.to.peer_type == 'channel' then
local chat = 'chat#id'..result.to.peer_id
local channel = 'channel#id'..result.to.peer_id
if tonumber(result.from.peer_id) == tonumber(our_id) then -- Ignore bot
return
end
if is_admin2(result.from.peer_id) then -- Ignore admins
return
end
ban_user(result.from.peer_id, result.to.peer_id)
send_large_msg(chat, "User "..result.from.peer_id.." Banned")
send_large_msg(channel, "User "..result.from.peer_id.." Banned")
else
return
end
end
| gpl-2.0 |
Frownigami1/cuberite | Server/Plugins/APIDump/Classes/Projectiles.lua | 4 | 8443 | return
{
cArrowEntity =
{
Desc = [[
Represents the arrow when it is shot from the bow. A subclass of the {{cProjectileEntity}}.
]],
Functions =
{
CanPickup =
{
Params =
{
{
Name = "Player",
Type = "cPlayer",
},
},
Returns =
{
{
Type = "boolean",
},
},
Notes = "Returns true if the specified player can pick the arrow when it's on the ground",
},
GetBlockHit =
{
Desc = "Gets the block arrow is in",
Returns =
{
{
Type = "Vector3i",
},
},
},
GetDamageCoeff =
{
Returns =
{
{
Type = "number",
},
},
Notes = "Returns the damage coefficient stored within the arrow. The damage dealt by this arrow is multiplied by this coeff",
},
GetPickupState =
{
Returns =
{
{
Type = "cArrowEntity#ePickupState",
},
},
Notes = "Returns the pickup state (one of the psXXX constants, above)",
},
IsCritical =
{
Returns =
{
{
Type = "boolean",
},
},
Notes = "Returns true if the arrow should deal critical damage. Based on the bow charge when the arrow was shot.",
},
SetDamageCoeff =
{
Params =
{
{
Name = "DamageCoeff",
Type = "number",
},
},
Notes = "Sets the damage coefficient. The damage dealt by this arrow is multiplied by this coeff",
},
SetIsCritical =
{
Params =
{
{
Name = "IsCritical",
Type = "boolean",
},
},
Notes = "Sets the IsCritical flag on the arrow. Critical arrow deal additional damage",
},
SetPickupState =
{
Params =
{
{
Name = "PickupState",
Type = "cArrowEntity#ePickupState",
},
},
Notes = "Sets the pickup state (one of the psXXX constants, above)",
},
},
Constants =
{
psInCreative =
{
Notes = "The arrow can be picked up only by players in creative gamemode",
},
psInSurvivalOrCreative =
{
Notes = "The arrow can be picked up by players in survival or creative gamemode",
},
psNoPickup =
{
Notes = "The arrow cannot be picked up at all",
},
},
ConstantGroups =
{
ePickupState =
{
Include = "ps.*",
TextBefore = [[
The following constants are used to signalize whether the arrow, once it lands, can be picked by
players:
]],
},
},
Inherits = "cProjectileEntity",
},
cExpBottleEntity =
{
Desc = [[
Represents a thrown ExpBottle. A subclass of the {{cProjectileEntity}}.
]],
Functions =
{
},
Inherits = "cProjectileEntity",
},
cFireChargeEntity =
{
Desc = [[
Represents a fire charge that has been shot by a Blaze or a {{cDispenserEntity|Dispenser}}. A subclass
of the {{cProjectileEntity}}.
]],
Functions =
{
},
Inherits = "cProjectileEntity",
},
cFireworkEntity =
{
Desc = [[
Represents a firework rocket.
]],
Functions =
{
GetItem =
{
Returns =
{
{
Type = "cItem",
},
},
Notes = "Returns the item that has been used to create the firework rocket. The item's m_FireworkItem member contains all the firework-related data.",
},
GetTicksToExplosion =
{
Returns =
{
{
Type = "number",
},
},
Notes = "Returns the number of ticks left until the firework explodes.",
},
SetItem =
{
Params =
{
{
Name = "FireworkItem",
Type = "cItem",
},
},
Notes = "Sets a new item to be used for the firework.",
},
SetTicksToExplosion =
{
Params =
{
{
Name = "NumTicks",
Type = "number",
},
},
Notes = "Sets the number of ticks left until the firework explodes.",
},
},
Inherits = "cProjectileEntity",
},
cGhastFireballEntity =
{
Desc = "",
Functions =
{
},
Inherits = "cProjectileEntity",
},
cProjectileEntity =
{
Desc = "Base class for all projectiles, such as arrows and fireballs.",
Functions =
{
GetCreator =
{
Returns =
{
{
Type = "cEntity",
},
},
Notes = "Returns the entity who created this projectile. May return nil.",
},
GetCreatorName =
{
Returns =
{
{
Type = "string",
},
},
Notes = "Returns the name of the player that created the projectile. Will be empty for non-player creators",
},
GetCreatorUniqueID =
{
Returns =
{
{
Type = "number",
},
},
Notes = "Returns the unique ID of the entity who created this projectile, or {{cEntity#INVALID_ID|cEntity.INVALID_ID}} if the projectile wasn't created by an entity.",
},
GetMCAClassName =
{
Returns =
{
{
Type = "string",
},
},
Notes = "Returns the string that identifies the projectile type (class name) in MCA files",
},
GetProjectileKind =
{
Returns =
{
{
Type = "cProjectileEntity#eKind",
},
},
Notes = "Returns the kind of this projectile (pkXXX constant)",
},
IsInGround =
{
Returns =
{
{
Type = "boolean",
},
},
Notes = "Returns true if this projectile has hit the ground.",
},
},
Constants =
{
pkArrow =
{
Notes = "The projectile is an {{cArrowEntity|arrow}}",
},
pkEgg =
{
Notes = "The projectile is a {{cThrownEggEntity|thrown egg}}",
},
pkEnderPearl =
{
Notes = "The projectile is a {{cThrownEnderPearlEntity|thrown enderpearl}}",
},
pkExpBottle =
{
Notes = "The projectile is a {{cExpBottleEntity|thrown exp bottle}}",
},
pkFireCharge =
{
Notes = "The projectile is a {{cFireChargeEntity|fire charge}}",
},
pkFirework =
{
Notes = "The projectile is a (flying) {{cFireworkEntity|firework}}",
},
pkFishingFloat =
{
Notes = "The projectile is a {{cFloater|fishing float}}",
},
pkGhastFireball =
{
Notes = "The projectile is a {{cGhastFireballEntity|ghast fireball}}",
},
pkSnowball =
{
Notes = "The projectile is a {{cThrownSnowballEntity|thrown snowball}}",
},
pkSplashPotion =
{
Notes = "The projectile is a {{cSplashPotionEntity|thrown splash potion}}",
},
pkWitherSkull =
{
Notes = "The projectile is a {{cWitherSkullEntity|wither skull}}",
},
},
ConstantGroups =
{
eKind =
{
Include = "pk.*",
TextBefore = "The following constants are used to distinguish between the different projectile kinds:",
},
},
Inherits = "cEntity",
},
cSplashPotionEntity =
{
Desc = [[
Represents a thrown splash potion.
]],
Functions =
{
GetEntityEffect =
{
Returns =
{
{
Type = "cEntityEffect",
},
},
Notes = "Returns the entity effect in this potion",
},
GetEntityEffectType =
{
Returns =
{
{
Type = "cEntityEffect",
},
},
Notes = "Returns the effect type of this potion",
},
GetItem =
{
Returns =
{
{
Type = "cItem",
},
},
Notes = "Gets the potion item that was thrown.",
},
GetPotionColor =
{
Returns =
{
{
Type = "number",
},
},
Notes = "Returns the color index of the particles emitted by this potion",
},
SetEntityEffect =
{
Params =
{
{
Name = "EntityEffect",
Type = "cEntityEffect",
},
},
Notes = "Sets the entity effect for this potion",
},
SetEntityEffectType =
{
Params =
{
{
Name = "EntityEffectType",
Type = "cEntityEffect#eType",
},
},
Notes = "Sets the effect type of this potion",
},
SetPotionColor =
{
Params =
{
{
Name = "PotionColor",
Type = "number",
},
},
Notes = "Sets the color index of the particles for this potion",
},
},
Inherits = "cProjectileEntity",
},
cThrownEggEntity =
{
Desc = [[
Represents a thrown egg.
]],
Functions =
{
},
Inherits = "cProjectileEntity",
},
cThrownEnderPearlEntity =
{
Desc = "Represents a thrown ender pearl.",
Functions =
{
},
Inherits = "cProjectileEntity",
},
cThrownSnowballEntity =
{
Desc = "Represents a thrown snowball.",
Functions =
{
},
Inherits = "cProjectileEntity",
},
cWitherSkullEntity =
{
Desc = "Represents a wither skull being shot.",
Functions =
{
},
Inherits = "cProjectileEntity",
},
}
| apache-2.0 |
hacker44-h44/50 | plugins/domaintools.lua | 359 | 1494 | local ltn12 = require "ltn12"
local https = require "ssl.https"
-- Edit data/mashape.lua with your Mashape API key
-- http://docs.mashape.com/api-keys
local mashape = load_from_file('data/mashape.lua', {
api_key = ''
})
local function check(name)
local api = "https://domainsearch.p.mashape.com/index.php?"
local param = "name="..name
local url = api..param
local api_key = mashape.api_key
if api_key:isempty() then
return 'Configure your Mashape API Key'
end
local headers = {
["X-Mashape-Key"] = api_key,
["Accept"] = "application/json"
}
local respbody = {}
local body, code = https.request{
url = url,
method = "GET",
headers = headers,
sink = ltn12.sink.table(respbody),
protocol = "tlsv1"
}
if code ~= 200 then return code end
local body = table.concat(respbody)
local body = json:decode(body)
--vardump(body)
local domains = "List of domains for '"..name.."':\n"
for k,v in pairs(body) do
print(k)
local status = " ❌ "
if v == "Available" then
status = " ✔ "
end
domains = domains..k..status.."\n"
end
return domains
end
local function run(msg, matches)
if matches[1] == "check" then
local name = matches[2]
return check(name)
end
end
return {
description = "Domain tools",
usage = {"!domain check [domain] : Check domain name availability.",
},
patterns = {
"^!domain (check) (.*)$",
},
run = run
}
| gpl-2.0 |
CarabusX/Zero-K | LuaRules/Gadgets/unit_fighter_pullup.lua | 6 | 1046 | if not gadgetHandler:IsSyncedCode() then return end
function gadget:GetInfo()
return {
name = "Fighter pull-up",
desc = "Sets attack safety distance for fighter/bomber aircraft",
author = "raaar",
date = "2015",
license = "PD",
layer = 3,
enabled = true
}
end
local pullupDist = {}
for unitDefID, unitDef in pairs(UnitDefs) do
local dist = unitDef.customParams.fighter_pullup_dist
if dist then
pullupDist[unitDefID] = dist
end
end
local spMoveCtrlGetTag = Spring.MoveCtrl.GetTag
local spMoveCtrlSetAirMoveTypeData = Spring.MoveCtrl.SetAirMoveTypeData
local moveTypeDataTable = {attackSafetyDistance = 123}
function gadget:UnitCreated(unitID, unitDefID)
local dist = pullupDist[unitDefID]
if dist then
if spMoveCtrlGetTag(unitID) == nil then
moveTypeDataTable.attackSafetyDistance = dist
spMoveCtrlSetAirMoveTypeData(unitID, moveTypeDataTable)
else
Spring.Echo("LUA_ERRRUN", "Fighter pullup with spMoveCtrlGetTag", (UnitDefs[unitDefID] and UnitDefs[unitDefID].name) or "noname")
end
end
end
| gpl-2.0 |
mattyx14/otxserver | data/monster/undeads/blood_beast.lua | 2 | 3556 | local mType = Game.createMonsterType("Blood Beast")
local monster = {}
monster.description = "a blood beast"
monster.experience = 1000
monster.outfit = {
lookType = 602,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.raceId = 1040
monster.Bestiary = {
class = "Undead",
race = BESTY_RACE_UNDEAD,
toKill = 1000,
FirstUnlock = 50,
SecondUnlock = 500,
CharmsPoints = 25,
Stars = 3,
Occurrence = 0,
Locations = "Oramond/Southern Plains, Lower Rathleton, Oramond/Western Plains, \z
Underground Glooth Factory, Jaccus Maxxen's Dungeon."
}
monster.health = 1600
monster.maxHealth = 1600
monster.race = "venom"
monster.corpse = 20980
monster.speed = 220
monster.manaCost = 0
monster.changeTarget = {
interval = 2000,
chance = 4
}
monster.strategiesTarget = {
nearest = 70,
health = 10,
damage = 10,
random = 10,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = true,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = true,
canWalkOnFire = false,
canWalkOnPoison = true
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "Roarr!", yell = false}
}
monster.loot = {
{id = 21178, chance = 2010}, -- glooth club
{id = 9640, chance = 3080}, -- poisonous slime
{id = 21146, chance = 2720}, -- glooth steak
{id = 3031, chance = 100000, maxCount = 139}, -- gold coin
{id = 21194, chance = 1040}, -- slime heart
{id = 236, chance = 7710}, -- strong health potion
{id = 7366, chance = 1290, maxCount = 5}, -- viper star
{id = 21183, chance = 250}, -- glooth amulet
{id = 21179, chance = 210}, -- glooth blade
{id = 21178, chance = 210}, -- glooth club
{id = 21180, chance = 250}, -- glooth axe
{id = 21158, chance = 280} -- glooth spear
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, skill = 82, attack = 50, condition = {type = CONDITION_POISON, totalDamage = 260, interval = 4000}},
{name ="combat", interval = 2000, chance = 10, type = COMBAT_EARTHDAMAGE, minDamage = -65, maxDamage = -105, range = 5, shootEffect = CONST_ANI_GREENSTAR, effect = CONST_ME_POISONAREA, target = true},
-- poison
{name ="condition", type = CONDITION_POISON, interval = 2000, chance = 17, minDamage = -300, maxDamage = -400, radius = 4, effect = CONST_ME_MAGIC_GREEN, target = false}
}
monster.defenses = {
defense = 36,
armor = 23,
{name ="speed", interval = 2000, chance = 8, speedChange = 314, effect = CONST_ME_MAGIC_RED, target = false, duration = 6000},
{name ="combat", interval = 2000, chance = 7, type = COMBAT_HEALING, minDamage = 80, maxDamage = 120, effect = CONST_ME_MAGIC_BLUE, target = false}
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = 10},
{type = COMBAT_EARTHDAMAGE, percent = 100},
{type = COMBAT_FIREDAMAGE, percent = -10},
{type = COMBAT_LIFEDRAIN, percent = 100},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = true},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
hacker44-h44/50 | plugins/webshot.lua | 919 | 1473 | local helpers = require "OAuth.helpers"
local base = 'https://screenshotmachine.com/'
local url = base .. 'processor.php'
local function get_webshot_url(param)
local response_body = {}
local request_constructor = {
url = url,
method = "GET",
sink = ltn12.sink.table(response_body),
headers = {
referer = base,
dnt = "1",
origin = base,
["User-Agent"] = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"
},
redirect = false
}
local arguments = {
urlparam = param,
size = "FULL"
}
request_constructor.url = url .. "?" .. helpers.url_encode_arguments(arguments)
local ok, response_code, response_headers, response_status_line = https.request(request_constructor)
if not ok or response_code ~= 200 then
return nil
end
local response = table.concat(response_body)
return string.match(response, "href='(.-)'")
end
local function run(msg, matches)
local find = get_webshot_url(matches[1])
if find then
local imgurl = base .. find
local receiver = get_receiver(msg)
send_photo_from_url(receiver, imgurl)
end
end
return {
description = "Send an screenshot of a website.",
usage = {
"!webshot [url]: Take an screenshot of the web and send it back to you."
},
patterns = {
"^!webshot (https?://[%w-_%.%?%.:/%+=&]+)$",
},
run = run
}
| gpl-2.0 |
hacker44-h44/50 | plugins/time.lua | 771 | 2865 | -- Implement a command !time [area] which uses
-- 2 Google APIs to get the desired result:
-- 1. Geocoding to get from area to a lat/long pair
-- 2. Timezone to get the local time in that lat/long location
-- Globals
-- If you have a google api key for the geocoding/timezone api
api_key = nil
base_api = "https://maps.googleapis.com/maps/api"
dateFormat = "%A %d %B - %H:%M:%S"
-- Need the utc time for the google api
function utctime()
return os.time(os.date("!*t"))
end
-- Use the geocoding api to get the lattitude and longitude with accuracy specifier
-- CHECKME: this seems to work without a key??
function get_latlong(area)
local api = base_api .. "/geocode/json?"
local parameters = "address=".. (URL.escape(area) or "")
if api_key ~= nil then
parameters = parameters .. "&key="..api_key
end
-- Do the request
local res, code = https.request(api..parameters)
if code ~=200 then return nil end
local data = json:decode(res)
if (data.status == "ZERO_RESULTS") then
return nil
end
if (data.status == "OK") then
-- Get the data
lat = data.results[1].geometry.location.lat
lng = data.results[1].geometry.location.lng
acc = data.results[1].geometry.location_type
types= data.results[1].types
return lat,lng,acc,types
end
end
-- Use timezone api to get the time in the lat,
-- Note: this needs an API key
function get_time(lat,lng)
local api = base_api .. "/timezone/json?"
-- Get a timestamp (server time is relevant here)
local timestamp = utctime()
local parameters = "location=" ..
URL.escape(lat) .. "," ..
URL.escape(lng) ..
"×tamp="..URL.escape(timestamp)
if api_key ~=nil then
parameters = parameters .. "&key="..api_key
end
local res,code = https.request(api..parameters)
if code ~= 200 then return nil end
local data = json:decode(res)
if (data.status == "ZERO_RESULTS") then
return nil
end
if (data.status == "OK") then
-- Construct what we want
-- The local time in the location is:
-- timestamp + rawOffset + dstOffset
local localTime = timestamp + data.rawOffset + data.dstOffset
return localTime, data.timeZoneId
end
return localTime
end
function getformattedLocalTime(area)
if area == nil then
return "The time in nowhere is never"
end
lat,lng,acc = get_latlong(area)
if lat == nil and lng == nil then
return 'It seems that in "'..area..'" they do not have a concept of time.'
end
local localTime, timeZoneId = get_time(lat,lng)
return "The local time in "..timeZoneId.." is: ".. os.date(dateFormat,localTime)
end
function run(msg, matches)
return getformattedLocalTime(matches[1])
end
return {
description = "Displays the local time in an area",
usage = "!time [area]: Displays the local time in that area",
patterns = {"^!time (.*)$"},
run = run
}
| gpl-2.0 |
tenplus1/ethereal | stairs.lua | 2 | 10617 |
local S = ethereal.intllib
-- Stairs Redo
if stairs and stairs.mod and stairs.mod == "redo" then
stairs.register_all("crystal_block", "ethereal:crystal_block",
{cracky = 1, level = 2, puts_out_fire = 1, cools_lava = 1},
{"crystal_block.png"},
S("Crystal Block Stair"),
S("Crystal Block Slab"),
default.node_sound_glass_defaults())
stairs.register_all("icebrick", "ethereal:icebrick",
{cracky = 3, puts_out_fire = 1, cools_lava = 1},
{"brick_ice.png"},
S("Ice Brick Stair"),
S("Ice Brick Slab"),
default.node_sound_glass_defaults())
stairs.register_all("snowbrick", "ethereal:snowbrick",
{crumbly = 3, puts_out_fire = 1, cools_lava = 1},
{"brick_snow.png"},
S("Snow Brick Stair"),
S("Snow Brick Slab"),
default.node_sound_dirt_defaults({
footstep = {name = "default_snow_footstep", gain = 0.25},
dug = {name = "default_snow_footstep", gain = 0.75},
}))
stairs.register_all("dry_dirt", "ethereal:dry_dirt",
{crumbly = 3},
{"ethereal_dry_dirt.png"},
S("Dried Dirt Stair"),
S("Dried Dirt Slab"),
default.node_sound_dirt_defaults())
stairs.register_all("mushroom_trunk", "ethereal:mushroom_trunk",
{choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
{"mushroom_trunk.png"},
S("Mushroom Trunk Stair"),
S("Mushroom Trunk Slab"),
default.node_sound_wood_defaults())
stairs.register_all("mushroom", "ethereal:mushroom",
{choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
{"mushroom_block.png"},
S("Mushroom Top Stair"),
S("Mushroom Top Slab"),
default.node_sound_wood_defaults())
stairs.register_all("frost_wood", "ethereal:frost_wood",
{choppy = 2, oddly_breakable_by_hand = 1, put_out_fire = 1},
{"frost_wood.png"},
S("Frost Wood Stair"),
S("Frost Wood Slab"),
default.node_sound_wood_defaults())
stairs.register_all("yellow_wood", "ethereal:yellow_wood",
{choppy = 2, oddly_breakable_by_hand = 1, put_out_fire = 1},
{"yellow_wood.png"},
S("Healing Wood Stair"),
S("Healing Wood Slab"),
default.node_sound_wood_defaults())
stairs.register_all("palm_wood", "ethereal:palm_wood",
{choppy = 2, oddly_breakable_by_hand = 1, flammable = 3},
{"moretrees_palm_wood.png"},
S("Palm Wood Stair"),
S("Palm Wood Slab"),
default.node_sound_wood_defaults())
stairs.register_all("birch_wood", "ethereal:birch_wood",
{choppy = 2, oddly_breakable_by_hand = 1, flammable = 3},
{"moretrees_birch_wood.png"},
S("Birch Wood Stair"),
S("Birch Wood Slab"),
default.node_sound_wood_defaults())
stairs.register_all("banana_wood", "ethereal:banana_wood",
{choppy = 2, oddly_breakable_by_hand = 1, flammable = 3},
{"banana_wood.png"},
S("Banana Wood Stair"),
S("Banana Wood Slab"),
default.node_sound_wood_defaults())
stairs.register_all("willow_wood", "ethereal:willow_wood",
{choppy = 2, oddly_breakable_by_hand = 1, flammable = 3},
{"willow_wood.png"},
S("Willow Wood Stair"),
S("Willow Wood Slab"),
default.node_sound_wood_defaults())
stairs.register_all("redwood_wood", "ethereal:redwood_wood",
{choppy = 2, oddly_breakable_by_hand = 1, flammable = 3},
{"redwood_wood.png"},
S("Redwood stair"),
S("Redwood Slab"),
default.node_sound_wood_defaults())
stairs.register_all("bamboo_wood", "ethereal:bamboo_floor",
{snappy = 3, choppy = 2, oddly_breakable_by_hand = 1, flammable = 3},
{"bamboo_floor.png"},
S("Bamboo stair"),
S("Bamboo Slab"),
default.node_sound_wood_defaults())
-- Stairs Plus (in More Blocks)
elseif minetest.global_exists("stairsplus") then
stairsplus:register_all("ethereal", "crystal_block", "ethereal:crystal_block", {
description = S("Crystal block"),
tiles = {"crystal_block.png"},
groups = {cracky = 1, falling_node = 1, puts_out_fire = 1, cools_lava = 1},
sounds = default.node_sound_glass_defaults(),
})
stairsplus:register_all("ethereal", "icebrick", "ethereal:icebrick", {
description = S("Ice Brick"),
tiles = {"brick_ice.png"},
groups = {cracky = 3, puts_out_fire = 1, cools_lava = 1},
sounds = default.node_sound_glass_defaults(),
})
stairsplus:register_all("ethereal", "snowbrick", "ethereal:snowbrick", {
description = S("Snow Brick"),
tiles = {"brick_snow.png"},
groups = {crumbly = 3, puts_out_fire = 1, cools_lava = 1},
sounds = default.node_sound_dirt_defaults({
footstep = {name = "default_snow_footstep", gain = 0.25},
dug = {name = "default_snow_footstep", gain = 0.75},
})
})
stairsplus:register_all("ethereal", "dry_dirt", "ethereal:dry_dirt", {
description = S("Dried Dirt"),
tiles = {"ethereal_dry_dirt.png"},
groups = {crumbly = 3},
sounds = default.node_sound_dirt_defaults(),
})
stairsplus:register_all("ethereal", "mushroom_trunk", "ethereal:mushroom_trunk", {
description = S("Mushroom Trunk"),
tiles = {"mushroom_trunk.png"},
groups = {choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
})
stairsplus:register_all("ethereal", "mushroom", "ethereal:mushroom", {
description = S("Mushroom Top"),
tiles = {"mushroom_block.png"},
groups = {choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
})
stairsplus:register_all("ethereal", "frost_wood", "ethereal:frost_wood", {
description = S("Frost Wood"),
tiles = {"frost_wood.png"},
groups = {choppy = 2, oddly_breakable_by_hand = 1, put_out_fire = 1},
sounds = default.node_sound_wood_defaults(),
})
stairsplus:register_all("ethereal", "yellow_wood", "ethereal:yellow_wood", {
description = S("Healing Wood"),
tiles = {"yellow_wood.png"},
groups = {choppy = 2, oddly_breakable_by_hand = 1, put_out_fire = 1},
sounds = default.node_sound_wood_defaults(),
})
stairsplus:register_all("ethereal", "palm_wood", "ethereal:palm_wood", {
description = S("Palm Wood"),
tiles = {"moretrees_palm_wood.png"},
groups = {choppy = 2, oddly_breakable_by_hand = 1, flammable = 3},
sounds = default.node_sound_wood_defaults(),
})
stairsplus:register_all("ethereal", "birch_wood", "ethereal:birch_wood", {
description = S("Birch Wood"),
tiles = {"moretrees_birch_wood.png"},
groups = {choppy = 2, oddly_breakable_by_hand = 1, flammable = 3},
sounds = default.node_sound_wood_defaults(),
})
stairsplus:register_all("ethereal", "banana_wood", "ethereal:banana_wood", {
description = S("Banana Wood"),
tiles = {"banana_wood.png"},
groups = {choppy = 2, oddly_breakable_by_hand = 1, flammable = 3},
sounds = default.node_sound_wood_defaults(),
})
stairsplus:register_all("ethereal", "willow_wood", "ethereal:willow_wood", {
description = S("Willow Wood"),
tiles = {"willow_wood.png"},
groups = {choppy = 2, oddly_breakable_by_hand = 1, flammable = 3},
sounds = default.node_sound_wood_defaults(),
})
stairsplus:register_all("ethereal", "redwood_wood", "ethereal:redwood_wood", {
description = S("Redwood"),
tiles = {"redwood_wood.png"},
groups = {choppy = 2, oddly_breakable_by_hand = 1, flammable = 3},
sounds = default.node_sound_wood_defaults(),
})
stairsplus:register_all("ethereal", "bamboo_wood", "ethereal:bamboo_floor", {
description = S("Bamboo"),
tiles = {"bamboo_floor.png"},
groups = {snappy = 3, choppy = 2, oddly_breakable_by_hand = 1, flammable = 3},
sounds = default.node_sound_wood_defaults(),
})
-- Default Stairs
else
stairs.register_stair_and_slab("crystal_block", "ethereal:crystal_block",
{cracky = 1, level = 2, puts_out_fire = 1, cools_lava = 1},
{"crystal_block.png"},
S("Crystal Block Stair"),
S("Crystal Block Slab"),
default.node_sound_glass_defaults())
stairs.register_stair_and_slab("icebrick", "ethereal:icebrick",
{cracky = 3, puts_out_fire = 1, cools_lava = 1},
{"brick_ice.png"},
S("Ice Brick Stair"),
S("Ice Brick Slab"),
default.node_sound_glass_defaults())
stairs.register_stair_and_slab("snowbrick", "ethereal:snowbrick",
{crumbly = 3, puts_out_fire = 1, cools_lava = 1},
{"brick_snow.png"},
S("Snow Brick Stair"),
S("Snow Brick Slab"),
default.node_sound_dirt_defaults({
footstep = {name = "default_snow_footstep", gain = 0.15},
dug = {name = "default_snow_footstep", gain = 0.2},
dig = {name = "default_snow_footstep", gain = 0.2}
}))
stairs.register_stair_and_slab("dry_dirt", "ethereal:dry_dirt",
{crumbly = 3},
{"ethereal_dry_dirt.png"},
S("Dried Dirt Stair"),
S("Dried Dirt Slab"),
default.node_sound_dirt_defaults())
stairs.register_stair_and_slab("mushroom_trunk", "ethereal:mushroom_trunk",
{choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
{"mushroom_trunk.png"},
S("Mushroom Trunk Stair"),
S("Mushroom Trunk Slab"),
default.node_sound_wood_defaults())
stairs.register_stair_and_slab("mushroom", "ethereal:mushroom",
{choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
{"mushroom_block.png"},
S("Mushroom Top Stair"),
S("Mushroom Top Slab"),
default.node_sound_wood_defaults())
stairs.register_stair_and_slab("frost_wood", "ethereal:frost_wood",
{choppy = 2, oddly_breakable_by_hand = 1, put_out_fire = 1},
{"frost_wood.png"},
S("Frost Wood Stair"),
S("Frost Wood Slab"),
default.node_sound_wood_defaults())
stairs.register_stair_and_slab("yellow_wood", "ethereal:yellow_wood",
{choppy = 2, oddly_breakable_by_hand = 1, put_out_fire = 1},
{"yellow_wood.png"},
S("Healing Wood Stair"),
S("Healing Wood Slab"),
default.node_sound_wood_defaults())
stairs.register_stair_and_slab("palm_wood", "ethereal:palm_wood",
{choppy = 2, oddly_breakable_by_hand = 1, flammable = 3},
{"moretrees_palm_wood.png"},
S("Palm Wood Stair"),
S("Palm Wood Slab"),
default.node_sound_wood_defaults())
stairs.register_stair_and_slab("birch_wood", "ethereal:birch_wood",
{choppy = 2, oddly_breakable_by_hand = 1, flammable = 3},
{"moretrees_birch_wood.png"},
"Birch Wood Stair",
"Birch Wood Slab",
default.node_sound_wood_defaults())
stairs.register_stair_and_slab("banana_wood", "ethereal:banana_wood",
{choppy = 2, oddly_breakable_by_hand = 1, flammable = 3},
{"banana_wood.png"},
S("Banana Wood Stair"),
S("Banana Wood Slab"),
default.node_sound_wood_defaults())
stairs.register_stair_and_slab("willow_wood", "ethereal:willow_wood",
{choppy = 2, oddly_breakable_by_hand = 1, flammable = 3},
{"willow_wood.png"},
S("Willow Wood Stair"),
S("Willow Wood Slab"),
default.node_sound_wood_defaults())
stairs.register_stair_and_slab("redwood_wood", "ethereal:redwood_wood",
{choppy = 2, oddly_breakable_by_hand = 1, flammable = 3},
{"redwood_wood.png"},
S("Redwood stair"),
S("Redwood Slab"),
default.node_sound_wood_defaults())
stairs.register_stair_and_slab("bamboo_wood", "ethereal:bamboo_floor",
{snappy = 3, choppy = 2, oddly_breakable_by_hand = 1, flammable = 3},
{"bamboo_floor.png"},
S("Bamboo stair"),
S("Bamboo Slab"),
default.node_sound_wood_defaults())
end
| mit |
MeshGeometry/Urho3D | Source/Urho3D/LuaScript/pkgs/ToZerobraneStudioHook.lua | 9 | 12213 | --
-- Copyright (c) 2008-2017 the Urho3D project.
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-- THE SOFTWARE.
--
-- Highly based on "ToDoxHook.lua", adjusted for Zerobrane Studio API format.
-- Compatible with Zerobrane Studio 0.41+ (Zerobrane Studio 0.40 and below may have issues)
--[[ Copy result in your Zerobrane Studio's folder "api/lua" and set it in your
"interpreters" file with the filename (excluding it's lua extension) into the
"api" table variable. ]]--
require "ToDoxHook"
function printFunction(self,ident,close,isfunc)
local func = {}
func.mod = self.mod
func.type = self.type
func.ptr = self.ptr
func.name = self.name
func.lname = self.lname
func.const = self.const
func.cname = self.cname
func.lname = self.lname
if isfunc then
func.name = func.lname
end
currentFunction = func
local i = 1
while self.args[i] do
self.args[i]:print(ident.." ",",")
i = i + 1
end
currentFunction = nil
if currentClass == nil then
table.insert(globalFunctions, func)
else
if func.name == "delete" then
func.type = "void"
end
if currentClass.functions == nil then
currentClass.functions = { func }
else
table.insert(currentClass.functions, func)
end
end
end
-- Workaround for Zerobrane Studio's tool-tip with overloaded functions
function adjustClassesOverloadFuncs()
for i, class in ipairs(classes) do
if classes[i].functions ~= nil then
for j, func in ipairs(classes[i].functions) do
for k, searchfunc in ipairs(classes[i].functions) do
-- don't apply on same
if k ~= j and func.name == searchfunc.name then
if classes[i].functions[j].overloads == nil then
classes[i].functions[j].overloads = {}
end
table.insert(classes[i].functions[j].overloads, searchfunc)
table.remove(classes[i].functions, k)
adjustClassesOverloadFuncs()
return
end
end
end
end
end
end
function writeFunctionArgs(file, declarations)
local count = table.maxn(declarations)
for i = 1, count do
local declaration = declarations[i]
if declaration.type ~= "void" then
-- add parameter type
local param_str = declaration.type
-- add pointer or reference
if declaration.ptr ~= "" then
param_str = param_str .. declaration.ptr
end
-- add parameter name
param_str = param_str .. " " .. declaration.name
-- add parameter default value
if declaration.def ~= "" then
param_str = param_str .. " = " .. declaration.def
end
local fixedParamStr = param_str:gsub([[(")]], [[\%1]])
file:write(fixedParamStr)
end
if i ~= count then
file:write(", ")
end
end
end
function writeFunctionReturn(file, func)
local return_str = ""
if func.type ~= "" and func.type ~= "void" then
return_str = return_str .. func.type
end
if func.ptr ~= "" then
if func.type == "" and classname ~= nil then
return_str = return_str .. classname
end
return_str = return_str .. func.ptr
end
file:write(return_str)
end
function writeInheritances(file, classname)
for i, inheritance in ipairs(classes) do
if inheritance.name == classname then
if inheritance.functions ~= nil then
for j, func in ipairs(inheritance.functions) do
writeFunction(file, func, classname, true)
end
end
if inheritance.properties ~= nil then
for j, property in ipairs(inheritance.properties) do
writeProperty(file, property)
end
end
-- append inheritance functions & properties
if inheritance.base ~= "" then
writeInheritances(file, inheritance.base)
end
end
end
end
function writeClasses(file)
sortByName(classes)
adjustClassesOverloadFuncs()
file:write("\n\n -- Classes")
for i, class in ipairs(classes) do
file:write("\n " .. class.name .. " = {")
if class.functions ~= nil or class.properties ~= nil then
file:write("\n childs = {")
end
if class.functions ~= nil then
for i, func in ipairs(class.functions) do
writeFunction(file, func, class.name)
end
end
if class.properties ~= nil then
for i, property in ipairs(class.properties) do
writeProperty(file, property)
end
end
-- append inheritance functions & properties
if class.base ~= "" then
writeInheritances(file, class.base)
end
if class.functions ~= nil or class.properties ~= nil then
file:write("\n },")
end
file:write("\n type = \"class\"")
file:write("\n },")
end
end
function writeEnumerates(file)
sortByName(enumerates)
file:write("\n\n -- Enumerations\n")
for i, enumerate in ipairs(enumerates) do
for i, value in ipairs(enumerate.values) do
file:write("\n " .. value .. " = {")
file:write("\n description = \"(Readonly) int for '" .. enumerate.name .. "'\",")
file:write("\n type = \"value\"")
file:write("\n },")
end
end
end
function writeFunction(file, func, classname, isInheritance, asFunc)
-- ignore operators
if func.name:find("^operator[=%+%-%*%(%)\\</]") == nil then
-- ignore new/delete object if from inheritance
if not ((func.name == classname or func.name == "new" or func.name == "delete") and isInheritance == true) then
-- write function begin
file:write("\n " .. func.name .. " = {")
-- write parameters
file:write("\n args = \"(")
if func.declarations ~= nil then
writeFunctionArgs(file, func.declarations)
end
file:write(")\",")
-- write description preparation
local isFirstDescription = true
if func.overloads ~= nil or func.descriptions ~= nil then
file:write("\n description = \"")
end
-- write overloaded parameters in description, if any
if func.overloads ~= nil then
for i, overload in ipairs(func.overloads) do
if isFirstDescription == false then
file:write(",\\n")
else
isFirstDescription = false
end
file:write("(")
writeFunctionReturn(file, overload)
file:write(") "..overload.name.." (")
writeFunctionArgs(file, overload.declarations)
file:write(")")
end
end
-- write description
if func.descriptions ~= nil then
for i, description in ipairs(func.descriptions) do
if isFirstDescription == false then
file:write("\\n")
else
isFirstDescription = false
end
local fixedDescription = description:gsub([[(")]], [[\%1]])
file:write(fixedDescription)
end
end
-- write description end
if func.overloads ~= nil or func.descriptions ~= nil then
file:write("\",")
end
-- write returns
if func.type ~= "" or func.ptr ~= "" then
file:write("\n returns = \"(")
writeFunctionReturn(file, func)
file:write(")\",")
end
-- write valuetype
if func.ptr ~= "" then
if func.type ~= "" then
file:write("\n valuetype = \"" .. func.type:gsub("(const%s+)","") .. "\",")
elseif classname ~= nil then
file:write("\n valuetype = \"" .. classname .. "\",")
end
end
-- write function end
if asFunc == true then
file:write("\n type = \"function\"") -- accepts auto-completion with ".", ":" and global
else
file:write("\n type = \"method\"") -- accepts auto-completion only with ":"
end
file:write("\n },")
end
end
end
function writeGlobalConstants(file)
sortByName(globalConstants)
file:write("\n\n -- Global Constants\n")
for i, constant in ipairs(globalConstants) do
file:write("\n " .. constant.name .. " = {")
-- write valuetype
if constant.ptr ~= "" then
if constant.type ~= "" then
file:write("\n valuetype = \"" .. constant.type:gsub("(const%s+)","") .. "\",")
end
end
-- write description (type)
file:write("\n description = \"" .. constant.type .. constant.ptr .. "\",")
-- write constant end
file:write("\n type = \"value\"")
file:write("\n },")
end
end
function writeGlobalConstants(file)
sortByName(globalConstants)
file:write("\n\n -- Global Constants\n")
for i, constant in ipairs(globalConstants) do
file:write("\n " .. constant.name .. " = {")
-- write valuetype
if constant.ptr ~= "" then
if constant.type ~= "" then
file:write("\n valuetype = \"" .. constant.type:gsub("(const%s+)","") .. "\",")
end
end
-- write description (type)
file:write("\n description = \"" .. constant.type .. constant.ptr .. "\",")
-- write constant end
file:write("\n type = \"value\"")
file:write("\n },")
end
end
function writeGlobalFunctions(file)
sortByName(globalFunctions)
file:write("\n\n -- Global Functions\n")
for i, func in ipairs(globalFunctions) do
writeFunction(file, func, nil, nil, true)
end
end
function writeGlobalProperties(file)
file:write("\n")
for i, property in ipairs(globalProperties) do
writeProperty(file, property)
end
end
function writeProperty(file, property)
file:write("\n " .. property.name .. " = {")
-- write valuetype
if property.ptr ~= "" then
if property.type ~= "" then
file:write("\n valuetype = \"" .. property.type:gsub("(const%s+)","") .. "\",")
end
end
-- write description (type)
if property.mod:find("tolua_readonly") == nil then
file:write("\n description = \"" .. property.type .. property.ptr .. "")
else
file:write("\n description = \"(Readonly) " .. property.type .. property.ptr .. "")
end
-- write description
if property.descriptions ~= nil then
for i, description in ipairs(property.descriptions) do
local fixedDescription = description:gsub([[(")]], [[\%1]])
file:write("\\n" .. fixedDescription)
end
end
file:write("\",")
-- write property end
file:write("\n type = \"value\"")
file:write("\n },")
end
function classPackage:print()
curDir = getCurrentDirectory()
if flags.o == nil then
print("Invalid output filename");
return
end
local filename = flags.o
local file = io.open(filename, "wt")
file:write("-- Urho3D API generated on "..os.date('%Y-%m-%d'))
file:write("\n\nlocal api = {")
local i = 1
while self[i] do
self[i]:print("","")
i = i + 1
end
printDescriptionsFromPackageFile(flags.f)
writeClasses(file)
writeEnumerates(file)
writeGlobalFunctions(file)
writeGlobalProperties(file)
writeGlobalConstants(file)
file:write("\n}\nreturn api\n")
file:close()
end
| mit |
nitheeshkl/kln_awesome | awesome_3.5/vicious/widgets/wifi.lua | 6 | 3025 | ---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- {{{ Grab environment
local tonumber = tonumber
local math = { ceil = math.ceil }
local setmetatable = setmetatable
local helpers = require("vicious.helpers")
local io = {
open = io.open,
popen = io.popen
}
local string = {
find = string.find,
match = string.match
}
-- }}}
-- Wifi: provides wireless information for a requested interface
-- vicious.widgets.wifi
local wifi = {}
-- {{{ Variable definitions
local iwconfig = "iwconfig"
local iwcpaths = { "/sbin", "/usr/sbin", "/usr/local/sbin", "/usr/bin" }
-- }}}
-- {{{ Wireless widget type
local function worker(format, warg)
if not warg then return end
-- Default values
local winfo = {
["{ssid}"] = "N/A",
["{mode}"] = "N/A",
["{chan}"] = 0,
["{rate}"] = 0,
["{link}"] = 0,
["{linp}"] = 0,
["{sign}"] = 0
}
-- Sbin paths aren't in user PATH, search for the binary
if iwconfig == "iwconfig" then
for _, p in ipairs(iwcpaths) do
local f = io.open(p .. "/iwconfig", "rb")
if f then
iwconfig = p .. "/iwconfig"
f:close()
break
end
end
end
-- Get data from iwconfig where available
local f = io.popen(iwconfig .." ".. warg .. " 2>&1")
local iw = f:read("*all")
f:close()
-- iwconfig wasn't found, isn't executable, or non-wireless interface
if iw == nil or string.find(iw, "No such device") then
return winfo
end
-- Output differs from system to system, some stats can be
-- separated by =, and not all drivers report all stats
winfo["{ssid}"] = -- SSID can have almost anything in it
helpers.escape(string.match(iw, 'ESSID[=:]"(.-)"') or winfo["{ssid}"])
winfo["{mode}"] = -- Modes are simple, but also match the "-" in Ad-Hoc
string.match(iw, "Mode[=:]([%w%-]*)") or winfo["{mode}"]
winfo["{chan}"] = -- Channels are plain digits
tonumber(string.match(iw, "Channel[=:]([%d]+)") or winfo["{chan}"])
winfo["{rate}"] = -- Bitrate can start with a space, we don't want to display Mb/s
tonumber(string.match(iw, "Bit Rate[=:]([%s]?[%d%.]*)") or winfo["{rate}"])
winfo["{link}"] = -- Link quality can contain a slash (32/70), match only the first number
tonumber(string.match(iw, "Link Quality[=:]([%d]+)") or winfo["{link}"])
winfo["{sign}"] = -- Signal level can be a negative value, don't display decibel notation
tonumber(string.match(iw, "Signal level[=:]([%-]?[%d]+)") or winfo["{sign}"])
-- Link quality percentage if quality was available
if winfo["{link}"] ~= 0 then winfo["{linp}"] = math.ceil(winfo["{link}"] / 0.7) end
return winfo
end
-- }}}
return setmetatable(wifi, { __call = function(_, ...) return worker(...) end })
| gpl-2.0 |
mattyx14/otxserver | data/monster/humans/hunter.lua | 2 | 3424 | local mType = Game.createMonsterType("Hunter")
local monster = {}
monster.description = "a hunter"
monster.experience = 150
monster.outfit = {
lookType = 129,
lookHead = 95,
lookBody = 116,
lookLegs = 120,
lookFeet = 115,
lookAddons = 0,
lookMount = 0
}
monster.raceId = 11
monster.Bestiary = {
class = "Human",
race = BESTY_RACE_HUMAN,
toKill = 500,
FirstUnlock = 25,
SecondUnlock = 250,
CharmsPoints = 15,
Stars = 2,
Occurrence = 0,
Locations = "North of Mount Sternum, Plains of Havoc, Outlaw Camp, Dark Cathedral, Femor Hills, \z
Maze of Lost Souls, north of the Amazon Camp, at the entrance and in the Hero Cave, \z
a castle tower at Elvenbane, Trade Quarter, Smuggler camp on Tyrsung, Formorgar Mines."
}
monster.health = 150
monster.maxHealth = 150
monster.race = "blood"
monster.corpse = 18138
monster.speed = 210
monster.manaCost = 530
monster.changeTarget = {
interval = 4000,
chance = 10
}
monster.strategiesTarget = {
nearest = 100,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = true,
pushable = false,
rewardBoss = false,
illusionable = true,
canPushItems = true,
canPushCreatures = false,
staticAttackChance = 90,
targetDistance = 4,
runHealth = 10,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "Guess who we're hunting, hahaha!", yell = false},
{text = "Guess who we are hunting!", yell = false},
{text = "Bullseye!", yell = false},
{text = "You'll make a nice trophy!", yell = false}
}
monster.loot = {
{id = 2920, chance = 3300}, -- torch
{name = "small ruby", chance = 150},
{name = "dragon necklace", chance = 3000},
{name = "bow", chance = 5770},
{name = "brass helmet", chance = 5050},
{name = "brass armor", chance = 5070},
{name = "arrow", chance = 82000, maxCount = 22},
{name = "poison arrow", chance = 4500, maxCount = 4},
{id = 3449, chance = 5360, maxCount = 3}, -- burst arrow
{name = "orange", chance = 20300, maxCount = 2},
{name = "roll", chance = 11370, maxCount = 2},
{name = "sniper gloves", chance = 610},
{name = "slingshot", chance = 120},
{id = 7394, chance = 190}, -- wolf trophy
{id = 7397, chance = 520}, -- deer trophy
{id = 7400, chance = 70}, -- lion trophy
{name = "hunter's quiver", chance = 10240}
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -20},
{name ="combat", interval = 2000, chance = 50, type = COMBAT_PHYSICALDAMAGE, minDamage = 0, maxDamage = -100, range = 7, shootEffect = CONST_ANI_ARROW, target = false}
}
monster.defenses = {
defense = 15,
armor = 15
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = -5},
{type = COMBAT_ENERGYDAMAGE, percent = 0},
{type = COMBAT_EARTHDAMAGE, percent = 0},
{type = COMBAT_FIREDAMAGE, percent = 0},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = 20},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = false},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
CarabusX/Zero-K | units/vehcapture.lua | 4 | 4178 | return { vehcapture = {
unitname = [[vehcapture]],
name = [[Dominatrix]],
description = [[Capture Rover]],
acceleration = 0.266,
brakeRate = 0.462,
buildCostMetal = 420,
builder = false,
buildPic = [[vehcapture.png]],
canGuard = true,
canMove = true,
canPatrol = true,
category = [[LAND]],
collisionVolumeOffsets = [[0 0 0]],
collisionVolumeScales = [[26 26 50]],
collisionVolumeType = [[cylZ]],
selectionVolumeOffsets = [[0 0 0]],
selectionVolumeScales = [[40 40 50]],
selectionVolumeType = [[cylZ]],
corpse = [[DEAD]],
customParams = {
bait_level_default = 1,
modelradius = [[13]],
turnatfullspeed = [[1]],
cus_noflashlight = 1,
},
explodeAs = [[BIG_UNITEX]],
footprintX = 3,
footprintZ = 3,
iconType = [[vehiclespecial]],
idleAutoHeal = 5,
idleTime = 1800,
leaveTracks = true,
maxDamage = 820,
maxSlope = 18,
maxVelocity = 1.95,
maxWaterDepth = 22,
movementClass = [[TANK3]],
noAutoFire = false,
noChaseCategory = [[TERRAFORM SATELLITE FIXEDWING GUNSHIP DRONE]],
objectName = [[corvrad_big.s3o]],
script = [[vehcapture.lua]],
selfDestructAs = [[BIG_UNITEX]],
sightDistance = 550,
trackOffset = -7,
trackStrength = 5,
trackStretch = 1,
trackType = [[StdTank]],
trackWidth = 28,
turninplace = 0,
turnRate = 672,
workerTime = 0,
weapons = {
{
def = [[CAPTURERAY]],
badTargetCategory = [[UNARMED FIXEDWING]],
onlyTargetCategory = [[FIXEDWING LAND SINK TURRET SHIP SWIM FLOAT GUNSHIP HOVER]],
},
},
weaponDefs = {
CAPTURERAY = {
name = [[Capture Ray]],
beamdecay = 0.9,
beamTime = 1/30,
beamttl = 3,
coreThickness = 0,
craterBoost = 0,
craterMult = 0,
customparams = {
capture_scaling = 1,
is_capture = 1,
post_capture_reload = 360,
stats_hide_damage = 1, -- continuous laser
stats_hide_reload = 1,
light_radius = 120,
light_color = [[0 0.6 0.15]],
},
damage = {
default = 22,
},
explosionGenerator = [[custom:NONE]],
fireStarter = 30,
impactOnly = true,
impulseBoost = 0,
impulseFactor = 0.4,
interceptedByShieldType = 0,
largeBeamLaser = true,
laserFlareSize = 0,
minIntensity = 1,
range = 450,
reloadtime = 1/30,
rgbColor = [[0 0.8 0.2]],
scrollSpeed = 2,
soundStart = [[weapon/laser/pulse_laser2]],
soundStartVolume = 0.5,
soundTrigger = true,
sweepfire = false,
texture1 = [[dosray]],
texture2 = [[flare]],
texture3 = [[flare]],
texture4 = [[smallflare]],
thickness = 4.2,
tolerance = 5000,
turret = true,
weaponType = [[BeamLaser]],
weaponVelocity = 500,
},
},
featureDefs = {
DEAD = {
blocking = true,
featureDead = [[HEAP]],
footprintX = 2,
footprintZ = 2,
collisionVolumeOffsets = [[0 0 0]],
collisionVolumeScales = [[26 26 50]],
collisionVolumeType = [[cylZ]],
object = [[corvrad_big_dead.s3o]],
},
HEAP = {
blocking = false,
footprintX = 2,
footprintZ = 2,
object = [[debris2x2c.s3o]],
},
},
} }
| gpl-2.0 |
mattyx14/otxserver | data/monster/giants/frost_giant.lua | 2 | 3242 | local mType = Game.createMonsterType("Frost Giant")
local monster = {}
monster.description = "a frost giant"
monster.experience = 150
monster.outfit = {
lookType = 257,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.raceId = 324
monster.Bestiary = {
class = "Giant",
race = BESTY_RACE_GIANT,
toKill = 500,
FirstUnlock = 25,
SecondUnlock = 250,
CharmsPoints = 15,
Stars = 2,
Occurrence = 0,
Locations = "Tyrsung (in the Jotunar mountain), Formorgar Glacier (single spawn), \z
Mammoth Shearing Factory, Chyllfroest."
}
monster.health = 270
monster.maxHealth = 270
monster.race = "blood"
monster.corpse = 7330
monster.speed = 190
monster.manaCost = 490
monster.changeTarget = {
interval = 4000,
chance = 10
}
monster.strategiesTarget = {
nearest = 70,
damage = 30,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = true,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = false,
staticAttackChance = 80,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "Hmm Humansoup!", yell = false},
{text = "Stand still ya tasy snack!", yell = false},
{text = "Joh Thun!", yell = false},
{text = "Br�re Sm�de!", yell = false},
{text = "H�rre Sjan Flan!", yell = false},
{text = "Forle Bramma", yell = false}
}
monster.loot = {
{name = "gold coin", chance = 82000, maxCount = 40},
{id = 3093, chance = 130}, -- club ring
{name = "halberd", chance = 560},
{name = "short sword", chance = 8140},
{name = "dark helmet", chance = 180},
{name = "battle shield", chance = 1350},
{name = "meat", chance = 4970, maxCount = 2},
{name = "shard", chance = 60},
{id = 7441, chance = 2180}, -- ice cube
{name = "norse shield", chance = 250},
{name = "health potion", chance = 819},
{name = "frost giant pelt", chance = 5000}
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -110},
{name ="combat", interval = 2000, chance = 15, type = COMBAT_PHYSICALDAMAGE, minDamage = 0, maxDamage = -90, range = 7, shootEffect = CONST_ANI_LARGEROCK, target = false}
}
monster.defenses = {
defense = 20,
armor = 20,
{name ="speed", interval = 2000, chance = 15, speedChange = 300, effect = CONST_ME_MAGIC_RED, target = false, duration = 5000}
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = 0},
{type = COMBAT_EARTHDAMAGE, percent = 0},
{type = COMBAT_FIREDAMAGE, percent = 0},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 100},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = false},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
mumuqz/luci | protocols/luci-proto-ipv6/luasrc/model/cbi/admin_network/proto_6to4.lua | 72 | 1073 | -- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
-- Licensed to the public under the Apache License 2.0.
local map, section, net = ...
local ipaddr, defaultroute, metric, ttl, mtu
ipaddr = section:taboption("general", Value, "ipaddr",
translate("Local IPv4 address"),
translate("Leave empty to use the current WAN address"))
ipaddr.datatype = "ip4addr"
defaultroute = section:taboption("advanced", Flag, "defaultroute",
translate("Use default gateway"),
translate("If unchecked, no default route is configured"))
defaultroute.default = defaultroute.enabled
metric = section:taboption("advanced", Value, "metric",
translate("Use gateway metric"))
metric.placeholder = "0"
metric.datatype = "uinteger"
metric:depends("defaultroute", defaultroute.enabled)
ttl = section:taboption("advanced", Value, "ttl", translate("Use TTL on tunnel interface"))
ttl.placeholder = "64"
ttl.datatype = "range(1,255)"
mtu = section:taboption("advanced", Value, "mtu", translate("Use MTU on tunnel interface"))
mtu.placeholder = "1280"
mtu.datatype = "max(9200)"
| apache-2.0 |
jasongdove/FCEUXLuaScripts | FF VIII/ffviii-util.lua | 1 | 1161 | local source = nil
-- sorted pairs
function spairs(t, order)
-- collect the keys
local keys = {}
for k in pairs(t) do keys[#keys+1] = k end
-- if order function given, sort by it by passing the table and keys a, b
-- otherwise just sort the keys
if order then
table.sort(keys, function(a, b) return order(t, a, b) end)
else
table.sort(keys)
end
-- return the iterator function
local i = 0
return function()
i = i + 1
if keys[i] then
return keys[i], t[keys[i]]
end
end
end
function pressAndRelease(bot_context, keys, key)
local info = debug.getinfo(2)
local traceback = info.source .. info.name .. info.currentline
if bot_context.press_and_release == nil or (source ~= traceback) then
source = traceback
bot_context.press_and_release = {}
bot_context.press_and_release.press_frame = emu.framecount()
bot_context.press_and_release.release_frame = emu.framecount() + 4
end
local framecount = emu.framecount()
if framecount < bot_context.press_and_release.release_frame then
keys[key] = true
else
keys[key] = false
bot_context.press_and_release = nil
end
end
| mit |
evoteamdev/EVO_TEAM | plugins/groupmanager.lua | 1 | 106977 | local function modadd(msg)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
if not lang then
return '_You are not bot admin_'
else
return '🚸┋انت لست مطور البوت'
end
end
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)] then
if not lang then
return '_Group is already added_'
else
return '🚸┋البوت مفعل بالفعل'
end
end
-- create data array in moderation.json
data[tostring(msg.to.id)] = {
owners = {},
mods ={},
banned ={},
is_silent_users ={},
filterlist ={},
settings = {
set_name = msg.to.title,
lock_link = 'yes',
lock_tag = 'yes',
lock_spam = 'yes',
lock_webpage = 'no',
lock_markdown = 'no',
flood = 'yes',
lock_bots = 'yes',
lock_pin = 'no',
welcome = 'no',
},
mutes = {
mute_fwd = 'no',
mute_audio = 'no',
mute_video = 'no',
mute_contact = 'no',
mute_text = 'no',
mute_photos = 'no',
mute_gif = 'no',
mute_loc = 'no',
mute_doc = 'no',
mute_sticker = 'no',
mute_voice = 'no',
mute_all = 'no',
mute_keyboard = 'no'
}
}
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = {}
save_data(_config.moderation.data, data)
end
data[tostring(groups)][tostring(msg.to.id)] = msg.to.id
save_data(_config.moderation.data, data)
if not lang then
return '*Group has been added*'
else
return '*تم اضافة المجموعه الى حمايتي*'
end
end
local function modrem(msg)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
-- superuser and admins only (because sudo are always has privilege)
if not is_admin(msg) then
if not lang then
return '_You are not bot admin_'
else
return '🚸┋انت لست مطور البوت'
end
end
local data = load_data(_config.moderation.data)
local receiver = msg.to.id
if not data[tostring(msg.to.id)] then
if not lang then
return '_Group is not added_'
else
return 'المجموعة معطلة ❌'
end
end
data[tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
local groups = 'groups'
if not data[tostring(groups)] then
data[tostring(groups)] = nil
save_data(_config.moderation.data, data)
end data[tostring(groups)][tostring(msg.to.id)] = nil
save_data(_config.moderation.data, data)
if not lang then
return '*Group has been removed*'
else
return '🚸┋تم تعطيل المجموعة'
end
end
local function filter_word(msg, word)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
local data = load_data(_config.moderation.data)
if not data[tostring(msg.to.id)]['filterlist'] then
data[tostring(msg.to.id)]['filterlist'] = {}
save_data(_config.moderation.data, data)
end
if data[tostring(msg.to.id)]['filterlist'][(word)] then
if not lang then
return "_Word_ *"..word.."* _is already filtered_"
else
return "🚸┋*"..word.."*\n🔺┋الكلمة بالفعل ضمن قائمة المنع"
end
end
data[tostring(msg.to.id)]['filterlist'][(word)] = true
save_data(_config.moderation.data, data)
if not lang then
return "_Word_ *"..word.."* _added to filtered words list_"
else
return "🚸┋*"..word.."*\n🔺┋تم اضافة الكلمة الى قائمة المنع"
end
end
local function unfilter_word(msg, word)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
local data = load_data(_config.moderation.data)
if not data[tostring(msg.to.id)]['filterlist'] then
data[tostring(msg.to.id)]['filterlist'] = {}
save_data(_config.moderation.data, data)
end
if data[tostring(msg.to.id)]['filterlist'][word] then
data[tostring(msg.to.id)]['filterlist'][(word)] = nil
save_data(_config.moderation.data, data)
if not lang then
return "_Word_ *"..word.."* _removed from filtered words list_"
elseif lang then
return "🚸┋*"..word.."*\n🚸┋تم حذفها من قائمة المنع"
end
else
if not lang then
return "_Word_ *"..word.."* _is not filtered_"
elseif lang then
return "🚸┋*"..word.."*\n🚸┋الكلمة ليست من ضمن قائمة المنع"
end
end
end
local function modlist(msg)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
local data = load_data(_config.moderation.data)
local i = 1
if not data[tostring(msg.chat_id_)] then
if not lang then
return "_Group is not added_"
else
return "❌┋البوت غير مفعل في المجموعة"
end
end
-- determine if table is empty
if next(data[tostring(msg.to.id)]['mods']) == nil then --fix way
if not lang then
return "_No_ *moderator* _in this group_"
else
return "❌┋لا يوجد ادمنية في هذه المجموعة"
end
end
if not lang then
message = '*List of moderators :*\n'
else
message = '*🌐┋ قائمة الادمنية:*\n'
end
for k,v in pairs(data[tostring(msg.to.id)]['mods'])
do
message = message ..i.. '- '..v..' [' ..k.. '] \n'
i = i + 1
end
return message
end
local function ownerlist(msg)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
local data = load_data(_config.moderation.data)
local i = 1
if not data[tostring(msg.to.id)] then
if not lang then
return "_Group is not added_"
else
return "❌┋البوت غير مفعل في المجموعة"
end
end
-- determine if table is empty
if next(data[tostring(msg.to.id)]['owners']) == nil then --fix way
if not lang then
return "_No_ *owner* _in this group_"
else
return "❌┋لا يوجد مدراء في هذه المجموعة"
end
end
if not lang then
message = '*List of moderators :*\n'
else
message = '*"🚸┋ قائمة المدراء :*\n'
end
for k,v in pairs(data[tostring(msg.to.id)]['owners']) do
message = message ..i.. '- '..v..' [' ..k.. '] \n'
i = i + 1
end
return message
end
local function action_by_reply(arg, data)
local hash = "gp_lang:"..data.chat_id_
local lang = redis:get(hash)
local cmd = arg.cmd
local administration = load_data(_config.moderation.data)
if not tonumber(data.sender_user_id_) then return false end
if data.sender_user_id_ then
if not administration[tostring(data.chat_id_)] then
if not lang then
return tdcli.sendMessage(data.chat_id_, "", 0, "_Group is not added_", 0, "md")
else
return tdcli.sendMessage(data.chat_id_, "", 0, "❌┋البوت غير مفعل في المجموعة", 0, "md")
end
end
if cmd == "رفع المدير" then
local function owner_cb(arg, data)
local hash = "gp_lang:"..arg.chat_id
local lang = redis:get(hash)
local administration = load_data(_config.moderation.data)
if data.username_ then
user_name = '@'..check_markdown(data.username_)
else
user_name = check_markdown(data.first_name_)
end
if administration[tostring(arg.chat_id)]['owners'][tostring(data.id_)] then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _is already a_ *group owner*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋هو مدير المجموعة بالفعل*", 0, "md")
end
end
administration[tostring(arg.chat_id)]['owners'][tostring(data.id_)] = user_name
save_data(_config.moderation.data, administration)
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _is now the_ *group owner*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *تم رفع رتبتك مدير 💡*", 0, "md")
end
end
tdcli_function ({
ID = "GetUser",
user_id_ = data.sender_user_id_
}, owner_cb, {chat_id=data.chat_id_,user_id=data.sender_user_id_})
end
if cmd == "رفع ادمن" then
local function promote_cb(arg, data)
local hash = "gp_lang:"..arg.chat_id
local lang = redis:get(hash)
local administration = load_data(_config.moderation.data)
if data.username_ then
user_name = '@'..check_markdown(data.username_)
else
user_name = check_markdown(data.first_name_)
end
if administration[tostring(arg.chat_id)]['mods'][tostring(data.id_)] then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _is already a_ *moderator*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *از قبل مدیر گروه بود*", 0, "md")
end
end
administration[tostring(arg.chat_id)]['mods'][tostring(data.id_)] = user_name
save_data(_config.moderation.data, administration)
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _has been_ *promoted*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋تم رفع رتبتك ادمن*", 0, "md")
end
end
tdcli_function ({
ID = "GetUser",
user_id_ = data.sender_user_id_
}, promote_cb, {chat_id=data.chat_id_,user_id=data.sender_user_id_})
end
if cmd == "تنزيل المدير" then
local function rem_owner_cb(arg, data)
local hash = "gp_lang:"..arg.chat_id
local lang = redis:get(hash)
local administration = load_data(_config.moderation.data)
if data.username_ then
user_name = '@'..check_markdown(data.username_)
else
user_name = check_markdown(data.first_name_)
end
if not administration[tostring(arg.chat_id)]['owners'][tostring(data.id_)] then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _is not a_ *group owner*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋هو عضو بالفعل*", 0, "md")
end
end
administration[tostring(arg.chat_id)]['owners'][tostring(data.id_)] = nil
save_data(_config.moderation.data, administration)
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _is no longer a_ *group owner*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋ تم تنزيل رتبتك*", 0, "md")
end
end
tdcli_function ({
ID = "GetUser",
user_id_ = data.sender_user_id_
}, rem_owner_cb, {chat_id=data.chat_id_,user_id=data.sender_user_id_})
end
if cmd == "تنزيل ادمن" then
local function demote_cb(arg, data)
local administration = load_data(_config.moderation.data)
if data.username_ then
user_name = '@'..check_markdown(data.username_)
else
user_name = check_markdown(data.first_name_)
end
if not administration[tostring(arg.chat_id)]['mods'][tostring(data.id_)] then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _is not a_ *moderator*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋ هو ليس ضمن الادمنية *", 0, "md")
end
end
administration[tostring(arg.chat_id)]['mods'][tostring(data.id_)] = nil
save_data(_config.moderation.data, administration)
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _has been_ *demoted*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋تم تنزيل رتبتك*", 0, "md")
end
end
tdcli_function ({
ID = "GetUser",
user_id_ = data.sender_user_id_
}, demote_cb, {chat_id=data.chat_id_,user_id=data.sender_user_id_})
end
if cmd == "ايدي" then
local function id_cb(arg, data)
return tdcli.sendMessage(arg.chat_id, "", 0, "*"..data.id_.."*", 0, "md")
end
tdcli_function ({
ID = "GetUser",
user_id_ = data.sender_user_id_
}, id_cb, {chat_id=data.chat_id_,user_id=data.sender_user_id_})
end
else
if lang then
return tdcli.sendMessage(data.chat_id_, "", 0, "🚸┋ لم يتم العثور على المستخدم", 0, "md")
else
return tdcli.sendMessage(data.chat_id_, "", 0, "*User Not Found*", 0, "md")
end
end
end
local function action_by_username(arg, data)
local hash = "gp_lang:"..arg.chat_id
local lang = redis:get(hash)
local cmd = arg.cmd
local administration = load_data(_config.moderation.data)
if not administration[tostring(arg.chat_id)] then
if not lang then
return tdcli.sendMessage(data.chat_id_, "", 0, "_Group is not added_", 0, "md")
else
return tdcli.sendMessage(data.chat_id_, "", 0, "❌┋ البوت غير مفعل في المجموعة", 0, "md")
end
end
if not arg.username then return false end
if data.id_ then
if data.type_.user_.username_ then
user_name = '@'..check_markdown(data.type_.user_.username_)
else
user_name = check_markdown(data.title_)
end
if cmd == "رفع المدير" then
if administration[tostring(arg.chat_id)]['owners'][tostring(data.id_)] then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _is already a_ *group owner*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋تم رفع رتبته مدير بالفعل*", 0, "md")
end
end
administration[tostring(arg.chat_id)]['owners'][tostring(data.id_)] = user_name
save_data(_config.moderation.data, administration)
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _is now the_ *group owner*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋ تم رفع رتبتك مدير*", 0, "md")
end
end
if cmd == "رفع ادمن" then
if administration[tostring(arg.chat_id)]['mods'][tostring(data.id_)] then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _is already a_ *moderator*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋تم رفع رتبته ادمن بالفعل*", 0, "md")
end
end
administration[tostring(arg.chat_id)]['mods'][tostring(data.id_)] = user_name
save_data(_config.moderation.data, administration)
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _has been_ *promoted*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋تم رفع رتبتك ادمن*", 0, "md")
end
end
if cmd == "تنزيل المدير" then
if not administration[tostring(arg.chat_id)]['owners'][tostring(data.id_)] then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _is not a_ *group owner*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋هو عضو بالفعل*", 0, "md")
end
end
administration[tostring(arg.chat_id)]['owners'][tostring(data.id_)] = nil
save_data(_config.moderation.data, administration)
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _is no longer a_ *group owner*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋تم تنزيل رتبته عضو*", 0, "md")
end
end
if cmd == "تنزيل ادمن" then
if not administration[tostring(arg.chat_id)]['mods'][tostring(data.id_)] then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _is not a_ *moderator*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋هو عضو بالفعل*", 0, "md")
end
end
administration[tostring(arg.chat_id)]['mods'][tostring(data.id_)] = nil
save_data(_config.moderation.data, administration)
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _has been_ *demoted*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋تم تنزيل رتبتك عضو*", 0, "md")
end
end
if cmd == "ايدي" then
return tdcli.sendMessage(arg.chat_id, "", 0, "*"..data.id_.."*", 0, "md")
end
if cmd == "معلومات" then
if not lang then
text = "Result for [ "..check_markdown(data.type_.user_.username_).." ] :\n"
.. ""..check_markdown(data.title_).."\n"
.. " ["..data.id_.."]"
else
text = "🚸┋ معلومات: [ "..check_markdown(data.type_.user_.username_).." ] :\n"
.. "".. check_markdown(data.title_) .."\n"
.. " [".. data.id_ .."]"
end
return tdcli.sendMessage(arg.chat_id, 0, 1, text, 1, 'md')
end
else
if lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "🚸┋ لم يتم العثور على المستخدم في المجموعة", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "*User Not Found*", 0, "md")
end
end
end
local function action_by_id(arg, data)
local hash = "gp_lang:"..arg.chat_id
local lang = redis:get(hash)
local cmd = arg.cmd
local administration = load_data(_config.moderation.data)
if not administration[tostring(arg.chat_id)] then
if not lang then
return tdcli.sendMessage(data.chat_id_, "", 0, "_Group is not added_", 0, "md")
else
return tdcli.sendMessage(data.chat_id_, "", 0, "❌┋البوت غير مفعل في المجموعة", 0, "md")
end
end
if not tonumber(arg.user_id) then return false end
if data.id_ then
if data.first_name_ then
if data.username_ then
user_name = '@'..check_markdown(data.username_)
else
user_name = check_markdown(data.first_name_)
end
if cmd == "رفع المدير" then
if administration[tostring(arg.chat_id)]['owners'][tostring(data.id_)] then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _is already a_ *group owner*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋تم رفع رتبته مدير بالفعل*", 0, "md")
end
end
administration[tostring(arg.chat_id)]['owners'][tostring(data.id_)] = user_name
save_data(_config.moderation.data, administration)
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _is now the_ *group owner*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋تم رفع رتبتك مدير*", 0, "md")
end
end
if cmd == "رفع ادمن" then
if administration[tostring(arg.chat_id)]['mods'][tostring(data.id_)] then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _is already a_ *moderator*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋تم رفع رتبته بالفعل*", 0, "md")
end
end
administration[tostring(arg.chat_id)]['mods'][tostring(data.id_)] = user_name
save_data(_config.moderation.data, administration)
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _has been_ *promoted*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋تم رفع رتبتك ادمن*", 0, "md")
end
end
if cmd == "تنزيل عضو" then
if not administration[tostring(arg.chat_id)]['owners'][tostring(data.id_)] then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _is not a_ *group owner*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n*🚸┋هو عضو بالفعل*", 0, "md")
end
end
administration[tostring(arg.chat_id)]['owners'][tostring(data.id_)] = nil
save_data(_config.moderation.data, administration)
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _is no longer a_ *group owner*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋تم تنزيل رتبته عضو*", 0, "md")
end
end
if cmd == "تنزيل ادمن" then
if not administration[tostring(arg.chat_id)]['mods'][tostring(data.id_)] then
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _is not a_ *moderator*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋هو عضو بالفعل*", 0, "md")
end
end
administration[tostring(arg.chat_id)]['mods'][tostring(data.id_)] = nil
save_data(_config.moderation.data, administration)
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User_ "..user_name.." *"..data.id_.."* _has been_ *demoted*", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "🔬┋المعرف :"..user_name.."\n 🔬┋الايدي :*"..data.id_.."*\n *🚸┋تم تنزيل رتبتك عضو*", 0, "md")
end
end
if cmd == "whois" then
if data.username_ then
username = '@'..check_markdown(data.username_)
else
if not lang then
username = 'not found'
else
username = 'لا يوجد'
end
end
if not lang then
return tdcli.sendMessage(arg.chat_id, 0, 1, 'Info for [ '..data.id_..' ] :\nUserName : '..username..'\nName : '..data.first_name_, 1)
else
return tdcli.sendMessage(arg.chat_id, 0, 1, 'معلومات : [ '..data.id_..' ] :\nالمعرف : '..username..'\nالاسم : '..data.first_name_, 1)
end
end
else
if not lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "_User not founded_", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "❌┋لم يتم العثور على المستخدم في المجموعة", 0, "md")
end
end
else
if lang then
return tdcli.sendMessage(arg.chat_id, "", 0, "❌┋لم يتم العثور على المستخدم في المجموعة", 0, "md")
else
return tdcli.sendMessage(arg.chat_id, "", 0, "*User Not Found*", 0, "md")
end
end
end
---------------Lock Link-------------------
local function lock_link(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_link = data[tostring(target)]["settings"]["lock_link"]
if lock_link == "yes" then
if not lang then
return "*Link* _Posting Is Already Locked_"
elseif lang then
return "🔐┋تم قفل الروابط بالفعل"
end
else
data[tostring(target)]["settings"]["lock_link"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Link* _Posting Has Been Locked_"
else
return "🔐┋تم قفل الروابط في المجموعة"
end
end
end
local function unlock_link(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_link = data[tostring(target)]["settings"]["lock_link"]
if lock_link == "no" then
if not lang then
return "*Link* _Posting Is Not Locked_"
elseif lang then
return "🔓┋تم فتح الروابط بالفعل"
end
else
data[tostring(target)]["settings"]["lock_link"] = "no" save_data(_config.moderation.data, data)
if not lang then
return "*Link* _Posting Has Been Unlocked_"
else
return "🔓┋تم فتح الروابط في المجموعة"
end
end
end
---------------Lock Tag-------------------
local function lock_tag(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_tag = data[tostring(target)]["settings"]["lock_tag"]
if lock_tag == "yes" then
if not lang then
return "*Tag* _Posting Is Already Locked_"
elseif lang then
return "🔐┋تم قفل التاك بالفعل"
end
else
data[tostring(target)]["settings"]["lock_tag"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Tag* _Posting Has Been Locked_"
else
return "🔐┋تم قفل التاك في المجموعة"
end
end
end
local function unlock_tag(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_tag = data[tostring(target)]["settings"]["lock_tag"]
if lock_tag == "no" then
if not lang then
return "*Tag* _Posting Is Not Locked_"
elseif lang then
return "🔓┋تم فتح التاك بالفعل"
end
else
data[tostring(target)]["settings"]["lock_tag"] = "no" save_data(_config.moderation.data, data)
if not lang then
return "*Tag* _Posting Has Been Unlocked_"
else
return "🔓┋تم فتح التاك في المجموعة"
end
end
end
---------------Lock Mention-------------------
local function lock_mention(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_mention = data[tostring(target)]["settings"]["lock_mention"]
if lock_mention == "yes" then
if not lang then
return "*Mention* _Posting Is Already Locked_"
elseif lang then
return "🔐┋تم قفل اليوزر بالفعل"
end
else
data[tostring(target)]["settings"]["lock_mention"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Mention* _Posting Has Been Locked_"
else
return "🔐┋تم قفل اليوزر في المجموعة"
end
end
end
local function unlock_mention(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_mention = data[tostring(target)]["settings"]["lock_mention"]
if lock_mention == "no" then
if not lang then
return "*Mention* _Posting Is Not Locked_"
elseif lang then
return "🔓┋تم فتح اليوزر بالفعل"
end
else
data[tostring(target)]["settings"]["lock_mention"] = "no" save_data(_config.moderation.data, data)
if not lang then
return "*Mention* _Posting Has Been Unlocked_"
else
return "ارسال فراخوانی افراد در گروه آزاد شد"
end
end
end
---------------Lock Arabic--------------
local function lock_arabic(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_arabic = data[tostring(target)]["settings"]["lock_arabic"]
if lock_arabic == "yes" then
if not lang then
return "*Arabic/Persian* _Posting Is Already Locked_"
elseif lang then
return "🔐┋تم قفل العربية بالفعل"
end
else
data[tostring(target)]["settings"]["lock_arabic"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Arabic/Persian* _Posting Has Been Locked_"
else
return "🔐┋تم قفل العربية في المجموعة"
end
end
end
local function unlock_arabic(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_arabic = data[tostring(target)]["settings"]["lock_arabic"]
if lock_arabic == "no" then
if not lang then
return "*Arabic/Persian* _Posting Is Not Locked_"
elseif lang then
return "🔓┋تم فتح العربية بالفعل"
end
else
data[tostring(target)]["settings"]["lock_arabic"] = "no" save_data(_config.moderation.data, data)
if not lang then
return "*Arabic/Persian* _Posting Has Been Unlocked_"
else
return "🔓┋تم فتح العربية في المجموعة"
end
end
end
---------------Lock Edit-------------------
local function lock_edit(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_edit = data[tostring(target)]["settings"]["lock_edit"]
if lock_edit == "yes" then
if not lang then
return "*Editing* _Is Already Locked_"
elseif lang then
return "🔐┋تم قفل التعديل بالفعل"
end
else
data[tostring(target)]["settings"]["lock_edit"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Editing* _Has Been Locked_"
else
return "🔐┋تم قفل التعديل في المجموعة"
end
end
end
local function unlock_edit(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_edit = data[tostring(target)]["settings"]["lock_edit"]
if lock_edit == "no" then
if not lang then
return "*Editing* _Is Not Locked_"
elseif lang then
return "🔓┋تم فتح التعديل بالفعل"
end
else
data[tostring(target)]["settings"]["lock_edit"] = "no" save_data(_config.moderation.data, data)
if not lang then
return "*Editing* _Has Been Unlocked_"
else
return "🔓┋تم فتح التعديل في المجموعة"
end
end
end
---------------Lock spam-------------------
local function lock_spam(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_spam = data[tostring(target)]["settings"]["lock_spam"]
if lock_spam == "yes" then
if not lang then
return "*Spam* _Is Already Locked_"
elseif lang then
return "🔐┋تم قفل الكلايش بالفعل"
end
else
data[tostring(target)]["settings"]["lock_spam"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Spam* _Has Been Locked_"
else
return "🔐┋تم قفل الكلايش في المجموعة"
end
end
end
local function unlock_spam(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_spam = data[tostring(target)]["settings"]["lock_spam"]
if lock_spam == "no" then
if not lang then
return "*Spam* _Posting Is Not Locked_"
elseif lang then
return "🔓┋تم فتح الكلايش بالفعل"
end
else
data[tostring(target)]["settings"]["lock_spam"] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "*Spam* _Has been unlocked_"
elseif lang then
return "🔓┋تم فتح الكلايش في المجموعة"
end
end
end
---------------Lock Flood-------------------
local function lock_flood(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_flood = data[tostring(target)]["settings"]["flood"]
if lock_flood == "yes" then
if not lang then
return "*Flooding* _Is Already Locked_"
elseif lang then
return "🔐┋تم قفل التكرار بالفعل"
end
else
data[tostring(target)]["settings"]["flood"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Flooding* _Has Been Locked_"
else
return "🔐┋تم قفل التكرار في المجموعة"
end
end
end
local function unlock_flood(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_flood = data[tostring(target)]["settings"]["flood"]
if lock_flood == "no" then
if not lang then
return "*Flooding* _Is Not Locked_"
elseif lang then
return "🔓┋تم فتح التكرار بالفعل"
end
else
data[tostring(target)]["settings"]["flood"] = "no" save_data(_config.moderation.data, data)
if not lang then
return "*Flooding* _Has Been Unlocked_"
else
return "🔓┋تم فتح التكرار في المجموعة"
end
end
end
---------------Lock Bots-------------------
local function lock_bots(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_bots = data[tostring(target)]["settings"]["lock_bots"]
if lock_bots == "yes" then
if not lang then
return "*Bots* _Protection Is Already Enabled_"
elseif lang then
return "🔐┋تم قفل البوتات بالفعل"
end
else
data[tostring(target)]["settings"]["lock_bots"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Bots* _Protection Has Been Enabled_"
else
return "محافظت از گروه در برابر ربات ها فعال شد"
end
end
end
local function unlock_bots(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_bots = data[tostring(target)]["settings"]["lock_bots"]
if lock_bots == "no" then
if not lang then
return "*Bots* _Protection Is Not Enabled_"
elseif lang then
return "🔐┋تم قفل البوتات في المجموعة"
end
else
data[tostring(target)]["settings"]["lock_bots"] = "no" save_data(_config.moderation.data, data)
if not lang then
return "*Bots* _Protection Has Been Disabled_"
else
return "🔓┋تم فتح البوتات في المجموعة"
end
end
end
---------------Lock Markdown-------------------
local function lock_markdown(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_markdown = data[tostring(target)]["settings"]["lock_markdown"]
if lock_markdown == "yes" then
if not lang then
return "*Markdown* _Posting Is Already Locked_"
elseif lang then
return "🔐┋تم قفل الماركدوان بالفعل"
end
else
data[tostring(target)]["settings"]["lock_markdown"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Markdown* _Posting Has Been Locked_"
else
return "🔐┋تم قفل الماركدوان في المجموعة"
end
end
end
local function unlock_markdown(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_markdown = data[tostring(target)]["settings"]["lock_markdown"]
if lock_markdown == "no" then
if not lang then
return "*Markdown* _Posting Is Not Locked_"
elseif lang then
return "🔓┋تم فتح الماركدوان بالفعل"
end
else
data[tostring(target)]["settings"]["lock_markdown"] = "no" save_data(_config.moderation.data, data)
if not lang then
return "*Markdown* _Posting Has Been Unlocked_"
else
return "🔓┋تم فتح الماركدوان في المجموعة"
end
end
end
---------------Lock Webpage-------------------
local function lock_webpage(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_webpage = data[tostring(target)]["settings"]["lock_webpage"]
if lock_webpage == "yes" then
if not lang then
return "*Webpage* _Is Already Locked_"
elseif lang then
return "🔐┋تم قفل الويب بالفعل"
end
else
data[tostring(target)]["settings"]["lock_webpage"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Webpage* _Has Been Locked_"
else
return "🔐┋تم قفل الويب في المجموعة"
end
end
end
local function unlock_webpage(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_webpage = data[tostring(target)]["settings"]["lock_webpage"]
if lock_webpage == "no" then
if not lang then
return "*Webpage* _Is Not Locked_"
elseif lang then
return "🔓┋تم فتح الويب بالفعل"
end
else
data[tostring(target)]["settings"]["lock_webpage"] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "*Webpage* _Has Been Unlocked_"
else
return "🔓┋تم فتح الويب في المجموعة"
end
end
end
---------------Lock Pin-------------------
local function lock_pin(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_pin = data[tostring(target)]["settings"]["lock_pin"]
if lock_pin == "yes" then
if not lang then
return "*Pinned Message* _Is Already Locked_"
elseif lang then
return "🔐┋تم قفل التثبيت بالفعل"
end
else
data[tostring(target)]["settings"]["lock_pin"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Pinned Message* _Has Been Locked_"
else
return "🔐┋تم قفل التثبيت في المجموعة"
end
end
end
local function unlock_pin(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local lock_pin = data[tostring(target)]["settings"]["lock_pin"]
if lock_pin == "no" then
if not lang then
return "*Pinned Message* _Is Not Locked_"
elseif lang then
return "🔓┋تم فتح التثبيت بالفعل"
end
else
data[tostring(target)]["settings"]["lock_pin"] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "*Pinned Message* _Has Been Unlocked_"
else
return "🔓┋تم فتح التثبيت في المجموعة"
end
end
end
function group_settings(msg, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local data = load_data(_config.moderation.data)
local target = msg.to.id
if data[tostring(target)] then
if data[tostring(target)]["settings"]["num_msg_max"] then
NUM_MSG_MAX = tonumber(data[tostring(target)]['settings']['num_msg_max'])
print('custom'..NUM_MSG_MAX)
else
NUM_MSG_MAX = 5
end
end
if data[tostring(target)]["settings"] then
if not data[tostring(target)]["settings"]["lock_link"] then
data[tostring(target)]["settings"]["lock_link"] = "yes"
end
end
if data[tostring(target)]["settings"] then
if not data[tostring(target)]["settings"]["lock_tag"] then
data[tostring(target)]["settings"]["lock_tag"] = "yes"
end
end
if data[tostring(target)]["settings"] then
if not data[tostring(target)]["settings"]["lock_mention"] then
data[tostring(target)]["settings"]["lock_mention"] = "no"
end
end
if data[tostring(target)]["settings"] then
if not data[tostring(target)]["settings"]["lock_arabic"] then
data[tostring(target)]["settings"]["lock_arabic"] = "no"
end
end
if data[tostring(target)]["settings"] then
if not data[tostring(target)]["settings"]["lock_edit"] then
data[tostring(target)]["settings"]["lock_edit"] = "no"
end
end
if data[tostring(target)]["settings"] then
if not data[tostring(target)]["settings"]["lock_spam"] then
data[tostring(target)]["settings"]["lock_spam"] = "yes"
end
end
if data[tostring(target)]["settings"] then
if not data[tostring(target)]["settings"]["lock_flood"] then
data[tostring(target)]["settings"]["lock_flood"] = "yes"
end
end
if data[tostring(target)]["settings"] then
if not data[tostring(target)]["settings"]["lock_bots"] then
data[tostring(target)]["settings"]["lock_bots"] = "yes"
end
end
if data[tostring(target)]["settings"] then
if not data[tostring(target)]["settings"]["lock_markdown"] then
data[tostring(target)]["settings"]["lock_markdown"] = "no"
end
end
if data[tostring(target)]["settings"] then
if not data[tostring(target)]["settings"]["lock_webpage"] then
data[tostring(target)]["settings"]["lock_webpage"] = "no"
end
end
if data[tostring(target)]["settings"] then
if not data[tostring(target)]["settings"]["welcome"] then
data[tostring(target)]["settings"]["welcome"] = "no"
end
end
if data[tostring(target)]["settings"] then
if not data[tostring(target)]["settings"]["lock_pin"] then
data[tostring(target)]["settings"]["lock_pin"] = "no"
end
end
local expire_date = ''
local expi = redis:ttl('ExpireDate:'..msg.to.id)
if expi == -1 then
if lang then
expire_date = 'نامحدود!'
else
expire_date = 'Unlimited!'
end
else
local day = math.floor(expi / 86400) + 1
if lang then
expire_date = day..' يوم'
else
expire_date = day..' Days'
end
end
if not lang then
local settings = data[tostring(target)]["settings"]
text = "Send الوسائط to see the settings Group🌟✔️"
else
local settings = data[tostring(target)]["settings"]
text = "ارسل الوسائط لمعرفة اعدادات المجموعة💜📩"
end
return text
end
--------Mutes---------
--------Mute all--------------------------
local function mute_all(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_all = data[tostring(target)]["mutes"]["mute_all"]
if mute_all == "yes" then
if not lang then
return "*Mute All* _Is Already Enabled_"
elseif lang then
return "🔐┋تم قفل الكل بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_all"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute All* _Has Been Enabled_"
else
return "🔐┋تم قفل الكل في المجموعة"
end
end
end
local function unmute_all(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_all = data[tostring(target)]["mutes"]["mute_all"]
if mute_all == "no" then
if not lang then
return "*Mute All* _Is Already Disabled_"
elseif lang then
return "🔓┋تم فتح الكل بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_all"] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute All* _Has Been Disabled_"
else
return "🔓┋تم فتح الكل في المجموعة"
end
end
end
---------------Mute Gif-------------------
local function mute_gif(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_gif = data[tostring(target)]["mutes"]["mute_gif"]
if mute_gif == "yes" then
if not lang then
return "*Mute Gif* _Is Already Enabled_"
elseif lang then
return "🔐┋تم قفل المتحركة بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_gif"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Gif* _Has Been Enabled_"
else
return "🔐┋تم قفل المتحركة في المجموعة"
end
end
end
local function unmute_gif(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_gif = data[tostring(target)]["mutes"]["mute_gif"]
if mute_gif == "no" then
if not lang then
return "*Mute Gif* _Is Already Disabled_"
elseif lang then
return "🔓┋تم فتح المتحركة بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_gif"] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Gif* _Has Been Disabled_"
else
return "🔓┋تم فتح المتحركة في المجموعة"
end
end
end
---------------Mute Game-------------------
local function mute_game(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_game = data[tostring(target)]["mutes"]["mute_game"]
if mute_game == "yes" then
if not lang then
return "*Mute Game* _Is Already Enabled_"
elseif lang then
return "🔐┋تم قفل الالعاب بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_game"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Game* _Has Been Enabled_"
else
return "🔐┋تم قفل الالعاب في المجموعة"
end
end
end
local function unmute_game(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_game = data[tostring(target)]["mutes"]["mute_game"]
if mute_game == "no" then
if not lang then
return "*Mute Game* _Is Already Disabled_"
elseif lang then
return "🔓┋تم فتح الالعاب بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_game"] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Game* _Has Been Disabled_"
else
return "🔓┋تم فتح الالعاب في المجموعة"
end
end
end
---------------Mute Inline-------------------
local function mute_inline(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_inline = data[tostring(target)]["mutes"]["mute_inline"]
if mute_inline == "yes" then
if not lang then
return "*Mute Inline* _Is Already Enabled_"
elseif lang then
return "🔐┋تم قفل الانلاين بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_inline"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Inline* _Has Been Enabled_"
else
return "🔐┋تم قفل الانلاين في المجموعة"
end
end
end
local function unmute_inline(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_inline = data[tostring(target)]["mutes"]["mute_inline"]
if mute_inline == "no" then
if not lang then
return "*Mute Inline* _Is Already Disabled_"
elseif lang then
return "🔓┋تم فتح الانلاين بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_inline"] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Inline* _Has Been Disabled_"
else
return "🔓┋تم فتح الانلاين في المجموعة"
end
end
end
---------------Mute Text-------------------
local function mute_text(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_text = data[tostring(target)]["mutes"]["mute_text"]
if mute_text == "yes" then
if not lang then
return "*Mute Text* _Is Already Enabled_"
elseif lang then
return "🔐┋تم قفل الكتابة بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_text"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Text* _Has Been Enabled_"
else
return "🔐┋تم قفل الكتابة في المجموعة"
end
end
end
local function unmute_text(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_text = data[tostring(target)]["mutes"]["mute_text"]
if mute_text == "no" then
if not lang then
return "*Mute Text* _Is Already Disabled_"
elseif lang then
return "🔓┋تم فتح الكتابة بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_text"] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Text* _Has Been Disabled_"
else
return "🔓┋تم فتح الكتابة في المجموعة"
end
end
end
---------------Mute photo-------------------
local function mute_photo(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_photo = data[tostring(target)]["mutes"]["mute_photo"]
if mute_photo == "yes" then
if not lang then
return "*Mute Photo* _Is Already Enabled_"
elseif lang then
return "🔐┋تم قفل الصور بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_photo"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Photo* _Has Been Enabled_"
else
return "🔓┋تم فتح الصور في المجموعة"
end
end
end
local function unmute_photo(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_photo = data[tostring(target)]["mutes"]["mute_photo"]
if mute_photo == "no" then
if not lang then
return "*Mute Photo* _Is Already Disabled_"
elseif lang then
return "🔓┋تم فتح الصور بالفعل "
end
else
data[tostring(target)]["mutes"]["mute_photo"] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Photo* _Has Been Disabled_"
else
return "🔓┋تم فتح الصور في المجموعة"
end
end
end
---------------Mute Video-------------------
local function mute_video(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_video = data[tostring(target)]["mutes"]["mute_video"]
if mute_video == "yes" then
if not lang then
return "*Mute Video* _Is Already Enabled_"
elseif lang then
return "🔐┋تم قفل الفيديو بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_video"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Video* _Has Been Enabled_"
else
return "🔐┋تم قفل الفيديو في المجموعة"
end
end
end
local function unmute_video(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_video = data[tostring(target)]["mutes"]["mute_video"]
if mute_video == "no" then
if not lang then
return "*Mute Video* _Is Already Disabled_"
elseif lang then
return "🔓┋تم فتح الفيديو بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_video"] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Video* _Has Been Disabled_"
else
return "🔓┋تم فتح الفيديو في المجموعة"
end
end
end
---------------Mute Audio-------------------
local function mute_audio(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_audio = data[tostring(target)]["mutes"]["mute_audio"]
if mute_audio == "yes" then
if not lang then
return "*Mute Audio* _Is Already Enabled_"
elseif lang then
return "🔐┋تم قفل الصوتيات بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_audio"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Audio* _Has Been Enabled_"
else
return "🔐┋تم قفل الصوتيات في المجموعة"
end
end
end
local function unmute_audio(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_audio = data[tostring(target)]["mutes"]["mute_audio"]
if mute_audio == "no" then
if not lang then
return "*Mute Audio* _Is Already Disabled_"
elseif lang then
return "🔓┋تم فتح الصوتيات بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_audio"] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Audio* _Has Been Disabled_"
else
return "🔓┋تم فتح الصوتيات في المجموعة"
end
end
end
---------------Mute Voice-------------------
local function mute_voice(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_voice = data[tostring(target)]["mutes"]["mute_voice"]
if mute_voice == "yes" then
if not lang then
return "*Mute Voice* _Is Already Enabled_"
elseif lang then
return "🔐┋تم قفل التسجيلات بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_voice"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Voice* _Has Been Enabled_"
else
return "🔐┋تم قفل التسجيلات في المجموعة"
end
end
end
local function unmute_voice(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_voice = data[tostring(target)]["mutes"]["mute_voice"]
if mute_voice == "no" then
if not lang then
return "*Mute Voice* _Is Already Disabled_"
elseif lang then
return "🔓┋تم فتح التسجيلات بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_voice"] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Voice* _Has Been Disabled_"
else
return "🔓┋تم فتح التسجيلات في المجموعة"
end
end
end
---------------Mute Sticker-------------------
local function mute_sticker(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_sticker = data[tostring(target)]["mutes"]["mute_sticker"]
if mute_sticker == "yes" then
if not lang then
return "*Mute Sticker* _Is Already Enabled_"
elseif lang then
return "🔐┋تم قفل الملصقات بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_sticker"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Sticker* _Has Been Enabled_"
else
return "🔐┋تم قفل الملصقات في المجموعة"
end
end
end
local function unmute_sticker(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_sticker = data[tostring(target)]["mutes"]["mute_sticker"]
if mute_sticker == "no" then
if not lang then
return "*Mute Sticker* _Is Already Disabled_"
elseif lang then
return "🔓┋تم فتح الملصقات بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_sticker"] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Sticker* _Has Been Disabled_"
else
return "🔓┋تم فتح الملصقات في المجموعة"
end
end
end
---------------Mute Contact-------------------
local function mute_contact(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_contact = data[tostring(target)]["mutes"]["mute_contact"]
if mute_contact == "yes" then
if not lang then
return "*Mute Contact* _Is Already Enabled_"
elseif lang then
return "🔐┋تم قفل الجهات بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_contact"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Contact* _Has Been Enabled_"
else
return "🔐┋تم قفل الجهات في المجموعة"
end
end
end
local function unmute_contact(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_contact = data[tostring(target)]["mutes"]["mute_contact"]
if mute_contact == "no" then
if not lang then
return "*Mute Contact* _Is Already Disabled_"
elseif lang then
return "🔓┋تم فتح الجهات بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_contact"] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Contact* _Has Been Disabled_"
else
return "🔓┋تم فتح الجهات في المجموعة"
end
end
end
---------------Mute Forward-------------------
local function mute_forward(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_forward = data[tostring(target)]["mutes"]["mute_forward"]
if mute_forward == "yes" then
if not lang then
return "*Mute Forward* _Is Already Enabled_"
elseif lang then
return "🔐┋تم قفل التوجيه بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_forward"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Forward* _Has Been Enabled_"
else
return "🔐┋تم قفل التوجيه في المجموعة"
end
end
end
local function unmute_forward(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "🚨❕ للمشرفين فقط"
end
end
local mute_forward = data[tostring(target)]["mutes"]["mute_forward"]
if mute_forward == "no" then
if not lang then
return "*Mute Forward* _Is Already Disabled_"
elseif lang then
return "🔓┋تم فتح التوجيه بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_forward"] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Forward* _Has Been Disabled_"
else
return "🔓┋تم فتح التوجيه في المجموعة"
end
end
end
---------------Mute Location-------------------
local function mute_location(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_location = data[tostring(target)]["mutes"]["mute_location"]
if mute_location == "yes" then
if not lang then
return "*Mute Location* _Is Already Enabled_"
elseif lang then
return "🔓┋تم فتح المواقع بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_location"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Location* _Has Been Enabled_"
else
return "🔐┋تم قفل المواقع في المجموعة"
end
end
end
local function unmute_location(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_location = data[tostring(target)]["mutes"]["mute_location"]
if mute_location == "no" then
if not lang then
return "*Mute Location* _Is Already Disabled_"
elseif lang then
return "🔓┋تم فتح المواقع بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_location"] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Location* _Has Been Disabled_"
else
return "🔓┋تم فتح المواقع في المجموعة"
end
end
end
---------------Mute Document-------------------
local function mute_document(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_document = data[tostring(target)]["mutes"]["mute_document"]
if mute_document == "yes" then
if not lang then
return "*Mute Document* _Is Already Enabled_"
elseif lang then
return "🔐┋تم قفل الملفات بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_document"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Document* _Has Been Enabled_"
else
return "🔐┋تم قفل الملفات في المجموعة"
end
end
end
local function unmute_document(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_document = data[tostring(target)]["mutes"]["mute_document"]
if mute_document == "no" then
if not lang then
return "*Mute Document* _Is Already Disabled_"
elseif lang then
return "🔓┋تم فتح الملفات بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_document"] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Document* _Has Been Disabled_"
else
return "🔓┋تم فتح الملفات في المجموعة"
end
end
end
---------------Mute TgService-------------------
local function mute_tgservice(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_tgservice = data[tostring(target)]["mutes"]["mute_tgservice"]
if mute_tgservice == "yes" then
if not lang then
return "*Mute TgService* _Is Already Enabled_"
elseif lang then
return "🔓┋تم فتح الخدمات بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_tgservice"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute TgService* _Has Been Enabled_"
else
return "🔐┋تم قفل الخدمات في المجموعة"
end
end
end
local function unmute_tgservice(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "شما مدیر گروه نیستید"
end
end
local mute_tgservice = data[tostring(target)]["mutes"]["mute_tgservice"]
if mute_tgservice == "no" then
if not lang then
return "*Mute TgService* _Is Already Disabled_"
elseif lang then
return "🔓┋تم فتح الخدمات بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_tgservice"] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute TgService* _Has Been Disabled_"
else
return "🔓┋تم فتح الخدمات في المجموعة"
end
end
end
---------------Mute Keyboard-------------------
local function mute_keyboard(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "للمشرفين فقط 🚨❕"
end
end
local mute_keyboard = data[tostring(target)]["mutes"]["mute_keyboard"]
if mute_keyboard == "yes" then
if not lang then
return "*Mute Keyboard* _Is Already Enabled_"
elseif lang then
return "🔐┋تم قفل الكيبورد بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_keyboard"] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Keyboard* _Has Been Enabled_"
else
return "🔐┋تم قفل الكيبورد في المجموعة"
end
end
end
local function unmute_keyboard(msg, data, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "شما مدیر گروه نیستید"
end
end
local mute_keyboard = data[tostring(target)]["mutes"]["mute_keyboard"]
if mute_keyboard == "no" then
if not lang then
return "*Mute Keyboard* _Is Already Disabled_"
elseif lang then
return "🔓┋تم فتح الكيبورد بالفعل"
end
else
data[tostring(target)]["mutes"]["mute_keyboard"] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "*Mute Keyboard* _Has Been Disabled_"
else
return "🔐┋تم قفل الكيبورد في المجموعة"
end
end
end
----------MuteList---------
local function mutes(msg, target)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
if not is_mod(msg) then
if not lang then
return "_You're Not_ *Moderator*"
else
return "شما مدیر گروه نیستید"
end
end
local data = load_data(_config.moderation.data)
local target = msg.to.id
if data[tostring(target)]["mutes"] then
if not data[tostring(target)]["mutes"]["mute_all"] then
data[tostring(target)]["mutes"]["mute_all"] = "no"
end
end
if data[tostring(target)]["mutes"] then
if not data[tostring(target)]["mutes"]["mute_gif"] then
data[tostring(target)]["mutes"]["mute_gif"] = "no"
end
end
if data[tostring(target)]["mutes"] then
if not data[tostring(target)]["mutes"]["mute_text"] then
data[tostring(target)]["mutes"]["mute_text"] = "no"
end
end
if data[tostring(target)]["mutes"] then
if not data[tostring(target)]["mutes"]["mute_photo"] then
data[tostring(target)]["mutes"]["mute_photo"] = "no"
end
end
if data[tostring(target)]["mutes"] then
if not data[tostring(target)]["mutes"]["mute_video"] then
data[tostring(target)]["mutes"]["mute_video"] = "no"
end
end
if data[tostring(target)]["mutes"] then
if not data[tostring(target)]["mutes"]["mute_audio"] then
data[tostring(target)]["mutes"]["mute_audio"] = "no"
end
end
if data[tostring(target)]["mutes"] then
if not data[tostring(target)]["mutes"]["mute_voice"] then
data[tostring(target)]["mutes"]["mute_voice"] = "no"
end
end
if data[tostring(target)]["mutes"] then
if not data[tostring(target)]["mutes"]["mute_sticker"] then
data[tostring(target)]["mutes"]["mute_sticker"] = "no"
end
end
if data[tostring(target)]["mutes"] then
if not data[tostring(target)]["mutes"]["mute_contact"] then
data[tostring(target)]["mutes"]["mute_contact"] = "no"
end
end
if data[tostring(target)]["mutes"] then
if not data[tostring(target)]["mutes"]["mute_forward"] then
data[tostring(target)]["mutes"]["mute_forward"] = "no"
end
end
if data[tostring(target)]["mutes"] then
if not data[tostring(target)]["mutes"]["mute_location"] then
data[tostring(target)]["mutes"]["mute_location"] = "no"
end
end
if data[tostring(target)]["mutes"] then
if not data[tostring(target)]["mutes"]["mute_document"] then
data[tostring(target)]["mutes"]["mute_document"] = "no"
end
end
if data[tostring(target)]["mutes"] then
if not data[tostring(target)]["mutes"]["mute_tgservice"] then
data[tostring(target)]["mutes"]["mute_tgservice"] = "no"
end
end
if data[tostring(target)]["mutes"] then
if not data[tostring(target)]["mutes"]["mute_inline"] then
data[tostring(target)]["mutes"]["mute_inline"] = "no"
end
end
if data[tostring(target)]["mutes"] then
if not data[tostring(target)]["mutes"]["mute_game"] then
data[tostring(target)]["mutes"]["mute_game"] = "no"
end
end
if data[tostring(target)]["mutes"] then
if not data[tostring(target)]["mutes"]["mute_keyboard"] then
data[tostring(target)]["mutes"]["mute_keyboard"] = "no"
end
end
if not lang then
local mutes = data[tostring(target)]["mutes"]
text = " *Group Mute List* : \n_Mute all : _ *"..mutes.mute_all.."*\n_Mute gif :_ *"..mutes.mute_gif.."*\n_Mute text :_ *"..mutes.mute_text.."*\n_Mute inline :_ *"..mutes.mute_inline.."*\n_Mute game :_ *"..mutes.mute_game.."*\n_Mute photo :_ *"..mutes.mute_photo.."*\n_Mute video :_ *"..mutes.mute_video.."*\n_Mute audio :_ *"..mutes.mute_audio.."*\n_Mute voice :_ *"..mutes.mute_voice.."*\n_Mute sticker :_ *"..mutes.mute_sticker.."*\n_Mute contact :_ *"..mutes.mute_contact.."*\n_Mute forward :_ *"..mutes.mute_forward.."*\n_Mute location :_ *"..mutes.mute_location.."*\n_Mute document :_ *"..mutes.mute_document.."*\n_Mute TgService :_ *"..mutes.mute_tgservice.."*\n_Mute Keyboard :_ *"..mutes.mute_keyboard.."*\n*____________________*\n*Bot channel*: @BeyondTeam\n*Group Language* : *EN*"
else
local mutes = data[tostring(target)]["mutes"]
text = "<i> 【 اعدادات الوسائط 】 </i>\n"
text = text.."<b>【 •┈•✦•۪۫•৩﴾ ❊ ﴿৩•۪۫•✦•┈• 】</b>\n\n"
text = text.."<i>【 الــكــل 】 « </i><b>"..mutes.mute_all.."</b>\n"
text = text.."<i>【 المتحركه 】 « </i><b>"..mutes.mute_gif.."</b>\n"
text = text.."<i>【 الـدردشه 】 « </i><b>"..mutes.mute_text.."</b>\n"
text = text.."<i>【 الاونـلاين 】 « </i><b>"..mutes.mute_inline.."</b>\n"
text = text.."<i>【 الـلـعـب 】 « </i><b>"..mutes.mute_game.."</b>\n"
text = text.."<i>【 الــصـور 】 « </i><b>"..mutes.mute_photo.."</b>\n"
text = text.."<i>【 الـفيديو 】 « </i><b>"..mutes.mute_video.."</b>\n"
text = text.."<i>【 الـصــوت 】 « </i><b>"..mutes.mute_audio.."</b>\n"
text = text.."<i>【 الـبصمات 】 « </i><b>"..mutes.mute_voice.."</b>\n"
text = text.."<i>【 الملصقات 】 « </i><b>"..mutes.mute_sticker.."</b>\n"
text = text.."<i>【 الـجهـات 】 « </i><b>"..mutes.mute_contact.."</b>\n"
text = text.."<i>【 التـوجيه 】 « </i><b>"..mutes.mute_forward.."</b>\n"
text = text.."<i>【 الـمواقع 】 « </i><b>"..mutes.mute_location.."</b>\n"
text = text.."<i>【 الـملفات 】 « </i><b>"..mutes.mute_document.."</b>\n"
text = text.."<i>【 الاشعارات 】 « </i><b>"..mutes.mute_tgservice.."</b>\n"
text = text.."<b>【 •┈•✦•۪۫•৩﴾ ❊ ﴿৩•۪۫•✦•┈• 】</b>\n"
text = text.."<b>【 Dev 】 « </b> @EVOtmBot\n"
text = text.."<b>【 CH 】 « </b> @dev_evo\n"
return tdcli.sendMessage(chat, msg.id_, 1, text, 1, 'html')
end
return text
end
local function run(msg, matches)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
local data = load_data(_config.moderation.data)
local chat = msg.to.id
local user = msg.from.id
if msg.to.type ~= 'pv' then
if matches[1] == "ايدي" then
if not matches[2] and not msg.reply_id then
local function getpro(arg, data)
if data.photos_[0] then
if not lang then
tdcli.sendPhoto(msg.chat_id_, msg.id_, 0, 1, nil, data.photos_[0].sizes_[1].photo_.persistent_id_,'Chat ID : '..msg.to.id..'\nUser ID : '..msg.from.id,dl_cb,nil)
elseif lang then
tdcli.sendPhoto(msg.chat_id_, msg.id_, 0, 1, nil, data.photos_[0].sizes_[1].photo_.persistent_id_,'ايدي المجموعة : '..msg.to.id..'\nايديك : '..msg.from.id,dl_cb,nil)
end
else
if not lang then
tdcli.sendMessage(msg.to.id, msg.id_, 1, "`You Have Not Profile Photo...!`\n\n> *Chat ID :* `"..msg.to.id.."`\n*User ID :* `"..msg.from.id.."`", 1, 'md')
elseif lang then
tdcli.sendMessage(msg.to.id, msg.id_, 1, "*لم يتم العثور على صورة شخصية..!*\n\n> ايدي المجموعة : `"..msg.to.id.."`\nايديك : `"..msg.from.id.."`", 1, 'md')
end
end
end
tdcli_function ({
ID = "GetUserProfilePhotos",
user_id_ = msg.from.id,
offset_ = 0,
limit_ = 1
}, getpro, nil)
end
if msg.reply_id and not matches[2] then
tdcli_function ({
ID = "GetMessage",
chat_id_ = msg.to.id,
message_id_ = msg.reply_id
}, action_by_reply, {chat_id=msg.to.id,cmd="ايدي"})
end
if matches[2] then
tdcli_function ({
ID = "SearchPublicChat",
username_ = matches[2]
}, action_by_username, {chat_id=msg.to.id,username=matches[2],cmd="ايدي"})
end
end
if matches[1] == "تثبيت" and is_mod(msg) and msg.reply_id then
local lock_pin = data[tostring(msg.to.id)]["settings"]["lock_pin"]
if lock_pin == 'yes' then
if is_owner(msg) then
data[tostring(chat)]['pin'] = msg.reply_id
save_data(_config.moderation.data, data)
tdcli.pinChannelMessage(msg.to.id, msg.reply_id, 1)
if not lang then
return "*Message Has Been Pinned*"
elseif lang then
return "🚸┋تم تثبيت الرسالة"
end
elseif not is_owner(msg) then
return
end
elseif lock_pin == 'no' then
data[tostring(chat)]['pin'] = msg.reply_id
save_data(_config.moderation.data, data)
tdcli.pinChannelMessage(msg.to.id, msg.reply_id, 1)
if not lang then
return "*Message Has Been Pinned*"
elseif lang then
return "🚸┋تم تثبيت الرسالة"
end
end
end
if matches[1] == 'الغاء تثبيت' and is_mod(msg) then
local lock_pin = data[tostring(msg.to.id)]["settings"]["lock_pin"]
if lock_pin == 'yes' then
if is_owner(msg) then
tdcli.unpinChannelMessage(msg.to.id)
if not lang then
return "*Pin message has been unpinned*"
elseif lang then
return "🚸┋ تم الغاء تثبيت الرسالة"
end
elseif not is_owner(msg) then
return
end
elseif lock_pin == 'no' then
tdcli.unpinChannelMessage(msg.to.id)
if not lang then
return "*Pin message has been unpinned*"
elseif lang then
return "🚸┋ تم الغاء تثبيت الرسالة"
end
end
end
if matches[1] == "تفعيل" then
return modadd(msg)
end
if matches[1] == "تعطيل" then
return modrem(msg)
end
if matches[1] == "رفع المدير" and is_admin(msg) then
if not matches[2] and msg.reply_id then
tdcli_function ({
ID = "GetMessage",
chat_id_ = msg.to.id,
message_id_ = msg.reply_id
}, action_by_reply, {chat_id=msg.to.id,cmd="رفع المدير"})
end
if matches[2] and string.match(matches[2], '^%d+$') then
tdcli_function ({
ID = "GetUser",
user_id_ = matches[2],
}, action_by_id, {chat_id=msg.to.id,user_id=matches[2],cmd="رفع المدير"})
end
if matches[2] and not string.match(matches[2], '^%d+$') then
tdcli_function ({
ID = "SearchPublicChat",
username_ = matches[2]
}, action_by_username, {chat_id=msg.to.id,username=matches[2],cmd="رفع المدير"})
end
end
if matches[1] == "تنزيل المدير" and is_admin(msg) then
if not matches[2] and msg.reply_id then
tdcli_function ({
ID = "GetMessage",
chat_id_ = msg.to.id,
message_id_ = msg.reply_id
}, action_by_reply, {chat_id=msg.to.id,cmd="تنزيل المدير"})
end
if matches[2] and string.match(matches[2], '^%d+$') then
tdcli_function ({
ID = "GetUser",
user_id_ = matches[2],
}, action_by_id, {chat_id=msg.to.id,user_id=matches[2],cmd="تنزيل المدير"})
end
if matches[2] and not string.match(matches[2], '^%d+$') then
tdcli_function ({
ID = "SearchPublicChat",
username_ = matches[2]
}, action_by_username, {chat_id=msg.to.id,username=matches[2],cmd="تنزيل المدير"})
end
end
if matches[1] == "رفع ادمن" and is_owner(msg) then
if not matches[2] and msg.reply_id then
tdcli_function ({
ID = "GetMessage",
chat_id_ = msg.to.id,
message_id_ = msg.reply_id
}, action_by_reply, {chat_id=msg.to.id,cmd="رفع ادمن"})
end
if matches[2] and string.match(matches[2], '^%d+$') then
tdcli_function ({
ID = "GetUser",
user_id_ = matches[2],
}, action_by_id, {chat_id=msg.to.id,user_id=matches[2],cmd="رفع ادمن"})
end
if matches[2] and not string.match(matches[2], '^%d+$') then
tdcli_function ({
ID = "SearchPublicChat",
username_ = matches[2]
}, action_by_username, {chat_id=msg.to.id,username=matches[2],cmd="رفع ادمن"})
end
end
if matches[1] == "تنزيل ادمن" and is_owner(msg) then
if not matches[2] and msg.reply_id then
tdcli_function ({
ID = "GetMessage",
chat_id_ = msg.to.id,
message_id_ = msg.reply_id
}, action_by_reply, {chat_id=msg.to.id,cmd="تنزيل ادمن"})
end
if matches[2] and string.match(matches[2], '^%d+$') then
tdcli_function ({
ID = "GetUser",
user_id_ = matches[2],
}, action_by_id, {chat_id=msg.to.id,user_id=matches[2],cmd="تنزيل ادمن"})
end
if matches[2] and not string.match(matches[2], '^%d+$') then
tdcli_function ({
ID = "SearchPublicChat",
username_ = matches[2]
}, action_by_username, {chat_id=msg.to.id,username=matches[2],cmd="تنزيل ادمن"})
end
end
if matches[1] == "قفل" and is_mod(msg) then
local target = msg.to.id
if matches[2] == "الروابط" then
return lock_link(msg, data, target)
end
if matches[2] == "اليوزر" then
return lock_tag(msg, data, target)
end
if matches[2] == "mention" then
return lock_mention(msg, data, target)
end
if matches[2] == "العربيه" then
return lock_arabic(msg, data, target)
end
if matches[2] == "التعديل" then
return lock_edit(msg, data, target)
end
if matches[2] == "الكلايش" then
return lock_spam(msg, data, target)
end
if matches[2] == "التكرار" then
return lock_flood(msg, data, target)
end
if matches[2] == "البوتات" then
return lock_bots(msg, data, target)
end
if matches[2] == "الماركدون" then
return lock_markdown(msg, data, target)
end
if matches[2] == "الويب" then
return lock_webpage(msg, data, target)
end
if matches[2] == "التثبيت" and is_owner(msg) then
return lock_pin(msg, data, target)
end
end
if matches[1] == "فتح" and is_mod(msg) then
local target = msg.to.id
if matches[2] == "الروابط" then
return unlock_link(msg, data, target)
end
if matches[2] == "اليوزر" then
return unlock_tag(msg, data, target)
end
if matches[2] == "المواقع" then
return unlock_mention(msg, data, target)
end
if matches[2] == "العربيه" then
return unlock_arabic(msg, data, target)
end
if matches[2] == "التعديل" then
return unlock_edit(msg, data, target)
end
if matches[2] == "السبام" then
return unlock_spam(msg, data, target)
end
if matches[2] == "التكرار" then
return unlock_flood(msg, data, target)
end
if matches[2] == "البوتات" then
return unlock_bots(msg, data, target)
end
if matches[2] == "الماركدون" then
return unlock_markdown(msg, data, target)
end
if matches[2] == "الويب" then
return unlock_webpage(msg, data, target)
end
if matches[2] == "التثبيت" and is_owner(msg) then
return unlock_pin(msg, data, target)
end
end
if matches[1] == "قفل" and is_mod(msg) then
local target = msg.to.id
if matches[2] == "الكل" then
return mute_all(msg, data, target)
end
if matches[2] == "المتحركه" then
return mute_gif(msg, data, target)
end
if matches[2] == "الدردشه" then
return mute_text(msg ,data, target)
end
if matches[2] == "الصور" then
return mute_photo(msg ,data, target)
end
if matches[2] == "الفديو" then
return mute_video(msg ,data, target)
end
if matches[2] == "الصوت" then
return mute_audio(msg ,data, target)
end
if matches[2] == "البصمات" then
return mute_voice(msg ,data, target)
end
if matches[2] == "الملصقات" then
return mute_sticker(msg ,data, target)
end
if matches[2] == "الجهات" then
return mute_contact(msg ,data, target)
end
if matches[2] == "التوجيه" then
return mute_forward(msg ,data, target)
end
if matches[2] == "المواقع" then
return mute_location(msg ,data, target)
end
if matches[2] == "الملفات" then
return mute_document(msg ,data, target)
end
if matches[2] == "الخدمات" then
return mute_tgservice(msg ,data, target)
end
if matches[2] == "انلاين" then
return mute_inline(msg ,data, target)
end
if matches[2] == "اللعبة" then
return mute_game(msg ,data, target)
end
if matches[2] == "الكيبورد" then
return mute_keyboard(msg ,data, target)
end
end
if matches[1] == "فتح" and is_mod(msg) then
local target = msg.to.id
if matches[2] == "الكل" then
return unmute_all(msg, data, target)
end
if matches[2] == "المتحركه" then
return unmute_gif(msg, data, target)
end
if matches[2] == "الدردشه" then
return unmute_text(msg, data, target)
end
if matches[2] == "الصور" then
return unmute_photo(msg ,data, target)
end
if matches[2] == "الفديو" then
return unmute_video(msg ,data, target)
end
if matches[2] == "الصوت" then
return unmute_audio(msg ,data, target)
end
if matches[2] == "البصمات" then
return unmute_voice(msg ,data, target)
end
if matches[2] == "��لملصقات" then
return unmute_sticker(msg ,data, target)
end
if matches[2] == "الجهات" then
return unmute_contact(msg ,data, target)
end
if matches[2] == "التوجيه" then
return unmute_forward(msg ,data, target)
end
if matches[2] == "المواقع" then
return unmute_location(msg ,data, target)
end
if matches[2] == "الملفات" then
return unmute_document(msg ,data, target)
end
if matches[2] == "الخدمات" then
return unmute_tgservice(msg ,data, target)
end
if matches[2] == "الانلاين" then
return unmute_inline(msg ,data, target)
end
if matches[2] == "اللعبة" then
return unmute_game(msg ,data, target)
end
if matches[2] == "الكيبورد" then
return unmute_keyboard(msg ,data, target)
end
end
if matches[1] == "معلومات المجموعه" and is_mod(msg) and msg.to.type == "channel" then
local function group_info(arg, data)
local hash = "gp_lang:"..arg.chat_id
local lang = redis:get(hash)
if not lang then
ginfo = "*Group Info :*\n_Admin Count :_ *"..data.administrator_count_.."*\n_Member Count :_ *"..data.member_count_.."*\n_Kicked Count :_ *"..data.kicked_count_.."*\n_Group ID :_ *"..data.channel_.id_.."*"
print(serpent.block(data))
elseif lang then
ginfo = "*معلومات المجموعه :*\n*عدد الادمنية* :*"..data.administrator_count_.."*\n*عدد الاعضاء* : *"..data.member_count_.."*\n*عدد المطرودين* : *"..data.kicked_count_.."*\n*ايدي المجموعة* : *"..data.channel_.id_.."*"
print(serpent.block(data))
end
tdcli.sendMessage(arg.chat_id, arg.msg_id, 1, ginfo, 1, 'md')
end
tdcli.getChannelFull(msg.to.id, group_info, {chat_id=msg.to.id,msg_id=msg.id})
end
if matches[1] == 'صنع رابط' and is_mod(msg) then
local function callback_link (arg, data)
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
local administration = load_data(_config.moderation.data)
if not data.invite_link_ then
administration[tostring(msg.to.id)]['settings']['linkgp'] = nil
save_data(_config.moderation.data, administration)
if not lang then
return tdcli.sendMessage(msg.to.id, msg.id, 1, "_Bot is not group creator_\n_set a link for group with using_ /setlink", 1, 'md')
elseif lang then
return tdcli.sendMessage(msg.to.id, msg.id, 1, "🔬┋المجموعة ليست من صنع البوت \n🚸┋ارسل /ضع رابط ثم ارسل الرابط", 1, 'md')
end
else
administration[tostring(msg.to.id)]['settings']['linkgp'] = data.invite_link_
save_data(_config.moderation.data, administration)
if not lang then
return tdcli.sendMessage(msg.to.id, msg.id, 1, "*Newlink Created*", 1, 'md')
elseif lang then
return tdcli.sendMessage(msg.to.id, msg.id, 1, "📡┋ تم انشاء الرابط", 1, 'md')
end
end
end
tdcli.exportChatInviteLink(msg.to.id, callback_link, nil)
end
if matches[1] == 'ضع رابط' and is_owner(msg) then
data[tostring(chat)]['settings']['linkgp'] = 'waiting'
save_data(_config.moderation.data, data)
if not lang then
return '_Please send the new group_ *link* _now_'
else
return 'ارسل رابط المجموعة الآن'
end
end
if msg.text then
local is_link = msg.text:match("^([https?://w]*.?telegram.me/joinchat/%S+)$") or msg.text:match("^([https?://w]*.?t.me/joinchat/%S+)$")
if is_link and data[tostring(chat)]['settings']['linkgp'] == 'waiting' and is_owner(msg) then
data[tostring(chat)]['settings']['linkgp'] = msg.text
save_data(_config.moderation.data, data)
if not lang then
return "*Newlink* _has been set_"
else
return "🔗┋ تم حفظ رابط المجموعة"
end
end
end
if matches[1] == 'الرابط' and is_mod(msg) then
local linkgp = data[tostring(chat)]['settings']['linkgp']
if not linkgp then
if not lang then
return "_First create a link for group with using_ /newlink\n_If bot not group creator set a link with using_ /setlink"
else
return "*ارسل ضع رابط لصنع رابط جديد*"
end
end
if not lang then
text = "<b>Group Link :</b>\n"..linkgp
else
text = "<b>رابط المجموعة 🔗:</b>\n"..linkgp
end
return tdcli.sendMessage(chat, msg.id, 1, text, 1, 'html')
end
if matches[1] == 'linkpv' and is_mod(msg) then
local linkgp = data[tostring(chat)]['settings']['linkgp']
if not linkgp then
if not lang then
return "_First create a link for group with using_ /newlink\n_If bot not group creator set a link with using_ /setlink"
else
return "*ارسل ضع رابط لصنع رابط جيد*"
end
end
if not lang then
tdcli.sendMessage(user, "", 1, "<b>Group Link "..msg.to.title.." :</b>\n"..linkgp, 1, 'html')
else
tdcli.sendMessage(user, "", 1, "<b>رابط مجموعة : "..msg.to.title.." :</b>\n"..linkgp, 1, 'html')
end
if not lang then
return "*Group Link Was Send In Your Private Message*"
else
return "❗️┋تم ارسال رابط المجموعة اليك"
end
end
if matches[1] == "ضع قوانين" and matches[2] and is_mod(msg) then
data[tostring(chat)]['rules'] = matches[2]
save_data(_config.moderation.data, data)
if not lang then
return "*Group rules* _has been set_"
else
return "❗️┋تم حفظ قوانين المجموعة"
end
end
if matches[1] == "القوانين" then
if not data[tostring(chat)]['rules'] then
if not lang then
rules = "ℹ️ The Default Rules :\n1⃣ No Flood.\n2⃣ No Spam.\n3⃣ No Advertising.\n4⃣ Try to stay on topic.\n5⃣ Forbidden any racist, sexual, homophobic or gore content.\n➡️ Repeated failure to comply with these rules will cause ban.\n@BeyondTeam"
elseif lang then
rules = "\n ❗️┋قوانين المجموعة ┋❗️\n🚸┋ عدم ارسال روابط في المجموعة \n💡┋عدم تكرار الرسائل او تنطرد\n🎚️┋عدم تخريب المجموعة \n🔞┋عدم ارسال صور اباحية \n •••••••••••••••••••••••••••••••••••••\n ❗️┋نتمنى لكم اسعد الاوقات في المجموعة┋❗️"
end
else
rules = "*Group Rules :*\n"..data[tostring(chat)]['rules']
end
return rules
end
if matches[1] == "res" and matches[2] and is_mod(msg) then
tdcli_function ({
ID = "SearchPublicChat",
username_ = matches[2]
}, action_by_username, {chat_id=msg.to.id,username=matches[2],cmd="res"})
end
if matches[1] == "whois" and matches[2] and is_mod(msg) then
tdcli_function ({
ID = "GetUser",
user_id_ = matches[2],
}, action_by_id, {chat_id=msg.to.id,user_id=matches[2],cmd="whois"})
end
if matches[1] == 'ضع تكرار' and is_mod(msg) then
if tonumber(matches[2]) < 1 or tonumber(matches[2]) > 50 then
return "_Wrong number, range is_ *[1-50]*"
end
local flood_max = matches[2]
data[tostring(chat)]['settings']['num_msg_max'] = flood_max
save_data(_config.moderation.data, data)
return "_♻️┋تم وضع عدد التكرار في المجموعه :_ *[ "..matches[2].." ]*"
end
if matches[1]:lower() == 'مسح' and is_owner(msg) then
if matches[2] == 'mods' then
if next(data[tostring(chat)]['mods']) == nil then
if not lang then
return "_No_ *moderators* _in this group_"
else
return "قائمة الاداريين فارغة"
end
end
for k,v in pairs(data[tostring(chat)]['mods']) do
data[tostring(chat)]['mods'][tostring(k)] = nil
save_data(_config.moderation.data, data)
end
if not lang then
return "_All_ *moderators* _has been demoted_"
else
return "تم تنزيل جميع الاداريين"
end
end
if matches[2] == 'filterlist' then
if next(data[tostring(chat)]['filterlist']) == nil then
if not lang then
return "*Filtered words list* _is empty_"
else
return "قائمة الكلمات الممنوعة فارغة"
end
end
for k,v in pairs(data[tostring(chat)]['filterlist']) do
data[tostring(chat)]['filterlist'][tostring(k)] = nil
save_data(_config.moderation.data, data)
end
if not lang then
return "*Filtered words list* _has been cleaned_"
else
return "تم مسح قائمة الكلمات الممنوعة"
end
end
if matches[2] == 'القوانين' then
if not data[tostring(chat)]['rules'] then
if not lang then
return "_No_ *rules* _available_"
else
return "❗️| لايوجد قوانين في المجموعة"
end
end
data[tostring(chat)]['rules'] = nil
save_data(_config.moderation.data, data)
if not lang then
return "*Group rules* _has been cleaned_"
else
return "تم مسح قوانين المجموعة"
end
end
if matches[2] == 'setwelcome' then
if not data[tostring(chat)]['setwelcome'] then
if not lang then
return "*Welcome Message not set*"
else
return "لا يوجد رسالة ترحيب"
end
end
data[tostring(chat)]['setwelcome'] = nil
save_data(_config.moderation.data, data)
if not lang then
return "*Welcome message* _has been cleaned_"
else
return "تم مسح الترحيب"
end
end
if matches[2] == 'الوصف' then
if msg.to.type == "chat" then
if not data[tostring(chat)]['about'] then
if not lang then
return "_No_ *description* _available_"
else
return "❗️┋لايوجد وصف في هذه المجموعة"
end
end
data[tostring(chat)]['about'] = nil
save_data(_config.moderation.data, data)
elseif msg.to.type == "channel" then
tdcli.changeChannelAbout(chat, "", dl_cb, nil)
end
if not lang then
return "*Group description* _has been cleaned_"
else
return "❗️️┋تم مسح وصف المجموعة"
end
end
end
if matches[1]:lower() == 'مسح' and is_admin(msg) then
if matches[2] == 'المدراء' then
if next(data[tostring(chat)]['owners']) == nil then
if not lang then
return "_No_ *owners* _in this group_"
else
return "💡️┋لابوجد مدراء في هذه المجموعة"
end
end
for k,v in pairs(data[tostring(chat)]['owners']) do
data[tostring(chat)]['owners'][tostring(k)] = nil
save_data(_config.moderation.data, data)
end
if not lang then
return "_All_ *owners* _has been demoted_"
else
return "💡️┋تم مسح قائمة المدراء"
end
end
end
if matches[1] == "ضع اسم" and matches[2] and is_mod(msg) then
local gp_name = matches[2]
tdcli.changeChatTitle(chat, gp_name, dl_cb, nil)
end
if matches[1] == "ضع وصف" and matches[2] and is_mod(msg) then
if msg.to.type == "channel" then
tdcli.changeChannelAbout(chat, matches[2], dl_cb, nil)
elseif msg.to.type == "chat" then
data[tostring(chat)]['about'] = matches[2]
save_data(_config.moderation.data, data)
end
if not lang then
return "*Group description* _has been set_"
else
return "❗️️┋تم حفظ وصف المجموعة"
end
end
if matches[1] == "الوصف" and msg.to.type == "chat" then
if not data[tostring(chat)]['about'] then
if not lang then
about = "_No_ *description* _available_"
elseif lang then
about = "❗️┋لايوجد وصف في هذه المجموعة"
end
else
about = "*Group Description :*\n"..data[tostring(chat)]['الوصف']
end
return about
end
if matches[1] == 'filter' and is_mod(msg) then
return filter_word(msg, matches[2])
end
if matches[1] == 'unfilter' and is_mod(msg) then
return unfilter_word(msg, matches[2])
end
if matches[1] == 'filterlist' and is_mod(msg) then
return filter_list(msg)
end
if matches[1] == "الحمايه" then
return group_settings(msg, target)
end
if matches[1] == "الوسائط" then
return mutes(msg, target)
end
if matches[1] == "الادمنيه" then
return modlist(msg)
end
if matches[1] == "المدراء" and is_owner(msg) then
return ownerlist(msg)
end
if matches[1] == "اللغه" and is_owner(msg) then
if matches[2] == "انكلش" then
local hash = "gp_lang:"..msg.to.id
local lang = redis:get(hash)
redis:del(hash)
return "_Group Language Set To:_ EN"
elseif matches[2] == "عربي" then
redis:set(hash, true)
return "* AR تم تحديد اللغة العربية*"
end
end
if matches[1] == "الاوامر" and is_mod(msg) then
if not lang then
text = [[
اوامر البوت
••••••••••ا•••••••••
┋تستخدم الاوامر┋
🔐┋قفل + الامر ┋ للقفل
🔓┋فتح + الامر ┋ للفتح
••••••••••ا•••••••••
🚸┋التعديل | التثبيت | الكلايش
🚸┋الانلاين | المتحركة | الصور
🚸┋الفيديو | الصوتيات | البصمات
🚸┋الروابط | الجهات | النص
🚸┋الملصقات | المواقع | الويب
🚸┋الماركدوان | التوجيه | الكتابة
🚸┋البوتات | التكرار | التاك
🚸┋الكيبورد | الكل | الملفات
••••••••••ا•••••••••
┋اوامر تخص المجموعة┋
••••••••••ا•••••••••
🔝┋رفع مدير |ايدي|بالرد|المعرف
🔝┋تنزيل عضو |ايدي|بالرد|المعرف
🔝┋رفع ادمن |ايدي|بالرد|المعرف
🔝┋تنزيل ادمن |ايدي|بالرد|المعرف
🔝┋حظر |ايدي|بالرد|المعرف
🔝┋كتم |ايدي|بالرد|المعرف
🔝┋فتح الحظر |ايدي|بالرد|المعرف
🔝┋فتح الكتم |ايدي|بالرد|المعرف
🔝┋حظر عام |ايدي|بالرد|المعرف
🔝┋فتح الحظر عام |ايدي|بالرد|المعرف
🔝┋امسح رسائل |ايدي|بالرد|المعرف
••••••••••ا•••••••••
💾┋المحظورين | المكتومين | الحظر العام
💾┋مسح |المحظورين|المكتومين|الحظر العام
💾┋صنع مجموعة | ضع اسم | ضع وصف
💾┋ ضع قوانين | ضع ترحيب | ضع صورة
💾┋الاعدادات | الحمايه
••••••••••ا•••••••••
┋اوامر لتغيير بروفايل البوت┋
🕹️┋اسم البوت | معرف البوت | صورة البوت]]
elseif lang then
text = [[
اوامر البوت
••••••••••ا•••••••••
┋تستخدم الاوامر┋
🔐┋قفل + الامر ┋ للقفل
🔓┋فتح + الامر ┋ للفتح
••••••••••ا•••••••••
🚸┋التعديل | التثبيت | الكلايش
🚸┋الانلاين | المتحركة | الصور
🚸┋الفيديو | الصوتيات | البصمات
🚸┋الروابط | الجهات | النص
🚸┋الملصقات | المواقع | الويب
🚸┋الماركدوان | التوجيه | الكتابة
🚸┋البوتات | التكرار | التاك
🚸┋الكيبورد | الكل | الملفات
••••••••••ا•••••••••
┋اوامر تخص المجموعة┋
••••••••••ا•••••••••
🔝┋رفع مدير |ايدي|بالرد|المعرف
🔝┋تنزيل عضو |ايدي|بالرد|المعرف
🔝┋رفع ادمن |ايدي|بالرد|المعرف
🔝┋تنزيل ادمن |ايدي|بالرد|المعرف
🔝┋حظر |ايدي|بالرد|المعرف
🔝┋كتم |ايدي|بالرد|المعرف
🔝┋فتح الحظر |ايدي|بالرد|المعرف
🔝┋فتح الكتم |ايدي|بالرد|المعرف
🔝┋حظر عام |ايدي|بالرد|المعرف
🔝┋فتح الحظر عام |ايدي|بالرد|المعرف
🔝┋امسح رسائل |ايدي|بالرد|المعرف
••••••••••ا•••••••••
💾┋المحظورين | المكتومين | الحظر العام
💾┋مسح |المحظورين|المكتومين|الحظر العام
💾┋صنع مجموعة | ضع اسم | ضع وصف
💾┋ ضع قوانين | ضع ترحيب | ضع صورة
💾┋الاعدادات | الحمايه
••••••••••ا•••••••••
┋اوامر لتغيير بروفايل البوت┋
🕹️┋اسم البوت | معرف البوت | صورة البوت]]
end
return text
end
--------------------- Welcome -----------------------
if matches[1] == "الترحيب" and is_mod(msg) then
if matches[2] == "تشغيل" then
welcome = data[tostring(chat)]['settings']['welcome']
if welcome == "yes" then
if not lang then
return "_Group_ *welcome* _is already enabled_"
elseif lang then
return "🔻 الترحيب مفعل بالفعل 🔺"
end
else
data[tostring(chat)]['settings']['welcome'] = "yes"
save_data(_config.moderation.data, data)
if not lang then
return "_Group_ *welcome* _has been enabled_"
elseif lang then
return "🔻 تم تفعيل الترحيب 🔺"
end
end
end
if matches[2] == "تعطيل" then
welcome = data[tostring(chat)]['settings']['welcome']
if welcome == "no" then
if not lang then
return "_Group_ *Welcome* _is already disabled_"
elseif lang then
return "🔺 الترحيب معطل بالفعل 🔻"
end
else
data[tostring(chat)]['settings']['welcome'] = "no"
save_data(_config.moderation.data, data)
if not lang then
return "_Group_ *welcome* _has been disabled_"
elseif lang then
return "🔻 تم تعطيل الترحيب 🔺"
end
end
end
end
if matches[1] == "صع ترحيب" and matches[2] and is_mod(msg) then
data[tostring(chat)]['setwelcome'] = matches[2]
save_data(_config.moderation.data, data)
if not lang then
return "_Welcome Message Has Been Set To :_\n*"..matches[2].."*\n\n*You can use :*\n_{gpname} Group Name_\n_{rules} ➣ Show Group Rules_\n_{name} ➣ New Member First Name_\n_{username} ➣ New Member Username_"
else
return "💾┋تم حفظ الترحيب : \n"..matches[2].."\n1 | لأضهار اسم المجموعة {gpname}\n 2| لأضهار المعرف {username}\n 3| لأضهار الاسم {name}\n 4| لأضهار القوانين {rules}"
end
end
end
end
-----------------------------------------
local function pre_process(msg)
local chat = msg.to.id
local user = msg.from.id
local data = load_data(_config.moderation.data)
local function welcome_cb(arg, data)
local hash = "gp_lang:"..arg.chat_id
local lang = redis:get(hash)
administration = load_data(_config.moderation.data)
if administration[arg.chat_id]['setwelcome'] then
welcome = administration[arg.chat_id]['setwelcome']
else
if not lang then
welcome = "*Welcome Dude* 💖🍂"
elseif lang then
welcome = "اهــلاً وسهـلاً 💖🍂"
end
end
if administration[tostring(arg.chat_id)]['rules'] then
rules = administration[arg.chat_id]['rules']
else
if not lang then
rules = "ℹ️ The Default Rules :\n1⃣ No Flood.\n2⃣ No Spam.\n3⃣ No Advertising.\n4⃣ Try to stay on topic.\n5⃣ Forbidden any racist, sexual, homophobic or gore content.\n➡️ Repeated failure to comply with these rules will cause ban"
elseif lang then
rules = "\n ❗️┋قوانين المجموعة ┋❗️\n🚸┋ عدم ارسال روابط في المجموعة \n💡┋عدم تكرار الرسائل او تنطرد\n🎚️┋عدم تخريب المجموعة \n🔞┋عدم ارسال صور اباحية \n •••••••••••••••••••••••••••••••••••••\n ❗️┋نتمنى لكم اسعد الاوقات في المجموعة┋❗️"
end
end
if data.username_ then
user_name = "@"..check_markdown(data.username_)
else
user_name = ""
end
local welcome = welcome:gsub("{rules}", rules)
local welcome = welcome:gsub("{name}", check_markdown(data.first_name_))
local welcome = welcome:gsub("{username}", user_name)
local welcome = welcome:gsub("{gpname}", arg.gp_name)
tdcli.sendMessage(arg.chat_id, arg.msg_id, 0, welcome, 0, "md")
end
if data[tostring(chat)] and data[tostring(chat)]['settings'] then
if msg.adduser then
welcome = data[tostring(msg.to.id)]['settings']['welcome']
if welcome == "yes" then
tdcli_function ({
ID = "GetUser",
user_id_ = msg.adduser
}, welcome_cb, {chat_id=chat,msg_id=msg.id,gp_name=msg.to.title})
else
return false
end
end
if msg.joinuser then
welcome = data[tostring(msg.to.id)]['settings']['welcome']
if welcome == "yes" then
tdcli_function ({
ID = "GetUser",
user_id_ = msg.joinuser
}, welcome_cb, {chat_id=chat,msg_id=msg.id,gp_name=msg.to.title})
else
return false
end
end
end
-- return msg
end
return {
patterns ={
"^(ايدي)$",
"^(ايدي) (.*)$",
"^(تثبيت)$",
"^(الغاء تثبيت)$",
"^(معلومات المجموعه)$",
"^[!/#](test)$",
"^(تفعيل)$",
"^(تعطيل)$",
"^(رفع المدير)$",
"^(رفع المدير) (.*)$",
"^(تنزيل المدير)$",
"^(تنزيل المدير) (.*)$",
"^(رفع ادمن)$",
"^(رفع ادمن) (.*)$",
"^(تنزيل ادمن)$",
"^(تنزيل ادمن) (.*)$",
"^(الادمنيه)$",
"^(المدراء)$",
"^(قفل) (.*)$",
"^(فتح) (.*)$",
"^(الحمايه)$",
"^(الوسائط)$",
"^(قفل) (.*)$",
"^(فتح) (.*)$",
"^(الرابط)$",
"^[!/#](linkpv)$",
"^(ضع رابط)$",
"^(صنع رابط)$",
"^(القوانين)$",
"^(ضع قوانين) (.*)$",
"^(الوصف)$",
"^(ضع وصف) (.*)$",
"^(ضع اسم) (.*)$",
"^(مسح) (.*)$",
"^(ضع تكرار) (%d+)$",
"^(res) (.*)$",
"^(whois) (%d+)$",
"^(الاوامر)$",
"^(اللغه) (.*)$",
"^[#!/](filter) (.*)$",
"^[#!/](unfilter) (.*)$",
"^[#!/](filterlist)$",
"^([https?://w]*.?t.me/joinchat/%S+)$",
"^([https?://w]*.?telegram.me/joinchat/%S+)$",
"^(ضع ترحيب) (.*)$",
"^(الترحيب) (.*)$",
},
run=run,
pre_process = pre_process
}
--end groupmanager.lua
| gpl-3.0 |
kbara/snabb | src/program/lwaftr/soaktest/soaktest.lua | 2 | 1366 | module(..., package.seeall)
local config = require("core.config")
local lib = require("core.lib")
local lwconf = require('apps.lwaftr.conf')
local setup = require("program.lwaftr.setup")
local long_opts = {
duration="D",
help="h",
["on-a-stick"] = 0,
}
function show_usage(code)
print(require("program.lwaftr.soaktest.README_inc"))
main.exit(code)
end
function parse_args (args)
local handlers = {}
local opts = {}
function handlers.h() show_usage(0) end
function handlers.D (arg)
opts.duration = tonumber(arg, "Duration must be a number")
end
handlers["on-a-stick"] = function ()
opts["on-a-stick"] = true
end
args = lib.dogetopt(args, handlers, "D:h", long_opts)
if #args ~= 3 then print("Wrong number of arguments: "..#args) show_usage(1) end
if not opts.duration then opts.duration = 0.10 end
return opts, args
end
function run (args)
local opts, args = parse_args(args)
local conf_file, inv4_pcap, inv6_pcap = unpack(args)
local load_soak_test = opts["on-a-stick"] and setup.load_soak_test_on_a_stick
or setup.load_soak_test
local c = config.new()
local conf = lwconf.load_lwaftr_config(conf_file)
load_soak_test(c, conf, inv4_pcap, inv6_pcap)
engine.configure(c)
engine.main({duration=opts.duration})
print("done")
end
| apache-2.0 |
dinodeck/rpg_conversation_graph | nwn_dialog/code/Animation.lua | 10 | 1057 | Animation = {}
Animation.__index = Animation
function Animation:Create(frames, loop, spf)
if loop == nil then
loop = true
end
local this =
{
mFrames = frames or { 1 },
mIndex = 1,
mSPF = spf or 0.12,
mTime = 0,
mLoop = loop
}
setmetatable(this, self)
return this
end
function Animation:Update(dt)
-- update the animation strip
self.mTime = self.mTime + dt
if self.mTime >= self.mSPF then
self.mIndex = self.mIndex + 1
self.mTime = 0
if self.mIndex > #self.mFrames then
if self.mLoop then
self.mIndex = 1
else
self.mIndex = #self.mFrames
end
end
end
end
function Animation:SetFrames(frames)
self.mFrames = frames
self.mIndex = math.min(self.mIndex, #self.mFrames)
end
function Animation:Frame()
return self.mFrames[self.mIndex]
end
function Animation:IsFinished()
return self.mLoop == false
and self.mIndex == #self.mFrames
end | mit |
CarabusX/Zero-K | LuaUI/Widgets/dbg_frame_grapher.lua | 6 | 2183 | function widget:GetInfo()
return {
name = "Frame Grapher",
desc = "Draw frame time graph in bottom right",
author = "Beherith",
date = "2020",
layer = -10000000000000000000,
enabled = false, -- loaded by default
}
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local spGetTimer = Spring.GetTimer
local spDiffTimers = Spring.DiffTimers
local deltats = {}
local timerold = 0
local viewSizeX, viewSizeY = 0,0
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function widget:Initialize()
startframe = Spring.GetGameFrame()
oldframe = startframe
viewSizeX, viewSizeY = gl.GetViewSizes()
end
function widget:ViewResize(vsx, vsy)
viewSizeX, viewSizeY = vsx , vsy
end
function widget:DrawScreen()
if timerold==0 then
timerold=Spring.GetTimer()
end
local timernew=Spring.GetTimer()
deltats [#deltats + 1] = Spring.DiffTimers(timernew,timerold)
timerold = timernew
--draw the bottom half of the screen as 2 seconds
--width of graph is e.q to 2sec
--height is 4 px = 1 ms
gl.PushMatrix()
gl.Color(0.0, 0.0, 0.0, 1.0)
gl.Rect(viewSizeX/2,0,viewSizeX,64);
gl.Color(1.0, 1.0, 1.0, 1.0)
gl.Text("DrawFrame times, top of this black area means 16ms (60fps), 2s window", viewSizeX/2, 48, 16, "d")
local leftpos = viewSizeX
local tindex = #deltats
local xmul = (viewSizeX/2.0)/2000.0
while leftpos > (viewSizeX/2) and tindex > 1 do-- we are not at halfway yet
deltat_ms = deltats[tindex]*1000
if deltat_ms > 16 then
local badness = math.min((deltat_ms-16.0)/16.0,1.0)
gl.Color(badness, 1.0-badness, 0.0, 1.0)
else
gl.Color(0.0, 1.0, 0.0, 1.0)
end
if deltat_ms < 100 then -- some minimal sanity
gl.Rect(leftpos-1,0 ,leftpos - deltat_ms*xmul, deltat_ms*4)
end
--Spring.Echo(leftpos,viewSizeY,leftpos - deltat_ms*xmul, viewSizeY - deltat_ms)
leftpos = leftpos - deltat_ms*xmul
tindex = tindex - 1
end
gl.Color(1.0, 1.0, 1.0, 1.0)
gl.PopMatrix()
end | gpl-2.0 |
veyesys/opencvr | 3rdparty/civetweb/test/html_esc.lua | 10 | 4611 | htmlEscape = { "☺", "☻", "♥", "♦", "♣", "♠", "•", -- ASCII 1-7 (symbols for control characters, see code page 437)
"◘", "○", "◙", "♂", "♀", "♪", "♫", "☼", -- ASCII 8-15
"►", "◄", "↕", "‼", "¶", "§", "▬", "↨", -- ASCII 16-23
"↑", "↓", "↨", "←", "∟", "→", "▲", "▼", -- ASCII 24-31
" ", "!", """, "#", "$", "%", "&", "'", -- ASCII 32-39
"(", ")", "*", "+", ",", "-", ".", "/", -- ASCII 40-47
"0", "1", "2", "3", "4", "5", "6", "7", -- ASCII 48-55
"8", "9", ":", ";", "<", "=", ">", "?", -- ASCII 56-63
"@", "A", "B", "C", "D", "E", "F", "G", -- ASCII 64-71
"H", "I", "J", "K", "L", "M", "N", "O", -- ASCII 72-79
"P", "Q", "R", "S", "T", "U", "V", "W", -- ASCII 80-87
"X", "Y", "Z", "[", "\\", "]", "^", "_", -- ASCII 88-95
"`", "a", "b", "c", "d", "e", "f", "g", -- ASCII 96-103
"h", "i", "j", "k", "l", "m", "n", "o", -- ASCII 104-111
"p", "q", "r", "s", "t", "u", "v", "w", -- ASCII 112-119
"x", "y", "z", "{", "|", "}", "~", "⌂", -- ASCII 120-127
"Ç", "ü", "é", "â", "ä", "à", "å", "ç", -- 128-135 (dos code page 850)
"ê", "ë", "è", "ï", "î", "ì", "Ä", "Å", -- 136-143
"É", "æ", "Æ", "ô", "ö", "ò", "û", "ù", -- 144-151
"ÿ", "Ö", "Ü", "ø", "£", "Ø", "×", "ƒ", -- 152-159
"á", "í", "ó", "ú", "ñ", "Ñ", "ª", "º", -- 160-167
"¿", "®", "¬", "½", "¼", "¡", "«", "»", -- 168-175
"░", "▒", "▓", "│", "┤", "Á", "Â", "À", -- 176-183
"©", "╣", "║", "╗", "╝", "¢", "¥", "┐", -- 184-191
"└", "┴", "┬", "├", "─", "┼", "ã", "Ã", -- 192-199
"╚", "╔", "╩", "╦", "╠", "═", "╬", "¤", -- 200-207
"ð", "Ð", "Ê", "Ë", "È", "ı", "Í", "Î", -- 208-215
"Ï", "┘", "┌", "█", "▄", "¦", "Ì", "▀", -- 216-223
"Ó", "ß", "Ô", "Ò", "õ", "Õ", "µ", "þ", -- 224-231
"Þ", "Ú", "Û", "Ù", "ý", "Ý", "¯", "´", -- 232-239
"≡", "±", "‗", "¾", "¶", "§", "÷", "¸", -- 240-247
"°", "¨", "·", "¹", "³", "²", "■", "□", -- 248-255 (use empty box for 255)
};
htmlEscape[0] = "·" -- in this table, we use a 8 bit character set, where every has a different graphical representation
-- the conversion table should work as a convertion function for strings as well
setmetatable(htmlEscape, {__call = function (tab,str) return string.gsub(str, ".", function (c) return tab[c:byte()] end) end})
function htmlEsc(txt)
s = txt:gsub("%&", "&")
s = s:gsub("%<", "<")
return s:gsub("%>", ">")
end
function iso8859_1_to_utf8(txt)
local s = txt:gsub(".",
function (c)
local b = c:byte()
if b < 128 then
return c
elseif b < 192 then
return string.char(194, b)
else
return string.char(195, b-64)
end
end)
return s
end
| mit |
minetest-mods/MoreMesecons | moremesecons_adjustable_blinkyplant/init.lua | 2 | 2104 | local toggle_timer = function (pos, restart)
local timer = minetest.get_node_timer(pos)
if timer:is_started()
and not restart then
timer:stop()
else
local interval = tonumber(minetest.get_meta(pos):get_string("interval")) or 1
if interval < moremesecons.setting("adjustable_blinky_plant", "min_interval", 0.5) then
interval = moremesecons.setting("adjustable_blinky_plant", "min_interval", 0.5)
end
timer:start(interval)
end
end
local on_timer = function(pos)
if mesecon.flipstate(pos, minetest.get_node(pos)) == "on" then
mesecon.receptor_on(pos)
else
mesecon.receptor_off(pos)
end
toggle_timer(pos, false)
end
mesecon.register_node("moremesecons_adjustable_blinkyplant:adjustable_blinky_plant", {
description="Adjustable Blinky Plant",
drawtype = "plantlike",
inventory_image = "moremesecons_blinky_plant_off.png",
paramtype = "light",
walkable = false,
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, -0.5+0.7, 0.3},
},
on_timer = on_timer,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("interval", "1")
meta:set_string("formspec", "field[interval;interval;${interval}]")
toggle_timer(pos, true)
end,
on_receive_fields = function(pos, _, fields, player)
local interval = tonumber(fields.interval)
if interval
and not minetest.is_protected(pos, player:get_player_name()) then
minetest.get_meta(pos):set_string("interval", interval)
toggle_timer(pos, true)
end
end,
},{
tiles = {"moremesecons_blinky_plant_off.png"},
groups = {dig_immediate=3},
mesecons = {receptor = { state = mesecon.state.off }}
},{
tiles = {"moremesecons_blinky_plant_off.png^moremesecons_blinky_plant_on.png"},
groups = {dig_immediate=3, not_in_creative_inventory=1},
sunlight_propagates = true,
mesecons = {receptor = { state = mesecon.state.on }},
})
minetest.register_craft({
output = "moremesecons_adjustable_blinkyplant:adjustable_blinky_plant_off 1",
recipe = { {"mesecons_blinkyplant:blinky_plant_off"},
{"default:mese_crystal_fragment"},}
})
| mpl-2.0 |
rainfiel/skynet | lualib/snax.lua | 59 | 3683 | local skynet = require "skynet"
local snax_interface = require "snax.interface"
local snax = {}
local typeclass = {}
local interface_g = skynet.getenv("snax_interface_g")
local G = interface_g and require (interface_g) or { require = function() end }
interface_g = nil
skynet.register_protocol {
name = "snax",
id = skynet.PTYPE_SNAX,
pack = skynet.pack,
unpack = skynet.unpack,
}
function snax.interface(name)
if typeclass[name] then
return typeclass[name]
end
local si = snax_interface(name, G)
local ret = {
name = name,
accept = {},
response = {},
system = {},
}
for _,v in ipairs(si) do
local id, group, name, f = table.unpack(v)
ret[group][name] = id
end
typeclass[name] = ret
return ret
end
local meta = { __tostring = function(v) return string.format("[%s:%x]", v.type, v.handle) end}
local skynet_send = skynet.send
local skynet_call = skynet.call
local function gen_post(type, handle)
return setmetatable({} , {
__index = function( t, k )
local id = type.accept[k]
if not id then
error(string.format("post %s:%s no exist", type.name, k))
end
return function(...)
skynet_send(handle, "snax", id, ...)
end
end })
end
local function gen_req(type, handle)
return setmetatable({} , {
__index = function( t, k )
local id = type.response[k]
if not id then
error(string.format("request %s:%s no exist", type.name, k))
end
return function(...)
return skynet_call(handle, "snax", id, ...)
end
end })
end
local function wrapper(handle, name, type)
return setmetatable ({
post = gen_post(type, handle),
req = gen_req(type, handle),
type = name,
handle = handle,
}, meta)
end
local handle_cache = setmetatable( {} , { __mode = "kv" } )
function snax.rawnewservice(name, ...)
local t = snax.interface(name)
local handle = skynet.newservice("snaxd", name)
assert(handle_cache[handle] == nil)
if t.system.init then
skynet.call(handle, "snax", t.system.init, ...)
end
return handle
end
function snax.bind(handle, type)
local ret = handle_cache[handle]
if ret then
assert(ret.type == type)
return ret
end
local t = snax.interface(type)
ret = wrapper(handle, type, t)
handle_cache[handle] = ret
return ret
end
function snax.newservice(name, ...)
local handle = snax.rawnewservice(name, ...)
return snax.bind(handle, name)
end
local function service_name(global, name, ...)
if global == true then
return name
else
return global
end
end
function snax.uniqueservice(name, ...)
local handle = assert(skynet.call(".service", "lua", "LAUNCH", "snaxd", name, ...))
return snax.bind(handle, name)
end
function snax.globalservice(name, ...)
local handle = assert(skynet.call(".service", "lua", "GLAUNCH", "snaxd", name, ...))
return snax.bind(handle, name)
end
function snax.queryservice(name)
local handle = assert(skynet.call(".service", "lua", "QUERY", "snaxd", name))
return snax.bind(handle, name)
end
function snax.queryglobal(name)
local handle = assert(skynet.call(".service", "lua", "GQUERY", "snaxd", name))
return snax.bind(handle, name)
end
function snax.kill(obj, ...)
local t = snax.interface(obj.type)
skynet_call(obj.handle, "snax", t.system.exit, ...)
end
function snax.self()
return snax.bind(skynet.self(), SERVICE_NAME)
end
function snax.exit(...)
snax.kill(snax.self(), ...)
end
local function test_result(ok, ...)
if ok then
return ...
else
error(...)
end
end
function snax.hotfix(obj, source, ...)
local t = snax.interface(obj.type)
return test_result(skynet_call(obj.handle, "snax", t.system.hotfix, source, ...))
end
function snax.printf(fmt, ...)
skynet.error(string.format(fmt, ...))
end
return snax
| mit |
mattyx14/otxserver | data/scripts/spells/monster/the_welter_heal.lua | 2 | 1187 | local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_NONE)
local spell = Spell("instant")
function spell.onCastSpell(creature, var)
local spectators, spectator = Game.getSpectators(creature:getPosition(), false, false, 10, 10, 10, 10)
for i = 1, #spectators do
spectator = spectators[i]
if spectator:isMonster() and spectator:getName() == "Egg" then
spectator:getPosition():sendMagicEffect(CONST_ME_HITBYPOISON)
spectator:remove()
creature:say("<the welter devours his spawn and heals himself>", TALKTYPE_ORANGE_1)
creature:addHealth(25000)
creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
return true
elseif spectator:isMonster() and spectator:getName() == "Spawn Of The Welter" then
spectator:getPosition():sendMagicEffect(CONST_ME_DRAWBLOOD)
spectator:remove()
creature:say("<the welter devours his spawn and heals himself>", TALKTYPE_ORANGE_1)
creature:addHealth(25000)
creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
return true
end
end
return combat:execute(creature, var)
end
spell:name("the welter heal")
spell:words("###336")
spell:blockWalls(true)
spell:needLearn(true)
spell:register() | gpl-2.0 |
fo369/luci-1505 | modules/luci-base/luasrc/ltn12.lua | 84 | 8954 | --[[
LuaSocket 2.0.2 license
Copyright � 2004-2007 Diego Nehab
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
]]--
--[[
Changes made by LuCI project:
* Renamed to luci.ltn12 to avoid collisions with luasocket
* Added inline documentation
]]--
-----------------------------------------------------------------------------
-- LTN12 - Filters, sources, sinks and pumps.
-- LuaSocket toolkit.
-- Author: Diego Nehab
-- RCS ID: $Id$
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
-- Declare module
-----------------------------------------------------------------------------
local string = require("string")
local table = require("table")
local base = _G
-- See http://lua-users.org/wiki/FiltersSourcesAndSinks for design concepts
module("luci.ltn12")
filter = {}
source = {}
sink = {}
pump = {}
-- 2048 seems to be better in windows...
BLOCKSIZE = 2048
_VERSION = "LTN12 1.0.1"
-----------------------------------------------------------------------------
-- Filter stuff
-----------------------------------------------------------------------------
-- by passing it each chunk and updating a context between calls.
function filter.cycle(low, ctx, extra)
base.assert(low)
return function(chunk)
local ret
ret, ctx = low(ctx, chunk, extra)
return ret
end
end
-- (thanks to Wim Couwenberg)
function filter.chain(...)
local n = table.getn(arg)
local top, index = 1, 1
local retry = ""
return function(chunk)
retry = chunk and retry
while true do
if index == top then
chunk = arg[index](chunk)
if chunk == "" or top == n then return chunk
elseif chunk then index = index + 1
else
top = top+1
index = top
end
else
chunk = arg[index](chunk or "")
if chunk == "" then
index = index - 1
chunk = retry
elseif chunk then
if index == n then return chunk
else index = index + 1 end
else base.error("filter returned inappropriate nil") end
end
end
end
end
-----------------------------------------------------------------------------
-- Source stuff
-----------------------------------------------------------------------------
-- create an empty source
local function empty()
return nil
end
function source.empty()
return empty
end
function source.error(err)
return function()
return nil, err
end
end
function source.file(handle, io_err)
if handle then
return function()
local chunk = handle:read(BLOCKSIZE)
if chunk and chunk:len() == 0 then chunk = nil end
if not chunk then handle:close() end
return chunk
end
else return source.error(io_err or "unable to open file") end
end
function source.simplify(src)
base.assert(src)
return function()
local chunk, err_or_new = src()
src = err_or_new or src
if not chunk then return nil, err_or_new
else return chunk end
end
end
function source.string(s)
if s then
local i = 1
return function()
local chunk = string.sub(s, i, i+BLOCKSIZE-1)
i = i + BLOCKSIZE
if chunk ~= "" then return chunk
else return nil end
end
else return source.empty() end
end
function source.rewind(src)
base.assert(src)
local t = {}
return function(chunk)
if not chunk then
chunk = table.remove(t)
if not chunk then return src()
else return chunk end
else
t[#t+1] = chunk
end
end
end
function source.chain(src, f)
base.assert(src and f)
local last_in, last_out = "", ""
local state = "feeding"
local err
return function()
if not last_out then
base.error('source is empty!', 2)
end
while true do
if state == "feeding" then
last_in, err = src()
if err then return nil, err end
last_out = f(last_in)
if not last_out then
if last_in then
base.error('filter returned inappropriate nil')
else
return nil
end
elseif last_out ~= "" then
state = "eating"
if last_in then last_in = "" end
return last_out
end
else
last_out = f(last_in)
if last_out == "" then
if last_in == "" then
state = "feeding"
else
base.error('filter returned ""')
end
elseif not last_out then
if last_in then
base.error('filter returned inappropriate nil')
else
return nil
end
else
return last_out
end
end
end
end
end
-- Sources will be used one after the other, as if they were concatenated
-- (thanks to Wim Couwenberg)
function source.cat(...)
local src = table.remove(arg, 1)
return function()
while src do
local chunk, err = src()
if chunk then return chunk end
if err then return nil, err end
src = table.remove(arg, 1)
end
end
end
-----------------------------------------------------------------------------
-- Sink stuff
-----------------------------------------------------------------------------
function sink.table(t)
t = t or {}
local f = function(chunk, err)
if chunk then t[#t+1] = chunk end
return 1
end
return f, t
end
function sink.simplify(snk)
base.assert(snk)
return function(chunk, err)
local ret, err_or_new = snk(chunk, err)
if not ret then return nil, err_or_new end
snk = err_or_new or snk
return 1
end
end
function sink.file(handle, io_err)
if handle then
return function(chunk, err)
if not chunk then
handle:close()
return 1
else return handle:write(chunk) end
end
else return sink.error(io_err or "unable to open file") end
end
-- creates a sink that discards data
local function null()
return 1
end
function sink.null()
return null
end
function sink.error(err)
return function()
return nil, err
end
end
function sink.chain(f, snk)
base.assert(f and snk)
return function(chunk, err)
if chunk ~= "" then
local filtered = f(chunk)
local done = chunk and ""
while true do
local ret, snkerr = snk(filtered, err)
if not ret then return nil, snkerr end
if filtered == done then return 1 end
filtered = f(done)
end
else return 1 end
end
end
-----------------------------------------------------------------------------
-- Pump stuff
-----------------------------------------------------------------------------
function pump.step(src, snk)
local chunk, src_err = src()
local ret, snk_err = snk(chunk, src_err)
if chunk and ret then return 1
else return nil, src_err or snk_err end
end
function pump.all(src, snk, step)
base.assert(src and snk)
step = step or pump.step
while true do
local ret, err = step(src, snk)
if not ret then
if err then return nil, err
else return 1 end
end
end
end
| apache-2.0 |
TideSofDarK/DotaCraft | game/dota_addons/dotacraft/scripts/vscripts/heroes/far_seer/chain_lightning.lua | 1 | 4296 | --[[
Author: Noya
Date: 17.01.2015.
Bounces a chain lightning
]]
function ChainLightning( event )
local hero = event.caster
local target = event.target
local ability = event.ability
local damage = ability:GetLevelSpecialValueFor( "lightning_damage", ability:GetLevel() - 1 )
local bounces = ability:GetLevelSpecialValueFor( "lightning_bounces", ability:GetLevel() - 1 )
local bounce_range = ability:GetLevelSpecialValueFor( "bounce_range", ability:GetLevel() - 1 )
local decay = ability:GetLevelSpecialValueFor( "lightning_decay", ability:GetLevel() - 1 ) * 0.01
local time_between_bounces = ability:GetLevelSpecialValueFor( "time_between_bounces", ability:GetLevel() - 1 )
local lightningBolt = ParticleManager:CreateParticle("particles/items_fx/chain_lightning.vpcf", PATTACH_WORLDORIGIN, hero)
ParticleManager:SetParticleControl(lightningBolt,0,Vector(hero:GetAbsOrigin().x,hero:GetAbsOrigin().y,hero:GetAbsOrigin().z + hero:GetBoundingMaxs().z ))
ParticleManager:SetParticleControl(lightningBolt,1,Vector(target:GetAbsOrigin().x,target:GetAbsOrigin().y,target:GetAbsOrigin().z + target:GetBoundingMaxs().z ))
--ParticleManager:SetParticleControlEnt(lightningBolt, 1, target, 1, "attach_hitloc", target:GetAbsOrigin(), true)
EmitSoundOn("Hero_Zuus.ArcLightning.Target", target)
ApplyDamage({ victim = target, attacker = hero, damage = damage, damage_type = DAMAGE_TYPE_MAGICAL })
PopupDamage(target,math.floor(damage))
-- Every target struck by the chain is added to a list of targets struck, And set a boolean inside its index to be sure we don't hit it twice.
local targetsStruck = {}
target.struckByChain = true
table.insert(targetsStruck,target)
local dummy = nil
local units = nil
Timers:CreateTimer(DoUniqueString("ChainLightning"), {
endTime = time_between_bounces,
callback = function()
-- unit selection and counting
units = FindUnitsInRadius(hero:GetTeamNumber(), target:GetOrigin(), target, bounce_range, DOTA_UNIT_TARGET_TEAM_ENEMY,
DOTA_UNIT_TARGET_BASIC + DOTA_UNIT_TARGET_HERO, DOTA_UNIT_TARGET_FLAG_NONE, FIND_ANY_ORDER, true)
-- particle and dummy to start the chain
targetVec = target:GetAbsOrigin()
targetVec.z = target:GetAbsOrigin().z + target:GetBoundingMaxs().z
if dummy ~= nil then
dummy:RemoveSelf()
end
dummy = CreateUnitByName("dummy_unit", targetVec, false, hero, hero, hero:GetTeam())
-- Track the possible targets to bounce from the units in radius
local possibleTargetsBounce = {}
for _,v in pairs(units) do
if not v.struckByChain then
table.insert(possibleTargetsBounce,v)
end
end
-- Select one of those targets at random
target = possibleTargetsBounce[math.random(1,#possibleTargetsBounce)]
if target then
target.struckByChain = true
table.insert(targetsStruck,target)
else
-- There's no more targets left to bounce, clear the struck table and end
for _,v in pairs(targetsStruck) do
v.struckByChain = false
v = nil
end
print("End Chain, no more targets")
return
end
local lightningChain = ParticleManager:CreateParticle("particles/items_fx/chain_lightning.vpcf", PATTACH_WORLDORIGIN, dummy)
ParticleManager:SetParticleControl(lightningChain,0,Vector(dummy:GetAbsOrigin().x,dummy:GetAbsOrigin().y,dummy:GetAbsOrigin().z + dummy:GetBoundingMaxs().z ))
-- damage and decay
damage = damage - (damage*decay)
ApplyDamage({ victim = target, attacker = hero, damage = damage, damage_type = DAMAGE_TYPE_MAGICAL })
PopupDamage(target,math.floor(damage))
print("Bounce "..bounces.." Hit Unit "..target:GetEntityIndex().. " for "..damage.." damage")
-- play the sound
EmitSoundOn("Hero_Zuus.ArcLightning.Target",target)
-- make the particle shoot to the target
ParticleManager:SetParticleControl(lightningChain,1,Vector(target:GetAbsOrigin().x,target:GetAbsOrigin().y,target:GetAbsOrigin().z + target:GetBoundingMaxs().z ))
-- decrement remaining spell bounces
bounces = bounces - 1
-- fire the timer again if spell bounces remain
if bounces > 0 then
return time_between_bounces
else
for _,v in pairs(targetsStruck) do
v.struckByChain = false
v = nil
end
print("End Chain, no more bounces")
end
end
})
end | gpl-3.0 |
Moosader/Kuko | scripts/Language.lua | 2 | 1264 | print( "Language.lua loaded" )
function Language_GetText( key )
if ( language == nil or language[ key ] == nil ) then
return "NOTFOUND"
end
return language[ key ]
end
-- this is for if the language table is stored in something other than a variable named "language"
function Language_GetTextFromLanguage( key, langType )
if ( language == nil or language[ langType ] == nil or language[ langType ][ key ] == nil ) then
return "NOTFOUND"
end
return language[ langType ][ key ]
end
function Language_GetSuggestedFont()
if ( language == nil or language[ "suggested_font" ] == nil ) then
return "NOTFOUND"
end
return language[ "suggested_font" ]
end
-- language["target"]["pronouns"][2]
-- language["helper"]["pronouns"]["English-he"]
function Language_GetSpecialField( langType, field, key )
if ( language == nil or language[langType] == nil or language[langType][field] == nil or language[langType][field][key] == nil ) then
return "NOTFOUND"
end
return language[langType][field][key]
end
-- Target / Pronouns
function Language_GetSpecialFieldCount( langType, field )
count = 0
if ( language[langType][field] == nil ) then
return 0
end
for key, value in pairs( language[langType][field] ) do
count = count + 1
end
return count
end
| mit |
CarabusX/Zero-K | LuaUI/i18nlib/i18n/interpolate.lua | 27 | 1075 |
local unpack = unpack or table.unpack -- lua 5.2 compat
local bracketDummy = "@@@@@@@@@{@@@@@@@@@"
local ltDummy = "@@@@@@@@@<@@@@@@@@@"
-- matches a string of type %{age}
local function interpolateVariables(str, vars)
return str:gsub("%%{%s*(.-)%s*}", function(key) return tostring(vars[key]) end)
end
-- matches a string of type %<age>.d
local function interpolateFormattedVariables(str, vars)
return str:gsub("%%<%s*(.-)%s*>%.([cdEefgGiouXxsq])", function(key, formatChar)
return string.format("%" .. formatChar, vars[key] or 'nil')
end)
end
local function escapeDoublePercent(str)
return str:gsub("%%%%{", bracketDummy):gsub("%%%%<", ltDummy)
end
local function unescapeDoublePercent(str)
return str:gsub(ltDummy, "%%<"):gsub(bracketDummy, "%%{")
end
local function interpolate(str, vars)
vars = vars or {}
str = escapeDoublePercent(str)
str = interpolateVariables(str, vars)
str = interpolateFormattedVariables(str, vars)
str = string.format(str, unpack(vars))
str = unescapeDoublePercent(str)
return str
end
return interpolate
| gpl-2.0 |
pampersrocker/risky-epsilon | Game/data/scripts/zombie_prototype/guns.lua | 1 | 2503 |
function __gun__update(guid, elapsedTime)
local self = __guns[guid]
if (self.shootTimer > 0) then
self.shootTimer = math.clamp(self.shootTimer - elapsedTime, 0, self.shootDelay)
end
if (self.reloadTimer > 0) then
self.reloadTimer = math.clamp(self.reloadTimer - elapsedTime, 0, self.reloadDelay)
if (self.reloadTimer == 0) then
self.bullets = self.magazineSize
self.shootTimer = 0
end
end
DebugRenderer:printText(Vec2(-0.9, 0.85), "gun: " .. self.name)
DebugRenderer:printText(Vec2(-0.9, 0.80), "bullets: " .. self.bullets .. " / " .. self.magazineSize)
if (self.reloadTimer > 0) then
DebugRenderer:printText(Vec2(-0.9, 0.75), "reloading: " .. string.format("%5.2f", self.reloadTimer))
end
end
function __gun__canShootOrReload(self)
return (self.shootTimer == 0 and self.reloadTimer == 0)
end
function __gun__shoot(self)
if (self:canShootOrReload()) then
if (self.bullets > 0) then
self.bullets = self.bullets - 1
self.shootTimer = self.shootDelay
self.shootSound:stop()
self.shootSound:play()
return true
else
self:reload()
return false
end
end
return false
end
function __gun__reload(self)
if (self.bullets < self.magazineSize and self.reloadTimer == 0) then
self.shootTimer = 0
self.reloadTimer = self.reloadDelay
self.reloadSound:play()
end
end
function __gun__getRecoil(self)
return Vec2(math.random(-self.recoil, self.recoil), math.random(-self.recoil, self.recoil))
end
function __gun__setActive(self, active, reset)
self.shootTimer = 0
self.reloadTimer = 0
if (self.bullets == nil) then
self.bullets = self.magazineSize
end
if (active) then
if (reset) then
self.bullets = self.magazineSize
else
self:reload()
end
self:setComponentStates(ComponentState.Active)
else
self:setComponentStates(ComponentState.Inactive)
end
end
__guns = {}
function createGun(guid, damage, shootDelay, recoil, magazineSize, reloadDelay)
local gun = GameObjectManager:createGameObject(guid)
__guns[guid] = gun
gun.sc = gun:createScriptComponent()
gun.sc:setUpdateFunction(__gun__update)
gun.name = guid
gun.damage = damage
gun.shootDelay = shootDelay
gun.recoil = recoil
gun.magazineSize = magazineSize
gun.reloadDelay = reloadDelay
gun.canShootOrReload = __gun__canShootOrReload
gun.shoot = __gun__shoot
gun.reload = __gun__reload
gun.getRecoil = __gun__getRecoil
gun.setActive = __gun__setActive
return gun
end
| mit |
aqasaeed/sparta | plugins/minecraft.lua | 624 | 2605 | local usage = {
"!mine [ip]: Searches Minecraft server on specified ip and sends info. Default port: 25565",
"!mine [ip] [port]: Searches Minecraft server on specified ip and port and sends info.",
}
local ltn12 = require "ltn12"
local function mineSearch(ip, port, receiver) --25565
local responseText = ""
local api = "https://api.syfaro.net/server/status"
local parameters = "?ip="..(URL.escape(ip) or "").."&port="..(URL.escape(port) or "").."&players=true&favicon=true"
local http = require("socket.http")
local respbody = {}
local body, code, headers, status = http.request{
url = api..parameters,
method = "GET",
redirect = true,
sink = ltn12.sink.table(respbody)
}
local body = table.concat(respbody)
if (status == nil) then return "ERROR: status = nil" end
if code ~=200 then return "ERROR: "..code..". Status: "..status end
local jsonData = json:decode(body)
responseText = responseText..ip..":"..port.." ->\n"
if (jsonData.motd ~= nil) then
local tempMotd = ""
tempMotd = jsonData.motd:gsub('%§.', '')
if (jsonData.motd ~= nil) then responseText = responseText.." Motd: "..tempMotd.."\n" end
end
if (jsonData.online ~= nil) then
responseText = responseText.." Online: "..tostring(jsonData.online).."\n"
end
if (jsonData.players ~= nil) then
if (jsonData.players.max ~= nil) then
responseText = responseText.." Max Players: "..jsonData.players.max.."\n"
end
if (jsonData.players.now ~= nil) then
responseText = responseText.." Players online: "..jsonData.players.now.."\n"
end
if (jsonData.players.sample ~= nil and jsonData.players.sample ~= false) then
responseText = responseText.." Players: "..table.concat(jsonData.players.sample, ", ").."\n"
end
end
if (jsonData.favicon ~= nil and false) then
--send_photo(receiver, jsonData.favicon) --(decode base64 and send)
end
return responseText
end
local function parseText(chat, text)
if (text == nil or text == "!mine") then
return usage
end
ip, port = string.match(text, "^!mine (.-) (.*)$")
if (ip ~= nil and port ~= nil) then
return mineSearch(ip, port, chat)
end
local ip = string.match(text, "^!mine (.*)$")
if (ip ~= nil) then
return mineSearch(ip, "25565", chat)
end
return "ERROR: no input ip?"
end
local function run(msg, matches)
local chat_id = tostring(msg.to.id)
local result = parseText(chat_id, msg.text)
return result
end
return {
description = "Searches Minecraft server and sends info",
usage = usage,
patterns = {
"^!mine (.*)$"
},
run = run
} | gpl-2.0 |
mattyx14/otxserver | data/monster/quests/ferumbras_ascendant/bosses/ragiaz.lua | 2 | 5295 | local mType = Game.createMonsterType("Ragiaz")
local monster = {}
monster.description = "ragiaz"
monster.experience = 100000
monster.outfit = {
lookType = 862,
lookHead = 76,
lookBody = 57,
lookLegs = 19,
lookFeet = 0,
lookAddons = 3,
lookMount = 0
}
monster.health = 380000
monster.maxHealth = 380000
monster.race = "undead"
monster.corpse = 22495
monster.speed = 340
monster.manaCost = 0
monster.changeTarget = {
interval = 5000,
chance = 8
}
monster.strategiesTarget = {
nearest = 70,
health = 10,
damage = 10,
random = 10,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = true,
illusionable = false,
canPushItems = true,
canPushCreatures = true,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = true,
canWalkOnFire = true,
canWalkOnPoison = true
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
}
monster.loot = {
{id = 22516, chance = 1000000}, -- silver token
{id = 6558, chance = 10000}, -- flask of demonic blood
{id = 6558, chance = 10000}, -- flask of demonic blood
{id = 6558, chance = 10000}, -- flask of demonic blood
{id = 6558, chance = 10000}, -- flask of demonic blood
{id = 6558, chance = 10000}, -- flask of demonic blood
{id = 3037, chance = 1000}, -- yellow gem
{id = 16125, chance = 3000, maxCount = 5}, -- cyan crystal fragment
{id = 16126, chance = 3000, maxCount = 5}, -- red crystal fragment
{id = 16127, chance = 3000, maxCount = 5}, -- green crystal fragment
{id = 3026, chance = 3000, maxCount = 8}, -- white pearl
{id = 3029, chance = 3000, maxCount = 9}, -- small sapphire
{id = 3031, chance = 98000, maxCount = 200}, -- gold coin
{id = 3033, chance = 3000, maxCount = 5}, -- small amethyst
{id = 3035, chance = 8000, maxCount = 58}, -- platinum coin
{id = 3038, chance = 1000}, -- green gem
{id = 3039, chance = 1000}, -- red gem
{id = 3041, chance = 1000}, -- blue gem
{id = 3324, chance = 4000}, -- skull staff
{id = 22758, chance = 100, unique = true}, -- death gaze
{id = 22866, chance = 700}, -- rift bow
{id = 22867, chance = 700}, -- rift crossbow
{id = 6499, chance = 11000}, -- demonic essence
{id = 7420, chance = 500}, -- reaper's axe
{id = 7426, chance = 4000}, -- amber staff
{id = 238, chance = 3000, maxCount = 5}, -- great mana potion
{id = 239, chance = 3100, maxCount = 5}, -- great health potion
{id = 281, chance = 3000, maxCount = 5}, -- giant shimmering pearl (green)
{id = 282, chance = 3000, maxCount = 5}, -- giant shimmering pearl (brown)
{id = 7642, chance = 3100, maxCount = 5}, -- great spirit potion
{id = 7643, chance = 3000, maxCount = 5}, -- ultimate health potion
{id = 9057, chance = 3000, maxCount = 8} -- small topaz
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = -1400, maxDamage = -2300},
{name ="combat", interval = 2000, chance = 20, type = COMBAT_DEATHDAMAGE, minDamage = -500, maxDamage = -900, radius = 4, effect = CONST_ME_SMALLCLOUDS, target = false},
{name ="combat", interval = 2000, chance = 20, type = COMBAT_DEATHDAMAGE, minDamage = -500, maxDamage = -900, range = 4, radius = 4, shootEffect = CONST_ANI_SUDDENDEATH, effect = CONST_ME_POFF, target = true},
{name ="combat", interval = 2000, chance = 20, type = COMBAT_LIFEDRAIN, minDamage = -1000, maxDamage = -1200, length = 10, spread = 3, effect = CONST_ME_MAGIC_GREEN, target = false},
{name ="combat", interval = 2000, chance = 20, type = COMBAT_PHYSICALDAMAGE, minDamage = -1500, maxDamage = -1900, length = 10, spread = 3, effect = CONST_ME_GROUNDSHAKER, target = false},
{name ="speed", interval = 2000, chance = 20, speedChange = -600, radius = 7, effect = CONST_ME_POFF, target = false, duration = 20000}
}
monster.defenses = {
defense = 25,
armor = 25,
{name ="combat", interval = 2000, chance = 10, type = COMBAT_HEALING, minDamage = 1000, maxDamage = 2000, effect = CONST_ME_MAGIC_BLUE, target = false},
{name ="speed", interval = 2000, chance = 20, speedChange = 600, effect = CONST_ME_MAGIC_GREEN, target = false, duration = 4000},
{name ="ragiaz transform", interval = 2000, chance = 8, target = false}
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 10},
{type = COMBAT_ENERGYDAMAGE, percent = 10},
{type = COMBAT_EARTHDAMAGE, percent = 10},
{type = COMBAT_FIREDAMAGE, percent = 10},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 10},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 30}
}
monster.immunities = {
{type = "paralyze", condition = true},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType.onThink = function(monster, interval)
end
mType.onAppear = function(monster, creature)
if monster:getType():isRewardBoss() then
monster:setReward(true)
end
end
mType.onDisappear = function(monster, creature)
end
mType.onMove = function(monster, creature, fromPosition, toPosition)
end
mType.onSay = function(monster, creature, type, message)
end
mType:register(monster)
| gpl-2.0 |
dani-sj/komyl | plugins/arabic_lock.lua | 30 | 1090 |
antiarabic = {}-- An empty table for solving multiple kicking problem
do
local function run(msg, matches)
if is_momod(msg) then -- Ignore mods,owner,admins
return
end
local data = load_data(_config.moderation.data)
if data[tostring(msg.to.id)]['settings']['lock_arabic'] then
if data[tostring(msg.to.id)]['settings']['lock_arabic'] == 'yes' then
if antiarabic[msg.from.id] == true then
return
end
send_large_msg("chat#id".. msg.to.id , "چت ممنوع بود بای")
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] kicked (arabic was locked) ")
chat_del_user('chat#id'..msg.to.id,'user#id'..msg.from.id,ok_cb,false)
antiarabic[msg.from.id] = true
return
end
end
return
end
local function cron()
antiarabic = {} -- Clear antiarabic table
end
return {
patterns = {
"([\216-\219][\128-\191])"
},
run = run,
cron = cron
}
end
--Copyright; @behroozyaghi
--Persian Translate; @behroozyaghi
--ch : @nod32team
--کپی بدون ذکر منبع حرام است
| gpl-2.0 |
black123456789/man | plugins/boobs.lua | 90 | 1731 | do
-- Recursive function
local function getRandomButts(attempt)
attempt = attempt or 0
attempt = attempt + 1
local res,status = http.request("http://api.obutts.ru/noise/1")
if status ~= 200 then return nil end
local data = json:decode(res)[1]
-- The OpenBoobs API sometimes returns an empty array
if not data and attempt <= 3 then
print('Cannot get that butts, trying another one...')
return getRandomButts(attempt)
end
return 'http://media.obutts.ru/' .. data.preview
end
local function getRandomBoobs(attempt)
attempt = attempt or 0
attempt = attempt + 1
local res,status = http.request("http://api.oboobs.ru/noise/1")
if status ~= 200 then return nil end
local data = json:decode(res)[1]
-- The OpenBoobs API sometimes returns an empty array
if not data and attempt < 10 then
print('Cannot get that boobs, trying another one...')
return getRandomBoobs(attempt)
end
return 'http://media.oboobs.ru/' .. data.preview
end
local function run(msg, matches)
local url = nil
if matches[1] == "!boobs" then
url = getRandomBoobs()
end
if matches[1] == "!butts" then
url = getRandomButts()
end
if url ~= nil then
local receiver = get_receiver(msg)
send_photo_from_url(receiver, url)
else
return 'Error getting boobs/butts for you, please try again later.'
end
end
return {
description = "Gets a random boobs or butts pic",
usage = {
"!boobs: Get a boobs NSFW image. 🔞",
"!butts: Get a butts NSFW image. 🔞"
},
patterns = {
"^!boobs$",
"^!butts$"
},
run = run
}
end
--Copyright; @behroozyaghi
--Persian Translate; @behroozyaghi
--ch : @nod32team
--کپی بدون ذکر منبع حرام است
| gpl-2.0 |
junkblocker/hammerspoon | extensions/window/init.lua | 7 | 37790 | --- === hs.window ===
---
--- Inspect/manipulate windows
---
--- Notes:
--- * See `hs.screen` and `hs.geometry` for more information on how Hammerspoon uses window/screen frames and coordinates
local uielement = hs.uielement -- Make sure parent module loads
local window = require "hs.window.internal"
local application = require "hs.application"
local geometry = require "hs.geometry"
local gtype=geometry.type
local screen = require "hs.screen"
local timer = require "hs.timer"
local image=require "hs.image" -- make sure we know about HSImage userdata type
local pairs,ipairs,next,min,max,abs,cos,type = pairs,ipairs,next,math.min,math.max,math.abs,math.cos,type
local tinsert,tremove,tsort,tunpack,tpack = table.insert,table.remove,table.sort,table.unpack,table.pack
--- hs.window.animationDuration (number)
--- Variable
--- The default duration for animations, in seconds. Initial value is 0.2; set to 0 to disable animations.
---
--- Usage:
--- ```
--- hs.window.animationDuration = 0 -- disable animations
--- hs.window.animationDuration = 3 -- if you have time on your hands
--- ```
window.animationDuration = 0.2
--- hs.window.desktop() -> hs.window object
--- Function
--- Returns the desktop "window"
---
--- Parameters:
--- * None
---
--- Returns:
--- * An `hs.window` object representing the desktop
---
--- Notes:
--- * The desktop belongs to Finder.app: when Finder is the active application, you can focus the desktop by cycling
--- through windows via cmd-`
--- * The desktop window has no id, a role of `AXScrollArea` and no subrole
--- * The desktop is filtered out from `hs.window.allWindows()` (and downstream uses)
function window.desktop()
local finder=application.get'com.apple.finder'
for _,w in ipairs(finder:allWindows()) do if w:role()=='AXScrollArea' then return w end end
end
--- hs.window.allWindows() -> list of hs.window objects
--- Function
--- Returns all windows
---
--- Parameters:
--- * None
---
--- Returns:
--- * A list of `hs.window` objects representing all open windows
---
--- Notes:
--- * `visibleWindows()`, `orderedWindows()`, `get()`, `find()`, and several more functions and methods in this and other
--- modules make use of this function, so it is important to understand its limitations
--- * This function queries all applications for their windows every time it is invoked; if you need to call it a lot and
--- performance is not acceptable consider using the `hs.window.filter` module
--- * This function can only return windows in the current Mission Control Space; if you need to address windows across
--- different Spaces you can use the `hs.window.filter` module
--- - if `Displays have separate Spaces` is *on* (in System Preferences>Mission Control) the current Space is defined
--- as the union of all currently visible Spaces
--- - minimized windows and hidden windows (i.e. belonging to hidden apps, e.g. via cmd-h) are always considered
--- to be in the current Space
--- * This function filters out the desktop "window"; use `hs.window.desktop()` to address it. (Note however that
--- `hs.application.get'Finder':allWindows()` *will* include the desktop in the returned list)
--- * Beside the limitations discussed above, this function will return *all* windows as reported by OSX, including some
--- "windows" that one wouldn't expect: for example, every Google Chrome (actual) window has a companion window for its
--- status bar; therefore you might get unexpected results - in the Chrome example, calling `hs.window.focusWindowSouth()`
--- from a Chrome window would end up "focusing" its status bar, and therefore the proper window itself, seemingly resulting
--- in a no-op. In order to avoid such surprises you can use the `hs.window.filter` module, and more specifically
--- the default windowfilter (`hs.window.filter.default`) which filters out known cases of not-actual-windows
local SKIP_APPS={
['com.apple.WebKit.WebContent']=true,['com.apple.qtserver']=true,['com.google.Chrome.helper']=true,
['org.pqrs.Karabiner-AXNotifier']=true,['com.adobe.PDApp.AAMUpdatesNotifier']=true,
['com.adobe.csi.CS5.5ServiceManager']=true}
-- so apparently OSX enforces a 6s limit on apps to respond to AX queries;
-- Karabiner's AXNotifier and Adobe Update Notifier fail in that fashion
function window.allWindows()
local r={}
for _,app in ipairs(application.runningApplications()) do
if app:kind()>=0 then
local bid=app:bundleID() or 'N/A' --just for safety; universalaccessd has no bundleid (but it's kind()==-1 anyway)
if bid=='com.apple.finder' then --exclude the desktop "window"
-- check the role explicitly, instead of relying on absent :id() - sometimes minimized windows have no :id() (El Cap Notes.app)
for _,w in ipairs(app:allWindows()) do if w:role()=='AXWindow' then r[#r+1]=w end end
elseif not SKIP_APPS[bid] then for _,w in ipairs(app:allWindows()) do r[#r+1]=w end end
end
end
return r
end
function window._timed_allWindows()
local r={}
for _,app in ipairs(application.runningApplications()) do
local starttime=timer.secondsSinceEpoch()
local _,bid=app:allWindows(),app:bundleID() or 'N/A'
r[bid]=(r[bid] or 0) + timer.secondsSinceEpoch()-starttime
end
for app,time in pairs(r) do
if time>0.05 then print(string.format('took %.2fs for %s',time,app)) end
end
-- print('known exclusions:') print(hs.inspect(SKIP_APPS))
return r
end
--- hs.window.visibleWindows() -> list of hs.window objects
--- Function
--- Gets all visible windows
---
--- Parameters:
--- * None
---
--- Returns:
--- * A list containing `hs.window` objects representing all windows that are visible as per `hs.window:isVisible()`
function window.visibleWindows()
local r={}
for _,app in ipairs(application.runningApplications()) do
if app:kind()>0 and not app:isHidden() then for _,w in ipairs(app:visibleWindows()) do r[#r+1]=w end end -- speedup by excluding hidden apps
end
return r
end
--- hs.window.orderedWindows() -> list of hs.window objects
--- Function
--- Returns all visible windows, ordered from front to back
---
--- Parameters:
--- * None
---
--- Returns:
--- * A list of `hs.window` objects representing all visible windows, ordered from front to back
function window.orderedWindows()
local r,winset,ids = {},{},window._orderedwinids()
for _,w in ipairs(window.visibleWindows()) do winset[w:id()or -1]=w end
for _,id in ipairs(ids) do r[#r+1]=winset[id] end -- no inner loop with a set, seems about 5% faster (iterating with prepoluated tables it's 50x faster)
return r
end
--- hs.window.get(hint) -> hs.window object
--- Constructor
--- Gets a specific window
---
--- Parameters:
--- * hint - search criterion for the desired window; it can be:
--- - an id number as per `hs.window:id()`
--- - a window title string as per `hs.window:title()`
---
--- Returns:
--- * the first hs.window object that matches the supplied search criterion, or `nil` if not found
---
--- Notes:
--- * see also `hs.window.find` and `hs.application:getWindow()`
function window.get(hint)
return tpack(window.find(hint,true),nil)[1] -- just to be sure, discard extra results
end
window.windowForID=window.get
--- hs.window.find(hint) -> hs.window object(s)
--- Constructor
--- Finds windows
---
--- Parameters:
--- * hint - search criterion for the desired window(s); it can be:
--- - an id number as per `hs.window:id()`
--- - a string pattern that matches (via `string.find`) the window title as per `hs.window:title()` (for convenience, the matching will be done on lowercased strings)
---
--- Returns:
--- * one or more hs.window objects that match the supplied search criterion, or `nil` if none found
---
--- Notes:
--- * for convenience you can call this as `hs.window(hint)`
--- * see also `hs.window.get`
--- * for more sophisticated use cases and/or for better performance if you call this a lot, consider using `hs.window.filter`
---
--- Usage:
--- ```
--- -- by id
--- hs.window(8812):title() --> Hammerspoon Console
--- -- by title
--- hs.window'bash':application():name() --> Terminal
--- ```
function window.find(hint,exact,wins)
if hint==nil then return end
local typ,r=type(hint),{}
wins=wins or window.allWindows()
if typ=='number' then for _,w in ipairs(wins) do if w:id()==hint then return w end end return
elseif typ~='string' then error('hint must be a number or string',2) end
if exact then for _,w in ipairs(wins) do if w:title()==hint then r[#r+1]=w end end
else hint=hint:lower() for _,w in ipairs(wins) do local wtitle=w:title() if wtitle and wtitle:lower():find(hint) then r[#r+1]=w end end end
if #r>0 then return tunpack(r) end
end
--- hs.window:isVisible() -> boolean
--- Method
--- Determines if a window is visible (i.e. not hidden and not minimized)
---
--- Parameters:
--- * None
---
--- Returns:
--- * `true` if the window is visible, otherwise `false`
---
--- Notes:
--- * This does not mean the user can see the window - it may be obscured by other windows, or it may be off the edge of the screen
function window:isVisible()
return not self:application():isHidden() and not self:isMinimized()
end
local animations, animTimer = {}
local DISTANT_FUTURE=315360000 -- 10 years (roughly)
--[[ local function quad(x,s,len)
local l=max(0,min(2,(x-s)*2/len))
if l<1 then return l*l/2
else l=2-l return 1-(l*l/2) end
end --]]
local function quadOut(x,s,len)
local l=1-max(0,min(1,(x-s)/len))
return 1-l*l
end
local function animate()
local time = timer.secondsSinceEpoch()
for id,anim in pairs(animations) do
local r = quadOut(time,anim.time,anim.duration)
local f = {}
if r>=1 then
f=anim.endFrame
animations[id] = nil
else
for _,k in pairs{'x','y','w','h'} do
f[k] = anim.startFrame[k] + (anim.endFrame[k]-anim.startFrame[k])*r
end
end
anim.window:_setFrame(f)
end
if not next(animations) then animTimer:setNextTrigger(DISTANT_FUTURE) end
end
animTimer = timer.new(0.017,animate)
animTimer:start() --keep this split
local function getAnimationFrame(win)
local id = win:id()
if animations[id] then return animations[id].endFrame end
end
local function stopAnimation(win,snap,id)
if not id then id = win:id() end
local anim = animations[id]
if not anim then return end
animations[id] = nil
if not next(animations) then animTimer:setNextTrigger(DISTANT_FUTURE) end
if snap then win:_setFrame(anim.endFrame) end
end
function window:_frame() -- get actual window frame right now
return geometry(self:_topLeft(),self:_size())
end
function window:_setFrame(f) -- set window frame instantly
self:_setSize(f) self:_setTopLeft(f) return self:_setSize(f)
end
local function setFrameAnimated(self,id,f,duration)
local frame = self:_frame()
if not animations[id] then animations[id] = {window=self} end
local anim = animations[id]
anim.time=timer.secondsSinceEpoch() anim.duration=duration
anim.startFrame=frame anim.endFrame=f
animTimer:setNextTrigger(0.01)
return self
end
local function setFrameWithWorkarounds(self,f,duration)
local originalFrame=geometry(self:_frame())
local safeBounds=self:screen():frame()
if duration>0 then -- if no animation, skip checking for possible trouble
if not originalFrame:inside(safeBounds) then duration=0 -- window straddling screens or partially offscreen
else
local testSize=geometry.size(originalFrame.w-1,originalFrame.h-1)
self:_setSize(testSize)
-- find out if it's a terminal, or a window already shrunk to minimum, or a window on a 'sticky' edge
local newSize=self:_size()
if originalFrame.size==newSize -- terminal or minimum size
or (testSize~=newSize and (abs(f.x2-originalFrame.x2)<100 or abs(f.y2-originalFrame.y2)<100)) then --sticky edge, and not going far enough
duration=0 end -- don't animate troublesome windows
end
end
local safeFrame=geometry.new(originalFrame.xy,f.size) --apply the desired size
safeBounds:move(30,30) -- offset
safeBounds.w=safeBounds.w-60 safeBounds.h=safeBounds.h-60 -- and shrink
self:_setFrame(safeFrame:fit(safeBounds)) -- put it within a 'safe' area in the current screen, and insta-resize
local actualSize=geometry(self:_size()) -- get the *actual* size the window resized to
if actualSize.area>f.area then f.size=actualSize end -- if it's bigger apply it
if duration==0 then
self:_setSize(f.size) -- apply the final size while the window is still in the safe area
self:_setTopLeft(f)
return self:_setSize(f.size)
end
self:_setFrame(originalFrame) -- restore the original frame and start the animation
return setFrameAnimated(self,self:id(),f,duration)
end
local function setFrame(self,f,duration,workarounds)
if duration==nil then duration = window.animationDuration end
if type(duration)~='number' then duration=0 end
f=geometry(f):floor()
if gtype(f)~='rect' then error('invalid rect: '..f.string,3) end
local id=self:id()
if id then stopAnimation(self,false,id) else duration=0 end
if workarounds then return setFrameWithWorkarounds(self,f,duration)
elseif duration<=0 then return self:_setFrame(f)
else return setFrameAnimated(self,id,f,duration) end
end
--- hs.window:setFrame(rect[, duration]) -> hs.window object
--- Method
--- Sets the frame of the window in absolute coordinates
---
--- Parameters:
--- * rect - An hs.geometry rect, or constructor argument, describing the frame to be applied to the window
--- * duration - (optional) The number of seconds to animate the transition. Defaults to the value of `hs.window.animationDuration`
---
--- Returns:
--- * The `hs.window` object
function window:setFrame(f, duration) return setFrame(self,f,duration,window.setFrameCorrectness) end
--- hs.window:setFrameWithWorkarounds(rect[, duration]) -> hs.window object
--- Method
--- Sets the frame of the window in absolute coordinates, using the additional workarounds described in `hs.window.setFrameCorrectness`
---
--- Parameters:
--- * rect - An hs.geometry rect, or constructor argument, describing the frame to be applied to the window
--- * duration - (optional) The number of seconds to animate the transition. Defaults to the value of `hs.window.animationDuration`
---
--- Returns:
--- * The `hs.window` object
function window:setFrameWithWorkarounds(f, duration) return setFrame(self,f,duration,true) end
--- hs.window.setFrameCorrectness
--- Variable
--- Using `hs.window:setFrame()` in some cases does not work as expected: namely, the bottom (or Dock) edge, and edges between screens, might
--- exhibit some "stickiness"; consequently, trying to make a window abutting one of those edges just *slightly* smaller could
--- result in no change at all (you can verify this by trying to resize such a window with the mouse: at first it won't budge,
--- and, as you drag further away, suddenly snap to the new size); and similarly in some cases windows along screen edges
--- might erroneously end up partially on the adjacent screen after a move/resize. Additionally some windows (no matter
--- their placement on screen) only allow being resized at "discrete" steps of several screen points; the typical example
--- is Terminal windows, which only resize to whole rows and columns. Both these OSX issues can cause incorrect behavior
--- when using `:setFrame()` directly or in downstream uses, such as `hs.window:move()` and the `hs.grid` and `hs.window.layout` modules.
---
--- Setting this variable to `true` will make `:setFrame()` perform additional checks and workarounds for these potential
--- issues. However, as a side effect the window might appear to jump around briefly before setting toward its destination
--- frame, and, in some cases, the move/resize animation (if requested) might be skipped entirely - these tradeoffs are
--- necessary to ensure the desired result.
---
--- The default value is `false`, in order to avoid the possibly annoying or distracting window wiggling; set to `true` if you see
--- incorrect results in `:setFrame()` or downstream modules and don't mind the the wiggling.
window.setFrameCorrectness = false
--- hs.window:setFrameInScreenBounds([rect][, duration]) -> hs.window object
--- Method
--- Sets the frame of the window in absolute coordinates, possibly adjusted to ensure it is fully inside the screen
---
--- Parameters:
--- * rect - An hs.geometry rect, or constructor argument, describing the frame to be applied to the window; if omitted,
--- the current window frame will be used
--- * duration - (optional) The number of seconds to animate the transition. Defaults to the value of `hs.window.animationDuration`
---
--- Returns:
--- * The `hs.window` object
function window:setFrameInScreenBounds(f, duration)
if type(f)=='number' then duration=f f=nil end
f = f and geometry(f):floor() or self:frame()
return self:setFrame(f:fit(screen.find(f):frame()),duration)
end
window.ensureIsInScreenBounds=window.setFrameInScreenBounds --backward compatible
--- hs.window:frame() -> hs.geometry rect
--- Method
--- Gets the frame of the window in absolute coordinates
---
--- Parameters:
--- * None
---
--- Returns:
--- * An hs.geometry rect containing the co-ordinates of the top left corner of the window and its width and height
function window:frame() return getAnimationFrame(self) or self:_frame() end
-- wrapping these Lua-side for dealing with animations cache
function window:size()
local f=getAnimationFrame(self)
return f and f.size or geometry(self:_size())
end
function window:topLeft()
local f=getAnimationFrame(self)
return f and f.xy or geometry(self:_topLeft())
end
function window:setSize(...)
stopAnimation(self,true)
return self:_setSize(geometry.size(...))
end
function window:setTopLeft(...)
stopAnimation(self,true)
return self:_setTopLeft(geometry.point(...))
end
function window:minimize()
stopAnimation(self,true)
return self:_minimize()
end
function window:unminimize()
stopAnimation(self,true)
return self:_unminimize()
end
function window:toggleZoom()
stopAnimation(self,true)
return self:_toggleZoom()
end
function window:setFullScreen(v)
stopAnimation(self,true)
return self:_setFullScreen(v)
end
function window:close()
stopAnimation(self,true)
return self:_close()
end
--- hs.window:otherWindowsSameScreen() -> list of hs.window objects
--- Method
--- Gets other windows on the same screen
---
--- Parameters:
--- * None
---
--- Returns:
--- * A table of `hs.window` objects representing the visible windows other than this one that are on the same screen
function window:otherWindowsSameScreen()
local r=window.visibleWindows() for i=#r,1,-1 do if r[i]==self or r[i]:screen()~=self:screen() then tremove(r,i) end end
return r
end
--- hs.window:otherWindowsAllScreens() -> list of hs.window objects
--- Method
--- Gets every window except this one
---
--- Parameters:
--- * None
---
--- Returns:
--- * A table containing `hs.window` objects representing all visible windows other than this one
function window:otherWindowsAllScreens()
local r=window.visibleWindows() for i=#r,1,-1 do if r[i]==self then tremove(r,i) break end end
return r
end
local desktopFocusWorkaroundTimer --workaround for the desktop taking over
--- hs.window:focus() -> hs.window object
--- Method
--- Focuses the window
---
--- Parameters:
--- * None
---
--- Returns:
--- * The `hs.window` object
function window:focus()
local app=self:application()
self:becomeMain()
app:_bringtofront()
if app:bundleID()=='com.apple.finder' then --workaround for the desktop taking over
-- it may look like this should ideally go inside :becomeMain(), but the problem is actually
-- triggered by :_bringtofront(), so the workaround belongs here
if desktopFocusWorkaroundTimer then desktopFocusWorkaroundTimer:stop() end
desktopFocusWorkaroundTimer=timer.doAfter(0.3,function()
-- 0.3s comes from https://github.com/Hammerspoon/hammerspoon/issues/581
-- it'd be slightly less ugly to use a "space change completed" callback (as per issue above) rather than
-- a crude timer, althought that route is a lot more complicated
self:becomeMain()
desktopFocusWorkaroundTimer=nil --cleanup the timer
end)
self:becomeMain() --ensure space change actually takes place when necessary
end
return self
end
--- hs.window:sendToBack() -> hs.window object
--- Method
--- Sends the window to the back
---
--- This method works by focusing all overlapping windows behind this one, front to back.
--- If called on the focused window, this method will switch focus to the topmost window under this one; otherwise, the
--- currently focused window will regain focus after this window has been sent to the back.
---
--- Parameters:
--- * None
---
--- Returns:
--- * The `hs.window` object
---
--- Notes:
--- * Due to the way this method works and OSX limitations, calling this method when you have a lot of randomly overlapping
--- (as opposed to neatly tiled) windows might be visually jarring, and take a fair amount of time to complete.
--- So if you don't use orderly layouts, or if you have a lot of windows in general, you're probably better off using
--- `hs.application:hide()` (or simply `cmd-h`)
local WINDOW_ROLES={AXStandardWindow=true,AXDialog=true,AXSystemDialog=true}
function window:sendToBack()
local id,frame=self:id(),self:frame()
local fw=window.focusedWindow()
local wins=window.orderedWindows()
for z=#wins,1,-1 do local w=wins[z] if id==w:id() or not WINDOW_ROLES[w:subrole()] then tremove(wins,z) end end
local toRaise,topz,didwork={}
repeat
for z=#wins,1,-1 do
didwork=nil
local wf=wins[z]:frame()
if frame:intersect(wf).area>0 then
topz=z
if not toRaise[z] then
didwork=true
toRaise[z]=true
frame=frame:union(wf) break
end
end
end
until not didwork
if topz then
for z=#wins,1,-1 do if toRaise[z] then wins[z]:focus() timer.usleep(80000) end end
wins[topz]:focus()
if fw and fw:id()~=id then fw:focus() end
end
return self
end
--- hs.window:maximize([duration]) -> hs.window object
--- Method
--- Maximizes the window
---
--- Parameters:
--- * duration - (optional) The number of seconds to animate the transition. Defaults to the value of `hs.window.animationDuration`
---
--- Returns:
--- * The `hs.window` object
---
--- Notes:
--- * The window will be resized as large as possible, without obscuring the dock/menu
function window:maximize(duration)
return self:setFrame(self:screen():frame(), duration)
end
--- hs.window:toggleFullScreen() -> hs.window object
--- Method
--- Toggles the fullscreen state of the window
---
--- Parameters:
--- * None
---
--- Returns:
--- * The `hs.window` object
---
--- Notes:
--- * Not all windows support being full-screened
function window:toggleFullScreen()
self:setFullScreen(not self:isFullScreen())
return self
end
-- aliases
window.toggleFullscreen=window.toggleFullScreen
window.isFullscreen=window.isFullScreen
window.setFullscreen=window.setFullScreen
--- hs.window:screen() -> hs.screen object
--- Method
--- Gets the screen which the window is on
---
--- Parameters:
--- * None
---
--- Returns:
--- * An `hs.screen` object representing the screen which most contains the window (by area)
function window:screen()
return screen.find(self:frame())--findScreenForFrame(self:frame())
end
local function isFullyBehind(f1,w2)
local f2=geometry(w2:frame())
return f1:intersect(f2).area>=f2.area*0.95
end
local function windowsInDirection(fromWindow, numRotations, candidateWindows, frontmost, strict)
-- assume looking to east
-- use the score distance/cos(A/2), where A is the angle by which it
-- differs from the straight line in the direction you're looking
-- for. (may have to manually prevent division by zero.)
local fromFrame=geometry(fromWindow:frame())
local winset,fromz,fromid={},99999,fromWindow:id() or -1
for z,w in ipairs(candidateWindows or window.orderedWindows()) do
if fromid==(w:id() or -2) then fromWindow=w fromz=z --workaround the fact that userdata keep changing
elseif not candidateWindows or w:isVisible() then winset[w]=z end --make a set, avoid inner loop (if using .orderedWindows skip the visible check as it's done upstream)
end
if frontmost then for w,z in pairs(winset) do if z>fromz and isFullyBehind(fromFrame,w) then winset[w]=nil end end end
local p1,wins=fromFrame.center,{}
for win,z in pairs(winset) do
local frame=geometry(win:frame())
local delta = p1:vector(frame.center:rotateCCW(p1,numRotations))
if delta.x > (strict and abs(delta.y) or 0) then
wins[#wins+1]={win=win,score=delta.length/cos(delta:angle()/2)+z,z=z,frame=frame}
end
end
tsort(wins,function(a,b)return a.score<b.score end)
if frontmost then
local i=1
while i<=#wins do
for j=i+1,#wins do
if wins[j].z<wins[i].z then
local r=wins[i].frame:intersect(wins[j].frame)
if r.w>5 and r.h>5 then --TODO var for threshold
--this window is further away, but it occludes the closest
local swap=wins[i] wins[i]=wins[j] wins[j]=swap
i=i-1 break
end
end
end
i=i+1
end
end
for i=1,#wins do wins[i]=wins[i].win end
return wins
end
--TODO zorder direct manipulation (e.g. sendtoback)
local function focus_first_valid_window(ordered_wins)
for _,win in ipairs(ordered_wins) do if win:focus() then return true end end
return false
end
--- hs.window:windowsToEast([candidateWindows[, frontmost[, strict]]]) -> list of hs.window objects
--- Method
--- Gets all windows to the east of this window
---
--- Parameters:
--- * candidateWindows - (optional) a list of candidate windows to consider; if nil, all visible windows
--- to the east are candidates.
--- * frontmost - (optional) boolean, if true unoccluded windows will be placed before occluded ones in the result list
--- * strict - (optional) boolean, if true only consider windows at an angle between 45° and -45° on the
--- eastward axis
---
--- Returns:
--- * A list of `hs.window` objects representing all windows positioned east (i.e. right) of the window, in ascending order of distance
---
--- Notes:
--- * If you don't pass `candidateWindows`, Hammerspoon will query for the list of all visible windows
--- every time this method is called; this can be slow, and some undesired "windows" could be included
--- (see the notes for `hs.window.allWindows()`); consider using the equivalent methods in
--- `hs.window.filter` instead
--- hs.window:windowsToWest([candidateWindows[, frontmost[, strict]]]) -> list of hs.window objects
--- Method
--- Gets all windows to the west of this window
---
--- (See `hs.window:windowsToEast()`)
--- hs.window:windowsToNorth([candidateWindows[, frontmost[, strict]]]) -> list of hs.window objects
--- Method
--- Gets all windows to the north of this window
---
--- (See `hs.window:windowsToEast()`)
--- hs.window:windowsToSouth([candidateWindows[, frontmost[, strict]]]) -> list of hs.window objects
--- Method
--- Gets all windows to the south of this window
---
--- (See `hs.window:windowsToEast()`)
--- hs.window.frontmostWindow() -> hs.window object
--- Constructor
--- Returns the focused window or, if no window has focus, the frontmost one
---
--- Parameters:
--- * None
---
--- Returns:
--- * An `hs.window` object representing the frontmost window, or `nil` if there are no visible windows
function window.frontmostWindow()
local w=window.focusedWindow()
if w then return w end
for _,w in ipairs(window.orderedWindows()) do
local app=w:application()
if (app and app:title()~='Hammerspoon') or w:subrole()~='AXUnknown' then return w end
end
end
for n,dir in pairs{['0']='East','North','West','South'}do
window['windowsTo'..dir]=function(self,...)
self=self or window.frontmostWindow()
return self and windowsInDirection(self,n,...)
end
window['focusWindow'..dir]=function(self,wins,...)
self=self or window.frontmostWindow()
if not self then return end
if wins==true then -- legacy sameApp parameter
wins=self:application():visibleWindows()
end
return self and focus_first_valid_window(window['windowsTo'..dir](self,wins,...))
end
window['moveOneScreen'..dir]=function(self,...) local s=self:screen() return self:moveToScreen(s['to'..dir](s),...) end
end
--- hs.window:focusWindowEast([candidateWindows[, frontmost[, strict]]]) -> boolean
--- Method
--- Focuses the nearest possible window to the east (i.e. right)
---
--- Parameters:
--- * candidateWindows - (optional) a list of candidate windows to consider; if nil, all visible windows
--- to the east are candidates.
--- * frontmost - (optional) boolean, if true focuses the nearest window that isn't occluded by any other window
--- * strict - (optional) boolean, if true only consider windows at an angle between 45° and -45° on the
--- eastward axis
---
--- Returns:
--- * `true` if a window was found and focused, `false` otherwise; `nil` if the search couldn't take place
---
--- Notes:
--- * If you don't pass `candidateWindows`, Hammerspoon will query for the list of all visible windows
--- every time this method is called; this can be slow, and some undesired "windows" could be included
--- (see the notes for `hs.window.allWindows()`); consider using the equivalent methods in
--- `hs.window.filter` instead
--- hs.window:focusWindowWest([candidateWindows[, frontmost[, strict]]]) -> boolean
--- Method
--- Focuses the nearest possible window to the west (i.e. right)
---
--- (See `hs.window:focusWindowEast()`)
--- hs.window:focusWindowNorth([candidateWindows[, frontmost[, strict]]]) -> boolean
--- Method
--- Focuses the nearest possible window to the north (i.e. up)
---
--- (See `hs.window:focusWindowEast()`)
--- hs.window:focusWindowSouth([candidateWindows[, frontmost[, strict]]]) -> boolean
--- Method
--- Focuses the nearest possible window to the south (i.e. down)
---
--- (See `hs.window:focusWindowEast()`)
--- hs.window:centerOnScreen([screen][, ensureInScreenBounds][, duration]) --> hs.window object
--- Method
--- Centers the window on a screen
---
--- Parameters:
--- * screen - (optional) An `hs.screen` object or argument for `hs.screen.find`; if nil, use the screen the window is currently on
--- * ensureInScreenBounds - (optional) if `true`, use `setFrameInScreenBounds()` to ensure the resulting window frame is fully contained within
--- the window's screen
--- * duration - (optional) The number of seconds to animate the transition. Defaults to the value of `hs.window.animationDuration`
---
--- Returns:
--- * The `hs.window` object
function window:centerOnScreen(toScreen,inBounds,duration)
if type(toScreen)=='boolean' then duration=inBounds inBounds=toScreen toScreen=nil
elseif type(toScreen)=='number' then duration=toScreen inBounds=nil toScreen=nil end
if type(inBounds)=='number' then duration=inBounds inBounds=nil end
toScreen=screen.find(toScreen) or self:screen()
local sf,wf=toScreen:fullFrame(),self:frame()
local frame=geometry(toScreen:localToAbsolute((geometry(sf.w,sf.h)-geometry(wf.w,wf.h))*0.5),wf.size)
if inBounds then return self:setFrameInScreenBounds(frame,duration)
else return self:setFrame(frame,duration) end
end
--- hs.window:moveToUnit(unitrect[, duration]) -> hs.window object
--- Method
--- Moves and resizes the window to occupy a given fraction of the screen
---
--- Parameters:
--- * unitrect - An `hs.geometry` unit rect, or constructor argument to create one
--- * duration - (optional) The number of seconds to animate the transition. Defaults to the value of `hs.window.animationDuration`
---
--- Returns:
--- * The `hs.window` object
---
--- Notes:
--- * An example, which would make a window fill the top-left quarter of the screen: `win:moveToUnit'[0,0,50,50]'`
function window:moveToUnit(unit, duration)
return self:setFrame(self:screen():fromUnitRect(unit),duration)
end
--- hs.window:moveToScreen(screen[, noResize, ensureInScreenBounds][, duration]) -> hs.window object
--- Method
--- Moves the window to a given screen, retaining its relative position and size
---
--- Parameters:
--- * screen - An `hs.screen` object, or an argument for `hs.screen.find()`, representing the screen to move the window to
--- * noResize - (optional) if `true`, maintain the window's absolute size
--- * ensureInScreenBounds - (optional) if `true`, use `setFrameInScreenBounds()` to ensure the resulting window frame is fully contained within
--- the window's screen
--- * duration - (optional) The number of seconds to animate the transition. Defaults to the value of `hs.window.animationDuration`
---
--- Returns:
--- * The `hs.window` object
function window:moveToScreen(toScreen,noResize,inBounds,duration)
if not toScreen then return end
local theScreen=screen.find(toScreen)
if not theScreen then print('window:moveToScreen(): screen not found: '..toScreen) return self end
if type(noResize)=='number' then duration=noResize noResize=nil inBounds=nil end
local frame=theScreen:fromUnitRect(self:screen():toUnitRect(self:frame()))
if noResize then frame.size=self:size() end
-- local frame=theScreen:localToAbsolute(self:screen():absoluteToLocal(self:frame()))
if inBounds then return self:setFrameInScreenBounds(frame,duration)
else return self:setFrame(frame,duration) end
-- else return self:setFrame(theScreen:fromUnitRect(self:screen():toUnitRect(self:frame())),duration) end
end
--- hs.window:move(rect[, screen][, ensureInScreenBounds][, duration]) --> hs.window object
--- Method
--- Moves the window
---
--- Parameters:
--- * rect - It can be:
--- - an `hs.geometry` point, or argument to construct one; will move the screen by this delta, keeping its size constant; `screen` is ignored
--- - an `hs.geometry` rect, or argument to construct one; will set the window frame to this rect, in absolute coordinates; `screen` is ignored
--- - an `hs.geometry` unit rect, or argument to construct one; will set the window frame to this rect relative to the desired screen;
--- if `screen` is nil, use the screen the window is currently on
--- * screen - (optional) An `hs.screen` object or argument for `hs.screen.find`; only valid if `rect` is a unit rect
--- * ensureInScreenBounds - (optional) if `true`, use `setFrameInScreenBounds()` to ensure the resulting window frame is fully contained within
--- the window's screen
--- * duration - (optional) The number of seconds to animate the transition. Defaults to the value of `hs.window.animationDuration`
---
--- Returns:
--- * The `hs.window` object
function window:move(rect,toScreen,inBounds,duration)
if type(toScreen)=='boolean' then duration=inBounds inBounds=toScreen toScreen=nil
elseif type(toScreen)=='number' then duration=toScreen inBounds=nil toScreen=nil end
if type(inBounds)=='number' then duration=inBounds inBounds=nil end
rect=geometry(rect)
local rtype,frame=rect:type()
if rtype=='point' then frame=geometry(self:frame()):move(rect)
if type(toScreen)=='number' then inBounds=nil duration=toScreen end
elseif rtype=='rect' then frame=rect
if type(toScreen)=='number' then inBounds=nil duration=toScreen end
elseif rtype=='unitrect' then
local theScreen
if toScreen then
theScreen=screen.find(toScreen)
if not theScreen then print('window:move(): screen not found: '..toScreen) return self end
else theScreen=self:screen() end
frame=rect:fromUnitRect(theScreen:frame())
else error('rect must be a point, rect, or unit rect',2) end
if inBounds then return self:setFrameInScreenBounds(frame,duration)
else return self:setFrame(frame,duration) end
end
--- hs.window:moveOneScreenEast([noResize, ensureInScreenBounds][, duration]) -> hs.window object
--- Method
--- Moves the window one screen east (i.e. right)
---
--- Parameters:
--- * noResize - (optional) if `true`, maintain the window's absolute size
--- * ensureInScreenBounds - (optional) if `true`, use `setFrameInScreenBounds()` to ensure the resulting window frame is fully contained within
--- the window's screen
--- * duration - (optional) The number of seconds to animate the transition. Defaults to the value of `hs.window.animationDuration`
---
--- Returns:
--- * The `hs.window` object
--- hs.window:moveOneScreenWest([noResize, ensureInScreenBounds][, duration]) -> hs.window object
--- Method
--- Moves the window one screen west (i.e. left)
---
--- (See `hs.window:moveOneScreenEast()`)
--- hs.window:moveOneScreenNorth([noResize, ensureInScreenBounds][, duration]) -> hs.window object
--- Method
--- Moves the window one screen north (i.e. up)
---
---
--- (See `hs.window:moveOneScreenEast()`)
--- hs.window:moveOneScreenSouth([noResize, ensureInScreenBounds][, duration]) -> hs.window object
--- Method
--- Moves the window one screen south (i.e. down)
---
---
--- (See `hs.window:moveOneScreenEast()`)
do
local submodules={filter=true,layout=true,tiling=true,switcher=true,highlight=true}
local function loadSubModule(k)
print("-- Loading extensions: window."..k)
window[k]=require('hs.window.'..k)
return window[k]
end
local mt=getmetatable(window)
if mt.__index==uielement then
--inject "lazy loading" for submodules
mt.__index=function(t,k)
if t==window and submodules[k] then return loadSubModule(k)
else return uielement[k] end
end
-- whoever gets it first (window vs application)
if not mt.__call then mt.__call=function(t,...) return t.find(...) end end
end
end
return window
| mit |
CarabusX/Zero-K | LuaUI/Widgets/gfx_deferred_rendering.lua | 7 | 22729 | --------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function widget:GetInfo()
return {
name = "Deferred rendering",
version = 3,
desc = "Collects and renders point and beam lights using HDR and applies bloom.",
author = "beherith, aeonios",
date = "2015 Sept.",
license = "GPL V2",
layer = -99999,
enabled = true
}
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local GL_RGB16F_ARB = 0x881B
local GL_RGB32F_ARB = 0x8815
local GL_RGB8 = 0x8051
local GL_MODELVIEW = GL.MODELVIEW
local GL_NEAREST = GL.NEAREST
local GL_ONE = GL.ONE
local GL_ONE_MINUS_SRC_ALPHA = GL.ONE_MINUS_SRC_ALPHA
local GL_PROJECTION = GL.PROJECTION
local GL_QUADS = GL.QUADS
local GL_SRC_ALPHA = GL.SRC_ALPHA
local glActiveTexture = gl.ActiveTexture
local glBeginEnd = gl.BeginEnd
local glBillboard = gl.Billboard
local glBlending = gl.Blending
local glCallList = gl.CallList
local glClear = gl.Clear
local glColor = gl.Color
local glColorMask = gl.ColorMask
local glCopyToTexture = gl.CopyToTexture
local glCreateList = gl.CreateList
local glCreateShader = gl.CreateShader
local glCreateTexture = gl.CreateTexture
local glDeleteShader = gl.DeleteShader
local glDeleteTexture = gl.DeleteTexture
local glGetMatrixData = gl.GetMatrixData
local glGetShaderLog = gl.GetShaderLog
local glGetUniformLocation = gl.GetUniformLocation
local glGetViewSizes = gl.GetViewSizes
local glLoadIdentity = gl.LoadIdentity
local glLoadMatrix = gl.LoadMatrix
local glMatrixMode = gl.MatrixMode
local glMultiTexCoord = gl.MultiTexCoord
local glOrtho = gl.Ortho
local glPopMatrix = gl.PopMatrix
local glPushMatrix = gl.PushMatrix
local glResetMatrices = gl.ResetMatrices
local glTexCoord = gl.TexCoord
local glTexture = gl.Texture
local glTexRect = gl.TexRect
local glRect = gl.Rect
local glRenderToTexture = gl.RenderToTexture
local glRotate = gl.Rotate
local glUniform = gl.Uniform
local glUniformInt = gl.UniformInt
local glUniformMatrix = gl.UniformMatrix
local glUseShader = gl.UseShader
local glVertex = gl.Vertex
local glTranslate = gl.Translate
local spEcho = Spring.Echo
local spGetCameraPosition = Spring.GetCameraPosition
local spGetCameraVectors = Spring.GetCameraVectors
local spGetDrawFrame = Spring.GetDrawFrame
local spIsSphereInView = Spring.IsSphereInView
local spWorldToScreenCoords = Spring.WorldToScreenCoords
local spTraceScreenRay = Spring.TraceScreenRay
local spGetSmoothMeshHeight = Spring.GetSmoothMeshHeight
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Config
local GLSLRenderer = true
options_path = 'Settings/Graphics/HDR (experimental)'
options_order = {'enableHDR', 'enableBloom', 'illumThreshold', 'maxBrightness'}
options = {
enableHDR = {type = 'bool', name = 'Use High Dynamic Range Color', value = true,},
enableBloom = {type = 'bool', name = 'Apply Bloom Effect (HDR Only)', value = true,},
-- how bright does a fragment need to be before being considered a glow source? [0, 1]
illumThreshold = {type = 'number', name = 'Illumination Threshold', value = 0.85, min = 0, max = 1, step = 0.05,},
-- maximum brightness of bloom additions [1, n]
maxBrightness = {type = 'number', name = 'Maximum Highlight Brightness', value = 0.35, min = 0.05, max = 1, step = 0.05,},
}
for key,option in pairs(options) do
option.OnChange = InitialiseShaders
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local vsx, vsy
local ivsx = 1.0
local ivsy = 1.0
local screenratio = 1.0
local kernelRadius = 32
-- dynamic light shaders
local depthPointShader = nil
local depthBeamShader = nil
-- bloom shaders
local brightShader = nil
local blurShaderH71 = nil
local blurShaderV71 = nil
local combineShader = nil
-- HDR textures
local screenHDR = nil
local brightTexture1 = nil
local brightTexture2 = nil
-- shader uniforms
local lightposlocPoint = nil
local lightcolorlocPoint = nil
local lightparamslocPoint = nil
local uniformEyePosPoint
local uniformViewPrjInvPoint
local lightposlocBeam = nil
local lightpos2locBeam = nil
local lightcolorlocBeam = nil
local lightparamslocBeam = nil
local uniformEyePosBeam
local uniformViewPrjInvBeam
-- bloom shader uniform locations
local brightShaderText0Loc = nil
local brightShaderInvRXLoc = nil
local brightShaderInvRYLoc = nil
local brightShaderIllumLoc = nil
local blurShaderH51Text0Loc = nil
local blurShaderH51InvRXLoc = nil
local blurShaderH51FragLoc = nil
local blurShaderV51Text0Loc = nil
local blurShaderV51InvRYLoc = nil
local blurShaderV51FragLoc = nil
local blurShaderH71Text0Loc = nil
local blurShaderH71InvRXLoc = nil
local blurShaderH71FragLoc = nil
local blurShaderV71Text0Loc = nil
local blurShaderV71InvRYLoc = nil
local blurShaderV71FragLoc = nil
local combineShaderUseBloomLoc = nil
local combineShaderTexture0Loc = nil
local combineShaderTexture1Loc = nil
local combineShaderFragLoc = nil
--------------------------------------------------------------------------------
--Light falloff functions: http://gamedev.stackexchange.com/questions/56897/glsl-light-attenuation-color-and-intensity-formula
--------------------------------------------------------------------------------
local verbose = false
local function VerboseEcho(...)
if verbose then
Spring.Echo(...)
end
end
local collectionFunctions = {}
local collectionFunctionCount = 0
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local function initBloomTextures()
local width, height = vsx/2, vsy/2
brightTexture1 = glCreateTexture(width, height, {
fbo = true, min_filter = GL.LINEAR, mag_filter = GL.LINEAR,
format = GL_RGB8, wrap_s = GL.CLAMP, wrap_t = GL.CLAMP,
})
brightTexture2 = glCreateTexture(width, height, {
fbo = true, min_filter = GL.LINEAR, mag_filter = GL.LINEAR,
format = GL_RGB8, wrap_s = GL.CLAMP, wrap_t = GL.CLAMP,
})
if not brightTexture1 or not brightTexture2 then
Spring.Echo('Deferred Rendering: Failed to create bloom buffers!')
options.enableBloom.value = false
end
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function widget:ViewResize()
vsx, vsy = gl.GetViewSizes()
ivsx = 1.0 / vsx --we can do /n here!
ivsy = 1.0 / vsy
if (Spring.GetMiniMapDualScreen() == 'left') then
vsx = vsx / 2
end
if (Spring.GetMiniMapDualScreen() == 'right') then
vsx = vsx / 2
end
screenratio = vsy / vsx --so we dont overdraw and only always draw a square
glDeleteTexture(brightTexture1 or "")
glDeleteTexture(brightTexture2 or "")
glDeleteTexture(screenHDR or "")
screenHDR, brightTexture1, brightTexture2 = nil, nil, nil
if options.enableHDR.value then
screenHDR = glCreateTexture(vsx, vsy, {
fbo = true, min_filter = GL.LINEAR, mag_filter = GL.LINEAR,
format = GL_RGB32F_ARB, wrap_s = GL.CLAMP, wrap_t = GL.CLAMP,
})
if options.enableBloom.value then
initBloomTextures()
end
if not screenHDR then
Spring.Echo('Deferred Rendering: Failed to create HDR buffer!')
options.enableHDR.value = false
end
end
end
widget:ViewResize()
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local vertSrc = [[
void main(void)
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_Vertex;
}
]]
local fragSrc
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local function DeferredLighting_RegisterFunction(func)
collectionFunctionCount = collectionFunctionCount + 1
collectionFunctions[collectionFunctionCount] = func
end
function InitialiseShaders()
if ((not forceNonGLSL) and Spring.GetMiniMapDualScreen() ~= 'left') then --FIXME dualscreen
if (not glCreateShader) then
spEcho("gfx_deferred_rendering.lua: Shaders not found, removing self.")
GLSLRenderer = false
widgetHandler:RemoveWidget()
else
fragSrc = VFS.LoadFile("LuaUI\\Widgets\\Shaders\\deferred_lighting.fs", VFS.ZIP)
--Spring.Echo('gfx_deferred_rendering.lua: Shader code:', fragSrc)
depthPointShader = depthPointShader or glCreateShader({
defines = {
"#version 120\n",
"#define BEAM_LIGHT 0\n",
"#define CLIP_CONTROL " .. (Platform.glSupportClipSpaceControl and 1 or 0) .. "\n"
},
vertex = vertSrc,
fragment = fragSrc,
uniformInt = {
modelnormals = 0,
modeldepths = 1,
mapnormals = 2,
mapdepths = 3,
modelExtra = 4,
},
})
if (not depthPointShader) then
spEcho(glGetShaderLog())
spEcho("gfx_deferred_rendering.lua: Bad depth point shader, removing self.")
GLSLRenderer = false
widgetHandler:RemoveWidget()
else
lightposlocPoint = glGetUniformLocation(depthPointShader, "lightpos")
lightcolorlocPoint = glGetUniformLocation(depthPointShader, "lightcolor")
uniformEyePosPoint = glGetUniformLocation(depthPointShader, 'eyePos')
uniformViewPrjInvPoint = glGetUniformLocation(depthPointShader, 'viewProjectionInv')
end
depthBeamShader = depthBeamShader or glCreateShader({
defines = {
"#version 120\n",
"#define BEAM_LIGHT 1\n",
"#define CLIP_CONTROL " .. (Platform.glSupportClipSpaceControl and 1 or 0) .. "\n"
},
vertex = vertSrc,
fragment = fragSrc,
uniformInt = {
modelnormals = 0,
modeldepths = 1,
mapnormals = 2,
mapdepths = 3,
modelExtra = 4,
},
})
if (not depthBeamShader) then
spEcho(glGetShaderLog())
spEcho("gfx_deferred_rendering.lua: Bad depth beam shader, removing self.")
GLSLRenderer = false
widgetHandler:RemoveWidget()
else
lightposlocBeam = glGetUniformLocation(depthBeamShader, 'lightpos')
lightpos2locBeam = glGetUniformLocation(depthBeamShader, 'lightpos2')
lightcolorlocBeam = glGetUniformLocation(depthBeamShader, 'lightcolor')
uniformEyePosBeam = glGetUniformLocation(depthBeamShader, 'eyePos')
uniformViewPrjInvBeam = glGetUniformLocation(depthBeamShader, 'viewProjectionInv')
end
if options.enableHDR.value and options.enableBloom.value then
brightShader = brightShader or glCreateShader({
defines = {"#version 120\n"},
fragment = VFS.LoadFile("LuaUI\\Widgets\\Shaders\\bloom_bright.fs", VFS.ZIP),
uniformInt = {texture0 = 0},
uniformFloat = {illuminationThreshold, inverseRX, inverseRY}
})
if not brightShader then
Spring.Echo('Deferred Rendering Widget: brightShader failed to compile!')
Spring.Echo(gl.GetShaderLog())
end
blurShaderH71 = blurShaderH71 or glCreateShader({
defines = {"#version 120\n"},
fragment = VFS.LoadFile("LuaUI\\Widgets\\Shaders\\bloom_blurH.fs", VFS.ZIP),
uniformInt = {texture0 = 0},
uniformFloat = {inverseRX}
})
if not blurShaderH71 then
Spring.Echo('Deferred Rendering Widget: blurshaderH71 failed to compile!')
Spring.Echo(gl.GetShaderLog())
end
blurShaderV71 = blurShaderV71 or glCreateShader({
defines = {"#version 120\n"},
fragment = VFS.LoadFile("LuaUI\\Widgets\\Shaders\\bloom_blurV.fs", VFS.ZIP),
uniformInt = {texture0 = 0},
uniformFloat = {inverseRY}
})
if not blurShaderV71 then
Spring.Echo('Deferred Rendering Widget: blueShaderV71 failed to compile!')
Spring.Echo(gl.GetShaderLog())
end
if not brightShader or not blurShaderH71 or not blurShaderV71 then
Spring.Echo('Deferred Rendering Widget: Failed to create bloom shaders!')
options.enableBloom.value = false
else
brightShaderText0Loc = glGetUniformLocation(brightShader, "texture0")
brightShaderInvRXLoc = glGetUniformLocation(brightShader, "inverseRX")
brightShaderInvRYLoc = glGetUniformLocation(brightShader, "inverseRY")
brightShaderIllumLoc = glGetUniformLocation(brightShader, "illuminationThreshold")
blurShaderH71Text0Loc = glGetUniformLocation(blurShaderH71, "texture0")
blurShaderH71InvRXLoc = glGetUniformLocation(blurShaderH71, "inverseRX")
blurShaderH71FragLoc = glGetUniformLocation(blurShaderH71, "fragKernelRadius")
blurShaderV71Text0Loc = glGetUniformLocation(blurShaderV71, "texture0")
blurShaderV71InvRYLoc = glGetUniformLocation(blurShaderV71, "inverseRY")
blurShaderV71FragLoc = glGetUniformLocation(blurShaderV71, "fragKernelRadius")
end
end
if options.enableHDR.value then
combineShader = combineShader or glCreateShader({
defines = {"#version 120\n"},
fragment = VFS.LoadFile("LuaUI\\Widgets\\Shaders\\bloom_combine.fs", VFS.ZIP),
uniformInt = { texture0 = 0, texture1 = 1, useBloom = 1, useHDR = 1},
uniformFloat = {fragMaxBrightness}
})
if not combineShader then
Spring.Echo('Deferred Rendering Widget: combineShader failed to compile!')
options.enableHDR.value = false
Spring.Echo(gl.GetShaderLog())
else
combineShaderUseBloomLoc = glGetUniformLocation(combineShader, "useBloom")
combineShaderTexture0Loc = glGetUniformLocation(combineShader, "texture0")
combineShaderTexture1Loc = glGetUniformLocation(combineShader, "texture1")
combineShaderFragLoc = glGetUniformLocation(combineShader, "fragMaxBrightness")
end
end
WG.DeferredLighting_RegisterFunction = DeferredLighting_RegisterFunction
end
screenratio = vsy / vsx --so we dont overdraw and only always draw a square
else
GLSLRenderer = false
end
widget:ViewResize()
end
function widget:Initialize()
if (glCreateShader == nil) then
Spring.Echo('Deferred Rendering requires shader support!')
widgetHandler:RemoveWidget()
return
end
if (Spring.GetConfigInt("AllowDeferredMapRendering") ~= 1 or Spring.GetConfigInt("AllowDeferredModelRendering") ~= 1) then
Spring.Echo('Deferred Rendering (gfx_deferred_rendering.lua) requires AllowDeferredMapRendering and AllowDeferredModelRendering to be enabled in springsettings.cfg!')
widgetHandler:RemoveWidget()
return
end
InitialiseShaders()
end
function widget:Shutdown()
if (GLSLRenderer) then
if (glDeleteShader) then
glDeleteShader(depthPointShader)
glDeleteShader(depthBeamShader)
glDeleteShader(brightShader)
glDeleteShader(blurShaderH71)
glDeleteShader(blurShaderV71)
glDeleteShader(combineShader)
end
glDeleteTexture(brightTexture1 or "")
glDeleteTexture(brightTexture2 or "")
glDeleteTexture(screenHDR or "")
screenHDR, brightTexture1, brightTexture2 = nil, nil, nil
end
end
local function DrawLightType(lights, lightsCount, lighttype) -- point = 0 beam = 1
--Spring.Echo('Camera FOV = ', Spring.GetCameraFOV()) -- default TA cam fov = 45
--set uniforms:
local cpx, cpy, cpz = spGetCameraPosition()
if lighttype == 0 then --point
glUseShader(depthPointShader)
glUniform(uniformEyePosPoint, cpx, cpy, cpz)
glUniformMatrix(uniformViewPrjInvPoint, "viewprojectioninverse")
else --beam
glUseShader(depthBeamShader)
glUniform(uniformEyePosBeam, cpx, cpy, cpz)
glUniformMatrix(uniformViewPrjInvBeam, "viewprojectioninverse")
end
glTexture(0, "$model_gbuffer_normtex")
glTexture(1, "$model_gbuffer_zvaltex")
glTexture(2, "$map_gbuffer_normtex")
glTexture(3, "$map_gbuffer_zvaltex")
glTexture(4, "$model_gbuffer_spectex")
local cx, cy, cz = spGetCameraPosition()
for i = 1, lightsCount do
local light = lights[i]
local param = light.param
if verbose then
VerboseEcho('gfx_deferred_rendering.lua: Light being drawn:', i)
Spring.Utilities.TableEcho(light)
end
if lighttype == 0 then -- point
local lightradius = param.radius
--Spring.Echo("Drawlighttype position = ", light.px, light.py, light.pz)
local sx, sy, sz = spWorldToScreenCoords(light.px, light.py, light.pz) -- returns x, y, z, where x and y are screen pixels, and z is z buffer depth.
-- prevent sharp cutoffs when projectile is slightly offscreen
sx = math.max(0,sx)
sx = math.min(sx,vsx)
sx = sx/vsx
sy = sy/vsy --since FOV is static in the Y direction, the Y ratio is the correct one
local dist_sq = (light.px-cx)^2 + (light.py-cy)^2 + (light.pz-cz)^2
local ratio = lightradius / math.sqrt(dist_sq) * 1.5
glUniform(lightposlocPoint, light.px, light.py, light.pz, param.radius) --in world space
glUniform(lightcolorlocPoint, param.r * light.colMult, param.g * light.colMult, param.b * light.colMult, 1)
glTexRect(
math.max(-1 , (sx-0.5)*2-ratio*screenratio),
math.max(-1 , (sy-0.5)*2-ratio),
math.min( 1 , (sx-0.5)*2+ratio*screenratio),
math.min( 1 , (sy-0.5)*2+ratio),
math.max( 0 , sx - 0.5*ratio*screenratio),
math.max( 0 , sy - 0.5*ratio),
math.min( 1 , sx + 0.5*ratio*screenratio),
math.min( 1 , sy + 0.5*ratio)
) -- screen size goes from -1, -1 to 1, 1; uvs go from 0, 0 to 1, 1
end
if lighttype == 1 then -- beam
local lightradius = 0
local px = light.px+light.dx*0.5
local py = light.py+light.dy*0.5
local pz = light.pz+light.dz*0.5
local lightradius = param.radius + math.sqrt(light.dx^2 + light.dy^2 + light.dz^2)*0.5
VerboseEcho("Drawlighttype position = ", light.px, light.py, light.pz)
local sx, sy, sz = spWorldToScreenCoords(px, py, pz) -- returns x, y, z, where x and y are screen pixels, and z is z buffer depth.
-- prevent sharp cutoffs when beam is slightly offscreen
sx = math.max(0,sx)
sx = math.min(sx,vsx)
sx = sx/vsx
sy = sy/vsy --since FOV is static in the Y direction, the Y ratio is the correct one
local dist_sq = (px-cx)^2 + (py-cy)^2 + (pz-cz)^2
local ratio = lightradius / math.sqrt(dist_sq)
ratio = ratio*2
glUniform(lightposlocBeam, light.px, light.py, light.pz, param.radius) --in world space
glUniform(lightpos2locBeam, light.px+light.dx, light.py+light.dy+24, light.pz+light.dz, param.radius) --in world space, the magic constant of +24 in the Y pos is needed because of our beam distance calculator function in GLSL
glUniform(lightcolorlocBeam, param.r * light.colMult, param.g * light.colMult, param.b * light.colMult, 1)
--TODO: use gl.Shape instead, to avoid overdraw
glTexRect(
math.max(-1 , (sx-0.5)*2-ratio*screenratio),
math.max(-1 , (sy-0.5)*2-ratio),
math.min( 1 , (sx-0.5)*2+ratio*screenratio),
math.min( 1 , (sy-0.5)*2+ratio),
math.max( 0 , sx - 0.5*ratio*screenratio),
math.max( 0 , sy - 0.5*ratio),
math.min( 1 , sx + 0.5*ratio*screenratio),
math.min( 1 , sy + 0.5*ratio)
) -- screen size goes from -1, -1 to 1, 1; uvs go from 0, 0 to 1, 1
end
end
glUseShader(0)
end
local function renderToTextureFunc(tex, s, t)
glTexture(tex)
glTexRect(-1 * s, -1 * t, 1 * s, 1 * t)
glTexture(false)
end
local function mglRenderToTexture(FBOTex, tex, s, t)
glRenderToTexture(FBOTex, renderToTextureFunc, tex, s, t)
end
local function Bloom()
gl.Color(1, 1, 1, 1)
if options.enableHDR.value and options.enableBloom.value then
if not brightTexture1 or not brightTexture2 then
Spring.Echo("Bloom textures (HDR) did not initialize on resize. Trying again.")
initBloomTextures()
if not options.enableBloom.value then
return
end
end
glUseShader(brightShader)
glUniformInt(brightShaderText0Loc, 0)
glUniform( brightShaderInvRXLoc, ivsx)
glUniform( brightShaderInvRYLoc, ivsy)
glUniform( brightShaderIllumLoc, options.illumThreshold.value)
mglRenderToTexture(brightTexture1, screenHDR, 1, -1)
glUseShader(0)
glUseShader(blurShaderH71)
glUniformInt(blurShaderH71Text0Loc, 0)
glUniform( blurShaderH71InvRXLoc, ivsx)
glUniform( blurShaderH71FragLoc, kernelRadius)
mglRenderToTexture(brightTexture2, brightTexture1, 1, -1)
glUseShader(0)
glUseShader(blurShaderV71)
glUniformInt(blurShaderV71Text0Loc, 0)
glUniform( blurShaderV71InvRYLoc, ivsy)
glUniform( blurShaderV71FragLoc, kernelRadius)
mglRenderToTexture(brightTexture1, brightTexture2, 1, -1)
glUseShader(0)
end
glUseShader(combineShader)
glUniformInt(combineShaderUseBloomLoc, options.enableBloom.value and 1 or 0)
glUniformInt(combineShaderTexture0Loc, 0)
glUniformInt(combineShaderTexture1Loc, 1)
glUniform( combineShaderFragLoc, options.maxBrightness.value)
glTexture(0, screenHDR)
if options.enableBloom.value then
glTexture(1, brightTexture1)
end
glTexRect(0, 0, vsx, vsy, false, true)
glTexture(0, false)
glTexture(1, false)
glUseShader(0)
end
function widget:DrawScreenEffects()
if not (GLSLRenderer) then
Spring.Echo('Removing deferred rendering widget: failed to use GLSL shader')
widgetHandler:RemoveWidget()
return
end
if options.enableHDR.value then
glCopyToTexture(screenHDR, 0, 0, 0, 0, vsx, vsy) -- copy the screen to an HDR texture
end
local beamLights = {}
local beamLightCount = 0
local pointLights = {}
local pointLightCount = 0
for i = 1, collectionFunctionCount do
beamLights, beamLightCount, pointLights, pointLightCount = collectionFunctions[i](beamLights, beamLightCount, pointLights, pointLightCount)
end
glBlending(GL.DST_COLOR, GL.ONE) -- Set add blending mode
if beamLightCount > 0 then
if options.enableHDR.value then
glRenderToTexture(screenHDR, DrawLightType, beamLights, beamLightCount, 1)
else
DrawLightType(beamLights, beamLightCount, 1)
end
end
if pointLightCount > 0 then
if options.enableHDR.value then
glRenderToTexture(screenHDR, DrawLightType, pointLights, pointLightCount, 0)
else
DrawLightType(pointLights, pointLightCount, 0)
end
end
glBlending(false)
if options.enableHDR.value then
Bloom()
end
end | gpl-2.0 |
imeteora/cocos2d-x-3.x-Qt | cocos/scripting/lua-bindings/auto/api/Twirl.lua | 2 | 1471 |
--------------------------------
-- @module Twirl
-- @extend Grid3DAction
--------------------------------
-- @function [parent=#Twirl] setAmplitudeRate
-- @param self
-- @param #float float
--------------------------------
-- @function [parent=#Twirl] getAmplitudeRate
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- @function [parent=#Twirl] setAmplitude
-- @param self
-- @param #float float
--------------------------------
-- @function [parent=#Twirl] getAmplitude
-- @param self
-- @return float#float ret (return value: float)
--------------------------------
-- @function [parent=#Twirl] setPosition
-- @param self
-- @param #point_table point
--------------------------------
-- @function [parent=#Twirl] getPosition
-- @param self
-- @return point_table#point_table ret (return value: point_table)
--------------------------------
-- @function [parent=#Twirl] create
-- @param self
-- @param #float float
-- @param #size_table size
-- @param #point_table point
-- @param #unsigned int int
-- @param #float float
-- @return Twirl#Twirl ret (return value: cc.Twirl)
--------------------------------
-- @function [parent=#Twirl] clone
-- @param self
-- @return Twirl#Twirl ret (return value: cc.Twirl)
--------------------------------
-- @function [parent=#Twirl] update
-- @param self
-- @param #float float
return nil
| gpl-2.0 |
awilliamson/Starfall | lua/starfall/libs_sv/holograms.lua | 1 | 10430 |
--- Library for creating and manipulating physics-less models AKA "Holograms".
-- @shared
local holograms_library, holograms_library_metamethods = SF.Libraries.Register("holograms")
--- Hologram type
local hologram_methods, hologram_metamethods = SF.Typedef("Hologram", SF.Entities.Metatable)
SF.Holograms = {}
SF.Holograms.defaultquota = CreateConVar( "sf_holograms_defaultquota", "7200", {FCVAR_ARCHIVE,FCVAR_REPLICATED},
"The default number of holograms allowed to spawn via Starfall scripts across all instances" )
SF.Holograms.personalquota = CreateConVar( "sf_holograms_personalquota", "300", {FCVAR_ARCHIVE,FCVAR_REPLICATED},
"The default number of holograms allowed to spawn via Starfall scripts for a single instance" )
SF.Holograms.burstrate = CreateConVar( "sf_holograms_burstrate", "10", {FCVAR_ARCHIVE,FCVAR_REPLICATED},
"The default number of holograms allowed to spawn in a short interval of time via Starfall scripts for a single instance ( burst )" )
SF.Holograms.Methods = hologram_methods
SF.Holograms.Metatable = hologram_metamethods
local dsetmeta = debug.setmetatable
local old_ent_wrap = SF.Entities.Wrap
function SF.Entities.Wrap(obj)
local w = old_ent_wrap(obj)
if IsValid(obj) and obj:IsValid() and obj:GetClass() == "starfall_hologram" then
dsetmeta(w, hologram_metamethods)
end
return w
end
local insts = {}
local plyCount = {}
SF.Libraries.AddHook("initialize",function(inst)
inst.data.holograms = {
holos = {},
count = 0,
burst = SF.Holograms.burstrate:GetInt() or 10
}
insts[inst] = true
plyCount[inst.player] = plyCount[inst.player] or inst.data.holograms.count
end)
SF.Libraries.AddHook("deinitialize", function(inst)
local holos = inst.data.holograms.holos
local holo = next(holos)
while holo do
local holoent = SF.Entities.Unwrap(holo)
if IsValid(holoent) then
holoent:Remove()
end
holos[holo] = nil
holo = next(holos)
end
plyCount[inst.player] = plyCount[inst.player] - inst.data.holograms.count
inst.data.holograms.count = 0
insts[inst]= nil
end)
local function hologramOnDestroy(holoent, holodata)
if not holodata.holos then return end
local holo = SF.Entities.Wrap(holoent)
if holodata.holos[holo] then
holodata.holos[holo] = nil
holodata.count = holodata.count - 1
assert(holodata.count >= 0)
end
end
-- ------------------------------------------------------------------------- --
--- Sets the hologram position.
-- @param pos New position
function hologram_methods:setPos(pos)
SF.CheckType(self, hologram_metamethods)
SF.CheckType(pos, "Vector")
local holo = SF.Entities.Unwrap(self)
if holo then holo:SetPos(pos) end
end
--- Sets the hologram angle
-- @param ang New angles
function hologram_methods:setAng(ang)
SF.CheckType(self, hologram_metamethods)
SF.CheckType(ang, "Angle")
local holo = SF.Entities.Unwrap(self)
if holo then holo:SetAngles(ang) end
end
--- Sets the hologram linear velocity
-- @param vel New velocity
function hologram_methods:setVel(vel)
SF.CheckType(self, hologram_metamethods)
SF.CheckType(vel, "Vector")
local holo = SF.Entities.Unwrap(self)
if holo then holo:SetLocalVelocity(vel) end
end
--- Sets the hologram's angular velocity.
-- @param angvel *Vector* angular velocity.
function hologram_methods:setAngVel(angvel)
SF.CheckType(self, hologram_metamethods)
SF.CheckType(angvel, "Angle")
local holo = SF.Entities.Unwrap(self)
if holo then holo:SetLocalAngularVelocity(angvel) end
end
--- Parents this hologram to the specified hologram
function hologram_methods:setParent(parent, attachment)
SF.CheckType(self, hologram_metamethods)
local child = SF.Entities.Unwrap(self)
if not child then return end
if parent then
SF.CheckType(parent, SF.Entities.Metatable)
local parent = SF.Entities.Unwrap(parent)
if not parent then return end
-- Prevent cyclic parenting ( = crashes )
local checkparent = parent
repeat
if checkparent == child then return end
checkparent = checkparent:GetParent()
until not IsValid(checkparent)
child:SetParent(parent)
if attachment then
SF.CheckType(attachment, "string")
child:Fire("SetParentAttachmentMaintainOffset", attachment, 0.01)
end
else
child:SetParent(nil)
end
end
--- Sets the hologram scale
-- @param scale New scale
function hologram_methods:setScale(scale)
SF.CheckType(self, hologram_metamethods)
SF.CheckType(scale, "Vector")
local holo = SF.Entities.Unwrap(self)
if holo then
holo:SetScale(scale)
end
end
--- Updates a clip plane
function hologram_methods:setClip(index, enabled, origin, normal, islocal)
SF.CheckType(self, hologram_metamethods)
SF.CheckType(index, "number")
SF.CheckType(enabled, "boolean")
SF.CheckType(origin, "Vector")
SF.CheckType(normal, "Vector")
SF.CheckType(islocal, "boolean")
local holo = SF.Entities.Unwrap(self)
if holo then
holo:UpdateClip(index, enabled, origin, normal, islocal)
end
end
--- Returns a table of flexname -> flexid pairs for use in flex functions.
-- These IDs become invalid when the hologram's model changes.
function hologram_methods:getFlexes()
SF.CheckType(self, hologram_metamethods)
local holoent = SF.Entities.Unwrap(self)
local flexes = {}
for i=0,holoent:GetFlexNum()-1 do
flexes[holoent:GetFlexName(i)] = i
end
return flexes
end
--- Sets the weight (value) of a flex.
function hologram_methods:setFlexWeight(flexid, weight)
SF.CheckType(self, hologram_metamethods)
SF.CheckType(flexid, "number")
SF.CheckType(weight, "number")
flexid = math.floor(flexid)
if flexid < 0 or flexid >= holoent:GetFlexNum() then
SF.throw( "Invalid flex: "..flexid, 2 )
end
local holoent = SF.Entities.Unwrap(self)
if IsValid(holoent) then
holoent:SetFlexWeight(self, weight)
end
end
--- Sets the scale of all flexes of a hologram
function hologram_methods:setFlexScale(scale)
SF.CheckType(self, hologram_metamethods)
SF.CheckType(scale, "number")
local holoent = SF.Entities.Unwrap(self)
if IsValid(holoent) then
holoent:SetFlexScale(scale)
end
end
--- Deletes the hologram
-- @server
function hologram_methods:remove()
SF.CheckType(self, hologram_metamethods)
local holoent = SF.Entities.Unwrap(self)
if IsValid(holoent) then
holoent:Remove()
end
end
--- Sets the color ( and alpha ) of a hologram
-- @server
-- @class function
-- @param color Color object to set the hologram to
function hologram_methods:setColor( color )
SF.CheckType( color, SF.Types[ "Color" ] )
local this = SF.Entities.Unwrap( self )
if IsValid( this ) then
this:SetColor( color )
this:SetRenderMode( this:GetColor().a == 255 and RENDERMODE_NORMAL or RENDERMODE_TRANSALPHA )
end
end
--- Suppress Engine Lighting of a hologram. Disabled by default.
-- @server
-- @class function
-- @param enable Boolean to represent if shading should be set or not.
function hologram_methods:suppressEngineLighting ( suppress )
SF.CheckType( suppress, "boolean" )
local this = SF.Entities.Unwrap( self )
if IsValid( this ) then
this:SetNetworkedBool( "suppressEngineLighting", suppress )
end
end
--- Updates/Checks burst constraints
-- @class function
-- @param instance Instance table for the burst values related to current SF Instance / Player
-- @param noupdate False if updating the burst should be done.
local function can_spawn(instance, noupdate)
if instance.data.holograms.burst > 0 then
if not noupdate then instance.data.holograms.burst = instance.data.holograms.burst - 1 end
return true
else
return false
end
end
--- Checks if the total number of holograms across all instances has reached the max limit.
-- @class function
-- @return True/False depending on if limit has been reached for SF Holograms
local function max_reached()
local c = 0
for _, v in pairs( plyCount ) do
c = c + v
end
if c >= SF.Holograms.defaultquota:GetInt() then return true else return false end
end
--- Checks if the users personal limit of holograms has been exhausted
-- @class function
-- @param i Instance to use, this will relate to the player in question
-- @return True/False depending on if the personal limit has been reached for SF Holograms
local function personal_max_reached( i )
return plyCount[i.player] >= SF.Holograms.personalquota:GetInt()
end
timer.Create( "SF_Hologram_BurstCounter", 1/4, 0, function()
for i, _ in pairs( insts ) do
if i.data.holograms.burst < SF.Holograms.burstrate:GetInt() or 10 then -- Should allow for dynamic changing of burst rate from the server.
i.data.holograms.burst = i.data.holograms.burst + 1
end
end
end )
--- Creates a hologram.
-- @server
-- @return The hologram object
function holograms_library.create( pos, ang, model, scale )
SF.CheckType( pos, "Vector" )
SF.CheckType( ang, "Angle" )
SF.CheckType( model, "string" )
if scale then SF.CheckType( scale, "Vector" ) end
local instance = SF.instance
if not can_spawn( instance ) then return SF.throw( "Can't spawn holograms that often", 2 )
elseif personal_max_reached( instance ) then return SF.throw( "Can't spawn holograms, maximum personal limit of " .. SF.Holograms.personalquota:GetInt() .. " has been reached", 2 )
elseif max_reached() then return SF.throw( "Can't spawn holograms, maximum limit of " .. SF.Holograms.defaultquota:GetInt() .. " has been reached", 2 ) end
local holodata = instance.data.holograms
local holoent = ents.Create( "starfall_hologram" )
if holoent and holoent:IsValid() then
holoent:SetPos( pos )
holoent:SetAngles( ang )
holoent:SetModel( model )
holoent:CallOnRemove( "starfall_hologram_delete", hologramOnDestroy, holodata )
holoent:Spawn()
if scale then
holoent:SetScale( scale )
end
local holo = SF.Entities.Wrap( holoent )
holodata.holos[ holo ] = holo
holodata.count = holodata.count + 1
plyCount[ instance.player ] = plyCount[ instance.player ] + 1
return holo
-- TODO: Need to fire a umsg here to assign clientside ownership(?)
end
end
--- Checks if a user can spawn anymore holograms.
-- @server
-- @return True if user can spawn holograms, False if not.
function holograms_library.canSpawn()
local instance = SF.instance
return not personal_max_reached( instance ) and not max_reached() and can_spawn( instance, true )
end
| bsd-3-clause |
mattyx14/otxserver | data/monster/quests/the_secret_library/invading_demon.lua | 2 | 2210 | local mType = Game.createMonsterType("Invading Demon")
local monster = {}
monster.description = "an invading demon"
monster.experience = 100
monster.outfit = {
lookType = 35,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.health = 1000
monster.maxHealth = 1000
monster.race = "fire"
monster.corpse = 5995
monster.speed = 350
monster.manaCost = 0
monster.changeTarget = {
interval = 5000,
chance = 8
}
monster.strategiesTarget = {
nearest = 100,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = true,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
}
monster.loot = {
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -200},
{name ="combat", interval = 1000, chance = 15, type = COMBAT_PHYSICALDAMAGE, minDamage = 0, maxDamage = -180, range = 7, shootEffect = CONST_ANI_SNOWBALL, effect = CONST_ME_POFF, target = false},
{name ="combat", interval = 1000, chance = 12, type = COMBAT_ENERGYDAMAGE, minDamage = 0, maxDamage = -175, length = 3, spread = 3, effect = CONST_ME_POFF, target = false}
}
monster.defenses = {
defense = 33,
armor = 28
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = 0},
{type = COMBAT_EARTHDAMAGE, percent = 0},
{type = COMBAT_FIREDAMAGE, percent = 0},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
mattyx14/otxserver | data/scripts/spells/monster/furyosa_skill_reducer.lua | 2 | 1244 | local combat = {}
for i = 40, 50 do
combat[i] = Combat()
combat[i]:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_SOUND_YELLOW)
local condition = Condition(CONDITION_ATTRIBUTES)
condition:setParameter(CONDITION_PARAM_TICKS, 10000)
condition:setParameter(CONDITION_PARAM_STAT_MAGICPOINTSPERCENT, i)
arr = {
{0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0},
}
local area = createCombatArea(arr)
combat[i]:setArea(area)
combat[i]:addCondition(condition)
end
local spell = Spell("instant")
function spell.onCastSpell(creature, var)
return combat[math.random(40, 50)]:execute(creature, var)
end
spell:name("furyosa skill reducer")
spell:words("###120")
spell:isAggressive(true)
spell:blockWalls(true)
spell:needLearn(true)
spell:register() | gpl-2.0 |
mattyx14/otxserver | data/monster/magicals/brain_squid.lua | 2 | 3898 | local mType = Game.createMonsterType("Brain Squid")
local monster = {}
monster.description = "a brain squid"
monster.experience = 17672
monster.outfit = {
lookType = 1059,
lookHead = 17,
lookBody = 41,
lookLegs = 77,
lookFeet = 57,
lookAddons = 0,
lookMount = 0
}
monster.raceId = 1653
monster.Bestiary = {
class = "Magical",
race = BESTY_RACE_MAGICAL,
toKill = 2500,
FirstUnlock = 100,
SecondUnlock = 1000,
CharmsPoints = 50,
Stars = 4,
Occurrence = 0,
Locations = "Secret Library."
}
monster.health = 18000
monster.maxHealth = 18000
monster.race = "undead"
monster.corpse = 28582
monster.speed = 430
monster.manaCost = 0
monster.changeTarget = {
interval = 5000,
chance = 8
}
monster.strategiesTarget = {
nearest = 100,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = true,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = true,
canWalkOnFire = true,
canWalkOnPoison = true
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
}
monster.loot = {
{name = "violet crystal shard", chance = 900, maxCount = 4},
{name = "platinum coin", chance = 100000, maxCount = 12},
{name = "glowing rune", chance = 900, maxCount = 4},
{name = "instable proto matter", chance = 1200, maxCount = 4},
{name = "energy ball", chance = 1200, maxCount = 4},
{name = "energy bar", chance = 1200, maxCount = 4},
{name = "energy drink", chance = 1200, maxCount = 4},
{name = "odd organ", chance = 1200, maxCount = 4},
{name = "frozen lightning", chance = 1200, maxCount = 4},
{id = 28568, chance = 1200, maxCount = 3}, -- inkwell
{name = "small ruby", chance = 1200, maxCount = 4},
{name = "violet gem", chance = 1200, maxCount = 4},
{name = "blue crystal splinter", chance = 1200, maxCount = 4},
{name = "cyan crystal fragment", chance = 1200, maxCount = 4},
{name = "ultimate mana potion", chance = 1200, maxCount = 4},
{name = "piece of dead brain", chance = 1200, maxCount = 4},
{name = "wand of defiance", chance = 800},
{name = "lightning headband", chance = 950},
{name = "lightning pendant", chance = 850},
{name = "might ring", chance = 1300},
{name = "slime heart", chance = 1200, maxCount = 4},
{id = 23544, chance = 560}, -- collar of red plasma
{id = 23542, chance = 560}, -- collar of blue plasma
{id = 23543, chance = 560}, -- collar of green plasma
{id = 23533, chance = 560}, -- ring of red plasma
{id = 23529, chance = 560}, -- ring of blue plasma
{id = 23531, chance = 560} -- ring of green plasma
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = -100, maxDamage = -200},
{name ="combat", interval = 2000, chance = 15, type = COMBAT_ENERGYDAMAGE, minDamage = -200, maxDamage = -470, range = 7, shootEffect = CONST_ANI_ENERGY, target = false},
{name ="combat", interval = 2000, chance = 13, type = COMBAT_ENERGYDAMAGE, minDamage = -200, maxDamage = -505, radius = 3, effect = CONST_ME_ENERGYAREA, target = false}
}
monster.defenses = {
defense = 40,
armor = 82
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = 100},
{type = COMBAT_EARTHDAMAGE, percent = 0},
{type = COMBAT_FIREDAMAGE, percent = 0},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = 100},
{type = COMBAT_DEATHDAMAGE , percent = -15}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
hussian1997/hhhuu | plugins/voice.lua | 8 | 1050 | --[[
▀▄ ▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀
▀▄ ▄▀ ▀▄ ▄▀
▀▄ ▄▀ BY(@AHMED_ALOBIDE) ▀▄ ▄▀
▀▄ ▄▀ BY(@hussian_9) ▀▄ ▄▀
▀▄ ▄▀ ▀▄ ▄▀
▀▄ ▄▀ ▀▄ ▄▀
▀▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀
--]]
do
local function run(msg, matches)
local url = "http://tts.baidu.com/text2audio?lan=en&ie=UTF-8&text="..matches[1]
local receiver = get_receiver(msg)
local file = download_to_file(url,'text.ogg')
send_audio('channel#id'..msg.to.id, file, ok_cb , false)
end
return {
description = "text to voice",
usage = {
"/voice [text]"
},
patterns = {
"^/voice (.+)$"
},
run = run
}
end
| agpl-3.0 |
mattyx14/otxserver | data/monster/quests/dangerous_depth/snail_slime.lua | 2 | 1881 | local mType = Game.createMonsterType("Snail Slime")
local monster = {}
monster.description = "a snail slime"
monster.experience = 160
monster.outfit = {
lookType = 19,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.health = 1000
monster.maxHealth = 1000
monster.race = "venom"
monster.corpse = 0
monster.speed = 180
monster.manaCost = 0
monster.changeTarget = {
interval = 4000,
chance = 10
}
monster.strategiesTarget = {
nearest = 70,
health = 10,
damage = 10,
random = 10,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = false,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
}
monster.loot = {
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -600}
}
monster.defenses = {
defense = 15,
armor = 15
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = -10},
{type = COMBAT_EARTHDAMAGE, percent = 100},
{type = COMBAT_FIREDAMAGE, percent = -10},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 20},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = false},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
imeteora/cocos2d-x-3.x-Qt | cocos/scripting/lua-bindings/auto/api/TextField.lua | 2 | 5929 |
--------------------------------
-- @module TextField
-- @extend Widget
--------------------------------
-- @function [parent=#TextField] setAttachWithIME
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#TextField] getFontSize
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- @function [parent=#TextField] getStringValue
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#TextField] getDeleteBackward
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#TextField] getPlaceHolder
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#TextField] getAttachWithIME
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#TextField] setFontName
-- @param self
-- @param #string str
--------------------------------
-- @function [parent=#TextField] getInsertText
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#TextField] setInsertText
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#TextField] getDetachWithIME
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#TextField] setTextVerticalAlignment
-- @param self
-- @param #cc.TextVAlignment textvalignment
--------------------------------
-- @function [parent=#TextField] didNotSelectSelf
-- @param self
--------------------------------
-- @function [parent=#TextField] getFontName
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#TextField] setTextAreaSize
-- @param self
-- @param #size_table size
--------------------------------
-- @function [parent=#TextField] attachWithIME
-- @param self
--------------------------------
-- @function [parent=#TextField] setPasswordEnabled
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#TextField] getPasswordStyleText
-- @param self
-- @return char#char ret (return value: char)
--------------------------------
-- @function [parent=#TextField] setMaxLengthEnabled
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#TextField] setPasswordStyleText
-- @param self
-- @param #char char
--------------------------------
-- @function [parent=#TextField] setDeleteBackward
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#TextField] setFontSize
-- @param self
-- @param #int int
--------------------------------
-- @function [parent=#TextField] setPlaceHolder
-- @param self
-- @param #string str
--------------------------------
-- @function [parent=#TextField] isPasswordEnabled
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#TextField] setTextHorizontalAlignment
-- @param self
-- @param #cc.TextHAlignment texthalignment
--------------------------------
-- @function [parent=#TextField] getMaxLength
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- @function [parent=#TextField] isMaxLengthEnabled
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#TextField] setDetachWithIME
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#TextField] setText
-- @param self
-- @param #string str
--------------------------------
-- @function [parent=#TextField] setTouchAreaEnabled
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#TextField] hitTest
-- @param self
-- @param #point_table point
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#TextField] setMaxLength
-- @param self
-- @param #int int
--------------------------------
-- @function [parent=#TextField] setTouchSize
-- @param self
-- @param #size_table size
--------------------------------
-- @function [parent=#TextField] getTouchSize
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- overload function: create(string, string, int)
--
-- overload function: create()
--
-- @function [parent=#TextField] create
-- @param self
-- @param #string str
-- @param #string str
-- @param #int int
-- @return TextField#TextField ret (retunr value: ccui.TextField)
--------------------------------
-- @function [parent=#TextField] createInstance
-- @param self
-- @return Ref#Ref ret (return value: cc.Ref)
--------------------------------
-- @function [parent=#TextField] getVirtualRenderer
-- @param self
-- @return Node#Node ret (return value: cc.Node)
--------------------------------
-- @function [parent=#TextField] getDescription
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#TextField] update
-- @param self
-- @param #float float
--------------------------------
-- @function [parent=#TextField] getVirtualRendererSize
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- @function [parent=#TextField] TextField
-- @param self
return nil
| gpl-2.0 |
houqp/koreader-base | thirdparty/lua-ljsqlite3/init.lua | 1 | 20667 | --------------------------------------------------------------------------------
-- A library for interfacing with SQLite3 databases.
--
-- Copyright (C) 2011-2016 Stefano Peluchetti. All rights reserved.
--
-- Features, documentation and more: http://www.scilua.org .
--
-- This file is part of the LJSQLite3 library, which is released under the MIT
-- license: full text in file LICENSE.TXT in the library's root folder.
--------------------------------------------------------------------------------
-- TODO: Refactor according to latest style / coding guidelines.
-- TODO: introduce functionality to get of a defined type to avoid if check?
-- TODO: Add extended error codes from Sqlite?
-- TODO: Consider type checks?
-- TODO: Exposed cdef constants are ok?
-- TODO: Resultset (and so exec) could be optimized by avoiding loads/stores
-- TODO: of row table via _step?
local ffi = require "ffi"
local bit = require "bit"
local xsys = require "xsys"
local split, trim = xsys.string.split, xsys.string.trim
local function err(code, msg)
error("ljsqlite3["..code.."] "..msg)
end
-- Codes -----------------------------------------------------------------------
local sqlconstants = {} -- SQLITE_* and OPEN_* declarations.
local codes = {
[0] = "OK", "ERROR", "INTERNAL", "PERM", "ABORT", "BUSY", "LOCKED", "NOMEM",
"READONLY", "INTERRUPT", "IOERR", "CORRUPT", "NOTFOUND", "FULL", "CANTOPEN",
"PROTOCOL", "EMPTY", "SCHEMA", "TOOBIG", "CONSTRAINT", "MISMATCH", "MISUSE",
"NOLFS", "AUTH", "FORMAT", "RANGE", "NOTADB", [100] = "ROW", [101] = "DONE"
} -- From 0 to 26.
do
local types = { "INTEGER", "FLOAT", "TEXT", "BLOB", "NULL" } -- From 1 to 5.
local opens = {
READONLY = 0x00000001;
READWRITE = 0x00000002;
CREATE = 0x00000004;
DELETEONCLOSE = 0x00000008;
EXCLUSIVE = 0x00000010;
AUTOPROXY = 0x00000020;
URI = 0x00000040;
MAIN_DB = 0x00000100;
TEMP_DB = 0x00000200;
TRANSIENT_DB = 0x00000400;
MAIN_JOURNAL = 0x00000800;
TEMP_JOURNAL = 0x00001000;
SUBJOURNAL = 0x00002000;
MASTER_JOURNAL = 0x00004000;
NOMUTEX = 0x00008000;
FULLMUTEX = 0x00010000;
SHAREDCACHE = 0x00020000;
PRIVATECACHE = 0x00040000;
WAL = 0x00080000;
}
local t = sqlconstants
local pre = "static const int32_t SQLITE_"
for i=0,26 do t[#t+1] = pre..codes[i].."="..i..";\n" end
for i=100,101 do t[#t+1] = pre..codes[i].."="..i..";\n" end
for i=1,5 do t[#t+1] = pre..types[i].."="..i..";\n" end
pre = pre.."OPEN_"
for k,v in pairs(opens) do t[#t+1] = pre..k.."="..bit.tobit(v)..";\n" end
end
-- Cdef ------------------------------------------------------------------------
-- SQLITE_*, OPEN_*
ffi.cdef(table.concat(sqlconstants))
-- sqlite3*, ljsqlite3_*
ffi.cdef[[
// Typedefs.
typedef struct sqlite3 sqlite3;
typedef struct sqlite3_stmt sqlite3_stmt;
typedef void (*sqlite3_destructor_type)(void*);
typedef struct sqlite3_context sqlite3_context;
typedef struct Mem sqlite3_value;
// Get informative error message.
const char *sqlite3_errmsg(sqlite3*);
// Connection.
int sqlite3_open_v2(const char *filename, sqlite3 **ppDb, int flags,
const char *zVfs);
int sqlite3_close(sqlite3*);
int sqlite3_busy_timeout(sqlite3*, int ms);
// Statement.
int sqlite3_prepare_v2(sqlite3 *conn, const char *zSql, int nByte,
sqlite3_stmt **ppStmt, const char **pzTail);
int sqlite3_step(sqlite3_stmt*);
int sqlite3_reset(sqlite3_stmt *pStmt);
int sqlite3_finalize(sqlite3_stmt *pStmt);
// Extra functions for SELECT.
int sqlite3_column_count(sqlite3_stmt *pStmt);
const char *sqlite3_column_name(sqlite3_stmt*, int N);
int sqlite3_column_type(sqlite3_stmt*, int iCol);
// Get value from SELECT.
int64_t sqlite3_column_int64(sqlite3_stmt*, int iCol);
double sqlite3_column_double(sqlite3_stmt*, int iCol);
int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
// Set value in bind.
int sqlite3_bind_int64(sqlite3_stmt*, int, int64_t);
int sqlite3_bind_double(sqlite3_stmt*, int, double);
int sqlite3_bind_null(sqlite3_stmt*, int);
int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));
int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
int sqlite3_bind_parameter_index(sqlite3_stmt *stmt, const char *name);
// Clear bindings.
int sqlite3_clear_bindings(sqlite3_stmt*);
// Get value in callbacks.
int sqlite3_value_type(sqlite3_value*);
int64_t sqlite3_value_int64(sqlite3_value*);
double sqlite3_value_double(sqlite3_value*);
int sqlite3_value_bytes(sqlite3_value*);
const unsigned char *sqlite3_value_text(sqlite3_value*); //Not used.
const void *sqlite3_value_blob(sqlite3_value*);
// Set value in callbacks.
void sqlite3_result_error(sqlite3_context*, const char*, int);
void sqlite3_result_int64(sqlite3_context*, int64_t);
void sqlite3_result_double(sqlite3_context*, double);
void sqlite3_result_null(sqlite3_context*);
void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
// Persistency of data in callbacks (here just a pointer for tagging).
void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
// Typedefs for callbacks.
typedef void (*ljsqlite3_cbstep)(sqlite3_context*,int,sqlite3_value**);
typedef void (*ljsqlite3_cbfinal)(sqlite3_context*);
// Register callbacks.
int sqlite3_create_function(
sqlite3 *conn,
const char *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*)
);
]]
--------------------------------------------------------------------------------
local sql = ffi.load("sqlite3")
local transient = ffi.cast("sqlite3_destructor_type", -1)
local int64_ct = ffi.typeof("int64_t")
local blob_mt = {} -- For tagging only.
local function blob(str)
return setmetatable({ str }, blob_mt)
end
local connstmt = {} -- Statements for a conn.
local conncb = {} -- Callbacks for a conn.
local aggregatestate = {} -- Aggregate states.
local stmt_step
local stmt_mt, stmt_ct = {}
stmt_mt.__index = stmt_mt
local conn_mt, conn_ct = {}
conn_mt.__index = conn_mt
-- Checks ----------------------------------------------------------------------
-- Helper function to get error msg and code from sqlite.
local function codemsg(pconn, code)
return codes[code]:lower(), ffi.string(sql.sqlite3_errmsg(pconn))
end
-- Throw error for a given connection.
local function E_conn(pconn, code)
local code, msg = codemsg(pconn, code)
err(code, msg)
end
-- Test code is OK or throw error for a given connection.
local function T_okcode(pconn, code)
if code ~= sql.SQLITE_OK then
E_conn(pconn, code)
end
end
local function T_open(x)
if x._closed then
err("misuse", "object is closed")
end
end
-- Getters / Setters to minimize code duplication ------------------------------
local sql_get_code = [=[
return function(stmt_or_value <opt_i>)
local t = sql.sqlite3_<variant>_type(stmt_or_value <opt_i>)
if t == sql.SQLITE_INTEGER then
return sql.sqlite3_<variant>_int64(stmt_or_value <opt_i>)
elseif t == sql.SQLITE_FLOAT then
return sql.sqlite3_<variant>_double(stmt_or_value <opt_i>)
elseif t == sql.SQLITE_TEXT then
local nb = sql.sqlite3_<variant>_bytes(stmt_or_value <opt_i>)
return ffi.string(sql.sqlite3_<variant>_text(stmt_or_value <opt_i>), nb)
elseif t == sql.SQLITE_BLOB then
local nb = sql.sqlite3_<variant>_bytes(stmt_or_value <opt_i>)
return ffi.string(sql.sqlite3_<variant>_blob(stmt_or_value <opt_i>), nb)
elseif t == sql.SQLITE_NULL then
return nil
else
err("constraint", "unexpected SQLite3 type")
end
end
]=]
local sql_set_code = [=[
return function(stmt_or_value, v <opt_i>)
local t = type(v)
if ffi.istype(int64_ct, v) then
return sql.sqlite3_<variant>_int64(stmt_or_value <opt_i>, v)
elseif t == "number" then
return sql.sqlite3_<variant>_double(stmt_or_value <opt_i>, v)
elseif t == "string" then
return sql.sqlite3_<variant>_text(stmt_or_value <opt_i>, v, #v,
transient)
elseif t == "table" and getmetatable(v) == blob_mt then
v = v[1]
return sql.sqlite3_<variant>_blob(stmt_or_value <opt_i>, v, #v,
transient)
elseif t == "nil" then
return sql.sqlite3_<variant>_null(stmt_or_value <opt_i>)
else
err("constraint", "unexpected Lua type")
end
end
]=]
-- Environment for setters/getters.
local sql_env = {
sql = sql,
transient = transient,
ffi = ffi,
int64_ct = int64_ct,
blob_mt = blob_mt,
getmetatable = getmetatable,
err = err,
type = type
}
local function sql_format(s, variant, index)
return s:gsub("<variant>", variant):gsub("<opt_i>", index)
end
local function loadcode(s, env)
local ret = assert(loadstring(s))
if env then setfenv(ret, env) end
return ret()
end
-- Must always be called from *:_* function due to error level 4.
local get_column = loadcode(sql_format(sql_get_code, "column", ",i"), sql_env)
local get_value = loadcode(sql_format(sql_get_code, "value" , " "), sql_env)
local set_column = loadcode(sql_format(sql_set_code, "bind" , ",i"), sql_env)
local set_value = loadcode(sql_format(sql_set_code, "result", " "), sql_env)
-- Connection ------------------------------------------------------------------
local open_modes = {
ro = sql.SQLITE_OPEN_READONLY,
rw = sql.SQLITE_OPEN_READWRITE,
rwc = bit.bor(sql.SQLITE_OPEN_READWRITE, sql.SQLITE_OPEN_CREATE)
}
local function open(str, mode)
mode = mode or "rwc"
mode = open_modes[mode]
if not mode then
err("constraint", "argument #2 to open must be ro, rw, or rwc")
end
local aptr = ffi.new("sqlite3*[1]")
-- Usually aptr is set even if error code, so conn always needs to be closed.
local code = sql.sqlite3_open_v2(str, aptr, mode, nil)
local conn = conn_ct(aptr[0], false)
-- Must create this anyway due to conn:close() function.
connstmt[conn] = setmetatable({}, { __mode = "k" })
conncb[conn] = { scalar = {}, step = {}, final = {} }
if code ~= sql.SQLITE_OK then
local code, msg = codemsg(conn._ptr, code) -- Before closing!
conn:close() -- Free resources, should not fail here in this case!
err(code, msg)
end
return conn
end
function conn_mt:close() T_open(self)
-- Close all stmt linked to conn.
for k,_ in pairs(connstmt[self]) do if not k._closed then k:close() end end
-- Close all callbacks linked to conn.
for _,v in pairs(conncb[self].scalar) do v:free() end
for _,v in pairs(conncb[self].step) do v:free() end
for _,v in pairs(conncb[self].final) do v:free() end
local code = sql.sqlite3_close(self._ptr)
T_okcode(self._ptr, code)
connstmt[self] = nil -- Table connstmt is not weak, need to clear manually.
conncb[self] = nil
self._closed = true -- Set only if close succeded.
end
function conn_mt:__gc()
if not self._closed then self:close() end
end
function conn_mt:prepare(stmtstr) T_open(self)
local aptr = ffi.new("sqlite3_stmt*[1]")
-- If error code aptr NULL, so no need to close anything.
local code = sql.sqlite3_prepare_v2(self._ptr, stmtstr, #stmtstr, aptr, nil)
T_okcode(self._ptr, code)
local stmt = stmt_ct(aptr[0], false, self._ptr, code)
connstmt[self][stmt] = true
return stmt
end
-- Connection exec, __call, rowexec --------------------------------------------
function conn_mt:exec(commands, get) T_open(self)
local cmd1 = split(commands, ";")
local res, n
for i=1,#cmd1 do
local cmd = trim(cmd1[i])
if #cmd > 0 then
local stmt = self:prepare(cmd)
res, n = stmt:resultset(get)
stmt:close()
end
end
return res, n -- Only last record is returned.
end
function conn_mt:rowexec(command) T_open(self)
local stmt = self:prepare(command)
local res = stmt:_step()
if stmt:_step() then
err("misuse", "multiple records returned, 1 expected")
end
stmt:close()
if res then
return unpack(res)
else
return nil
end
end
function conn_mt:__call(commands, out) T_open(self)
out = out or print
local cmd1 = split(commands, ";")
for c=1,#cmd1 do
local cmd = trim(cmd1[c])
if #cmd > 0 then
local stmt = self:prepare(cmd)
local ret, n = stmt:resultset()
if ret then -- All the results get handled, not only last one.
out(unpack(ret[0])) -- Headers are printed.
for i=1,n do
local o = {}
for j=1,#ret[0] do
local v = ret[j][i]
if type(v) == "nil" then v = "" end -- Empty strings for NULLs.
o[#o+1] = tostring(v)
end
out(unpack(o))
end
end
stmt:close()
end
end
end
-- Callbacks -------------------------------------------------------------------
-- Update (one of) callbacks registry for sqlite functions.
local function updatecb(self, where, name, f)
local cbs = conncb[self][where]
if cbs[name] then -- Callback already present, free old one.
cbs[name]:free()
end
cbs[name] = f -- Could be nil and that's fine.
end
-- Return manually casted callback that sqlite expects, scalar.
local function scalarcb(name, f)
local values = {} -- Conversion buffer.
local function sqlf(context, nvalues, pvalues)
-- Indexing 0,N-1.
for i=1,nvalues do values[i] = get_value(pvalues[i - 1]) end
-- Throw error via sqlite function if necessary.
local ok, result = pcall(f, unpack(values, 1, nvalues))
if not ok then
local msg = "Lua registered scalar function "..name.." error: "..result
sql.sqlite3_result_error(context, msg, #msg)
else
set_value(context, result)
end
end
return ffi.cast("ljsqlite3_cbstep", sqlf)
end
-- Return the state for aggregate case (created via initstate()). We use the ptr
-- returned from aggregate_context() for tagging only, all the state data is
-- handled from Lua side.
local function getstate(context, initstate, size)
-- Only pointer address relevant for indexing, size irrelevant.
local ptr = sql.sqlite3_aggregate_context(context, size)
local pid = tonumber(ffi.cast("intptr_t",ptr))
local state = aggregatestate[pid]
if type(state) == "nil" then
state = initstate()
aggregatestate[pid] = state
end
return state, pid
end
-- Return manually casted callback that sqlite expects, stepper for aggregate.
local function stepcb(name, f, initstate)
local values = {} -- Conversion buffer.
local function sqlf(context, nvalues, pvalues)
-- Indexing 0,N-1.
for i=1,nvalues do values[i] = get_value(pvalues[i - 1]) end
local state = getstate(context, initstate, 1)
-- Throw error via sqlite function if necessary.
local ok, result = pcall(f, state, unpack(values, 1, nvalues))
if not ok then
local msg = "Lua registered step function "..name.." error: "..result
sql.sqlite3_result_error(context, msg, #msg)
end
end
return ffi.cast("ljsqlite3_cbstep", sqlf)
end
-- Return manually casted callback that sqlite expects, finalizer for aggregate.
local function finalcb(name, f, initstate)
local function sqlf(context)
local state, pid = getstate(context, initstate, 0)
aggregatestate[pid] = nil -- Clear the state.
local ok, result = pcall(f, state)
-- Throw error via sqlite function if necessary.
if not ok then
local msg = "Lua registered final function "..name.." error: "..result
sql.sqlite3_result_error(context, msg, #msg)
else
set_value(context, result)
end
end
return ffi.cast("ljsqlite3_cbfinal", sqlf)
end
function conn_mt:setscalar(name, f) T_open(self)
jit.off(stmt_step) -- Necessary to avoid bad calloc in some use cases.
local cbf = f and scalarcb(name, f) or nil
local code = sql.sqlite3_create_function(self._ptr, name, -1, 5, nil,
cbf, nil, nil) -- If cbf nil this clears the function is sqlite.
T_okcode(self._ptr, code)
updatecb(self, "scalar", name, cbf) -- Update and clear old.
end
function conn_mt:setaggregate(name, initstate, step, final) T_open(self)
jit.off(stmt_step) -- Necessary to avoid bad calloc in some use cases.
local cbs = step and stepcb (name, step, initstate) or nil
local cbf = final and finalcb(name, final, initstate) or nil
local code = sql.sqlite3_create_function(self._ptr, name, -1, 5, nil,
nil, cbs, cbf) -- If cbs, cbf nil this clears the function is sqlite.
T_okcode(self._ptr, code)
updatecb(self, "step", name, cbs) -- Update and clear old.
updatecb(self, "final", name, cbf) -- Update and clear old.
end
conn_ct = ffi.metatype("struct { sqlite3* _ptr; bool _closed; }", conn_mt)
-- Statement -------------------------------------------------------------------
function stmt_mt:reset() T_open(self)
-- Ignore possible error code, it would be repetition of error raised during
-- most recent evaluation of statement which would have been raised already.
sql.sqlite3_reset(self._ptr)
self._code = sql.SQLITE_OK -- Always succeds.
return self
end
function stmt_mt:close() T_open(self)
-- Ignore possible error code, it would be repetition of error raised during
-- most recent evaluation of statement which would have been raised already.
sql.sqlite3_finalize(self._ptr)
self._code = sql.SQLITE_OK -- Always succeds.
self._closed = true -- Must be called exaclty once.
end
function stmt_mt:__gc()
if not self._closed then self:close() end
end
-- Statement step, resultset ---------------------------------------------------
function stmt_mt:_ncol()
return sql.sqlite3_column_count(self._ptr)
end
function stmt_mt:_header(h)
for i=1,self:_ncol() do -- Here indexing 0,N-1.
h[i] = ffi.string(sql.sqlite3_column_name(self._ptr, i - 1))
end
end
stmt_step = function(self, row, header)
-- Must check code ~= SQL_DONE or sqlite3_step --> undefined result.
if self._code == sql.SQLITE_DONE then return nil end -- Already finished.
self._code = sql.sqlite3_step(self._ptr)
if self._code == sql.SQLITE_ROW then
-- All the sql.* functions called never errors here.
row = row or {}
for i=1,self:_ncol() do
row[i] = get_column(self._ptr, i - 1)
end
if header then self:_header(header) end
return row, header
elseif self._code == sql.SQLITE_DONE then -- Have finished now.
return nil
else -- If code not DONE or ROW then it's error.
E_conn(self._conn, self._code)
end
end
stmt_mt._step = stmt_step
function stmt_mt:step(row, header) T_open(self)
return self:_step(row, header)
end
function stmt_mt:resultset(get, maxrecords) T_open(self)
get = get or "hik"
maxrecords = maxrecords or math.huge
if maxrecords < 1 then
err("constraint", "agument #1 to resultset must be >= 1")
end
local hash, hasi, hask = get:find("h"), get:find("i"), get:find("k")
local r, h = self:_step({}, {})
if not r then return nil, 0 end -- No records case.
-- First record, o is a temporary table used to get records.
local o = hash and { [0] = h } or {}
for i=1,#h do o[i] = { r[i] } end
-- Other records.
local n = 1
while n < maxrecords and self:_step(r) do
n = n + 1
for i=1,#h do o[i][n] = r[i] end
end
local out = { [0] = o[0] } -- Eventually copy colnames.
if hasi then -- Use numeric indexes.
for i=1,#h do out[i] = o[i] end
end
if hask then -- Use colnames indexes.
for i=1,#h do out[h[i]] = o[i] end
end
return out, n
end
-- Statement bind --------------------------------------------------------------
function stmt_mt:_bind1(i, v)
local code = set_column(self._ptr, v, i) -- Here indexing 1,N.
T_okcode(self._conn, code)
return self
end
function stmt_mt:bind1(i, v) T_open(self)
return self:_bind1(i, v)
end
function stmt_mt:bind(...) T_open(self)
for i=1,select("#", ...) do self:_bind1(i, select(i, ...)) end
return self
end
function stmt_mt:bindkv(t, pre) T_open(self)
pre = pre or ":"
for k,v in pairs(t) do
if type(k) == "string" then
local param = sql.sqlite3_bind_parameter_index(self._ptr, pre..k)
if param ~= 0 then
self:_bind1(param, v)
end
end
end
return self
end
function stmt_mt:clearbind() T_open(self)
local code = sql.sqlite3_clear_bindings(self._ptr)
T_okcode(self._conn, code)
return self
end
stmt_ct = ffi.metatype([[struct {
sqlite3_stmt* _ptr;
bool _closed;
sqlite3* _conn;
int32_t _code;
}]], stmt_mt)
return {
open = open,
blob = blob,
}
| agpl-3.0 |
CarabusX/Zero-K | LuaUI/Utilities/engine_range_circles.lua | 8 | 3083 | -- emulates engine range circles. By very_bad_soldier and versus666
local max = math.max
local abs = math.abs
local cos = math.cos
local sin = math.sin
local sqrt = math.sqrt
local pi = math.pi
local spGetGroundHeight = Spring.GetGroundHeight
local function GetRange2DWeapon(range, yDiff)
local root1 = range * range - yDiff * yDiff
if root1 < 0 then
return 0
else
return sqrt(root1)
end
end
local GAME_GRAVITY = Game.gravity / (Game.gameSpeed^2)
local function GetRange2DCannon( range, yDiff, projectileSpeed, rangeFactor, myGravity )
local factor = 0.7071067
local smoothHeight = 100.0
local speed2d = projectileSpeed * factor
local speed2dSq = speed2d * speed2d
local gravity = myGravity or GAME_GRAVITY
local heightBoostFactor = (2.0 - rangeFactor) / sqrt(rangeFactor)
if yDiff < -smoothHeight then
yDiff = yDiff * heightBoostFactor
elseif yDiff < 0.0 then
yDiff = yDiff * (1.0 + (heightBoostFactor - 1.0) * -yDiff / smoothHeight)
end
local root1 = speed2dSq + 2 * -gravity * yDiff
if root1 < 0 then
return 0
else
return rangeFactor * (speed2dSq + speed2d * sqrt(root1)) / gravity
end
end
local function CalcBallisticCircle( x, y, z, range, weaponDef )
local rangeLineStrip = {}
local slope = 0.0
local rangeFunc = GetRange2DWeapon
local rangeFactor = 1.0 -- used by range2dCannon
if weaponDef.type == "Cannon" then
rangeFunc = GetRange2DCannon
rangeFactor = range / GetRange2DCannon(range, 0.0, weaponDef.projectilespeed, rangeFactor)
if rangeFactor > 1.0 or rangeFactor <= 0.0 then
rangeFactor = 1.0
end
end
local yGround = spGetGroundHeight(x, z)
for i = 1, 40 do
local radians = 2.0 * pi * i / 40
local rAdj = range
local sinR = sin(radians)
local cosR = cos(radians)
local posx = x + sinR * rAdj
local posz = z + cosR * rAdj
local posy = spGetGroundHeight(posx, posz)
local heightDiff = (posy - yGround) / 2.0 -- maybe y has to be getGroundHeight(x,z) cause y is unit center and not aligned to ground
rAdj = rAdj - heightDiff * slope
local adjRadius = rangeFunc( range, heightDiff * weaponDef.heightMod, weaponDef.projectilespeed, rangeFactor )
local adjustment = rAdj / 2.0
local yDiff = 0.0
for j = 0, 49 do
if ( abs( adjRadius - rAdj ) + yDiff <= 0.01 * rAdj ) then
break
end
if ( adjRadius > rAdj ) then
rAdj = rAdj + adjustment
else
rAdj = rAdj - adjustment
adjustment = adjustment / 2.0
end
posx = x + ( sinR * rAdj )
posz = z + ( cosR * rAdj )
local newY = spGetGroundHeight( posx, posz )
yDiff = abs( posy - newY )
posy = newY
posy = max( posy, 0.0 ) --hack
heightDiff = ( posy - yGround ) --maybe y has to be Ground(x,z)
adjRadius = rangeFunc( range, heightDiff * weaponDef.heightMod, weaponDef.projectilespeed, rangeFactor, weaponDef.myGravity )
end
posx = x + ( sinR * adjRadius )
posz = z + ( cosR * adjRadius )
posy = spGetGroundHeight( posx, posz ) + 5.0
posy = max( posy, 0.0 ) --hack
rangeLineStrip[i] = { posx, posy, posz }
end
return rangeLineStrip
end
return CalcBallisticCircle
| gpl-2.0 |
CarabusX/Zero-K | LuaRules/Configs/MetalSpots/Barren.lua | 8 | 1499 | local LARGE_SPOT = 2.09
local MEDIUM_SPOT = 1.75
local SMALL_SPOT = 1.40
local TINY_SPOT = 1.04
return {
spots = {
{x = 1304, z = 2680, metal = MEDIUM_SPOT},
{x = 440, z = 248, metal = TINY_SPOT},
{x = 344, z = 888, metal = TINY_SPOT},
{x = 3992, z = 3176, metal = MEDIUM_SPOT},
{x = 104, z = 3448, metal = SMALL_SPOT},
{x = 968, z = 2216, metal = TINY_SPOT},
{x = 3176, z = 1848, metal = TINY_SPOT},
{x = 1976, z = 2888, metal = SMALL_SPOT},
{x = 728, z = 3944, metal = TINY_SPOT},
{x = 3576, z = 3912, metal = TINY_SPOT},
{x = 3704, z = 3224, metal = TINY_SPOT},
{x = 3944, z = 3896, metal = MEDIUM_SPOT},
{x = 776, z = 3496, metal = MEDIUM_SPOT},
{x = 3384, z = 664, metal = MEDIUM_SPOT},
{x = 3816, z = 600, metal = SMALL_SPOT},
{x = 3912, z = 1608, metal = SMALL_SPOT},
{x = 2792, z = 1352, metal = MEDIUM_SPOT},
{x = 2472, z = 3640, metal = LARGE_SPOT},
{x = 3304, z = 120, metal = TINY_SPOT},
{x = 184, z = 2488, metal = SMALL_SPOT},
{x = 104, z = 936, metal = MEDIUM_SPOT},
{x = 136, z = 120, metal = MEDIUM_SPOT},
{x = 2136, z = 1112, metal = SMALL_SPOT},
{x = 1624, z = 424, metal = LARGE_SPOT},
}
}
| gpl-2.0 |
imeteora/cocos2d-x-3.x-Qt | tests/lua-tests/src/AssetsManagerTest/AssetsManagerTest.lua | 5 | 4588 | local targetPlatform = cc.Application:getInstance():getTargetPlatform()
local lineSpace = 40
local itemTagBasic = 1000
local menuItemNames =
{
"enter",
"reset",
"update",
}
local winSize = cc.Director:getInstance():getWinSize()
local function updateLayer()
local layer = cc.Layer:create()
local support = false
if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform)
or (cc.PLATFORM_OS_WINDOWS == targetPlatform) or (cc.PLATFORM_OS_ANDROID == targetPlatform)
or (cc.PLATFORM_OS_MAC == targetPlatform) then
support = true
end
if not support then
print("Platform is not supported!")
return layer
end
local isUpdateItemClicked = false
local assetsManager = nil
local pathToSave = ""
local menu = cc.Menu:create()
menu:setPosition(cc.p(0, 0))
cc.MenuItemFont:setFontName("Arial")
cc.MenuItemFont:setFontSize(24)
local progressLable = cc.Label:createWithTTF("",s_arialPath,30)
progressLable:setAnchorPoint(cc.p(0.5, 0.5))
progressLable:setPosition(cc.p(140,50))
layer:addChild(progressLable)
pathToSave = createDownloadDir()
local function onError(errorCode)
if errorCode == cc.ASSETSMANAGER_NO_NEW_VERSION then
progressLable:setString("no new version")
elseif errorCode == cc.ASSETSMANAGER_NETWORK then
progressLable:setString("network error")
end
end
local function onProgress( percent )
local progress = string.format("downloading %d%%",percent)
progressLable:setString(progress)
end
local function onSuccess()
progressLable:setString("downloading ok")
end
local function getAssetsManager()
if nil == assetsManager then
assetsManager = cc.AssetsManager:new("https://raw.github.com/samuele3hu/AssetsManagerTest/master/package.zip",
"https://raw.github.com/samuele3hu/AssetsManagerTest/master/version",
pathToSave)
assetsManager:retain()
assetsManager:setDelegate(onError, cc.ASSETSMANAGER_PROTOCOL_ERROR )
assetsManager:setDelegate(onProgress, cc.ASSETSMANAGER_PROTOCOL_PROGRESS)
assetsManager:setDelegate(onSuccess, cc.ASSETSMANAGER_PROTOCOL_SUCCESS )
assetsManager:setConnectionTimeout(3)
end
return assetsManager
end
local function update(sender)
progressLable:setString("")
getAssetsManager():update()
end
local function reset(sender)
progressLable:setString("")
deleteDownloadDir(pathToSave)
getAssetsManager():deleteVersion()
createDownloadDir()
end
local function reloadModule( moduleName )
package.loaded[moduleName] = nil
return require(moduleName)
end
local function enter(sender)
if not isUpdateItemClicked then
local realPath = pathToSave .. "/package"
addSearchPath(realPath,true)
end
assetsManagerModule = reloadModule("src/AssetsManagerTest/AssetsManagerModule")
assetsManagerModule.newScene(AssetsManagerTestMain)
end
local callbackFuncs =
{
enter,
reset,
update,
}
local function menuCallback(tag, menuItem)
local scene = nil
local nIdx = menuItem:getLocalZOrder() - itemTagBasic
local ExtensionsTestScene = CreateExtensionsTestScene(nIdx)
if nil ~= ExtensionsTestScene then
cc.Director:getInstance():replaceScene(ExtensionsTestScene)
end
end
for i = 1, table.getn(menuItemNames) do
local item = cc.MenuItemFont:create(menuItemNames[i])
item:registerScriptTapHandler(callbackFuncs[i])
item:setPosition(winSize.width / 2, winSize.height - i * lineSpace)
if not support then
item:setEnabled(false)
end
menu:addChild(item, itemTagBasic + i)
end
local function onNodeEvent(msgName)
if nil ~= assetsManager then
assetsManager:release()
assetsManager = nil
end
end
layer:registerScriptHandler(onNodeEvent)
layer:addChild(menu)
return layer
end
-------------------------------------
-- AssetsManager Test
-------------------------------------
function AssetsManagerTestMain()
local scene = cc.Scene:create()
scene:addChild(updateLayer())
scene:addChild(CreateBackMenuItem())
return scene
end
| gpl-2.0 |
mattyx14/otxserver | data/monster/quests/the_percht_queens_island/percht_minion.lua | 2 | 1913 | local mType = Game.createMonsterType("Percht Minion")
local monster = {}
monster.description = "a percht minion"
monster.experience = 0
monster.outfit = {
lookType = 53,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.health = 55
monster.maxHealth = 55
monster.race = "blood"
monster.corpse = 5998
monster.speed = 160
monster.manaCost = 0
monster.changeTarget = {
interval = 4000,
chance = 0
}
monster.strategiesTarget = {
nearest = 100,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = true,
rewardBoss = false,
illusionable = false,
canPushItems = false,
canPushCreatures = false,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 10,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "Brrr", yell = false},
{text = "Broar!", yell = false}
}
monster.loot = {
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -20}
}
monster.defenses = {
defense = 15,
armor = 15
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 100},
{type = COMBAT_ENERGYDAMAGE, percent = 100},
{type = COMBAT_EARTHDAMAGE, percent = 100},
{type = COMBAT_FIREDAMAGE, percent = 100},
{type = COMBAT_LIFEDRAIN, percent = 100},
{type = COMBAT_MANADRAIN, percent = 100},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 100},
{type = COMBAT_HOLYDAMAGE , percent = 100},
{type = COMBAT_DEATHDAMAGE , percent = 100}
}
monster.immunities = {
{type = "paralyze", condition = true},
{type = "outfit", condition = true},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
tgp1994/LiquidRP-tgp1994 | entities/entities/darkrp_laws/init.lua | 1 | 4481 | AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
local Laws = {}
local FixedLaws = {}
timer.Simple(0, function()
Laws = table.Copy(GAMEMODE.Config.DefaultLaws)
FixedLaws = table.Copy(Laws)
end)
function DarkRP.hooks:canEditLaws(ply, action, args)
if not RPExtraTeams[ply:Team()] or not RPExtraTeams[ply:Team()].mayor then
return false, DarkRP.getPhrase("incorrect_job", GAMEMODE.Config.chatCommandPrefix .. action)
end
return true
end
function ENT:Initialize()
self:SetModel("models/props/cs_assault/Billboard.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
local phys = self:GetPhysicsObject()
if phys and phys:IsValid() then
phys:Wake()
phys:EnableMotion(false)
end
end
local function addLaw(ply, args)
local canEdit, message = hook.Call("canEditLaws", DarkRP.hooks, ply, "addLaw", args)
if not canEdit then
DarkRP.notify(ply, 1, 4, message ~= nil and message or DarkRP.getPhrase("unable", GAMEMODE.Config.chatCommandPrefix .. "addLaw", ""))
return ""
end
if not args or args == "" then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", DarkRP.getPhrase("arguments"), ""))
return ""
end
if string.len(args) < 3 then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("law_too_short"))
return ""
end
if #Laws >= 12 then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("laws_full"))
return ""
end
local num = table.insert(Laws, args)
umsg.Start("DRP_AddLaw")
umsg.String(args)
umsg.End()
hook.Run("addLaw", num, args)
DarkRP.notify(ply, 0, 2, DarkRP.getPhrase("law_added"))
return ""
end
DarkRP.defineChatCommand("addLaw", addLaw)
local function removeLaw(ply, args)
local canEdit, message = hook.Call("canEditLaws", DarkRP.hooks, ply, "removeLaw", args)
if not canEdit then
DarkRP.notify(ply, 1, 4, message ~= nil and message or DarkRP.getPhrase("unable", GAMEMODE.Config.chatCommandPrefix .. "removeLaw", ""))
return ""
end
local i = tonumber(args)
if not i or not Laws[i] then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", DarkRP.getPhrase("arguments"), ""))
return ""
end
if FixedLaws[i] then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("default_law_change_denied"))
return ""
end
local law = Laws[i]
table.remove(Laws, i)
umsg.Start("DRP_RemoveLaw")
umsg.Short(i)
umsg.End()
hook.Run("removeLaw", i, law)
DarkRP.notify(ply, 0, 2, DarkRP.getPhrase("law_removed"))
return ""
end
DarkRP.defineChatCommand("removeLaw", removeLaw)
function DarkRP.resetLaws()
Laws = table.Copy(FixedLaws)
umsg.Start("DRP_ResetLaws")
umsg.End()
end
local function resetLaws(ply, args)
local canEdit, message = hook.Call("canEditLaws", DarkRP.hooks, ply, "resetLaws", args)
if not canEdit then
DarkRP.notify(ply, 1, 4, message ~= nil and message or DarkRP.getPhrase("unable", GAMEMODE.Config.chatCommandPrefix .. "resetLaws", ""))
return ""
end
hook.Run("resetLaws", ply)
DarkRP.resetLaws()
DarkRP.notify(ply, 0, 2, DarkRP.getPhrase("law_reset"))
return ""
end
DarkRP.defineChatCommand("resetLaws", resetLaws)
local numlaws = 0
local function placeLaws(ply, args)
local canEdit, message = hook.Call("canEditLaws", DarkRP.hooks, ply, "placeLaws", args)
if not canEdit then
DarkRP.notify(ply, 1, 4, message ~= nil and message or DarkRP.getPhrase("unable", GAMEMODE.Config.chatCommandPrefix .. "placeLaws", ""))
return ""
end
if numlaws >= GAMEMODE.Config.maxlawboards then
DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("limit", GAMEMODE.Config.chatCommandPrefix .. "placeLaws"))
return ""
end
local trace = {}
trace.start = ply:EyePos()
trace.endpos = trace.start + ply:GetAimVector() * 85
trace.filter = ply
local tr = util.TraceLine(trace)
local ent = ents.Create("darkrp_laws")
ent:SetPos(tr.HitPos + Vector(0, 0, 100))
local ang = ply:GetAngles()
ang:RotateAroundAxis(ang:Up(), 180)
ent:SetAngles(ang)
ent:CPPISetOwner(ply)
ent.SID = ply.SID
ent:Spawn()
ent:Activate()
if IsValid(ent) then
numlaws = numlaws + 1
end
ply.lawboards = ply.lawboards or {}
table.insert(ply.lawboards, ent)
return ""
end
DarkRP.defineChatCommand("placeLaws", placeLaws)
function ENT:OnRemove()
numlaws = numlaws - 1
end
hook.Add("PlayerInitialSpawn", "SendLaws", function(ply)
for i, law in pairs(Laws) do
if FixedLaws[i] then continue end
umsg.Start("DRP_AddLaw", ply)
umsg.String(law)
umsg.End()
end
end)
function DarkRP.getLaws()
return Laws
end
| gpl-3.0 |
CarabusX/Zero-K | scripts/striderdante.lua | 4 | 14653 | include 'constants.lua'
--------------------------------------------------------------------------------
-- pieces
--------------------------------------------------------------------------------
local base = piece 'base'
local pelvis = piece 'pelvis'
local torso = piece 'torso'
local tail = piece 'tail'
local flagellum = piece 'flagellum'
local ruparm = piece 'ruparm'
local rarm = piece 'rarm'
local rshield = piece 'rshield'
local lshield = piece 'lshield'
local luparm = piece 'luparm'
local larm = piece 'larm'
local rupleg = piece 'rupleg'
local lupleg = piece 'lupleg'
local lleg = piece 'lleg'
local rleg = piece 'rleg'
local rfoot = piece 'rfoot'
local lfoot = piece 'lfoot'
local rtoef = piece 'rtoef'
local rtoer = piece 'rtoer'
local ltoef = piece 'ltoef'
local ltoer = piece 'ltoer'
local rf1 = piece 'rf1'
local rf2 = piece 'rf2'
local rf3 = piece 'rf3'
local rbak1 = piece 'rbak1'
local rbak2 = piece 'rbak2'
local lbak1 = piece 'lbak1'
local lbak2 = piece 'lbak2'
local lf1 = piece 'lf1'
local lf2 = piece 'lf2'
local lf3 = piece 'lf3'
local flame1 = piece 'flame1'
local flame2 = piece 'flame2'
local jet1 = piece 'jet1'
local jet2 = piece 'jet2'
local fix = piece 'fix'
local smokePiece = {torso, pelvis, flagellum}
local weaponPieces = {
{aimFrom = torso, query = {rf1, lf1, rf2, lf2, rf3, lf3}, index = 1},
{aimFrom = torso, query = {flame1, flame2}, index = 1},
{aimFrom = torso, query = {rf1, lf1, rf2, lf2, rf3, lf3}, index = 1},
{aimFrom = torso, query = {fix}, index = 1},
}
local missileEmits = {{lbak1, lbak2}, {rbak1, rbak2}}
--------------------------------------------------------------------------------
-- constants
--------------------------------------------------------------------------------
local SIG_WALK = 1
local SIG_AIM = 2
local SIG_AIM_2 = 4
local SIG_AIM_3 = 8
local SIG_AIM_4 = 16
local SIG_RESTORE = 32
local SIG_IDLE = 64
local RELOADTIME = wd and WeaponDefs[wd].reload*30 or 20*30
local SALVO_TIME = 1000
local unitDefID = Spring.GetUnitDefID(unitID)
local wd = UnitDefs[unitDefID].weapons[3] and UnitDefs[unitDefID].weapons[3].weaponDef
--------------------------------------------------------------------------------
-- vars
--------------------------------------------------------------------------------
local dead = false
local armsFree = true
local dgunning = false
local rightArmPitch = 0
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Arm Animation
local function RestorePose()
Turn(torso, x_axis, 0, math.rad(100))
Turn(lupleg, x_axis, 0, math.rad(100))
Turn(rupleg, x_axis, 0, math.rad(100))
Turn(lfoot, x_axis, 0, math.rad(100))
Turn(rfoot, x_axis, 0, math.rad(100))
Turn(lleg, x_axis, 0, math.rad(100))
Turn(rleg, x_axis, 0, math.rad(100))
Turn(ltoef, x_axis, 0, math.rad(100))
Turn(ltoer, x_axis, 0, math.rad(100))
Turn(rtoef, x_axis, 0, math.rad(100))
Turn(rtoer, x_axis, 0, math.rad(100))
Turn(pelvis, z_axis, 0, math.rad(100))
Move(pelvis, y_axis, 0, 25)
rightArmPitch = 0
end
local function IdleAnim()
Signal(SIG_IDLE)
SetSignalMask(SIG_IDLE)
Sleep(12000)
while true do
Turn(torso, y_axis, math.rad(15), math.rad(60))
--Turn(larm, y_axis, math.rad(15), math.rad(60))
--Turn(rarm, y_axis, math.rad(-10), math.rad(60))
Turn(luparm, x_axis, math.rad(-40), math.rad(120))
Turn(ruparm, x_axis, 0, math.rad(120))
Sleep(1500)
Turn(torso, y_axis, math.rad(-15), math.rad(90))
--Turn(larm, y_axis, math.rad(10), math.rad(60))
--Turn(rarm, y_axis, math.rad(-15), math.rad(60))
Turn(luparm, x_axis, 0, math.rad(120))
Turn(ruparm, x_axis, math.rad(-40), math.rad(120))
Sleep(1500)
Turn(torso, y_axis, 0, math.rad(60))
--Turn(larm, y_axis, 0, math.rad(60))
--Turn(rarm, y_axis, 0, math.rad(60))
Turn(luparm, x_axis, 0, math.rad(120))
Turn(ruparm, x_axis, 0, math.rad(120))
Sleep(7000)
end
end
local function RestoreAfterDelay()
Signal(SIG_RESTORE)
SetSignalMask(SIG_RESTORE)
Sleep(8000)
--torso
if not dead then
Turn(torso, y_axis, 0, math.rad(100))
Turn(ruparm, x_axis, 0, math.rad(250))
Turn(ruparm, y_axis, 0, math.rad(250))
Turn(ruparm, z_axis, math.rad(-(0)), math.rad(250))
Turn(rarm, x_axis, 0, math.rad(250)) --up 2
Turn(rarm, y_axis, 0, math.rad(250))
Turn(rarm, z_axis, math.rad(-(0)), math.rad(250)) --up -12
Turn(flagellum, x_axis, 0, math.rad(90))
Turn(luparm, x_axis, 0, math.rad(250)) --up -9
Turn(luparm, y_axis, 0, math.rad(250))
Turn(luparm, z_axis, math.rad(-(0)), math.rad(250))
Turn(larm, x_axis, 0, math.rad(250)) --up 5
Turn(larm, y_axis, 0, math.rad(250)) --up -3
Turn(larm, z_axis, math.rad(-(0)), math.rad(250)) --up 22
RestorePose()
end
StartThread(IdleAnim)
armsFree = true
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Walking
local PACE = 3.9
local SLEEP_TIME = 1080/PACE
local walkCycle = 1 -- Alternate between 1 and 2
local tempSpeed = 40
local walkAngle = {
{ -- Moving forwards
{
hip = {math.rad(0), math.rad(20) * PACE},
leg = {math.rad(-20), math.rad(40) * PACE},
foot = {math.rad(15), math.rad(54) * PACE},
toeFront = {math.rad(22), math.rad(45) * PACE},
toeRear = {math.rad(-22), math.rad(45) * PACE},
arm = {math.rad(4), math.rad(12) * PACE},
},
{
hip = {math.rad(-35), math.rad(35) * PACE},
leg = {math.rad(0), math.rad(20) * PACE},
foot = {math.rad(-5), math.rad(20) * PACE},
toeFront = {math.rad(22), 0},
toeRear = {math.rad(-6), 10},
},
{
hip = {math.rad(-60), math.rad(25) * PACE},
leg = {math.rad(30), math.rad(30) * PACE},
foot = {math.rad(31), math.rad(36) * PACE},
toeFront = {0, math.rad(45) * PACE},
toeRear = {math.rad(10), math.rad(30) * PACE},
},
},
{ -- Moving backwards
{
hip = {math.rad(-35), math.rad(25) * PACE},
leg = {math.rad(20), math.rad(10) * PACE},
foot = {math.rad(15), math.rad(16) * PACE},
toeFront = {0, 0},
toeRear = {0, math.rad(40) * PACE},
arm = {math.rad(4), math.rad(12) * PACE},
},
{
hip = {math.rad(-5), math.rad(30) * PACE},
leg = {math.rad(10), math.rad(10) * PACE},
foot = {math.rad(-3), math.rad(18) * PACE},
toeFront = {0, 0},
toeRear = {0, 0},
},
{
hip = {math.rad(20), math.rad(25) * PACE},
leg = {math.rad(20), math.rad(10) * PACE},
foot = {math.rad(-39), math.rad(36) * PACE},
toeFront = {0, 0},
toeRear = {0, 0},
},
},
{ -- Do each cycle
{
pelvisMove = {4.6, 2.9 * PACE},
pelvisTurn = {math.rad(0.8), math.rad(1.6) * PACE},
},
{
pelvisMove = {3.8, 0.9 * PACE},
pelvisTurn = {math.rad(2), math.rad(1.2) * PACE},
},
{
pelvisMove = {1.7, 2.1 * PACE},
pelvisTurn = {math.rad(0.8), math.rad(1.6) * PACE},
},
}
}
local function Walk()
Signal(SIG_WALK)
SetSignalMask(SIG_WALK)
if armsFree then
Turn(torso, y_axis, 0, math.rad(90))
Turn(larm, y_axis, 0, math.rad(120))
Turn(rarm, y_axis, 0, math.rad(120))
Turn(luparm, x_axis, 0, math.rad(240))
Turn(ruparm, x_axis, 0, math.rad(240))
rightArmPitch = 0
end
while true do
walkCycle = 3 - walkCycle
local speedMult = (GG.att_MoveChange[unitID] or 1)
local left = walkAngle[walkCycle]
local right = walkAngle[3 - walkCycle]
local main = walkAngle[3]
for i = 1, 3 do
Turn(lupleg, x_axis, left[i].hip[1], left[i].hip[2] * speedMult)
Turn(lleg, x_axis, left[i].leg[1], left[i].leg[2] * speedMult)
Turn(lfoot, x_axis, left[i].foot[1], left[i].foot[2] * speedMult)
Turn(ltoef, x_axis, left[i].toeFront[1], left[i].toeFront[2] * speedMult)
Turn(ltoer, x_axis, left[i].toeRear[1], left[i].toeRear[2] * speedMult)
Turn(rupleg, x_axis, right[i].hip[1], right[i].hip[2] * speedMult)
Turn(rleg, x_axis, right[i].leg[1], right[i].leg[2] * speedMult)
Turn(rfoot, x_axis, right[i].foot[1], right[i].foot[2] * speedMult)
Turn(rtoef, x_axis, right[i].toeFront[1], right[i].toeFront[2] * speedMult)
Turn(rtoer, x_axis, right[i].toeRear[1], right[i].toeRear[2] * speedMult)
if armsFree and left[i].arm then
local parity = 3 - walkCycle*2
Turn(larm, y_axis, left[i].arm[1] * parity, left[i].arm[2] * speedMult)
Turn(rarm, y_axis, right[i].arm[1] * parity, right[i].arm[2] * speedMult)
Turn(pelvis, z_axis, main[i].pelvisTurn[1] * parity, main[i].pelvisTurn[2] * speedMult)
end
Move(pelvis, y_axis, main[i].pelvisMove[1], main[i].pelvisMove[2] * speedMult)
Sleep(SLEEP_TIME / speedMult)
end
end
end
function script.Create()
Hide(flame1)
Hide(flame2)
Hide(rf1)
Hide(rf2)
Hide(rf3)
Hide(lf1)
Hide(lf2)
Hide(lf3)
Hide(jet1)
Hide(jet2)
StartThread(GG.Script.SmokeUnit, unitID, smokePiece)
end
local function Stopping()
Signal(SIG_WALK)
SetSignalMask(SIG_WALK)
RestorePose()
StartThread(IdleAnim)
end
function script.StartMoving()
StartThread(Walk)
Signal(SIG_IDLE)
end
function script.StopMoving()
StartThread(Stopping)
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Weaponry
function script.AimFromWeapon(num)
if num > 4 then
return torso
end
return weaponPieces[num].aimFrom
end
function script.QueryWeapon(num)
if num > 4 then
return torso
end
local pieces = weaponPieces[num].query
return pieces[weaponPieces[num].index]
end
function script.AimWeapon(num, heading, pitch)
Signal(SIG_IDLE)
if num == 1 then
if dgunning then return false end
Signal(SIG_AIM)
SetSignalMask(SIG_AIM)
armsFree = false
Turn(ruparm, x_axis, -pitch - math.rad(20), math.rad(250))
Turn(luparm, x_axis, -pitch - math.rad(20), math.rad(250))
Turn(torso, y_axis, heading, math.rad(250))
Turn(rarm, x_axis, math.rad(20), math.rad(250))
Turn(larm, x_axis, math.rad(20), math.rad(250))
WaitForTurn(torso, y_axis)
WaitForTurn(larm, x_axis) --need to make surenot
rightArmPitch = -pitch
return true
elseif num == 2 then
if dgunning then return false end
Signal(SIG_AIM_2)
SetSignalMask(SIG_AIM_2)
Turn(torso, y_axis, heading, math.rad(200))
WaitForTurn(torso, y_axis)
StartThread(RestoreAfterDelay)
return true
elseif num == 3 then
dgunning = true
Signal(SIG_AIM)
Signal(SIG_AIM_2)
Signal(SIG_AIM_3)
SetSignalMask(SIG_AIM_3)
Spring.SetUnitRulesParam(unitID, "selfTurnSpeedChange", 0)
GG.UpdateUnitAttributes(unitID)
armsFree = false
Turn(ruparm, x_axis, -pitch - math.rad(20), math.rad(250))
Turn(luparm, x_axis, -pitch - math.rad(20), math.rad(250))
Turn(torso, y_axis, heading, math.rad(250))
Turn(rarm, x_axis, math.rad(20), math.rad(250))
Turn(larm, x_axis, math.rad(20), math.rad(250))
WaitForTurn(torso, y_axis)
WaitForTurn(larm, x_axis)
StartThread(RestoreAfterDelay)
Signal(SIG_AIM)
Signal(SIG_AIM_2)
Spring.SetUnitRulesParam(unitID, "selfTurnSpeedChange", 1)
GG.UpdateUnitAttributes(unitID)
dgunning = false
rightArmPitch = -pitch
return true
elseif num == 4 then
if dgunning then return false end
Signal(SIG_AIM_4)
SetSignalMask(SIG_AIM_4)
Turn(flagellum, x_axis, -pitch - rightArmPitch + 0.45, math.rad(90))
Turn(torso, y_axis, heading, math.rad(250))
WaitForTurn(ruparm, x_axis)
WaitForTurn(flagellum, x_axis)
WaitForTurn(torso, y_axis)
StartThread(RestoreAfterDelay)
return true
end
return true
end
function script.Shot(num)
local weapon = weaponPieces[num]
local index = weapon.index
if num == 1 or num == 3 then
local side = index%2 + 1
EmitSfx(weapon.query[index], 1024)
EmitSfx(missileEmits[side][1], 1025)
EmitSfx(missileEmits[side][2], 1025)
end
weapon.index = index + 1
if (index + 1) > #weapon.query then
weapon.index = 1
end
end
function script.BlockShot(num, targetID)
if num ~= 1 then
return false
end
local reloadState = Spring.GetUnitWeaponState(unitID, 3, 'reloadState')
return not (reloadState and (reloadState < 0 or reloadState < Spring.GetGameFrame()))
end
function script.FireWeapon(num)
if num == 3 then
dgunning = true
Spring.SetUnitRulesParam(unitID, "selfTurnSpeedChange", 0)
GG.UpdateUnitAttributes(unitID)
Sleep(SALVO_TIME)
dgunning = false
Spring.SetUnitRulesParam(unitID, "selfTurnSpeedChange", 1)
GG.UpdateUnitAttributes(unitID)
end
end
function OnLoadGame()
Spring.SetUnitRulesParam(unitID, "selfTurnSpeedChange", 1)
GG.UpdateUnitAttributes(unitID)
end
function script.Killed(recentDamage, maxHealth)
local severity = recentDamage/maxHealth
dead = true
Turn(torso, y_axis, 0, math.rad(200))
if severity <= 0.5 then
Turn(base, x_axis, math.rad(71), math.rad(70))
Turn(torso, x_axis, math.rad(-31), math.rad(50))
Turn(ruparm, x_axis, math.rad(-41), math.rad(50))
Turn(ruparm, y_axis, math.rad(-11), math.rad(50))
Turn(rarm, x_axis, math.rad(-6), math.rad(50)) --was 0
Turn(flagellum, x_axis, math.rad(49), math.rad(50))
Turn(flagellum, y_axis, math.rad(14), math.rad(50))
Turn(luparm, y_axis, math.rad(54), math.rad(50))
Turn(rupleg, x_axis, math.rad(-27), math.rad(50))
Turn(rupleg, y_axis, math.rad(-42), math.rad(50))
Turn(rupleg, z_axis, math.rad(-(-5)), math.rad(50))
Turn(rleg, x_axis, math.rad(13), math.rad(50))
Turn(rleg, y_axis, math.rad(-36), math.rad(50))
Turn(rleg, z_axis, math.rad(-(24)), math.rad(50))
Turn(lupleg, y_axis, math.rad(18), math.rad(50))
Turn(lleg, x_axis, math.rad(20), math.rad(50))
Turn(lleg, y_axis, math.rad(28), math.rad(50))
Turn(lfoot, x_axis, math.rad(23), math.rad(50))
GG.Script.InitializeDeathAnimation(unitID)
Sleep(800)
--EmitSfx(torso, 1027) --impact
--StartThread(burn)
--Sleep((1000 * rand (2, 5)))
Explode(pelvis, SFX.NONE)
Explode(luparm, SFX.NONE)
Explode(lleg, SFX.NONE)
Explode(lupleg, SFX.NONE)
Explode(rarm, SFX.FALL)
Explode(rleg, SFX.NONE)
Explode(ruparm, SFX.NONE)
Explode(rupleg, SFX.NONE)
Explode(torso, SFX.NONE)
return 1
else
Explode(pelvis, SFX.FALL + SFX.FIRE + SFX.SMOKE + SFX.EXPLODE_ON_HIT)
Explode(luparm, SFX.FALL + SFX.FIRE + SFX.SMOKE + SFX.EXPLODE_ON_HIT)
Explode(lleg, SFX.FALL + SFX.FIRE + SFX.SMOKE + SFX.EXPLODE_ON_HIT)
Explode(lupleg, SFX.FALL + SFX.FIRE + SFX.SMOKE + SFX.EXPLODE_ON_HIT)
Explode(rarm, SFX.FALL + SFX.FIRE + SFX.SMOKE + SFX.EXPLODE_ON_HIT)
Explode(rleg, SFX.FALL + SFX.FIRE + SFX.SMOKE + SFX.EXPLODE_ON_HIT)
Explode(ruparm, SFX.FALL + SFX.FIRE + SFX.SMOKE + SFX.EXPLODE_ON_HIT)
Explode(rupleg, SFX.FALL + SFX.FIRE + SFX.SMOKE + SFX.EXPLODE_ON_HIT)
Explode(torso, SFX.SHATTER + SFX.EXPLODE_ON_HIT)
return 2
end
end
| gpl-2.0 |
mattyx14/otxserver | data/monster/reptiles/young_sea_serpent.lua | 2 | 3508 | local mType = Game.createMonsterType("Young Sea Serpent")
local monster = {}
monster.description = "a young sea serpent"
monster.experience = 1000
monster.outfit = {
lookType = 317,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.raceId = 439
monster.Bestiary = {
class = "Reptile",
race = BESTY_RACE_REPTILE,
toKill = 1000,
FirstUnlock = 50,
SecondUnlock = 500,
CharmsPoints = 25,
Stars = 3,
Occurrence = 0,
Locations = "Sea Serpent Area."
}
monster.health = 1050
monster.maxHealth = 1050
monster.race = "blood"
monster.corpse = 8965
monster.speed = 480
monster.manaCost = 390
monster.changeTarget = {
interval = 4000,
chance = 10
}
monster.strategiesTarget = {
nearest = 100,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = true,
staticAttackChance = 85,
targetDistance = 1,
runHealth = 400,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = true,
canWalkOnFire = true,
canWalkOnPoison = true
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "CHHHRRRR", yell = false},
{text = "HISSSS", yell = false}
}
monster.loot = {
{name = "small sapphire", chance = 1900, maxCount = 2},
{name = "gold coin", chance = 50000, maxCount = 100},
{name = "gold coin", chance = 48000, maxCount = 74},
{id = 3049, chance = 1000}, -- stealth ring
{name = "life crystal", chance = 300},
{name = "battle axe", chance = 8000},
{name = "morning star", chance = 40000},
{name = "battle hammer", chance = 5000},
{name = "strong health potion", chance = 5000},
{name = "strong mana potion", chance = 4000},
{id = 8894, chance = 7940}, -- heavily rusted armor
{id = 8895, chance = 7940}, -- rusted armor
{name = "sea serpent scale", chance = 5000}
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -200},
{name ="combat", interval = 2000, chance = 10, type = COMBAT_EARTHDAMAGE, minDamage = -10, maxDamage = -250, length = 7, spread = 2, effect = CONST_ME_SMALLPLANTS, target = false},
{name ="combat", interval = 2000, chance = 10, type = COMBAT_ICEDAMAGE, minDamage = -80, maxDamage = -250, length = 7, spread = 2, effect = CONST_ME_ICEATTACK, target = false},
{name ="young sea serpent drown", interval = 2000, chance = 15, range = 5, target = false}
}
monster.defenses = {
defense = 30,
armor = 30,
{name ="combat", interval = 2000, chance = 30, type = COMBAT_HEALING, minDamage = 25, maxDamage = 175, effect = CONST_ME_MAGIC_BLUE, target = false},
{name ="speed", interval = 2000, chance = 15, speedChange = 400, effect = CONST_ME_MAGIC_RED, target = false, duration = 5000}
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = -20},
{type = COMBAT_ENERGYDAMAGE, percent = -10},
{type = COMBAT_EARTHDAMAGE, percent = 100},
{type = COMBAT_FIREDAMAGE, percent = 30},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 100},
{type = COMBAT_ICEDAMAGE, percent = 100},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = -15}
}
monster.immunities = {
{type = "paralyze", condition = true},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
fo369/luci-1505 | applications/luci-app-vsftpd/luasrc/model/cbi/vsftpd/general.lua | 11 | 4092 | --[[
LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2014 HackPascal <hackpascal@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
]]--
m = Map("vsftpd", translate("FTP Server - General Settings"))
sl = m:section(NamedSection, "listen", "listen", translate("Listening Settings"))
o = sl:option(Flag, "enable4", translate("Enable IPv4"))
o.rmempty = false
o.default = true
o = sl:option(Value, "ipv4", translate("IPv4 Address"))
o.datatype = "ip4addr"
o.default = "0.0.0.0"
o = sl:option(Flag, "enable6", translate("Enable IPv6"))
o.rmempty = false
o = sl:option(Value, "ipv6", translate("IPv6 Address"))
o.datatype = "ip6addr"
o.default = "::"
o = sl:option(Value, "port", translate("Listen Port"))
o.datatype = "uinteger"
o.default = "21"
o = sl:option(Value, "dataport", translate("Data Port"))
o.datatype = "uinteger"
o.default = "20"
sg = m:section(NamedSection, "global", "global", translate("Global Settings"))
o = sg:option(Flag, "write", translate("Enable write"), translate("When disabled, all write request will give permission denied."));
o.default = true
o = sg:option(Flag, "download", translate("Enable download"), translate("When disabled, all download request will give permission denied."));
o.default = true
o = sg:option(Flag, "dirlist", translate("Enable directory list"), translate("When disabled, list commands will give permission denied."))
o.default = true
o = sg:option(Flag, "lsrecurse", translate("Allow directory recursely list"))
o = sg:option(Flag, "dotfile", translate("Show dot files"), translate(". and .. are excluded."));
o.default = true
o = sg:option(Value, "umask", translate("File mode umask"), translate("Uploaded file mode will be 666 - <umask>; directory mode will be 777 - <umask>."))
o.default = "022"
o = sg:option(Value, "banner", translate("FTP Banner"))
o = sg:option(Flag, "dirmessage", translate("Enable directory message"), translate("A message will be displayed when entering a directory."))
o = sg:option(Value, "dirmsgfile", translate("Directory message filename"))
o.default = ".message"
sl = m:section(NamedSection, "local", "local", translate("Local Users"))
o = sl:option(Flag, "enabled", translate("Enable local user"))
o.rmempty = false
o = sl:option(Value, "root", translate("Root directory"), translate("Leave empty will use user's home directory"))
o.default = ""
sc = m:section(NamedSection, "connection", "connection", translate("Connection Settings"))
o = sc:option(Flag, "portmode", translate("Enable PORT mode"))
o = sc:option(Flag, "pasvmode", translate("Enable PASV mode"))
o = sc:option(ListValue, "ascii", translate("ASCII mode"))
o:value("disabled", translate("Disabled"))
o:value("download", translate("Download only"))
o:value("upload", translate("Upload only"))
o:value("both", translate("Both download and upload"))
o.default = "both"
o = sc:option(Value, "idletimeout", translate("Idle session timeout"), translate("in seconds"))
o.datatype = "uinteger"
o.default = "1800"
o = sc:option(Value, "conntimeout", translate("Connection timeout"), translate("in seconds"))
o.datatype = "uinteger"
o.default = "120"
o = sc:option(Value, "dataconntimeout", translate("Data connection timeout"), translate("in seconds"))
o.datatype = "uinteger"
o.default = "120"
o = sc:option(Value, "maxclient", translate("Max clients"), translate("0 means no limitation"))
o.datatype = "uinteger"
o.default = "0"
o = sc:option(Value, "maxperip", translate("Max clients per IP"), translate("0 means no limitation"))
o.datatype = "uinteger"
o.default = "0"
o = sc:option(Value, "maxrate", translate("Max transmit rate"), translate("in KB/s, 0 means no limitation"))
o.datatype = "uinteger"
o.default = "0"
o = sc:option(Value, "maxretry", translate("Max login fail count"), translate("Can not be zero, default is 3"))
o.datatype = "uinteger"
o.default = "3"
return m
| apache-2.0 |
mattyx14/otxserver | data/monster/quests/the_dream_courts/bosses/malofur_mangrinder.lua | 2 | 3579 | local mType = Game.createMonsterType("Malofur Mangrinder")
local monster = {}
monster.description = "Malofur Mangrinder"
monster.experience = 55000
monster.outfit = {
lookType = 1120,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.health = 200000
monster.maxHealth = 200000
monster.race = "blood"
monster.corpse = 30017
monster.speed = 250
monster.manaCost = 0
monster.changeTarget = {
interval = 4000,
chance = 10
}
monster.strategiesTarget = {
nearest = 70,
health = 10,
damage = 10,
random = 10,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = true,
illusionable = false,
canPushItems = true,
canPushCreatures = true,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "RAAAARGH! I'M MASHING YE TO DUST BOOM!", yell = false},
{text = "BOOOM!", yell = false},
{text = "BOOOOM!!!", yell = false},
{text = "BOOOOOM!!!", yell = false}
}
monster.loot = {
{name = "ultimate spirit potion", chance = 50000, maxCount = 6},
{name = "crystal coin", chance = 50000},
{name = "ultimate mana potion", chance = 50000, maxCount = 14},
{name = "supreme health potion", chance = 50000, maxCount = 6},
{name = "gold token", chance = 50000, maxCount = 2},
{name = "silver token", chance = 100000, maxCount = 2},
{id = 281, chance = 100000}, -- giant shimmering pearl (green)
{name = "green gem", chance = 100000},
{id= 3039, chance = 50000}, -- red gem
{name = "blue gem", chance = 100000},
{id = 23529, chance = 50000}, -- ring of blue plasma
{name = "platinum coin", chance = 50000, maxCount = 5},
{name = "bullseye potion", chance = 50000, maxCount = 10},
{name = "piggy bank", chance = 100000},
{name = "mysterious remains", chance = 100000},
{name = "energy bar", chance = 100000},
{id = 23543, chance = 50000}, -- collar of green plasma
{name = "ring of the sky", chance = 100000},
{name = "crunor idol", chance = 100000},
{name = "resizer", chance = 100000},
{name = "shoulder plate", chance = 100000},
{name = "malofur's lunchbox", chance = 100000},
{name = "pomegranate", chance = 50000}
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -5}
}
monster.defenses = {
defense = 20,
armor = 20
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = 0},
{type = COMBAT_EARTHDAMAGE, percent = 0},
{type = COMBAT_FIREDAMAGE, percent = 20},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = true},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType.onThink = function(monster, interval)
end
mType.onAppear = function(monster, creature)
if monster:getType():isRewardBoss() then
monster:setReward(true)
end
end
mType.onDisappear = function(monster, creature)
end
mType.onMove = function(monster, creature, fromPosition, toPosition)
end
mType.onSay = function(monster, creature, type, message)
end
mType:register(monster)
| gpl-2.0 |
kbara/snabb | src/core/config.lua | 14 | 2514 | -- Use of this source code is governed by the Apache 2.0 license; see COPYING.
-- 'config' is a data structure that describes an app network.
module(..., package.seeall)
local lib = require("core.lib")
-- API: Create a new configuration.
-- Initially there are no apps or links.
function new ()
return {
apps = {}, -- list of {name, class, args}
links = {} -- table with keys like "a.out -> b.in"
}
end
-- API: Add an app to the configuration.
--
-- config.app(c, name, class, arg):
-- c is a config object.
-- name is the name of this app in the network (a string).
-- class is the Lua object with a class:new(arg) method to create the app.
-- arg is the app's configuration (to be passed to new()).
--
-- Example: config.app(c, "nic", Intel82599, {pciaddr = "0000:00:01.00"})
function app (config, name, class, arg)
assert(type(name) == "string", "name must be a string")
assert(type(class) == "table", "class must be a table")
if class.config then
local status, result = pcall(parse_app_arg, arg, class.config)
if status then arg = result
else error("failed to configure '"..name.."': "..result) end
end
config.apps[name] = { class = class, arg = arg}
end
-- API: Add a link to the configuration.
--
-- Example: config.link(c, "nic.tx -> vm.rx")
function link (config, spec)
config.links[canonical_link(spec)] = true
end
-- Given "a.out -> b.in" return "a", "out", "b", "in".
function parse_link (spec)
local fa, fl, ta, tl = spec:gmatch(link_syntax)()
if fa and fl and ta and tl then
return fa, fl, ta, tl
else
error("link parse error: " .. spec)
end
end
link_syntax = [[ *([%w_]+)%.([%w_]+) *-> *([%w_]+)%.([%w_]+) *]]
function format_link (fa, fl, ta, tl)
return ("%s.%s -> %s.%s"):format(fa, fl, ta, tl)
end
function canonical_link (spec)
return format_link(parse_link(spec))
end
-- Parse Lua object for the arg to an app based on config. Arg may be a table
-- or a string encoded Lua object.
function parse_app_arg (arg, config)
if type(arg) == 'string' then arg = lib.load_string(arg) end
return lib.parse(arg, config)
end
function graphviz (c)
local viz = 'digraph config {\n'
local function trim (name) return name:sub(0, 12) end
for linkspec,_ in pairs(c.links) do
local fa, fl, ta, tl = config.parse_link(linkspec)
viz = viz..' '..trim(fa).." -> "..trim(ta)..' [taillabel="'..fl..'" headlabel="'..tl..'"]\n'
end
viz = viz..'}\n'
return viz
end
| apache-2.0 |
luohancfd/FluidDynamicTools | Thermo_Chemical_Properties/Molecule_Properties/RawData/HNO3.lua | 1 | 1034 | -- Collater: Rowan J. Gollan
-- Date: 30-Mar-2009
HNO3 = {}
HNO3.M = {
value = 63.01284e-3,
units = 'kg/mol',
description = 'molecular mass',
reference = 'CEA2::thermo.inp'
}
HNO3.atomic_constituents = {H=1,N=1,O=3}
HNO3.charge = 0
HNO3.gamma = {
value = 1.181,
units = 'non-dimensional',
description = 'ratio of specific heats at room temperature (= Cp/(Cp - R))',
reference = 'using Cp evaluated from CEA2 coefficients at T=300.0 K'
}
HNO3.CEA_coeffs = {
{ T_low = 200.0,
T_high = 1000.0,
coeffs = { 9.202869010e+03, 1.093774496e+02, -4.521042450e-01,
2.984914503e-02, -3.190635500e-05, 1.720931528e-08,
-3.782649830e-12, -1.764048507e+04, 2.746644879e+01
}
},
{ T_low = 1000.0,
T_high = 6000.0,
coeffs = { -9.497809640e+04, -2.733024468e+03, 1.449426995e+01,
-7.821868050e-04, 1.702693665e-07, -1.930543961e-11,
8.870455120e-16, -4.882517780e+03, -5.928392985e+01
}
},
ref="from CEA2::thermo.inp"
}
| gpl-3.0 |
luohancfd/FluidDynamicTools | Thermo_Chemical_Properties/Molecule_Properties/RawData/N2_B.lua | 1 | 1870 | -- Collater: Daniel F. Potter
-- Date: 15 July 2012
-- 2nd excited state of nitrogen, B3Pig
N2_B = {}
N2_B.M = {
value = 28.0134e-3,
units = 'kg/mol',
description = 'molecular mass',
reference = 'from CEA2::thermo.inp'
}
N2_B.atomic_constituents = {N=2}
N2_B.charge = 0
N2_B.CEA_coeffs = {
{ T_low = 200.0,
T_high = 1000.0,
coeffs = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }
},
ref="none"
}
-- Nonequilibrium data
N2_B.species_type = "nonpolar diatomic"
N2_B.s_0 = {
value = 0.0,
units = 'J/kg-K',
description = 'Dummy standard state entropy at 1 bar',
reference = 'none'
}
N2_B.I = {
value = 0.0,
units = 'J/kg',
description = 'Dummy ionization energy',
reference = 'none'
}
N2_B.h_f = {
value = 25459360.09,
units = 'J/kg',
description = 'Heat of formation',
reference = 'from CEA2::thermo.inp'
}
N2_B.Z = {
value = 0,
units = 'ND',
description = 'Charge number',
reference = 'NA'
}
N2_B.electronic_levels = {
n_levels = 1,
ref = 'Spradian07::diatom.dat',
-- ===========================================================================================================================================================
-- n Te re g dzero we wexe weye weze be alphae de betae spn-orb l s
-- ===========================================================================================================================================================
ilev_0 = { 0.0, 1.2126, 6, 38660.00, 1734.025, 14.4120, -3.300E-03, -7.900E-04, 1.63772, 1.793E-02, 5.900E-06, 0.000E+00, 4.224E+01, 1, 3 }
-- ===========================================================================================================================================================
}
| gpl-3.0 |
manoelcampos/LuaXML | XmlParser.lua | 1 | 14037 | --- @module Class providing the actual XML parser.
-- Available options are:
-- * stripWS
-- Strip non-significant whitespace (leading/trailing)
-- and do not generate events for empty text elements
--
-- * expandEntities
-- Expand entities (standard entities + single char
-- numeric entities only currently - could be extended
-- at runtime if suitable DTD parser added elements
-- to table (see obj._ENTITIES). May also be possible
-- to expand multibyre entities for UTF-8 only
--
-- * errorHandler
-- Custom error handler function
--
-- NOTE: Boolean options must be set to 'nil' not '0'
---Converts the decimal code of a character to its corresponding char
--if it's a graphical char, otherwise, returns the HTML ISO code
--for that decimal value in the format &#code
--@param code the decimal value to convert to its respective character
local function decimalToHtmlChar(code)
local n = tonumber(code)
if n >= 0 and n < 256 then
return string.char(n)
else
return "&#"..code..";"
end
end
---Converts the hexadecimal code of a character to its corresponding char
--if it's a graphical char, otherwise, returns the HTML ISO code
--for that hexadecimal value in the format ode
--@param code the hexadecimal value to convert to its respective character
local function hexadecimalToHtmlChar(code)
local n = tonumber(code, 16)
if n >= 0 and n < 256 then
return string.char(n)
else
return "&#x"..code..";"
end
end
local XmlParser = {
-- Private attribures/functions
_XML = '^([^<]*)<(%/?)([^>]-)(%/?)>',
_ATTR1 = '([%w-:_]+)%s*=%s*"(.-)"',
_ATTR2 = '([%w-:_]+)%s*=%s*\'(.-)\'',
_CDATA = '<%!%[CDATA%[(.-)%]%]>',
_PI = '<%?(.-)%?>',
_COMMENT = '<!%-%-(.-)%-%->',
_TAG = '^(.-)%s.*',
_LEADINGWS = '^%s+',
_TRAILINGWS = '%s+$',
_WS = '^%s*$',
_DTD1 = '<!DOCTYPE%s+(.-)%s+(SYSTEM)%s+["\'](.-)["\']%s*(%b[])%s*>',
_DTD2 = '<!DOCTYPE%s+(.-)%s+(PUBLIC)%s+["\'](.-)["\']%s+["\'](.-)["\']%s*(%b[])%s*>',
--_DTD3 = '<!DOCTYPE%s+(.-)%s*(%b[])%s*>',
_DTD3 = '<!DOCTYPE%s.->',
_DTD4 = '<!DOCTYPE%s+(.-)%s+(SYSTEM)%s+["\'](.-)["\']%s*>',
_DTD5 = '<!DOCTYPE%s+(.-)%s+(PUBLIC)%s+["\'](.-)["\']%s+["\'](.-)["\']%s*>',
--Matches an attribute with non-closing double quotes (The equal sign is matched non-greedly by using =+?)
_ATTRERR1 = '=+?%s*"[^"]*$',
--Matches an attribute with non-closing single quotes (The equal sign is matched non-greedly by using =+?)
_ATTRERR2 = '=+?%s*\'[^\']*$',
--Matches a closing tag such as </person> or the end of a openning tag such as <person>
_TAGEXT = '(%/?)>',
_errstr = {
xmlErr = "Error Parsing XML",
declErr = "Error Parsing XMLDecl",
declStartErr = "XMLDecl not at start of document",
declAttrErr = "Invalid XMLDecl attributes",
piErr = "Error Parsing Processing Instruction",
commentErr = "Error Parsing Comment",
cdataErr = "Error Parsing CDATA",
dtdErr = "Error Parsing DTD",
endTagErr = "End Tag Attributes Invalid",
unmatchedTagErr = "Unbalanced Tag",
incompleteXmlErr = "Incomplete XML Document",
},
_ENTITIES = {
["<"] = "<",
[">"] = ">",
["&"] = "&",
["""] = '"',
["'"] = "'",
["&#(%d+);"] = decimalToHtmlChar,
["&#x(%x+);"] = hexadecimalToHtmlChar,
},
}
--- Instantiates a XmlParser object.
--@param _handler Handler module to be used to convert the XML string
-- to another formats. See the available handlers at the handler directory.
-- Usually you get an instance to a handler module using, for instance:
-- local handler = require("xmlhandler/tree").
--@param _options Options for this XmlParser instance.
--@see XmlParser.options
function XmlParser.new(_handler, _options)
local obj = {
handler = _handler,
options = _options,
_stack = {}
}
setmetatable(obj, XmlParser)
obj.__index = XmlParser
return obj;
end
---Checks if a function/field exists in a table or in its metatable
--@param table the table to check if it has a given function
--@param elementName the name of the function/field to check if exists
--@return true if the function/field exists, false otherwise
local function fexists(table, elementName)
if table == nil then
return false
end
if table[elementName] ~= nil then
return true
else
return fexists(getmetatable(table), elementName)
end
end
local function err(self, err, pos)
if self.options.errorHandler then
self.options.errorHandler(err,pos)
end
end
--- Removes whitespaces
local function stripWS(self, s)
if self.options.stripWS then
s = string.gsub(s,'^%s+','')
s = string.gsub(s,'%s+$','')
end
return s
end
local function parseEntities(self, s)
if self.options.expandEntities then
for k,v in pairs(self._ENTITIES) do
s = string.gsub(s,k,v)
end
end
return s
end
--- Parses a string representing a tag.
--@param s String containing tag text
--@return a {name, attrs} table
-- where name is the name of the tag and attrs
-- is a table containing the atributtes of the tag
local function parseTag(self, s)
local tag = {
name = string.gsub(s, self._TAG, '%1'),
attrs = {}
}
local parseFunction = function (k, v)
tag.attrs[k] = parseEntities(self, v)
tag.attrs._ = 1
end
string.gsub(s, self._ATTR1, parseFunction)
string.gsub(s, self._ATTR2, parseFunction)
if tag.attrs._ then
tag.attrs._ = nil
else
tag.attrs = nil
end
return tag
end
local function parseXmlDeclaration(self, xml, f)
-- XML Declaration
f.match, f.endMatch, f.text = string.find(xml, self._PI, f.pos)
if not f.match then
err(self, self._errstr.declErr, f.pos)
end
if f.match ~= 1 then
-- Must be at start of doc if present
err(self, self._errstr.declStartErr, f.pos)
end
local tag = parseTag(self, f.text)
-- TODO: Check if attributes are valid
-- Check for version (mandatory)
if tag.attrs and tag.attrs.version == nil then
err(self, self._errstr.declAttrErr, f.pos)
end
if fexists(self.handler, 'decl') then
self.handler:decl(tag, f.match, f.endMatch)
end
return tag
end
local function parseXmlProcessingInstruction(self, xml, f)
local tag = {}
-- XML Processing Instruction (PI)
f.match, f.endMatch, f.text = string.find(xml, self._PI, f.pos)
if not f.match then
err(self, self._errstr.piErr, f.pos)
end
if fexists(self.handler, 'pi') then
-- Parse PI attributes & text
tag = parseTag(self, f.text)
local pi = string.sub(f.text, string.len(tag.name)+1)
if pi ~= "" then
if tag.attrs then
tag.attrs._text = pi
else
tag.attrs = { _text = pi }
end
end
self.handler:pi(tag, f.match, f.endMatch)
end
return tag
end
local function parseComment(self, xml, f)
f.match, f.endMatch, f.text = string.find(xml, self._COMMENT, f.pos)
if not f.match then
err(self, self._errstr.commentErr, f.pos)
end
if fexists(self.handler, 'comment') then
f.text = parseEntities(self, stripWS(self, f.text))
self.handler:comment(f.text, next, f.match, f.endMatch)
end
end
local function _parseDtd(self, xml, pos)
-- match,endMatch,root,type,name,uri,internal
local dtdPatterns = {self._DTD1, self._DTD2, self._DTD3, self._DTD4, self._DTD5}
for i, dtd in pairs(dtdPatterns) do
local m,e,r,t,n,u,i = string.find(xml, dtd, pos)
if m then
return m, e, {_root=r, _type=t, _name=n, _uri=u, _internal=i}
end
end
return nil
end
local function parseDtd(self, xml, f)
f.match, f.endMatch, attrs = _parseDtd(self, xml, f.pos)
if not f.match then
err(self, self._errstr.dtdErr, f.pos)
end
if fexists(self.handler, 'dtd') then
local tag = {name="DOCTYPE", value=string.sub(xml, f.match+10, f.endMatch-1)}
self.handler:dtd(tag, f.match, f.endMatch)
end
end
local function parseCdata(self, xml, f)
f.match, f.endMatch, f.text = string.find(xml, self._CDATA, f.pos)
if not f.match then
err(self, self._errstr.cdataErr, f.pos)
end
if fexists(self.handler, 'cdata') then
self.handler:cdata(f.text, nil, f.match, f.endMatch)
end
end
--- Parse a Normal tag
-- Need check for embedded '>' in attribute value and extend
-- match recursively if necessary eg. <tag attr="123>456">
local function parseNormalTag(self, xml, f)
--Check for errors
while 1 do
--If there isn't an attribute without closing quotes (single or double quotes)
--then breaks to follow the normal processing of the tag.
--Otherwise, try to find where the quotes close.
f.errStart, f.errEnd = string.find(f.tagstr, self._ATTRERR1)
if f.errEnd == nil then
f.errStart, f.errEnd = string.find(f.tagstr, self._ATTRERR2)
if f.errEnd == nil then
break
end
end
f.extStart, f.extEnd, f.endt2 = string.find(xml, self._TAGEXT, f.endMatch+1)
f.tagstr = f.tagstr .. string.sub(xml, f.endMatch, f.extEnd-1)
if not f.match then
err(self, self._errstr.xmlErr, f.pos)
end
f.endMatch = f.extEnd
end
-- Extract tag name and attrs
local tag = parseTag(self, f.tagstr)
if (f.endt1=="/") then
if fexists(self.handler, 'endtag') then
if tag.attrs then
-- Shouldn't have any attributes in endtag
err(self, string.format("%s (/%s)", self._errstr.endTagErr, tag.name), f.pos)
end
if table.remove(self._stack) ~= tag.name then
err(self, string.format("%s (/%s)", self._errstr.unmatchedTagErr, tag.name), f.pos)
end
self.handler:endtag(tag, f.match, f.endMatch)
end
else
table.insert(self._stack, tag.name)
if fexists(self.handler, 'starttag') then
self.handler:starttag(tag, f.match, f.endMatch)
end
--TODO: Tags com fechamento automático estão sendo
--retornadas como uma tabela, o que complica
--para a app NCLua tratar isso. É preciso
--fazer com que seja retornado um campo string vazio.
-- Self-Closing Tag
if (f.endt2=="/") then
table.remove(self._stack)
if fexists(self.handler, 'endtag') then
self.handler:endtag(tag, f.match, f.endMatch)
end
end
end
return tag
end
local function parseTagType(self, xml, f)
-- Test for tag type
if string.find(string.sub(f.tagstr, 1, 5), "?xml%s") then
parseXmlDeclaration(self, xml, f)
elseif string.sub(f.tagstr, 1, 1) == "?" then
parseXmlProcessingInstruction(self, xml, f)
elseif string.sub(f.tagstr, 1, 3) == "!--" then
parseComment(self, xml, f)
elseif string.sub(f.tagstr, 1, 8) == "!DOCTYPE" then
parseDtd(self, xml, f)
elseif string.sub(f.tagstr, 1, 8) == "![CDATA[" then
parseCdata(self, xml, f)
else
parseNormalTag(self, xml, f)
end
end
--- Get next tag (first pass - fix exceptions below).
--@return true if the next tag could be got, false otherwise
local function getNextTag(self, xml, f)
f.match, f.endMatch, f.text, f.endt1, f.tagstr, f.endt2 = string.find(xml, self._XML, f.pos)
if not f.match then
if string.find(xml, self._WS, f.pos) then
-- No more text - check document complete
if #self._stack ~= 0 then
err(self, self._errstr.incompleteXmlErr, f.pos)
else
return false
end
else
-- Unparsable text
err(self, self._errstr.xmlErr, f.pos)
end
end
f.text = f.text or ''
f.tagstr = f.tagstr or ''
f.match = f.match or 0
return f.endMatch ~= nil
end
--Main function which starts the XML parsing process
--@param xml the XML string to parse
--@param parseAttributes indicates if tag attributes should be parsed or not.
-- If omitted, the default value is true.
function XmlParser:parse(xml, parseAttributes)
if type(self) ~= "table" or getmetatable(self) ~= XmlParser then
error("You must call xmlparser:parse(parameters) instead of xmlparser.parse(parameters)")
end
if parseAttributes == nil then
parseAttributes = true
end
self.handler.parseAttributes = parseAttributes
--Stores string.find results and parameters
--and other auxiliar variables
local f = {
--string.find return
match = 0,
endMatch = 0,
-- text, end1, tagstr, end2,
--string.find parameters and auxiliar variables
pos = 1,
-- startText, endText,
-- errStart, errEnd, extStart, extEnd,
}
while f.match do
if not getNextTag(self, xml, f) then
break
end
-- Handle leading text
f.startText = f.match
f.endText = f.match + string.len(f.text) - 1
f.match = f.match + string.len(f.text)
f.text = parseEntities(self, stripWS(self, f.text))
if f.text ~= "" and fexists(self.handler, 'text') then
self.handler:text(f.text, nil, f.match, f.endText)
end
parseTagType(self, xml, f)
f.pos = f.endMatch + 1
end
end
XmlParser.__index = XmlParser
return XmlParser
| mit |
rafael/kong | kong/resolver/handler.lua | 21 | 1037 | -- Kong resolver core-plugin
--
-- This core-plugin is executed before any other, and allows to map a Host header
-- to an API added to Kong. If the API was found, it will set the $backend_url variable
-- allowing nginx to proxy the request as defined in the nginx configuration.
--
-- Executions: 'access', 'header_filter'
local access = require "kong.resolver.access"
local BasePlugin = require "kong.plugins.base_plugin"
local certificate = require "kong.resolver.certificate"
local header_filter = require "kong.resolver.header_filter"
local ResolverHandler = BasePlugin:extend()
function ResolverHandler:new()
ResolverHandler.super.new(self, "resolver")
end
function ResolverHandler:access(conf)
ResolverHandler.super.access(self)
access.execute(conf)
end
function ResolverHandler:certificate(conf)
ResolverHandler.super.certificate(self)
certificate.execute(conf)
end
function ResolverHandler:header_filter(conf)
ResolverHandler.super.header_filter(self)
header_filter.execute(conf)
end
return ResolverHandler
| apache-2.0 |
MeshGeometry/Urho3D | bin/Data/LuaScripts/09_MultipleViewports.lua | 24 | 13081 | -- Multiple viewports example.
-- This sample demonstrates:
-- - Setting up two viewports with two separate cameras
-- - Adding post processing effects to a viewport's render path and toggling them
require "LuaScripts/Utilities/Sample"
local rearCameraNode = nil
function Start()
-- Execute the common startup for samples
SampleStart()
-- Create the scene content
CreateScene()
-- Create the UI content
CreateInstructions()
-- Setup the viewports for displaying the scene
SetupViewports()
-- Set the mouse mode to use in the sample
SampleInitMouseMode(MM_RELATIVE)
-- Hook up to the frame update and render post-update events
SubscribeToEvents()
end
function CreateScene()
scene_ = Scene()
-- Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
-- Also create a DebugRenderer component so that we can draw debug geometry
scene_:CreateComponent("Octree")
scene_:CreateComponent("DebugRenderer")
-- Create scene node & StaticModel component for showing a static plane
local planeNode = scene_:CreateChild("Plane")
planeNode.scale = Vector3(100.0, 1.0, 100.0)
local planeObject = planeNode:CreateComponent("StaticModel")
planeObject.model = cache:GetResource("Model", "Models/Plane.mdl")
planeObject.material = cache:GetResource("Material", "Materials/StoneTiled.xml")
-- Create a Zone component for ambient lighting & fog control
local zoneNode = scene_:CreateChild("Zone")
local zone = zoneNode:CreateComponent("Zone")
zone.boundingBox = BoundingBox(-1000.0, 1000.0)
zone.ambientColor = Color(0.15, 0.15, 0.15)
zone.fogColor = Color(0.5, 0.5, 0.7)
zone.fogStart = 100.0
zone.fogEnd = 300.0
-- Create a directional light to the world. Enable cascaded shadows on it
local lightNode = scene_:CreateChild("DirectionalLight")
lightNode.direction = Vector3(0.6, -1.0, 0.8)
local light = lightNode:CreateComponent("Light")
light.lightType = LIGHT_DIRECTIONAL
light.castShadows = true
light.shadowBias = BiasParameters(0.00025, 0.5)
-- Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
light.shadowCascade = CascadeParameters(10.0, 50.0, 200.0, 0.0, 0.8)
-- Create some mushrooms
local NUM_MUSHROOMS = 240
for i = 1, NUM_MUSHROOMS do
local mushroomNode = scene_:CreateChild("Mushroom")
mushroomNode.position = Vector3(Random(90.0) - 45.0, 0.0, Random(90.0) - 45.0)
mushroomNode.rotation = Quaternion(0.0, Random(360.0), 0.0)
mushroomNode:SetScale(0.5 + Random(2.0))
local mushroomObject = mushroomNode:CreateComponent("StaticModel")
mushroomObject.model = cache:GetResource("Model", "Models/Mushroom.mdl")
mushroomObject.material = cache:GetResource("Material", "Materials/Mushroom.xml")
mushroomObject.castShadows = true
end
-- Create randomly sized boxes. If boxes are big enough, make them occluders. Occluders will be software rasterized before
-- rendering to a low-resolution depth-only buffer to test the objects in the view frustum for visibility
local NUM_BOXES = 20
for i = 1, NUM_BOXES do
local boxNode = scene_:CreateChild("Box")
local size = 1.0 + Random(10.0)
boxNode.position = Vector3(Random(80.0) - 40.0, size * 0.5, Random(80.0) - 40.0)
boxNode:SetScale(size)
local boxObject = boxNode:CreateComponent("StaticModel")
boxObject.model = cache:GetResource("Model", "Models/Box.mdl")
boxObject.material = cache:GetResource("Material", "Materials/Stone.xml")
boxObject.castShadows = true
if size >= 3.0 then
boxObject.occluder = true
end
end
-- Create the camera. Limit far clip distance to match the fog
cameraNode = scene_:CreateChild("Camera")
local camera = cameraNode:CreateComponent("Camera")
camera.farClip = 300.0
-- Parent the rear camera node to the front camera node and turn it 180 degrees to face backward
-- Here, we use the angle-axis constructor for Quaternion instead of the usual Euler angles
rearCameraNode = cameraNode:CreateChild("RearCamera")
rearCameraNode:Rotate(Quaternion(180.0, Vector3(0.0, 1.0, 0.0)))
local rearCamera = rearCameraNode:CreateComponent("Camera")
rearCamera.farClip = 300.0
-- Because the rear viewport is rather small, disable occlusion culling from it. Use the camera's
-- "view override flags" for this. We could also disable eg. shadows or force low material quality
-- if we wanted
rearCamera.viewOverrideFlags = VO_DISABLE_OCCLUSION
-- Set an initial position for the front camera scene node above the plane
cameraNode.position = Vector3(0.0, 5.0, 0.0)
end
function CreateInstructions()
-- Construct new Text object, set string to display and font to use
local instructionText = ui.root:CreateChild("Text")
instructionText.text =
"Use WASD keys and mouse to move\n"..
"B to toggle bloom, F to toggle FXAA\n"..
"Space to toggle debug geometry\n"
instructionText:SetFont(cache:GetResource("Font", "Fonts/Anonymous Pro.ttf"), 15)
-- The text has multiple rows. Center them in relation to each other
instructionText.textAlignment = HA_CENTER
-- Position the text relative to the screen center
instructionText.horizontalAlignment = HA_CENTER
instructionText.verticalAlignment = VA_CENTER
instructionText:SetPosition(0, ui.root.height / 4)
end
function SetupViewports()
renderer.numViewports = 2
-- Set up the front camera viewport
local viewport = Viewport:new(scene_, cameraNode:GetComponent("Camera"))
renderer:SetViewport(0, viewport)
-- Clone the default render path so that we do not interfere with the other viewport, then add
-- bloom and FXAA post process effects to the front viewport. Render path commands can be tagged
-- for example with the effect name to allow easy toggling on and off. We start with the effects
-- disabled.
local effectRenderPath = viewport:GetRenderPath():Clone()
effectRenderPath:Append(cache:GetResource("XMLFile", "PostProcess/Bloom.xml"))
effectRenderPath:Append(cache:GetResource("XMLFile", "PostProcess/FXAA2.xml"))
-- Make the bloom mixing parameter more pronounced
effectRenderPath:SetShaderParameter("BloomMix", Variant(Vector2(0.9, 0.6)))
effectRenderPath:SetEnabled("Bloom", false)
effectRenderPath:SetEnabled("FXAA2", false)
viewport:SetRenderPath(effectRenderPath)
-- Set up the rear camera viewport on top of the front view ("rear view mirror")
-- The viewport index must be greater in that case, otherwise the view would be left behind
local rearViewport = Viewport:new(scene_, rearCameraNode:GetComponent("Camera"),
IntRect(graphics.width * 2 / 3, 32, graphics.width - 32, graphics.height / 3))
renderer:SetViewport(1, rearViewport)
end
function SubscribeToEvents()
-- Subscribe HandleUpdate() function for processing update events
SubscribeToEvent("Update", "HandleUpdate")
-- Subscribe HandlePostRenderUpdate() function for processing the post-render update event, during which we request
-- debug geometry
SubscribeToEvent("PostRenderUpdate", "HandlePostRenderUpdate")
end
function MoveCamera(timeStep)
-- Do not move if the UI has a focused element (the console)
if ui.focusElement ~= nil then
return
end
-- Movement speed as world units per second
local MOVE_SPEED = 20.0
-- Mouse sensitivity as degrees per pixel
local MOUSE_SENSITIVITY = 0.1
-- Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
local mouseMove = input.mouseMove
yaw = yaw + MOUSE_SENSITIVITY * mouseMove.x
pitch = pitch + MOUSE_SENSITIVITY * mouseMove.y
pitch = Clamp(pitch, -90.0, 90.0)
-- Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
cameraNode.rotation = Quaternion(pitch, yaw, 0.0)
-- Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
if input:GetKeyDown(KEY_W) then
cameraNode:Translate(Vector3(0.0, 0.0, 1.0) * MOVE_SPEED * timeStep)
end
if input:GetKeyDown(KEY_S) then
cameraNode:Translate(Vector3(0.0, 0.0, -1.0) * MOVE_SPEED * timeStep)
end
if input:GetKeyDown(KEY_A) then
cameraNode:Translate(Vector3(-1.0, 0.0, 0.0) * MOVE_SPEED * timeStep)
end
if input:GetKeyDown(KEY_D) then
cameraNode:Translate(Vector3(1.0, 0.0, 0.0) * MOVE_SPEED * timeStep)
end
-- Toggle post processing effects on the front viewport. Note that the rear viewport is unaffected
local effectRenderPath = renderer:GetViewport(0).renderPath
if input:GetKeyPress(KEY_B) then
effectRenderPath:ToggleEnabled("Bloom")
end
if input:GetKeyPress(KEY_F) then
effectRenderPath:ToggleEnabled("FXAA2")
end
-- Toggle debug geometry with space
if input:GetKeyPress(KEY_SPACE) then
drawDebug = not drawDebug
end
end
function HandleUpdate(eventType, eventData)
-- Take the frame time step, which is stored as a float
local timeStep = eventData["TimeStep"]:GetFloat()
-- Move the camera, scale movement with time step
MoveCamera(timeStep)
end
function HandlePostRenderUpdate(eventType, eventData)
-- If draw debug mode is enabled, draw viewport debug geometry. Disable depth test so that we can see the effect of occlusion
if drawDebug then
renderer:DrawDebugGeometry(false)
end
end
-- Create XML patch instructions for screen joystick layout specific to this sample app
function GetScreenJoystickPatchString()
return
"<patch>" ..
" <add sel=\"/element\">" ..
" <element type=\"Button\">" ..
" <attribute name=\"Name\" value=\"Button3\" />" ..
" <attribute name=\"Position\" value=\"-120 -120\" />" ..
" <attribute name=\"Size\" value=\"96 96\" />" ..
" <attribute name=\"Horiz Alignment\" value=\"Right\" />" ..
" <attribute name=\"Vert Alignment\" value=\"Bottom\" />" ..
" <attribute name=\"Texture\" value=\"Texture2D;Textures/TouchInput.png\" />" ..
" <attribute name=\"Image Rect\" value=\"96 0 192 96\" />" ..
" <attribute name=\"Hover Image Offset\" value=\"0 0\" />" ..
" <attribute name=\"Pressed Image Offset\" value=\"0 0\" />" ..
" <element type=\"Text\">" ..
" <attribute name=\"Name\" value=\"Label\" />" ..
" <attribute name=\"Horiz Alignment\" value=\"Center\" />" ..
" <attribute name=\"Vert Alignment\" value=\"Center\" />" ..
" <attribute name=\"Color\" value=\"0 0 0 1\" />" ..
" <attribute name=\"Text\" value=\"FXAA\" />" ..
" </element>" ..
" <element type=\"Text\">" ..
" <attribute name=\"Name\" value=\"KeyBinding\" />" ..
" <attribute name=\"Text\" value=\"F\" />" ..
" </element>" ..
" </element>" ..
" </add>" ..
" <remove sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]/attribute[@name='Is Visible']\" />" ..
" <replace sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]/element[./attribute[@name='Name' and @value='Label']]/attribute[@name='Text']/@value\">Bloom</replace>" ..
" <add sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]\">" ..
" <element type=\"Text\">" ..
" <attribute name=\"Name\" value=\"KeyBinding\" />" ..
" <attribute name=\"Text\" value=\"B\" />" ..
" </element>" ..
" </add>" ..
" <remove sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/attribute[@name='Is Visible']\" />" ..
" <replace sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/element[./attribute[@name='Name' and @value='Label']]/attribute[@name='Text']/@value\">Debug</replace>" ..
" <add sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]\">" ..
" <element type=\"Text\">" ..
" <attribute name=\"Name\" value=\"KeyBinding\" />" ..
" <attribute name=\"Text\" value=\"SPACE\" />" ..
" </element>" ..
" </add>" ..
"</patch>"
end
| mit |
qiuxin2012/BigDL | spark/dl/src/test/resources/torch/genPreprocessRefTensors.lua | 13 | 1904 | --
-- Copyright 2016 The BigDL Authors.
--
-- 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.
--
-- This script can generate some tensor files from torch preprocess, which
-- can be used in bigdl test
--
require 'image'
local function loadImage(path)
local input = image.load(path, 3, 'float')
return input
end
local function norm(out, mean, std)
for i = 1, 3 do -- channels
if mean then out[{ { i }, {}, {} }]:add(-mean[i]) end
if std then out[{ { i }, {}, {} }]:div(std[i]) end
end
return out
end
local function crop(img, oH, oW)
local iW = img:size(3)
local iH = img:size(2)
local h1 = math.ceil(torch.uniform(1e-2, iH - oH))
local w1 = math.ceil(torch.uniform(1e-2, iW - oW))
local out = image.crop(img, w1, h1, w1 + oW, h1 + oH)
return out
end
local function preprocess(source, target)
local img = loadImage(source)
img = crop(img, 224, 224)
img = image.hflip(img)
norm(img, { 0.4, 0.5, 0.6 }, { 0.1, 0.2, 0.3 })
torch.save(target, img)
end
torch.manualSeed(100)
preprocess('n02110063/n02110063_11239.JPEG', 'torch/n02110063_11239.t7')
torch.manualSeed(100)
preprocess('n04370456/n04370456_5753.JPEG', 'torch/n04370456_5753.t7')
torch.manualSeed(100)
preprocess('n15075141/n15075141_38508.JPEG', 'torch/n15075141_38508.t7')
torch.manualSeed(100)
preprocess('n99999999/n03000134_4970.JPEG', 'torch/n03000134_4970.t7')
| apache-2.0 |
hussian1997/hhhuu | plugins/APICLI.lua | 8 | 1774 | --[[
▀▄ ▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀
▀▄ ▄▀ ▀▄ ▄▀
▀▄ ▄▀ BY(@AHMED_ALOBIDE) ▀▄ ▄▀
▀▄ ▄▀ BY(@hussian_9) ▀▄ ▄▀
▀▄ ▄▀ ▀▄ ▄▀
▀▄ ▄▀ (ملف اشعار او خواطر) ▀▄ ▄▀
▀▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀
--]]
local function run(msg, matches)
if matches[1] == "خواطر" then
if msg.to.type == 'channel' or 'chat' then
local answers = {'رسالة لـ ميت 💭\nكان وجع 💔 رحيلك عظيم\n كان اعظم من ان يتحملهُ البكاء 😪\n\n@API_CLI',' على الرغم من كوني وحيداً ..\nإلا أنني أحياناً أشعرُ بالوحدة !\n\n @API_CLI','ِوإذا كآنت الغيرةة تُضايقكِ ،\nفلآآ داعي أن يكون حبيبكِ شرقيآ !\n\n @API_CLI','لو رأيت الكل يمشـي عكسك ، لا تتردد ، امشي حتّى لو أصبحت وحيدًا ..فالوحدة خير من أن تعيش عكس نفسك لإرضاء غيرك .','الكبرياء أن تقول لا شيءَ يحدثْ .. وكل الأشياء تحدثُ بداخلك','لكن كعادة إنسانية متآصلة فينا.. نعتاد الحزن أسرع من أي شيء آخر!!'}
return answers[math.random(#answers)]
end
end
end
return {
description = "Chat With Robot Server",
usage = "chat with robot",
patterns = {
"^خواطر$"
},
run = run
}
| agpl-3.0 |
jenisteam/AghayeKhas | plugins/plugins.lua | 1 | 7870 | do
local function plugin_enabled( name )
for k,v in pairs(_config.enabled_plugins) do
if name == v then
return k
end
end
-- If not found
return false
end
-- Returns true if file exists in plugins folder
local function plugin_exists( name )
for k,v in pairs(plugins_names()) do
if name..'.lua' == v then
return true
end
end
return false
end
local function list_all_plugins(only_enabled, msg)
local tmp = '\n'..BDRpm
local text = ''
local nsum = 0
for k, v in pairs( plugins_names( )) do
-- ✅ enabled, ❌ disabled
local status = '❌'
nsum = nsum+1
nact = 0
-- Check if is enabled
for k2, v2 in pairs(_config.enabled_plugins) do
if v == v2..'.lua' then
status = '✅'
end
nact = nact+1
end
if not only_enabled or status == '✅'then
-- get the name
v = string.match (v, "(.*)%.lua")
text = text..nsum..'.'..status..' '..v..' \n'
end
end
text = text..'\n•• تعداد پلاگ های نصب شده : [ '..nsum..' ] عدد 💠\n\n•• تعداد پلاگین فعال✅ : [ '..nact..' ] عدد\n\n•• اعداد پلاگین غیرفعال❌ : [ '..nsum-nact..' ] عدد'
tdcli.sendMessage(msg.to.id, msg.id_, 1, text, 1, 'html')
end
local function list_plugins(only_enabled, msg)
local text = ''
local nsum = 0
for k, v in pairs( plugins_names( )) do
-- ✅ enabled, ❌ disabled
local status = '❌'
nsum = nsum+1
nact = 0
-- Check if is enabled
for k2, v2 in pairs(_config.enabled_plugins) do
if v == v2..'.lua' then
status = '✅'
end
nact = nact+1
end
if not only_enabled or status == '✅'then
-- get the name
v = string.match (v, "(.*)%.lua")
-- text = text..v..' '..status..'\n'
end
end
text = "•• انجام شد 💠\n•• ربات با موفقیت بروزرسانی شد !\n\n➖➖➖➖➖➖➖➖➖➖➖\n\n•• تعداد پلاگین فعال [ "..nact.." ] عدد !\n•• تعداد پلاگین نصب شده [ "..nsum.." ] عدد !"
tdcli.sendMessage(msg.to.id, msg.id_, 1, text, 1, 'md')
end
local function reload_plugins(checks, msg)
plugins = {}
load_plugins()
return list_plugins(true, msg)
end
local function enable_plugin( plugin_name, msg )
print('checking if '..plugin_name..' exists')
-- Check if plugin is enabled
if plugin_enabled(plugin_name) then
local text = '<b>'..plugin_name..'</b> فعال است'
tdcli.sendMessage(msg.to.id, msg.id_, 1, text, 1, 'html')
return
end
-- Checks if plugin exists
if plugin_exists(plugin_name) then
-- Add to the config table
table.insert(_config.enabled_plugins, plugin_name)
print(plugin_name..' added to _config table')
save_config()
-- Reload the plugins
return reload_plugins(true, msg)
else
local text = '<b>'..plugin_name..'</b> وجود ندارد'
tdcli.sendMessage(msg.to.id, msg.id_, 1, text, 1, 'html')
end
end
local function disable_plugin( name, msg )
local k = plugin_enabled(name)
-- Check if plugin is enabled
if not k then
local text = '<b>'..name..'</b> فعال نیست'
tdcli.sendMessage(msg.to.id, msg.id_, 1, text, 1, 'html')
return
end
-- Check if plugins exists
if not plugin_exists(name) then
local text = '<b>'..name..'</b> وجود ندارد'
tdcli.sendMessage(msg.to.id, msg.id_, 1, text, 1, 'html')
else
-- Disable and reload
table.remove(_config.enabled_plugins, k)
save_config( )
return reload_plugins(true, msg)
end
end
local function disable_plugin_on_chat(receiver, plugin, msg)
if not plugin_exists(plugin) then
return "_Plugin doesn't exists_"
end
if not _config.disabled_plugin_on_chat then
_config.disabled_plugin_on_chat = {}
end
if not _config.disabled_plugin_on_chat[receiver] then
_config.disabled_plugin_on_chat[receiver] = {}
end
_config.disabled_plugin_on_chat[receiver][plugin] = true
save_config()
local text = '<b>'..plugin..'</b> <i>disabled on this chat.</i>'
tdcli.sendMessage(msg.to.id, msg.id_, 1, text, 1, 'html')
end
local function reenable_plugin_on_chat(receiver, plugin, msg)
if not _config.disabled_plugin_on_chat then
return 'There aren\'t any disabled plugins'
end
if not _config.disabled_plugin_on_chat[receiver] then
return 'There aren\'t any disabled plugins for this chat'
end
if not _config.disabled_plugin_on_chat[receiver][plugin] then
return '_This plugin is not disabled_'
end
_config.disabled_plugin_on_chat[receiver][plugin] = false
save_config()
local text = '<b>'..plugin..'</b> <i>is enabled again.</i>'
tdcli.sendMessage(msg.to.id, msg.id_, 1, text, 1, 'html')
end
local function run(msg, matches)
-- Show the available plugins
if is_sudo(msg) then
if (matches[1]:lower() == 'plist' or matches[1] == 'لیست پلاگین') then --after changed to moderator mode, set only sudo
return list_all_plugins(false, msg)
end
end
-- Re-enable a plugin for this chat
if matches[1]:lower() == 'pl' or matches[1] == 'پلاگین' then
if matches[2] == '+' and matches[4] == 'chat' or matches[4] == 'گروه' then
if is_mod(msg) then
local receiver = msg.chat_id_
local plugin = matches[3]
print("enable "..plugin..' on this chat')
return reenable_plugin_on_chat(receiver, plugin, msg)
end
end
-- Enable a plugin
if matches[2] == '+' and is_sudo(msg) then --after changed to moderator mode, set only sudo
local plugin_name = matches[3]
print("enable: "..matches[3])
return enable_plugin(plugin_name, msg)
end
-- Disable a plugin on a chat
if matches[2] == '-' and matches[4] == 'chat' or matches[4] == 'گروه' then
if is_mod(msg) then
local plugin = matches[3]
local receiver = msg.chat_id_
print("disable "..plugin..' on this chat')
return disable_plugin_on_chat(receiver, plugin, msg)
end
end
-- Disable a plugin
if matches[2] == '-' and is_sudo(msg) then --after changed to moderator mode, set only sudo
if matches[3] == 'plugins' then
return 'This plugin can\'t be disabled'
end
print("disable: "..matches[3])
return disable_plugin(matches[3], msg)
end
-- Reload all the plugins!
if matches[2] == '*' and is_sudo(msg) then --after changed to moderator mode, set only sudo
return reload_plugins(true, msg)
end
end
if (matches[1]:lower() == 'reload' or matches[1] == 'ریلود') and is_sudo(msg) then --after changed to moderator mode, set only sudo
return reload_plugins(true, msg)
end
end
return {
description = "Plugin to manage other plugins. Enable, disable or reload.",
usage = {
moderator = {
"!pl - [plugin] chat : disable plugin only this chat.",
"!pl + [plugin] chat : enable plugin only this chat.",
},
sudo = {
"!plist : list all plugins.",
"!pl + [plugin] : enable plugin.",
"!pl - [plugin] : disable plugin.",
"!pl * : reloads all plugins." },
},
patterns = {
command .. "([Pp]list)$",
command .. "([Pp]l) (+) ([%w_%.%-]+)$",
command .. "([Pp]l) (-) ([%w_%.%-]+)$",
command .. "([Pp]l) (+) ([%w_%.%-]+) (chat)$",
command .. "([Pp]l) (-) ([%w_%.%-]+) (chat)$",
command .. "([Pp]l) (*)$",
command .. "([Rr]eload)$",
"^([Pp]list)$",
"^([Pp]l) (+) ([%w_%.%-]+)$",
"^([Pp]l) (-) ([%w_%.%-]+)$",
"^([Pp]l) (+) ([%w_%.%-]+) (chat)$",
"^([Pp]l) (-) ([%w_%.%-]+) (chat)$",
"^([Pp]l) (*)$",
"^([Rr]eload)$"
},
patterns_fa = {
"^(ریلود)$",
"^(لیست پلاگین)$",
"^(پلاگین) (+) ([%w_%.%-]+)$",
"^(پلاگین) (+) ([%w_%.%-]+)$",
"^(پلاگین) (+) ([%w_%.%-]+) (گروه)$",
"^(پلاگین) (+) ([%w_%.%-]+) (گروه)$",
},
run = run,
moderated = true, -- set to moderator mode
privileged = true
}
end | gpl-3.0 |
CarabusX/Zero-K | effects/unused_chloe.lua | 25 | 1910 | -- chloe
return {
["chloe"] = {
glow = {
air = true,
class = [[CSimpleParticleSystem]],
count = 20,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[1 0.5 0 1 1 1 0.5 1 0.3 0.3 0.3 0 0 0 0 0.01 ]],
directional = true,
emitrot = 0,
emitrotspread = 90,
emitvector = [[0, 1, 0]],
gravity = [[0, 0.0005, 0]],
numparticles = 1,
particlelife = [[5 i5]],
particlelifespread = 10,
particlesize = 3,
particlesizespread = 0,
particlespeed = 0.1,
particlespeedspread = 0.1,
pos = [[0, 0, 0]],
sizegrowth = [[3 i-0.04]],
sizemod = 1.0,
texture = [[ksquareblur]],
},
},
meteors = {
air = true,
class = [[CSimpleParticleSystem]],
count = 20,
ground = true,
water = true,
properties = {
airdrag = 1,
colormap = [[1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0.01 ]],
directional = true,
emitrot = 0,
emitrotspread = 90,
emitvector = [[0, 1, 0]],
gravity = [[0, 0, 0]],
numparticles = 1,
particlelife = 40,
particlelifespread = 1,
particlesize = 2,
particlesizespread = 2,
particlespeed = 2,
particlespeedspread = 0,
pos = [[0, 0, 0]],
sizegrowth = 0,
sizemod = 1.0,
texture = [[kthinmeteor]],
},
},
},
}
| gpl-2.0 |
TideSofDarK/DotaCraft | game/dota_addons/dotacraft/scripts/vscripts/heroes/tauren_chieftain/reincarnation.lua | 1 | 3879 | --[[Author: Noya
Date: 12.01.2015.
Attempts to reincarnate the target if the caster has enough mana and ability is not on cooldown
For the respawn time if you use any custom rule you'll have to change it.
Bug: can't reduce death count. However, all the other interactions should be correct (gold/xp/messages)
Note: Warcraft 3 Heroes don't have a respawn time. We'll have to review this spell later
]]
function Reincarnation( event )
local caster = event.caster
local attacker = event.attacker
local ability = event.ability
local cooldown = ability:GetCooldown(ability:GetLevel() - 1)
local casterHP = caster:GetHealth()
local casterMana = caster:GetMana()
local abilityManaCost = ability:GetManaCost( ability:GetLevel() - 1 )
-- Change it to your game needs
local respawnTimeFormula = caster:GetLevel() * 4
if casterHP == 0 and ability:IsCooldownReady() and casterMana >= abilityManaCost then
print("Reincarnate")
-- Variables for Reincarnation
local reincarnate_time = ability:GetLevelSpecialValueFor( "reincarnate_time", ability:GetLevel() - 1 )
local casterGold = caster:GetGold()
local respawnPosition = caster:GetAbsOrigin()
-- Start cooldown on the passive
ability:StartCooldown(cooldown)
-- Kill, counts as death for the player but doesn't count the kill for the killer unit
caster:SetHealth(1)
caster:Kill(caster, nil)
-- Set the gold back
caster:SetGold(casterGold, false)
-- Set the short respawn time and respawn position
caster:SetTimeUntilRespawn(reincarnate_time)
caster:SetRespawnPosition(respawnPosition)
-- Particle
local particleName = "particles/units/heroes/hero_skeletonking/wraith_king_reincarnate.vpcf"
caster.ReincarnateParticle = ParticleManager:CreateParticle( particleName, PATTACH_ABSORIGIN_FOLLOW, caster )
ParticleManager:SetParticleControl(caster.ReincarnateParticle, 0, respawnPosition)
ParticleManager:SetParticleControl(caster.ReincarnateParticle, 1, Vector(500,0,0))
ParticleManager:SetParticleControl(caster.ReincarnateParticle, 1, Vector(500,500,0))
-- End Particle after reincarnating
Timers:CreateTimer(reincarnate_time, function()
ParticleManager:DestroyParticle(caster.ReincarnateParticle, false)
end)
-- Grave and rock particles
-- The parent "particles/units/heroes/hero_skeletonking/skeleton_king_death.vpcf" misses the grave model
local model = "models/props_gameplay/tombstoneb01.vmdl"
local grave = Entities:CreateByClassname("prop_dynamic")
grave:SetModel(model)
grave:SetAbsOrigin(respawnPosition)
local particleName = "particles/units/heroes/hero_skeletonking/skeleton_king_death_bits.vpcf"
local particle1 = ParticleManager:CreateParticle( particleName, PATTACH_ABSORIGIN, caster )
ParticleManager:SetParticleControl(particle1, 0, respawnPosition)
local particleName = "particles/units/heroes/hero_skeletonking/skeleton_king_death_dust.vpcf"
local particle2 = ParticleManager:CreateParticle( particleName, PATTACH_ABSORIGIN_FOLLOW, caster )
ParticleManager:SetParticleControl(particle2, 0, respawnPosition)
local particleName = "particles/units/heroes/hero_skeletonking/skeleton_king_death_dust_reincarnate.vpcf"
local particle3 = ParticleManager:CreateParticle( particleName, PATTACH_ABSORIGIN_FOLLOW, caster )
ParticleManager:SetParticleControl(particle3 , 0, respawnPosition)
-- End grave after reincarnating
Timers:CreateTimer(reincarnate_time, function() grave:RemoveSelf() end)
-- Sounds
caster:EmitSound("Hero_SkeletonKing.Reincarnate")
caster:EmitSound("Hero_SkeletonKing.Death")
Timers:CreateTimer(reincarnate_time, function()
caster:EmitSound("Hero_SkeletonKing.Reincarnate.Stinger")
end)
elseif casterHP == 0 then
-- On Death without reincarnation, set the respawn time to the respawn time formula
caster:SetTimeUntilRespawn(respawnTimeFormula)
end
end
| gpl-3.0 |
mattyx14/otxserver | data/monster/quests/svargrond_arena/warlord/deathbringer.lua | 2 | 2935 | local mType = Game.createMonsterType("Deathbringer")
local monster = {}
monster.description = "Deathbringer"
monster.experience = 5100
monster.outfit = {
lookType = 231,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.health = 8440
monster.maxHealth = 8440
monster.race = "undead"
monster.corpse = 7349
monster.speed = 300
monster.manaCost = 0
monster.changeTarget = {
interval = 0,
chance = 0
}
monster.strategiesTarget = {
nearest = 70,
health = 10,
damage = 10,
random = 10,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = false,
staticAttackChance = 95,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "YOU FOOLS WILL PAY!", yell = true},
{text = "YOU ALL WILL DIE!!", yell = true},
{text = "DEATH, DESTRUCTION!", yell = true},
{text = "I will eat your soul!", yell = false}
}
monster.loot = {
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -465},
{name ="combat", interval = 1000, chance = 10, type = COMBAT_FIREDAMAGE, minDamage = -80, maxDamage = -120, range = 7, radius = 4, shootEffect = CONST_ANI_FIRE, target = true},
{name ="combat", interval = 3000, chance = 17, type = COMBAT_FIREDAMAGE, minDamage = -300, maxDamage = -450, length = 8, spread = 3, effect = CONST_ME_FIREAREA, target = false},
{name ="combat", interval = 2000, chance = 12, type = COMBAT_EARTHDAMAGE, minDamage = -300, maxDamage = -450, length = 8, spread = 3, effect = CONST_ME_POISONAREA, target = false},
{name ="combat", interval = 2000, chance = 10, type = COMBAT_LIFEDRAIN, minDamage = -80, maxDamage = -100, radius = 6, effect = CONST_ME_POFF, target = false},
{name ="combat", interval = 3000, chance = 25, type = COMBAT_LIFEDRAIN, minDamage = -80, maxDamage = -150, range = 7, effect = CONST_ME_MAGIC_RED, target = false}
}
monster.defenses = {
defense = 15,
armor = 15
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = 10},
{type = COMBAT_EARTHDAMAGE, percent = 100},
{type = COMBAT_FIREDAMAGE, percent = 100},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 100},
{type = COMBAT_HOLYDAMAGE , percent = -15},
{type = COMBAT_DEATHDAMAGE , percent = 100}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = true},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
mattyx14/otxserver | data/monster/mammals/enraged_white_deer.lua | 2 | 2326 | local mType = Game.createMonsterType("Enraged White Deer")
local monster = {}
monster.description = "an enraged white deer"
monster.experience = 165
monster.outfit = {
lookType = 400,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.health = 255
monster.maxHealth = 255
monster.race = "blood"
monster.corpse = 12524
monster.speed = 210
monster.manaCost = 0
monster.changeTarget = {
interval = 5000,
chance = 0
}
monster.strategiesTarget = {
nearest = 100,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = true,
rewardBoss = false,
illusionable = true,
canPushItems = false,
canPushCreatures = false,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.events = {
"WhiteDeerScoutsDeath"
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "*wheeze*", yell = false},
{text = "ROOOAAARR!!", yell = false},
{text = "*sniff*", yell = false},
{text = "*bell*", yell = false}
}
monster.loot = {
{name = "ham", chance = 19850, maxCount = 3},
{name = "white deer antlers", chance = 19520},
{name = "white deer skin", chance = 20280}
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -45}
}
monster.defenses = {
defense = 15,
armor = 15,
{name ="combat", interval = 4000, chance = 15, type = COMBAT_HEALING, minDamage = 10, maxDamage = 40, effect = CONST_ME_MAGIC_BLUE, target = false}
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = 0},
{type = COMBAT_EARTHDAMAGE, percent = 0},
{type = COMBAT_FIREDAMAGE, percent = 0},
{type = COMBAT_LIFEDRAIN, percent = 0},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 0},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = false},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
garrysmodlua/wire | lua/autorun/wire_load.lua | 3 | 5041 | --[[
Copyright 2013 Wiremod Developers
https://github.com/wiremod/
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.
]]--
if VERSION < 140403 and VERSION > 5 then
-- VERSION > 5 check added June 2013, to address issues regarding the Steampipe update sometimes setting VERSION to 1.
ErrorNoHalt("WireMod: This branch of wiremod only supports Gmod13+.\n")
return
end
if SERVER then
-- this file
AddCSLuaFile("autorun/wire_load.lua")
-- shared includes
AddCSLuaFile("wire/wire_paths.lua")
AddCSLuaFile("wire/wireshared.lua")
AddCSLuaFile("wire/wiregates.lua")
AddCSLuaFile("wire/wiremonitors.lua")
AddCSLuaFile("wire/gpulib.lua")
AddCSLuaFile("wire/cpulib.lua")
AddCSLuaFile("wire/timedpairs.lua")
AddCSLuaFile("wire/default_data_decompressor.lua")
AddCSLuaFile("wire/flir.lua")
AddCSLuaFile("wire/von.lua")
-- client includes
AddCSLuaFile("wire/client/cl_wirelib.lua")
AddCSLuaFile("wire/client/cl_modelplug.lua")
AddCSLuaFile("wire/client/cl_wire_map_interface.lua")
AddCSLuaFile("wire/client/wiredermaexts.lua")
AddCSLuaFile("wire/client/wiremenus.lua")
AddCSLuaFile("wire/client/wire_expression2_browser.lua")
AddCSLuaFile("wire/client/wire_filebrowser.lua")
AddCSLuaFile("wire/client/wire_listeditor.lua")
AddCSLuaFile("wire/client/wire_soundpropertylist.lua")
AddCSLuaFile("wire/client/e2helper.lua")
AddCSLuaFile("wire/client/e2descriptions.lua")
AddCSLuaFile("wire/client/e2_extension_menu.lua")
AddCSLuaFile("wire/client/gmod_tool_auto.lua")
AddCSLuaFile("wire/client/sound_browser.lua")
AddCSLuaFile("wire/client/thrusterlib.lua")
AddCSLuaFile("wire/client/rendertarget_fix.lua")
AddCSLuaFile("wire/client/customspawnmenu.lua")
-- text editor
AddCSLuaFile("wire/client/text_editor/texteditor.lua")
AddCSLuaFile("wire/client/text_editor/wire_expression2_editor.lua")
AddCSLuaFile("wire/client/text_editor/modes/e2.lua")
AddCSLuaFile("wire/client/text_editor/modes/zcpu.lua")
-- HL-ZASM
AddCSLuaFile("wire/client/hlzasm/hc_compiler.lua")
AddCSLuaFile("wire/client/hlzasm/hc_opcodes.lua")
AddCSLuaFile("wire/client/hlzasm/hc_expression.lua")
AddCSLuaFile("wire/client/hlzasm/hc_preprocess.lua")
AddCSLuaFile("wire/client/hlzasm/hc_syntax.lua")
AddCSLuaFile("wire/client/hlzasm/hc_codetree.lua")
AddCSLuaFile("wire/client/hlzasm/hc_optimize.lua")
AddCSLuaFile("wire/client/hlzasm/hc_output.lua")
AddCSLuaFile("wire/client/hlzasm/hc_tokenizer.lua")
-- ZVM
AddCSLuaFile("wire/zvm/zvm_core.lua")
AddCSLuaFile("wire/zvm/zvm_features.lua")
AddCSLuaFile("wire/zvm/zvm_opcodes.lua")
AddCSLuaFile("wire/zvm/zvm_data.lua")
if CreateConVar("wire_force_workshop", 1, {FCVAR_ARCHIVE}, "Should Wire force all clients to download the Workshop edition of Wire, for models? (requires restart to disable)"):GetBool() then
resource.AddWorkshop("160250458")
end
end
-- shared includes
include("wire/wireshared.lua")
include("wire/wire_paths.lua")
include("wire/wiregates.lua")
include("wire/wiremonitors.lua")
include("wire/gpulib.lua")
include("wire/cpulib.lua")
include("wire/timedpairs.lua")
include("wire/default_data_decompressor.lua")
include("wire/flir.lua")
include("wire/von.lua")
-- server includes
if SERVER then
include("wire/server/wirelib.lua")
include("wire/server/modelplug.lua")
include("wire/server/radiolib.lua")
include("wire/server/debuggerlib.lua")
end
-- client includes
if CLIENT then
include("wire/client/cl_wirelib.lua")
include("wire/client/cl_modelplug.lua")
include("wire/client/cl_wire_map_interface.lua")
include("wire/client/wiredermaexts.lua")
include("wire/client/wiremenus.lua")
include("wire/client/text_editor/texteditor.lua")
include("wire/client/wire_expression2_browser.lua")
include("wire/client/text_editor/wire_expression2_editor.lua")
include("wire/client/wire_filebrowser.lua")
include("wire/client/wire_listeditor.lua")
include("wire/client/wire_soundpropertylist.lua")
include("wire/client/e2helper.lua")
include("wire/client/e2descriptions.lua")
include("wire/client/e2_extension_menu.lua")
include("wire/client/gmod_tool_auto.lua")
include("wire/client/sound_browser.lua")
include("wire/client/thrusterlib.lua")
include("wire/client/rendertarget_fix.lua")
include("wire/client/hlzasm/hc_compiler.lua")
include("wire/client/customspawnmenu.lua")
end
-- Load UWSVN, done here so its definitely after Wire is loaded.
if file.Find("wire/uwsvn_load.lua","LUA")[1] then
if SERVER then AddCSLuaFile( "wire/uwsvn_load.lua" ) end
include("wire/uwsvn_load.lua")
end
if SERVER then print("Wiremod Version '"..WireLib.GetVersion().."' loaded") end
| apache-2.0 |
mattyx14/otxserver | data/monster/quests/in_service_of_yalahar/sharptooth.lua | 2 | 2306 | local mType = Game.createMonsterType("Sharptooth")
local monster = {}
monster.description = "Sharptooth"
monster.experience = 1600
monster.outfit = {
lookType = 20,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
lookFeet = 0,
lookAddons = 0,
lookMount = 0
}
monster.health = 3100
monster.maxHealth = 3100
monster.race = "blood"
monster.corpse = 6067
monster.speed = 290
monster.manaCost = 0
monster.changeTarget = {
interval = 5000,
chance = 8
}
monster.strategiesTarget = {
nearest = 70,
health = 10,
damage = 10,
random = 10,
}
monster.flags = {
summonable = false,
attackable = true,
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = true,
staticAttackChance = 90,
targetDistance = 1,
runHealth = 0,
healthHidden = false,
isBlockable = false,
canWalkOnEnergy = false,
canWalkOnFire = false,
canWalkOnPoison = false
}
monster.light = {
level = 0,
color = 0
}
monster.voices = {
interval = 5000,
chance = 10,
{text = "Gnarrr!", yell = false},
{text = "Tcharrr!", yell = false},
{text = "Rrrah!", yell = false},
{text = "Rraaar!", yell = false}
}
monster.loot = {
{id = 3111, chance = 50000} -- fishbone
}
monster.attacks = {
{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -500}
}
monster.defenses = {
defense = 29,
armor = 20,
{name ="speed", interval = 2000, chance = 15, effect = CONST_ME_MAGIC_GREEN, target = false},
{name ="combat", interval = 2000, chance = 12, type = COMBAT_HEALING, minDamage = 200, maxDamage = 240, effect = CONST_ME_MAGIC_BLUE, target = false}
}
monster.elements = {
{type = COMBAT_PHYSICALDAMAGE, percent = 0},
{type = COMBAT_ENERGYDAMAGE, percent = -5},
{type = COMBAT_EARTHDAMAGE, percent = 80},
{type = COMBAT_FIREDAMAGE, percent = 100},
{type = COMBAT_LIFEDRAIN, percent = 100},
{type = COMBAT_MANADRAIN, percent = 0},
{type = COMBAT_DROWNDAMAGE, percent = 100},
{type = COMBAT_ICEDAMAGE, percent = 0},
{type = COMBAT_HOLYDAMAGE , percent = 0},
{type = COMBAT_DEATHDAMAGE , percent = 0}
}
monster.immunities = {
{type = "paralyze", condition = false},
{type = "outfit", condition = false},
{type = "invisible", condition = true},
{type = "bleed", condition = false}
}
mType:register(monster)
| gpl-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.