content stringlengths 5 1.05M |
|---|
teal_map =
{
pos = "1;0",
entities =
{
{
codename = "villager",
type = "character",
pos = { x = 9, y = 10 },
orientation = "right"
},
{
codename = "villager",
type = "character",
pos = { x = 10, y = 8 },
orientation = "downleft"
},
{
codename = "villager",
type = "character",
pos = { x = 10, y = 12 },
orientation = "upleft"
}
},
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass2", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass2", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass2", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass2", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass2", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass2", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass2", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "red" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "blue" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "red" },
{ texId = "stone", flag = "red" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "red" },
{ texId = "stone", flag = "none" },
{ texId = "stone", flag = "none" },
{ texId = "grass", flag = "blue" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "blue" },
{ texId = "grass", flag = "blue" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "red" },
{ texId = "grass", flag = "red" },
{ texId = "grass", flag = "red" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "red" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "blue" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "blue" },
{ texId = "grass", flag = "blue" },
{ texId = "grass", flag = "blue" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "red" },
{ texId = "grass", flag = "red" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "red" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "blue" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "blue" },
{ texId = "grass", flag = "blue" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "red" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "blue" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass2", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass2", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
{ texId = "grass", flag = "none" },
} |
local tpl = require('ilk.template-text').template_eval
local backend = require('ilk.backend.eigen.backend-symbols')
local cppcom = require('ilk.backend.eigen.common')
local com = require('ilk.common')
local keys = require('ilk.parser').keys
local M = {}
local tpleval = function(template, env, opts)
return com.tplEval_failOnError(template, env, opts or {xtendStyle=true, returnTable=true})
end
M.poseCompose = function(program, poseComposeOp)
local ids = {
result = poseComposeOp.res,
arg1 = program.poseValueExpression(poseComposeOp.arg1),
arg2 = program.poseValueExpression(poseComposeOp.arg2)
}
if program.source.meta.outputs[poseComposeOp.res]==nil then
ids.result = backend.types[com.metatypes.pose] .. " " .. ids.result
end
return com.tplEval_failOnError("$(result) = $(arg2) * $(arg1);", ids, {returnTable=true})
end
local jacColTemplate = {
[keys.jointType.revolute] =
[[
geometricJacobianColumn_revolute(
poi_«J.jac»,
«funcs.posView»(«jpose»),
«polarity»«funcs.zAxisView»(«jpose»),
«J.jac».col(«J.col») );
]],
[keys.jointType.prismatic] =
[[
geometricJacobianColumn_prismatic(
«polarity»«funcs.zAxisView»(«jpose»),
«J.jac».col(«J.col») );
]]
}
M.jacobian = function(program)
return {
init = function(jac_op)
return {
[1] = backend.types[com.metatypes.position3d].." poi_"..jac_op.name.." = "..backend.funcs.posView.."("..jac_op.pose..");"
}
end,
column = function(jac_col)
local codetpl = jacColTemplate[jac_col.jtype]
local polarity = ""
if jac_col.polarity == -1 then
polarity = "-"
end
local ok,res = tpl(codetpl,
{
jpose = program.poseValueExpression(jac_col.joint_pose),
funcs = backend.funcs,
J = jac_col,
polarity = polarity
}, {xtendStyle=true, returnTable=true})
return res
end
}
end
M.geometricJacobianInit = function(program, op)
return {
[1] = backend.types[com.metatypes.position3d].." poi_"..op.name.." = "..backend.funcs.posView.."("..op.pose..");"
}
end
M.geometricJacobianColumn = function(program, op, joint)
local codetpl = jacColTemplate[joint.kind]
local polarity = ""
if op.polarity == -1 then
polarity = "-"
end
local code = com.tplEval_failOnError(codetpl,
{
jpose = program.poseValueExpression(op.joint_pose),
funcs = backend.funcs,
J = op,
polarity = polarity
}, {xtendStyle=true, returnTable=true})
return code
end
M.jointVelocityTwist = function(program, jointVelOp, jointVelocitySpec, joint, qd_argument)
local twist_t = backend.types[com.metatypes.twist]
local ids = {
qd = qd_argument.name,
velocity = jointVelOp.arg,
index = joint.coordinate,
spatialIndex = backend.spatialVectorIndex[ joint.kind ],
funcs = backend.funcs
}
if program.source.meta.outputs[jointVelOp.arg]==nil then
ids.init = twist_t .. " " .. jointVelOp.arg .. " = " .. twist_t .. "::Zero();"
else
ids.init = jointVelOp.arg .. ".setZero();"
end
local texttpl = nil
if jointVelocitySpec.polarity == -1 then
ids.twist_t = twist_t
ids.H = program.poseValueExpression(jointVelocitySpec.ctransform)
texttpl =
[[«init»
«twist_t» aux = twist_t::Zero();
aux[«spatialIndex»] = -«qd»(«index»);
«funcs.ct_twist»( «H», aux, «velocity» );
]]
else
texttpl =
[[«init»
«velocity»[«spatialIndex»] = «qd»(«index»);]]
end
return com.tplEval_failOnError(texttpl, ids, {xtendStyle=true, returnTable=true})
end
M.jointVelComposeSnippets = function(program, velocityComposeOp, env)
local defineLocalForResult = program.source.meta.outputs[velocityComposeOp.res]==nil
-- the resulting velocity is not an output of the solver, so there is no
-- formal parameter for it; thus, (generate code to) define a local variable.
local twistInit = ""
if defineLocalForResult then
env.vel_t = backend.types[com.metatypes.velocity]
twistInit = "«vel_t» «res»;"
end
env.coordt = backend.funcs.ct_twist
env.sptInd = backend.spatialVectorIndex[ env.joint.kind ]
env. qdInd = env.joint.coordinate
local eval = function(text) return tpleval(text, env) end
return {
initializeVelocityVariable = eval(twistInit),
subtractJointVelocity = eval("«v2»[«sptInd»] -= «qd»[«qdInd»];"),
twistCoordinateTransform = eval("«coordt»( «H», «v2», «res» );"),
addJointVelocity = eval("«res»[«sptInd»] += «qd»[«qdInd»];")
}
end
M.jointAccelerationTwist = function(program, op, jointAccTwistSpec, joint, qdd_arg)
local twist_t = backend.types[com.metatypes.twist]
local ids = {
qdd = qdd_arg.name,
acc = op.arg,
index = joint.coordinate,
spatialIndex = backend.spatialVectorIndex[ joint.kind ],
funcs = backend.funcs
}
if program.source.meta.outputs[op.arg]==nil then
ids.init = twist_t .. " " .. op.arg .. " = " .. twist_t .. "::Zero();"
else
ids.init = op.arg .. ".setZero();"
end
local texttpl = nil
if op.polarity == -1 then
cppcom.logger.warning("Joint acceleration twist with inverse polarity not supported yet")
texttpl =
[[«init»
#error Inverse polarity acceleration not supported yet
]]
else
texttpl =
[[«init»
«acc»[«spatialIndex»] = «qdd»(«index»);]]
end
return com.tplEval_failOnError(texttpl, ids, {xtendStyle=true, returnTable=true})
end
M.forwardPropagationAcceleration = function(program, op, env)
local defineLocalForResult = program.source.meta.outputs[op.res]==nil
local twistInit = ""
if defineLocalForResult then
env.acc_t = backend.types[com.metatypes.acceleration]
twistInit = "«acc_t» «res»;"
end
env.coordt = backend.funcs.ct_twist
env.sptInd = backend.spatialVectorIndex[ env.joint.kind ]
env.Sdot = backend.funcs.Sdot[ env.joint.kind ]
env.vel = op.velocity
local lines = function(text) return tpleval(text, env, {xtendStyle=true, returnTable=true}) end
return {
initializeAccelerationVariable = lines(twistInit),
subtractJointAcceleration = lines("«a2»[«sptInd»] -= «qdd»[«joint.coordinate»];"),
twistCoordinateTransform = lines("«coordt»( «H», «a2», «res» );"),
addRelativeAcceleration = lines(
[[«res» += «Sdot»(«vel») * «qd»[«joint.coordinate»];
«res»[«sptInd»] += «qdd»[«joint.coordinate»];
]]
)
}
end
return M |
--[[ MOB SPAWN LIST
mob(<mob_spawner_alias>, <mob_id>, <mob_count>, <spawner_limit>, <spawn_interval>, <spawner_range>, <map_id>, <x_pos>, <y_pos>, <z_pos>);
--]]
mob("", 41, 1, 4, 5, 16, 22, 5239.33, 5453.489, 31.07313);
mob("", 41, 1, 4, 5, 16, 22, 5239.33, 5453.489, 31.07313);
mob("", 41, 1, 4, 5, 16, 22, 5239.33, 5453.489, 31.07313);
mob("", 41, 1, 4, 5, 16, 22, 5239.33, 5453.489, 31.07313);
mob("", 41, 1, 4, 5, 16, 22, 5239.33, 5453.489, 31.07313);
mob("", 13, 1, 4, 5, 16, 22, 5239.33, 5453.489, 31.07313);
mob("", 203, 1, 4, 5, 16, 22, 5239.33, 5453.489, 31.07313);
mob("", 41, 1, 2, 5, 13, 22, 5263.663, 5478.341, 32.50475);
mob("", 41, 1, 2, 5, 13, 22, 5263.663, 5478.341, 32.50475);
mob("", 42, 1, 2, 5, 13, 22, 5263.663, 5478.341, 32.50475);
mob("", 41, 1, 2, 5, 13, 22, 5263.663, 5478.341, 32.50475);
mob("", 42, 1, 2, 5, 13, 22, 5263.663, 5478.341, 32.50475);
mob("", 13, 1, 2, 5, 13, 22, 5263.663, 5478.341, 32.50475);
mob("", 41, 1, 3, 5, 14, 22, 5277.405, 5459.036, 30.20532);
mob("", 41, 1, 3, 5, 14, 22, 5277.405, 5459.036, 30.20532);
mob("", 42, 1, 3, 5, 14, 22, 5277.405, 5459.036, 30.20532);
mob("", 42, 1, 3, 5, 14, 22, 5277.405, 5459.036, 30.20532);
mob("", 41, 1, 3, 5, 14, 22, 5277.405, 5459.036, 30.20532);
mob("", 13, 1, 3, 5, 14, 22, 5277.405, 5459.036, 30.20532);
mob("", 41, 1, 1, 10, 10, 22, 5169.93, 5442.79, 13.8);
mob("", 41, 1, 1, 10, 10, 22, 5148.18, 5465.27, 15.4);
mob("", 41, 1, 1, 2, 13, 22, 5420.296, 5490.999, 16.60349);
mob("", 41, 1, 1, 2, 13, 22, 5420.296, 5490.999, 16.60349);
mob("", 41, 1, 1, 2, 13, 22, 5420.296, 5490.999, 16.60349);
mob("", 42, 1, 1, 2, 13, 22, 5420.296, 5490.999, 16.60349);
mob("", 41, 1, 1, 2, 13, 22, 5420.296, 5490.999, 16.60349);
mob("", 41, 1, 1, 10, 20, 22, 5403.49, 5486.09, 16.05);
mob("", 41, 1, 1, 10, 10, 22, 5383.53, 5458.45, 15.05);
mob("", 41, 1, 1, 10, 10, 22, 5382.96, 5443.12, 13.58);
mob("", 41, 1, 1, 10, 20, 22, 5107.12, 5284.62, 3.58);
mob("", 10, 2, 3, 10, 5, 22, 5114.62, 5405.59, 7.05);
mob("", 10, 2, 3, 10, 5, 22, 5062.87, 5427.05, 11.97);
mob("", 3, 2, 9, 7, 27, 22, 5260.445, 5363.589, 1.461055);
mob("", 2, 1, 9, 7, 27, 22, 5260.445, 5363.589, 1.461055);
mob("", 3, 1, 9, 7, 27, 22, 5260.445, 5363.589, 1.461055);
mob("", 3, 2, 9, 7, 27, 22, 5260.445, 5363.589, 1.461055);
mob("", 41, 1, 9, 7, 27, 22, 5260.445, 5363.589, 1.461055);
mob("", 5, 1, 9, 7, 27, 22, 5260.445, 5363.589, 1.461055);
mob("", 42, 1, 9, 7, 27, 22, 5260.445, 5363.589, 1.461055);
mob("", 2, 2, 13, 6, 28, 22, 5160.385, 5352.938, 7.09205);
mob("", 2, 1, 13, 6, 28, 22, 5160.385, 5352.938, 7.09205);
mob("", 3, 2, 13, 6, 28, 22, 5160.385, 5352.938, 7.09205);
mob("", 41, 1, 13, 6, 28, 22, 5160.385, 5352.938, 7.09205);
mob("", 3, 1, 13, 6, 28, 22, 5160.385, 5352.938, 7.09205);
mob("", 3, 3, 13, 6, 28, 22, 5160.385, 5352.938, 7.09205);
mob("", 42, 1, 13, 6, 28, 22, 5160.385, 5352.938, 7.09205);
mob("", 2, 2, 12, 7, 22, 22, 5215.487, 5321.637, 3.093623);
mob("", 3, 1, 12, 7, 22, 22, 5215.487, 5321.637, 3.093623);
mob("", 2, 2, 12, 7, 22, 22, 5215.487, 5321.637, 3.093623);
mob("", 41, 1, 12, 7, 22, 22, 5215.487, 5321.637, 3.093623);
mob("", 42, 1, 12, 7, 22, 22, 5215.487, 5321.637, 3.093623);
mob("", 3, 3, 12, 7, 22, 22, 5215.487, 5321.637, 3.093623);
mob("", 42, 1, 12, 7, 22, 22, 5215.487, 5321.637, 3.093623);
mob("", 3, 1, 8, 7, 50, 22, 5207.101, 5356.586, 2.15);
mob("", 3, 1, 8, 7, 50, 22, 5207.101, 5356.586, 2.15);
mob("", 41, 1, 8, 7, 50, 22, 5207.101, 5356.586, 2.15);
mob("", 12, 1, 8, 7, 50, 22, 5207.101, 5356.586, 2.15);
mob("", 3, 1, 8, 7, 50, 22, 5207.101, 5356.586, 2.15);
mob("", 61, 1, 8, 7, 50, 22, 5207.101, 5356.586, 2.15);
mob("", 203, 1, 8, 7, 50, 22, 5207.101, 5356.586, 2.15);
mob("", 2, 1, 9, 9, 22, 22, 5156.64, 5314.14, 1.81);
mob("", 2, 1, 9, 9, 22, 22, 5156.64, 5314.14, 1.81);
mob("", 3, 2, 9, 9, 22, 22, 5156.64, 5314.14, 1.81);
mob("", 41, 1, 9, 9, 22, 22, 5156.64, 5314.14, 1.81);
mob("", 3, 1, 9, 9, 22, 22, 5156.64, 5314.14, 1.81);
mob("", 3, 2, 9, 9, 22, 22, 5156.64, 5314.14, 1.81);
mob("", 42, 1, 9, 9, 22, 22, 5156.64, 5314.14, 1.81);
mob("", 3, 1, 6, 9, 20, 22, 5145.52, 5416.9, 5.38);
mob("", 3, 1, 6, 9, 20, 22, 5145.52, 5416.9, 5.38);
mob("", 41, 1, 6, 9, 20, 22, 5145.52, 5416.9, 5.38);
mob("", 12, 1, 6, 9, 20, 22, 5145.52, 5416.9, 5.38);
mob("", 3, 1, 6, 9, 20, 22, 5145.52, 5416.9, 5.38);
mob("", 61, 1, 6, 9, 20, 22, 5145.52, 5416.9, 5.38);
mob("", 203, 1, 6, 9, 20, 22, 5145.52, 5416.9, 5.38);
mob("", 3, 3, 6, 7, 20, 22, 5137.33, 5299.13, 6.34);
mob("", 12, 2, 6, 7, 20, 22, 5137.33, 5299.13, 6.34);
mob("", 2, 2, 6, 7, 20, 22, 5137.33, 5299.13, 6.34);
mob("", 13, 2, 6, 7, 20, 22, 5137.33, 5299.13, 6.34);
mob("", 2, 1, 6, 7, 20, 22, 5137.33, 5299.13, 6.34);
mob("", 5, 2, 6, 7, 20, 22, 5137.33, 5299.13, 6.34);
mob("", 203, 1, 6, 7, 20, 22, 5137.33, 5299.13, 6.34);
mob("", 3, 1, 9, 5, 30, 22, 5335.413, 5371.168, 2.99999);
mob("", 2, 1, 9, 5, 30, 22, 5335.413, 5371.168, 2.99999);
mob("", 2, 1, 9, 5, 30, 22, 5335.413, 5371.168, 2.99999);
mob("", 3, 1, 9, 5, 30, 22, 5335.413, 5371.168, 2.99999);
mob("", 3, 1, 9, 5, 30, 22, 5335.413, 5371.168, 2.99999);
mob("", 3, 1, 9, 5, 30, 22, 5335.413, 5371.168, 2.99999);
mob("", 5, 1, 9, 5, 30, 22, 5335.413, 5371.168, 2.99999);
mob("", 3, 1, 10, 6, 25, 22, 5320.19, 5331.45, 8.1);
mob("", 2, 2, 10, 6, 25, 22, 5320.19, 5331.45, 8.1);
mob("", 2, 1, 10, 6, 25, 22, 5320.19, 5331.45, 8.1);
mob("", 2, 1, 10, 6, 25, 22, 5320.19, 5331.45, 8.1);
mob("", 2, 2, 10, 6, 25, 22, 5320.19, 5331.45, 8.1);
mob("", 5, 1, 10, 6, 25, 22, 5320.19, 5331.45, 8.1);
mob("", 3, 1, 10, 6, 25, 22, 5320.19, 5331.45, 8.1);
mob("", 2, 1, 8, 6, 21, 22, 5296.59, 5332.89, 7.62);
mob("", 2, 2, 8, 6, 21, 22, 5296.59, 5332.89, 7.62);
mob("", 2, 1, 8, 6, 21, 22, 5296.59, 5332.89, 7.62);
mob("", 2, 1, 8, 6, 21, 22, 5296.59, 5332.89, 7.62);
mob("", 3, 2, 8, 6, 21, 22, 5296.59, 5332.89, 7.62);
mob("", 3, 2, 8, 6, 21, 22, 5296.59, 5332.89, 7.62);
mob("", 5, 1, 8, 6, 21, 22, 5296.59, 5332.89, 7.62);
mob("", 2, 1, 8, 5, 21, 22, 5358.88, 5428.17, 5.19);
mob("", 2, 1, 8, 5, 21, 22, 5358.88, 5428.17, 5.19);
mob("", 2, 1, 8, 5, 21, 22, 5358.88, 5428.17, 5.19);
mob("", 3, 1, 8, 5, 21, 22, 5358.88, 5428.17, 5.19);
mob("", 3, 1, 8, 5, 21, 22, 5358.88, 5428.17, 5.19);
mob("", 3, 2, 8, 5, 21, 22, 5358.88, 5428.17, 5.19);
mob("", 41, 1, 8, 5, 21, 22, 5358.88, 5428.17, 5.19);
mob("", 3, 1, 8, 6, 25, 22, 5346.25, 5337.41, 8.02);
mob("", 2, 2, 8, 6, 25, 22, 5346.25, 5337.41, 8.02);
mob("", 3, 1, 8, 6, 25, 22, 5346.25, 5337.41, 8.02);
mob("", 2, 1, 8, 6, 25, 22, 5346.25, 5337.41, 8.02);
mob("", 2, 2, 8, 6, 25, 22, 5346.25, 5337.41, 8.02);
mob("", 3, 2, 8, 6, 25, 22, 5346.25, 5337.41, 8.02);
mob("", 5, 1, 8, 6, 25, 22, 5346.25, 5337.41, 8.02);
mob("", 41, 1, 1, 10, 10, 22, 5300.8, 5412.8, 21.06);
mob("", 41, 1, 1, 10, 10, 22, 5294.44, 5378.05, 6.18);
mob("", 2, 1, 8, 4, 17, 22, 5473.067, 5315.472, 12.35182);
mob("", 2, 1, 8, 4, 17, 22, 5473.067, 5315.472, 12.35182);
mob("", 12, 1, 8, 4, 17, 22, 5473.067, 5315.472, 12.35182);
mob("", 2, 1, 8, 4, 17, 22, 5473.067, 5315.472, 12.35182);
mob("", 3, 2, 8, 4, 17, 22, 5473.067, 5315.472, 12.35182);
mob("", 15, 1, 8, 4, 17, 22, 5473.067, 5315.472, 12.35182);
mob("", 3, 2, 8, 4, 17, 22, 5473.067, 5315.472, 12.35182);
mob("", 1, 1, 7, 5, 18, 22, 5480.355, 5378.704, 4.989541);
mob("", 2, 1, 7, 5, 18, 22, 5480.355, 5378.704, 4.989541);
mob("", 2, 1, 7, 5, 18, 22, 5480.355, 5378.704, 4.989541);
mob("", 3, 1, 7, 5, 18, 22, 5480.355, 5378.704, 4.989541);
mob("", 3, 2, 7, 5, 18, 22, 5480.355, 5378.704, 4.989541);
mob("", 5, 1, 7, 5, 18, 22, 5480.355, 5378.704, 4.989541);
mob("", 3, 2, 7, 5, 18, 22, 5480.355, 5378.704, 4.989541);
mob("", 1, 1, 6, 7, 15, 22, 5515.01, 5424.65, 8.131132);
mob("", 1, 1, 6, 7, 15, 22, 5515.01, 5424.65, 8.131132);
mob("", 1, 1, 6, 7, 15, 22, 5515.01, 5424.65, 8.131132);
mob("", 2, 1, 6, 7, 15, 22, 5515.01, 5424.65, 8.131132);
mob("", 1, 1, 6, 7, 15, 22, 5515.01, 5424.65, 8.131132);
mob("", 3, 1, 6, 7, 15, 22, 5515.01, 5424.65, 8.131132);
mob("", 12, 1, 6, 7, 15, 22, 5515.01, 5424.65, 8.131132);
mob("", 1, 1, 7, 7, 19, 22, 5575.17, 5319.04, 1.78);
mob("", 2, 1, 7, 7, 19, 22, 5575.17, 5319.04, 1.78);
mob("", 2, 1, 7, 7, 19, 22, 5575.17, 5319.04, 1.78);
mob("", 3, 1, 7, 7, 19, 22, 5575.17, 5319.04, 1.78);
mob("", 3, 2, 7, 7, 19, 22, 5575.17, 5319.04, 1.78);
mob("", 3, 1, 7, 7, 19, 22, 5575.17, 5319.04, 1.78);
mob("", 5, 1, 7, 7, 19, 22, 5575.17, 5319.04, 1.78);
mob("", 1, 1, 5, 5, 18, 22, 5496.2, 5398.78, 10.06);
mob("", 2, 1, 5, 5, 18, 22, 5496.2, 5398.78, 10.06);
mob("", 2, 1, 5, 5, 18, 22, 5496.2, 5398.78, 10.06);
mob("", 3, 1, 5, 5, 18, 22, 5496.2, 5398.78, 10.06);
mob("", 3, 2, 5, 5, 18, 22, 5496.2, 5398.78, 10.06);
mob("", 5, 1, 5, 5, 18, 22, 5496.2, 5398.78, 10.06);
mob("", 3, 2, 5, 5, 18, 22, 5496.2, 5398.78, 10.06);
mob("", 1, 1, 5, 5, 18, 22, 5465.8, 5348.34, 9.03);
mob("", 2, 1, 5, 5, 18, 22, 5465.8, 5348.34, 9.03);
mob("", 12, 1, 5, 5, 18, 22, 5465.8, 5348.34, 9.03);
mob("", 3, 1, 5, 5, 18, 22, 5465.8, 5348.34, 9.03);
mob("", 13, 2, 5, 5, 18, 22, 5465.8, 5348.34, 9.03);
mob("", 3, 1, 5, 5, 18, 22, 5465.8, 5348.34, 9.03);
mob("", 3, 2, 5, 5, 18, 22, 5465.8, 5348.34, 9.03);
mob("", 5, 1, 4, 4, 13, 22, 5492.59, 5280.5, 19.05);
mob("", 2, 1, 4, 4, 13, 22, 5492.59, 5280.5, 19.05);
mob("", 12, 1, 4, 4, 13, 22, 5492.59, 5280.5, 19.05);
mob("", 2, 1, 4, 4, 13, 22, 5492.59, 5280.5, 19.05);
mob("", 3, 2, 4, 4, 13, 22, 5492.59, 5280.5, 19.05);
mob("", 15, 1, 4, 4, 13, 22, 5492.59, 5280.5, 19.05);
mob("", 3, 2, 4, 4, 13, 22, 5492.59, 5280.5, 19.05);
mob("", 41, 1, 1, 10, 10, 22, 5469.16, 5425.2, 10.46);
mob("", 1, 1, 10, 7, 26, 22, 5608.51, 5294.62, 1.77);
mob("", 2, 1, 10, 7, 26, 22, 5608.51, 5294.62, 1.77);
mob("", 2, 1, 10, 7, 26, 22, 5608.51, 5294.62, 1.77);
mob("", 3, 1, 10, 7, 26, 22, 5608.51, 5294.62, 1.77);
mob("", 3, 2, 10, 7, 26, 22, 5608.51, 5294.62, 1.77);
mob("", 3, 1, 10, 7, 26, 22, 5608.51, 5294.62, 1.77);
mob("", 5, 1, 10, 7, 26, 22, 5608.51, 5294.62, 1.77);
mob("", 1, 1, 4, 7, 15, 22, 5629.51, 5348.91, 17.06);
mob("", 2, 1, 4, 7, 15, 22, 5629.51, 5348.91, 17.06);
mob("", 2, 1, 4, 7, 15, 22, 5629.51, 5348.91, 17.06);
mob("", 3, 1, 4, 7, 15, 22, 5629.51, 5348.91, 17.06);
mob("", 3, 2, 4, 7, 15, 22, 5629.51, 5348.91, 17.06);
mob("", 3, 1, 4, 7, 15, 22, 5629.51, 5348.91, 17.06);
mob("", 5, 1, 4, 7, 15, 22, 5629.51, 5348.91, 17.06);
mob("", 41, 1, 1, 10, 10, 22, 5631.49, 5430.5, 5.99);
mob("", 2, 1, 4, 10, 36, 22, 5792.27, 5439.44, 2.72);
mob("", 3, 1, 4, 10, 36, 22, 5792.27, 5439.44, 2.72);
mob("", 2, 1, 4, 10, 36, 22, 5792.27, 5439.44, 2.72);
mob("", 5, 1, 4, 10, 36, 22, 5792.27, 5439.44, 2.72);
mob("", 3, 1, 4, 10, 36, 22, 5792.27, 5439.44, 2.72);
mob("", 3, 1, 4, 10, 36, 22, 5792.27, 5439.44, 2.72);
mob("", 3, 1, 4, 10, 36, 22, 5792.27, 5439.44, 2.72);
mob("", 11, 2, 8, 8, 17, 22, 5233.644, 5226.572, 6.952744);
mob("", 12, 2, 8, 8, 17, 22, 5233.644, 5226.572, 6.952744);
mob("", 41, 1, 8, 8, 17, 22, 5233.644, 5226.572, 6.952744);
mob("", 15, 1, 8, 8, 17, 22, 5233.644, 5226.572, 6.952744);
mob("", 13, 1, 8, 8, 17, 22, 5233.644, 5226.572, 6.952744);
mob("", 3, 2, 8, 8, 17, 22, 5233.644, 5226.572, 6.952744);
mob("", 42, 1, 8, 8, 17, 22, 5233.644, 5226.572, 6.952744);
mob("", 11, 2, 12, 6, 25, 22, 5155.918, 5188.169, 2.061328);
mob("", 12, 2, 12, 6, 25, 22, 5155.918, 5188.169, 2.061328);
mob("", 3, 2, 12, 6, 25, 22, 5155.918, 5188.169, 2.061328);
mob("", 41, 1, 12, 6, 25, 22, 5155.918, 5188.169, 2.061328);
mob("", 13, 2, 12, 6, 25, 22, 5155.918, 5188.169, 2.061328);
mob("", 13, 1, 12, 6, 25, 22, 5155.918, 5188.169, 2.061328);
mob("", 42, 1, 12, 6, 25, 22, 5155.918, 5188.169, 2.061328);
mob("", 12, 3, 7, 10, 20, 22, 5228.77, 5146.33, 2.34);
mob("", 2, 2, 7, 10, 20, 22, 5228.77, 5146.33, 2.34);
mob("", 15, 2, 7, 10, 20, 22, 5228.77, 5146.33, 2.34);
mob("", 11, 2, 7, 10, 20, 22, 5228.77, 5146.33, 2.34);
mob("", 12, 2, 9, 7, 32, 22, 5176.11, 5255.75, 2.68);
mob("", 13, 2, 9, 7, 32, 22, 5176.11, 5255.75, 2.68);
mob("", 41, 1, 9, 7, 32, 22, 5176.11, 5255.75, 2.68);
mob("", 15, 1, 9, 7, 32, 22, 5176.11, 5255.75, 2.68);
mob("", 15, 1, 9, 7, 32, 22, 5176.11, 5255.75, 2.68);
mob("", 3, 2, 9, 7, 32, 22, 5176.11, 5255.75, 2.68);
mob("", 42, 1, 9, 7, 32, 22, 5176.11, 5255.75, 2.68);
mob("", 15, 2, 7, 8, 26, 22, 5145.72, 5256.88, 4.97);
mob("", 13, 1, 7, 8, 26, 22, 5145.72, 5256.88, 4.97);
mob("", 41, 1, 7, 8, 26, 22, 5145.72, 5256.88, 4.97);
mob("", 12, 1, 7, 8, 26, 22, 5145.72, 5256.88, 4.97);
mob("", 3, 1, 7, 8, 26, 22, 5145.72, 5256.88, 4.97);
mob("", 3, 2, 7, 8, 26, 22, 5145.72, 5256.88, 4.97);
mob("", 42, 1, 7, 8, 26, 22, 5145.72, 5256.88, 4.97);
mob("", 2, 2, 8, 11, 18, 22, 5225.67, 5262.22, 3.77);
mob("", 3, 1, 8, 11, 18, 22, 5225.67, 5262.22, 3.77);
mob("", 2, 2, 8, 11, 18, 22, 5225.67, 5262.22, 3.77);
mob("", 41, 1, 8, 11, 18, 22, 5225.67, 5262.22, 3.77);
mob("", 42, 1, 8, 11, 18, 22, 5225.67, 5262.22, 3.77);
mob("", 3, 3, 8, 11, 18, 22, 5225.67, 5262.22, 3.77);
mob("", 42, 1, 8, 11, 18, 22, 5225.67, 5262.22, 3.77);
mob("", 41, 1, 1, 10, 10, 22, 5133.04, 5216.09, 4.83);
mob("", 41, 1, 1, 10, 10, 22, 5244.23, 5220.09, 10.25);
mob("", 2, 2, 9, 8, 27, 22, 5150, 5214.89, 4.12);
mob("", 15, 1, 9, 8, 27, 22, 5150, 5214.89, 4.12);
mob("", 3, 2, 9, 8, 27, 22, 5150, 5214.89, 4.12);
mob("", 12, 1, 9, 8, 27, 22, 5150, 5214.89, 4.12);
mob("", 41, 1, 9, 8, 27, 22, 5150, 5214.89, 4.12);
mob("", 15, 1, 9, 8, 27, 22, 5150, 5214.89, 4.12);
mob("", 5, 1, 9, 8, 27, 22, 5150, 5214.89, 4.12);
mob("", 12, 2, 7, 5, 16, 22, 5346.444, 5165.773, 12.64942);
mob("", 13, 1, 7, 5, 16, 22, 5346.444, 5165.773, 12.64942);
mob("", 12, 1, 7, 5, 16, 22, 5346.444, 5165.773, 12.64942);
mob("", 12, 1, 7, 5, 16, 22, 5346.444, 5165.773, 12.64942);
mob("", 41, 1, 7, 5, 16, 22, 5346.444, 5165.773, 12.64942);
mob("", 13, 1, 7, 5, 16, 22, 5346.444, 5165.773, 12.64942);
mob("", 42, 1, 7, 5, 16, 22, 5346.444, 5165.773, 12.64942);
mob("", 11, 1, 3, 8, 22, 22, 5381.507, 5180.65, 6);
mob("", 12, 1, 3, 8, 22, 22, 5381.507, 5180.65, 6);
mob("", 13, 1, 3, 8, 22, 22, 5381.507, 5180.65, 6);
mob("", 41, 1, 3, 8, 22, 22, 5381.507, 5180.65, 6);
mob("", 41, 1, 3, 8, 22, 22, 5381.507, 5180.65, 6);
mob("", 13, 1, 3, 8, 22, 22, 5381.507, 5180.65, 6);
mob("", 42, 1, 3, 8, 22, 22, 5381.507, 5180.65, 6);
mob("", 41, 1, 3, 6, 16, 22, 5435.472, 5225.75, 20.20951);
mob("", 41, 1, 3, 6, 16, 22, 5435.472, 5225.75, 20.20951);
mob("", 12, 1, 3, 6, 16, 22, 5435.472, 5225.75, 20.20951);
mob("", 41, 1, 3, 6, 16, 22, 5435.472, 5225.75, 20.20951);
mob("", 12, 1, 3, 6, 16, 22, 5435.472, 5225.75, 20.20951);
mob("", 42, 1, 3, 6, 16, 22, 5435.472, 5225.75, 20.20951);
mob("", 13, 1, 3, 6, 16, 22, 5435.472, 5225.75, 20.20951);
mob("", 41, 1, 1, 10, 10, 22, 5351.05, 5120.84, 17.96);
mob("", 41, 1, 1, 10, 10, 22, 5370.47, 5155.74, 8.57);
mob("", 41, 1, 3, 5, 16, 22, 5457.79, 5245.15, 21.06);
mob("", 15, 1, 3, 5, 16, 22, 5457.79, 5245.15, 21.06);
mob("", 12, 1, 3, 5, 16, 22, 5457.79, 5245.15, 21.06);
mob("", 13, 1, 3, 5, 16, 22, 5457.79, 5245.15, 21.06);
mob("", 15, 1, 3, 5, 16, 22, 5457.79, 5245.15, 21.06);
mob("", 42, 1, 3, 5, 16, 22, 5457.79, 5245.15, 21.06);
mob("", 13, 1, 3, 5, 16, 22, 5457.79, 5245.15, 21.06);
mob("", 41, 1, 8, 5, 22, 22, 5482.76, 5249.64, 22.28);
mob("", 15, 1, 8, 5, 22, 22, 5482.76, 5249.64, 22.28);
mob("", 12, 1, 8, 5, 22, 22, 5482.76, 5249.64, 22.28);
mob("", 13, 1, 8, 5, 22, 22, 5482.76, 5249.64, 22.28);
mob("", 15, 1, 8, 5, 22, 22, 5482.76, 5249.64, 22.28);
mob("", 42, 1, 8, 5, 22, 22, 5482.76, 5249.64, 22.28);
mob("", 13, 1, 8, 5, 22, 22, 5482.76, 5249.64, 22.28);
mob("", 41, 1, 1, 10, 10, 22, 5529.9, 5217.8, 29.25);
mob("", 1, 2, 12, 5, 40, 22, 5644.63, 5247.89, 4.92);
mob("", 2, 1, 12, 5, 40, 22, 5644.63, 5247.89, 4.92);
mob("", 12, 1, 12, 5, 40, 22, 5644.63, 5247.89, 4.92);
mob("", 3, 1, 12, 5, 40, 22, 5644.63, 5247.89, 4.92);
mob("", 13, 2, 12, 5, 40, 22, 5644.63, 5247.89, 4.92);
mob("", 3, 2, 12, 5, 40, 22, 5644.63, 5247.89, 4.92);
mob("", 13, 2, 12, 5, 40, 22, 5644.63, 5247.89, 4.92);
mob("", 11, 2, 13, 6, 36, 22, 5661.16, 5193.36, 4.4);
mob("", 1, 2, 13, 6, 36, 22, 5661.16, 5193.36, 4.4);
mob("", 12, 1, 13, 6, 36, 22, 5661.16, 5193.36, 4.4);
mob("", 13, 1, 13, 6, 36, 22, 5661.16, 5193.36, 4.4);
mob("", 3, 1, 13, 6, 36, 22, 5661.16, 5193.36, 4.4);
mob("", 12, 1, 13, 6, 36, 22, 5661.16, 5193.36, 4.4);
mob("", 13, 1, 13, 6, 36, 22, 5661.16, 5193.36, 4.4);
mob("", 11, 1, 5, 6, 18, 22, 5608.47, 5150.49, 5.16);
mob("", 11, 1, 5, 6, 18, 22, 5608.47, 5150.49, 5.16);
mob("", 12, 1, 5, 6, 18, 22, 5608.47, 5150.49, 5.16);
mob("", 13, 1, 5, 6, 18, 22, 5608.47, 5150.49, 5.16);
mob("", 3, 1, 5, 6, 18, 22, 5608.47, 5150.49, 5.16);
mob("", 12, 1, 5, 6, 18, 22, 5608.47, 5150.49, 5.16);
mob("", 13, 1, 5, 6, 18, 22, 5608.47, 5150.49, 5.16);
mob("", 11, 3, 10, 6, 26, 22, 5689.49, 5155.62, 5.99);
mob("", 12, 1, 10, 6, 26, 22, 5689.49, 5155.62, 5.99);
mob("", 11, 1, 10, 6, 26, 22, 5689.49, 5155.62, 5.99);
mob("", 13, 1, 10, 6, 26, 22, 5689.49, 5155.62, 5.99);
mob("", 3, 1, 10, 6, 26, 22, 5689.49, 5155.62, 5.99);
mob("", 12, 1, 10, 6, 26, 22, 5689.49, 5155.62, 5.99);
mob("", 13, 1, 10, 6, 26, 22, 5689.49, 5155.62, 5.99);
mob("", 1, 2, 12, 7, 32, 22, 5665.06, 5279.82, 7.65);
mob("", 2, 1, 12, 7, 32, 22, 5665.06, 5279.82, 7.65);
mob("", 1, 2, 12, 7, 32, 22, 5665.06, 5279.82, 7.65);
mob("", 3, 1, 12, 7, 32, 22, 5665.06, 5279.82, 7.65);
mob("", 3, 2, 12, 7, 32, 22, 5665.06, 5279.82, 7.65);
mob("", 3, 1, 12, 7, 32, 22, 5665.06, 5279.82, 7.65);
mob("", 5, 1, 12, 7, 32, 22, 5665.06, 5279.82, 7.65);
mob("", 11, 1, 8, 6, 23, 22, 5633.87, 5197.84, 4.29);
mob("", 11, 1, 8, 6, 23, 22, 5633.87, 5197.84, 4.29);
mob("", 12, 1, 8, 6, 23, 22, 5633.87, 5197.84, 4.29);
mob("", 13, 1, 8, 6, 23, 22, 5633.87, 5197.84, 4.29);
mob("", 3, 1, 8, 6, 23, 22, 5633.87, 5197.84, 4.29);
mob("", 12, 1, 8, 6, 23, 22, 5633.87, 5197.84, 4.29);
mob("", 13, 1, 8, 6, 23, 22, 5633.87, 5197.84, 4.29);
mob("", 319, 2, 15, 15, 35, 22, 5824.91, 5200.09, -1.37);
mob("", 320, 2, 15, 15, 35, 22, 5824.91, 5200.09, -1.37);
mob("", 321, 3, 15, 15, 35, 22, 5824.91, 5200.09, -1.37);
mob("", 11, 1, 3, 6, 12, 22, 5405.089, 5107.835, 16.58707);
mob("", 12, 1, 3, 6, 12, 22, 5405.089, 5107.835, 16.58707);
mob("", 12, 1, 3, 6, 12, 22, 5405.089, 5107.835, 16.58707);
mob("", 13, 1, 3, 6, 12, 22, 5405.089, 5107.835, 16.58707);
mob("", 12, 1, 3, 6, 12, 22, 5405.089, 5107.835, 16.58707);
mob("", 15, 1, 3, 6, 12, 22, 5405.089, 5107.835, 16.58707);
mob("", 13, 1, 3, 6, 12, 22, 5405.089, 5107.835, 16.58707);
mob("", 203, 1, 2, 300, 5, 22, 5391.01, 5074.42, 17.9);
mob("", 2, 3, 2, 300, 5, 22, 5391.01, 5074.42, 17.9);
mob("", 5, 1, 1, 10, 10, 22, 5436.63, 5078.05, 13.07);
mob("", 41, 1, 1, 10, 10, 22, 5427.06, 5096.83, 15);
mob("", 41, 1, 1, 10, 10, 22, 5302.09, 5086.06, 2.99);
mob("", 41, 1, 1, 10, 10, 22, 5309.91, 5112.33, 5.01);
mob("", 41, 1, 1, 10, 10, 22, 5296.56, 5118.19, 3.99);
mob("", 3, 1, 3, 6, 12, 22, 5533.34, 5080.11, 6.61);
mob("", 12, 1, 3, 6, 12, 22, 5533.34, 5080.11, 6.61);
mob("", 12, 1, 3, 6, 12, 22, 5533.34, 5080.11, 6.61);
mob("", 13, 1, 3, 6, 12, 22, 5533.34, 5080.11, 6.61);
mob("", 13, 1, 3, 6, 12, 22, 5533.34, 5080.11, 6.61);
mob("", 12, 3, 3, 6, 12, 22, 5533.34, 5080.11, 6.61);
mob("", 13, 1, 3, 6, 12, 22, 5533.34, 5080.11, 6.61);
mob("", 41, 2, 2, 7, 10, 22, 5570, 5113.44, 3.6);
mob("", 41, 1, 1, 7, 10, 22, 5509.26, 5095.13, 3.28);
mob("", 41, 1, 1, 7, 10, 22, 5479.63, 5061.43, 7.56);
|
local plugin_name = 'pg.uptime'
local every = 300
local sql_uptime = read_file_in_plugin_dir("uptime.sql")
local sql_checkpointer_uptime = read_file_in_plugin_dir("checkpointer_uptime_10.sql")
local function collect_9()
local result = target:query(sql_uptime)
for _, row in pairs(result.rows) do
storage_insert_metric({ plugin = plugin_name, int = row[1] })
end
end
local function collect_10()
local result = target:query(sql_uptime)
for _, row in pairs(result.rows) do
storage_insert_metric({ plugin = plugin_name, int = row[1] })
end
local result = target:query(sql_checkpointer_uptime)
for _, row in pairs(result.rows) do
storage_insert_metric({ plugin = plugin_name .. ".checkpointer", int = row[1] })
end
end
local collect = collect_9
if get_pg_server_version() >= 10 then collect = collect_10 end
run_every(collect, every)
|
--MoveCurve
--H_Tokisaki/curve_Attack_4 curve_Attack_4
return
{
filePath = "H_Tokisaki/curve_Attack_4",
startTime = Fixed64(10485760) --[[10]],
startRealTime = Fixed64(122334) --[[0.1166667]],
endTime = Fixed64(69940016) --[[66.7]],
endRealTime = Fixed64(815967) --[[0.7781667]],
isZoom = false,
isCompensate = false,
curve = {
[1] = {
time = 0 --[[0]],
value = 0 --[[0]],
inTangent = 5242880 --[[5]],
outTangent = 5242880 --[[5]],
},
[2] = {
time = 1048576 --[[1]],
value = 5242880 --[[5]],
inTangent = 5242880 --[[5]],
outTangent = 5242880 --[[5]],
},
},
} |
dofile("../framework/framework.lua")
SetupSolution("Tutorial11")
dofile("tutorials.lua")
|
--[[
LuCI - Lua Configuration Interface
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
]]--
local ds = require "luci.dispatcher"
local datatypes = require("luci.cbi.datatypes")
local dsp = require "luci.dispatcher"
local vc = require "luci.model.cbi.voice.common"
arg[1] = arg[1] or ""
-- Create a map and a section
m = Map("voice_client", "Call Filter")
m.redirect = dsp.build_url("admin/services/voice/call_filters")
s = m:section(NamedSection, arg[1], "call_filter")
s.anonymous = true
s.addremove = false
-- Find the lowest free section number
function get_new_section_number(direction)
local section_nr = 0
while m.uci:get("voice_client", "call_filter_rule_" .. direction .. section_nr) do
section_nr = section_nr + 1
end
return section_nr
end
-- Set page title, or redirect if we have nothing to edit
create_new = false
if m.uci:get("voice_client", arg[1]) ~= "call_filter" then
luci.http.redirect(m.redirect)
return
else
local name = m:get(arg[1], "name")
create_new = not name or #name == 0
if create_new then
m.title = "New Call Filter"
else
m.title = "Edit Call Filter"
end
end
name = s:option(Value, "name", "Name")
function name.parse(self, section)
Value.parse(self, section)
local value = self:formvalue(section)
if not value or #value == 0 then
self.add_error(self, section, "missing", "Name is mandatory")
end
end
outgoing = m:section(TypedSection, "call_filter_rule_outgoing", "Outgoing Calls", "Specify rules for outgoing calls. Use # to match a range of numbers. 123# will block calls to all numbers starting with 123.")
function outgoing.filter(self, section)
owner = m.uci:get("voice_client", section, 'owner')
if owner == arg[1] then
return true
end
return false
end
outgoing.template = "cbi/tblsection"
outgoing.anonymous = true
outgoing.addremove = true
-- This function is called when a new call filter rule should be configured i.e. when
-- user presses the "Add" button.
function outgoing.create(self, section)
if m.save == false then
return
end
section_number = get_new_section_number("outgoing")
data = { owner = arg[1], enabled = 1 }
newSelection = m.uci:section("voice_client", "call_filter_rule_outgoing", "call_filter_rule_outgoing" .. section_number , data)
end
exten = outgoing:option(Value, "extension", "Called Number")
function exten.validate(self, value, section)
if not value:match("^[0-9]+#?$") then
return nil, value .. " is not a valid pattern"
end
return value
end
function exten.parse(self, section)
Value.parse(self, section)
local value = self:formvalue(section)
if not value or #value == 0 then
self.add_error(self, section, "missing", "Called number is mandatory")
end
end
enabled = outgoing:option(Flag, "enabled", "Enabled")
enabled.default = 1
s = m:section(NamedSection, arg[1], "call_filter")
s.anonymous = true
block_foreign = s:option(Flag, "block_foreign", "Block Foreign", "Block all outgoing calls to foreign numbers")
block_foreign.default = 0
block_special_rate = s:option(Flag, "block_special_rate", "Block Special Rate", "Block all outgoing calls to special rate numbers")
block_special_rate = 0
incoming = m:section(TypedSection, "call_filter_rule_incoming", "Incoming Calls", "Specify rules for incoming calls. Use # to match a range of numbers. 123# will block calls from all numbers starting with 123.")
function incoming.filter(self, section)
owner = m.uci:get("voice_client", section, 'owner')
if owner == arg[1] then
return true
end
return false
end
incoming.template = "cbi/tblsection"
incoming.anonymous = true
incoming.addremove = true
-- This function is called when a new call filter rule should be configured i.e. when
-- user presses the "Add" button.
function incoming.create(self, section)
if m.save == false then
return
end
section_number = get_new_section_number("incoming")
data = { owner = arg[1], enabled = 1 }
newSelection = m.uci:section("voice_client", "call_filter_rule_incoming", "call_filter_rule_incoming" .. section_number , data)
end
exten = incoming:option(Value, "extension", "Calling Number")
function exten.validate(self, value, section)
if not value:match("^[0-9]+#?$") then
return nil, value .. " is not a valid pattern"
end
return value
end
function exten.parse(self, section)
Value.parse(self, section)
local value = self:formvalue(section)
if not value or #value == 0 then
self.add_error(self, section, "missing", "Calling number is mandatory")
end
end
enabled = incoming:option(Flag, "enabled", "Enabled")
enabled.default = 1
return m
|
--ZFUNC-marry-v1
local function marry( keys, values ) --> tab
local tab = {}
if #keys ~= #values then
return nil
end
for i = 1, #keys do
local k = keys[ i ]
local v = values[ i ]
tab[ k ] = v
end
return tab
end
return marry
|
local count = 1
if (count == 1) then
print("yes")
end
local count = 2
if (count == 1) then
print("yes")
else
print("no")
end
a = 1000
if (a == 100) then
print("a=100")
elseif (a == 200) then
print("a=200")
else
print("a=" .. a)
end
|
local TensionItem, super = Class(Item)
function TensionItem:init()
super:init(self)
-- Amount of TP this item gives
self.tp_amount = 0
end
function TensionItem:getTensionAmount()
return self.tp_amount
end
function TensionItem:onBattleSelect(user, target)
self.tension_given = Game:giveTension(self:getTensionAmount())
user:flash()
local sound = Assets.newSound("cardrive")
sound:setPitch(1.4)
sound:setVolume(0.8)
sound:play()
user:sparkle(1, 0.625, 0.25)
end
function TensionItem:onBattleDeselect(user, target)
Game:removeTension(self.tension_given or 0)
end
function TensionItem:onWorldUse(target)
Game.world:showText({
"* (You felt tense.)",
"* (... try using it in battle.)"
})
return false
end
return TensionItem |
require("helper/table")
require("helper/conversion")
require("helper/math")
---find_nearby_balancer
---find neaby balancers, by searching on the map for nearby entities
---and then creating a unique list with them.
---Only index returned, to always use the original data and operate on them
---
---@param entity LuaEntity the newly placed splitter
---@return number[] unique list of found balancers (only indices)
function find_nearby_balancer(entity)
local found_splitters = entity.surface.find_entities_filtered {
position = entity.position,
name = "belt-balancer",
radius = 1,
}
if #found_splitters == 1 then
return {}
end
local found_balancers = {}
for key, balancer in pairs(global.new_balancers) do
for _, found_splitter in pairs(found_splitters) do
if found_splitter.unit_number ~= entity.unit_number then
if balancer_has_splitter(key, found_splitter) then
found_balancers[balancer.index] = balancer.index
break
end
end
end
end
return found_balancers
end
---find_input_output_belts
---find input and output belts for this specific splitter
---@param splitter LuaEntity the splitter to search from
---@return table[],table[] -- found input and output belts. Object is no direct array: array[number]{ LuaEntity belt, string belt_type, ?number[] lanes }
function find_input_output_belts(splitter)
local splitter_pos = splitter.position
-- input_belts[belt_index] = { belt, belt_type, lanes }
local input_belts = {}
-- output_belts[belt_index] = { belt, belt_type, lanes }
local output_belts = {}
local found_belts = splitter.surface.find_entities_filtered {
position = splitter_pos,
type = "transport-belt",
radius = 1
}
for _, belt in pairs(found_belts) do
local into_pos, from_pos = get_input_output_pos(belt)
if into_pos.x == splitter_pos.x and into_pos.y == splitter_pos.y then
input_belts[belt.unit_number] = { belt = belt, belt_type = "belt" }
elseif from_pos.x == splitter_pos.x and from_pos.y == splitter_pos.y then
output_belts[belt.unit_number] = { belt = belt, belt_type = "belt" }
end
end
local found_underground_belts = splitter.surface.find_entities_filtered {
position = splitter_pos,
type = "underground-belt",
radius = 1
}
for _, underground_belt in pairs(found_underground_belts) do
local into_pos, from_pos = get_input_output_pos(underground_belt)
if underground_belt.belt_to_ground_type == "output" and into_pos.x == splitter_pos.x and into_pos.y == splitter_pos.y then
input_belts[underground_belt.unit_number] = { belt = underground_belt, belt_type = "underground" }
elseif underground_belt.belt_to_ground_type == "input" and from_pos.x == splitter_pos.x and from_pos.y == splitter_pos.y then
output_belts[underground_belt.unit_number] = { belt = underground_belt, belt_type = "underground" }
end
end
local found_splitter_belts = splitter.surface.find_entities_filtered {
position = splitter_pos,
type = "splitter",
radius = 1.5
}
for _, splitter_belt in pairs(found_splitter_belts) do
local into_pos, from_pos = get_input_output_pos_splitter(splitter_belt)
for _, into in pairs(into_pos) do
if into.position.x == splitter_pos.x and into.position.y == splitter_pos.y then
input_belts[splitter_belt.unit_number] = { belt = splitter_belt, belt_type = "splitter", lanes = into.lanes }
end
end
for _, from in pairs(from_pos) do
if from.position.x == splitter_pos.x and from.position.y == splitter_pos.y then
output_belts[splitter_belt.unit_number] = { belt = splitter_belt, belt_type = "splitter", lanes = from.lanes }
end
end
end
return input_belts, output_belts
end
---find_belonging_balancer
---find which balancer holds this splitter
---@param splitter LuaEntity splitter to find
---@return number Index of the Balancer with the splitter within
function find_belonging_balancer(splitter)
for index, _ in pairs(global.new_balancers) do
if balancer_has_splitter(index, splitter) then
return index
end
end
end
---get_input_output_pos
---get the positions where the belt will transport items from and to
---@param belt LuaEntity the belt to calculate on
---@return Position,Position return the positions (into, from)
---@param direction defines.direction override the direction of the belt. if nil will use belt.direction
function get_input_output_pos(belt, direction)
local belt_pos = belt.position
local into_pos, from_pos
direction = direction or belt.direction
if direction == defines.direction.north then
into_pos = { x = belt_pos.x, y = belt_pos.y - 1 }
from_pos = { x = belt_pos.x, y = belt_pos.y + 1 }
elseif direction == defines.direction.south then
into_pos = { x = belt_pos.x, y = belt_pos.y + 1 }
from_pos = { x = belt_pos.x, y = belt_pos.y - 1 }
elseif direction == defines.direction.west then
into_pos = { x = belt_pos.x - 1, y = belt_pos.y }
from_pos = { x = belt_pos.x + 1, y = belt_pos.y }
elseif direction == defines.direction.east then
into_pos = { x = belt_pos.x + 1, y = belt_pos.y }
from_pos = { x = belt_pos.x - 1, y = belt_pos.y }
end
return into_pos, from_pos
end
---get_input_output_pos_splitter
---get the positions where the splitter will transport items from and to
---@param splitter LuaEntity the splitter to calculate on
---@param direction defines.direction override the direction of the belt. if nil will use belt.direction
---@return table[],table[] returns array (from,into) of positions and belt-lanes. -- array[] = { Position, array[] = number }.
function get_input_output_pos_splitter(splitter, direction)
local splitter_pos = splitter.position
direction = direction or splitter.direction
local into_pos = {}
local from_pos = {}
local output_left_lanes = { 5, 6 }
local output_right_lanes = { 7, 8 }
local input_left_lanes = { 1, 2 }
local input_right_lanes = { 3, 4 }
if direction == defines.direction.north then
table.insert(into_pos, { position = { x = splitter_pos.x - 0.5, y = splitter_pos.y - 1 }, lanes = output_left_lanes })
table.insert(into_pos, { position = { x = splitter_pos.x + 0.5, y = splitter_pos.y - 1 }, lanes = output_right_lanes })
table.insert(from_pos, { position = { x = splitter_pos.x - 0.5, y = splitter_pos.y + 1 }, lanes = input_left_lanes })
table.insert(from_pos, { position = { x = splitter_pos.x + 0.5, y = splitter_pos.y + 1 }, lanes = input_right_lanes })
elseif direction == defines.direction.south then
table.insert(into_pos, { position = { x = splitter_pos.x - 0.5, y = splitter_pos.y + 1 }, lanes = output_right_lanes })
table.insert(into_pos, { position = { x = splitter_pos.x + 0.5, y = splitter_pos.y + 1 }, lanes = output_left_lanes })
table.insert(from_pos, { position = { x = splitter_pos.x - 0.5, y = splitter_pos.y - 1 }, lanes = input_right_lanes })
table.insert(from_pos, { position = { x = splitter_pos.x + 0.5, y = splitter_pos.y - 1 }, lanes = input_left_lanes })
elseif direction == defines.direction.west then
table.insert(into_pos, { position = { x = splitter_pos.x - 1, y = splitter_pos.y - 0.5 }, lanes = output_right_lanes })
table.insert(into_pos, { position = { x = splitter_pos.x - 1, y = splitter_pos.y + 0.5 }, lanes = output_left_lanes })
table.insert(from_pos, { position = { x = splitter_pos.x + 1, y = splitter_pos.y - 0.5 }, lanes = input_right_lanes })
table.insert(from_pos, { position = { x = splitter_pos.x + 1, y = splitter_pos.y + 0.5 }, lanes = input_left_lanes })
elseif direction == defines.direction.east then
table.insert(into_pos, { position = { x = splitter_pos.x + 1, y = splitter_pos.y - 0.5 }, lanes = output_left_lanes })
table.insert(into_pos, { position = { x = splitter_pos.x + 1, y = splitter_pos.y + 0.5 }, lanes = output_right_lanes })
table.insert(from_pos, { position = { x = splitter_pos.x - 1, y = splitter_pos.y - 0.5 }, lanes = input_left_lanes })
table.insert(from_pos, { position = { x = splitter_pos.x - 1, y = splitter_pos.y + 0.5 }, lanes = input_right_lanes })
end
return into_pos, from_pos
end
---get_balancer_index_from_pos
---@param surface LuaSurface Surface where it is
---@param position Position Position to look for balancer
---@return number Balancer index
function get_balancer_index_from_pos(surface, position)
local splitters = surface.find_entities_filtered {
position = position,
name = "belt-balancer"
}
for _, splitter in pairs(splitters) do
return find_belonging_balancer(splitter)
end
end
---get_input_output_balancer_index
---get the index of the input and output balancers, this belt belongs to.
---@param belt LuaEntity the belt to search from
---@param direction defines.direction override the direction of the belt.
---@return number,number into_balancer, from_balancer
function get_input_output_balancer_index(belt, direction)
local into_pos, from_pos = get_input_output_pos(belt, direction)
local into_balancer, from_balancer
local into_splitter = belt.surface.find_entities_filtered {
position = into_pos,
name = "belt-balancer",
}
for _, splitter in pairs(into_splitter) do
into_balancer = find_belonging_balancer(splitter)
end
local from_splitter = belt.surface.find_entities_filtered {
position = from_pos,
name = "belt-balancer"
}
for _, splitter in pairs(from_splitter) do
from_balancer = find_belonging_balancer(splitter, direction)
end
return into_balancer, from_balancer
end
---new_balancer
---constructor of Balancer_Class
---@param splitter LuaEntity
function new_balancer(splitter)
local new_balancer = {}
new_balancer.index = global.belt_balancer_max_id
global.new_balancers[new_balancer.index] = new_balancer
global.belt_balancer_max_id = global.belt_balancer_max_id + 1
-- list of all splitters, that form this balancer
new_balancer.splitter = {}
-- list of all input belts
new_balancer.input_belts = {}
-- list of all output belts
new_balancer.output_belts = {}
-- list of all input lanes
new_balancer.input_lanes = {}
-- list of all output lanes
new_balancer.output_lanes = {}
-- define current position of lanes
new_balancer.current_output_lane = 1
new_balancer.current_input_lane = 1
---@type SimpleItemStack[]
new_balancer.buffer = {}
new_balancer.nth_tick = 999
if type(splitter) == "table" and splitter.name == "belt-balancer" then
balancer_add_splitter(new_balancer.index, splitter)
elseif type(splitter) == "table" then
for _, splitter_single in pairs(splitter) do
balancer_add_splitter(new_balancer.index, splitter_single)
end
end
end
---balancer_add_splitter
---@param balancer_id number balancer to perform on
---@param splitter LuaEntity splitter to add
function balancer_add_splitter(balancer_id, splitter)
global.new_balancers[balancer_id].splitter[splitter.unit_number] = splitter
local input_belts, output_belts = find_input_output_belts(splitter)
for _, input_belt in pairs(input_belts) do
balancer_add_belt(balancer_id, input_belt.belt, true, input_belt.belt_type, input_belt.lanes)
end
for _, output_belt in pairs(output_belts) do
balancer_add_belt(balancer_id, output_belt.belt, false, output_belt.belt_type, output_belt.lanes)
end
end
---balancer_remove_splitter
---@param balancer_id number balancer to perform on
---@param splitter LuaEntity splitter to remove
function balancer_remove_splitter(balancer_id, splitter)
local balancer = global.new_balancers[balancer_id]
balancer.splitter[splitter.unit_number] = nil
local input_belts, output_belts = find_input_output_belts(splitter)
for _, input_belt in pairs(input_belts) do
balancer_remove_belt(balancer_id, input_belt.belt, true)
end
for _, output_belt in pairs(output_belts) do
balancer_remove_belt(balancer_id, output_belt.belt, false)
end
end
---balancer_add_belt
---@param balancer_id number balancer to perform on
---@param belt LuaEntity the belt to add
---@param input boolean true if input, false if output
---@param belt_type string "belt", "underground" or "splitter"
---@param lane_ids number[] array of numbers, that override, the automatic transport_line indices
function balancer_add_belt(balancer_id, belt, input, belt_type, lane_ids)
belt_type = belt_type or "belt"
lane_ids = lane_ids or nil
local balancer = global.new_balancers[balancer_id]
local belts, lanes
if input then
belts = balancer.input_belts
lanes = balancer.input_lanes
else
belts = balancer.output_belts
lanes = balancer.output_lanes
end
belts[belt.unit_number] = belt
if lane_ids then
for _, id in pairs(lane_ids) do
local transport_line = belt.get_transport_line(id)
table.insert(lanes, transport_line)
end
else
local max_transport_line_index = 0
if belt_type == "belt" then
max_transport_line_index = belt.get_max_transport_line_index()
elseif belt_type == "underground" then
max_transport_line_index = 2
end
for i = 1, max_transport_line_index do
local transport_line = belt.get_transport_line(i)
table.insert(lanes, transport_line)
end
end
-- update nth_tick
balancer_recalculate_nth_tick(balancer_id)
end
---balancer_remove_belt
---remove belt from input/output and also remove related lanes
---@param balancer_id number balancer to perform on
---@param belt LuaEntity the belt to remove from input/output
---@param input boolean true if input, false if output
function balancer_remove_belt(balancer_id, belt, input)
local balancer = global.new_balancers[balancer_id]
if input then
balancer.input_belts[belt.unit_number] = nil
for i = 1, belt.get_max_transport_line_index() do
remove_from_table(balancer.input_lanes, belt.get_transport_line(i))
end
else
balancer.output_belts[belt.unit_number] = nil
for i = 1, belt.get_max_transport_line_index() do
remove_from_table(balancer.output_lanes, belt.get_transport_line(i))
end
end
balancer_recalculate_nth_tick(balancer_id)
end
---balancer_merge_balancer
---merge other_balancer into the balancer
---@param balancer_id number balancer to perform on
---@param other_balancer_id number balancer that has to merge into this one
function balancer_merge_balancer(balancer_id, other_balancer_id)
local balancer = global.new_balancers[balancer_id]
local other_balancer = global.new_balancers[other_balancer_id]
-- move splitters
for _, splitter in pairs(other_balancer.splitter) do
if splitter.valid then
balancer.splitter[splitter.unit_number] = splitter
end
end
-- move belts
for key, belt in pairs(other_balancer.input_belts) do
if belt.valid then
balancer.input_belts[key] = belt
end
end
for key, belt in pairs(other_balancer.output_belts) do
if belt.valid then
balancer.output_belts[key] = belt
end
end
-- move belts
for _, lane in pairs(other_balancer.input_lanes) do
if lane.valid then
table.insert(balancer.input_lanes, lane)
end
end
for _, lane in pairs(other_balancer.output_lanes) do
if lane.valid then
table.insert(balancer.output_lanes, lane)
end
end
-- move buffer
for _, item in pairs(other_balancer.buffer) do
table.insert(balancer.buffer, item)
end
global.new_balancers[other_balancer_id] = nil
unregister_on_tick(other_balancer_id)
balancer_recalculate_nth_tick(balancer_id)
end
---balancer_recalculate_nth_tick
---Recalculate the tick, when this balancer has to run.
---It has to be the gcd, cause else, some belts are not compressed
---@param balancer_id number balancer to perform on
function balancer_recalculate_nth_tick(balancer_id)
local balancer = global.new_balancers[balancer_id]
if table_size(balancer.input_belts) == 0 or table_size(balancer.output_belts) == 0 then
unregister_on_tick(balancer_id)
balancer.nth_tick = -1
return
end
-- recalculate nth_tick
local tick_list = {}
local run_on_tick_override = false
for _, belt in pairs(balancer.input_belts) do
if belt.valid then
local belt_speed = belt.prototype.belt_speed
local ticks_per_tile = 0.25 / belt_speed
local nth_tick = math.floor(ticks_per_tile)
if nth_tick ~= ticks_per_tile then
run_on_tick_override = true
break
end
tick_list[nth_tick] = nth_tick
end
end
if not run_on_tick_override then
for _, belt in pairs(balancer.output_belts) do
if belt.valid then
local belt_speed = belt.prototype.belt_speed
local ticks_per_tile = 0.25 / belt_speed
local nth_tick = math.floor(ticks_per_tile)
if nth_tick ~= ticks_per_tile then
run_on_tick_override = true
break
end
tick_list[nth_tick] = nth_tick
end
end
end
local smallest_gcd = -1
if not run_on_tick_override then
for _, tick in pairs(tick_list) do
if smallest_gcd == -1 then
smallest_gcd = tick
elseif smallest_gcd == 1 then
break
elseif smallest_gcd == tick then
-- do nothing
else
smallest_gcd = math.gcd(smallest_gcd, tick)
end
end
end
if run_on_tick_override then
smallest_gcd = 1
end
if smallest_gcd ~= -1 and balancer.nth_tick ~= smallest_gcd then
balancer.nth_tick = smallest_gcd
unregister_on_tick(balancer_id)
register_on_tick(smallest_gcd, balancer_id)
end
end
---balancer_has_splitter
---check if given balancer holds a specific splitter
---@param balancer_id number balancer to perform on
---@param splitter LuaEntity splitter to
---@return boolean true if splitter is hold by balancer
function balancer_has_splitter(balancer_id, splitter)
local balancer = global.new_balancers[balancer_id]
for _, self_splitter in pairs(balancer.splitter) do
if self_splitter.valid and splitter.unit_number == self_splitter.unit_number then
return true
end
end
return false
end
---is_valid
---@return boolean true if balancer is valid
function balancer_is_valid(balancer_id)
local balancer = global.new_balancers[balancer_id]
if table_size(balancer.splitter) > 0 then
return true
end
return false
end
---balancer_on_tick
---Run the complete Logic from moving objects from input to buffer and from buffer to output
---@param balancer_id number balancer to perform on
function balancer_on_tick(balancer_id, tick)
local balancer = global.new_balancers[balancer_id]
if #balancer.input_lanes > 0 and #balancer.output_lanes > 0 then
local last_one_failed = 0
-- get how many items are needed per lane
local buffer_count = #balancer.buffer
local output_lane_count = #balancer.output_lanes
local gather_amount = output_lane_count - buffer_count
-- INPUT
while gather_amount > 0 do
if last_one_failed == balancer.current_input_lane then
break
end
local lane = balancer.input_lanes[balancer.current_input_lane]
if lane then
if not lane.valid then
-- this lane is not valid, remove it for the sake of my mind and as a workaround.
balancer.input_lanes[balancer.current_input_lane] = nil
else
if #lane > 0 then
-- remove item from lane and add to buffer
local lua_item = lane[1]
local simple_item = convert_LuaItemStack_to_SimpleItemStack(lua_item)
lane.remove_item(lua_item)
table.insert(balancer.buffer, simple_item)
gather_amount = gather_amount - 1
last_one_failed = 0
else
if last_one_failed == 0 then
last_one_failed = balancer.current_input_lane
end
end
end
end
balancer.current_input_lane = balancer.current_input_lane + 1
balancer.current_input_lane = ((balancer.current_input_lane - 1) % #balancer.input_lanes) + 1
end
-- OUTPUT
for i = 1, #balancer.output_lanes do
if #balancer.buffer > 0 then
local lane = balancer.output_lanes[balancer.current_output_lane]
if lane and lane.valid and lane.can_insert_at_back() then
if lane.insert_at_back(balancer.buffer[1]) then
table.remove(balancer.buffer, 1)
end
end
balancer.current_output_lane = balancer.current_output_lane + 1
balancer.current_output_lane = ((balancer.current_output_lane - 1) % #balancer.output_lanes) + 1
else
break
end
end
end
end
---balancer_get_linked
---get all lined splitters into an array of LuaEntity
---@param balancer_id number balancer to perform on
---@return LuaEntity[]
function balancer_get_linked(balancer_id)
local balancer = global.new_balancers[balancer_id]
-- create matrix
local matrix = {}
for _, splitter in pairs(balancer.splitter) do
if splitter and splitter.valid then
local pos = splitter.position
if not matrix[pos.x] then
matrix[pos.x] = {}
end
matrix[pos.x][pos.y] = splitter
end
end
local curr_num = 0
local result = {}
repeat
curr_num = curr_num + 1
balancer_expand_first(matrix, curr_num, result)
until (table_size(matrix) == 0)
return result
end
---balancer_expand_first
---expand the first found not expanded Element in the matrix
---@param matrix LuaEntity[][] matrix to perform logic on
---@param num number
function balancer_expand_first(matrix, num, result)
for x_key, _ in pairs(matrix) do
local breaker = false
for y_key, _ in pairs(matrix[x_key]) do
if matrix[x_key][y_key] then
result[num] = {}
balancer_expand_matrix(matrix, { x = x_key, y = y_key }, num, result)
breaker = true
break
end
end
if breaker then
break
end
end
end
---balancer_expand_matrix
---expand given element in the matrix and then expand its neighbours
---only expand if this element is not nil
function balancer_expand_matrix(matrix, pos, num, result)
if matrix[pos.x] and matrix[pos.x][pos.y] then
local splitter = matrix[pos.x][pos.y]
result[num][splitter.unit_number] = splitter
matrix[pos.x][pos.y] = nil
if table_size(matrix[pos.x]) == 0 then
matrix[pos.x] = nil
end
balancer_expand_matrix(matrix, { x = pos.x - 1, y = pos.y }, num, result)
balancer_expand_matrix(matrix, { x = pos.x + 1, y = pos.y }, num, result)
balancer_expand_matrix(matrix, { x = pos.x, y = pos.y - 1 }, num, result)
balancer_expand_matrix(matrix, { x = pos.x, y = pos.y + 1 }, num, result)
end
end
|
object_building_kashyyyk_poi_sign_go_back = object_building_kashyyyk_shared_poi_sign_go_back:new {
}
ObjectTemplates:addTemplate(object_building_kashyyyk_poi_sign_go_back, "object/building/kashyyyk/poi_sign_go_back.iff")
|
workspace "Test1"
architecture "x64"
configurations
{
"Debug",
"Release",
"Dist"
}
outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
--IncludeDirs = {}
--IncludeDirs["GLFW"] = "VOI.I4GE/glfw/include"
--IncludeDirs["Glad"] = "VOI.I4GE/Glad/include"
--IncludeDirs["ImGui"] = "VOI.I4GE/ImGui"
--IncludeDirs["vulkan-1"] = "VOI.I4GE/VulkanSDK"
--include "VOI.I4GE/glfw"
--include "VOI.I4GE/Glad"
--include "VOI.I4GE/ImGui"
--include "VOI.I4GE/VulkanSDK"
project "TEST"
location "TEST"
kind "ConsoleApp"
language "C++"
cppdialect "C++17"
staticruntime "Off"
targetdir ("OutputDir/" .. outputdir .. "/%{prj.name}")
objdir ("InterDir/" .. outputdir .. "/%{prj.name}")
pchheader "i4pch.h"
pchsource "TEST/src/i4pch.cpp"
files
{
"%{prj.name}/src/**.h",
"%{prj.name}/src/**.cpp"
}
includedirs
{
"TEST/src",
"C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Include"
}
links
{
"d3d9.lib",
"C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64/d3dx9.lib"
--"C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64/d3dxof.lib"
}
filter "system:windows"
systemversion "latest"
defines
{
"I4_WND_PLATFORM",
"I4_DLL"
}
filter "configurations:Debug"
defines "I4_DEBUG"
runtime "Debug"
symbols "On"
filter "configurations:Release"
defines "I4_RELEASE"
runtime "Release"
symbols "On"
filter "configurations:Dist"
defines "I4_DIST"
runtime "Release"
symbols "On"
|
return function (filename)
local fd = io.open(filename, "r")
local contents = fd:read("*a")
fd:close()
return contents
end |
Build {
Units = "units.lua",
Configs = {
{
Name = "macosx-gcc",
DefaultOnHost = "macosx",
Tools = { "gcc" },
},
{
Name = "linux-gcc",
DefaultOnHost = "linux",
Tools = { "gcc" },
},
{
Name = "win32-msvc",
DefaultOnHost = "windows",
Tools = { "msvc-vs2012" },
},
{
Name = "win32-mingw",
Tools = { "mingw" },
},
},
}
|
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Initialize()
self:SetModel("models/props_c17/FurnitureBoiler001a.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self.ingredients = {}
local phys = self:GetPhysicsObject()
if phys:IsValid() then
phys:Wake()
end
self:SetPos(self:GetPos() + Vector(0, 0, 35))
end
function ENT:UpdateOnClient()
net.Start("kdrugs.lab")
net.WriteEntity(self)
net.WriteTable(self.ingredients)
net.Broadcast()
end
function ENT:AddIngredient(name)
self.ingredients[name] = self.ingredients[name] and self.ingredients[name] + 1 or 1
self:UpdateOnClient()
end
function ENT:Use(_, ply)
if !self.nextuse then
self.nextuse = CurTime() + 0.75
elseif self.nextuse > CurTime() then
return
end
local best = 0
local toRemove = {}
local drugid
for id, drug in next, kdrugs.drugs do
local has = 0
local remove = {}
for index, tab in next, drug.ingredients do
if self.ingredients[tab[1]] and self.ingredients[tab[1]] >= tab[4] then
remove[tab[1]] = tab[4]
has = has + 1
end
end
if has == table.Count(drug.ingredients) then
if has > best then
best = has
toRemove = remove
drugid = id
end
end
end
if drugid then
local meme = ents.Create("kdrug_" .. drugid)
if !meme:IsValid() then return end
for name, count in next, toRemove do
self.ingredients[name] = self.ingredients[name] - count
if 0 >= self.ingredients[name] then
self.ingredients[name] = nil
end
end
self:UpdateOnClient()
local min, max = self:GetCollisionBounds()
meme:SetPos(self:GetPos() + Vector(0, 0, max.z + 15))
meme:Spawn()
end
end |
--[[
[] Author: Martynas Petuska
[] E-mail: martynas.petuska@outlook.com
[] Date: January 2018
--]]
---------------- NAMESPACE ----------------
-------------------------------------------
ADDON.Commands = {
help = function()
ADDON:Print("List of slash commands:");
--ADDON:Print("[reset] Resets the default settings.");
--ADDON:Print("[size <size>] Sets the size of the minimap.");
ADDON:Print("[rotation <on | off>] Sets the minimap's rotation mode.");
end,
--example = {
-- test = function(...)
-- ADDON:Print("My Value:", ...);
-- end
--},
--reset = function()
-- ADDON.Settings = ADDON.DefaultSettings;
-- ADDON.UI.ConfigureUI();
-- ADDON:Print("Addon settings reset.")
--end,
--size = function(size)
-- size = tonumber(size);
-- if (type(size) == "number") then
-- ADDON.Settings.MiniMap.size = size;
-- ADDON.UI.wheel:SetDimensions(size, size);
-- else
-- ADDON.Println()
-- ADDON:Print("Invalid command argument!")
-- ADDON.Commands.help();
-- return;
-- end
-- ADDON:Print("Size updated to", size);
--end,
rotation = function(isEnabled)
if (isEnabled == "on") then
ADDON.Settings.isMapRotationEnabled = true;
elseif (isEnabled == "off") then
ADDON.Settings.isMapRotationEnabled = false;
else
ADDON.Println()
ADDON:Print("Invalid command argument!")
ADDON.Commands.help();
return;
end
ADDON.UI.playerPin:SetTextureRotation(0);
ADDON.UI.wheel:SetTextureRotation(0);
ADDON.UpdateInfo.updatePending = true;
ADDON.UI.UpdateMap();
ADDON:Print("Minimap's rotation is ", isEnabled);
end
}
--- Handles a given command string redirecting to an appropriate function in the ADDON.Commands table.
---@param str string
---@return void
function ADDON.HandleSlashCommands(str)
if (#str == 0) then
ADDON.Commands.help();
return;
end
-- Parse arguments --
local args = {};
for _, arg in pairs({ split(str, " ") }) do
if (#arg > 0) then
table.insert(args, arg);
end
end
local path = ADDON.Commands;
for id, arg in ipairs(args) do
arg = string.lower(arg);
if (path[arg]) then
if (type(path[arg]) == "function") then
path[arg](select(id + 1, unpack(args)));
return
elseif (type(path[arg]) == "table") then
path = path[arg];
else
ADDON.Println()
ADDON:Print("Unrecognised command!")
ADDON.Commands.help();
return
end
else
ADDON.Println()
ADDON:Print("Unrecognised command!")
ADDON.Commands.help()
return
end
end
end
|
require "yu.visitor"
require "yu.type"
local getTypeDecl,newTypeRef=yu.getTypeDecl,yu.newTypeRef
local ipairs,print=ipairs,print
local format = string.format
local makeDeclRefName=yu.makeDeclRefName
local setmetatable,getmetatable=setmetatable,getmetatable
module("yu",package.seeall)
local pre={}
local post={}
local isConst,isDecl,isGlobalDecl,isFuncDecl=isConst,isDecl,isGlobalDecl,isFuncDecl
local is,isBuiltinType=is,isBuiltinType
local function makeNamePrefix(stack,sep)
local out=''
for i,n in ipairs(stack) do
out=out..n
out=out..sep
end
return out
end
----------
local metamethodNames=makeStringCheckTable(
'__new',
'__init',
'__gc',
'__index',
'__newindex',
'__add',
'__sub',
'__div',
'__mul',
'__tostring',
'__iter',
'__next',
'__gt',
'__lt',
'__eq'
)
function newDeclCollector()
return yu.newVisitor({
pre=pre,
post=post,
nameStack=yu.newStack(),
scopeStack=yu.newStack(),
exNameStack=yu.newStack(),
maxDeclId=0,
maxClosureId=0,
currentNamePrefix="",
currentExNamePrefix="",
currentScope=false,
currentScopeLevel=0,
-- currentN
depth=0,
pushName=function(self,name)
local n
if self.currentNamePrefix~='' then
n=name..'_'..self.currentNamePrefix
else
n=name
end
self.currentNamePrefix=n
return self.nameStack:push(n)
end,
popName=function(self)
local n=self.nameStack:pop() or ''
self.currentNamePrefix=n
return n
end,
pushExternName=function(self,name)
local n
if self.currentExNamePrefix~='' then
n=self.currentExNamePrefix..'.'..name
else
n=name
end
self.currentExNamePrefix=n
return self.exNameStack:push(n)
end,
popExternName=function(self)
local n=self.exNameStack:pop() or ''
self.currentExNamePrefix=n
return n
end,
genDeclId=function( self )
local id=self.maxDeclId
self.maxDeclId=id+1
return id
end,
genClosureId=function( self )
local id=self.maxClosureId
self.maxClosureId=id+1
return id
end,
pushScope=function(self)
local mt={}
local scope=setmetatable({},mt)
self.scopeStack:push(scope)
mt.parentScope=self.currentScope
mt.node=self.currentNode
self.currentScope=scope
self.currentNode.scope=scope
self.currentNode.scopeLevel=self.currentScopeLevel
self.currentScopeLevel=self.currentScopeLevel+1
return scope
end,
popScope=function(self)
self.currentScope=self.scopeStack:pop()
self.currentScopeLevel=self.currentScopeLevel-1
return self.currentScope
end,
addEachDecl=function(self,list, parent)
for i,n in ipairs(list) do
local tag=n.tag
if isDecl(n) then
self:addDecl(n)
elseif tag=="public" or tag=="private" then
self:addDecl(n)
elseif tag=='import' then
if not n.ishead then
self:err('import must be in head of source', n)
end
if n.alias then
n.type=moduleMetaType
self:addDecl(n)
parent.module.namedExternModule[n.mod]=true
end
end
end
end,
addDecl=function(self,decl,inclass)
local currentScope=self.currentScope
--
if isBuiltinType(decl.name) then
self:err(decl.name..' is builtin type',decl,self.currentModule)
end
if inclass then
if metamethodNames[decl.name] then
if decl.tag~='methoddecl' then
self:err(format('%q is reserved for metamethod',decl.name),decl)
else
decl.metamethod=true
end
end
end
local tag=decl.tag
if tag=="vardecl" then
local meta=decl.meta
for i,var in ipairs(decl.vars) do
var.vtype=decl.vtype
var.extern=decl.extern
if meta then var.meta=meta end
self:addDecl(var,inclass)
end
return
end
if tag=="private" then
getmetatable(currentScope).private=true
return
elseif tag=="public" then
getmetatable(currentScope).private=false
return
end
if tag=="import" then
decl.name=decl.alias
end
--TODO:check for internal method name like '__new','__add','__next'
local scope=currentScope
decl.private=getmetatable(scope).private
local name=decl.name
local decl0=scope[name]
if decl0 then --duplicated?
-- local tag0=decl0.tag
-- if tag==tag0 then
-- if decl0.private ~= decl.private then
-- self:err('function overload must be both private or public',decl)
-- end
-- --TODO:duplicated overloading
-- local dd=decl0
-- local n=1
-- while true do
-- local d1=dd.nextProto
-- if not d1 then
-- dd.nextProto=decl
-- break
-- end
-- n=n+1
-- dd=d1
-- end
-- decl.protoId=n
-- else
return self:err(
"duplicated declaration:'"..decl.name
.."',first defined:"
..getTokenPosString(decl0,self.currentModule)
,decl,self.currentModule)
-- end
else
scope[decl.name]=decl
end
decl.declId=self:genDeclId()
decl.refname=makeDeclRefName(decl,decl.declId)
if decl.alias then
decl.fullname=decl.alias
else
decl.fullname=name..'_'..self.currentNamePrefix
end
if decl.extern then
local p=self.currentExNamePrefix
if p~='' then p=p..'.' end
decl.externname=p..name
end
if decl.protoId then
decl.fullname=decl.fullname..'_p'..decl.protoId
end
decl.depth=self.depth
end
}
)
end
-------------
function pre.any(vi,n)
n.module=vi.currentModule
end
function pre.module(vi,m)
-- vi:pushScope()
-- vi:pushName(m.name)
vi.currentModule=m
m.module=m
m.namedExternModule={}
end
function post.module(vi,m)
--todo: extract decls from main block scope rather than refer to it directly
m.fullname=m.name
m.mainfunc.fullname='@main'
m.mainfunc.refname='@main'
m.mainfunc.name='@main'
local expose={}
for k,decl in pairs(m.mainfunc.block.scope) do
if k~='private' then
if isGlobalDecl(decl) then
expose[k]=decl
end
end
end
m.scope=expose
m.maxDeclId=vi.maxDeclId
m.externalRefers={}
m.externalReferNames={}
end
---------------
function pre.block(vi,b,parent)
-- if not is(parent.tag,'funcdecl','methoddecl','forstmt','catch','foreachstmt')
-- b.scope=vi:pushScope()
-- end
vi:addEachDecl(b, parent)
end
function post.block(vi,b)
-- vi:popScope()
end
function pre.dostmt(vi,d)
vi:pushScope()
end
function post.dostmt(vi,d)
vi:popScope()
end
-----------
function pre.extern(vi,e)
for i,s in ipairs(e.decls) do
if isDecl(s) or is(s.tag,"public","private") then
vi:addDecl(s)
end
end
end
-----------
local function spreadVarTypes(vars,forceType,visitor)
local lasttype=nil
for i=#vars,1,-1 do
local var=vars[i]
if var.type then
lasttype=var.type
elseif lasttype then
var.type=lasttype
elseif forceType then
return visitor:err("type identifier expected",var)
end
end
end
function pre:vardecl(vd)
local vars,values=vd.vars,vd.values
local varcount,valcount=#vars,values and #values or 0
local mulval=false
if values and vd.extern and vd.vtype~='const' then
return self:err('cannot assign initial value for extern variable',vd)
end
if values and varcount>valcount then
if is(values[#values].tag,'call','wait') then
mulval=true --might be mul value
else
return self:err('too less values in variable declaration',vd)
end
elseif varcount<valcount then
return self:err('too many values in variable declaration',vd)
end
if vd.def then --should no type id
for i,var in ipairs(vars) do
if var.type then return self:err("unnecessary type identifier",var.type) end
end
for i = 1, valcount do
local var=vars[i]
local v=values[i]
var.value=v
var.type=newTypeRef(v)
end
if varcount>valcount then
local lastval=values[valcount]
for i = valcount+1, varcount do
local var=vars[i]
local v={tag='mulval',src=lastval,idx=i-valcount}
var.value=v
var.type=newTypeRef(v)
end
end
else
spreadVarTypes(vars,not values,self)
if values then
for i = 1, valcount do
local var=vars[i]
local v=values[i]
var.value=v
if not var.type then var.type=newTypeRef(v) end
end
if varcount>valcount then
local lastval=values[valcount]
for i = valcount+1, varcount do
local var=vars[i]
local v={tag='mulval',src=lastval,idx=i-valcount}
var.value=v
if not var.type then var.type=newTypeRef(v) end
end
end
end
end
return true
end
function pre.funcdecl(vi,f)
if f.name~='@main' then vi:pushName(f.name,true) end
vi:pushScope()
vi.depth=vi.depth+1
end
function post.funcdecl(vi,f)
vi:popScope()
if f.block then
f.block.scope=f.scope
f.block.scopeLevel=f.scopeLevel
f.scope=nil
f.scopeLevel=nil
end
vi:popName()
vi.depth=vi.depth-1
end
function pre.closure(vi,f)
f.name='C'
vi:pushName(f.name,true)
vi:pushScope()
end
function post.closure(vi,f)
vi:popScope()
vi:popName()
end
-----------
function pre.methoddecl(vi,f,parent)
vi:pushName(f.name)
vi:pushScope()
vi.depth=vi.depth+1
end
function post.methoddecl(vi,f)
vi:popScope()
vi:popName()
vi.depth=vi.depth-1
end
------------
function pre.functype(vi,ft)
local args=ft.args
if args then
--spread arg types:
local lastType=nil
for i=#args,1,-1 do
local arg=args[i]
if not arg.type then --check default value firstt
if arg.value then
arg.type=newTypeRef(arg.value)
elseif lastType then
arg.type=lastType
else
vi:err('argument type expected '..i,arg)
end
end
lastType=arg.type
end
local prevHasDefault=false
for i,arg in ipairs(args) do
if arg.value then
prevHasDefault=true
elseif prevHasDefault and arg.name~='...' then
vi:err('non-optional argument follows optional argument', arg)
end
if not ft.typeonly then
vi:addDecl(arg)
end
arg.argId=i
if arg.name=='...' then
if i<#args then vi:err('vararg should only appear at the end',arg) end
arg.type={tag='vararg',type=arg.type}
end
end
end
end
function post.functype(vi,ft)
end
function pre.tabletype( vi,tt )
if tt.ktype=='empty' then tt.ktype=numberType end
tt.valuetype=true
end
function pre.signaldecl( vi,sig )
local args=sig.args
if args then
spreadVarTypes(args,true,vi)
for i,arg in ipairs(args) do
if arg.name=='...' then
if i<#args then vi:err('vararg should only appear at the end',arg) end
arg.type={tag='vararg',type=arg.type}
end
end
end
end
------------
function pre.catch(vi,c)
vi:pushScope()
for i,v in ipairs(c.vars) do
vi:addDecl(v)
end
end
function post.catch(vi,c)
vi:popScope()
end
------------
function pre.foreachstmt(vi,f)
vi:pushScope()
for i,v in ipairs(f.vars) do
v.vtype='local'
vi:addDecl(v)
end
end
function post.foreachstmt(vi,f)
spreadVarTypes(f.vars,false,vi)
for i,v in ipairs(f.vars) do
if not v.type then --make typeref
local val={tag='mulval',src=f.iterator,idx=i-1}
v.type=newTypeRef(val)
v.value=val
end
end
vi:popScope()
end
function pre.forstmt(vi,f)
vi:pushScope()
f.var.type=numberType
f.var.vtype='local'
vi:addDecl(f.var)
end
function post.forstmt(vi,f)
vi:popScope()
end
function pre.whilestmt( vi,f )
vi:pushScope()
end
function post.whilestmt( vi,f )
vi:popScope()
end
function pre.cyclestmt( vi,f )
vi:pushScope()
end
function post.cyclestmt( vi,f )
vi:popScope()
end
function pre.repeatstmt( vi,f )
vi:pushScope()
end
function post.repeatstmt( vi,f )
vi:popScope()
end
function pre.classdecl(vi,c)
c.type=classMetaType
c.valuetype=true
vi:pushName(c.alias or c.name)
if c.extern then
for i,d in ipairs(c.decls) do
d.extern=true
end
vi:pushExternName(c.alias or c.name)
end
vi:pushScope()
vi.depth=vi.depth+1
end
function post.classdecl(vi,c)
if c.tvars then
for i,v in ipairs(c.tvars) do
vi:addDecl(v)
end
end
if c.decls then
for i,d in ipairs(c.decls) do
vi:addDecl(d,true)
end
if not vi.currentScope['__init'] then
for k,d in pairs(vi.currentScope) do
if d.vtype=='field' and d.value then
--has default value,
--create a empty initializer container, fill it in resolver
local loader={
tag='methoddecl',
type={tag='functype',args={},rettype=voidType},
name='__init',
block={tag='block'},
module=vi.currentModule
}
table.insert(c.decls,loader)
vi:addDecl(loader,true)
break
end
end
end
end
vi:popScope()
vi:popName()
if c.extern then vi:popExternName(c.name) end
vi.depth=vi.depth-1
end
---
function pre.enumdecl(vi,e)
vi:pushName(e.name)
vi:pushScope()
for i,ei in ipairs(e.items) do
vi:addDecl(ei)
end
end
function post.enumdecl(vi,c)
vi:popScope()
vi:popName()
end
-- function pre:signaldecl(s)
-- s.type=
-- end
function post.varacc(vi,a)
a.scope=vi.currentScope
end |
-------------------------------------------------
-- Pomodoro Arc Widget for Awesome Window Manager
-- Modelled after Pavel Makhov's work
-- @author Raphaël Fournier-S'niehotta
-- @copyright 2018 Raphaël Fournier-S'niehotta
-------------------------------------------------
local awful = require("awful")
local beautiful = require("beautiful")
local spawn = require("awful.spawn")
local watch = require("awful.widget.watch")
local wibox = require("wibox")
local naughty = require("naughty")
local GET_pomodoro_CMD = "/home/raph/scripts/pomo/pomo.sh clock"
local PAUSE_pomodoro_CMD = "/home/raph/scripts/pomo/pomo.sh pause"
local START_pomodoro_CMD = "/home/raph/scripts/pomo/pomo.sh start"
local STOP_pomodoro_CMD = "/home/raph/scripts/pomo/pomo.sh stop"
local text = wibox.widget {
id = "txt",
--font = "Play 12",
font = "Inconsolata Medium 13",
widget = wibox.widget.textbox
}
-- mirror the text, because the whole widget will be mirrored after
local mirrored_text = wibox.container.margin(wibox.container.mirror(text, { horizontal = true }))
mirrored_text.right = 5 -- pour centrer le texte dans le rond
--
--local mirrored_text = wibox.container.mirror(text, { horizontal = true })
-- mirrored text with background
local mirrored_text_with_background = wibox.container.background(mirrored_text)
local pomodoroarc = wibox.widget {
mirrored_text_with_background,
max_value = 1,
thickness = 2,
start_angle = 4.71238898, -- 2pi*3/4
forced_height = 32,
forced_width = 32,
rounded_edge = true,
bg = "#ffffff11",
paddings = 0,
widget = wibox.container.arcchart
}
local pomodoroarc_widget = wibox.container.mirror(pomodoroarc, { horizontal = true })
local update_graphic = function(widget, stdout, _, _, _)
local pomostatus = string.match(stdout, " (%D?%D?):%D?%D?")
if pomostatus == "--" then
text.font = "Inconsolata Medium 13"
widget.colors = { beautiful.widget_main_color }
text.text = "25"
widget.value = 1
else
text.font = "Inconsolata Medium 13"
local pomomin = string.match(stdout, "[ P]?[BW](%d?%d?):%d?%d?")
local pomosec = string.match(stdout, "[ P]?[BW]%d?%d?:(%d?%d?)")
local pomodoro = pomomin * 60 + pomosec
local status = string.match(stdout, "([ P]?)[BW]%d?%d?:%d?%d?")
local workbreak = string.match(stdout, "[ P]?([BW])%d?%d?:%d?%d?")
text.text = pomomin
--naughty.notify {
--text = pomomin,
--title = "pomodoro debug",
--timeout = 5,
--hover_timeout = 0.5,
--width = 200,
--}
if status == " " then -- clock ticking
if workbreak == "W" then
widget.value = tonumber(pomodoro/(25*60))
if tonumber(pomomin) < 5 then -- last 5 min of pomo
widget.colors = { beautiful.widget_red }
else
widget.colors = { beautiful.widget_blue }
end
elseif workbreak == "B" then -- color during pause
widget.colors = { beautiful.widget_green }
widget.value = tonumber(pomodoro/(5*60))
end
elseif status == "P" then -- paused
if workbreak == "W" then
widget.colors = { beautiful.widget_yellow }
widget.value = tonumber(pomodoro/(25*60))
text.font = "Inconsolata Medium 13"
text.text = "PW"
elseif workbreak == "B" then
widget.colors = { beautiful.widget_yellow }
widget.value = tonumber(pomodoro/(5*60))
text.font = "Inconsolata Medium 13"
text.text = "PB"
end
end
end
end
pomodoroarc:connect_signal("button::press", function(_, _, _, button)
if (button == 2) then awful.spawn(PAUSE_pomodoro_CMD, false)
elseif (button == 1) then awful.spawn(START_pomodoro_CMD, false)
elseif (button == 3) then awful.spawn(STOP_pomodoro_CMD, false)
end
spawn.easy_async(GET_pomodoro_CMD, function(stdout, stderr, exitreason, exitcode)
update_graphic(pomodoroarc, stdout, stderr, exitreason, exitcode)
end)
end)
local notification
function show_pomodoro_status()
spawn.easy_async(GET_pomodoro_CMD,
function(stdout, _, _, _)
notification = naughty.notify {
text = stdout,
title = "pomodoro status",
timeout = 5,
hover_timeout = 0.5,
width = 200,
}
end)
end
pomodoroarc:connect_signal("mouse::enter", function() show_pomodoro_status() end)
pomodoroarc:connect_signal("mouse::leave", function() naughty.destroy(notification) end)
watch(GET_pomodoro_CMD, 1, update_graphic, pomodoroarc)
return pomodoroarc_widget
|
local colorscheme = "onenord"
local status_ok, colorscheme_module = pcall(require, colorscheme)
if not status_ok then
vim.notify("Could not load colorscheme " .. colorscheme)
return
end
colorscheme_module.setup()
|
local Dictionary = script.Parent
local Llama = Dictionary.Parent
local equalObjects = require(Llama.equalObjects)
local function compare(a, b)
if type(a) ~= "table" or type(b) ~= "table" then
return a == b
end
for key, value in pairs(a) do
if b[key] ~= value then
return false
end
end
for key, value in pairs(b) do
if a[key] ~= value then
return false
end
end
return true
end
local function equals(...)
if equalObjects(...) then
return true
end
local argCount = select('#', ...)
local firstObject = select(1, ...)
for i = 2, argCount do
local object = select(i, ...)
if not compare(firstObject, object) then
return false
end
end
return true
end
return equals |
local buttonAPI = {}
local button = {}
local component = require("component")
local gpu = component.gpu
local term = require("term")
local w, h = gpu.getResolution()
local colors = {
["lime"] = 0x00FF00,
["red"] = 0xFF0000,
["black"] = 0x000000,
}
buttonStatus = nil
function buttonAPI.clear()
gpu.setBackground(colors.black)
gpu.fill(1, 1, w, h, " ")
end
function buttonAPI.clearTable()
button = {}
buttonAPI.clear()
end
function buttonAPI.setTable(name, func, param, xmin, xmax, ymin, ymax)
button[name] = {}
button[name]["func"] = func
button[name]["active"] = false
button[name]["param"] = param
button[name]["xmin"] = xmin
button[name]["xmax"] = xmax
button[name]["ymin"] = ymin
button[name]["ymax"] = ymax
end
function buttonAPI.fill(text, color, bData)
local yspot = math.floor((bData["ymin"] + bData["ymax"]) / 2)
local xspot = math.floor((bData["xmax"] + bData["xmin"] - string.len(text)) / 2) + 1
local oldColor = gpu.setBackground(color)
gpu.fill(bData["xmin"], bData["ymin"], (bData["xmax"] - bData["xmin"] + 1), (bData["ymax"] - bData["ymin"] + 1), " ")
gpu.set(xspot, yspot, text)
gpu.setBackground(oldColor)
end
function buttonAPI.screen()
local currColor
for name, data in pairs(button) do
local on = data["active"]
if on == true then currColor = colors.lime else currColor = colors.red end
buttonAPI.fill(name, currColor, data)
end
end
function buttonAPI.toggleButton(name)
button[name]["active"] = not button[name]["active"]
buttonStatus = button[name]["active"]
buttonAPI.screen()
end
function buttonAPI.flash(name, length)
buttonAPI.toggleButton(name)
buttonAPI.screen()
if (length == nil) then
os.sleep(0.05)
else
os.sleep(length)
end
buttonAPI.toggleButton(name)
buttonAPI.screen()
end
function buttonAPI.checkxy(x, y)
for _, data in pairs(button) do
if (y >= data["ymin"] and y <= data["ymax"]) then
if (x >= data["xmin"] and x <= data["xmax"]) then
if (data["param"] == "") then
data["func"]()
else
data["func"](data["param"])
end
return true
end
end
end
return false
end
function buttonAPI.heading(text)
w, h = gpu.getResolution()
term.setCursor((w - string.len(text)) / 2 + 1, 1)
term.write(text)
end
function buttonAPI.label(w, h, text, center)
if (center) then
w, _ = gpu.getResolution()
term.setCursor((w - string.len(text)) / 2 + 1, h)
term.write(text)
else
term.setCursor(w, h)
term.write(text)
end
end
return buttonAPI
|
require("gitsigns").setup({
keymaps = {
-- Default keymap options
noremap = true,
["n ]h"] = { expr = true, "&diff ? ']c' : '<cmd>lua require\"gitsigns.actions\".next_hunk()<CR>zz'" },
["n [h"] = { expr = true, "&diff ? '[c' : '<cmd>lua require\"gitsigns.actions\".prev_hunk()<CR>zz'" },
},
})
|
package.path = "../lua/?.lua"
local evdtest = require("evdtest")
a = 3
undef(a)
|
function test.foo(t)
t:eq( 0, 0, '0 is 0' )
end
|
--* Localization for enUS & enGB clients [GUI]
--// System //--
L_GUI_APPLY = 'Apply'
L_SYSTEM_ERROR = 'You can`t do that while in combat!'
--// Main //--
L_GUI_MAIN = 'Main'
L_GUI_MAIN_UISCALE = 'Use UI Scale'
L_GUI_MAIN_RESTYLEUI = 'Restyles Default BlizzardUI'
L_GUI_MAIN_ANNOUNCE = 'Announces Spell Messages'
L_GUI_MAIN_DURABILITY = 'Display Durability Items'
L_GUI_MAIN_MISC = 'Enable Miscs'
L_GUI_MAIN_DECLINEDUEL = 'Dicline Duels'
L_GUI_MAIN_AUTOINVITE = 'Auto Invite Group'
L_GUI_MAIN_AUTOGREED = 'Auto Greed Items'
L_GUI_MAIN_AUTORELEASE = 'Auto Release Spirit'
L_GUI_MAIN_AUTOQUEST = 'Auto Accept Quests'
L_GUI_MAIN_AUTOLOOT = 'Auto Loot'
L_GUI_MAIN_AUTOMERCHANT = 'Auto Merchant (Sell & Repair)'
L_GUI_MAIN_DPSMETER = 'Enable DPS Meter'
L_GUI_MAIN_DPSMETERFADE = 'Enable Fade Mode'
L_GUI_MAIN_DPSMETERTITLE = 'Display Title Texts'
L_GUI_MAIN_DPSMETERCOMBAT = 'Show Only In Combat'
L_GUI_MAIN_DPSMETERLAYOUT = 'Show Background'
L_GUI_MAIN_DPSMETERLOCK = 'Lock Frame'
L_GUI_MAIN_FONT = 'Fonts: '
L_GUI_MAIN_SHADOW = 'Shadow Opacity'
L_GUI_MAIN_FONTSIZE = 'Font Size'
L_GUI_MAIN_INFO1 = 'Media & Style'
L_GUI_MAIN_INFO2 = 'Automation'
L_GUI_MAIN_INFO3 = 'Chat Options'
L_GUI_MAIN_INFO4 = 'Damage Meter'
--// Action Bar //--
L_GUI_AB = 'Bar'
L_GUI_AB_ENABLE = 'Enable Action Bar'
L_GUI_AB_SCALE = 'Bar Size'
L_GUI_AB_STYLE = 'Style:'
L_GUI_AB_MACRO = 'Display Macro Name'
L_GUI_AB_BACKGROUND = 'Display Background Buttons'
L_GUI_AB_STRIPARTS = 'Hide All Action Bar Arts'
L_GUI_AB_ENDCAPS = 'Display Endcaps (Diablo)'
L_GUI_AB_BPACK = 'Display Bpack Icon (Right)'
L_GUI_AB_MENU = 'Display Menu Icon (Left)'
--// Bags //--
L_GUI_BAGS = 'Bags'
L_GUI_BAGS_ENABLE = 'Enable Bag Module'
L_GUI_BAGS_SIZE = 'Bag Size'
L_GUI_BAGS_SPACE = 'Bag Space'
L_GUI_BAGS_COLUMNS = 'Bag Columns'
L_GUI_BAGS_BANKCOLUMNS = 'Bank Columns'
L_GUI_BAGS_INFO1 = 'Bag Options'
--// Chat //--
L_GUI_CHAT_ENABLE = 'Enable Chat'
L_GUI_CHAT_ORIENT = 'Top Orientation'
L_GUI_CHAT_EMOTE = 'Display Emote Menu'
L_GUI_CHAT_TIME = 'Show Time Stamp [H:M]'
L_GUI_CHAT_COPY = 'Chat Сopyability'
L_GUI_CHAT_TAB = 'Always Show Tabs'
--// UF //--
L_GUI_UNITS = 'Units'
L_GUI_UNITS_CLASSPORTRAIT = 'Class Portraits'
L_GUI_UNITS_FAT_STYLE = 'Fat Style Frames'
L_GUI_UNITS_STATUSBARS = 'Statusbar: '
L_GUI_UNITS_SMOOTH = 'Smooth Health/Power Bar'
L_GUI_UNITS_AURATIMER = 'Display Aura Timer'
L_GUI_UNITS_AURAPOS = 'Aura Pos: '
L_GUI_UNITS_AURASELF = 'Display Self Auras'
L_GUI_UNITS_ENCHANTOUF = 'Poison Icon Near Player'
L_GUI_UNITS_COMBATTEXT = 'Display Portrait CombatText'
L_GUI_UNITS_THREATGLOW = 'Show Units Combat Glow'
L_GUI_UNITS_STATUSFLASH = 'Show Player Combat Flash'
L_GUI_UNITS_COMBAT = 'Show Swords In Combat'
L_GUI_UNITS_COMBOPOINTS = 'Enable Combo Points'
L_GUI_UNITS_CPNUMBER = 'Combo Points As Number'
L_GUI_UNITS_SHOWPARTY = 'Show Party Members'
L_GUI_UNITS_PARTYRAID = 'Show Party Members In Raid'
L_GUI_UNITS_CBTICK = 'Display Castbar Ticks'
L_GUI_UNITS_CBCOLORS = 'Castbar Class Colors'
L_GUI_UNITS_ABSORB = 'Show Absorb Bar (Blue Line)'
L_GUI_UNITS_HEALCOMM = 'Enable HealComm Plugin'
L_GUI_UNITS_INFO1 = 'Unit Styles'
L_GUI_UNITS_INFO2 = 'Misc'
L_GUI_UNITS_INFO3 = 'Style Options'
--// Tip //--
L_GUI_TIP = 'Tips'
L_GUI_TIP_ENABLE = 'Enable Tooltips'
L_GUI_TIP_HIDE_INCOMBAT = 'Hide In Combat'
L_GUI_TIP_HIDE_UNITS = 'Hide Units'
L_GUI_TIP_CURSOR = 'Anchor To Cursor'
L_GUI_TIP_INFO1 = 'Tooltips'
--// CombatText //--
L_GUI_CT = 'Combat'
L_GUI_CT_ENABLE = 'Enable Combat Text'
L_GUI_CT_BLIZZNUM = 'Use Blizzard Output'
L_GUI_CT_DMGSTYLE = 'Replace Default Font'
L_GUI_CT_DAMAGE = 'Show Outgoing Damage'
L_GUI_CT_HEALING = 'Show Outgoing Healing'
L_GUI_CT_HOTS = 'Show Hots'
L_GUI_CT_OVERHEAL = 'Show Outgoing Overhealing'
L_GUI_CT_PETDMG = 'Show Your Pet Damage'
L_GUI_CT_DOTDMG = 'Show Dots Damage'
L_GUI_CT_COLORS = 'Display Numbers Colors'
L_GUI_CT_CRITPREFIX = 'Symbol that will be added before crit'
L_GUI_CT_POSTFIX = 'Symbol that will be added after crit'
L_GUI_CT_ICONS = 'Show Outgoing Icons'
L_GUI_CT_ICONSIZE = 'Icon Size of Spells'
L_GUI_CT_THRESHOLD = 'Minimum damage to show in damage frame'
L_GUI_CT_HEALTHRESHOLD = 'Minimum Healing to show in incoming/Outgoing Healing messages'
L_GUI_CT_SCROLLABLE = 'Allows Mousewheel Lines'
L_GUI_CT_MAXLINE = 'Max lines to keep in scrollable mode (more lines = more memory)'
L_GUI_CT_SHOWTIME = 'Time(seconds) a single message will be visible'
L_GUI_CT_KILLINGBLOW = 'Show KillingBlow (In Party)'
L_GUI_CT_AOESPAM = 'Merges AoE Damage Spam'
L_GUI_CT_MELEE = 'Merges Auto-Attack Spam'
L_GUI_CT_DISPEL = 'Tells About Your Dispels'
L_GUI_CT_INTERRUPT = 'Tells About Your Interrupts'
L_GUI_CT_DIRECTION = "Scrolling Direction('top'(goes down) or 'bottom'(goes up))"
L_GUI_CT_SHORTNUMBERS = 'Use Short Numbers (25.3k)'
L_GUI_CT_INFO1 = 'Combat Text'
L_GUI_CT_INFO2 = 'Outgoing'
L_GUI_CT_INFO3 = 'Misc'
--// InfoBox //--
L_GUI_INFO_IBX_START = '|cf2f3f4ffWelcome to Sohigh|r|cffa800a5UI|r!'
L_GUI_INFO_IBX_A = '|cf2f3f4ffVersion: 1.0|r (|cff00b5ffBeta|r)'
L_GUI_INFO_IBX_B = '|cf2f3f4ffAuthor:|r |C00EB7823Sohigh|R'
L_GUI_INFO_IBX_C = '|cf2f3f4ffNotes: Styled default UI|r'
L_GUI_INFO_IBX_D = '|cf2f3f4ffCommand:|r /sui |cf2f3f4ffor click on icon|r'
L_GUI_INFO_IBX_E = '|cf2f3f4ffGithub: sativahigh|r'
L_GUI_INFO_IBX_F = '|cf2f3f4ffCommunity of TBC Addons:|r'
L_GUI_INFO_IBX_G = '|cff00b5ffdiscord.gg/5qVu56M|r'
L_GUI_INFO_IBX_H = 'Support the Author: WebMoney'
L_GUI_INFO_IBX_I = '|cffe8b62bZ|r|cf2f3f4ff505976462488|r'
L_GUI_INFO_IBX_J = '|cff409dffE|r|cf2f3f4ff604523622537|r'
L_GUI_INFO_IBX_K = '|cffff2400R|r|cf2f3f4ff876994451229|r'
--L_GUI_INFO_IBX_NIL = 'Reset'
L_GUI_INFO_IBX_ADDON = 'AddOn Info'
L_GUI_INFO_IBX_CONTACT = 'Contact Info'
|
-- Modified from https://github.com/sainnhe/edge/blob/master/lua/lualine/themes/edge.lua
local palette = require("edge_lush.palette")
palette = vim.tbl_map(function(hsl)
return tostring(hsl):lower()
end, palette)
return {
normal = {
a = { bg = palette.bg_purple, fg = palette.bg0, gui = "bold" },
b = { bg = palette.bg4, fg = palette.fg },
c = { bg = palette.bg1, fg = palette.fg },
},
insert = {
a = { bg = palette.bg_blue, fg = palette.bg0, gui = "bold" },
b = { bg = palette.bg4, fg = palette.fg },
c = { bg = palette.bg1, fg = palette.fg },
},
visual = {
a = { bg = palette.bg_red, fg = palette.bg0, gui = "bold" },
b = { bg = palette.bg4, fg = palette.fg },
c = { bg = palette.bg1, fg = palette.fg },
},
replace = {
a = { bg = palette.yellow, fg = palette.bg0, gui = "bold" },
b = { bg = palette.bg4, fg = palette.fg },
c = { bg = palette.bg1, fg = palette.fg },
},
command = {
a = { bg = palette.bg_green, fg = palette.bg0, gui = "bold" },
b = { bg = palette.bg4, fg = palette.fg },
c = { bg = palette.bg1, fg = palette.fg },
},
terminal = {
a = { bg = palette.cyan, fg = palette.bg0, gui = "bold" },
b = { bg = palette.bg4, fg = palette.fg },
c = { bg = palette.bg1, fg = palette.fg },
},
inactive = {
a = { bg = palette.bg1, fg = palette.grey },
b = { bg = palette.bg1, fg = palette.grey },
c = { bg = palette.bg1, fg = palette.grey },
},
}
|
-- Game hook mod injector
function listener()
local playerTurns = ""
for i,a in pairs(Players) do
if a:IsEverAlive() and a:IsHuman() then
playerTurns = playerTurns .. "{" ..
'"id" : ' .. tostring(a:GetID()) .. "," ..
'"nickName" : ' .. '"' .. a:GetNickName() .. '"' .. "," ..
'"civilization" : ' .. '"' .. a:GetCivilizationShortDescription() .. '"' .. "," ..
'"isTurnComplete" : ' .. tostring(a:HasReceivedNetTurnComplete()) .. "," ..
'"isOnline" : ' .. tostring(Network.IsPlayerConnected(a:GetID())) .. "," ..
'"isAlive" : ' .. tostring(a:IsAlive()) ..
"},"
end
end
print("----JSON----{" ..
'"gameTurn" : ' .. tostring(Game.GetGameTurn()) .."," ..
'"players" : [' .. playerTurns:sub(1, -2) .. "]" ..
"}----JSON----")
end
print("----GameHook: GameHook listener initialized.")
Events.RemotePlayerTurnEnd.Add(listener)
Events.RemotePlayerTurnStart.Add(listener)
Events.ActivePlayerTurnStart.Add(listener)
Events.ActivePlayerTurnEnd.Add(listener)
Events.MultiplayerGamePlayerDisconnected.Add(listener)
Events.MultiplayerGamePlayerUpdated.Add(listener)
Events.MultiplayerHotJoinCompleted.Add(listener)
|
// Copyright 2006-2013 Robert Gieseke. See LICENSE.
// Literate CoffeeScript LPeg lexer.
// http://coffeescript.org/#literate
var l = require('lexer');
var token = l.token;
var P = lpeg.P;
var M = {_NAME = 'litcoffee'};
// Embedded in Markdown.
var markdown = l.load('markdown');
M._lexer = markdown; // ensure markdown's rules are loaded, not HTML's
// Embedded CoffeeScript.
var coffeescript = l.load('coffeescript');
var coffee_start_rule = token(l.STYLE_EMBEDDED, (P(' ')**4 + P('\t')));
var coffee_end_rule = token(l.STYLE_EMBEDDED, l.newline);
l.embed_lexer(markdown, coffeescript, coffee_start_rule, coffee_end_rule);
return M;
|
--# selene: allow(unused_variable)
---@diagnostic disable: unused-local
-- This sub-module is used to access the individual results of a spotlightObject or a spotlightGroupObject.
--
-- Each Spotlight item contains attributes which you can access with the [hs.spotlight.item:valueForAttribute](#valueForAttribute) method. An array containing common attributes for the type of entity the item represents can be retrieved with the [hs.spotlight.item:attributes](#attributes) method, however this list of attributes is usually not a complete list of the attributes available for a given spotlightItemObject. Many of the known attribute names are included in the `hs.spotlight.commonAttributeKeys` constant array, but even this is not an exhaustive list -- an application may create and assign any key it wishes to an entity for inclusion in the Spotlight metadata database.
--
-- For convenience, metamethods have been added to the spotlightItemObjects as a shortcut to the [hs.spotlight.item:valueForAttribute](#valueForAttribute) method; e.g. you can access the value of a specific attribute by treating the attribute as a key name: `spotlightItemObject.kMDItemPath` will return the path to the entity the spotlightItemObject refers to.
---@class hs.spotlight.item
local M = {}
hs.spotlight.item = M
-- Returns a list of attributes associated with the spotlightItemObject
--
-- Parameters:
-- * None
--
-- Returns:
-- * an array table containing a list of attributes associated with the result item.
--
-- Notes:
-- * This list of attributes is usually not a complete list of the attributes available for a given spotlightItemObject. Many of the known attribute names are included in the `hs.spotlight.commonAttributeKeys` constant array, but even this is not an exhaustive list -- an application may create and assign any key it wishes to an entity for inclusion in the Spotlight metadata database.
--
-- * A common attribute, which is not usually included in the results of this method is the "kMDItemPath" attribute which specifies the local path to the file the entity represents. This is included here for reference, as it is a commonly desired value that is not obviously available for almost all Spotlight entries.
-- * It is believed that only those keys which are explicitly set when an item is added to the Spotlight database are included in the array returned by this method. Any attribute which is calculated or restricted in a sandboxed application appears to require an explicit request. This is, however, conjecture, and when in doubt you should explicitly check for the attributes you require with [hs.spotlight.item:valueForAttribute](#valueForAttribute) and not rely solely on the results from this method.
function M:attributes() end
-- Returns the value for the specified attribute of the spotlightItemObject
--
-- Parameters:
-- * `attribute` - a string specifying the attribute to get the value of for the spotlightItemObject
--
-- Returns:
-- * the attribute value as an appropriate data type or nil if the attribute does not exist or contains no value
--
-- Notes:
-- * See [hs.spotlight.item:attributes](#attributes) for information about possible attribute names.
--
-- * For convenience, metamethods have been added to the spotlightItemObject which allow you to use `spotlightItemObject.attribute` as a shortcut for `spotlightItemObject:valueForAttribute(attribute)`.
function M:valueForAttribute(attribute, ...) end
|
local arr = {"a", "b"}
table.insert(arr, 1, 2)
for key, value in ipairs(arr) do
print(key, value)
end |
local ljson_decoder = require"json_decoder"
local instance = ljson_decoder.new()
local luafile = io.open("benchdata/simpledata.json", "rb")
local text = luafile:read("*all")
luafile:close()
function run_iter(count)
for n=1, count do
local result, err = instance:decode(text)
assert(result and not err)
end
end
|
if not loadLuaFileInRpgDir or not loadLuaFileInGameDir then
local function loadFunc(path)
return loadfile(path .. 'lua_file_loader.lua')()
end
local function tryLoadLuaFileLoader()
for _, offset in ipairs({ './', './../', './lua/rpg/', './../lua/rpg/', './../../lua/rpg/' }) do
local loadOk, _, _, _, setRpgGameNameBySource = pcall(loadFunc, offset)
if loadOk then
setRpgGameNameBySource(debug.getinfo(1).source)
return true
end
end
return false
end
if tryLoadLuaFileLoader() then
print ('[log] load "lua_file_loader.lua" success.')
else
error('[error] load "lua_file_loader.lua" failed.')
end
end
ActionGroup = {
--gameName = '',
--pathOffset = './%s/',
-- ?lua_file_loader 记录 gameName 并提供 加载game目录下文件的方法 ...
-- ?所以其他地方不再需要 pathOffset ...
actionCsvConfigTable = nil,
lib = nil,
needCache = false,
objCache = nil,
DEBUG_MODE = false,
}
function ActionGroup:new(o)
o = o or {}
setmetatable(o, self)
self.__index = self
self.actionCsvConfigTable = nil
self.lib = {}
self.needCache = false
self.objCache = {}
self.DEBUG_MODE = false
return o
end
function ActionGroup:setDebugMode(debug)
self.DEBUG_MODE = (debug ~= false)
end
local loadCsvConfigTable = loadLuaFileInRpgDir('csv_table_maker.lua', false)
if not loadCsvConfigTable then
print ('[error]', 'load "csv_table_maker.lua" failed.')
end
function ActionGroup:getCsvConfigTable()
if self.actionCsvConfigTable then
return self.actionCsvConfigTable
else
local csvFilename = 'csv/actions.csv'
local csvConfigTable = loadCsvConfigTable(csvFilename, 'aid')
if csvConfigTable then
self.actionCsvConfigTable = csvConfigTable
return csvConfigTable
else
print ('[error]', 'load csv config table "' .. csvFilename .. '" failed.')
end
end
end
function ActionGroup:getActionData(aid)
return self:getCsvConfigTable().rowInfos[aid]
end
--[[
local actionCodeMakeFunc = loadLuaFileInRpgDir('action_lua_code_maker.lua', false)
if not actionCodeMakeFunc then
print ('[error]', 'load "action_lua_code_maker.lua" failed.')
end
function ActionGroup:getActionCode(aid)
return actionCodeMakeFunc(self:getActionData(aid))
end
function ActionGroup:loadActionClass(aid)
local classCode = self:getActionCode(aid)
self.lib[aid] = load(classCode)()
return self.lib[aid]
end
function ActionGroup:requireActionClass(aid)
return self.lib[aid] or self:loadActionClass(aid)
end
function ActionGroup:requireActionObj(aid)
if not self.objCache[aid] then
if self.needCache then
self.objCache[aid] = self:requireActionClass(aid):new()
else
return self:requireActionClass(aid):new()
end
end
return self.objCache[aid]
end
]]
local getActionByData = loadLuaFileInRpgDir('action_factory.lua', false)
function ActionGroup:requireActionObj(aid)
if not self.objCache[aid] then
local obj = getActionByData(self:getActionData(aid))
if not obj then
print ('[error]', 'not found action ' .. aid .. '.')
return nil
elseif self.needCache then
self.objCache[aid] = obj
return self.objCache[aid]
else
return obj
end
end
return self.objCache[aid]
end
local function createActionGroup()
return ActionGroup:new(nil)
end
-- for test
--[[
local actGroup = createActionGroup('./actionLib/output/')
actGroup:setDebugMode()
local action = actGroup:requireActionClass(1)
print (action:new():test())
actGroup:requireActionClass(1):new():test()
actGroup:requireActionClass(2):new():test()
actGroup:requireActionClass(3):new():test()
actGroup:requireActionClass(6):new():test()
actGroup:requireActionClass(11):new():test()
actGroup:requireActionClass(42):new():test()
]]
-- for test
--[[
local actGroup = createActionGroup('./actionLib/output/')
actGroup:setDebugMode()
local action = actGroup:requireActionClass(1)
print (action:new():test())
actGroup:requireActionObj(1):test()
actGroup:requireActionObj(2):test()
actGroup:requireActionObj(3):test()
actGroup:requireActionObj(6):test()
actGroup:requireActionObj(11):test()
actGroup:requireActionObj(42):test()
]]
-- for debug
--[[
if not loadLuaFileInRpgDir or not loadLuaFileInGameDir then
local function loadFunc(path)
return loadfile(path .. 'lua_file_loader.lua')()
end
local function tryLoadLuaFileLoader()
for _, offset in ipairs({ './', './../', './lua/rpg/', './../lua/rpg/', './../../lua/rpg/' }) do
local loadOk, _, _, _, setRpgGameNameBySource = pcall(loadFunc, offset)
if loadOk then
setRpgGameNameBySource(debug.getinfo(1).source)
return true
end
end
return false
end
if tryLoadLuaFileLoader() then
print ('[log] load "lua_file_loader.lua" success.')
else
error('[error] load "lua_file_loader.lua" failed.')
end
end
if not loadLuaFileInRpgDir('action_model.lua', true) then
error('[error] load "action_model.lua" failed.')
end
print ()
print ()
print ()
print ()
ActionBase:test()
a1 = ActionBase:new(nil, 111, 2, 3)
print (a1)
a1:test()
ActionBase:test()
a2 = ActionBase:new(nil, 222, 44, 66)
print (a2)
a2:test()
ActionBase:test()
print ()
print ()
print ()
print ()
]]
return createActionGroup
-- usage :
--[[
local actGroup = createActionGroup('./xx')
local action = actGroup:requireActionObj(123)
]]
|
--
-- created with TexturePacker - https://www.codeandweb.com/texturepacker
--
-- $TexturePacker:SmartUpdate:1bcdb78b6183204ec35bd1d9528179ef:bec8917ba21f83e2ae490ccb2a64a2b9:662e339976a0837a1f28f0ec9a027adb$
--
-- local sheetInfo = require("mysheet")
-- local myImageSheet = graphics.newImageSheet( "mysheet.png", sheetInfo:getSheet() )
-- local sprite = display.newSprite( myImageSheet , {frames={sheetInfo:getFrameIndex("sprite")}} )
--
local SheetInfo = {}
SheetInfo.sheet =
{
frames = {
{
-- dg_effects32-0
x=471,
y=1,
width=16,
height=28,
sourceX = 9,
sourceY = 3,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-1
x=375,
y=33,
width=30,
height=30,
sourceX = 2,
sourceY = 2,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-2
x=681,
y=19,
width=16,
height=16,
sourceX = 8,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-3
x=717,
y=105,
width=6,
height=16,
sourceX = 14,
sourceY = 10,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-4
x=667,
y=113,
width=12,
height=14,
sourceX = 10,
sourceY = 10,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-5
x=707,
y=1,
width=28,
height=16,
sourceX = 3,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-6
x=543,
y=1,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-7
x=517,
y=31,
width=16,
height=28,
sourceX = 9,
sourceY = 3,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-8
x=567,
y=1,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-9
x=657,
y=1,
width=28,
height=16,
sourceX = 3,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-10
x=1,
y=103,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-11
x=647,
y=49,
width=28,
height=16,
sourceX = 3,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-12
x=595,
y=49,
width=20,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-13
x=69,
y=69,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-14
x=103,
y=1,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-15
x=103,
y=35,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-16
x=103,
y=69,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-17
x=313,
y=97,
width=32,
height=30,
sourceX = 0,
sourceY = 2,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-18
x=341,
y=1,
width=32,
height=30,
sourceX = 0,
sourceY = 2,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-19
x=671,
y=67,
width=28,
height=16,
sourceX = 3,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-20
x=381,
y=97,
width=30,
height=30,
sourceX = 2,
sourceY = 2,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-21
x=509,
y=121,
width=18,
height=6,
sourceX = 8,
sourceY = 14,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-22
x=653,
y=113,
width=12,
height=14,
sourceX = 10,
sourceY = 10,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-23
x=701,
y=73,
width=16,
height=16,
sourceX = 9,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-24
x=529,
y=109,
width=6,
height=18,
sourceX = 14,
sourceY = 8,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-25
x=169,
y=103,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-26
x=651,
y=25,
width=28,
height=16,
sourceX = 3,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-27
x=193,
y=103,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-28
x=217,
y=103,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-29
x=487,
y=65,
width=16,
height=28,
sourceX = 9,
sourceY = 3,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-30
x=577,
y=97,
width=20,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-31
x=597,
y=73,
width=20,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-32
x=137,
y=1,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-33
x=241,
y=103,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-34
x=137,
y=35,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-35
x=137,
y=69,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-36
x=341,
y=33,
width=32,
height=30,
sourceX = 0,
sourceY = 2,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-37
x=341,
y=65,
width=32,
height=30,
sourceX = 0,
sourceY = 2,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-38
x=265,
y=103,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-39
x=407,
y=33,
width=30,
height=30,
sourceX = 2,
sourceY = 2,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-40
x=577,
y=121,
width=18,
height=6,
sourceX = 8,
sourceY = 14,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-41
x=641,
y=87,
width=16,
height=6,
sourceX = 9,
sourceY = 14,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-42
x=537,
y=109,
width=6,
height=18,
sourceX = 14,
sourceY = 8,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-43
x=681,
y=85,
width=16,
height=16,
sourceX = 8,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-44
x=289,
y=103,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-45
x=523,
y=61,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-46
x=499,
y=31,
width=16,
height=28,
sourceX = 9,
sourceY = 3,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-47
x=535,
y=31,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-48
x=677,
y=43,
width=28,
height=16,
sourceX = 3,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-49
x=617,
y=49,
width=20,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-50
x=629,
y=25,
width=20,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-51
x=171,
y=1,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-52
x=171,
y=35,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-53
x=171,
y=69,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-54
x=205,
y=1,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-55
x=707,
y=19,
width=28,
height=16,
sourceX = 3,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-56
x=439,
y=33,
width=28,
height=30,
sourceX = 3,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-57
x=441,
y=1,
width=28,
height=30,
sourceX = 3,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-58
x=409,
y=1,
width=30,
height=30,
sourceX = 2,
sourceY = 2,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-59
x=719,
y=73,
width=16,
height=16,
sourceX = 8,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-60
x=507,
y=1,
width=16,
height=28,
sourceX = 9,
sourceY = 3,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-61
x=681,
y=103,
width=16,
height=16,
sourceX = 8,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-62
x=527,
y=85,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-63
x=491,
y=95,
width=16,
height=28,
sourceX = 9,
sourceY = 3,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-64
x=547,
y=55,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-65
x=707,
y=37,
width=28,
height=16,
sourceX = 3,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-66
x=505,
y=61,
width=16,
height=28,
sourceX = 9,
sourceY = 3,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-67
x=559,
y=25,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-68
x=635,
y=1,
width=20,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-69
x=599,
y=97,
width=20,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-70
x=205,
y=35,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-71
x=205,
y=69,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-72
x=239,
y=1,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-73
x=239,
y=35,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-74
x=347,
y=97,
width=32,
height=30,
sourceX = 0,
sourceY = 2,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-75
x=439,
y=65,
width=28,
height=30,
sourceX = 3,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-76
x=443,
y=97,
width=28,
height=30,
sourceX = 3,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-77
x=699,
y=91,
width=16,
height=16,
sourceX = 9,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-78
x=545,
y=109,
width=6,
height=18,
sourceX = 12,
sourceY = 8,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-79
x=659,
y=87,
width=16,
height=6,
sourceX = 10,
sourceY = 14,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-80
x=597,
y=121,
width=18,
height=6,
sourceX = 8,
sourceY = 14,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-81
x=551,
y=79,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-82
x=707,
y=55,
width=28,
height=16,
sourceX = 3,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-83
x=525,
y=1,
width=16,
height=28,
sourceX = 9,
sourceY = 3,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-84
x=553,
y=103,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-85
x=509,
y=91,
width=16,
height=28,
sourceX = 9,
sourceY = 3,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-86
x=571,
y=49,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-87
x=619,
y=73,
width=20,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-88
x=583,
y=25,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-89
x=239,
y=69,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-90
x=273,
y=1,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-91
x=273,
y=35,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-92
x=273,
y=69,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-93
x=375,
y=1,
width=32,
height=30,
sourceX = 0,
sourceY = 2,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-94
x=469,
y=33,
width=28,
height=30,
sourceX = 3,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-95
x=407,
y=65,
width=30,
height=30,
sourceX = 2,
sourceY = 2,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-96
x=639,
y=49,
width=6,
height=18,
sourceX = 14,
sourceY = 8,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-97
x=699,
y=109,
width=16,
height=16,
sourceX = 8,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-98
x=717,
y=91,
width=14,
height=12,
sourceX = 9,
sourceY = 11,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-99
x=617,
y=121,
width=18,
height=6,
sourceX = 8,
sourceY = 14,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-100
x=489,
y=1,
width=16,
height=28,
sourceX = 9,
sourceY = 3,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-101
x=25,
y=103,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-102
x=621,
y=97,
width=28,
height=16,
sourceX = 3,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-103
x=49,
y=103,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-104
x=641,
y=69,
width=28,
height=16,
sourceX = 3,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-105
x=591,
y=1,
width=20,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-106
x=575,
y=73,
width=20,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-107
x=1,
y=1,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-108
x=1,
y=35,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-109
x=1,
y=69,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-110
x=469,
y=65,
width=16,
height=28,
sourceX = 9,
sourceY = 3,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-111
x=35,
y=1,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-112
x=307,
y=1,
width=32,
height=30,
sourceX = 0,
sourceY = 2,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-113
x=413,
y=97,
width=28,
height=30,
sourceX = 3,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-114
x=375,
y=65,
width=30,
height=30,
sourceX = 2,
sourceY = 2,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-115
x=73,
y=103,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-116
x=637,
y=115,
width=14,
height=12,
sourceX = 10,
sourceY = 11,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-117
x=699,
y=19,
width=6,
height=16,
sourceX = 12,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-118
x=687,
y=1,
width=16,
height=16,
sourceX = 8,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-119
x=651,
y=95,
width=28,
height=16,
sourceX = 3,
sourceY = 9,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-120
x=97,
y=103,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-121
x=121,
y=103,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-122
x=473,
y=95,
width=16,
height=28,
sourceX = 9,
sourceY = 3,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-123
x=145,
y=103,
width=22,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-124
x=607,
y=25,
width=20,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-125
x=613,
y=1,
width=20,
height=22,
sourceX = 6,
sourceY = 6,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-126
x=35,
y=35,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-127
x=35,
y=69,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-128
x=69,
y=1,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-129
x=69,
y=35,
width=32,
height=32,
sourceX = 1,
sourceY = 1,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-130
x=307,
y=33,
width=32,
height=30,
sourceX = 0,
sourceY = 2,
sourceWidth = 34,
sourceHeight = 34
},
{
-- dg_effects32-131
x=307,
y=65,
width=32,
height=30,
sourceX = 0,
sourceY = 2,
sourceWidth = 34,
sourceHeight = 34
},
},
sheetContentWidth = 736,
sheetContentHeight = 128
}
SheetInfo.frameIndex =
{
["dg_effects32-0"] = 1,
["dg_effects32-1"] = 2,
["dg_effects32-2"] = 3,
["dg_effects32-3"] = 4,
["dg_effects32-4"] = 5,
["dg_effects32-5"] = 6,
["dg_effects32-6"] = 7,
["dg_effects32-7"] = 8,
["dg_effects32-8"] = 9,
["dg_effects32-9"] = 10,
["dg_effects32-10"] = 11,
["dg_effects32-11"] = 12,
["dg_effects32-12"] = 13,
["dg_effects32-13"] = 14,
["dg_effects32-14"] = 15,
["dg_effects32-15"] = 16,
["dg_effects32-16"] = 17,
["dg_effects32-17"] = 18,
["dg_effects32-18"] = 19,
["dg_effects32-19"] = 20,
["dg_effects32-20"] = 21,
["dg_effects32-21"] = 22,
["dg_effects32-22"] = 23,
["dg_effects32-23"] = 24,
["dg_effects32-24"] = 25,
["dg_effects32-25"] = 26,
["dg_effects32-26"] = 27,
["dg_effects32-27"] = 28,
["dg_effects32-28"] = 29,
["dg_effects32-29"] = 30,
["dg_effects32-30"] = 31,
["dg_effects32-31"] = 32,
["dg_effects32-32"] = 33,
["dg_effects32-33"] = 34,
["dg_effects32-34"] = 35,
["dg_effects32-35"] = 36,
["dg_effects32-36"] = 37,
["dg_effects32-37"] = 38,
["dg_effects32-38"] = 39,
["dg_effects32-39"] = 40,
["dg_effects32-40"] = 41,
["dg_effects32-41"] = 42,
["dg_effects32-42"] = 43,
["dg_effects32-43"] = 44,
["dg_effects32-44"] = 45,
["dg_effects32-45"] = 46,
["dg_effects32-46"] = 47,
["dg_effects32-47"] = 48,
["dg_effects32-48"] = 49,
["dg_effects32-49"] = 50,
["dg_effects32-50"] = 51,
["dg_effects32-51"] = 52,
["dg_effects32-52"] = 53,
["dg_effects32-53"] = 54,
["dg_effects32-54"] = 55,
["dg_effects32-55"] = 56,
["dg_effects32-56"] = 57,
["dg_effects32-57"] = 58,
["dg_effects32-58"] = 59,
["dg_effects32-59"] = 60,
["dg_effects32-60"] = 61,
["dg_effects32-61"] = 62,
["dg_effects32-62"] = 63,
["dg_effects32-63"] = 64,
["dg_effects32-64"] = 65,
["dg_effects32-65"] = 66,
["dg_effects32-66"] = 67,
["dg_effects32-67"] = 68,
["dg_effects32-68"] = 69,
["dg_effects32-69"] = 70,
["dg_effects32-70"] = 71,
["dg_effects32-71"] = 72,
["dg_effects32-72"] = 73,
["dg_effects32-73"] = 74,
["dg_effects32-74"] = 75,
["dg_effects32-75"] = 76,
["dg_effects32-76"] = 77,
["dg_effects32-77"] = 78,
["dg_effects32-78"] = 79,
["dg_effects32-79"] = 80,
["dg_effects32-80"] = 81,
["dg_effects32-81"] = 82,
["dg_effects32-82"] = 83,
["dg_effects32-83"] = 84,
["dg_effects32-84"] = 85,
["dg_effects32-85"] = 86,
["dg_effects32-86"] = 87,
["dg_effects32-87"] = 88,
["dg_effects32-88"] = 89,
["dg_effects32-89"] = 90,
["dg_effects32-90"] = 91,
["dg_effects32-91"] = 92,
["dg_effects32-92"] = 93,
["dg_effects32-93"] = 94,
["dg_effects32-94"] = 95,
["dg_effects32-95"] = 96,
["dg_effects32-96"] = 97,
["dg_effects32-97"] = 98,
["dg_effects32-98"] = 99,
["dg_effects32-99"] = 100,
["dg_effects32-100"] = 101,
["dg_effects32-101"] = 102,
["dg_effects32-102"] = 103,
["dg_effects32-103"] = 104,
["dg_effects32-104"] = 105,
["dg_effects32-105"] = 106,
["dg_effects32-106"] = 107,
["dg_effects32-107"] = 108,
["dg_effects32-108"] = 109,
["dg_effects32-109"] = 110,
["dg_effects32-110"] = 111,
["dg_effects32-111"] = 112,
["dg_effects32-112"] = 113,
["dg_effects32-113"] = 114,
["dg_effects32-114"] = 115,
["dg_effects32-115"] = 116,
["dg_effects32-116"] = 117,
["dg_effects32-117"] = 118,
["dg_effects32-118"] = 119,
["dg_effects32-119"] = 120,
["dg_effects32-120"] = 121,
["dg_effects32-121"] = 122,
["dg_effects32-122"] = 123,
["dg_effects32-123"] = 124,
["dg_effects32-124"] = 125,
["dg_effects32-125"] = 126,
["dg_effects32-126"] = 127,
["dg_effects32-127"] = 128,
["dg_effects32-128"] = 129,
["dg_effects32-129"] = 130,
["dg_effects32-130"] = 131,
["dg_effects32-131"] = 132,
}
function SheetInfo:getSheet()
return self.sheet;
end
function SheetInfo:getFrameIndex(name)
return self.frameIndex[name];
end
return SheetInfo
|
function round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end
function print_table(elt)
for i,_ in ipairs(elt) do
print(unpack(elt[i]))
end
end
function draw_collision(x,y,w,h) -- {{{2
love.graphics.rectangle("line",x,y,w,h) -- vertical left
end
function has_value(tab, val)
for _, value in ipairs(tab) do
if value == val then
return true
end
end
return false
end |
local bson = require "bson"
local socket = require "skynet.socket"
local socketchannel = require "skynet.socketchannel"
local skynet = require "skynet"
local driver = require "skynet.mongo.driver"
local md5 = require "md5"
local crypt = require "skynet.crypt"
local rawget = rawget
local assert = assert
local table = table
local bson_encode = bson.encode
local bson_encode_order = bson.encode_order
local bson_decode = bson.decode
local empty_bson = bson_encode {}
local mongo = {}
mongo.null = assert(bson.null)
mongo.maxkey = assert(bson.maxkey)
mongo.minkey = assert(bson.minkey)
mongo.type = assert(bson.type)
local mongo_cursor = {}
local cursor_meta = {
__index = mongo_cursor,
}
local mongo_client = {}
local client_meta = {
__index = function(self, key)
return rawget(mongo_client, key) or self:getDB(key)
end,
__tostring = function (self)
local port_string
if self.port then
port_string = ":" .. tostring(self.port)
else
port_string = ""
end
return "[mongo client : " .. self.host .. port_string .."]"
end,
-- DO NOT need disconnect, because channel will shutdown during gc
}
local mongo_db = {}
local db_meta = {
__index = function (self, key)
return rawget(mongo_db, key) or self:getCollection(key)
end,
__tostring = function (self)
return "[mongo db : " .. self.name .. "]"
end
}
local mongo_collection = {}
local collection_meta = {
__index = function(self, key)
return rawget(mongo_collection, key) or self:getCollection(key)
end ,
__tostring = function (self)
return "[mongo collection : " .. self.full_name .. "]"
end
}
local function dispatch_reply(so)
local len_reply = so:read(4)
local reply = so:read(driver.length(len_reply))
local result = { result = {} }
local succ, reply_id, document, cursor_id, startfrom = driver.reply(reply, result.result)
result.document = document
result.cursor_id = cursor_id
result.startfrom = startfrom
result.data = reply
return reply_id, succ, result
end
local function __parse_addr(addr)
local host, port = string.match(addr, "([^:]+):(.+)")
return host, tonumber(port)
end
local function mongo_auth(mongoc)
local user = rawget(mongoc, "username")
local pass = rawget(mongoc, "password")
local authmod = rawget(mongoc, "authmod") or "scram_sha1"
authmod = "auth_" .. authmod
return function()
if user ~= nil and pass ~= nil then
-- autmod can be "mongodb_cr" or "scram_sha1"
local auth_func = mongoc[authmod]
assert(auth_func , "Invalid authmod")
assert(auth_func(mongoc,user, pass))
end
local rs_data = mongoc:runCommand("ismaster")
if rs_data.ok == 1 then
if rs_data.hosts then
local backup = {}
for _, v in ipairs(rs_data.hosts) do
local host, port = __parse_addr(v)
table.insert(backup, {host = host, port = port})
end
mongoc.__sock:changebackup(backup)
end
if rs_data.ismaster then
if rawget(mongoc, "__pickserver") then
rawset(mongoc, "__pickserver", nil)
end
return
else
if rs_data.primary then
local host, port = __parse_addr(rs_data.primary)
mongoc.host = host
mongoc.port = port
mongoc.__sock:changehost(host, port)
else
skynet.error("WARNING: NO PRIMARY RETURN " .. rs_data.me)
-- determine the primary db using hosts
local pickserver = {}
if rawget(mongoc, "__pickserver") == nil then
for _, v in ipairs(rs_data.hosts) do
if v ~= rs_data.me then
table.insert(pickserver, v)
end
rawset(mongoc, "__pickserver", pickserver)
end
end
if #mongoc.__pickserver <= 0 then
error("CAN NOT DETERMINE THE PRIMARY DB")
end
skynet.error("INFO: TRY TO CONNECT " .. mongoc.__pickserver[1])
local host, port = __parse_addr(mongoc.__pickserver[1])
table.remove(mongoc.__pickserver, 1)
mongoc.host = host
mongoc.port = port
mongoc.__sock:changehost(host, port)
end
end
end
end
end
function mongo.client( conf )
local first = conf
local backup = nil
if conf.rs then
first = conf.rs[1]
backup = conf.rs
end
local obj = {
host = first.host,
port = first.port or 27017,
username = first.username,
password = first.password,
authmod = first.authmod,
}
obj.__id = 0
obj.__sock = socketchannel.channel {
host = obj.host,
port = obj.port,
response = dispatch_reply,
auth = mongo_auth(obj),
backup = backup,
nodelay = true,
}
setmetatable(obj, client_meta)
obj.__sock:connect(true) -- try connect only once
return obj
end
function mongo_client:getDB(dbname)
local db = {
connection = self,
name = dbname,
full_name = dbname,
database = false,
__cmd = dbname .. "." .. "$cmd",
}
db.database = db
return setmetatable(db, db_meta)
end
function mongo_client:disconnect()
if self.__sock then
local so = self.__sock
self.__sock = false
so:close()
end
end
function mongo_client:genId()
local id = self.__id + 1
self.__id = id
return id
end
function mongo_client:runCommand(...)
if not self.admin then
self.admin = self:getDB "admin"
end
return self.admin:runCommand(...)
end
function mongo_client:auth_mongodb_cr(user,password)
local password = md5.sumhexa(string.format("%s:mongo:%s",user,password))
local result= self:runCommand "getnonce"
if result.ok ~=1 then
return false
end
local key = md5.sumhexa(string.format("%s%s%s",result.nonce,user,password))
local result= self:runCommand ("authenticate",1,"user",user,"nonce",result.nonce,"key",key)
return result.ok == 1
end
local function salt_password(password, salt, iter)
salt = salt .. "\0\0\0\1"
local output = crypt.hmac_sha1(password, salt)
local inter = output
for i=2,iter do
inter = crypt.hmac_sha1(password, inter)
output = crypt.xor_str(output, inter)
end
return output
end
function mongo_client:auth_scram_sha1(username,password)
local user = string.gsub(string.gsub(username, '=', '=3D'), ',' , '=2C')
local nonce = crypt.base64encode(crypt.randomkey())
local first_bare = "n=" .. user .. ",r=" .. nonce
local sasl_start_payload = crypt.base64encode("n,," .. first_bare)
local r
r = self:runCommand("saslStart",1,"autoAuthorize",1,"mechanism","SCRAM-SHA-1","payload",sasl_start_payload)
if r.ok ~= 1 then
return false
end
local conversationId = r['conversationId']
local server_first = r['payload']
local parsed_s = crypt.base64decode(server_first)
local parsed_t = {}
for k, v in string.gmatch(parsed_s, "(%w+)=([^,]*)") do
parsed_t[k] = v
end
local iterations = tonumber(parsed_t['i'])
local salt = parsed_t['s']
local rnonce = parsed_t['r']
if not string.sub(rnonce, 1, 12) == nonce then
skynet.error("Server returned an invalid nonce.")
return false
end
local without_proof = "c=biws,r=" .. rnonce
local pbkdf2_key = md5.sumhexa(string.format("%s:mongo:%s",username,password))
local salted_pass = salt_password(pbkdf2_key, crypt.base64decode(salt), iterations)
local client_key = crypt.hmac_sha1(salted_pass, "Client Key")
local stored_key = crypt.sha1(client_key)
local auth_msg = first_bare .. ',' .. parsed_s .. ',' .. without_proof
local client_sig = crypt.hmac_sha1(stored_key, auth_msg)
local client_key_xor_sig = crypt.xor_str(client_key, client_sig)
local client_proof = "p=" .. crypt.base64encode(client_key_xor_sig)
local client_final = crypt.base64encode(without_proof .. ',' .. client_proof)
local server_key = crypt.hmac_sha1(salted_pass, "Server Key")
local server_sig = crypt.base64encode(crypt.hmac_sha1(server_key, auth_msg))
r = self:runCommand("saslContinue",1,"conversationId",conversationId,"payload",client_final)
if r.ok ~= 1 then
return false
end
parsed_s = crypt.base64decode(r['payload'])
parsed_t = {}
for k, v in string.gmatch(parsed_s, "(%w+)=([^,]*)") do
parsed_t[k] = v
end
if parsed_t['v'] ~= server_sig then
skynet.error("Server returned an invalid signature.")
return false
end
if not r.done then
r = self:runCommand("saslContinue",1,"conversationId",conversationId,"payload","")
if r.ok ~= 1 then
return false
end
if not r.done then
skynet.error("SASL conversation failed to complete.")
return false
end
end
return true
end
function mongo_client:logout()
local result = self:runCommand "logout"
return result.ok == 1
end
function mongo_db:runCommand(cmd,cmd_v,...)
local conn = self.connection
local request_id = conn:genId()
local sock = conn.__sock
local bson_cmd
if not cmd_v then
bson_cmd = bson_encode_order(cmd,1)
else
bson_cmd = bson_encode_order(cmd,cmd_v,...)
end
local pack = driver.query(request_id, 0, self.__cmd, 0, 1, bson_cmd)
-- we must hold req (req.data), because req.document is a lightuserdata, it's a pointer to the string (req.data)
local req = sock:request(pack, request_id)
local doc = req.document
return bson_decode(doc)
end
function mongo_db:getCollection(collection)
local col = {
connection = self.connection,
name = collection,
full_name = self.full_name .. "." .. collection,
database = self.database,
}
self[collection] = setmetatable(col, collection_meta)
return col
end
mongo_collection.getCollection = mongo_db.getCollection
function mongo_collection:insert(doc)
if doc._id == nil then
doc._id = bson.objectid()
end
local sock = self.connection.__sock
local pack = driver.insert(0, self.full_name, bson_encode(doc))
-- flags support 1: ContinueOnError
sock:request(pack)
end
local function werror(r)
local ok = (r.ok == 1 and not r.writeErrors and not r.writeConcernError)
local err
if not ok then
if r.writeErrors then
err = r.writeErrors[1].errmsg
else
err = r.writeConcernError.errmsg
end
end
return ok, err, r
end
function mongo_collection:safe_insert(doc)
local r = self.database:runCommand("insert", self.name, "documents", {bson_encode(doc)})
return werror(r)
end
function mongo_collection:batch_insert(docs)
for i=1,#docs do
if docs[i]._id == nil then
docs[i]._id = bson.objectid()
end
docs[i] = bson_encode(docs[i])
end
local sock = self.connection.__sock
local pack = driver.insert(0, self.full_name, docs)
sock:request(pack)
end
function mongo_collection:update(selector,update,upsert,multi)
local flags = (upsert and 1 or 0) + (multi and 2 or 0)
local sock = self.connection.__sock
local pack = driver.update(self.full_name, flags, bson_encode(selector), bson_encode(update))
sock:request(pack)
end
function mongo_collection:safe_update(selector, update, upsert, multi)
local r = self.database:runCommand("update", self.name, "updates", {bson_encode({
q = selector,
u = update,
upsert = upsert,
multi = multi,
})})
return werror(r)
end
function mongo_collection:delete(selector, single)
local sock = self.connection.__sock
local pack = driver.delete(self.full_name, single, bson_encode(selector))
sock:request(pack)
end
function mongo_collection:safe_delete(selector, single)
local r = self.database:runCommand("delete", self.name, "deletes", {bson_encode({
q = selector,
limit = single and 1 or 0,
})})
return werror(r)
end
function mongo_collection:findOne(query, selector)
local conn = self.connection
local request_id = conn:genId()
local sock = conn.__sock
local pack = driver.query(request_id, 0, self.full_name, 0, 1, query and bson_encode(query) or empty_bson, selector and bson_encode(selector))
-- we must hold req (req.data), because req.document is a lightuserdata, it's a pointer to the string (req.data)
local req = sock:request(pack, request_id)
local doc = req.document
return bson_decode(doc)
end
function mongo_collection:find(query, selector)
return setmetatable( {
__collection = self,
__query = query and bson_encode(query) or empty_bson,
__selector = selector and bson_encode(selector),
__ptr = nil,
__data = nil,
__cursor = nil,
__document = {},
__flags = 0,
__skip = 0,
__sortquery = nil,
__limit = 0,
} , cursor_meta)
end
local function unfold(list, key, ...)
if key == nil then
return list
end
local next_func, t = pairs(key)
local k, v = next_func(t) -- The first key pair
table.insert(list, k)
table.insert(list, v)
return unfold(list, ...)
end
-- cursor:sort { key = 1 } or cursor:sort( {key1 = 1}, {key2 = -1})
function mongo_cursor:sort(key, key_v, ...)
if key_v then
local key_list = unfold({}, key, key_v , ...)
key = bson_encode_order(table.unpack(key_list))
end
self.__sortquery = bson_encode {['$query'] = self.__query, ['$orderby'] = key}
return self
end
function mongo_cursor:skip(amount)
self.__skip = amount
return self
end
function mongo_cursor:limit(amount)
self.__limit = amount
return self
end
function mongo_cursor:count(with_limit_and_skip)
local cmd = {
'count', self.__collection.name,
'query', self.__query,
}
if with_limit_and_skip then
local len = #cmd
cmd[len+1] = 'limit'
cmd[len+2] = self.__limit
cmd[len+3] = 'skip'
cmd[len+4] = self.__skip
end
local ret = self.__collection.database:runCommand(table.unpack(cmd))
assert(ret and ret.ok == 1)
return ret.n
end
-- For compatibility.
-- collection:createIndex({username = 1}, {unique = true})
local function createIndex_onekey(self, key, option)
local doc = {}
for k,v in pairs(option) do
doc[k] = v
end
local k,v = next(key) -- support only one key
assert(next(key,k) == nil, "Use new api for multi-keys")
doc.name = doc.name or (k .. "_" .. v)
doc.key = key
return self.database:runCommand("createIndexes", self.name, "indexes", {doc})
end
local function IndexModel(option)
local doc = {}
for k,v in pairs(option) do
if type(k) == "string" then
doc[k] = v
end
end
local keys = {}
local name
for _, kv in ipairs(option) do
local k,v
if type(kv) == "string" then
k = kv
v = 1
else
k,v = next(kv)
end
table.insert(keys, k)
table.insert(keys, v)
name = (name == nil) and k or (name .. "_" .. k)
name = name .. "_" .. v
end
assert(name, "Need keys")
doc.name = doc.name or name
doc.key = bson_encode_order(table.unpack(keys))
return doc
end
-- collection:createIndex { { key1 = 1}, { key2 = 1 }, unique = true }
-- or collection:createIndex { "key1", "key2", unique = true }
-- or collection:createIndex( { key1 = 1} , { unique = true } ) -- For compatibility
function mongo_collection:createIndex(arg1 , arg2)
if arg2 then
return createIndex_onekey(self, arg1, arg2)
else
return self.database:runCommand("createIndexes", self.name, "indexes", { IndexModel(arg1) })
end
end
function mongo_collection:createIndexes(...)
local idx = { ... }
for k,v in ipairs(idx) do
idx[k] = IndexModel(v)
end
return self.database:runCommand("createIndexes", self.name, "indexes", idx)
end
mongo_collection.ensureIndex = mongo_collection.createIndex
function mongo_collection:drop()
return self.database:runCommand("drop", self.name)
end
-- collection:dropIndex("age_1")
-- collection:dropIndex("*")
function mongo_collection:dropIndex(indexName)
return self.database:runCommand("dropIndexes", self.name, "index", indexName)
end
-- collection:findAndModify({query = {name = "userid"}, update = {["$inc"] = {nextid = 1}}, })
-- keys, value type
-- query, table
-- sort, table
-- remove, bool
-- update, table
-- new, bool
-- fields, bool
-- upsert, boolean
function mongo_collection:findAndModify(doc)
assert(doc.query)
assert(doc.update or doc.remove)
local cmd = {"findAndModify", self.name};
for k, v in pairs(doc) do
table.insert(cmd, k)
table.insert(cmd, v)
end
return self.database:runCommand(table.unpack(cmd))
end
function mongo_cursor:hasNext()
if self.__ptr == nil then
if self.__document == nil then
return false
end
local conn = self.__collection.connection
local request_id = conn:genId()
local sock = conn.__sock
local pack
if self.__data == nil then
local query = self.__sortquery or self.__query
pack = driver.query(request_id, self.__flags, self.__collection.full_name, self.__skip, self.__limit, query, self.__selector)
else
if self.__cursor then
pack = driver.more(request_id, self.__collection.full_name, self.__limit, self.__cursor)
else
-- no more
self.__document = nil
self.__data = nil
return false
end
end
local ok, result = pcall(sock.request,sock,pack, request_id)
local doc = result.document
local cursor = result.cursor_id
if ok then
if doc then
local doc = result.result
self.__document = doc
self.__data = result.data
self.__ptr = 1
self.__cursor = cursor
local limit = self.__limit
if cursor and limit > 0 then
limit = limit - #doc
if limit <= 0 then
-- reach limit
self:close()
end
self.__limit = limit
end
return true
else
self.__document = nil
self.__data = nil
self.__cursor = nil
return false
end
else
self.__document = nil
self.__data = nil
self.__cursor = nil
if doc then
local err = bson_decode(doc)
error(err["$err"])
else
error("Reply from mongod error")
end
end
end
return true
end
function mongo_cursor:next()
if self.__ptr == nil then
error "Call hasNext first"
end
local r = bson_decode(self.__document[self.__ptr])
self.__ptr = self.__ptr + 1
if self.__ptr > #self.__document then
self.__ptr = nil
end
return r
end
function mongo_cursor:close()
if self.__cursor then
local sock = self.__collection.connection.__sock
local pack = driver.kill(self.__cursor)
sock:request(pack)
self.__cursor = nil
end
end
return mongo
|
require 'xml'
-- load XML
xml = xml.load("test.xml")
-- print
printr(xml)
|
--technologies
if settings.startup["moreshinybobs-tech-alien-and-research"] and settings.startup["moreshinybobs-tech-alien-and-research"].value == true then
--alien-and-research
require("tech-alien-and-research")
end
if settings.startup["moreshinybobs-tech-ammo"] and settings.startup["moreshinybobs-tech-ammo"].value == true then
--ammo
require("tech-ammo")
end
if settings.startup["moreshinybobs-tech-chemical-processing"] and settings.startup["moreshinybobs-tech-chemical-processing"].value == true then
--tech-chemical-processing
require("tech-chemical-processing")
end
if settings.startup["moreshinybobs-tech-electronics"] and settings.startup["moreshinybobs-tech-electronics"].value == true then
--electronics
require("tech-electronics")
end
if settings.startup["moreshinybobs-tech-equipment"] and settings.startup["moreshinybobs-tech-equipment"].value == true then
--equipment
require("tech-equipment")
end
if settings.startup["moreshinybobs-tech-logistics"] and settings.startup["moreshinybobs-tech-logistics"].value == true then
--tech-logistics
require("tech-logistics")
end
if settings.startup["moreshinybobs-tech-material-processing"] and settings.startup["moreshinybobs-tech-material-processing"].value == true then
--tech-material-processing
require("tech-material-processing")
end
if settings.startup["moreshinybobs-tech-mining"] and settings.startup["moreshinybobs-tech-mining"].value == true then
--mining
require("tech-mining")
end
if settings.startup["moreshinybobs-tech-modules"] and settings.startup["moreshinybobs-tech-modules"].value == true then
--modules
require("tech-modules")
end
if settings.startup["moreshinybobs-tech-power"] and settings.startup["moreshinybobs-tech-power"].value == true then
--power
require("tech-power")
end
if settings.startup["moreshinybobs-tech-robotics"] and settings.startup["moreshinybobs-tech-robotics"].value == true then
--robotics
require("tech-robotics")
end
if settings.startup["moreshinybobs-tech-warfare"] and settings.startup["moreshinybobs-tech-warfare"].value == true then
--warfare
require("tech-warfare")
end |
local Broadcast = require("core.Broadcast")
local Logger = require("core.Logger")
local tablex = require("pl.tablex")
local sfmt = string.format
---
---An example behavior that causes an NPC to wander around an area when not in combat
---Options:
--- areaRestricted: boolean, true to restrict the NPC's wandering to his home area. Default: false
--- restrictTo: Array<EntityReference>, list of room entity references to restrict the NPC to. For
--- example if you want them to wander along a set path
--- interval: number, delay in seconds between room movements. Default: 20
---
return {
listeners = {
updateTick = function(state)
return function(self, config)
if self:isInCombat() or not self.room then return end
config = config or {}
config = tablex.update({
areaRestricted = false,
restrictTo = nil,
interval = 20,
}, config);
if not self._lastWanderTime then self._lastWanderTime = os.time() end
if os.time() - self._lastWanderTime < config.interval * 1000 then
return
end
self._lastWanderTime = os.time()
local exits = self.room:getExits()
if #exits < 1 then return end
local roomExit = exits[math.random(#exits)]
local randomRoom = state.RoomManager:getRoom(roomExit.roomId)
local door = self.room:getDoor(randomRoom) or
(randomRoom and randomRoom:getDoor(self.room))
if randomRoom and door and (door.locked or door.closed) then
Logger.verbose("NPC [%q] wander blocked by door", self.uuid)
end
if not randomRoom or (config.restrictTo and
not tablex.find(config.restrictTo, randomRoom.entityReference)) or
(config.areaRestricted and randomRoom.area ~= self.area) then
return
end
Logger.verbose("NPC [%q] wandering from %q to %q.", self.uuid,
self.room.entityReference, randomRoom.entityReference);
Broadcast.sayAt(self.room,
sfmt("%q wanders %q}.", self.name, roomExit.direction));
self:moveTo(randomRoom);
end
end,
},
};
|
-- Not strictly necessary, kept here to help document and avoid forgotten flags
return {
["escaped=prison"] = false, -- Escaped the first prison
["killed-minion1"] = false,
["killed-minion2"] = false,
["killed-minion3"] = false,
["killed-minion4"] = false,
["killed-bigboss"] = false,
["win"] = false, -- won the game
}
|
local vimscript = vim.cmd
function PackInit()
vim.cmd('packadd minpac')
vim.call('minpac#init')
local add = vim.fn['minpac#add']
add('k-takata/minpac', { type = 'opt' })
add('kyazdani42/nvim-web-devicons')
add('kyazdani42/nvim-tree.lua')
add('NLKNguyen/papercolor-theme')
add('Raimondi/delimitMate')
-- JS/TS/React development
add('neoclide/coc.nvim', { branch = 'release' })
add('pangloss/vim-javascript')
add('maxmellon/vim-jsx-pretty')
add('elzr/vim-json')
add('eslint/eslint')
add('leafgarland/typescript-vim')
add('preservim/vim-markdown')
add('vim-python/python-syntax')
end
-- Plugin settings here.
-- Define user commands for updating/cleaning the plugins.
-- Each of them calls PackInit() to load minpac and register
-- the information of plugins, then performs the task.
vimscript[[
command! PackUpdate lua PackInit(); vim.call('minpac#update')
command! PackClean lua PackInit(); vim.call('minpac#clean')
command! PackStatus lua PackInit(); vim.call('minpac#status')
]]
|
local calc_util = require("scripts.calc.util")
--- @param entity LuaEntity
return function(rates, entity, emissions_per_second)
local entity_prototype = entity.prototype
local added_emissions = 0
-- Electric energy interfaces can have their settings adjusted at runtime, so checking the energy source is pointless
-- They also don't produce pollution whatsoever, despite their energy source emissions setting
if entity.type == "electric-energy-interface" then
local production = entity.power_production
local usage = entity.power_usage
local entity_name = entity.name
if production > 0 then
calc_util.add_rate(rates, "output", "entity", entity_name, entity.prototype.localised_name, production)
end
if usage > 0 then
calc_util.add_rate(rates, "input", "entity", entity_name, entity.prototype.localised_name, usage)
end
else
local electric_energy_source_prototype = entity_prototype.electric_energy_source_prototype
local max_energy_usage = entity_prototype.max_energy_usage or 0
if electric_energy_source_prototype and max_energy_usage > 0 then
local consumption_bonus = (entity.consumption_bonus + 1)
local drain = electric_energy_source_prototype.drain
local amount = max_energy_usage * consumption_bonus
if max_energy_usage ~= drain then
amount = amount + drain
end
calc_util.add_rate(rates, "input", "entity", entity.name, entity_prototype.localised_name, amount)
added_emissions = electric_energy_source_prototype.emissions * (max_energy_usage * consumption_bonus) * 60
end
local max_energy_production = entity_prototype.max_energy_production
if max_energy_production > 0 then
if entity.type == "solar-panel" then
max_energy_production = max_energy_production * entity.surface.solar_power_multiplier
end
calc_util.add_rate(rates, "output", "entity", entity.name, entity_prototype.localised_name, max_energy_production)
-- Pollution is not calculated here because the rate depends on entity-specific variables
end
end
return emissions_per_second + added_emissions
end
|
--- Parse the ldoc dump file ($1 script argument)
--- and generate the emmylua annotations output to stout
---
--- author: Maxim Tuprikov, Insality <insality@gmail.com
--- license: MIT
--- date: 10.2020
local parser = require("./src/parser")
local prepare = require("./src/prepare")
local annotations = require("./src/annotations")
local function main()
local filedata = assert(loadfile(arg[1]))()
local parsed_data = parser.parse_file(filedata)
local prepared_data = prepare.prepare(parsed_data) -- Transform ldoc parsed data to our structure
local annotations_string = annotations.generate(prepared_data) -- Output our structure to string
print(annotations_string)
end
main()
|
-- Created By, Hiram Abiff v2.1
--[[
This script was only possible due to the continued help from the really
cool guys on the Berserk Forums. There may be some pieces of code that don't
belong, but I will be sure to clean it up over time.
A lot of snippets you may find here, are directly from MrStumps lua tutorials;
I gratly thank him for his help and patience with providing others the
knowledge to create their own scripts.
If you have any suggestions on further changes or if you find any bugs, please
make a post in the comments or "Bugs" discussions thread for this mod. Thank you.
For a complete list of changes for v2.1, you can read the changelog located on the
workshop page for this mod.
]]
--------------------------------------------------------
local debug = false
function onLoad()
local backgColor = {0,0,0}--{0.3,0.2,0}
local fontColor = {1,1,1}
self.createButton({ -- index 0, Previous Layout
label="<--", click_function="prevLayout",
function_owner=self, position={-1,0.075,-0.6},
height=250, width=250, font_size=100,
font_color=fontColor, color=backgColor
})
self.createButton({ -- index 1, Selection Button
label="Selection Button", click_function="selectLayout",
function_owner=self, position={-0,0.075,-0.6},
height=250, width=720, font_size=100,
font_color=fontColor, color=backgColor
})
self.createButton({ -- index 2, Next Layout
label="-->", click_function="nextLayout",
function_owner=self, position={1,0.075,-0.6},
height=250, width=250, font_size=100,
font_color=fontColor, color=backgColor
})
self.createButton({ -- index 3, Number Display
label="0", click_function="none",
function_owner=self, position={-1.155,0.075,-1.108},
height=0, width=0, font_size=100,
font_color={1,1,1}, color={0,0,0}
})
self.createButton({ -- index 4, Instruction Display
label="Place a deck beside\n the tool and press the\n Find Deck button.", click_function="none",
function_owner=self, position={-0,0.075,0.8},
height=0, width=0, font_size=110,
font_color=fontColor, color={0,0,0}
})
self.createButton({ -- index 5, Find Deck
label="Find\nDeck", click_function="findDeck",
function_owner=self, position={1.06,0.075,-1.1},
height=250, width=320, font_size=80,
font_color={0.7,0.2,0.2}, color=backgColor
})
self.createButton({ -- index 6, Rotation On/Off
label="Rotation\nOn", click_function="rotationOnOff",
function_owner=self, position={-0.37,0.075,0},
height=250, width=445, font_size=100,
font_color=fontColor, color=backgColor
})
self.createButton({ -- index 7, Shuffle
label="Shuffle", click_function="shuffle",
function_owner=self, position={0.4,0.075,0},
height=250, width=330, font_size=100,
font_color=fontColor, color=backgColor
})
self.createButton({ -- index 8, Spawns and controls the Help Tablet
label="Help\nTablet", click_function="helpTablet",
function_owner=self, position={1.05,0.075,0},
height=250, width=320, font_size=100,
font_color=fontColor, color=backgColor
})
self.createButton({ -- index 9, Display used to
label="------------->", click_function="None",
function_owner=self, position={-0,0.075,-1.1},
height=0, width=0, font_size=130,
font_color={1,1,1}, color={0,0,0}
})
self.createButton({ -- index 10, Automatically select cards enable/disable
label="Manual\nDraw", click_function="autoSelectCards",
function_owner=self, position={-1.1,0.075,0},
height=250, width=300, font_size=80,
font_color={1,1,1}, color={0,0,0}
})
rotation = true
layout = nil
layoutNum = 0
cardPosX = nil
cardPosZ = nil
neededCards = nil
autoCards = false
activeButtonColor = {0.9,0.9,0.3}
selectNewCards = false
nextLayout()
end
selectedCards = {}
layoutFunctions = {
"none", --oneCardDraw
"none", --threeCardDraw
"none", --fiveCardDraw
"none", --celticCrossDraw
"none", --tetraktysDraw
"none", --crossAndTriangleDraw
"none", --astroDraw
"none", --planetaryDraw
"none", --treeOfLifeDraw
"none", --starGuideDraw
"none", --spiritualGuidanceDraw
"none", --doOrDontDraw
"none", --highPriestessDraw
"none", --careerPathDraw
"none", --pastLifeDraw
"none", --relationshipProblemsDraw
"none", --birthdayDraw
"none", --mandalaDraw
"none", --horseshoeDraw
"none", --opportunitiesAndObstaclesDraw
"none", --moneyProblemsDraw
"customCardsDraw",
}
layoutNames = {
"Single Card",
"Three Card",
"Five Card",
"Celtic Cross",
"Tetraktys",
"Cross & Triangle",
"Astrological",
"Planetary",
"Tree of Life",
"Star Guide",
"Spiritual\nGuidance",
"Should you? or\nShouldn't You?",
"Secret of the\nHigh Priestess",
"Career Path",
"Past Life",
"Relationship\nProblems",
"Birthday",
"Mandala",
"Horseshoe",
"Opportunities &\nObstacles",
"Money Problems",
"Custom Cards",
}
helpTabUrls = {
"https://dl.dropboxusercontent.com/s/ubokfwb2w0u6dnx/HomePage.png", -- Help Home Page
"https://dl.dropbox.com/s/ocqmv6jah0388pp/Single%20Card.png?dl=0", -- Single Card
"https://dl.dropbox.com/s/pd10yopytjp0oj8/Three%20Card.png?dl=0", -- Three Card
"https://dl.dropbox.com/s/6iva4pye4s8i92g/Five%20card.png?dl=0", -- Five Card
"https://dl.dropbox.com/s/mx8rjp9ybuy8jqu/celticCross.png?dl=0", -- Celtic Cross
"https://dl.dropbox.com/s/j4tdmbzojnfqb9d/Tetraktys.png?dl=0", -- Tetraktys
"https://dl.dropbox.com/s/ojjkkwobokwbguz/Cross%20and%20Triangle.png?dl=0", -- Cross & Triangle
"https://dl.dropbox.com/s/ppwqizeqjj5ohub/Astro%20Zodiac.png?dl=0", -- Astrological
"https://dl.dropbox.com/s/600ny3vhc2lvzrf/Planetary.png?dl=0", -- Planetary
"https://dl.dropbox.com/s/ynhwcc668lxoil3/Tree%20of%20Life.png?dl=0", -- Tree of Life
"https://dl.dropbox.com/s/r0b249ndjviac0v/Star%20Guide.png?dl=0", -- Star Guide
"https://dl.dropbox.com/s/a7n62u801aoqer6/Spiritual%20Guidance.png?dl=0", -- Spiritual Guidance
"https://dl.dropbox.com/s/w9kwlhlwu0tju74/Should%20you%2C%20shouldnt%20you.png?dl=0", -- Should you? or Shouldn't you?
"https://dl.dropbox.com/s/vhtnrze7tep0fl8/Secret%20of%20the%20High%20Priestess.png?dl=0", -- Secret of the High Priestess
"https://dl.dropbox.com/s/7i7p9emxyrev2mx/Career%20Path.png?dl=0", -- Career Path
"https://dl.dropbox.com/s/voxepwd9cjergdg/Past%20Life.png?dl=0", -- Past Life
"https://dl.dropbox.com/s/ravkl7f7cxl2dcm/Relationship%20Problems.png?dl=0", -- Relationship Problems
"https://dl.dropbox.com/s/zxuiufqnxfdkp8c/Birthday%20spread.png?dl=0", -- Birthday
"https://dl.dropbox.com/s/4rfsdxoymv76qdy/Mandala.png?dl=0", -- Mandala
"https://dl.dropbox.com/s/ersbnozvuxs5uds/Horseshoe.png?dl=0", -- Horseshoe
"https://dl.dropbox.com/s/ju4rylxx272l3zg/Opportunities%20and%20Obstacles.png?dl=0", -- Opportunities & Obstacles
"https://dl.dropbox.com/s/twfgho07d2od1sb/Money%20Problems.png?dl=0", -- Money Problems
"https://i.imgur.com/bVZuYKA.jpg", -- Custom Catds
}
function nextLayout()
if layout == nil then
if layoutNum <= 21 then
layoutNum = layoutNum + 1
self.editButton({index=3, label=layoutNum})
self.editButton({index=1, label=layoutNames[layoutNum], click_function=layoutFunctions[layoutNum]})
else
layoutNum = 1
self.editButton({index=3, label=layoutNum})
self.editButton({index=1, label=layoutNames[layoutNum], click_function=layoutFunctions[layoutNum]})
end
end
end
function prevLayout()
if layout == nil then
if layoutNum >= 2 then
layoutNum = layoutNum - 1
self.editButton({index=3, label=layoutNum})
self.editButton({index=1, label=layoutNames[layoutNum], click_function=layoutFunctions[layoutNum]})
else
layoutNum = 21
self.editButton({index=3, label=layoutNum})
self.editButton({index=1, label=layoutNames[layoutNum], click_function=layoutFunctions[layoutNum]})
end
end
end
function rotationOnOff() -- Enables or disables rotation; Rotation On/Off button.
if rotation == true then
rotation = false
local button_parameters = {}
self.editButton({index=6, label="Rotation\nOff"})
elseif rotation == false then
rotation = true
self.editButton({index=6, label="Rotation\nON"})
end
end
function autoSelectCards() -- designed to enable to disable user selecting cards.
if autoCards == false then
autoCards = true
self.editButton({index=10, label="Auto\nDraw"})
elseif autoCards == true then
autoCards = false
self.editButton({index=10, label="Manual\nDraw"})
end
end
function shuffle()
local cardsOnTable = getAllObjects()
for i,v in ipairs(cardsOnTable) do
if v.tag == "Card" then
cardsOnTable = true
end
end
if cardsOnTable == true then
startLuaCoroutine(self, "shuffleCoroutine")
elseif deckRef == nil then
print("To Shuffle, you must first find a deck with the Find Deck button.")
elseif deckRef ~= nil then
deckRef.shuffle()
end
end
function shuffleCoroutine() -- Resets all all cards back to the deck, and resets layout buttons.
self.editButton({index=4, font_size=110, label='Using the arrows, choose\na layout, and select it with\nthe center button labeled\n with the layout name.'})
setNotes("")
layout = nil
selectNewCards = false
local handCards = Player.Black.getHandObjects()
local deckPos = self.positionToWorld({3,0,0})
if #handCards > 0 then -- Resets cards from the hand back to the deck. This is used when the player wants to reset the deck mid draw.
for i,v in ipairs(handCards) do
deckPos.y = deckPos.y + 0.01
v.setPosition(deckPos)
for i=1,1,1 do coroutine.yield(0) end
end
end
findDeck()
if #selectedCards > 0 and deckRef ~= nil then
for _, object in ipairs(selectedCards) do -- uses the table and puts all selected cards back into the deck.
deckRef.putObject(object)
end
for i=1, 25,1 do coroutine.yield(0) end -- coroutine used to wait for cards to return before the table is wiped.
for k in pairs(selectedCards) do
selectedCards[k] = nil
end
end
local cardsOnTable = getAllObjects()
for _, objects in ipairs(cardsOnTable) do -- Moves any left over cards on the table to the deck.
if objects.tag == "Card" then
deckRef.putObject(objects)
end
end
self.editButton({index=1, font_color={1,1,1}})
for i=1,25,1 do coroutine.yield(0) end
deckRef.Shuffle()
return 1
end
function findDeck() -- "Find Deck" Button; finds deck within 5 units of tool.
local allObjects = getAllObjects()
foundDeck = false
for _, deckObjects in ipairs(allObjects) do
if deckObjects.tag == "Deck" then
local distance = findProximity(self.getPosition(), deckObjects)
if distance <= 5 then
deckGuid = deckObjects.getGUID()
deckRef = getObjectFromGUID(deckGuid)
--deckRef.setScale({0.89, 1.00, 0.89})
deckRef.setDescription(deckGuid)
self.editButton({index=9, font_size=100, position={-0,0.075,-1.1}, font_color={0,0.7,0.2}, label="GUID: "..deckGuid})
self.editButton({index=5, font_size=60, font_color={0,0.7,0.2}, label='Deck\nFound'})
foundDeck= true
end
end
end
if foundDeck == false and deckRef ~= nil then
self.editButton({index=9, font_size=55, font_color={0,0.7,0.2}, label='No Deck Found within 5 Units\nUsing last known deck\nGUID: '..deckGuid})
elseif deckRef == nil then
self.editButton({index=4, font_size=110, label='No deck found; place deck\n beside the tool and press\n the Find Deck Button.'})
elseif layout == nil then
self.editButton({index=4, font_size=110, label='Using the arrows, choose\na layout, and select it with\nthe center button labeled\n with the layout name.'})
end
end
function findProximity(targetPos, object) -- Used by "findDeck" to determine distance between tool and deck.
local objectPos = object.getPosition()
local xDistance = math.abs(targetPos.x - objectPos.x)
local zDistance = math.abs(targetPos.z - objectPos.z)
local distance = xDistance^2 + zDistance^2
return math.sqrt(distance)
end
function update() -- This update function watches for GUIDs that are input to the tools description box.
if self.getDescription() ~= nil then
local deckObj = getObjectFromGUID(self.getDescription())
if deckObj then
deckRef = deckObj
self.editButton({index=2, font_color={0,0.7,0.2}, label='Deck:\n'..deckObj.getGUID()})
--deckObj.setScale({0.89, 1.00, 0.89})
deckObj.setDescription(deckObj.getGUID())
foundDeck = true
end
self.setDescription("")
end
end
function drawCards()
startLuaCoroutine(self, "drawCardsCoroutine")
end
function drawCardsCoroutine()
local fontSize = 130
for i=1, 10,1 do coroutine.yield(0) end
Player.Black.setHandTransform({
position = {-0.39, 4.61, -8.14},
rotation = {0.00, 0.00, 0.00},
scale = {23.78, 1.65, 1.73},
})
local deckSize = deckRef.getObjects()
for i=1, #deckSize do
deckRef.dealToColorWithOffset({-14.5, 2, 0.19}, false, "Black")
selectNewCards = true
end
setNotes(layout..' - Choose '..neededCards..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..neededCards..' cards to\n continue.'})
broadcastToColor(layout..' layout selected', 'White')--, {0,1,0})
return 1
end
movingCards = false
function onObjectPickedUp(White, obj)
if obj.tag == "Card" and selectNewCards == true and movingCards == false then
cardRef = obj
startLuaCoroutine(self, "moveCard")
end
end
neededCards = nil
cardPosX = nil
cardPosZ = nil
function moveCard()
handCards = Player.Black.getHandObjects()
for i=1, 10 do
coroutine.yield(0)
end
local fontSize = 130
if #selectedCards <= neededCards and selectNewCards == true then
if #selectedCards == 0 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX, 1.6, cardPosZ})
table.insert( selectedCards, 1, cardRef)
card2 = neededCards - 1
setNotes(layout..' - Choose '..card2..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card2..' cards to\n continue.'})
elseif #selectedCards == 1 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+2.3, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card3 = neededCards - 2
setNotes(layout..' - Choose '..card3..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card3..' cards to\n continue.'})--this
elseif #selectedCards == 2 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+4.6, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card4 = neededCards - 3
setNotes(layout..' - Choose '..card4..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card4..' cards to\n continue.'})
elseif #selectedCards == 3 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+6.9, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card5 = neededCards - 4
setNotes(layout..' - Choose '..card5..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card5..' cards to\n continue.'})
elseif #selectedCards == 4 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+9.2, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card6 = neededCards - 5
setNotes(layout..' - Choose '..card6..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card6..' cards to\n continue.'})
elseif #selectedCards == 5 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+11.5, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card7 = neededCards - 6
setNotes(layout..' - Choose '..card7..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card7..' cards to\n continue.'})
elseif #selectedCards == 6 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+13.8, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card8 = neededCards - 7
setNotes(layout..' - Choose '..card8..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card8..' cards to\n continue.'})
elseif #selectedCards == 7 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+16.1, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card9 = neededCards - 8
setNotes(layout..' - Choose '..card9..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card9..' cards to\n continue.'})
elseif #selectedCards == 8 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+18.4, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card10 = neededCards - 9
setNotes(layout..' - Choose '..card10..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card10..' cards to\n continue.'})
elseif #selectedCards == 9 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+20.7, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card11 = neededCards - 10
setNotes(layout..' - Choose '..card11..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card11..' cards to\n continue.'})
elseif #selectedCards == 10 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+23, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card12 = neededCards - 11
setNotes(layout..' - Choose '..card12..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card12..' cards to\n continue.'})
elseif #selectedCards == 11 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+25.3, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card13 = neededCards - 12
setNotes(layout..' - Choose '..card13..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card13..' cards to\n continue.'})
elseif #selectedCards == 12 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+27.6, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card14 = neededCards - 13
setNotes(layout..' - Choose '..card14..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card14..' cards to\n continue.'})
elseif #selectedCards == 13 then
if rotation == true and math.random (2) == 1 then
cardRef.setRotation({0,0,180})
else
cardRef.setRotation({0,180,180})
end
cardRef.setPosition({cardPosX+29.9, 1.6, cardPosZ})
table.insert( selectedCards, cardRef)
card15 = neededCards - 14
setNotes(layout..' - Choose '..card15..' cards to continue.')
self.editButton({index=4, font_size=fontSize, font_color=fontColor, label='\nChoose '..card15..' cards\n to continue.'})
end
end
for i=1,15,1 do coroutine.yield(0) end
if #selectedCards == neededCards then
selectNewCards = false
if selectNewCards == false then
setNotes('')
broadcastToColor("Done!", 'White')--, {0,2,0})
local unusedCards = Player.Black.getHandObjects()
local selfPos = self.positionToWorld({2.9,1,0})
for i,v in ipairs(unusedCards) do
v.setPosition(selfPos)
for i=1,1,1 do coroutine.yield(0) end
end
for i=1, 30,1 do coroutine.yield(0) end
pickedCardsFinished()
Player.Black.setHandTransform({
position = {-0.39, 160, -8.14},
rotation = {0.00, 0.00, 0.00},
scale = {23.78, 1.65, 1.73},
})
end
for i=1,30,1 do coroutine.yield(0) end
findDeck()
end
return 1
end
function altDraw()
startLuaCoroutine(self, "altDrawCoroutine")
end
function altDrawCoroutine()
if autoCards == true then
for i=1, neededCards do
if layout ~= nil then
local params = {}
params.callback = "autoDrawCallback"
params.callback_owner = self
params.position = {cardPosX, 2, cardPosZ}
deckRef.takeObject(params)
cardPosX = cardPosX + 2.3
for i=1,15,1 do coroutine.yield(0) end
end
end
end
return 1
end
function autoDrawCallback(card)
local cardLoc = card.getPosition()
if rotation == true and math.random(2) == 1 then -- rotation was used here instead of within takeObject so the movement would not be seen.
card.setRotation({cardLoc.x, cardLoc.y, 180})
else
cardLoc.y = cardLoc.y + 180
card.setRotation({cardLoc.x, cardLoc.y, 180})
end
table.insert( selectedCards, card)
if #selectedCards == neededCards then
pickedCardsFinished()
end
end
function helpTablet()
local targetPos = self.positionToWorld({0,1,-3.6})
if tabletRef == nil then
spawnObject({
type = "Tablet",
rotation = {0.00, 179.99, 0.00},
position = targetPos,
scale = {0.40, 0.40, 0.40},
callback_owner = self,
callback = "helpTabletCallback",
params = {"tab"}
})
else
if tabletRef ~= nil then
local currentUrl = tabletRef.getValue()
if currentUrl == helpTabUrls[1] then
tabletRef.setValue("http://psychiclibrary.com/beyondBooks/tarot-deck/")
elseif currentUrl == "http://psychiclibrary.com/beyondBooks/tarot-deck/" then
tabletRef.setValue(helpTabUrls[1])
elseif currentUrl ~= helpTabUrls[1] or currentUrl ~= "http://psychiclibrary.com/beyondBooks/tarot-deck/" then
tabletRef.setValue(helpTabUrls[1])
end
end
end
end
function helpTabletCallback(tab)
local tabletGuid = tab.getGUID()
tabletRef = getObjectFromGUID(tabletGuid)
tab.setName("Tarot Help Tablet")
tab.setValue(helpTabUrls[1])
end
function selectLayout()
return 1
end
function customCardsDraw()
neededCards = 5
cardPosX = 0.00
cardPosZ = -13.78
layout = "Custom Cards"
autoCards = true
customDraw()
end
function customDraw()
startLuaCoroutine(self, "customDrawCoroutine")
end
function customDrawCoroutine()
if autoCards == true then
local cardPositions = {
{68.00, 5.00, -13.60}, -- Sai
{68.00, 5.00, 13.60}, --Zerrik
{68.00, 5.00, -6.80}, --Varan
{68.00, 5.00, 6.80}, --Bobby
{68.00, 5.00, 0.00}, --Erik
}
if debug then
cardPositions = {
{0, 2.00, -8}, -- Sai
{0, 2.00, -4}, --Zerrik
{0, 2.00, 4}, --Varan
{0, 2.00, 8}, --Bobby
{0, 2.00, 0}, --Erik
}
end
for i=1, neededCards do -- drawing cards and initial position
if layout ~= nil then
local params = {}
params.callback = "customDrawCallback"
params.callback_owner = self
params.position = cardPositions[i]
params.rotation = {0.00, 90.00, 180.00}
deckRef.takeObject(params)
for i=1,45,1 do coroutine.yield(0) end
end
end
end
return 1
end
function customDrawCallback(card)
card.setLock(true)
--card.setScale({1.83, 1, 1.83})
table.insert( selectedCards, card)
if #selectedCards == neededCards then
customFinished()
end
end
function customFinished()
startLuaCoroutine(self, "customFinishedCoroutine")
end
function customFinishedCoroutine()
local cardFinalPos = { -- cards in "hand"
{-74.82, 2.00, -49.30}, --Sai
{40.80, 2.00, 49.30}, --Zerrik
{-37.40, 2.00, 49.30}, --Varan
{-17.00, 2.00, 49.30}, --Bobby
{-16.15, 2.00, -48.45}, --Erik
}
local cardMidPos = { -- cards in formation
{-5.10, 4.45, -5.10}, --Sai
{5.10, 4.45, -5.10}, --Zerrik
{-5.10, 4.45, 5.10}, --Varan
{5.10, 4.45, 5.10}, --Bobby
{0.00, 4.45, 0.00}, --Erik
}
local cardRot = {
{0.00, 180.00, 0.00}, --Sai
{0.00, 0.00, 0.00}, --Zerrik
{0.00, 0.00, 0.00}, --Varan
{0.00, 0.00, 0.00}, --Bobby
{0.00, 180.00, 0.00}, --Erik
}
for i,v in ipairs(selectedCards) do -- setting to 0
local targetPos = v.positionToWorld({0,0,0})
v.setPositionSmooth(targetPos)
end
-- "shuffling"
local locZ = selectedCards[#selectedCards].getPosition()
for i,v in ipairs(selectedCards) do
local targetPos = v.getPosition()
targetPos.y = targetPos.y+i*0.05
targetPos.z = locZ.z
targetPos.x = locZ.z
v.setPositionSmooth(targetPos,false,false)
end
for i=1,60,1 do coroutine.yield(0) end
deckRef.shuffle()
local curRot = selectedCards[1].getRotation()
local steps = 20
for i=1,steps do
local rot = (curRot.y*i)/steps
selectedCards[1].setRotation({curRot.x,rot,curRot.z})
coroutine.yield(0)
end
deckRef.shuffle()
local curRot = selectedCards[3].getRotation()
local steps = 20
for i=1,steps do
local rot = (curRot.y*i)/steps
selectedCards[1].setRotation({curRot.x,rot,curRot.z})
coroutine.yield(0)
end
for i=1,45,1 do coroutine.yield(0) end -- setting to formation
for i,v in ipairs(selectedCards) do
local targetPos = cardMidPos[i]
v.setPositionSmooth(targetPos)
end
for i=1,60,1 do coroutine.yield(0) end -- going to hand
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardFinalPos[i])
v.setRotationSmooth(cardRot[i])
v.setLock(false)
--v.flip()
for i=1, 15,1 do coroutine.yield(0) end
end
selectedCards = {}
return 1
end
function allResting(arr)
for i=1, #arr do
if not arr[i].resting then
return false
end
end
return true
end
function oneCardDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 1
cardPosX = 0.00
cardPosZ = -13.78
layout = "Single Card"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[2])
end
end
function threeCardDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 3
cardPosX = -2.30
cardPosZ = -13.78
layout = "Three Card"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[3])
end
end
function fiveCardDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 5
cardPosX = -4.60
cardPosZ = -13.78
layout = "Five Card"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[4])
end
end
function celticCrossDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 10
cardPosX = -10.37
cardPosZ = -13.78
layout = "Celtic Cross"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[5])
end
end
function tetraktysDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 10
cardPosX = -10.37
cardPosZ = -13.78
layout = "Tetraktys"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[6])
end
end
function astroDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 13
cardPosX = -13.87
cardPosZ = -13.78
layout = "Astrological"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[8])
end
end
function planetaryDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 8
cardPosX = -8.13
cardPosZ = -13.78
layout = "Planetary"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[9])
end
end
function treeOfLifeDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 10
cardPosX = -10.37
cardPosZ = -13.78
layout = "Tree Of Life"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[10])
end
end
function crossAndTriangleDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 9
cardPosX = -9.23
cardPosZ = -13.78
layout = "Cross & Triangle"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[7])
end
end
function relationshipProblemsDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 9
cardPosX = -9.23
cardPosZ = -13.78
layout = "Relationship Problems"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[17])
end
end
function moneyProblemsDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 5
cardPosX = -4.60
cardPosZ = -13.78
layout = "Money Problems"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[22])
end
end
function pastLifeDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 14
cardPosX = -14.93
cardPosZ = -13.78
layout = "Past Life"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[16])
end
end
function careerPathDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 7
cardPosX = -6.97
cardPosZ = -13.78
layout = "Career Path"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[15])
end
end
function highPriestessDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 9
cardPosX = -9.23
cardPosZ = -13.78
layout = "High Priestess"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[14])
end
end
function doOrDontDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 9
cardPosX = -9.23
cardPosZ = -13.78
layout = "Should you Shouldn't you"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[13])
end
end
function starGuideDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 6
cardPosX = -5.73
cardPosZ = -13.78
layout = "Star Guide"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[11])
end
end
function spiritualGuidanceDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 8
cardPosX = -8.13
cardPosZ = -13.78
layout = "Spiritual Guidance"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[12])
end
end
function birthdayDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 9
cardPosX = -9.23
cardPosZ = -13.78
layout = "Birthday"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[18])
end
end
function mandalaDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 9
cardPosX = -9.23
cardPosZ = -13.78
layout = "Mandala"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[19])
end
end
function horseshoeDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 7
cardPosX = -6.97
cardPosZ = -13.78
layout = "Horseshoe"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[20])
end
end
function opportunitiesAndObstaclesDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 7
cardPosX = -6.97
cardPosZ = -13.78
layout = "Opportunities &\nObstacles"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[21])
end
end
function moneyProblemsDraw()
local handCards = Player.Black.getHandObjects()
if layout == nil and deckRef ~= nil then
self.editButton({index=1, font_color=activeButtonColor})
neededCards = 6
cardPosX = -5.73
cardPosZ = -13.78
layout = "Money Problems"
if autoCards == false then
selectNewCards = true
drawCards()
else
altDraw()
end
end
if tabletRef ~= nil then
tabletRef.setValue(helpTabUrls[22])
end
end
function pickedCardsFinished()
startLuaCoroutine(self, "pickedCardsCoroutine")
end
function pickedCardsCoroutine()
if #selectedCards == neededCards then
self.editButton({index=4, font_size=110, label='Finished reading your\n layout? Press the "Shuffle"\n button to reset the deck.'})
for i,v in ipairs(selectedCards) do
v.flip()
for i=1, 10,1 do coroutine.yield(0) end
end
for i=1, 60,1 do coroutine.yield(0) end
if layout == "Single Card" then
return 1
elseif layout == "Three Card" then
return 1
elseif layout == "Five Card" then
local cardPos = {
{0.00, 1.41, -14.67},
{-2.27, 1.41, -14.67},
{2.28, 1.41, -14.67},
{0.00, 1.41, -17.98},
{0.00, 1.41, -11.41},
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardPos[i])
for i=1, 15,1 do coroutine.yield(0) end
end
elseif layout == "Celtic Cross" then
local cardPos = {
{-1.64, 1.45, -14.32},
{-1.63, 1.60, -14.24},
{-1.64, 1.50, -17.45},
{-3.95, 1.50, -14.32},
{-1.64, 1.50, -11.12},
{0.66, 1.50, -14.32},
{3.36, 1.50, -19.18},
{3.36, 1.50, -15.97},
{3.36, 1.50, -12.77},
{3.36, 1.50, -9.61}
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardPos[i])
selectedCards[2].setRotation({0,90,0})
for i=1, 20,1 do coroutine.yield(0) end
end
elseif layout == "Tetraktys" then
local cardPos = {
{3.45, 1.51, -20.17},
{1.15, 1.51, -20.16},
{-1.19, 1.51, -20.16},
{-3.56, 1.51, -20.16},
{2.34, 1.51, -17.21},
{0.00, 1.51, -17.21},
{-2.38, 1.51, -17.21},
{1.15, 1.51, -14.26},
{-1.17, 1.51, -14.26},
{0.00, 1.51, -11.22}
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardPos[i])
for i=1, 15,1 do coroutine.yield(0) end
end
elseif layout == "Astrological" then
local cardPos = {
{-5.28, 1.45, -15.50},
{-3.54, 1.45, -17.10},
{-1.74, 1.45, -18.60},
{0.00, 1.45, -20.03},
{1.69, 1.45, -18.60},
{3.44, 1.45, -17.10},
{5.20, 1.45, -15.50},
{3.44, 1.45, -14.02},
{1.69, 1.45, -12.32},
{0.00, 1.45, -10.72},
{-1.74, 1.45, -12.35},
{-3.52, 1.45, -14.02},
{0.00, 1.45, -15.50}
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardPos[i])
for i=1, 15,1 do coroutine.yield(0) end
end
elseif layout == "Planetary" then
local cardPos = {
{0.00, 1.45, -19.46},
{-1.12, 1.45, -16.29},
{-3.31, 1.45, -14.63},
{-1.12, 1.45, -13.11},
{0.00, 1.45, -9.91},
{1.19, 1.45, -13.11},
{3.28, 1.45, -14.63},
{1.19, 1.45, -16.26}
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardPos[i])
for i=1, 15,1 do coroutine.yield(0) end
end
elseif layout == "Tree Of Life" then
local cardPos = {
{0.00, 1.47, -8.00},
{2.44, 1.47, -9.77},
{-2.50, 1.47, -9.72},
{2.48, 1.47, -12.82},
{-2.51, 1.47, -12.82},
{0.00, 1.47, -14.44},
{2.48, 1.47, -16.62},
{-2.51, 1.47, -16.60},
{0.00, 1.47, -18.61},
{0.00, 1.47, -21.65}
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
for i=1, 30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
if i >= 6 then
local targetPos = v.positionToWorld({0,0,0})
targetPos.x = targetPos.x + 4
targetPos.y = targetPos.y + 0.2
v.setPositionSmooth(targetPos)
end
if i <= 5 then
local targetPos = v.positionToWorld({0,0,0})
targetPos.x = targetPos.x - 4
targetPos.y = targetPos.y + 0.2
v.setPositionSmooth(targetPos)
end
end
for i=1, 30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardPos[i])
for i=1, 15,1 do coroutine.yield(0) end
end
elseif layout == "Cross & Triangle" then
local cardPos = {
{0.00, 1.46, -11.26},
{0.00, 1.46, -7.94},
{2.27, 1.46, -9.52},
{0.00, 1.46, -14.50},
{-2.25, 1.46, -9.52},
{-2.25, 1.46, -20.84},
{2.27, 1.46, -20.84},
{0.01, 1.46, -20.82},
{0.00, 1.46, -17.70}
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
if i >= 5 then
local targetPos = v.positionToWorld({0,0,0})
targetPos.x = targetPos.x + 5
targetPos.y = targetPos.y + 0.2
v.setPositionSmooth(targetPos)
end
if i <= 4 then
local targetPos = v.positionToWorld({0,0,0})
targetPos.x = targetPos.x - 4
targetPos.y = targetPos.y + 0.2
v.setPositionSmooth(targetPos)
end
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardPos[i])
for i=1,15,1 do coroutine.yield(0) end
end
elseif layout == "Relationship Problems" then
local cardPos = {
{3.56, 1.45, -18.77},
{3.56, 1.45, -15.58},
{-3.59, 1.45, -18.77},
{-3.58, 1.45, -15.58},
{0.00, 1.45, -16.04},
{0.00, 1.45, -12.78},
{3.56, 1.45, -10.05},
{0.00, 1.45, -9.49},
{-3.59, 1.45, -10.05},
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in pairs(selectedCards) do
v.setPositionSmooth(cardPos[i])
for i=1,15,1 do coroutine.yield(0) end
end
elseif layout == "Past Life" then
local cardPos = {
{0.00, 1.46, -7.74},
{-2.18, 1.46, -10.70},
{0.00, 1.46, -10.70},
{2.10, 1.46, -10.70},
{-2.17, 1.46, -13.64},
{0.00, 1.46, -13.64},
{2.10, 1.46, -13.64},
{-2.17, 1.46, -16.61},
{0.00, 1.46, -16.61},
{2.10, 1.46, -16.61},
{-1.15, 1.46, -19.60},
{1.08, 1.46, -19.60},
{-1.14, 1.46, -22.48},
{1.07, 1.46, -22.48}
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
if i >= 8 then
local targetPos = v.positionToWorld({0,0,0})
targetPos.x = targetPos.x + 4
targetPos.y = targetPos.y + 0.2
v.setPositionSmooth(targetPos)
end
if i <= 7 then
local targetPos = v.positionToWorld({0,0,0})
targetPos.x = targetPos.x - 4
targetPos.y = targetPos.y + 0.2
v.setPositionSmooth(targetPos)
end
end
for i=1,45,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardPos[i])
for i=1,15,1 do coroutine.yield(0) end
end
elseif layout == "Career Path" then
local cardPos = {
{0.91, 1.45, -12.01},
{-0.91, 1.45, -12.01},
{0.00, 1.45, -14.98},
{2.81, 1.45, -17.91},
{0.87, 1.45, -17.91},
{-0.96, 1.45, -17.91},
{-2.88, 1.45, -17.91}
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardPos[i])
for i=1,15,1 do coroutine.yield(0) end
end
elseif layout == "High Priestess" then
local cardPos = {
{-0.92, 1.45, -12.76},
{0.93, 1.45, -12.76},
{0.00, 1.45, -7.69},
{-2.58, 1.45, -9.18},
{2.64, 1.45, -9.18},
{-2.58, 1.45, -16.32},
{2.64, 1.45, -16.32},
{0.00, 1.45, -19.79},
{0.00, 1.45, -16.32}
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
if i >= 5 then
local targetPos = v.positionToWorld({0,0,0})
targetPos.x = targetPos.x + 5
targetPos.y = targetPos.y + 0.2
v.setPositionSmooth(targetPos)
end
if i <= 4 then
local targetPos = v.positionToWorld({0,0,0})
targetPos.x = targetPos.x - 4
targetPos.y = targetPos.y + 0.2
v.setPositionSmooth(targetPos)
end
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardPos[i])
for i=1,15,1 do coroutine.yield(0) end
end
elseif layout == "Should you Shouldn't you" then
local cardPos = {
{-5.48, 1.45, -11.30},
{-3.48, 1.45, -11.30},
{-1.51, 1.45, -11.30},
{1.30, 1.45, -11.30},
{3.31, 1.45, -11.30},
{5.30, 1.45, -11.30},
{-3.48, 1.45, -14.43},
{3.31, 1.45, -14.43},
{0.00, 1.45, -18.33}
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardPos[i])
for i=1,15,1 do coroutine.yield(0) end
end
elseif layout == "Star Guide" then
local cardPos = {
{0.01, 1.45, -10.98},
{-2.96, 1.45, -14.38},
{3.05, 1.45, -14.38},
{-2.96, 1.45, -19.98},
{3.05, 1.45, -20.04},
{0.01, 1.45, -17.18}
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardPos[i])
for i=1,15,1 do coroutine.yield(0) end
end
elseif layout == "Spiritual Guidance" then
local cardPos = {
{0.00, 1.45, -14.81},
{-5.95, 1.45, -11.65},
{-3.98, 1.45, -11.65},
{-1.97, 1.45, -11.65},
{0.00, 1.45, -11.65},
{1.98, 1.45, -11.65},
{3.98, 1.45, -11.65},
{5.96, 1.45, -11.65}
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardPos[i])
for i=1,15,1 do coroutine.yield(0) end
end
elseif layout == "Birthday" then
local cardPos = {
{-3.61, 1.51, -11.21},
{-1.21, 1.51, -11.21},
{1.11, 1.51, -11.21},
{3.35, 1.51, -11.21},
{-2.42, 1.51, -14.41},
{0.00, 1.51, -14.40},
{2.25, 1.51, -14.41},
{-1.49, 1.51, -17.51},
{1.46, 1.51, -17.51}
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardPos[i])
for i=1,15,1 do coroutine.yield(0) end
end
elseif layout == "Mandala" then
local cardPos = {
{0.00, 1.51, -13.90},
{1.28, 1.51, -11.00},
{2.61, 1.51, -13.90},
{1.28, 1.51, -16.76},
{0.00, 1.51, -19.60},
{-1.29, 1.51, -16.76},
{-2.69, 1.51, -13.90},
{-1.30, 1.51, -11.00},
{0.00, 1.51, -8.11}
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardPos[i])
for i=1,15,1 do coroutine.yield(0) end
end
elseif layout == "Horseshoe" then
local cardPos = {
{-3.46, 1.51, -16.04},
{-2.71, 1.51, -13.08},
{-1.93, 1.51, -10.07},
{0.00, 1.51, -9.31},
{1.93, 1.51, -10.07},
{2.76, 1.51, -13.08},
{3.51, 1.51, -16.04},
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardPos[i])
for i=1,15,1 do coroutine.yield(0) end
end
elseif layout == "Opportunities &\nObstacles" then
local cardPos = {
{-1.88, 1.51, -13.87},
{0.00, 1.51, -13.87},
{1.86, 1.51, -13.87},
{0.00, 1.51, -10.88},
{-1.88, 1.51, -10.88},
{0.00, 1.51, -16.83},
{1.86, 1.51, -16.83},
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardPos[i])
for i=1,15,1 do coroutine.yield(0) end
end
elseif layout == "Money Problems" then
local cardPos = {
{0.00, 1.51, -12.07},
{-3.24, 1.51, -15.01},
{3.15, 1.51, -15.01},
{-3.24, 1.51, -18.32},
{3.15, 1.51, -18.32},
{0.00, 1.51, -21.19},
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
for i=1,30,1 do coroutine.yield(0) end
for i,v in ipairs(selectedCards) do
v.setPositionSmooth(cardPos[i])
for i=1,15,1 do coroutine.yield(0) end
end
elseif layout == "Custom Cards" then
local cardPos = {
{-13.28, 1.41, -8.06},
{-13.28, 1.41, -10.24},
{-13.28, 1.41, -12.44},
{13.27, 1.50, -7.77},
{13.27, 1.50, -9.96},
{13.27, 1.50, -12.23}
}
for i,v in ipairs(selectedCards) do
local targetPos = v.positionToWorld({0,0,0})
targetPos.z = targetPos.z + 6
v.setPositionSmooth(targetPos)
end
end
end
return 1
end |
--[[
This script reads a list of domains we want to block from a file and redirects
all A or AAAA requsts to a "sorry page".
--]]
-- returns true if the given file exists
function fileExists(file)
local f = io.open(file, "rb")
if f then
f:close()
end
return f ~= nil
end
-- loads contents of a file line by line into the given table
function loadFile(filename, list)
if fileExists(filename) then
for line in io.lines(filename) do
list:add(line)
end
pdnslog("Lua script: " .. filename .. " successfully loaded", pdns.loglevels.Notice)
else
pdnslog("Lua script: could not open file " .. filename, pdns.loglevels.Warning)
end
end
-- this funciton is hooked before resolving starts
function preresolve(dq)
-- check blocklist
if blocklist:check(dq.qname) then
blocklist_metric:inc()
return true
end
-- default, do not rewrite this response
return false
end
function maintenance()
loadFile("/etc/pdns-recursor/block.list", blocklist)
end
-- import court mandated blocklist
blocklist=newDS()
loadFile("/etc/pdns-recursor/block.list", blocklist)
-- get metrics
blocklist_metric = getMetric("blocklist_hits")
local redis = require 'redis'
local client = redis.connect('127.0.0.1', 6379)
local response = client:ping() -- true
|
--
-- This script dies at the assert if compiled using the following commands:
-- 1. llvm-luac -O0 -no-main -bc -o scimark_rand.bc scimark_rand.lua
-- 2. opt -O2 -f -o scimark_rand_opt.bc scimark_rand.bc
-- 3. llc --march=c -f -o scimark_rand.c scimark_rand_opt.bc
-- 4. gcc -O3 -o scimark_rand scimark_rand.c ../liblua_main.a -lm -ld
--
-- Compiled on x86_64 Gentoo linux host.
--
-- If the optimization levels for 'opt' or 'gcc' are lowered then this script will run correctly.
-- Seems to expose a bug in LLVM or GCC or both.
--
local Rj = 17
local function rand()
local j = 17
if 17 < 17 then
Rj = j + 1
else
Rj = 1
print("Rj", Rj)
assert(Rj == 1)
end
end
rand()
|
--Author Pasky13
---------------
----GLOBALS----
---------------
local pbase = 0x9D8
local px = pbase +0x5
local py = pbase +0x8
local cx = 0x1E5D
local cy = 0x1E60
local xm
local ym
---------------
----TOGGLES----
---------------
local draw_megaman = true
local draw_enemies = true
local draw_hpvalues = true
local draw_projectiles = true
memory.usememorydomain("CARTROM")
local function megaman()
local camx = mainmemory.read_u16_le(cx)
local camy = mainmemory.read_u16_le(cy)
local x = mainmemory.read_u16_le(px) - camx
local y = mainmemory.read_u16_le(py) - camy
local facing = mainmemory.read_u8(pbase + 0x11)
local boxpointer = mainmemory.read_u16_le(pbase + 0x20) + 0x28000
local xoff = memory.read_s8(boxpointer + 0)
local yoff = memory.read_s8(boxpointer + 1)
local xrad = memory.read_u8(boxpointer + 2)
local yrad = memory.read_u8(boxpointer + 3)
if facing > 0x45 then
xoff = xoff * -1
end
gui.drawBox(x + xoff +xrad,y + yoff + yrad, x + xoff - xrad, y + yoff - yrad,0xFF0000FF,0x400000FF)
end
local function enemies()
local x
local xoff
local xrad
local y
local yoff
local yrad
local camx = mainmemory.read_u16_le(cx)
local camy = mainmemory.read_u16_le(cy)
local base
local boxpointer
local facing
local fill
local outl
local start = 0xD18
local oend = 31
for i = 0, oend,1 do
base = start + (i * 0x40)
if i == 0 then
base = start
end
if mainmemory.read_u8(base) ~= 0 and mainmemory.read_u8(base + 0x27) ~= 128 then
if i > 14 and i < 25 then
if draw_projectiles == true then
fill = 0x40FFFFFF
outl = 0xFFFFFFFF
else
fill = 0x00000000
outl = 0x00000000
end
else
fill = 0x40FF0000
outl = 0xFFFF0000
end
if i > 24 then
fill = 0x40FFFF00
outl = 0xFFFFFF00
end
facing = mainmemory.read_u8(base + 0x11)
x = mainmemory.read_u16_le(base + 5) - camx
y = mainmemory.read_u16_le(base + 8) - camy
boxpointer = mainmemory.read_u16_le(base +0x20) + 0x28000
xoff = memory.read_s8(boxpointer + 0)
yoff = memory.read_s8(boxpointer + 1)
xrad = memory.read_u8(boxpointer + 2)
yrad = memory.read_u8(boxpointer + 3)
if facing > 0x45 then
xoff = xoff * -1
end
--gui.text(x,y,string.format("%X",base)) -- Debug
gui.drawBox(x + xoff +xrad,y + yoff + yrad, x + xoff - xrad, y + yoff - yrad,outl, fill)
if draw_hpvalues == true and mainmemory.read_u8(base+0x27) > 0 and mainmemory.read_u8(base+0x27) ~= 128 then
if i < 15 or i > 20 then
gui.text((x-5) * xm,(y-5) * ym,"HP: " .. mainmemory.read_u8(base+0x27))
end
end
end
end
end
local function scaler()
xm = client.screenwidth() / 256
ym = client.screenheight() / 224
end
while true do
scaler()
if draw_megaman == true then
megaman()
end
if draw_enemies == true then
enemies()
end
emu.frameadvance()
end |
local sl = require("SIGIL")
-- set up our window and a few resources we need
sl.slWindow(400, 400, "Simple SIGIL Example", false)
sl.slSetFont(sl.slLoadFont("../fonts/jura.ttf"), 24)
sl.slSetTextAlign(sl.SL_ALIGN_CENTER)
while ((sl.slShouldClose() ~= 1) and (sl.slGetKey(sl.SL_KEY_ESCAPE) ~= 1)) do
-- background glow
sl.slSetForeColor(0.1, 0.9, 0.2, 0.4)
-- large text and fat line
sl.slSetForeColor(0.0, 0.8, 0.2, 1.0)
sl.slSetFontSize(24)
sl.slText(200, 250, "SIGIL:")
sl.slRectangleFill(200, 240, 100, 7)
-- smaller subtext
sl.slSetFontSize(14)
sl.slText(200, 220, "Sprites, text, sound, input, and more!")
sl.slLine(48, 210, 352, 210)
sl.slRender() -- draw everything
end
sl.slClose() -- close the window and shut down SIGIL |
Ext.RegisterSkillProperty("CUSTOMSURFACEBOOST", {
GetDescription = function (property)
return "Absorb surfaces to boost the skill"
end
})
--- @param status EsvStatus
--- @param statusSource EsvGameObject
--- @param character StatCharacter
--- @param par string
local function CSBStatusDescriptionParam(status, statusSource, statCharacter, par)
if string.match(par, "CSB%-") or string.match(par, "WPN%-") then
local field = string.gsub(par, "CSB%-", "")
local statEntry = status.Name.."_"..field.."_"
if string.match(par, "WPN%-") then
field = string.gsub(par, "WPN%-", "")
statEntry = Ext.GetStat(status.StatsId).BonusWeapon
Ext.Print(statEntry)
end
local character = statCharacter.Character
for i, sts in pairs(character:GetStatuses()) do
-- Ext.Print("status:", sts)
if string.match(sts, statEntry) then
statEntry = string.gsub(sts, "LXC_Proxy_", "")
end
end
local damage = {Min=0, Max=0}
statEntry = Ext.GetStat(statEntry)
if field == "DamageFromBase" then
local dmg = 0
if statEntry.Damage == 1 then
dmg = Game.Math.GetAverageLevelDamage(statCharacter.Level)
else
dmg = Game.Math.GetLevelScaledWeaponDamage(statCharacter.Level)
end
local globalMult = 1 + (statCharacter.Strength-10) * (Ext.ExtraData.DGM_StrengthGlobalBonus*0.01 + Ext.ExtraData.DGM_StrengthWeaponBonus*0.01) +
(statCharacter.Finesse-10) * (Ext.ExtraData.DGM_FinesseGlobalBonus*0.01) +
(statCharacter.Intelligence-10) * (Ext.ExtraData.DGM_IntelligenceGlobalBonus*0.01)
local damageTypeBoost = 1.0 + Game.Math.GetDamageBoostByType(statCharacter, statEntry["Damage Type"])
dmg = dmg*(statEntry.DamageFromBase/100)*damageTypeBoost
local dmgRange = dmg*(statEntry["Damage Range"])*0.005
local minDmg = math.floor(Ext.Round((dmg - dmgRange)*globalMult))
local maxDmg = math.ceil((dmg + dmgRange)*globalMult)
if maxDmg <= minDmg then maxDmg = maxDmg+1 end
local color = getDamageColor(statEntry["Damage Type"])
return "<font color="..color..">"..tostring(minDmg).."-"..tostring(maxDmg).." "..statEntry["Damage Type"].." damage".."</font>"
end
end
end
Ext.RegisterListener("StatusGetDescriptionParam", CSBStatusDescriptionParam) |
energylauncher = class:new()
function energylauncher:init(x, y, dir, r)
--PHYSICS STUFF
self.x = x-1
self.y = y-1
self.width = 8/16
self.height = 16/16
self.static = true
self.active = true
self.category = 4
self.gravity = 0
self.portalable = false
self.dir = dir or "right"
self.defaulton = true
self.green = false
self.r = {unpack(r)}
table.remove(self.r, 1)
table.remove(self.r, 1)
if self.r[1] and self.r[1] ~= "link" then
local v = convertr(self.r[1], {"string", "bool", "bool", "bool"}, true)
--DIR
self.dir = v[1]
--OFFSET?
self.offset = v[2]
if self.offset then
if self.dir == "left" or self.dir == "right" then
self.y = self.y + .5
else
self.x = self.x + .5
end
end
--GREEN
self.green = v[4]
--DEFAULT OFF?
self.defaulton = not v[3]
table.remove(self.r, 1)
end
self.on = self.defaulton
self.rotation = 0
self.mask = {true}
--IMAGE STUFF
self.drawable = true
self.graphic = energylauncherimage
if self.on then
self.quad = energylauncherquad[1][2]
else
self.quad = energylauncherquad[1][1]
end
self.offsetX = 8
self.offsetY = 0
self.quadcenterX = 8
self.quadcenterY = 8
if self.dir == "right" then --multiple directions. This code is so bad I feel bad :(
self.animationdirection = "right"
elseif self.dir == "left" then
self.animationdirection = "left"
self.offsetX = 0
self.x = self.x + 8/16
elseif self.dir == "up" then
self.rotation = -math.pi/2
self.y = self.y + 8/16
self.offsetY = 8
self.width = 16/16
self.height = 8/16
elseif self.dir == "down" then
self.rotation = math.pi/2
self.width = 16/16
self.height = 8/16
end
self.children = 0
self.launchtimer = 0
self.falling = false
end
function energylauncher:update(dt)
if self.finished then
return false
end
if (not self.on) or self.children >= 1 then --Check if there's a energy pellet
--nothing
else
self.launchtimer = self.launchtimer + dt
if self.launchtimer > 0.5 and self.children < 1 then
self:launchenergyball()
end
end
end
function energylauncher:launchenergyball()
local t = "yellow"
if self.green then
t = "green"
end
local obj
if self.dir == "right" then
obj = energyball:new(self.x+8/16, self.y+4/16, self.dir, t, self)
elseif self.dir == "down" then
obj = energyball:new(self.x+4/16, self.y+8/16, self.dir, t, self)
elseif self.dir == "left" then
obj = energyball:new(self.x-8/16, self.y+4/16, self.dir, t, self)
elseif self.dir == "up" then
obj = energyball:new(self.x+4/16, self.y-8/16, self.dir, t, self)
end
self.child = obj
table.insert(objects["energyball"], obj)
self.children = self.children + 1
self.launchtimer = 0
end
function energylauncher:callback(caught)
self.children = self.children - 1
self.child = false
if caught then
self.finished = true
end
end
function energylauncher:leftcollide(a, b)
if self:globalcollide(a, b) then
return false
end
return false
end
function energylauncher:rightcollide(a, b)
if self:globalcollide(a, b) then
return false
end
return false
end
function energylauncher:ceilcollide(a, b)
if self:globalcollide(a, b) then
return false
end
return false
end
function energylauncher:floorcollide(a, b)
if self:globalcollide(a, b) then
return false
end
if a == "player" and b.speedy < 0 then
playsound(blockhitsound) --make sound when hit by mario
end
end
function energylauncher:globalcollide(a, b)
end
function energylauncher:passivecollide(a, b)
return false
end
function energylauncher:input(t)
local quadi = 1
if t == "on" then
self.on = not self.defaulton
elseif t == "off" then
self.on = self.defaulton
elseif t == "toggle" then
self.on = not self.on
end
if self.on then
quadi = 2
if self.green then
self.launchtimer = 0.5
if self.child then
self.child.destroy = true
end
end
end
self.quad = energylauncherquad[1][quadi]
end
function energylauncher:link()
if #self.r > 2 then
for j, w in pairs(outputs) do
for i, v in pairs(objects[w]) do
if tonumber(self.r[2]) == v.cox and tonumber(self.r[3]) == v.coy then
v:addoutput(self)
end
end
end
end
end
-----------------------------------------------ENERGY PELLET---------------------------------------------------
energyball = class:new()
function energyball:init(x, y, dir, t, parent)
--PHYSICS STUFF
self.x = x
self.y = y
self.dir = dir or "right"
if self.dir == "right" then
self.speedx = 3
self.speedy = 0
elseif self.dir == "left" then
self.speedx = -3
self.speedy = 0
elseif self.dir == "up" then
self.speedx = 0
self.speedy = -3
elseif self.dir == "down" then
self.speedx = 0
self.speedy = 3
end
self.width = 8/16
self.height = 8/16
self.static = false
self.active = true
self.category = 4
self.t = t or "yellow"
self.ti = 1
if self.t == "green" then
self.ti = 2
end
self.hp = 3
self.gravity = 0
self.mask = {true, false}
--IMAGE STUFF
self.drawable = true
self.quadi = 1
self.graphic = energyballimage
self.quad = energyballquad[self.ti][self.quadi]
self.offsetX = 4
self.offsetY = 4
self.quadcenterX = 4
self.quadcenterY = 4
self.rotation = 0 --for portals
self.direction = "left"
self.animationtimer = 0
self.falling = false
self.dead = false
self.deathtimer = 0
self.autodelete = true
self.parent = parent
self.shot = false
end
function energyball:update(dt)
if self.hp > 0 or self.t == "green" then
self.animationtimer = self.animationtimer + dt
while self.animationtimer > 0.1 do
self.animationtimer = self.animationtimer - 0.1
self.quadi = self.quadi + 1
if self.quadi == 5 then
self.quadi = 1
end
self.quad = energyballquad[self.ti][self.quadi]
end
end
if self.hp <= 0 or self.destroy then
if self.hp <= 0 then
table.insert(emancipateanimations, emancipateanimation:new(self.x, self.y, self.width, self.height, self.graphic, self.quad, self.speedx*0.2, self.speedy*0.2, self.rotation, self.offsetX, self.offsetY, self.quadcenterX, self.quadcenterY))
end
self.parent:callback(self.catched)
return true
end
end
function energyball:hitwall()
if self.t ~= "green" then
self.hp = self.hp - 1
if self.hp < 0 then
self.destroy = true
return true
end
end
end
function energyball:leftcollide(a, b)
if self:globalcollide(a, b) then
return false
end
if a == "energycatcher" then
if b.dir == "right" then
--self.hp = 0
self.destroy = true
self.catched = true
return true
end
end
if onscreen(self.x, self.y, self.width, self.height) then
playsound(energybouncesound)
end
if a == "pixeltile" and b.dir == "right" then
if b.step == 0 then --upside down
self.speedy = -self.speedx
self.speedx = 0
else
self.speedy = self.speedx
self.speedx = 0
end
return true
elseif a == "tile" or a == "flipblock" or a == "door" or a == "frozencoin" then
self:hitwall()
end
self.speedx = math.abs(self.speedx)
return false
end
function energyball:rightcollide(a, b)
if self:globalcollide(a, b) then
return false
end
if onscreen(self.x, self.y, self.width, self.height) then
playsound(energybouncesound)
end
if a == "pixeltile" and b.dir == "left" then
if b.step == 0 then --upside down
self.speedy = self.speedx
self.speedx = 0
else
self.speedy = -self.speedx
self.speedx = 0
end
return true
elseif a == "tile" or a == "flipblock" or a == "door" or a == "frozencoin" then
self:hitwall()
end
self.speedx = -math.abs(self.speedx)
if a == "energycatcher" then
if b.dir == "left" then
--self.hp = 0
self.destroy = true
self.catched = true
return true
end
end
return false
end
function energyball:ceilcollide(a, b)
if self:globalcollide(a, b) then
return false
end
self.speedy = math.abs(self.speedy)
if onscreen(self.x, self.y, self.width, self.height) then
playsound(energybouncesound)
end
if a == "pixeltile" and b.step == 0 then
if b.dir == "right" then
self.speedx = self.speedy
self.speedy = 0
else
self.speedx = -self.speedy
self.speedy = 0
end
return true
elseif a == "tile" or a == "flipblock" or a == "door" or a == "frozencoin" then
self:hitwall()
end
if a == "energycatcher" then
if b.dir == "down" then
--self.hp = 0
self.destroy = true
self.catched = true
return true
end
end
end
function energyball:globalcollide(a, b)
if a == "turret" then
b:dofrenzy()
end
end
function energyball:floorcollide(a, b)
if self:globalcollide(a, b) then
return false
end
if onscreen(self.x, self.y, self.width, self.height) then
playsound(energybouncesound)
end
if a == "pixeltile" then
if b.dir == "right" then
self.speedx = self.speedy
self.speedy = 0
else
self.speedx = -self.speedy
self.speedy = 0
end
return true
elseif a == "tile" or a == "flipblock" or a == "door" or a == "frozencoin" then
self:hitwall()
end
self.speedy = -math.abs(self.speedy)
if a == "energycatcher" then
if b.dir == "up" then
--self.hp = 0
self.destroy = true
self.catched = true
return true
end
end
end
function energyball:passivecollide(a, b)
self:leftcollide(a, b)
return false
end
function energyball:portaled()
self.hp = 3
end
function energyball:emancipate(a)
self.destroy = true
end
function energyball:laser()
self.destroy = true
end
function energyball:autodeleted()
self.destroy = true
end |
model.plot={}
function model.plot.updateData(triggerData,plotId)
if model.plot.ui then
if plotId==1 then
simUI.clearCurve(model.plot.ui,1,'l')
simUI.clearCurve(model.plot.ui,1,'h')
simUI.clearCurve(model.plot.ui,1,'trigger')
local startT=0
if triggerData.lastTime-10>0 then
startT=triggerData.lastTime-10
end
local trig={}
for i=1,#triggerData.triggerTimes,1 do
trig[i]=4
end
simUI.addCurveTimePoints(model.plot.ui,1,'l',{startT,triggerData.lastTime},{0,0})
simUI.addCurveTimePoints(model.plot.ui,1,'h',{startT,triggerData.lastTime},{4.5,4.5})
if #trig>0 then
simUI.addCurveTimePoints(model.plot.ui,1,'trigger',triggerData.triggerTimes,trig)
end
simUI.rescaleAxesAll(model.plot.ui,1,false,false)
simUI.replot(model.plot.ui,1)
end
end
end
function model.plot.showPlot()
if not model.plot.ui then
local xml=[[
<plot id="1" max-buffer-size="1000" cyclic-buffer="false" background-color="25,25,25" foreground-color="150,150,150" y-ticks="false" y-tick-labels="false"/>
]]
if not model.plot.previousPos then
model.plot.previousPos="bottomRight"
end
model.plot.ui=simBWF.createCustomUi(xml,simBWF.getObjectAltName(model.handle),model.plot.previousPos,true,"model.plot.closePlot_callback",false,true,false,nil,model.plot.previousSize)
simUI.setPlotLabels(model.plot.ui,1,"time (seconds)","trigger state")
local curveStyle=simUI.curve_style.line
local scatterShape={scatter_shape=simUI.curve_scatter_shape.none,scatter_size=1,line_size=1,add_to_legend=false,selectable=false,track=false}
simUI.addCurve(model.plot.ui,1,simUI.curve_type.time,'l',{255,255,255},curveStyle,scatterShape)
simUI.addCurve(model.plot.ui,1,simUI.curve_type.time,'h',{64,64,64},curveStyle,scatterShape)
simUI.addCurve(model.plot.ui,1,simUI.curve_type.time,'trigger',{255,255,0},simUI.curve_style.scatter,{scatter_shape=simUI.curve_scatter_shape.circle,scatter_size=10,line_size=1,add_to_legend=true,selectable=true,track=false})
simUI.setLegendVisibility(model.plot.ui,1,true)
-- simUI.YLabel(model.plot.ui,1,''
simUI.setMouseOptions(model.plot.ui,1,false,false,false,false)
end
end
function model.plot.closePlot_callback()
model.plot.wasClosed=true
model.plot.closePlot()
end
function model.plot.closePlot()
if model.plot.ui then
local x,y=simUI.getPosition(model.plot.ui)
model.plot.previousPos={x,y}
local x,y=simUI.getSize(model.plot.ui)
model.plot.previousSize={x,y}
simUI.destroy(model.plot.ui)
model.plot.ui=nil
end
end
|
function onStart(target, buff)
add_buff_parameter(target, buff, 1)
end
function onPostTick(target, buff)
if buff.not_go_round > 0 then
return
end
buff.remaining_round = buff.remaining_round - 1;
if buff.remaining_round <= 0 then
UnitRemoveBuff(buff);
end
end
function onEnd(target, buff)
add_buff_parameter(target, buff, -1)
target.hp = 1
local T = {}
local max_count = 0
for _, v in ipairs(FindAllEnemy()) do
if v.BuffID_2103210 > 0 then
local count = RepeatReomveBuff(v, 2103210, 20)
if count > max_count then
max_count = count
end
table.insert(T, {role = v, count = count})
end
end
for i = 1, max_count do
for _, v in pairs(T) do
if i <= v.count then
Common_FireBullet(1103230, attacker, {v.role}, nil, {
Duration = 0,
Interval = 0,
Hurt = target.ad,
Type = 1,
Element = 4,
})
end
end
end
target.hp = 0
end
function targetAfterHit(target, buff, bullet)
local range = buff.cfg_property[1] and buff.cfg_property[1] or 0
if Hurt_Effect_judge(bullet) then
Common_UnitAddBuff(attacker, bullet.attacker, 2103210, range/10000, {round = 4})
end
end
function targetBeforeHit(target, buff, bullet)
local dam_reduce = buff.cfg_property[2] and buff.cfg_property[2]/10000 or 0
if bullet.attacker.BuffID_2103210 > 0 and Hurt_Effect_judge(bullet) then
bullet.damageReduce = bullet.damageReduce + dam_reduce
end
end |
--[[
© 2020 TERRANOVA do not share, re-distribute or modify
without permission of its author.
--]]
ix.meta = ix.meta or {}
local TRAIT = ix.meta.trait or {}
TRAIT.__index = TRAIT
TRAIT.name = "undefined"
TRAIT.description = "undefined"
TRAIT.uniqueID = "undefined"
TRAIT.category = "undefined"
TRAIT.icon = "undefined"
TRAIT.opposite = "undefined"
TRAIT.negative = false
TRAIT.hooks = {}
function TRAIT:GetName()
return self.name
end
function TRAIT:GetDescription()
return self.description
end
function TRAIT:GetIcon()
return self.icon
end
function TRAIT:Register()
if(self.positive == true) then
self.order = 1
elseif(self.negative == true) then
self.order = 3
else
self.order = 2
end
end
function TRAIT:GetColor()
if(self.positive == true) then
return Color(0, 255, 0, 11)
elseif(self.negative == true) then
return Color(255, 0, 0, 11)
else
return Color(255, 255, 255, 11)
end
end
ix.meta.trait = TRAIT
|
local function API_Check()
if Drawing == nil then
return "No"
else
return "Yes"
end
end
local Find_Required = API_Check()
if Find_Required == "No" then
game:GetService("StarterGui"):SetCore("SendNotification",{
Title = "Exunys Developer";
Text = "Crosshair script could not be loaded because your exploit is unsupported.";
Duration = math.huge;
Button1 = "OK"
})
return
end
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Camera = workspace.CurrentCamera
local Typing = false
local ViewportSize_ = Camera.ViewportSize / 2
local Axis_X, Axis_Y = ViewportSize_.X, ViewportSize_.Y
local HorizontalLine = Drawing.new("Line")
local VerticalLine = Drawing.new("Line")
_G.SendNotifications = true -- If set to true then the script would notify you frequently on any changes applied and when loaded / errored. (If a game can detect this, it is recommended to set it to false)
_G.DefaultSettings = false -- If set to true then the script would create a crosshair with the default settings regardless of any changes.
_G.ToMouse = false -- If set to true then the crosshair will be positioned to your mouse cursor's position. If set to false it will be positioned to the center of your screen.
_G.CrosshairVisible = true -- If set to true then the crosshair would be visible and vice versa.
_G.CrosshairSize = 20 -- The size of the crosshair.
_G.CrosshairThickness = 1 -- The thickness of the crosshair.
_G.CrosshairColor = Color3.fromRGB(0, 255, 0) -- The color of the crosshair
_G.CrosshairTransparency = 1 -- The transparency of the crosshair.
_G.DisableKey = Enum.KeyCode.Q -- The key that enables / disables the crosshair.
RunService.RenderStepped:Connect(function()
local Real_Size = _G.CrosshairSize / 2
HorizontalLine.Color = _G.CrosshairColor
HorizontalLine.Thickness = _G.CrosshairThickness
HorizontalLine.Visible = _G.CrosshairVisible
HorizontalLine.Transparency = _G.CrosshairTransparency
VerticalLine.Color = _G.CrosshairColor
VerticalLine.Thickness = _G.CrosshairThickness
VerticalLine.Visible = _G.CrosshairVisible
VerticalLine.Transparency = _G.CrosshairTransparency
if _G.ToMouse == true then
HorizontalLine.From = Vector2.new(UserInputService:GetMouseLocation().X - Real_Size, UserInputService:GetMouseLocation().Y)
HorizontalLine.To = Vector2.new(UserInputService:GetMouseLocation().X + Real_Size, UserInputService:GetMouseLocation().Y)
VerticalLine.From = Vector2.new(UserInputService:GetMouseLocation().X, UserInputService:GetMouseLocation().Y - Real_Size)
VerticalLine.To = Vector2.new(UserInputService:GetMouseLocation().X, UserInputService:GetMouseLocation().Y + Real_Size)
elseif _G.ToMouse == false then
HorizontalLine.From = Vector2.new(Axis_X - Real_Size, Axis_Y)
HorizontalLine.To = Vector2.new(Axis_X + Real_Size, Axis_Y)
VerticalLine.From = Vector2.new(Axis_X, Axis_Y - Real_Size)
VerticalLine.To = Vector2.new(Axis_X, Axis_Y + Real_Size)
end
end)
if _G.DefaultSettings == true then
_G.CrosshairVisible = true
_G.CrosshairSize = 25
_G.CrosshairThickness = 1
_G.CrosshairColor = Color3.fromRGB(40, 90, 255)
_G.CrosshairTransparency = 0.15
_G.DisableKey = Enum.KeyCode.Q
end
UserInputService.TextBoxFocused:Connect(function()
Typing = true
end)
UserInputService.TextBoxFocusReleased:Connect(function()
Typing = false
end)
UserInputService.InputBegan:Connect(function(Input)
if Input.KeyCode == _G.DisableKey and Typing == false then
_G.CrosshairVisible = not _G.CrosshairVisible
if _G.SendNotifications == true then
game:GetService("StarterGui"):SetCore("SendNotification",{
Title = "Exunys Developer";
Text = "The crosshair's visibility is now set to "..tostring(_G.CrosshairVisible)..".";
Duration = 5;
})
end
end
end)
|
local flora = {}
local sep = "\x03"
-- Flora's internal prefix coding for IRIs
local function _flora_iri_to_string(iri)
-- () -> return only the first value
return (iri:gsub("^i\x08", ""))
end
local
function _parse_xsb_output(str, fields)
local i = 1
local j = str:find(sep)
local vals = {}
for num = 1, fields do
table.insert(vals, str:sub(i, j - 1))
i = j + 1
j = str:find(sep, i)
if not j and num < fields then
error("Not enough values available for parsing")
end
end
return table.unpack(vals)
end
function flora.getprefixes()
local qres = xsb_query("flora_query(\"prefix{?X, ?Y}.\", [\"?X\"=X,\"?Y\"=Y],_,_,_).", " ")
local prefixes = {}
for idx, str in ipairs(qres) do
local i = str:find(" ")
local prefix = str:sub(1, i - 1)
local uri = str:sub(i + 1, -1 + str:find(" ", i + 1))
prefixes[prefix] = _flora_iri_to_string(uri)
end
return prefixes
end
function flora.getproperties(objname)
local query = string.format("%s[?X -> ?Y].", objname)
local qres = xsb_query(string.format("flora_query(\"%s\", [\"?X\"=X,\"?Y\"=Y],_,_,_).", query), sep)
local propvals = {}
for idx, str in ipairs(qres) do
local prop, val = _parse_xsb_output(str, 2)
if propvals[prop] then
-- handle sets dynamically
if type(propvals[prop]) ~= "table" then
local vals = {}
table.insert(vals, propvals[prop])
propvals[prop] = vals
end
table.insert(propvals[prop], val)
else
propvals[prop] = val
end
end
return propvals
end
function flora.classes(objname)
-- we only consider IRIs as classes, not other values
local query = string.format("%s:?X^^\\iri.", objname)
local qres = xsb_query(string.format("flora_query(\"%s\", [\"?X\"=X],_,_,_).", query), sep)
local classes = {}
local _dupcheck = {}
for idx, str in ipairs(qres) do
if not _dupcheck[str] then
table.insert(classes, _flora_iri_to_string(_parse_xsb_output(str, 1)))
_dupcheck[str] = 1
end
end
return classes
end
function flora.instances(classname)
-- TODO generalize with classes() method
local query = string.format("?X^^\\iri:%s.", classname)
local qres = xsb_query(string.format("flora_query(\"%s\", [\"?X\"=X],_,_,_).", query), sep)
local instances = {}
-- we need to remove identical answers from the Flora query
-- c.f. flranswer.P, flora_write_matches,
-- flora_skip_identical_answers
local _dupcheck = {}
for idx, str in ipairs(qres) do
if not _dupcheck[str] then
table.insert(instances, _flora_iri_to_string(_parse_xsb_output(str, 1)))
_dupcheck[str] = 1
end
end
return instances
end
function flora.shell()
xsb_command("flora_shell.")
end
return flora
|
script_name 'mimgui hello world'
local imgui = require 'mimgui'
imgui.OnFrame(
function() -- condition
return isPlayerPlaying(PLAYER_HANDLE)
end,
function() -- render frame
imgui.Begin('mimgui')
imgui.Text('Hello, World!')
imgui.End()
end)
|
local L = LibStub("AceLocale-3.0"):NewLocale("CopyAnything", "enUS", true)
--@localization(locale="enUS", handle-unlocalized="comment")@
--@do-not-package@
-- General
L.copyAnything = "Copy Anything"
-- Bindings
L.show = "Show"
-- Options
L.general = "General"
L.profiles = "Profiles"
L.copyFrame = "Copy Frame"
L.fastCopy = "Fast Copy"
L.fastCopyDesc = "Automatically hide the copy frame after CTRL+C is pressed."
-- Search types
L.searchType = "Search Type"
L.searchTypeDesc = "Method to use for searching for frames under the cursor."
L.searchTypeDescExtended = [=[Font Strings (default) - Search for individual FontStrings under the cursor.
Parent Frames - Search for top level frames under the cursor, and copy all text from their children.
Mouse Focus - Copy text from the mouse focus frame. Only works on frames that are registered for mouse events.]=]
L.fontStrings = "Font Strings"
L.parentFrames = "Parent Frames"
L.mouseFocus = "Mouse Focus"
-- Errors
L.invalidSearchType = "Invalid search type '%s'. Check options."
L.noTextFound = "No text found."
L.tooManyFontStrings = "More than %d font strings were found. The copy was cancelled to prevent the game from freezing for an excessive amount of time."
--@end-do-not-package@
|
Import("mod3/mod3.lua")
|
--creating class for state machine
machine = class{}
--intialising machine class with states passed in main
function machine:init(states)
self.states = states or false
self.current = false
end
--changing state
function machine:change(state,params)
self.current = self.states[state]()
if params then
self.current:init(params)
end
end
--update using current state update function
function machine:update(dt)
self.current:update(dt)
end
--redering using current state render function
function machine:render()
self.current:render()
end
|
require("gameData/gameData");
require("hall/userInfo/data/userInfoData");
require("hall/prop/propManager");
--@brief 每日任务数据源
DayTaskData = class(GameData);
DayTaskData.Delegate = {
onGetDayTaskListCallBack = "onGetDayTaskListCallBack";
onGetTaskRewardCallBack = "onGetTaskRewardCallBack";
}
DayTaskData.initData = function(self)
self.m_taskList = {};
end
DayTaskData.getDayTaskList = function(self, isForceUpdate)
self:__requestDayTaskList(isForceUpdate);
return Copy(self.m_taskList);
end
DayTaskData.__requestDayTaskList = function(self, isForceUpdate)
if table.isEmpty(self.m_taskList) or isForceUpdate then
OnlineSocketManager.getInstance():sendMsg(PHP_DAY_MISSION_GET_LIST,{});
end
end
DayTaskData.onGetDayTaskListCallBack = function(self, isSuccess, info)
if not isSuccess or table.isEmpty(info) then
self:execDelegate(DayTaskData.Delegate.onGetDayTaskListCallBack, false);
return;
end
self.m_taskList = {};
for k, v in pairs(info) do
local item = {};
item.region_id = tonumber(v.region_id) or 0; --?
item.jump_code = tostring(v.jump_code) or ""; --跳转地址
item.id = tonumber(v.id) or 0;
item.desc = tostring(v.desc) or ""; --微信分享动态
item.progress = tostring(v.progress) or ""; --任务完成进度(请原样展示,可能会有"进行中"这种值)
item.name = tostring(v.name) or ""; --任务名称
item.reward_type = tonumber(v.reward_type) or 0; --任务奖励类型
item.status = tonumber(v.status) or 0; --任务状态 0:未完成 1:已完成未领奖 2:已领奖
item.sort_order = tonumber(v.sort_order) or 0; --任务显示排序
item.icon = v.icon or "";--任务图标
item.reward = tonumber(v.reward) or 0;--任务奖励(请原样展示,可能会有"随机"这种值)
table.insert(self.m_taskList, item);
end
self:saveData();
self:execDelegate(DayTaskData.Delegate.onGetDayTaskListCallBack, true, Copy(self.m_taskList) );
end
DayTaskData.requestGetTaskReward = function(self, taskId)
VipAnimManager.getInstance():setPauseAnim(true);
OnlineSocketManager.getInstance():sendMsg(PHP_DAY_MISSION_GET_REWARD, {mission = taskId});
end
DayTaskData.onGetTaskRewardCallBack = function(self, isSuccess, info, sendParam)
VipAnimManager.getInstance():setPauseAnim(false);
if not isSuccess or table.isEmpty(info) then
self:execDelegate(DayTaskData.Delegate.onGetTaskRewardCallBack, false)
return;
end
info.reward_type = tonumber(info.reward_type) or 0;--任务奖励类型(参见全局配置表的物品ID)
info.reward = tonumber(info.reward) or 0;--领取的奖励数目
local totalNum;
if info.reward_type == 0 then
--奖励为银币
totalNum = kUserInfoData:getMoney() + info.reward;
kUserInfoData:setMoney(totalNum);
elseif info.reward_type == 1 then
--奖励为金条
totalNum = kUserInfoData:getCrystal() + info.reward;
kUserInfoData:setCrystal(totalNum);
elseif info.reward_type == 2 then
--奖励为砖石
totalNum = kUserInfoData:getDiamond() + info.reward;
kUserInfoData:setDiamond(totalNum);
else
--道具通过推送进行刷新
end
local isRefresh = self:refreshTaskStatus(sendParam.mission, 2);--设为已领奖
if isRefresh then
self:execDelegate(DayTaskData.Delegate.onGetDayTaskListCallBack, true, Copy(self.m_taskList) );
end
self:removeItemByjumpCode(CommonJumpCmds.GOTO_REGISTER_ACCOUNT);
self:execDelegate(DayTaskData.Delegate.onGetTaskRewardCallBack, true, info);
end
DayTaskData.refreshTaskStatus = function(self, taskId, status)
if not (taskId and status) then
return false;
end
for _, v in pairs(self.m_taskList) do
if v.id == taskId then
v.status = status or v.status;
return true;
end
end
return false;
end
DayTaskData.onFinishTaskSuccess = function(self, taskId)
Log.v("DayTaskData.onFinishTaskSuccess --> ", taskId);
for k,v in pairs(self.m_taskList) do
if tonumber(v.id) == tonumber(taskId) then
v.status = 1;
v.progress = "完成";
self:saveData();
break;
end
end
self:execDelegate(DayTaskData.Delegate.onGetDayTaskListCallBack, true, Copy(self.m_taskList) );
end
DayTaskData.getCanRewardTaskNum = function(self)
local num = 0;
for k, v in pairs(self.m_taskList) do
if tonumber(v.status) == 1 then --0:未完成 1:已完成未领奖 2:已领奖
num = num + 1;
end
end
return num;
end
DayTaskData.getRewardNumByjumpCode = function (self,jumpCode)
local num = 0;
for k, v in pairs(self.m_taskList) do
local jumpInfo = json.decode(v.jump_code);
if not table.isEmpty(jumpInfo) and jumpInfo.cmd == jumpCode then
num = v.reward;
end
end
return num;
end
DayTaskData.removeItemByjumpCode = function (self, jumpCode)
if table.isEmpty(self.m_taskList) then
return;
end
for k,v in pairs(self.m_taskList) do
local jumpInfo = json.decode(v.jump_code);
if not table.isEmpty(jumpInfo) and jumpInfo.cmd == jumpCode then
table.remove(self.m_taskList, k);
self:saveData();
end
end
end
---------------------------------------------------------------------------------------------------------
-- 本地缓存
DayTaskData.loadDictData = function(self, dict)
self.m_taskList = table.verify(json.decode(dict:getString("task_list")));
end
DayTaskData.saveDictData = function(self, dict)
dict:setString("task_list", json.encode(self.m_taskList));
end
DayTaskData.getLocalDictName = function(self)
self.m_userId = self.m_userId or kUserInfoData:getUserId();
return "dic_day_task_" .. self.m_userId;
end
DayTaskData.s_socketCmdFuncMap = {
[PHP_DAY_MISSION_GET_LIST] = DayTaskData.onGetDayTaskListCallBack;
[PHP_DAY_MISSION_GET_REWARD] = DayTaskData.onGetTaskRewardCallBack;
}; |
--@native term
function Terminal.setFG(color)
term.setTextColor(color)
end
function Terminal.setBG(color)
term.setBackgroundColor(color)
end
function Terminal.write(string)
term.write(cast(string, "string"))
end
function Terminal.clear()
term.clear()
end
function Terminal.clearLine()
term.clearLine()
end
function Terminal.getSize()
local x, y = term.getSize()
return {x = x, y = y}
end
function Terminal.setCursorBlink(blink)
term.setCursorBlink(blink)
end
function Terminal.redirect(object)
return term.redirect(object)
end
function Terminal.current()
return term.current()
end
function Terminal.setPos(x, y)
term.setCursorPos(x, y)
end
function Terminal.getPos()
local x, y = term.getCursorPos()
return {x = x, y = y}
end
function Terminal.isColor()
return term.isColor()
end
function Terminal.isColour()
return term.isColour()
end |
package.path = package.path..';../?.lua'
local ffi = require("ffi")
local libvirt, err = require("libvirt")
if (not libvirt) then
print(err);
return nil;
end
local function printHostName(conn)
local hostname = ffi.string(libvirt.Lib.virConnectGetHostname(conn));
print("Host: ", hostname);
end
local function printCPUModelNames(conn, arch)
local flags = 0;
print("==== printCPUModelNames ====")
-- first find out how many there are
local err = libvirt.Lib.virConnectGetCPUModelNames(conn,arch,nil,flags);
print("Number of models: ", err)
if err < 0 then
return false
end
--local voidPtr = ffi.new("void*[1]")
local modelsArray = ffi.new(ffi.typeof("char **[1]"))
err = libvirt.Lib.virConnectGetCPUModelNames(conn,arch,modelsArray,flags);
if err < 0 then
print("error with virConnectGetCPUModelNames: ", err)
return false
end
print("Models: ", modelsArray)
for i=0,err-1 do
local str = modelsArray[0][i]
if str ~= nil then
print("MODEL: ", ffi.string(str))
end
end
end
local function printCapabilities(conn)
local caps = libvirt.Lib.virConnectGetCapabilities (conn);
if caps ~= nil then
print("CAPS: ",ffi.string(caps));
end
--free(caps);
end
local driveruri = "qemu:///system";
local conn = libvirt.Lib.virConnectOpenReadOnly(driveruri);
if not conn then
print("No connection")
return
end
printHostName(conn)
printCPUModelNames(conn, "x86_64")
printCPUModelNames(conn, "mips")
--printCapabilities(conn);
libvirt.Lib.virConnectClose(conn);
|
Player = Object:extend()
function Player:init(uid, x, y)
self.dead = false
self.uid = uid
self.health = 100
self.armor = 0
self.speed = 250
self:setPos(x, y)
self.img = Engine.assets.image.pieceGreen
self.scale = .5
local w, h = self.img:getWidth(), self.img:getHeight()
self:setSize(w, h)
self:setShape('circle')
self:setSize(8)
self:setPhysics(world)
self.hurtTimer = 0
end
local down = love.keyboard.isDown
function Player:update(dt)
if self.hurtTimer > 0 then self.hurtTimer = self.hurtTimer - dt end
local x, y = 0, 0
if down("w") or down("up") then y = y - self.speed end
if down("s") or down("down") then y = y + self.speed end
if down("a") or down("left") then x = x - self.speed end
if down("d") or down("right") then x = x + self.speed end
self.body:applyForce(x, y)
self.x, self.y = self.body:getWorldCenter()
end
function Player:hurt(amt)
if self.hurtTimer <= 0 then
local dmg = amt
if self.armor > 0 then
if self.armor >= amt then
self.armor = self.armor - amt
else
dmg = amt - self.armor
self.health = self.health - dmg
end
else
self.health = self.health - amt
end
if self.health <= 0 then self.dead = true end
self.hurtTimer = .25
end
end |
local api = GetApi()
--api:setFPS(30);
local press = ""
function update()
press = ""
if api:btn(BTN_A) then
press = press .. "A "
else
press = press .. " "
end
if api:btn(BTN_B) then
press = press .. "B "
else
press = press .. " "
end
if api:btn(BTN_UP) then
press = press .. "U "
else
press = press .. " "
end
if api:btn(BTN_DOWN) then
press = press .. "D "
else
press = press .. " "
end
if api:btn(BTN_LEFT) then
press = press .. "L "
else
press = press .. " "
end
if api:btn(BTN_RIGHT) then
press = press .. "R "
else
press = press .. " "
end
end
function draw()
api:cls(COLOR_BLACK)
api:circb(api:analogX() + 80, api:analogY() + 64, 10, COLOR_GREEN)
api:text(0, 0, press, COLOR_WHITE)
end
|
--
-- Created by IntelliJ IDEA.
-- User: romansztergbaum
-- Date: 17/07/2018
-- Time: 16:47
-- To change this template use File | Settings | File Templates.
--
local entities = {}
function update()
end
function on_key_pressed(evt)
print("game scene keycode: " .. evt.keycode)
if (evt.keycode == Keyboard.Escape) then
shiva.dispatcher:trigger_quit_game_event(1)
end
end
function on_key_released(evt)
print("game scene released keycode: " .. evt.keycode)
end
function leave()
print("leave game scene")
for key, value in pairs(entities) do
shiva.entity_registry:destroy(value)
end
shiva.resource_registry:unload_all_resources("game_scene")
end
function on_after_load_resources(evt)
-- local id, sprite = shiva.entity_registry:create_game_object_with_sprite()
-- sprite:set_texture(shiva.resource_registry:get_texture("game_scene/toto"), false)
-- entities[#entities + 1] = id
-- shiva.entity_registry:add_layer_1_component(id)
end
function enter()
print("enter game scene")
shiva.resource_registry:load_all_resources("game_scene")
end
return {
on_key_released = on_key_released,
on_key_pressed = on_key_pressed,
on_after_load_resources = on_after_load_resources,
leave = leave,
enter = enter,
update = update,
scene_active = false
} |
--[[
This may be moved to a separate library at some point (Holiman)
--]]
local Utils =
{
-- Asks the user for Yes or No
confirm = function(message, ...)
local answer
message = message .. " [y/n] ?"
repeat
io.write(message)
io.flush()
answer=io.read()
if answer == 'Y' or answer == "y" then
return true
elseif answer == 'N' or answer == 'n' then
return false
end
until false
end,
---
-- Asks the user for input
input = function (message , default)
local answer
if default ~= nil then
message = message .. " (default: ".. default.. " )"
end
message = message .." \n > "
io.write(message)
io.flush()
answer=io.read()
if answer == '' then answer = default end
return answer
end,
------------ FILE READING
ReadDumpFile = function (filename)
if filename == nil then
return nil, 'Filename is empty'
end
if #filename == 0 then
return nil, 'Filename length is zero'
end
infile = io.open(filename, "rb")
if infile == nil then
return nil, string.format("Could not read file %s",filename)
end
local t = infile:read("*all")
len = string.len(t)
local _,hex = bin.unpack(("H%d"):format(len),t)
io.close(infile)
return hex
end,
------------ string split function
Split = function( inSplitPattern, outResults )
if not outResults then
outResults = {}
end
local start = 1
local splitStart, splitEnd = string.find( self, inSplitPattern, start )
while splitStart do
table.insert( outResults, string.sub( self, start, splitStart-1 ) )
start = splitEnd + 1
splitStart, splitEnd = string.find( self, inSplitPattern, start )
end
table.insert( outResults, string.sub( self, start ) )
return outResults
end,
------------ CRC-16 ccitt checksums
-- Takes a hex string and calculates a crc16
Crc16 = function(s)
if s == nil then return nil end
if #s == 0 then return nil end
if type(s) == 'string' then
local utils = require('utils')
local asc = utils.ConvertHexToAscii(s)
local hash = core.crc16(asc)
return hash
end
return nil
end,
-- input parameter is a string
-- Swaps the endianess and returns a number,
-- IE: 'cd7a' -> '7acd' -> 0x7acd
SwapEndianness = function(s, len)
if s == nil then return nil end
if #s == 0 then return '' end
if type(s) ~= 'string' then return nil end
local retval = 0
if len == 16 then
local t = s:sub(3,4)..s:sub(1,2)
retval = tonumber(t,16)
elseif len == 24 then
local t = s:sub(5,6)..s:sub(3,4)..s:sub(1,2)
retval = tonumber(t,16)
elseif len == 32 then
local t = s:sub(7,8)..s:sub(5,6)..s:sub(3,4)..s:sub(1,2)
retval = tonumber(t,16)
end
return retval
end,
-- input parameter is a string
-- Swaps the endianess and returns a string,
-- IE: 'cd7a' -> '7acd' -> 0x7acd
SwapEndiannessStr = function(s, len)
if s == nil then return nil end
if #s == 0 then return '' end
if type(s) ~= 'string' then return nil end
local retval
if len == 16 then
retval = s:sub(3,4)..s:sub(1,2)
elseif len == 24 then
retval = s:sub(5,6)..s:sub(3,4)..s:sub(1,2)
elseif len == 32 then
retval = s:sub(7,8)..s:sub(5,6)..s:sub(3,4)..s:sub(1,2)
end
return retval
end,
------------ CONVERSIONS
--
-- Converts DECIMAL to HEX
ConvertDecToHex = function(IN)
local B,K,OUT,I,D=16,"0123456789ABCDEF","",0
while IN>0 do
I=I+1
IN , D = math.floor(IN/B), math.modf(IN,B)+1
OUT=string.sub(K,D,D)..OUT
end
return OUT
end,
---
-- Convert Byte array to string of hex
ConvertBytesToHex = function(bytes)
if #bytes == 0 then
return ''
end
local s={}
for i = 1, #(bytes) do
s[i] = string.format("%02X",bytes[i])
end
return table.concat(s)
end,
-- Convert byte array to string with ascii
ConvertBytesToAscii = function(bytes)
if #bytes == 0 then
return ''
end
local s={}
for i = 1, #(bytes) do
s[i] = string.char(bytes[i])
end
return table.concat(s)
end,
ConvertHexToBytes = function(s)
local t={}
if s == nil then return t end
if #s == 0 then return t end
for k in s:gmatch"(%x%x)" do
table.insert(t,tonumber(k,16))
end
return t
end,
ConvertAsciiToBytes = function(s)
local t={}
if s == nil then return t end
if #s == 0 then return t end
for k in s:gmatch"(.)" do
table.insert(t, string.byte(k))
end
return t
end,
ConvertHexToAscii = function(s)
local t={}
if s == nil then return t end
if #s == 0 then return t end
for k in s:gmatch"(%x%x)" do
table.insert(t, string.char(tonumber(k,16)))
end
return table.concat(t)
end,
-- function convertStringToBytes(str)
-- local bytes = {}
-- local strLength = string.len(str)
-- for i=1,strLength do
-- table.insert(bytes, string.byte(str, i))
-- end
-- return bytes
-- end
-- function convertBytesToString(bytes)
-- local bytesLength = table.getn(bytes)
-- local str = ""
-- for i=1,bytesLength do
-- str = str .. string.char(bytes[i])
-- end
-- return str
-- end
-- function convertHexStringToBytes(str)
-- local bytes = {}
-- local strLength = string.len(str)
-- for k=2,strLength,2 do
-- local hexString = "0x" .. string.sub(str, (k - 1), k)
-- table.insert(bytes, hex.to_dec(hexString))
-- end
-- return bytes
-- end
-- function convertBytesToHexString(bytes)
-- local str = ""
-- local bytesLength = table.getn(bytes)
-- for i=1,bytesLength do
-- local hexString = string.sub(hex.to_hex(bytes[i]), 3)
-- if string.len(hexString) == 1 then
-- hexString = "0" .. hexString
-- end
-- str = str .. hexString
-- end
-- return str
-- end
}
return Utils |
---@class WorldStateInfo
C_WorldStateInfo = {}
|
-- Copyright (C) Alex Zhang
local cjson = require "cjson.safe"
local util = require "resty.requests.util"
local setmetatable = setmetatable
local pairs = pairs
local new_tab = util.new_tab
local is_func = util.is_func
local is_str = util.is_str
local insert = table.insert
local concat = table.concat
local find = string.find
local sub = string.sub
local ngx_match = ngx.re.match
local _M = { _VERSION = "0.1" }
local mt = { __index = _M }
local url_pattern = [[(?:(https?)://)?([^:/]+)(?::(\d+))?(.*)]]
local DEFAULT_PORT = {
http = 80,
https = 443,
}
local function parse_url(url)
local m, err = ngx_match(url, url_pattern, "jo")
if not m then
return nil, err
end
local parts = new_tab(0, 5)
parts.scheme = m[1] or "http"
parts.host = m[2]
parts.port = m[3] or DEFAULT_PORT[parts.scheme]
if not m[4] or m[4] == "" then
parts.path = "/"
parts.args = nil
else
local query = find(m[4], "?", nil, true)
if query then
parts.path = sub(m[4], 1, query - 1)
parts.args = sub(m[4], query + 1)
else
parts.path = m[4]
parts.args = nil
end
if parts.path == "" then
parts.path = "/"
end
end
return parts
end
local function prepare(url_parts, headers, session, config)
local headers = session.headers
headers["Content-Length"] = nil
headers["Transfer-Encoding"] = nil
local content
local json = config.json
local body = config.body
if json then
content = cjson.encode(json)
headers["Content-Length"] = #content
headers["Content-Type"] = "application/json"
else
content = body
if is_func(body) then
headers["Transfer-Encoding"] = "chunked"
if not headers["Content-Type"] then
headers["Content-Type"] = "application/octet-stream"
end
elseif body then
headers["Content-Length"] = #body
if not headers["Content-Type"] then
headers["Content-Type"] = "text/plain"
end
end
end
if not headers["Host"] then
headers["Host"] = url_parts.host
end
headers["Connection"] = "keep-alive"
local auth = session.auth
if auth then
headers["Authorization"] = auth
end
local cookie = session.cookie
if cookie then
local plain = new_tab(4, 0)
for k, v in pairs(cookie) do
insert(plain, ("%s=%s"):format(k, v))
end
headers["Cookie"] = concat(plain, "; ")
end
return content
end
local function new(method, url, headers, session, config)
local url_parts, err = parse_url(url)
if not url_parts then
return nil, err or "malformed url"
end
local body = prepare(url_parts, headers, session, config)
local r = {
method = method,
scheme = url_parts.scheme,
host = url_parts.host,
port = url_parts.port,
uri = url_parts.path,
args = url_parts.args,
headers = session.headers,
http_version = session.version,
proxies = session.proxies,
body = body,
}
return setmetatable(r, mt)
end
_M.new = new
return _M
|
ENT.Type = "brush"
ENT.Base = "base_brush"
function ENT:PassesTriggerFilters(ent)
return (ent:IsPlayer() || ent:GetClass() == "portalball")
end
function ENT:StartTouch(ent)
if ent:IsPlayer() then
for _,w in pairs(ents.FindByClass("portalgun")) do
if w.Owner == ent then
w:Clear(true)
w:Lock(true)
w:CheckExisting()
end
end
else
if ent:GetClass() == "portalball" then ent:Remove() end
end
end
function ENT:EndTouch(ent)
if ent:IsPlayer() then
for _,w in pairs(ents.FindByClass("portalgun")) do
if w.Owner == ent then
w:Lock(false)
w:CheckExisting()
end
end
end
end |
AddCSLuaFile("cl_init.lua");
AddCSLuaFile("shared.lua");
include("shared.lua");
include("autorun/laundry_config.lua"); -- Include the config file. There are other ways to do this, but this one has proved to be the easiest.
function ENT:Initialize()
self:SetModel("models/props_wasteland/laundry_washer003.mdl"); -- This is the model that the entity will use.
self:PhysicsInit(SOLID_VPHYSICS);
self:SetMoveType(MOVETYPE_VPHYSICS);
self:SetSolid(SOLID_VPHYSICS);
self.IsInUse = false
local phys = self:GetPhysicsObject();
if (phys:IsValid()) then
phys:Wake();
end;
end;
function ENT:StartTouch(ent)
if (ent:GetClass() == "laundry_wetclothes" and self.IsInUse == false) then
local EntOwner = ent:GetOwner()
self:EmitSound("ambient/machines/thumper_amb.wav");
ent:Remove()
self.IsInUse = true
-- Creating a function within the timer because creating a separate one was too much trouble..
timer.Simple(LaundryConfig.DryerTimer, function()
self:EmitSound("buttons/button9.wav");
self:StopSound("ambient/machines/thumper_amb.wav");
local OutputEnt = ents.Create("laundry_cleanclothes"); -- Spawning the clean clothing.
OutputEnt:SetPos(self:GetPos() + Vector(0, 0, 30));
OutputEnt:SetAngles(self:GetAngles());
OutputEnt:SetOwner(EntOwner);
OutputEnt:Spawn();
self.IsInUse = false
end);
end;
end;
function ENT:OnRemove()
self:StopSound("ambient/machines/thumper_amb.wav");
end; |
local modulemanager = require "core.modulemanager";
local config = require "core.configmanager";
module.host = "*";
local function reload_components()
local defined_hosts = config.getconfig();
for host in pairs(defined_hosts) do
if (not hosts[host] and host ~= "*") then
module:log ("debug", "loading new component %s", host);
modulemanager.load(host, configmanager.get(host, "core", "component_module"));
end
end;
return;
end
module:hook("config-reloaded", reload_components);
|
Config = {}
Config.MarkerType = 1
Config.DrawDistance = 0.1
Config.ZoneSize = {x = 5.0, y = 5.0, z = 3.0}
Config.MarkerColor = {r = 0, g = 0, b = 0}
Config.RequiredCopsCoke = 3
Config.RequiredCopsMeth = 3
Config.RequiredCopsWeed = 3
Config.RequiredCopsOpium = 3
Config.Locale = 'fr'
Config.Zones = {
CokeFarm = {x = 1272.3989, y = -1711.6396, z = 54.7714},
CokeTreatment = {x = 864.1530, y = -2496.4360, z = 52.3146},
CokeResell = {x = 2728.6877, y = 1577.9539, z = 66.5381},
MethFarm = {x = 1443.2133, y = 6331.8725, z = 23.98},
MethTreatment = {x = 662.0059, y = 1282.5637, z = 360.2959},
MethResell = {x = 680.8930, y = -1031.1052, z = 22.3505},
WeedFarm = {x = 1339.7961, y = 4225.3041, z = 33.915},
WeedTreatment = {x = -1913.1453, y = 2085.8876, z = 140.38},
WeedResell = {x = 245.0792, y = 129.6543, z = 102.59},
OpiumFarm = {x = -1933.4682, y = -3087.9343, z = 10.3437},
OpiumTreatment = {x = 725.6553, y = 4192.6630, z = 40.7091},
OpiumResell = {x = 525.2307, y = -974.1176, z = 27.4455}
}
|
local bin = require "plc52.bin"
local Reader = require("lightning-dissector.utils").Reader
local OrderedDict = require("lightning-dissector.utils").OrderedDict
local f = require("lightning-dissector.constants").fields.payload.deserialized
function deserialize(payload)
local reader = Reader:new(payload)
local packed_chain_hash = reader:read(32)
local packed_complete = reader:read(1)
return OrderedDict:new(
f.chain_hash, bin.stohex(packed_chain_hash),
"complete", OrderedDict:new(
f.complete.raw, bin.stohex(packed_complete),
f.complete.deserialized, (string.unpack(">I1", packed_complete))
)
)
end
return {
number = 262,
name = "reply_short_channel_ids_end",
deserialize = deserialize
}
|
---
-- D-NEB class
-- @classmod DNEB
local mc = require "flos.middleclass.middleclass"
local _NEB = require "flos.special.neb"
local array = require "flos.num"
-- Create the D-NEB class
local DNEB = mc.class("DNEB", _NEB)
--- Calculate perpendicular spring force for a given image
-- @int image image to calculate the perpendicular spring force of
-- @return the perpendicular spring force
function DNEB:perpendicular_spring_force(image)
-- We don't need to check image (these function calls does exactly that)
local S_F = self:spring_force(image)
-- Return the new perpendicular spring force
return S_F - S_F:project( self:tangent(image) )
end
-- Now we need to overwrite the calculation of the NEB-force
--- Calculate the resulting NEB force of a given image
-- @int image the image to calculate the NEB force of
-- @return NEB force
function DNEB:neb_force(image)
-- Calculate *original* NEB force
local NEB_F = _NEB.neb_force(self, image)
-- Only correct in case we are past climbing
if self.niter > self._climbing and self:climbing(image) then
return NEB_F
end
local PS_F = self:perpendicular_spring_force(image)
local P_F = self:perpendicular_force(image)
-- This is equivalent to:
-- flatdot(PS_F, P_F) / norm(P_F)^2 * P_F .* P_F
-- with .* being the elementwise multiplication
return NEB_F + PS_F - PS_F:project( P_F ) * P_F
end
--- Print to screen some information regarding the NEB algorithm
function DNEB:info()
print("DNEB Number of Images : " .. self.n_images)
print("DNEB Use Climbing After : " .. self._climbing .. " Steps")
local tmp = array.Array( self.n_images + 1 )
--tmp[1] = self:dR(0, 1):norm(0)
tmp[1] = self:dR(0, 1):norm(0)
for i = 2, self.n_images + 1 do
tmp[i] = tmp[i-1] + self:dR(i-1, i):norm(0)
end
print("DNEB Reaction Coordinates: ")
print(tostring(tmp))
local tmp = array.Array( self.n_images )
for i = 1, self.n_images do
tmp[i] = self.k[i]
end
print("DNEB spring constant: ")
print(tostring(tmp))
end
function DNEB:force(image, IO)
self:_check_image(image)
if image == 1 then
-- Increment step-counter
self.niter = self.niter + 1
end
local NEB_F = self:neb_force(image)
-- Things I want to output in files as control (all in 3xN format)
if IO then
local f
-- Current coordinates (ie .R)
f = io.open( ("DNEB.%d.R"):format(image), "a")
self[image].R:savetxt(f)
f:close()
-- Forces before (ie .F)
f = io.open( ("DNEB.%d.F"):format(image), "a")
self[image].F:savetxt(f)
f:close()
-- Perpendicular force
f = io.open( ("DNEB.%d.F.P"):format(image), "a")
self:perpendicular_force(image):savetxt(f)
f:close()
-- Spring force parallel
f = io.open( ("DNEB.%d.F.S.parallel"):format(image), "a")
self:spring_force(image):savetxt(f)
f:close()
-- Spring force perdpendicular
f = io.open( ("DNEB.%d.F.S.perpendicular"):format(image), "a")
self:perpendicular_spring_force(image):savetxt(f)
f:close()
-- NEB Force
f = io.open( ("DNEB.%d.F.NEB"):format(image), "a")
NEB_F:savetxt(f)
f:close()
-- Tangent
f = io.open( ("DNEB.%d.T"):format(image), "a")
self:tangent(image):savetxt(f)
f:close()
-- dR - previous reaction coordinate
f = io.open( ("DNEB.%d.dR_prev"):format(image), "a")
self:dR(image-1, image):savetxt(f)
f:close()
-- dR - next reaction coordinate
f = io.open( ("DNEB.%d.dR_next"):format(image), "a")
self:dR(image, image+1):savetxt(f)
f:close()
end
-- Fake return to test
return NEB_F
end
function DNEB:init_files()
-- We clean all image data for a new run
local function new_file(fname, ...)
local f = io.open(fname, 'w')
local a = {...}
for _, v in pairs(a) do
f:write("# " .. v .. "\n")
end
f:close()
end
new_file("DNEB.results", "DNEB results file",
"Image reaction-coordinate Energy E-diff Curvature F-max(atom)")
for img = 1, self.n_images do
new_file( ("DNEB.%d.R"):format(img), "Coordinates")
new_file( ("DNEB.%d.F"):format(img), "Constrained force")
new_file( ("DNEB.%d.F.P"):format(img), "Perpendicular force")
new_file( ("DNEB.%d.F.S.parallel"):format(img), "Spring parallel force")
new_file( ("DNEB.%d.F.S.perpendicular"):format(img), "Spring perpendicular force")
new_file( ("DNEB.%d.F.NEB"):format(img), "Resulting NEB force")
new_file( ("DNEB.%d.T"):format(img), "NEB tangent")
new_file( ("DNEB.%d.dR_prev"):format(img), "Reaction distance (previous)")
new_file( ("DNEB.%d.dR_next"):format(img), "Reaction distance (next)")
end
end
function DNEB:file_exists(name)--name
--local name
--DM_name=tostring(name)
DM_name=name
--print ("DM_name is :" .. DM_name)
local check
--local DM_name = name
local f = io.open(DM_name, "r") --name
if f ~= nil then
io.close(f)
--check=true
--print("TRUE: The file ".. DM_name.. " Exist!")
return true
else
--print("False: The file ".. DM_name.. " Doesn't Exist!")
return false
--check=false
end
--return check
end
return DNEB
|
--[[
This script uses the lavfi cropdetect filter to automatically
insert a crop filter with appropriate parameters for the
currently playing video.
It will automatically crop the video, when playback starts.
Also It registers the key-binding "C" (shift+c). You can manually
crop the video by pressing the "C" (shift+c) key.
If the "C" key is pressed again, the crop filter is removed
restoring playback to its original state.
The workflow is as follows: First, it inserts the filter
vf=lavfi=cropdetect. After <detect_seconds> (default is 1)
seconds, it then inserts the filter vf=crop=w:h:x:y, where
w,h,x,y are determined from the vf-metadata gathered by
cropdetect. The cropdetect filter is removed immediately after
the crop filter is inserted as it is no longer needed.
Since the crop parameters are determined from the 1 second of
video between inserting the cropdetect and crop filters, the "C"
key should be pressed at a position in the video where the crop
region is unambiguous (i.e., not a black frame, black background
title card, or dark scene).
The default options can be overridden by adding
script-opts-append=autocrop-<parameter>=<value> into mpv.conf
List of available parameters (For default values, see <options>):
auto: bool - Whether to automatically apply crop at the start of
playback. If you don't want to crop automatically, set it to
false or add "script-opts-append=autocrop-auto=no" into
mpv.conf.
auto_delay: seconds - Delay before starting crop in auto mode.
You can try to increase this value to avoid dark scene or
fade in at beginning. Automatic cropping will not occur if
the value is larger than the remaining playback time.
detect_limit: number[0-255] - Black threshold for cropdetect.
Smaller values will generally result in less cropping.
See limit of https://ffmpeg.org/ffmpeg-filters.html#cropdetect
detect_round: number[2^n] - The value which the width/height
should be divisible by. Smaller values have better detection
accuracy. If you have problems with other filters,
you can try to set it to 4 or 16.
See round of https://ffmpeg.org/ffmpeg-filters.html#cropdetect
detect_min_ratio: number[0.0-1.0] - The ratio of the minimum clip
size to the original. If the picture is over cropped or under
cropped, try adjusting this value.
detect_seconds: seconds - How long to gather cropdetect data.
Increasing this may be desirable to allow cropdetect more
time to collect data.
suppress_osd: bool - Whether the OSD shouldn't be used when filters
are applied and removed.
--]]
require "mp.msg"
require 'mp.options'
local options = {
auto = true,
auto_delay = 4,
detect_limit = "24/255",
detect_round = 2,
detect_min_ratio = 0.5,
detect_seconds = 1,
suppress_osd = false,
}
read_options(options)
local label_prefix = mp.get_script_name()
local labels = {
crop = string.format("%s-crop", label_prefix),
cropdetect = string.format("%s-cropdetect", label_prefix)
}
timers = {
auto_delay = nil,
detect_crop = nil
}
local command_prefix = options.suppress_osd and 'no-osd' or ''
function is_filter_present(label)
local filters = mp.get_property_native("vf")
for index, filter in pairs(filters) do
if filter["label"] == label then
return true
end
end
return false
end
function is_enough_time(seconds)
-- Plus 1 second for deviation.
local time_needed = seconds + 1
local playtime_remaining = mp.get_property_native("playtime-remaining")
return playtime_remaining and time_needed < playtime_remaining
end
function is_cropable()
for _, track in pairs(mp.get_property_native('track-list')) do
if track.type == 'video' and track.selected then
return not track.albumart
end
end
return false
end
function remove_filter(label)
if is_filter_present(label) then
mp.command(string.format('%s vf remove @%s', command_prefix, label))
return true
end
return false
end
function cleanup()
-- Remove all existing filters.
for key, value in pairs(labels) do
remove_filter(value)
end
-- Kill all timers.
for index, timer in pairs(timers) do
if timer then
timer:kill()
timer = nil
end
end
end
function detect_crop()
-- If it's not cropable, exit.
if not is_cropable() then
mp.msg.warn("autocrop only works for videos.")
return
end
-- Verify if there is enough time to detect crop.
local time_needed = options.detect_seconds
if not is_enough_time(time_needed) then
mp.msg.warn("Not enough time to detect crop.")
return
end
-- Insert the cropdetect filter.
local limit = options.detect_limit
local round = options.detect_round
mp.command(
string.format(
'%s vf pre @%s:cropdetect=limit=%s:round=%d:reset=0',
command_prefix, labels.cropdetect, limit, round
)
)
-- Wait to gather data.
timers.detect_crop = mp.add_timeout(time_needed, detect_end)
end
function detect_end()
-- Get the metadata and remove the cropdetect filter.
local cropdetect_metadata =
mp.get_property_native(
string.format("vf-metadata/%s",
labels.cropdetect
)
)
remove_filter(labels.cropdetect)
-- Remove the timer of detect crop.
if timers.detect_crop then
timers.detect_crop:kill()
timers.detect_crop = nil
end
local meta = {}
-- Verify the existence of metadata.
if cropdetect_metadata then
meta = {
w = cropdetect_metadata["lavfi.cropdetect.w"],
h = cropdetect_metadata["lavfi.cropdetect.h"],
x = cropdetect_metadata["lavfi.cropdetect.x"],
y = cropdetect_metadata["lavfi.cropdetect.y"],
}
else
mp.msg.error("No crop data.")
mp.msg.info("Was the cropdetect filter successfully inserted?")
mp.msg.info("Does your version of ffmpeg/libav support AVFrame metadata?")
return
end
-- Verify that the metadata meets the requirements and convert it.
if meta.w and meta.h and meta.x and meta.y then
local width = mp.get_property_native("width")
local height = mp.get_property_native("height")
meta = {
w = tonumber(meta.w),
h = tonumber(meta.h),
x = tonumber(meta.x),
y = tonumber(meta.y),
min_w = width * options.detect_min_ratio,
min_h = height * options.detect_min_ratio,
max_w = width,
max_h = height
}
else
mp.msg.error("Got empty crop data.")
mp.msg.info("You might need to increase detect_seconds.")
return
end
apply_crop(meta)
end
function apply_crop(meta)
-- Verify if it is necessary to crop.
local is_effective = meta.x > 0 or meta.y > 0
or meta.w < meta.max_w or meta.h < meta.max_h
if not is_effective then
mp.msg.info("No area detected for cropping.")
return
end
-- Verify it is not over cropped.
local is_excessive = meta.w < meta.min_w and meta.h < meta.min_h
if is_excessive then
mp.msg.info("The area to be cropped is too large.")
mp.msg.info("You might need to decrease detect_min_ratio.")
return
end
-- Remove existing crop.
remove_filter(labels.crop)
-- Apply crop.
mp.command(
string.format("%s vf pre @%s:lavfi-crop=w=%s:h=%s:x=%s:y=%s",
command_prefix, labels.crop, meta.w, meta.h, meta.x, meta.y
)
)
end
function on_start()
-- Clean up at the beginning.
cleanup()
-- If auto is not true, exit.
if not options.auto then
return
end
-- If it is the beginning, wait for detect_crop
-- after auto_delay seconds, otherwise immediately.
local playback_time = mp.get_property_native("playback-time")
local is_delay_needed = playback_time
and options.auto_delay > playback_time
if is_delay_needed then
-- Verify if there is enough time for autocrop.
local time_needed = options.auto_delay + options.detect_seconds
if not is_enough_time(time_needed) then
mp.msg.warn("Not enough time for autocrop.")
return
end
timers.auto_delay = mp.add_timeout(time_needed,
function()
detect_crop()
-- Remove the timer of auto delay.
timers.auto_delay:kill()
timers.auto_delay = nil
end
)
else
detect_crop()
end
end
function on_toggle()
-- If it is during auto_delay, kill the timer.
if timers.auto_delay then
timers.auto_delay:kill()
timers.auto_delay = nil
end
-- Cropped => Remove it.
if remove_filter(labels.crop) then
return
end
-- Detecting => Leave it.
if timers.detect_crop then
mp.msg.warn("Already cropdetecting!")
return
end
-- Neither => Do delectcrop.
detect_crop()
end
mp.add_key_binding("C", "toggle_crop", on_toggle)
mp.register_event("end-file", cleanup)
mp.register_event("file-loaded", on_start)
|
local Json = require('json')
local Fs = require('fs')
local Object = require('core').Object
local Watcher = require('uv').Watcher
local Conf = Object:extend()
function Conf:initialize(path)
if Fs.existsSync(path) then
self.path = path
else
error('No configuration file found')
end
end
function Conf:read()
if not self.path then
return nil
end
local content = Fs.readFileSync(self.path)
local json = Json.parse(content)
return json
end
function Conf:watch(callback)
if not self.path then
return nil
end
--local watcher = Watcher:new(self.path)
--watcher:on('change', callback)
end
return Conf
|
--[[
Mission mode for RIO
Designed to be as idiot proof as possible
Setup:
1. Make a folder in Courses with the name of your mission group.
2. Fill it with up to 6 courses.
3. Add to this script.
Refer to https://github.com/stepmania/stepmania/wiki/Courses on help with making courses.
There is one unique tag you can put in RIO courses, which is #MINSCORE. This is the minimum score needed to pass the mission.
]]
--[[
Sorry jousway lol you can put it in the config.ini if you want
This controls the number of courses you can skip before going on to the next mission group.
So let's say you completed 3 out of 5 missions for the group it's set to 2, now you can
go on to the next group.
]]
NUM_MISSIONS_SKIPPABLE = 2
RIO_COURSES = ["An Example Group"]
|
local Plugin = {}
Plugin.WINRATE = "pregamescoreboardsort_WINRATE"
TGNS.RegisterNetworkMessage(Plugin.WINRATE, {i="integer",m="float", a="float"})
function Plugin:Initialise()
self.Enabled = true
return true
end
function Plugin:Cleanup()
--Cleanup your extra stuff like timers, data etc.
self.BaseClass.Cleanup( self )
end
Shine:RegisterExtension("pregamescoreboardsort", Plugin ) |
local cjson = require 'cjson'
local utils = {}
-- Assume required if default_value is nil
function utils.getopt(opt, key, default_value)
if default_value == nil and (opt == nil or opt[key] == nil) then
error('error: required key ' .. key .. ' was not provided in an opt.')
end
if opt == nil then return default_value end
local v = opt[key]
if v == nil then v = default_value end
return v
end
function utils.read_json(path)
local file = io.open(path, 'r')
local text = file:read()
file:close()
local info = cjson.decode(text)
return info
end
function utils.countKeys(tableInput)
local count = 0
for k, v in pairs(tableInput) do
count = count + 1
end
return count
end
function utils.read_encoding(path)
local info = utils.read_json(path)
local new_table = {}
local encodingSize = nil
local numCaps = nil
for k,v in pairs(info) do
if encodingSize == nil then
encodingSize = utils.countKeys(info[k][1])
end
if numCaps == nil then
numCaps = utils.countKeys(info[k])
end
new_table[tonumber(k)] = torch.Tensor(numCaps, encodingSize)
for k1, v1 in pairs(v) do
for k2, v2 in pairs(v1) do
new_table[tonumber(k)][k1][k2] = v2
end
end
end
return new_table
end
function utils.write_json(path, j)
-- API reference http://www.kyne.com.au/~mark/software/lua-cjson-manual.html#encode
cjson.encode_sparse_array(true, 2, 10)
local text = cjson.encode(j)
local file = io.open(path, 'w')
file:write(text)
file:close()
end
-- dicts is a list of tables of k:v pairs, create a single
-- k:v table that has the mean of the v's for each k
-- assumes that all dicts have same keys always
function utils.dict_average(dicts)
local dict = {}
local n = 0
for i,d in pairs(dicts) do
for k,v in pairs(d) do
if dict[k] == nil then dict[k] = 0 end
dict[k] = dict[k] + v
end
n=n+1
end
for k,v in pairs(dict) do
dict[k] = dict[k] / n -- produce the average
end
return dict
end
-- seriously this is kind of ridiculous
function utils.count_keys(t)
local n = 0
for k,v in pairs(t) do
n = n + 1
end
return n
end
-- return average of all values in a table...
function utils.average_values(t)
local n = 0
local vsum = 0
for k,v in pairs(t) do
vsum = vsum + v
n = n + 1
end
return vsum / n
end
function utils.getCaptions(data, seq_per_image, caption_encoding_path, encoding_size, negativeCaps)
local imageIds = {}
for k, v in pairs(data.infos) do
table.insert(imageIds, v['id'])
end
local captionEncodedPositive = torch.Tensor(#imageIds * seq_per_image, encoding_size)
local captionEncodedNegative = torch.Tensor(#imageIds * seq_per_image, encoding_size)
local capCount = 0
for k, v in pairs(imageIds) do
local temp_table = {}
if caption_encoding[v] == nil then
temp_table = utils.read_encoding(caption_encoding_path .. 'coco_skipthoughts_' .. v .. '.json')
caption_encoding[v] = temp_table[v]
else
temp_table[v] = caption_encoding[v]
end
captionEncodedPositive[{{capCount+1, capCount+seq_per_image}, {}}] = temp_table[v][{{1, 5}, {}}]
capCount = capCount + seq_per_image
end
capCount = 0
for k, v in pairs(imageIds) do
for i = 1, seq_per_image do
--captionEncodedNegative[{{capCount+i}, {}}] = caption_encoding[tostring(negativeCaps[v][i])][math.random(seq_per_image)]
--[[
local randNo1
while randNo1 == nil or v == imageIds[randNo1] do
randNo1 = math.random(#imageIds)
end
--]]
local temp_table = {}
v_ = tostring(v)
if caption_encoding[negativeCaps[v_][i]] == nil then
temp_table = utils.read_encoding(caption_encoding_path .. 'coco_skipthoughts_' .. negativeCaps[v_][i] .. '.json')
caption_encoding[negativeCaps[v_][i]] = temp_table[negativeCaps[v_][i]]
else
temp_table[negativeCaps[v_][i]] = caption_encoding[negativeCaps[v_][i]]
end
captionEncodedNegative[{{capCount+i}, {}}] = temp_table[negativeCaps[v_][i]][math.random(seq_per_image)]
end
capCount = capCount + seq_per_image
end
return captionEncodedPositive, captionEncodedNegative
end
return utils
|
--[[
##############################################################################
S V U I By: Failcoder
Obliterum Skin By: JoeyMagz
##############################################################################
--]]
--[[ GLOBALS ]]--
local _G = _G;
local unpack = _G.unpack;
local select = _G.select;
local ipairs = _G.ipairs;
local pairs = _G.pairs;
local type = _G.type;
--[[ ADDON ]]--
local SV = _G['InkedSV'];
local L = SV.L;
local MOD = SV.Skins;
local Schema = MOD.Schema;
--[[
##########################################################
OBLITERUM FORGE
##########################################################
]]--
local function OblitFrameStyle()
if SV.db.Skins.blizzard.enable ~= true or SV.db.Skins.blizzard.obliterum ~= true then
return
end
-- Set API
SV.API:Set("Window", ObliterumForgeFrame, true)
SV.API:Set("Button", ObliterumForgeFrame.ObliterateButton, true)
SV.API:Set("ItemButton", ObliterumForgeFrame.ItemSlot, nil, true)
-- Movable Window
ObliterumForgeFrame:SetMovable(true)
ObliterumForgeFrame:EnableMouse(true)
ObliterumForgeFrame:RegisterForDrag("LeftButton")
ObliterumForgeFrame:SetScript("OnDragStart", ObliterumForgeFrame.StartMoving)
ObliterumForgeFrame:SetScript("OnDragStop", ObliterumForgeFrame.StopMovingOrSizing)
end
--[[
##########################################################
MOD LOADING
##########################################################
]]--
MOD:SaveBlizzardStyle("Blizzard_ObliterumUI",OblitFrameStyle)
|
greater_standing_attack_damage_moving_health_regen = class({})
function greater_standing_attack_damage_moving_health_regen:OnCreated( data )
-- ### VALUES START ### --
self.attack_damage = 24
self.health_regen = 1.5
self.effectiveness_defensive = 18.0
self.effectiveness_supportive = 32.0
-- ### VALUES END ### --
if not IsServer() then return end
self.perkname = data.perkName
self.perkID = data.perkID
self.level = data.level
self.perkEffectiveness = data.perkEffectiveness
Change_PerkEffectivenessStats(self, true)
local caster = self:GetParent()
self.oldPos = caster:GetAbsOrigin()
self.stacks = 0
self:StartIntervalThink(0.1)
end
function greater_standing_attack_damage_moving_health_regen:OnRemoved()
if not IsServer() then return end
Change_PerkEffectivenessStats(self, false)
end
function greater_standing_attack_damage_moving_health_regen:DeclareFunctions()
local funcs = {
MODIFIER_PROPERTY_BASEDAMAGEOUTGOING_PERCENTAGE,
MODIFIER_PROPERTY_HEALTH_REGEN_PERCENTAGE,
}
return funcs
end
function greater_standing_attack_damage_moving_health_regen:OnIntervalThink()
local caster = self:GetParent()
self:SetStackCount( 10000 * self.perkEffectiveness )
local distance = ( self.oldPos - caster:GetAbsOrigin() ):Length2D()
if distance == 0 then
self:SetStackCount( 10000 * self.perkEffectiveness )
else
self:SetStackCount( -1 * 10000 * self.perkEffectiveness )
end
self.oldPos = caster:GetAbsOrigin()
end
function greater_standing_attack_damage_moving_health_regen:GetModifierBaseDamageOutgoing_Percentage( params )
if self:GetStackCount() > 0 then
return self.attack_damage * ( self:GetStackCount() / 10000 )
else
return 0
end
end
function greater_standing_attack_damage_moving_health_regen:GetModifierHealthRegenPercentage( params )
if self:GetStackCount() < 0 then
return self.health_regen * ( self:GetStackCount() / 10000 ) * -1
else
return 0
end
end
function greater_standing_attack_damage_moving_health_regen:GetAttributes()
return MODIFIER_ATTRIBUTE_PERMANENT + MODIFIER_ATTRIBUTE_IGNORE_INVULNERABLE + MODIFIER_ATTRIBUTE_MULTIPLE
end
function greater_standing_attack_damage_moving_health_regen:IsHidden()
return true
end
function greater_standing_attack_damage_moving_health_regen:IsPurgable()
return false
end
function greater_standing_attack_damage_moving_health_regen:IsPurgeException()
return false
end
function greater_standing_attack_damage_moving_health_regen:IsStunDebuff()
return false
end
function greater_standing_attack_damage_moving_health_regen:IsDebuff()
return false
end
|
-- Helpful premake documentation
-- Tokens https://github.com/premake/premake-core/wiki/Tokens
workspace ("RuntimeCompiling")
architecture ("x86")
configurations
{
"Debug",
"Release"
}
outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
IncludeDir = {}
IncludeDir["dlfcn"] = "RuntimeCompiling/Vendor/dlfcn"
-- Engine
project ("RuntimeCompiling")
location ("RuntimeCompiling")
kind "ConsoleApp"
language "C++"
cppdialect "C++17"
staticruntime "off"
targetdir ("Bin/" .. outputdir .. "/%{prj.name}")
objdir ("Bin-Int/" .. outputdir .. "/%{prj.name}")
pchheader "stdafx.h"
pchsource "RuntimeCompiling/Source/stdafx.cpp"
files
{
"%{prj.name}/Source/**.cpp",
"%{prj.name}/Source/**.h",
}
defines
{
"_CRT_SECURE_NO_WARNINGS",
}
includedirs
{
"%{IncludeDir.dlfcn}/",
"%{prj.name}/Source/",
}
links
{
}
filter "system:windows"
systemversion "latest"
flags
{
"MultiProcessorCompile"
}
|
-------------------------
-- Brightness Widget --
-------------------------
local wibox = require("wibox")
local text = wibox.widget{
align = 'center',
valign = 'center',
widget = wibox.widget.textbox,
}
brightness_indicator = {
text,
fg = '#e2a478',
widget = wibox.container.background
}
function update_brightness()
local fd = io.popen("brightnessctl -m | awk -F',' '{print $4}'")
local status = fd:read("*all")
fd:close()
text.markup = "Brightness: " .. status
end
update_brightness()
|
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
AddCSLuaFile("round/cl_controller.lua")
include("cvars.lua")
include("shared.lua")
include("round/sv_controller.lua")
-- Teams
team.SetUp(1, "Innocent", Color(125, 125, 125, 255))
team.SetUp(2, "Traitor", Color(125, 125, 125, 255))
team.SetUp(3, "Spectator", Color(0, 0, 0, 0))
-- Joining events
function GM:PlayerConnect(name, ip)
print("Player " .. name .. " connected")
end
function GM:PlayerInitialSpawn(ply)
-- Set all new players to spectators
ply:SetTeam(3)
ply:Spectate(0)
print("Player " .. ply:Name() .. " joined")
end |
settings = NewSettings()
source =
{
"CompSystem.c",
"testmain.c"
}
objects = Compile(settings, source)
exe = Link(settings, "test", objects)
|
pfDB["areatrigger"]["data-turtle"] = {
}
|
return {
summary = 'Reset the matrix to the identity.',
description = [[
Resets the matrix to the identity, effectively setting its translation to zero, its scale to 1,
and clearing any rotation.
]],
arguments = {},
returns = {
{
name = 'm',
type = 'Mat4',
description = 'The original matrix.'
}
},
related = {
'lovr.graphics.origin'
}
}
|
pg = pg or {}
pg.IPAddress = class("IPAddress")
slot2 = "https://www.azurlane.tw/getip"
slot3 = {
{
"202.39.128.0",
"202.39.255.255"
},
{
"203.66.0.0",
"203.66.255.255"
},
{
"203.69.0.0",
"203.69.255.255"
},
{
"203.75.0.0",
"203.75.255.255"
},
{
"203.74.0.0",
"203.74.255.255"
},
{
"210.65.0.0",
"210.65.255.255"
},
{
"210.71.128.0",
"210.71.255.255"
},
{
"210.61.0.0",
"210.61.255.255"
},
{
"210.62.248.0",
"210.62.255.255"
},
{
"210.59.128.0",
"210.59.255.255"
},
{
"210.242.0.0",
"210.242.127.255"
},
{
"210.242.128.0",
"210.242.255.255"
},
{
"210.241.224.0",
"210.241.255.255"
},
{
"211.72.0.0",
"211.72.127.255"
},
{
"211.72.128.0",
"211.72.255.255"
},
{
"211.75.0.0",
" 211.75.127.255"
},
{
"211.75.128.0",
"211.75.255.255"
},
{
"211.20.0.0",
"211.20.255.255"
},
{
"211.21.0.0",
"211.21.255.255"
},
{
"211.22.0.0",
"211.22.255.255"
},
{
"211.23.0.0",
"211.23.255.255"
},
{
"61.216.0.0",
"61.219.255.255"
},
{
"61.220.0.0",
"61.227.255.255"
},
{
"61.228.0.0",
"61.231.255.255"
},
{
"218.160.0.0",
"218.165.255.255"
}
}
pg.IPAddress.Ctor = function (slot0)
slot0:ConvertIPRange()
slot0.requestUrl = slot0
if not Application.isEditor then
VersionMgr.Inst:WebRequest(slot0.requestUrl, function (slot0, slot1)
slot0.exportIP = slot1
slot0.isSpecialIP = slot0:CheckExportIP()
end)
end
end
pg.IPAddress.IsIPString = function (slot0, slot1)
if type(slot1) ~= "string" then
return false
end
if string.len(slot1) < 7 or slot2 > 15 then
return false
end
slot3 = string.find(slot1, "%p", 1)
slot4 = 0
while slot3 ~= nil do
if string.sub(slot1, slot3, slot3) ~= "." then
return false
end
slot3 = string.find(slot1, "%p", slot3 + 1)
if slot4 + 1 > 3 then
return false
end
end
if slot4 ~= 3 then
return false
end
slot5 = {}
for slot9 in string.gmatch(slot1, "%d+") do
slot5[#slot5 + 1] = slot9
if tonumber(slot9) == nil or slot10 > 255 then
return false
end
end
if #slot5 ~= 4 then
return false
end
return true
end
pg.IPAddress.IP2Int = function (slot0, slot1)
slot2 = 0
slot3, slot4, slot5, slot6 = slot1:match("(%d+)%.(%d+)%.(%d+)%.(%d+)")
return 16777216 * slot3 + 65536 * slot4 + 256 * slot5 + slot6
end
pg.IPAddress.ConvertIPRange = function (slot0)
slot0.IPRangeIntList = {}
for slot4, slot5 in ipairs(slot0) do
table.insert(slot6, slot7)
table.insert(slot6, slot8)
table.insert(slot0.IPRangeIntList, {})
end
end
pg.IPAddress.CheckExportIP = function (slot0)
if not slot0.exportIP or not slot0:IsIPString(slot0.exportIP) then
return false
end
slot1 = slot0:IP2Int(slot0.exportIP)
for slot5, slot6 in ipairs(slot0.IPRangeIntList) do
if slot6[1] <= slot1 and slot1 <= slot6[2] then
return true
end
end
return false
end
pg.IPAddress.GetExportIPString = function (slot0)
return slot0.exportIP
end
pg.IPAddress.GetLocalIP = function (slot0)
slot0.localIP = ReflectionHelp.RefGetProperty(typeof("UnityEngine.NetworkPlayer"), "ipAddress", ReflectionHelp.RefGetProperty(typeof("UnityEngine.Network"), "player"))
return slot0.localIP
end
pg.IPAddress.IsSpecialIP = function (slot0)
return slot0.isSpecialIP
end
return
|
-- Wolfe Labs Dual Universe Screen Library
-- Project: DU-Screens
-- Author: Matheus Pratta (DU: Wolfram)
---------------------------------
-- class: ListVertical
---------------------------------
local Element = require('Element')
local Container = require('Container')
local Class = require('@wolfe-labs/Core:Class')
local Table = require('@wolfe-labs/Core:Table')
local Utils = require('@wolfe-labs/Core:Utils')
-- Create the class definition
local ListVertical = {}
-- Class constructor
function ListVertical:__constructor (parent)
-- Initializes the base instance
self:__init(parent)
-- List of data to be rendered
self.__data = {}
-- Current page being rendered
self.page = 1
-- Keep track of individual elements visible
self.elements = {}
end
-- Default entry when none is set
function ListVertical:getBaseElement (data)
if self.baseElement then
return self.baseElement(data, self)
else
return Element.new(self)
end
end
-- Sets the element used for looping and caches stuff for sizing
function ListVertical:setBaseElement (fn)
-- Sanity check if the function is valid
if not type(fn) == 'function' then
return error('Entry must be a function returning a valid ScreenElement object')
end
-- Sets the baseElement to this function
self.baseElement = fn
-- Creates empty entry and caches stuff
local _ = self:getBaseElement(nil)
self.__szEntry = _.height + _.spacing
self.__szPage = (function (c)
-- Inner space, add the extra spacing because the last element never has spacing
local iS = _.spacing + (100 - c.paddingY * 2)
-- Returns how many entries fit on that inner space
return math.floor(iS / c.__szEntry)
end)
_:destroy()
end
-- Refreshes the contents
function ListVertical:updateElements ()
-- Cleanup elements in rendered elements list
for k, v in pairs(self.elements) do
v:destroy()
end
-- Generates an empty elements table
self.elements = {}
-- Gets the first entry's index
local index = (self.page - 1) * self:getPageSize()
-- Loops data for current page
for _ = index + 1, index + self:getPageSize() do
-- If no data is found, stop
if not self.__data[_] then break end
-- Creates an element for this data entry
local element = self:getBaseElement(self.__data[_])
-- Adds to rendered elements list
table.insert(self.elements, element)
-- Sets position and size properly
element:position(self.paddingX, self.paddingY + self:getEntrySize() * ((_ - index) - 1))
element.width = 100 - self.paddingX * 2
end
end
-- Gets the element entry size
function ListVertical:getEntrySize ()
-- Returns cached entry size
return self.__szEntry
end
-- Gets the number of elements per page
function ListVertical:getPageSize ()
-- Gets the current size, excludes padding and divides by the element size
return self.__szPage(self)
end
-- Gets the number of elements per page
function ListVertical.getPageCount (self)
return math.ceil(Table.length(self.__data, true) / self:getPageSize())
end
-- Goes to prev page
function ListVertical.pagePrev (self)
-- Changes page number
self.page = math.max(self.page - 1, 1)
-- Refreshes content
self:updateElements()
end
-- Goes to next page
function ListVertical:pageNext ()
-- Changes page number
self.page = math.min(self.page + 1, self:getPageCount())
-- Refreshes content
self:updateElements()
end
-- Sets data
function ListVertical:data (value)
-- Replaces data if that's the case, will be unkeyed
if value then
self.__data = Table.values(value)
end
-- Refreshes content
self:updateElements()
-- Returns the data
return self.__data
end
-- Creates the actual Class, inherits Container
return Class.new('ListVertical', ListVertical, Container) |
return {
no_consumer = false, -- this plugin is available on APIs as well as on Consumers,
fields = {
routingkey = { required = true, type = "string" },
exchange = { default = "", type = "string" },
user = { default = "guest", type = "string" },
password = { default = "guest", type = "string" }
},
self_check = function(schema, plugin_t, dao, is_updating)
-- perform any custom verification
return true
end
}
|
workspace "singlelibs"
configurations { "debug", "release" }
newoption {
trigger = "notest",
description = "Autoruns the test after successful build"
}
project "test"
kind "ConsoleApp"
language "C"
targetdir "bin"
files {
"test.c",
"hashtable.h",
"mempool.h"
}
links "m"
filter "configurations:debug"
symbols "on"
optimize "off"
filter "configurations:release"
symbols "off"
optimize "on"
-- Run test
configuration "not notest"
postbuildcommands "./bin/test"
|
if IsValid(Sonus.Player.Panel) then
Sonus.Player.Panel:Remove()
end
Sonus.Player.Panel = vgui.Create("DFrame")
local Panel = Sonus.Player.Panel
Panel:SetSize(600,430)
Panel:SetPos(ScrW()/2 - 300,ScrH()/2 - 215)
Panel:SetMouseInputEnabled(true)
Panel:SetKeyBoardInputEnabled(false)
Panel:ShowCloseButton(true)
Panel:SetDeleteOnClose(false)
Panel:Hide()
Panel:SetTitle("Sonus")
Panel.lastToggled = SysTime()
concommand.Add("+sonus",function()
if Panel:IsVisible() then
Panel:Hide()
else
Panel:Show()
Panel:MakePopup()
Panel:SetMouseInputEnabled(true)
Panel:SetKeyBoardInputEnabled(false)
end
Panel.lastToggled = SysTime()
end)
concommand.Add("-sonus",function()
if (SysTime() - Panel.lastToggled) > 0.5 then
Panel:Hide()
end
end)
function Panel:Paint(w,h)
surface.SetDrawColor(Color(255,255,255,220))
surface.DrawRect(0,0,w,h)
surface.SetDrawColor(Color(105,155,155,220))
surface.DrawRect(0,0,w,25)
end
local Playlist = vgui.Create("DListView",Panel)
Playlist:SetPos(10,35)
Playlist:SetSize(380,305)
Playlist:SetMultiSelect(false)
Playlist:AddColumn("ID")
Playlist:AddColumn("Title")
Playlist:AddColumn("Artist")
function Playlist:DoDoubleClick(id,line)
Sonus.Player:Pause()
Sonus.Player:PlayID(id)
end
function Playlist:UpdateOrder()
self:Clear()
for i,track in pairs(Sonus.Player.Playlist) do
self:AddLine(i,track.title,track.artist)
end
self:SelectItem(self:GetLine(Sonus.Player.CurrentTrackID))
end
Sonus.Player.event:on("PlaylistUpdate",function()
Playlist:UpdateOrder()
end)
Sonus.Player.event:on("Playing",function()
Playlist:UpdateOrder()
end)
Playlist:UpdateOrder()
surface.CreateFont("NormalButtonFont",{
font = "Roboto",
extended = false,
size = 22,
weight = 500,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = false,
})
local AddURL = vgui.Create("DButton",Panel)
AddURL:SetFont("NormalButtonFont")
AddURL:SetColor(Color(255,255,255))
AddURL:SetText("Add from a URL")
AddURL:SetPos(410,35)
AddURL:SetSize(170,50)
function AddURL:Paint(w,h)
surface.SetDrawColor(Color(105,155,155,220))
surface.DrawRect(0,0,w,h)
end
function AddURL:DoClick()
Derma_StringRequest(
"Sonus URL Parser",
"Enter a valid URL to a soundcloud track or direct media file",
"",
function(url)
Sonus.Player:AutoAddURL(url)
end
)
end
local AddQuery = vgui.Create("DButton",Panel)
AddQuery:SetFont("NormalButtonFont")
AddQuery:SetColor(Color(255,255,255))
AddQuery:SetText("Add from a search")
AddQuery:SetPos(410,95)
AddQuery:SetSize(170,50)
function AddQuery:Paint(w,h)
surface.SetDrawColor(Color(105,155,155,220))
surface.DrawRect(0,0,w,h)
end
function AddQuery:DoClick()
Derma_StringRequest(
"Sonus URL Parser",
"Enter your query",
"",
function(query)
Sonus.Soundcloud.SearchTracks(query,function(data)
if data[1] then
Sonus.Player:AddTrack(Sonus.Soundcloud.AppendClientID(data[1].stream_url),data[1].title,data[1].user.username)
else
notification.AddLegacy("No tracks found!",NOTIFY_ERROR,5)
end
end)
end
)
end
local RemoveEntry = vgui.Create("DButton",Panel)
RemoveEntry:SetFont("NormalButtonFont")
RemoveEntry:SetColor(Color(255,255,255))
RemoveEntry:SetText("Delete track")
RemoveEntry:SetPos(410,215)
RemoveEntry:SetSize(170,50)
function RemoveEntry:Paint(w,h)
surface.SetDrawColor(Color(105,155,155,220))
surface.DrawRect(0,0,w,h)
end
function RemoveEntry:DoClick()
local idx = Playlist:GetSelectedLine()
Sonus.Player:RemoveTrack(idx)
end
local ShareTrack = vgui.Create("DButton",Panel)
ShareTrack:SetFont("NormalButtonFont")
ShareTrack:SetColor(Color(255,255,255))
ShareTrack:SetText("Share current track")
ShareTrack:SetPos(410,155)
ShareTrack:SetSize(170,50)
function ShareTrack:Paint(w,h)
surface.SetDrawColor(Color(105,155,155,220))
surface.DrawRect(0,0,w,h)
end
function ShareTrack:DoClick()
-- Derma_Message("Unimplemented.","Sonus","ok :'(")
local track = Sonus.Player.Playlist[#Sonus.Player.Playlist]
if track and IsValid(Sonus.Player.ActiveStation) then
local dialog = vgui.Create("DFrame")
dialog:SetPos(ScrW()/2-250,ScrH()/2-150)
dialog:SetSize(500,300)
dialog:MakePopup()
dialog.Paint = Panel.Paint
local Playerlist = vgui.Create("DListView",dialog)
Playerlist:SetPos(10,35)
Playerlist:SetSize(480,215)
Playerlist:AddColumn("Nickname")
local list = player.GetAll()
for i,ply in ipairs(list) do
Playerlist:AddLine(ply:Nick()).ply = ply
end
local Share = vgui.Create("DButton",dialog)
Share:SetFont("NormalButtonFont")
Share:SetColor(Color(255,255,255))
Share:SetText("Share")
Share:SetPos(10,260)
Share:SetSize(480,30)
function Share:Paint(w,h)
surface.SetDrawColor(Color(105,155,155,220))
surface.DrawRect(0,0,w,h)
end
function Share:DoClick()
for i,line in ipairs(Playerlist:GetSelected()) do
Sonus:ShareTrack(line.ply,track.url,CurTime() - Sonus.Player.ActiveStation:GetTime(),track.artist,track.title)
end
dialog:Remove()
end
else
notification.AddLegacy("No track is playing!",NOTIFY_ERROR,5)
end
end
local Visuals = vgui.Create("DButton",Panel)
Visuals:SetFont("NormalButtonFont")
Visuals:SetColor(Color(255,255,255))
Visuals:SetText("Visualiser")
Visuals:SetPos(410,275)
Visuals:SetSize(170,50)
function Visuals:Paint(w,h)
surface.SetDrawColor(Color(105,155,155,220))
surface.DrawRect(0,0,w,h)
end
function Visuals:DoClick()
Derma_Query(
"Pick a visualiser",
"Sonus VIS",
"None",
function()
Sonus.Player:SetActiveVisualiser("none")
end,
"Genesis",
function()
Sonus.Player:SetActiveVisualiser("genesis")
end
)
end
local AudioControl = vgui.Create("DPanel",Panel)
AudioControl:SetPos(0,350)
AudioControl:SetSize(600,80)
function AudioControl:Paint(w,h)
surface.SetDrawColor(Color(105,155,155,220))
surface.DrawRect(0,0,w,h)
end
local AudioMetadata = vgui.Create("DLabel",AudioControl)
AudioMetadata:SetPos(160,0)
AudioMetadata:SetSize(310,50)
AudioMetadata:SetFont("DermaLarge")
AudioMetadata:SetColor(Color(255,255,255))
function AudioMetadata:UpdateText()
if Sonus.Player.Metadata then
-- self:SetText(Sonus.Player.Metadata.Artist.." - "..Sonus.Player.Metadata.Title)
self:SetText(Sonus.Player.Metadata.Title or "Unknown title")
else
self:SetText("No tracks are playing.")
end
end
Sonus.Player.event:on("Playing",function()
AudioMetadata:UpdateText()
end)
AudioMetadata:UpdateText()
surface.CreateFont("TextButtonFont",{
font = "Roboto",
extended = false,
size = 64,
weight = 500,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = false,
})
local PrevButton = vgui.Create("DButton",AudioControl)
PrevButton:SetText("")
PrevButton:SetPos(0,0)
PrevButton:SetSize(50,50)
function PrevButton:Paint(w,h)
surface.SetDrawColor(Color(255,255,255,220))
surface.DrawRect(0,0,w,h)
draw.SimpleText("⏪","TextButtonFont",w/2,h/2-6,Color(0,0,0),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
end
function PrevButton:DoClick()
Sonus.Player:PreviousTrack()
end
local PlayButton = vgui.Create("DButton",AudioControl)
PlayButton:SetText("")
PlayButton:SetPos(50,0)
PlayButton:SetSize(50,50)
function PlayButton:Paint(w,h)
surface.SetDrawColor(Color(255,255,255,220))
surface.DrawRect(0,0,w,h)
if IsValid(Sonus.Player.ActiveStation) and Sonus.Player.ActiveStation:GetState() == GMOD_CHANNEL_PLAYING then
draw.SimpleText("⏸","TextButtonFont",w/2,h/2-10,Color(0,0,0),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
else
draw.SimpleText("▶","TextButtonFont",w/2,h/2,Color(0,0,0),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
end
end
function PlayButton:DoClick()
if IsValid(Sonus.Player.ActiveStation) then
if Sonus.Player.ActiveStation:GetState() == GMOD_CHANNEL_PLAYING then
Sonus.Player.ActiveStation:Pause()
else
Sonus.Player.ActiveStation:Play()
end
end
end
local NextButton = vgui.Create("DButton",AudioControl)
NextButton:SetText("")
NextButton:SetPos(100,0)
NextButton:SetSize(50,50)
function NextButton:Paint(w,h)
surface.SetDrawColor(Color(255,255,255,220))
surface.DrawRect(0,0,w,h)
draw.SimpleText("⏩","TextButtonFont",w/2,h/2-6,Color(0,0,0),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
end
function NextButton:DoClick()
Sonus.Player:NextTrack()
end
local VolumeSlider = vgui.Create("DNumSlider",AudioControl)
VolumeSlider:SetPos(480,10)
VolumeSlider:SetSize(120,30)
VolumeSlider.TextArea:SetTextColor(Color(255,255,255))
VolumeSlider.TextArea:SetText("100%")
-- VolumeSlider:SetDecimals(1)
VolumeSlider.Slider:SetImageColor(255,255,255)
function VolumeSlider:OnValueChanged(val)
self.TextArea:SetText(string.format("%02d%%",val*100))
if self:IsEditing() then
Sonus.Player:SetVolume(val)
end
end
function VolumeSlider:PerformLayout()
self.Label:SetWide(0)
end
VolumeSlider:SetValue(Sonus.Player:GetVolume())
Sonus.Player.event:on("VolumeUpdate",function(vol)
if not VolumeSlider:IsEditing() then
VolumeSlider:SetValue(Sonus.Player:GetVolume())
end
end)
local Scrub = vgui.Create("DNumSlider",AudioControl)
Scrub:SetPos(10,50)
Scrub:SetSize(580,30)
Scrub.TextArea:SetTextColor(Color(255,255,255))
Scrub.TextArea:SetText("0:00")
-- Scrub:SetDecimals(1)
Scrub.Slider:SetImageColor(255,255,255)
function Scrub:OnValueChanged(val)
self.TextArea:SetText(string.format("%d:%02d",val/60,val%60))
if IsValid(Sonus.Player.ActiveStation) and self:IsEditing() then
Sonus.Player.ActiveStation:SetTime(val)
end
end
function Scrub:PerformLayout()
self.Label:SetWide(0)
end
timer.Create("sonus.updateUISlider",0.1,0,function()
if IsValid(Sonus.Player.ActiveStation) and not Scrub:IsEditing() then
local len = Sonus.Player.ActiveStation:GetLength()
if len ~= Scrub:GetMax() then
Scrub:SetMax(len)
end
Scrub:SetValue(Sonus.Player.ActiveStation:GetTime())
end
end)
|
local common = require "unbox/common"
local Contact = require "unbox/Contact"
local Body = {}
Body.__index = Body
function Body.new(args)
local body = setmetatable({}, Body)
body:init(args or {})
return body
end
function Body:init(args)
self.dynamic = false
self.x, self.y = args.x or 0, args.y or 0
self.width, self.height = args.width or 1, args.height or 1
self.velocityX, self.velocityY = args.velocityX or 0, args.velocityY or 0
self.gravityX, self.gravityY = args.gravityX or 0, args.gravityY or 0
self.contacts = {}
self.world = assert(args.world)
self.world.bodies[self] = true
self:updateBounds()
self:initCellBounds()
self:addToCells()
self:setDynamic(args.dynamic or false)
self:setDirty(true)
end
function Body:destroy()
self:removeFromCells()
self:setDynamic(false)
self:setDirty(false)
self.world.bodies[self] = nil
self.world = nil
end
function Body:isDynamic()
return self.dynamic
end
function Body:setDynamic(dynamic)
if dynamic ~= self.dynamic then
if self.dynamic then
self.world.dynamicBodies[self] = nil
end
self.dynamic = dynamic
if self.dynamic then
self.world.dynamicBodies[self] = true
end
end
end
function Body:isDirty()
return self.dirty
end
function Body:setDirty(dirty)
if dirty ~= self.dirty then
if self.dirty then
self.world.dirtyBodies[self] = nil
end
self.dirty = dirty
if self.dirty then
self.world.dirtyBodies[self] = true
end
end
end
function Body:getPosition()
return self.x, self.y
end
function Body:setPosition(x, y)
self.x, self.y = x, y
self:updateBounds()
self:setDirty(true)
end
function Body:getDimensions()
return self.width, self.height
end
function Body:setDimensions(width, height)
self.width, self.height = width, height
self:updateBounds()
self:setDirty(true)
end
function Body:getVelocity()
return self.velocityX, self.velocityY
end
function Body:setVelocity(velocityX, velocityY)
self.velocityX, self.velocityY = velocityX, velocityY
end
function Body:getContacts()
return self.contacts
end
function Body:update(dt)
local gravityX = self.gravityX + self.world.gravityX
local gravityY = self.gravityY + self.world.gravityY
self.x = self.x + self.velocityX * dt + 0.5 * gravityX * dt * dt
self.y = self.y + self.velocityY * dt + 0.5 * gravityY * dt * dt
self.velocityX = self.velocityX + gravityX * dt
self.velocityY = self.velocityY + gravityY * dt
self:updateBounds()
self:setDirty(true)
end
function Body:updateBounds()
self.x1, self.y1 = self.x - 0.5 * self.width, self.y - 0.5 * self.height
self.x2, self.y2 = self.x + 0.5 * self.width, self.y + 0.5 * self.height
end
function Body:initCellBounds()
self.cellX1, self.cellY1 = self.world:getCellIndices(self.x1, self.y1)
self.cellX2, self.cellY2 = self.world:getCellIndices(self.x2, self.y2)
end
function Body:updateCellBounds()
local cellX1, cellY1 = self.world:getCellIndices(self.x1, self.y1)
local cellX2, cellY2 = self.world:getCellIndices(self.x2, self.y2)
self.cellX1 = common.clamp(self.cellX1, cellX1 - 1, cellX1)
self.cellY1 = common.clamp(self.cellY1, cellY1 - 1, cellY1)
self.cellX2 = common.clamp(self.cellX2, cellX2, cellX2 + 1)
self.cellY2 = common.clamp(self.cellY2, cellY2, cellY2 + 1)
end
function Body:addToCells()
for cellX = self.cellX1, self.cellX2 do
for cellY = self.cellY1, self.cellY2 do
self.world:addBodyToCell(self, cellX, cellY)
end
end
end
function Body:removeFromCells()
for cellX = self.cellX1, self.cellX2 do
for cellY = self.cellY1, self.cellY2 do
self.world:removeBodyFromCell(self, cellX, cellY)
end
end
end
function Body:updateContacts()
local cellX1, cellY1 = self.cellX1, self.cellY1
local cellX2, cellY2 = self.cellX2, self.cellY2
self:updateCellBounds()
if self.cellX1 ~= cellX1 or self.cellY1 ~= cellY1 or
self.cellX2 ~= cellX2 or self.cellY2 ~= cellY2 then
-- Remove body from old cells
for cellX = cellX1, cellX2 do
for cellY = cellY1, cellY2 do
if not (self.cellX1 <= cellX and cellX <= self.cellX2 and
self.cellY1 <= cellY and cellY <= self.cellY2) then
self.world:removeBodyFromCell(self, cellX, cellY)
end
end
end
-- Add body to new cells
for cellX = self.cellX1, self.cellX2 do
for cellY = self.cellY1, self.cellY2 do
if not (cellX1 <= cellX and cellX <= cellX2 and
cellY1 <= cellY and cellY <= cellY2) then
self.world:addBodyToCell(self, cellX, cellY)
end
end
end
end
end
function Body:intersects(body)
return self:intersectsBounds(body.x1, body.y1, body.x2, body.y2)
end
function Body:intersectsBounds(x1, y1, x2, y2)
return x1 < self.x2 and self.x1 < x2 and y1 < self.y2 and self.y1 < y2
end
function Body:intersectsBox(x, y, width, height)
return self:intersectsBounds(x - 0.5 * width, y - 0.5 * height,
x + 0.5 * width, y + 0.5 * height)
end
function Body:resolve(body)
if self:intersects(body) then
local distanceX1, distanceX2 = self.x2 - body.x1, body.x2 - self.x1
local distanceY1, distanceY2 = self.y2 - body.y1, body.y2 - self.y1
if math.min(distanceX1, distanceX2) <
math.min(distanceY1, distanceY2) then
if distanceX1 < distanceX2 then
self.x = self.x - distanceX1
self.velocityX = math.min(self.velocityX, body.velocityX)
else
self.x = self.x + distanceX2
self.velocityX = math.max(self.velocityX, body.velocityX)
end
else
if distanceY1 < distanceY2 then
self.y = self.y - distanceY1
self.velocityY = math.min(self.velocityY, body.velocityY)
else
self.y = self.y + distanceY2
self.velocityY = math.max(self.velocityY, body.velocityY)
end
end
self:updateBounds()
self:setDirty(true)
end
end
function Body:getDistance(body)
local distance, normalX, normalY, x1, y1, x2, y2
if self.x2 < body.x1 then
if self.y2 < body.y1 then
return self.x2, self.y2, body.x1, body.y1
elseif self.y1 < body.y2 then
local y = 0.5 * (math.max(self.y1, body.y1) + math.min(self.y2, body.y2))
return self.x2, y, body.x1, y
else
return self.x2, self.y1, body.x1, body.y2
end
elseif self.x1 < body.x2 then
if self.y2 < body.y1 then
elseif self.y1 < body.y2 then
else
end
else
if self.y2 < body.y1 then
return self.x1, self.y2, body.x2, body.y1
elseif self.y1 < body.y2 then
local y = 0.5 * (math.max(self.y1, body.y1) + math.min(self.y2, body.y2))
return self.x1, y, body.x2, y
else
return self.x1, self.y1, body.x2, body.y2
end
end
return distance, normalX, normalY, x1, y1, x2, y2
end
return Body
|
require 'ext'
local CSV = require 'csv'
print'reading hyg'
local hyg = CSV.file'../hyg/hygdata_v3.csv'
print'done reading hyg'
hyg:setColumnNames(hyg.rows:remove(1))
local num, con = ...
if not con then
con = num
num = nil
else
assert(tonumber(num), "couldn't parse number "..tostring(num))
end
assert(con, "exected [flamsteed#] [constellation-con] , or just the con")
local rows = table()
for _,row in ipairs(hyg.rows) do
if row.con == con then
if not num
or row.flam == num
then
rows:insert(row)
end
end
end
rows:sort(function(a,b)
return (tonumber(a.mag) or math.huge)
> (tonumber(b.mag) or math.huge)
end)
for _,row in ipairs(rows) do
print(tolua(table.mapi(hyg.columns, function(col)
local value = row[col]
if value ~= '' then
return row[col], col
end
end)))
end
print('found '..#rows..' rows')
--[[ maybe this is what 'findIndexForExoplanet' is now
local exoplanets = fromlua(file['../exoplanet/openExoplanetCatalog.lua'])
if namedStars then
local exoplanetSystemsMatched = 0
local starIndexForName = table.map(namedStars, function(name,index)
return index, name
end):setmetatable(nil)
for _,system in ipairs(exoplanets) do
local name = system.name
-- "14 Her" ... is where in the HYG database?
-- "24 Sex" ... HYG has 23 and 25, but not 24
-- "4 UMa"
-- "1RXS1609" ... ?
-- "WASP-*" ... ?
-- "2MASS *" ... ?
-- "2M *" ... ?
-- "TOI-*" ... ?
-- "YSES *" ... ?
for abbrev,name in pairs(constellationNamesForAbbrevs) do
name = name:gsub(name, abbrev)
end
-- off-spellings of the names:
name = name
:gsub('Aquarii', 'Aqr') -- Aquarius
:gsub('Cancri', 'Cnc') -- Cancer
:gsub('Coronae Borealis', 'CrB') -- Corona Borealis
:gsub('Cygni', 'Cyg') -- Cygnus
:gsub('Eridani', 'Eri') -- Eridanus
:gsub('Indi', 'Ind') -- Indus
:gsub('Leonis', 'Leo') -- Leo I think? and not LeoMinor?
:gsub('Serpentis', 'Ser') -- Serpens
:gsub('Ursae Minoris', 'UMi')
-- Greek letters
name = name
:gsub('Epsilon ', 'Eps ')
:gsub('eps ', 'Eps ')
:gsub('gamma ', 'Gam ')
:gsub('kappa ', 'Kap ')
:gsub('Omega ', 'Ome ')
:gsub('alf ', 'Alp ')
:gsub('eta ', 'Eta ')
:gsub('mu ', 'Mu ')
:gsub('nu ', 'Nu ')
:gsub('tau ', 'Tau ')
:gsub('xi ', 'Xi ')
:gsub('omi ', 'Omi ')
local index = starIndexForName[system.name]
if index then
exoplanetSystemsMatched = exoplanetSystemsMatched + 1
end
print(name, index)
end
print('matched '..exoplanetSystemsMatched..' of '..#exoplanets..' openExoplanetDatabase starsystems with HYG stars')
end
--]]
|
local awful = require("awful")
local gears = require("gears")
local beautiful = require("beautiful")
local xresources = require("beautiful.xresources")
local dpi = xresources.apply_dpi
local helpers = {}
function helpers.move_focus(c, direction)
if not c then
return
end
local layout = awful.layout.getname(awful.layout.get(awful.screen.focused()))
if layout == "max" then
if direction == "left" or direction == "down" then
awful.client.focus.byidx(-1)
else
awful.client.focus.byidx(1)
end
else
awful.client.focus.bydirection(direction)
end
if c.focus then
c.focus:raise()
end
end
local direction_translate = {
["up"] = "top",
["down"] = "bottom",
["left"] = "left",
["right"] = "right",
}
function helpers.move_to_edge(c, direction)
local old = c:geometry()
local new = awful.placement[direction_translate[direction]](
c,
{ honor_padding = true, honor_workarea = true, margins = beautiful.useless_gap * 2, pretend = true }
)
if direction == "up" or direction == "down" then
c:geometry({ x = old.x, y = new.y })
else
c:geometry({ x = new.x, y = old.y })
end
end
-- Resize DWIM (Do What I Mean)
-- Resize client or factor
-- Constants --
local floating_resize_amount = dpi(20)
local tiling_resize_factor = 0.05
---------------
function helpers.resize_dwim(c, direction)
if c and c.floating then
if direction == "up" then
c:relative_move(0, 0, 0, -floating_resize_amount)
elseif direction == "down" then
c:relative_move(0, 0, 0, floating_resize_amount)
elseif direction == "left" then
c:relative_move(0, 0, -floating_resize_amount, 0)
elseif direction == "right" then
c:relative_move(0, 0, floating_resize_amount, 0)
end
elseif awful.layout.get(mouse.screen) ~= awful.layout.suit.floating then
if direction == "up" then
awful.client.incwfact(-tiling_resize_factor)
elseif direction == "down" then
awful.client.incwfact(tiling_resize_factor)
elseif direction == "left" then
awful.tag.incmwfact(-tiling_resize_factor)
elseif direction == "right" then
awful.tag.incmwfact(tiling_resize_factor)
end
end
end
-- Move client DWIM (Do What I Mean)
-- Move to edge if the client / layout is floating
-- Swap by index if maximized
-- Else swap client by direction
function helpers.move_client_dwim(c, direction)
if c.floating or (awful.layout.get(mouse.screen) == awful.layout.suit.floating) then
helpers.move_to_edge(c, direction)
elseif awful.layout.get(mouse.screen) == awful.layout.suit.max then
if direction == "up" or direction == "left" then
awful.client.swap.byidx(-1, c)
elseif direction == "down" or direction == "right" then
awful.client.swap.byidx(1, c)
end
else
awful.client.swap.bydirection(direction, c, nil)
end
end
-- Tag back and forth:
-- If you try to focus the tag you are already at, go back to the previous tag.
-- Useful for quick switching after for example checking an incoming chat
-- message at tag 2 and coming back to your work at tag 1 with the same
-- keypress.
function helpers.tag_back_and_forth(tag_index)
local s = mouse.screen
local tag = s.tags[tag_index]
if tag then
if tag == s.selected_tag then
awful.tag.history.restore()
else
tag:view_only()
end
end
end
local double_tap_timer = nil
function helpers.single_double_tap(single_tap_function, double_tap_function)
if double_tap_timer then
double_tap_timer:stop()
double_tap_timer = nil
double_tap_function()
-- naughty.notify({text = "We got a double tap"})
return
end
double_tap_timer = gears.timer.start_new(0.20, function()
double_tap_timer = nil
-- naughty.notify({text = "We got a single tap"})
if single_tap_function then
single_tap_function()
end
return false
end)
end
-- Given a `match` condition, returns an array with clients that match it, or
-- just the first found client if `first_only` is true
function helpers.find_clients(match, first_only)
local matcher = function(c)
return awful.rules.match(c, match)
end
if first_only then
for c in awful.client.iterate(matcher) do
return c
end
else
local clients = {}
for c in awful.client.iterate(matcher) do
table.insert(clients, c)
end
return clients
end
return nil
end
-- Given a `match` condition, calls the specified function `f_do` on all the
-- clients that match it
function helpers.find_clients_and_do(match, f_do)
local matcher = function(c)
return awful.rules.match(c, match)
end
for c in awful.client.iterate(matcher) do
f_do(c)
end
end
function helpers.run_or_raise(match, move, spawn_cmd, spawn_args)
local matcher = function(c)
return awful.rules.match(c, match)
end
-- Find and raise
local found = false
for c in awful.client.iterate(matcher) do
found = true
c.minimized = false
if move then
c:move_to_tag(mouse.screen.selected_tag)
client.focus = c
else
c:jump_to()
end
break
end
-- Spawn if not found
if not found then
awful.spawn(spawn_cmd, spawn_args)
end
end
-- Run raise or minimize a client (scratchpad style)
-- Depends on helpers.run_or_raise
-- If it not running, spawn it
-- If it is running, focus it
-- If it is focused, minimize it
function helpers.scratchpad(match, spawn_cmd, spawn_args)
local cf = client.focus
if cf and awful.rules.match(cf, match) then
cf.minimized = true
else
helpers.run_or_raise(match, true, spawn_cmd, spawn_args)
end
end
function helpers.float_and_resize(c, width, height)
c.maximized = false
c.width = width
c.height = height
awful.placement.centered(c, { honor_workarea = true, honor_padding = true })
awful.client.property.set(c, "floating_geometry", c:geometry())
c.floating = true
c:raise()
end
-- Adds a maximized mask to a screen
function helpers.screen_mask(s, bg)
local mask = wibox({ visible = false, ontop = true, type = "splash", screen = s })
awful.placement.maximize(mask)
mask.bg = bg
return mask
end
-- Useful for periodically checking the output of a command that
-- requires internet access.
-- Ensures that `command` will be run EXACTLY once during the desired
-- `interval`, even if awesome restarts multiple times during this time.
-- Saves output in `output_file` and checks its last modification
-- time to determine whether to run the command again or not.
-- Passes the output of `command` to `callback` function.
function helpers.remote_watch(command, interval, output_file, callback)
local run_the_thing = function()
-- Pass output to callback AND write it to file
awful.spawn.easy_async_with_shell(command .. " | tee " .. output_file, function(out)
callback(out)
end)
end
local timer
timer = gears.timer({
timeout = interval,
call_now = true,
autostart = true,
single_shot = false,
callback = function()
awful.spawn.easy_async_with_shell("date -r " .. output_file .. " +%s", function(last_update, _, __, exitcode)
-- Probably the file does not exist yet (first time
-- running after reboot)
if exitcode == 1 then
run_the_thing()
return
end
local diff = os.time() - tonumber(last_update)
if diff >= interval then
run_the_thing()
else
-- Pass the date saved in the file since it is fresh enough
awful.spawn.easy_async_with_shell("cat " .. output_file, function(out)
callback(out)
end)
-- Schedule an update for when the remaining time to complete the interval passes
timer:stop()
gears.timer.start_new(interval - diff, function()
run_the_thing()
timer:again()
end)
end
end)
end,
})
end
-- The directory of the currently executed lua script
-- Requires the `debug` library to be available in the build of Lua that is running
function helpers.this_dir()
local str = debug.getinfo(2, "S").source:sub(2)
return str:match("(.*/)")
end
return helpers
|
local Blocks = require('builder.blocks')
local class = require('class')
local Message = require('message')
local Util = require('util')
local device = _G.device
local fs = _G.fs
local turtle = _G.turtle
local Builder = class()
Util.merge(Builder, {
isCommandComputer = not turtle,
loc = { },
index = 1,
mode = 'build',
})
local BUILDER_DIR = 'usr/builder'
local blockInfo = Blocks()
function Builder:getBlockCounts()
local blocks = { }
for k = self.index, #self.schematic.blocks do
local b = self.schematic.blocks[k]
local key = tostring(b.id) .. ':' .. b.dmg
local block = blocks[key]
if not block then
block = Util.shallowCopy(b)
block.qty = 0
block.need = 0
blocks[key] = block
end
block.need = block.need + 1
end
return blocks
end
function Builder:substituteBlocks(throttle)
for _,b in pairs(self.schematic.blocks) do
-- replace schematic block type with substitution
local pb = blockInfo:getPlaceableBlock(b.id, b.dmg)
Util.merge(b, pb)
b.odmg = pb.odmg or pb.dmg
local sub = self.subDB:get({ b.id, b.dmg })
if sub then
b.id, b.dmg = self.subDB:extract(sub)
end
throttle()
end
end
function Builder:reloadSchematic(throttle)
self.schematic:reload(throttle)
self:substituteBlocks(throttle)
end
function Builder:log(...)
Util.print(...)
end
function Builder:dumpInventory()
end
function Builder:logBlock(index, b)
local bdir = b.direction or ''
local logText = string.format('%d %s:%d (x:%d,z:%d:y:%d) %s',
index, b.id, b.dmg, b.x, b.z, b.y, bdir)
self:log(logText)
-- self:log(b.index) -- unique identifier of block
if device.wireless_modem then
Message.broadcast('builder', { x = b.x, y = b.y, z = b.z, heading = b.heading })
end
end
function Builder:saveProgress(index)
Util.writeTable(
fs.combine(BUILDER_DIR, self.schematic.filename .. '.progress'),
{ index = index, loc = self.loc }
)
end
function Builder:loadProgress(filename)
local progress = Util.readTable(fs.combine(BUILDER_DIR, filename))
if progress then
self.index = progress.index
if self.index > #self.schematic.blocks then
self.index = 1
end
self.loc = progress.loc or { }
end
end
return Builder
|
local event = require "event"
local network = require "network"
local component = require "component"
network.tcp.listen(22)
while true do
local evt = {event.pullFiltered(function(ev, action, ch, remote, port, inc)
if ev ~= "tcp" or action ~= "connection" or port ~= 22 or inc ~= "incoming" then
return false
end
return true
end)}
os.spawnp("/usr/sbin/sshsession.lua", nil, nil, nil, evt[3])
--os.spawn("/usr/sbin/sshsession.lua", evt[3])
end
|
ItemSelection = ItemSelection or class({})
function ItemSelection:Init()
Debug:EnableDebugging()
self:Reset()
self.loadedHeroes = {}
self.prisonLocation = Entities:FindByName(nil, "player_prison"):GetAbsOrigin()
self.abilitySelection = {}
CustomGameEventManager:RegisterListener('repeat_fight', partial(ItemSelection.RepeatFight, self))
CustomGameEventManager:RegisterListener('done_shopping', partial(ItemSelection.DoneShopping, self))
CustomGameEventManager:RegisterListener('reset', partial(ItemSelection.Reset, self))
end
function ItemSelection:ResetHeroes ()
local function killHero (playerID)
local hero = PlayerResource:GetSelectedHeroEntity(playerID)
if not hero then
return
end
hero:SetRespawnsDisabled(true)
hero:ClearLastHitMultikill()
hero:ClearLastHitStreak()
hero:ClearStreak()
PlayerResource:ClearKillsMatrix(playerID)
if hero:IsAlive() then
hero:Kill(nil, hero)
end
end
each(killHero, PlayerResource:GetAllTeamPlayerIDs())
GridNav:RegrowAllTrees()
GameRules:SetTimeOfDay(0.5)
end
function ItemSelection:Reset (playerID, keys)
self:ResetHeroes()
self.state = {
isSelecting = false,
radiant = {},
dire = {}
}
self.abilitySelection = {}
CustomNetTables:SetTableValue( 'hero_selection', 'items', self.state)
end
function ItemSelection:ChooseItems (selection)
Debug:EnableDebugging()
DebugPrint('Starting choose items flow!')
self.selection = selection
self.state = {
isSelecting = 'radiant',
radiant = {},
dire = {}
}
CustomNetTables:SetTableValue( 'hero_selection', 'items', self.state)
local index = #self.state.radiant + 1
self:EnableHero(self.selection.radiant[index])
end
function ItemSelection:DoneShopping (playerID, keys)
local player = PlayerResource:GetPlayer(self.selection.playerID)
local hero = PlayerResource:GetSelectedHeroEntity(self.selection.playerID)
local items = {}
-- Store items of current hero
for i = DOTA_ITEM_SLOT_1, DOTA_ITEM_SLOT_9 do
local item = hero:GetItemInSlot(i)
if item then
table.insert(items, item:GetName())
UTIL_Remove(item)
end
end
local skillTable = {}
for i = 0, 23 do
local ability = hero:GetAbilityByIndex(i)
if ability and ability:GetLevel() > 0 then
skillTable[ability:GetName()] = ability:GetLevel()
end
end
self:AssignAbilitySelectionToHero(hero:GetName(), skillTable)
if self.state.isSelecting == 'dire' then
table.insert(self.state.dire, items)
local index = #self.state.dire + 1
if index > self.selection.heroCount then
self.state.isSelecting = false
DebugPrint('All done calculating items!')
hero:SetRespawnsDisabled(true)
FindClearSpaceForUnit(hero, self.prisonLocation, true)
BotController:SetTeams(self.selection, self.state)
else
self:EnableHero(self.selection.dire[index])
end
end
if self.state.isSelecting == 'radiant' then
table.insert(self.state.radiant, items)
local index = #self.state.radiant + 1
if index > self.selection.heroCount then
self.state.isSelecting = 'dire'
self:EnableHero(self.selection.dire[1])
else
self:EnableHero(self.selection.radiant[index])
end
end
CustomNetTables:SetTableValue( 'hero_selection', 'items', self.state)
end
function ItemSelection:RepeatFight ()
self:ResetHeroes()
BotController:SetTeams(self.selection, self.state)
end
function ItemSelection:EnableHero (heroName)
DebugPrint('Replacing the hero so they can select items! ' .. heroName)
local oldHero = PlayerResource:GetSelectedHeroEntity(self.selection.playerID)
if oldHero then
for i = DOTA_ITEM_SLOT_1, DOTA_ITEM_SLOT_9 do
local item = oldHero:GetItemInSlot(i)
if item and not item:IsNull() then
oldHero:RemoveItem(item)
UTIL_Remove(item)
end
end
end
GameRules:SetUseUniversalShopMode(true)
HudTimer:SetGameTime(0)
self:CacheHeroForPlayer(heroName, self.selection.playerID, function (hero)
hero:RespawnHero(false, false)
local goldAmount = 1000
if self.selection.level >= 25 then
goldAmount = 20000
elseif self.selection.level >= 15 then
goldAmount = 10000
end
PlayerResource:SetGold(self.selection.playerID, goldAmount, true)
self:LevelUpHero(hero)
for i = DOTA_ITEM_SLOT_1, DOTA_ITEM_SLOT_9 do
local item = hero:GetItemInSlot(i)
if item and not item:IsNull() then
hero:RemoveItem(item)
end
end
BotController:Teleport(hero, 'radiant')
end)
end
function ItemSelection:CacheHeroForPlayer (heroName, playerID, cb)
if self.loadedHeroes[heroName] then
PlayerResource:ReplaceHeroWith(playerID, heroName, 0, 0)
local hero = PlayerResource:GetSelectedHeroEntity(playerID)
if hero:IsAlive() then
hero:Kill(nil, hero)
end
hero:SetRespawnsDisabled(true)
cb(hero)
return
end
PrecacheUnitByNameAsync(heroName, function()
self.loadedHeroes[heroName] = true
local player = PlayerResource:GetPlayer(playerID)
if player == nil then -- disconnected! don't give em a hero yet...
return
end
DebugPrint('Giving player ' .. playerID .. ' ' .. heroName)
PlayerResource:ReplaceHeroWith(playerID, heroName, 0, 0)
local hero = PlayerResource:GetSelectedHeroEntity(playerID)
if hero:IsAlive() then
hero:Kill(nil, hero)
end
hero:SetRespawnsDisabled(true)
cb(hero)
end)
end
function ItemSelection:LevelUpHero(hero)
if hero:GetLevel() >= self.selection.level then
return
end
hero:AddExperience(XP_PER_LEVEL_TABLE[self.selection.level], 0, false, false)
Timers:CreateTimer(0.1, function()
self:LevelUpHero(hero)
end)
end
function ItemSelection:AssignAbilitySelectionToHero( heroName, skillTable )
self.abilitySelection[heroName] = skillTable
end
function ItemSelection:GetAbilitySelectionForHero( heroName )
return self.abilitySelection[heroName]
end
|
-- The base Shader class.
Shader = Object:extend()
function Shader:init(vertex_name, fragment_name)
self.shader = love.graphics.newShader("assets/shaders/" .. (vertex_name or "default.vert"), "assets/shaders/" .. fragment_name)
end
-- Sets this shader as the active one.
function Shader:set()
current_shader = self
love.graphics.setShader(self.shader)
end
-- Unsets this shader as the active one.
function Shader:unset()
current_shader = nil
love.graphics.setShader()
end
-- Takes in a parameter and the data that corresponds to it and sends it to the shader.
-- shader:send('displacement_map', displacement_canvas)
function Shader:send(value, data)
if data:is(Canvas) then
self.shader:send(value, data.canvas)
elseif data:is(Image) then
self.shader:send(value, data.image)
else
self.shader:send(value, data)
end
end
|
local spawnedVehicles = {}
vehspawned = false
local matricula = {}
Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
while ESX.GetPlayerData().job == nil do
Citizen.Wait(10)
end
PlayerData = ESX.GetPlayerData()
DisablePlayerVehicleRewards(GetPlayerPed(-1))
end)
function SetVehicleMaxMods(vehicle)
local props = {
modEngine = 3,
modBrakes = 2,
modTransmission = 2,
modSuspension = 3,
modTurbo = true,
}
ESX.Game.SetVehicleProperties(vehicle, props)
end
function IsAVeh()
local isAVeh = false
local playerPed = GetPlayerPed(-1)
for k,v in pairs(Config.Vehiculos) do
if IsVehicleModel(GetVehiclePedIsUsing(playerPed), v.model) then
isAVeh = true
break
end
end
return isAVeh
end
function IsAVeh2()
local isAVeh2 = false
local playerPed = GetPlayerPed(-1)
for i=1, #Config.Helicopteros, 1 do
if IsVehicleModel(GetVehiclePedIsUsing(playerPed), Config.Helicopteros[i]) then
isAVeh2 = true
break
end
end
return isAVeh2
end
function StoreNearbyVehicle(playerCoords)
ped = GetPlayerPed(-1)
vehicle = GetVehiclePedIsIn(ped, false)
ESX.Game.DeleteVehicle(vehicle)
end
function OpenVehicleSpawnerMenu(type, station, part, partNum)
if type == 'car' then
local playerCoords = GetEntityCoords(PlayerPedId())
PlayerData = ESX.GetPlayerData()
local elements = {
{label = _U('garage_storeditem'), action = 'garage'},
{label = _U('garage_storeitem'), action = 'store_garage'},
-- {label = _U('garage_buyitem'), action = 'buy_vehicle'}
}
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle', {
title = _U('garage_title'),
align = 'top-right',
elements = elements
}, function(data, menu)
if data.current.action == 'garage' then
local garaje = {}
for k,v in pairs(Config.Vehiculos) do
table.insert(garaje, {label = v.name, model = v.model})
end
ESX.UI.Menu.CloseAll()
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_garage', {
title = _U('garage_title'),
align = 'top-right',
elements = garaje
},
function(data2, menu2)
local foundSpawn, spawnPoint = GetAvailableVehicleSpawnPoint(station, part, partNum)
if vehspawned == false then
ESX.Game.SpawnVehicle(data2.current.model, spawnPoint.coords, spawnPoint.heading, function(vehicle)
SetVehicleMaxMods(vehicle)
platenum = math.random(10000, 99999)
SetVehicleNumberPlateText(vehicle, "EMS"..platenum)
vehspawned = true
SetVehicleFuelLevel(vehicle, 100.0)
matricula = "EMS"..platenum
TaskWarpPedIntoVehicle(GetPlayerPed(-1), vehicle, -1)
menu2.close()
end)
else
ESX.ShowNotification(_U('yatienesunofuera'))
menu2.close()
end
end,
function(data2, menu2)
menu2.close()
end
)
elseif data.current.action == 'store_garage' then
local playerPed = GetPlayerPed(-1)
if IsPedSittingInAnyVehicle(playerPed) and IsAVeh() then
matriculaactual = GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))
if matricula == matriculaactual then
StoreNearbyVehicle()
vehspawned = false
else
ESX.ShowNotification(_U('noestucoche'))
end
end
end
end, function(data, menu)
menu.close()
end)
elseif type == 'helicopter' then
local playerCoords = GetEntityCoords(PlayerPedId())
PlayerData = ESX.GetPlayerData()
local elements = {
{label = _U('garage_storeditem'), action = 'garage'},
{label = _U('garage_storeitem'), action = 'store_garage'},
-- {label = _U('garage_buyitem'), action = 'buy_vehicle'}
}
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle', {
title = _U('garage_title'),
align = 'top-right',
elements = elements
}, function(data, menu)
if data.current.action == 'garage' then
local garajeheli = {}
for i=1, #Config.Helicopteros, 1 do
table.insert(garajeheli, {label = GetLabelText(GetDisplayNameFromVehicleModel(Config.Helicopteros[i])), value = Config.Helicopteros[i]})
end
ESX.UI.Menu.CloseAll()
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_garage', {
title = _U('garage_title'),
align = 'top-right',
elements = garajeheli
},function(data2, menu2)
local foundSpawn, spawnPoint = GetAvailableVehicleSpawnPoint(station, part, partNum)
if vehspawned == false then
ESX.Game.SpawnVehicle(data2.current.value, spawnPoint.coords, spawnPoint.heading, function(vehicle)
platenum = math.random(10000, 99999)
SetVehicleNumberPlateText(vehicle, "LFP"..platenum)
vehspawned = true
matricula = "LFP"..platenum
TaskWarpPedIntoVehicle(GetPlayerPed(-1), vehicle, -1)
menu2.close()
end)
else
ESX.ShowNotification(_U('yatienesunofuera'))
menu2.close()
end
end,
function(data2, menu2)
menu2.close()
end
)
elseif data.current.action == 'store_garage' then
local playerPed = GetPlayerPed(-1)
if IsPedSittingInAnyVehicle(playerPed) and IsAVeh2() then
matriculaactual = GetVehicleNumberPlateText(GetVehiclePedIsIn(GetPlayerPed(-1), false))
if matricula == matriculaactual then
StoreNearbyVehicle()
vehspawned = false
else
ESX.ShowNotification(_U('noestucoche'))
end
end
end
end, function(data, menu)
menu.close()
end)
end
end
function IsAVeh()
local isAVeh = false
local playerPed = GetPlayerPed(-1)
for k,v in pairs(Config.Vehiculos) do
if IsVehicleModel(GetVehiclePedIsUsing(playerPed), v.model) then
isAVeh = true
break
end
end
return isAVeh
end
function IsAVeh2()
local isAVeh2 = false
local playerPed = GetPlayerPed(-1)
for i=1, #Config.Helicopteros, 1 do
if IsVehicleModel(GetVehiclePedIsUsing(playerPed), Config.Helicopteros[i]) then
isAVeh2 = true
break
end
end
return isAVeh2
end
function StoreNearbyVehicle(playerCoords)
ped = GetPlayerPed(-1)
vehicle = GetVehiclePedIsIn(ped, false)
ESX.Game.DeleteVehicle(vehicle)
end
function GetAvailableVehicleSpawnPoint(station, part, partNum)
local spawnPoints = Config.Hospitals[station][part][partNum].SpawnPoints
local found, foundSpawnPoint = false, nil
for i=1, #spawnPoints, 1 do
if ESX.Game.IsSpawnPointClear(spawnPoints[i].coords, spawnPoints[i].radius) then
found, foundSpawnPoint = true, spawnPoints[i]
break
end
end
if found then
return true, foundSpawnPoint
else
ESX.ShowNotification(_U('vehicle_blocked'))
return false
end
end
function OpenShopMenu(elements, restoreCoords, shopCoords)
local playerPed = PlayerPedId()
isInShopMenu = true
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_shop', {
title = _U('vehicleshop_title'),
align = 'top-right',
elements = elements
}, function(data, menu)
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_shop_confirm', {
title = _U('vehicleshop_confirm', data.current.name, data.current.price),
align = 'top-right',
elements = {
{label = _U('confirm_no'), value = 'no'},
{label = _U('confirm_yes'), value = 'yes'}
}}, function(data2, menu2)
if data2.current.value == 'yes' then
local newPlate = exports['esx_vehicleshop']:GeneratePlate()
local vehicle = GetVehiclePedIsIn(playerPed, false)
local props = ESX.Game.GetVehicleProperties(vehicle)
props.plate = newPlate
ESX.TriggerServerCallback('esx_policejob:buyJobVehicle', function (bought)
if bought then
ESX.ShowNotification(_U('vehicleshop_bought', data.current.name, ESX.Math.GroupDigits(data.current.price)))
isInShopMenu = false
ESX.UI.Menu.CloseAll()
DeleteSpawnedVehicles()
FreezeEntityPosition(playerPed, false)
SetEntityVisible(playerPed, true)
ESX.Game.Teleport(playerPed, restoreCoords)
else
ESX.ShowNotification(_U('vehicleshop_money'))
menu2.close()
end
end, props, data.current.type)
else
menu2.close()
end
end, function(data2, menu2)
menu2.close()
end)
end, function(data, menu)
isInShopMenu = false
ESX.UI.Menu.CloseAll()
DeleteSpawnedVehicles()
FreezeEntityPosition(playerPed, false)
SetEntityVisible(playerPed, true)
ESX.Game.Teleport(playerPed, restoreCoords)
end, function(data, menu)
DeleteSpawnedVehicles()
WaitForVehicleToLoad(data.current.model)
ESX.Game.SpawnLocalVehicle(data.current.model, shopCoords, 0.0, function(vehicle)
table.insert(spawnedVehicles, vehicle)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
FreezeEntityPosition(vehicle, true)
SetModelAsNoLongerNeeded(data.current.model)
if data.current.props then
ESX.Game.SetVehicleProperties(vehicle, data.current.props)
end
end)
end)
WaitForVehicleToLoad(elements[1].model)
ESX.Game.SpawnLocalVehicle(elements[1].model, shopCoords, 0.0, function(vehicle)
table.insert(spawnedVehicles, vehicle)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
FreezeEntityPosition(vehicle, true)
SetModelAsNoLongerNeeded(elements[1].model)
if elements[1].props then
ESX.Game.SetVehicleProperties(vehicle, elements[1].props)
end
end)
end
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if isInShopMenu then
DisableControlAction(0, 75, true) -- Disable exit vehicle
DisableControlAction(27, 75, true) -- Disable exit vehicle
else
Citizen.Wait(500)
end
end
end)
function DeleteSpawnedVehicles()
while #spawnedVehicles > 0 do
local vehicle = spawnedVehicles[1]
ESX.Game.DeleteVehicle(vehicle)
table.remove(spawnedVehicles, 1)
end
end
function WaitForVehicleToLoad(modelHash)
modelHash = (type(modelHash) == 'number' and modelHash or GetHashKey(modelHash))
if not HasModelLoaded(modelHash) then
RequestModel(modelHash)
BeginTextCommandBusyspinnerOn('STRING')
AddTextComponentSubstringPlayerName(_U('vehicleshop_awaiting_model'))
EndTextCommandBusyspinnerOn(4)
while not HasModelLoaded(modelHash) do
Citizen.Wait(0)
DisableAllControlActions(0)
end
BusyspinnerOff()
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.