content
stringlengths 5
1.05M
|
---|
--[[ Netherstorm -- Ever-Core the Punisher.lua
This script was written and is protected
by the GPL v2. This script was released
by BlackHer0 of the BLUA Scripting
Project. Please give proper accredidations
when re-releasing or sharing this script
with others in the emulation community.
~~End of License Agreement
-- BlackHer0, July, 29th, 2008. ]]
function Punisher_OnEnterCombat(Unit,Event)
Unit:RegisterEvent("Punisher_Explosion",1500,0)
Unit:RegisterEvent("Punisher_Suppression",3000,0)
end
function Punisher_Explosion(Unit,Event)
Unit:FullCastSpellOnTarget(33860,Unit:GetClosestPlayer())
end
function Punisher_Suppression(Unit,Event)
Unit:FullCastSpellOnTarget(35892,Unit:GetClosestPlayer())
end
function Punisher_OnLeaveCombat(Unit,Event)
Unit:RemoveEvents()
end
function Punisher_OnDied(Unit,Event)
Unit:RemoveEvents()
end
RegisterUnitEvent (18698, 1, "Punisher_OnEnterCombat")
RegisterUnitEvent (18698, 2, "Punisher_OnLeaveCombat")
RegisterUnitEvent (18698, 4, "Punisher_OnDied")
|
--[[
Project: SA-MP-API
Author: Tim4ukys
My url: vk.com/tim4ukys
]]
local sys = require 'SA-MP API.kernel'
sys.ffi.cdef[[
struct stInputBox {
void *pUnknown;
unsigned char bIsChatboxOpen;
unsigned char bIsMouseInChatbox;
unsigned char bMouseClick_related;
unsigned char unk;
unsigned int dwPosChatInput[2];
unsigned char unk2[263];
int iCursorPosition;
unsigned char unk3;
int iMarkedText_startPos;
unsigned char unk4[20];
int iMouseLeftButton;
}__attribute__((packed));
typedef void(__cdecl *CMDPROC)(char *);
struct stInputInfo {
void *pD3DDevice;
void *pDXUTDialog;
stInputBox *pDXUTEditBox;
CMDPROC pCMDs[144];
char szCMDNames[144][33];
int iCMDCount;
int iInputEnabled;
char szInputBuffer[129];
char szRecallBufffer[10][129];
char szCurrentBuffer[129];
int iCurrentRecall;
int iTotalRecalls;
CMDPROC pszDefaultCMD;
}__attribute__((packed));
]]
|
minetest.register_node("yatm_decor:mesh_dense", {
description = "Dense Mesh",
groups = {cracky = 1},
sounds = yatm.node_sounds:build("metal"),
tiles = {
"yatm_meshes_border.png",
"yatm_meshes_dense_mesh.png",
},
drawtype = "glasslike_framed",
place_param2 = 0,
paramtype = "light",
paramtype2 = "facedir",
})
minetest.register_node("yatm_decor:mesh_wide", {
description = "Wide Mesh",
groups = {cracky = 1},
sounds = yatm.node_sounds:build("metal"),
tiles = {
"yatm_meshes_border.png",
"yatm_meshes_wide_mesh.png",
},
drawtype = "glasslike_framed",
place_param2 = 0,
paramtype = "light",
paramtype2 = "facedir",
})
|
local CorePackages = game:GetService("CorePackages")
local CoreGui = game:GetService("CoreGui")
local Roact = require(CorePackages.Roact)
local RoactRodux = require(CorePackages.RoactRodux)
local t = require(CorePackages.Packages.t)
local UIBlox = require(CorePackages.UIBlox)
local InteractiveAlert = UIBlox.App.Dialog.Alert.InteractiveAlert
local ButtonType = UIBlox.App.Button.Enum.ButtonType
local RobloxGui = CoreGui:WaitForChild("RobloxGui")
local RobloxTranslator = require(RobloxGui.Modules.RobloxTranslator)
local Components = script.Parent.Parent
local AvatarEditorPrompts = Components.Parent
local HumanoidViewport = require(Components.HumanoidViewport)
local ItemsList = require(Components.ItemsList)
local SignalSaveAvatarPermissionDenied = require(AvatarEditorPrompts.Thunks.SignalSaveAvatarPermissionDenied)
local PerformSaveAvatar = require(AvatarEditorPrompts.Thunks.PerformSaveAvatar)
local GetConformedHumanoidDescription = require(AvatarEditorPrompts.GetConformedHumanoidDescription)
local Modules = AvatarEditorPrompts.Parent
local FFlagAESPromptsSupportGamepad = require(Modules.Flags.FFlagAESPromptsSupportGamepad)
local EngineFeatureAESConformToAvatarRules = game:GetEngineFeature("AESConformToAvatarRules")
local SCREEN_SIZE_PADDING = 30
local VIEWPORT_MAX_TOP_PADDING = 40
local VIEWPORT_SIDE_PADDING = 5
local ITEMS_LIST_WIDTH_PERCENT = 0.45
local HUMANOID_VIEWPORT_WIDTH_PERCENT = 0.55
local SaveAvatarPrompt = Roact.PureComponent:extend("SaveAvatarPrompt")
SaveAvatarPrompt.validateProps = t.strictInterface({
--State
gameName = t.string,
screenSize = t.Vector2,
humanoidDescription = t.instanceOf("HumanoidDescription"),
rigType = t.enum(Enum.HumanoidRigType),
--Dispatch
performSaveAvatar = t.callback,
signalSaveAvatarPermissionDenied = t.callback,
})
function SaveAvatarPrompt:init()
self.mounted = false
if EngineFeatureAESConformToAvatarRules then
self:setState({
conformedHumanoidDescription = nil,
getConformedDescriptionFailed = false,
itemListScrollable = false,
})
else
self:setState({
itemListScrollable = false,
})
end
self.middleContentRef = Roact.createRef()
self.contentSize, self.updateContentSize = Roact.createBinding(UDim2.new(1, 0, 0, 200))
self.onAlertSizeChanged = function(rbx)
local alertSize = rbx.AbsoluteSize
if not self.middleContentRef:getValue() then
return
end
local currentHeight = self.middleContentRef:getValue().AbsoluteSize.Y
local alertNoContentHeight = alertSize.Y - currentHeight
local maxAllowedContentHeight = self.props.screenSize.Y - (SCREEN_SIZE_PADDING * 2) - alertNoContentHeight
local halfWidth = self.middleContentRef:getValue().AbsoluteSize.X / 2
local viewportMaxSize = halfWidth - ( VIEWPORT_SIDE_PADDING * 2) + (VIEWPORT_MAX_TOP_PADDING * 2)
if maxAllowedContentHeight > viewportMaxSize then
maxAllowedContentHeight = viewportMaxSize
end
if currentHeight ~= maxAllowedContentHeight then
self.updateContentSize(UDim2.new(1, 0, 0, maxAllowedContentHeight))
end
end
self.itemListScrollableUpdated = function(itemListScrollable, currentListHeight)
if currentListHeight == self.contentSize:getValue().Y.Offset then
self:setState({
itemListScrollable = itemListScrollable,
})
end
end
if EngineFeatureAESConformToAvatarRules then
self.retryLoadDescription = function()
self:setState({
getConformedDescriptionFailed = false,
})
self:getConformedHumanoidDescription()
end
end
self.renderAlertMiddleContent = function()
local humanoidDescription = self.props.humanoidDescription
local loadingFailed = nil
if EngineFeatureAESConformToAvatarRules then
humanoidDescription = self.state.conformedHumanoidDescription
loadingFailed = self.state.getConformedDescriptionFailed
end
return Roact.createElement("Frame", {
BackgroundTransparency = 1,
Size = self.contentSize,
[Roact.Ref] = self.middleContentRef,
}, {
ItemsListFrame = Roact.createElement("Frame", {
BackgroundTransparency = 1,
Size = UDim2.fromScale(ITEMS_LIST_WIDTH_PERCENT, 1),
}, {
ItemsList = Roact.createElement(ItemsList, {
humanoidDescription = humanoidDescription,
retryLoadDescription = self.retryLoadDescription,
loadingFailed = loadingFailed,
itemListScrollableUpdated = self.itemListScrollableUpdated,
}),
}),
HumanoidViewportFrame = Roact.createElement("Frame", {
BackgroundTransparency = 1,
Size = UDim2.fromScale(HUMANOID_VIEWPORT_WIDTH_PERCENT, 1),
Position = UDim2.fromScale(ITEMS_LIST_WIDTH_PERCENT, 0),
LayoutOrder = 2,
}, {
UIPadding = Roact.createElement("UIPadding", {
PaddingLeft = UDim.new(0, VIEWPORT_SIDE_PADDING),
PaddingRight = UDim.new(0, VIEWPORT_SIDE_PADDING),
}),
HumanoidViewport = Roact.createElement(HumanoidViewport, {
humanoidDescription = humanoidDescription,
loadingFailed = loadingFailed,
retryLoadDescription = self.retryLoadDescription,
rigType = self.props.rigType,
}),
}),
UISizeConstraint = Roact.createElement("UISizeConstraint", {
MaxSize = self.contentMaxSize,
}),
})
end
end
function SaveAvatarPrompt:render()
return Roact.createElement(InteractiveAlert, {
title = RobloxTranslator:FormatByKey("CoreScripts.AvatarEditorPrompts.SaveAvatarPromptTitle"),
bodyText = RobloxTranslator:FormatByKey("CoreScripts.AvatarEditorPrompts.SaveAvatarPromptText", {
RBX_NAME = self.props.gameName,
}),
buttonStackInfo = {
buttons = {
{
props = {
onActivated = self.props.signalSaveAvatarPermissionDenied,
text = RobloxTranslator:FormatByKey("CoreScripts.AvatarEditorPrompts.SaveAvatarPromptNo"),
},
},
{
buttonType = ButtonType.PrimarySystem,
props = {
onActivated = self.props.performSaveAvatar,
text = RobloxTranslator:FormatByKey("CoreScripts.AvatarEditorPrompts.SaveAvatarPromptYes"),
},
},
},
},
position = UDim2.fromScale(0.5, 0.5),
screenSize = self.props.screenSize,
middleContent = self.renderAlertMiddleContent,
onAbsoluteSizeChanged = self.onAlertSizeChanged,
isMiddleContentFocusable = FFlagAESPromptsSupportGamepad and self.state.itemListScrollable,
})
end
function SaveAvatarPrompt:getConformedHumanoidDescription(humanoidDescription)
local includeDefaultClothing = true
GetConformedHumanoidDescription(humanoidDescription, includeDefaultClothing):andThen(function(conformedDescription)
if not self.mounted then
return
end
self:setState({
conformedHumanoidDescription = conformedDescription,
})
end, function(err)
if not self.mounted then
return
end
self:setState({
getConformedDescriptionFailed = true,
})
end)
end
function SaveAvatarPrompt:didMount()
self.mounted = true
if EngineFeatureAESConformToAvatarRules then
self:getConformedHumanoidDescription(self.props.humanoidDescription)
end
end
function SaveAvatarPrompt:willUpdate(nextProps, nextState)
if EngineFeatureAESConformToAvatarRules then
if nextProps.humanoidDescription ~= self.props.humanoidDescription then
self:setState({
conformedHumanoidDescription = Roact.None,
getConformedDescriptionFailed = false,
})
self:getConformedHumanoidDescription(nextProps.humanoidDescription)
end
end
end
function SaveAvatarPrompt:willUnmount()
self.mounted = false
end
local function mapStateToProps(state)
return {
gameName = state.gameName,
screenSize = state.screenSize,
humanoidDescription = state.promptInfo.humanoidDescription,
rigType = state.promptInfo.rigType,
}
end
local function mapDispatchToProps(dispatch)
return {
signalSaveAvatarPermissionDenied = function()
return dispatch(SignalSaveAvatarPermissionDenied)
end,
performSaveAvatar = function()
return dispatch(PerformSaveAvatar)
end,
}
end
return RoactRodux.UNSTABLE_connect2(mapStateToProps, mapDispatchToProps)(SaveAvatarPrompt)
|
LinkLuaModifier("modifier_hide_healthbar_when_damaged", "modifier_scripts/modifier_hide_healthbar_when_damaged.lua", LUA_MODIFIER_MOTION_NONE)
modifier_hide_healthbar_when_damaged = class({})
function modifier_hide_healthbar_when_damaged:CheckState()
if not IsServer() then return end
local state = { [MODIFIER_STATE_NO_HEALTH_BAR] = true }
if 0 < self:GetParent():GetHealthDeficit() then
state = { [MODIFIER_STATE_NO_HEALTH_BAR] = false }
end
return state
end
function modifier_hide_healthbar_when_damaged:IsHidden()
return true
end
|
---- Nano Guard v1.0.0
-- Check Password
function checkPassword()
term.setCursorPos(1,2)
textutils.slowPrint("Password:")
print(">")
term.setCursorPos(3,3)
term.setTextColor(colors.gray)
local input = read("#")
term.setTextColor(colors.white)
if input == "Lifeline" then
return true
else return false
end
end
-- Correct Password
function correct()
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.yellow)
term.write(os.getComputerLabel())
term.setTextColor(colors.orange)
term.write(" : ")
term.setTextColor(colors.yellow)
term.write(os.getComputerID())
term.setTextColor(colors.orange)
term.write(" : ")
term.setTextColor(colors.yellow)
local fuel = turtle.getFuelLevel()
term.write(fuel)
term.setTextColor(colors.white)
term.setCursorPos(1,2)
end
-- Execution
local backup = os.pullEvent
os.pullEvent = os.pullEventRaw
local w,h = term.getSize()
local loop = true
while loop do
term.clear()
term.setCursorPos(1,1)
term.setBackgroundColor(colors.orange)
local x = 0
repeat
term.write(" ")
x = x + 1
until x == w
term.setTextColor(colors.black)
term.setCursorPos(2,1)
term.write("NanoGuard v1.0.0")
term.setCursorPos(1,1)
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
local continue = checkPassword()
if continue == true then
loop = false
os.pullEvent = backup
break
elseif continue == false then
term.setCursorPos(3,3)
local x = 3
repeat
term.write(" ")
x = x + 1
until x == w
term.setCursorPos(3,3)
term.setTextColor(colors.red)
textutils.slowWrite("Incorrect")
term.setTextColor(colors.white)
sleep(2)
else
--os.pullEvent = os.pullEventRaw
--os.pullEventRaw("terminate")
os.shutdown()
end
term.clear()
end
correct()
|
#!/usr/bin/env tarantool
local fio = require('fio')
package.path = fio.abspath(debug.getinfo(1).source:match("@?(.*/)")
:gsub('/./', '/'):gsub('/+$', '')) .. '/../../?.lua' .. ';' .. package.path
local tap = require('tap')
local yaml = require('yaml')
local json = require('json')
local http = require('http.client').new()
local graphql = require('graphql')
local utils = require('graphql.utils')
local test_utils = require('test.test_utils')
local testdata = require('test.testdata.common_testdata')
box.cfg{background = false}
testdata.init_spaces()
-- upload test data
local meta = testdata.meta or testdata.get_test_metadata()
testdata.fill_test_data(box.space, meta)
-- acquire metadata
local metadata = testdata.get_test_metadata()
local schemas = metadata.schemas
local collections = metadata.collections
local service_fields = metadata.service_fields
local indexes = metadata.indexes
-- build accessor and graphql schemas
-- ----------------------------------
local gql_wrapper = graphql.new(utils.merge_tables({
schemas = schemas,
collections = collections,
service_fields = service_fields,
indexes = indexes,
accessor = 'space',
}, test_utils.test_conf_graphql_opts()))
local test = tap.test('server')
test:plan(6)
-- test server
test_utils.show_trace(function()
local res = gql_wrapper:start_server()
local exp_res_start = 'The GraphQL server started at http://127.0.0.1:8080'
test:is(res, exp_res_start, 'start_server')
local method = 'POST'
local url = "http://127.0.0.1:8080/graphql"
local request_data =
[[{"query":"query user_by_order($order_id: String)]] ..
[[{\n order_collection(order_id: $order_id) ]] ..
[[{\n order_id\n description\n }\n}",]] ..
[["variables":{"order_id": "order_id_1"},"operationName":"user_by_order"}]]
local _, response = pcall(function()
return http:request(method, url, request_data)
end)
local body = json.decode(response.body)
local exp_body_data = yaml.decode(([[
--- {'order_collection': [{'description': 'first order of Ivan', 'order_id': 'order_id_1'}]}
]]):strip())
test:is_deeply(body.data, exp_body_data, '1')
local res = gql_wrapper:stop_server()
local exp_res_stop = 'The GraphQL server stopped at http://127.0.0.1:8080'
test:is(res, exp_res_stop, 'stop_server')
-- add space formats and try default instance
box.space.order_collection:format({{name='order_id', type='string'},
{name='user_id', type='string'}, {name='description', type='string'}})
local res = graphql.start_server(nil, nil,
test_utils.test_conf_graphql_opts())
test:is(res, exp_res_start, 'start_server')
_, response = pcall(function()
return http:request(method, url, request_data)
end)
body = json.decode(response.body)
local exp_body_data = yaml.decode(([[
--- {'order_collection': [{'description': 'first order of Ivan', 'order_id': 'order_id_1'}]}
]]):strip())
test:is_deeply(body.data, exp_body_data, '2')
local res = graphql.stop_server()
test:is(res, exp_res_stop, 'stop_server')
end)
assert(test:check(), 'check plan')
testdata.drop_spaces()
os.exit()
|
----- INI-FILE -----
--------------------
VBU3 = {}
VBU3.name = "VBU3"
VBU3.Vane = "RTSI"
VBU3.enabled = false
VBU3.market = false
VBU3.brake=0.3
VBU3.trade_volume=2
VBU3.stop_steps=15
VBU3.maxloss=100
--------------------
SRU3 = {}
SRU3.name = "SRU3"
SRU3.Vane = "RTSI"
SRU3.enabled = false
SRU3.market = false
SRU3.brake=0.3
SRU3.trade_volume=1
SRU3.stop_steps=16
SRU3.maxloss=100
--------------------
LKU3 = {}
LKU3.name="LKU3"
LKU3.Vane="MICEXO&G"
LKU3.enabled = false
LKU3.market = true
LKU3.brake=0.3
LKU3.trade_volume=1
LKU3.stop_steps=19
LKU3.maxloss=180
--------------------
GZU3={}
GZU3.name="GZU3"
GZU3.Vane="MICEXO&G"
GZU3.enabled = false
GZU3.market=true
GZU3.brake=0.3
GZU3.trade_volume=1
GZU3.stop_steps=19
GZU3.maxloss=150
--------------------
RNU3={}
RNU3.name="RNU3"
RNU3.Vane="MICEXO&G"
RNU3.enabled = false
RNU3.market = true
RNU3.brake=0.3
RNU3.trade_volume=1
RNU3.stop_steps=22
RNU3.maxloss=200
--------------------
RIU3={}
RIU3.name="RIU3"
RIU3.Vane="RTSI"
RIU3.enabled = false
RIU3.market = false
RIU3.brake=0.3
RIU3.trade_volume=1
RIU3.stop_steps=19
RIU3.maxloss=400
--------------------
VTBR={}
VTBR.name="VTBR"
VTBR.Vane="VBU3"
VTBR.enabled = false
VTBR.market = true
VTBR.brake=0.3
VTBR.trade_volume=1
VTBR.stop_steps=17
VTBR.maxloss =10
--------------------
--------------------
Tickers = {VBU3,SRU3,LKU3,GZU3,RNU3,RIU3,VTBR}
toLog(log,"ini read")
toLog(log, Tickers)
|
ys = ys or {}
slot1 = ys.Battle.BattleDataFunction
slot2 = class("BattleSkillFireSupport", ys.Battle.BattleSkillEffect)
ys.Battle.BattleSkillFireSupport = slot2
slot2.__name = "BattleSkillFireSupport"
slot2.Ctor = function (slot0, slot1)
slot0.super.Ctor(slot0, slot1, lv)
slot0._weaponID = slot0._tempData.arg_list.weapon_id
slot0._supportTargetFilter = slot0._tempData.arg_list.supportTarget.targetChoice
slot0._supportTargetArgList = slot0._tempData.arg_list.supportTarget.arg_list
end
slot2.DoDataEffect = function (slot0, slot1, slot2)
if slot0._weapon == nil then
slot3 = nil
for slot7, slot8 in ipairs(slot0._supportTargetFilter) do
slot3 = slot0.Battle.BattleTargetChoise[slot8](slot1, slot0._supportTargetArgList, slot3)
end
slot4 = slot3[1]
slot0._weapon = slot0.Battle.BattleDataFunction.CreateWeaponUnit(slot0._weaponID, slot1)
if BATTLE_DEBUG and slot0._weapon:GetType() == slot0.Battle.BattleConst.EquipmentType.SCOUT then
slot0._weapon:GetATKAircraftList()
end
if slot4 then
slot0._weapon:SetStandHost(slot4)
end
slot1:DispatchEvent(slot0.Event.New(slot0.Battle.BattleUnitEvent.CREATE_TEMPORARY_WEAPON, slot5))
end
slot0._weapon.updateMovementInfo(slot4)
slot0._weapon:SingleFire(slot2, slot0._emitter, function ()
slot0._weapon:Clear()
end)
end
slot2.DoDataEffectWithoutTarget = function (slot0, slot1)
slot0:DoDataEffect(slot1)
end
slot2.Clear = function (slot0)
slot0.super.Clear(slot0)
if slot0._weapon and not slot0._weapon:GetHost():IsAlive() then
slot0._weapon:Clear()
end
end
slot2.Interrupt = function (slot0)
slot0.super.Interrupt(slot0)
if slot0._weapon then
slot0._weapon:Cease()
slot0._weapon:Clear()
end
end
slot2.GetDamageSum = function (slot0)
slot1 = 0
if not slot0._weapon then
slot1 = 0
elseif slot0._weapon:GetType() == slot0.Battle.BattleConst.EquipmentType.SCOUT then
for slot5, slot6 in ipairs(slot0._weapon:GetATKAircraftList()) do
for slot11, slot12 in ipairs(slot7) do
slot1 = slot1 + slot12:GetDamageSUM()
end
end
else
slot1 = slot0._weapon:GetDamageSUM()
end
return slot1
end
return
|
--*****************************************************************************
--* _______ __
--* |_ _| |--.----.---.-.--.--.--.-----.-----.
--* | | | | _| _ | | | | |__ --|
--* |___| |__|__|__| |___._|________|__|__|_____|
--* ______
--* | __ \.-----.--.--.-----.-----.-----.-----.
--* | <| -__| | | -__| | _ | -__|
--* |___|__||_____|\___/|_____|__|__|___ |_____|
--* |_____|
--*
--* @Author: [EaWX]Pox
--* @Date: 2020-12-30
--* @Project: Empire at War Expanded
--* @Filename: init.lua
--* @License: MIT
--*****************************************************************************
require("eawx-std/plugintargets")
require("eawx-plugins-gameobject-space/microjump/Microjump")
return {
target = PluginTargets.always(),
init = function(self, ctx)
return Microjump()
end
}
|
AntibodiesShared = {}
AntibodiesShared.__index = AntibodiesShared
-----------------------------------------------------
--CONST----------------------------------------------
-----------------------------------------------------
AntibodiesShared.version = "1.142"
AntibodiesShared.author = "lonegamedev.com"
AntibodiesShared.modName = "Antibodies"
AntibodiesShared.modId = "lgd_antibodies"
-----------------------------------------------------
--STATE----------------------------------------------
-----------------------------------------------------
AntibodiesShared.General = nil
AntibodiesShared.DamageEffects = nil
AntibodiesShared.MoodleEffects = nil
AntibodiesShared.TraitsEffects = nil
-----------------------------------------------------
--COMMON---------------------------------------------
-----------------------------------------------------
local function has_key(table,key)
return table[key] ~= nil
end
local function lerp(v0, v1, t)
return (1.0 - t) * v0 + t * v1
end
local function format_float(num)
return string.format("%.4f", num)
end
local function is_number(num)
if type(num) == "number" then
return true
else
return false
end
end
local function clamp(num, min, max)
return math.max(min, math.min(num, max))
end
local function deepcopy(val)
local val_copy
if type(val) == 'table' then
val_copy = {}
for k,v in pairs(val) do
val_copy[k] = deepcopy(v)
end
else
val_copy = val
end
return val_copy
end
-----------------------------------------------------
--OPTIONS--------------------------------------------
-----------------------------------------------------
local function hasOptions()
if not AntibodiesShared.General then return false end
if not AntibodiesShared.DamageEffects then return false end
if not AntibodiesShared.MoodleEffects then return false end
if not AntibodiesShared.TraitsEffects then return false end
return true
end
local function getOptionsPreset(preset)
--todo: add presets
return {
["General"] = {
["baseAntibodyGrowth"] = 1.6
},
["DamageEffects"] = {
["InfectedWound"] = -0.001
},
["MoodleEffects"] = {
["Bleeding"] = -0.1,
["Hypothermia"] = -0.1,
["Injured"] = 0.0,
["Thirst"] = -0.04,
["Hungry"] = -0.03,
["Sick"] = -0.02,
["HasACold"] = -0.02,
["Tired"] = -0.01,
["Endurance"] = -0.01,
["Pain"] = -0.01,
["Wet"] = -0.01,
["HeavyLoad"] = -0.01,
["Windchill"] = -0.01,
["Panic"] = -0.01,
["Stress"] = -0.01,
["Unhappy"] = -0.01,
["Bored"] = -0.01,
["Hyperthermia"] = 0.01,
["Drunk"] = 0.01,
["FoodEaten"] = 0.05,
["Dead"] = 0.0,
["Zombie"] = 0.0,
["Angry"] = 0.0,
},
["TraitsEffects"] = {
["Asthmatic"] = -0.01,
["Smoker"] = -0.01,
["Unfit"] = -0.02,
["Out of Shape"] = -0.01,
["Athletic"] = 0.01,
["SlowHealer"] = -0.01,
["FastHealer"] = 0.01,
["ProneToIllness"] = -0.01,
["Resilient"] = 0.01,
["Weak"] = -0.02,
["Feeble"] = -0.01,
["Strong"] = 0.01,
["Stout"] = 0.02,
["Emaciated"] = -0.02,
["Very Underweight"] = -0.01,
["Underweight"] = 0.005,
["Overweight"] = 0.005,
["Obese"] = -0.02
}
}
end
local function applyOptions(options)
if (type(options) ~= "table") then
return false
end
if(options["Antibodies"] ~= nil) then
if(options["Antibodies"]["version"] ~= AntibodiesShared.version) then
return false
end
else
return false
end
if(options["General"] ~= nil) then
for k,v in pairs(AntibodiesShared.General) do
if(options["General"][k] ~= nil) then
AntibodiesShared.General[k] = options["General"][k]
end
end
end
if(options["MoodleEffects"] ~= nil) then
for k,v in pairs(AntibodiesShared.MoodleEffects) do
if(options["MoodleEffects"][k] ~= nil) then
AntibodiesShared.MoodleEffects[k] = options["MoodleEffects"][k]
end
end
end
if(options["DamageEffects"] ~= nil) then
for k,v in pairs(AntibodiesShared.DamageEffects) do
if(options["DamageEffects"][k] ~= nil) then
AntibodiesShared.DamageEffects[k] = options["DamageEffects"][k]
end
end
end
if(options["TraitsEffects"] ~= nil) then
for k,v in pairs(AntibodiesShared.TraitsEffects) do
if(options["TraitsEffects"][k] ~= nil) then
AntibodiesShared.TraitsEffects[k] = options["TraitsEffects"][k]
end
end
end
return true
end
local function loadOptions()
local options = {}
local reader = getFileReader("antibodies_options.ini", false)
if not reader then
return false
end
local current_group = nil
while true do
local line = reader:readLine()
if not line then
reader:close()
break
end
line = line:trim()
if line ~= "" then
local k,v = line:match("^([^=%[]+)=([^=]+)$")
if k then
if not current_group then
else
k = k:trim()
options[current_group][k] = v:trim()
end
else
local group = line:match("^%[([^%[%]%%]+)%]$")
if group then
current_group = group:trim()
options[current_group] = {}
end
end
end
end
if(options["Antibodies"] ~= nil) then
if(options["Antibodies"]["version"] ~= nil) then
if(options["Antibodies"]["version"] == AntibodiesShared.version) then
return options
end
end
end
return false
end
local function saveHostOptions(options)
if isClient() then
sendClientCommand(getPlayer(), AntibodiesShared.modId, "saveOptions", options)
end
end
local function saveOptions(options)
if (type(options) ~= "table") then
return false
end
local writer = getFileWriter("antibodies_options.ini", true, false)
for id,group in pairs(options) do
writer:write("\r\n["..id.."]\r\n")
for k,v in pairs(group) do
writer:write(k..' = '..v.."\r\n")
end
end
writer:close();
return true
end
local function getCurrentOptions()
if not hasOptions() then
local default = getOptionsPreset()
AntibodiesShared.General = default["General"]
AntibodiesShared.DamageEffects = default["DamageEffects"]
AntibodiesShared.MoodleEffects = default["MoodleEffects"]
AntibodiesShared.TraitsEffects = default["TraitsEffects"]
applyOptions(loadOptions())
end
local options = {}
options["Antibodies"] = {}
options["Antibodies"]["version"] = AntibodiesShared.version
options["Antibodies"]["author"] = AntibodiesShared.author
options["Antibodies"]["modName"] = AntibodiesShared.modName
options["Antibodies"]["modId"] = AntibodiesShared.modId
options["General"] = deepcopy(AntibodiesShared.General)
options["MoodleEffects"] = deepcopy(AntibodiesShared.MoodleEffects)
options["DamageEffects"] = deepcopy(AntibodiesShared.DamageEffects)
options["TraitsEffects"] = deepcopy(AntibodiesShared.TraitsEffects)
return options
end
-----------------------------------------------------
--EXPORTS--------------------------------------------
-----------------------------------------------------
AntibodiesShared.has_key = has_key
AntibodiesShared.lerp = lerp
AntibodiesShared.format_float = format_float
AntibodiesShared.is_number = is_number
AntibodiesShared.clamp = clamp
AntibodiesShared.deepcopy = deepcopy
AntibodiesShared.hasOptions = hasOptions
AntibodiesShared.applyOptions = applyOptions
AntibodiesShared.getCurrentOptions = getCurrentOptions
AntibodiesShared.loadOptions = loadOptions
AntibodiesShared.saveOptions = saveOptions
AntibodiesShared.saveHostOptions = saveHostOptions
AntibodiesShared.getOptionsPreset = getOptionsPreset
return AntibodiesShared
|
--[[
author: Aussiemon
-----
Copyright 2019 Aussiemon
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-----
This mod censors common profanity in lobby messages.
--]]
local mod = get_mod("WatchYourProfanity")
-- ##########################################################
-- ################## Variables #############################
local ChatManager = ChatManager
local math = math
local string = string
-- ##########################################################
-- ################## Functions #############################
mod.censorify = function(self, chat_message, profanity_index)
if profanity_index > #self.profanity_list then
return chat_message
else
local profanity = self.profanity_list[profanity_index]
local censor = self.censor[math.min(math.ceil(string.len(profanity)/4.0), #self.censor)]
return self:censorify(string.gsub(chat_message, profanity, censor), profanity_index + 1)
end
end
-- ##########################################################
-- #################### Hooks ###############################
mod:hook("ChatManager", "send_chat_message", function (func, self, channel_id, local_player_id, message, ...)
-- Censor profanity
message = mod:censorify(message, 1, 1)
-- Original function
local result = func(self, channel_id, local_player_id, message, ...)
return result
end)
mod:hook("ChatManager", "rpc_chat_message", function (func, self, sender, channel_id, message_sender, local_player_id, message, ...)
-- Censor profanity
message = mod:censorify(message, 1, 1)
-- Original function
local result = func(self, sender, channel_id, message_sender, local_player_id, message, ...)
return result
end)
-- ##########################################################
-- ################### Callback #############################
-- ##########################################################
-- ################### Script ###############################
-- ##########################################################
|
object_intangible_pet_nerf_hue = object_intangible_pet_shared_nerf_hue:new {
}
ObjectTemplates:addTemplate(object_intangible_pet_nerf_hue, "object/intangible/pet/nerf_hue.iff")
|
local Com = require "meiru.com.com"
local Cookie = require "meiru.util.cookie"
----------------------------------------------
--ComCookie
----------------------------------------------
local ComCookie = class("ComCookie", Com)
function ComCookie:ctor()
end
function ComCookie:match(req, res)
if not req.cookies then
local req_cookie = req.get('cookie')
if not req_cookie then
req.cookies = {}
req.signcookies = {}
else
local session_secret = req.app.get("session_secret") or "meiru"
local cookies, signcookies = Cookie.cookie_decode(req_cookie, session_secret)
req.cookies = cookies or {}
req.signcookies = signcookies or {}
end
end
end
return ComCookie
|
--[[
Carbon for Lua
#class Logging
#description {
Provides logging facilities.
}
]]
local Carbon = (...)
local Graphene = Carbon:GetGraphene()
local out = io.stdout
local eol = "\n"
if (Carbon.Support.windows) then
eol = "\r\n"
end
--[[
#property public @unumber ReportingLevel {
The level of messages to report. Messages are always outputted.
- 0 - Errors only
- 1 - Errors and warnings
- 2 - Errors, warnings, and notices
}
]]
local Logging = Graphene:MakeImportable {
ReportingLevel = 2,
OncedMessages = {},
OncedNotices = {},
OncedWarnings = {}
}
--[[#method {
class public Logging.SetOutputHandle(file handle)
required handle: The file handle to use for logging.t
Sets a new handle for outputting logs with.
}]]
function Logging.SetOutputHandle(handle)
out = handle
end
--[[#method {
class public Logging.Message(@string msg)
required msg: The message to send.
Reports a message to the log.
}]]
function Logging.Message(msg)
out:write("MESSAGE: ")
out:write(msg)
out:write(eol)
end
--[[#method {
class public Logging.MessageOnce(@string msg)
required msg: The message to send.
Reports a message to the log, once per message body.
}]]
function Logging.MessageOnce(msg)
if (Logging.OncedMessages[msg]) then
return
end
Logging.OncedMessages[msg] = true
Logging.Message(msg)
end
--[[#method {
class public Logging.Notice(@string msg)
required msg: The notice to send.
Reports a notice to the log if `ReportingLevel` >= 2.
}]]
function Logging.Notice(msg)
if (Logging.ReportingLevel >= 2) then
out:write("NOTICE: ")
out:write(msg)
out:write(eol)
end
end
--[[#method {
class public Logging.NoticeOnce(@string msg)
required msg: The notice to send.
Reports a notice to the log if `ReportingLevel` >= 2, once per message body.
}]]
function Logging.NoticeOnce(msg)
if (Logging.OncedNotices[msg]) then
return
end
Logging.OncedNotices[msg] = true
Logging.Notice(msg)
end
--[[#method {
class public Logging.Warn(@string msg)
required msg: The warning to send.
Reports a warning to the log if `ReportingLevel` >= 1.
}]]
function Logging.Warn(msg)
if (Logging.ReportingLevel >= 1) then
out:write("WARNING: ")
out:write(msg)
out:write(eol)
end
end
--[[#method {
class public Logging.WarnOnce(@string msg)
required msg: The warning to send.
Reports a warning to the log if `ReportingLevel` >= 1, once per message body.
}]]
function Logging.WarnOnce(msg)
if (Logging.OncedWarnings[msg]) then
return
end
Logging.OncedWarnings[msg] = true
Logging.Warn(msg)
end
--[[#method {
class public Logging.Warn(@string msg)
required msg: The error to send.
Reports an error to the log and throws an error.
}]]
function Logging.Err(msg)
out:write("ERROR: ")
out:write(msg)
out:write(eol)
error(msg, 2)
end
return Logging
|
--[[
__ __ _______ __ __ __ __ ________
/ \ / / / _____/ \ \ / / \ \ \ \ \ _____\
/ /\ \ / / / /____ \ \/ / \ \ \ \ \ \_____
/ / \ \ / / / _____/ / /\ \ \ \ \ \ \_____ \
/ / \ \/ / / /____ / / \ \ \ \__\ \ ____\ \
/_/ \__/ /______/ /_/ \_\ \______\ \______\
Nexus VR Character Model, by TheNexusAvenger
File: NexusVRCharacterModel.lua
Author: TheNexusAvenger
Date: March 11th 2018
KNOWN INCOMPATABILITIES:
- Animations can't be played (automatically stopped; messes up the joints)
- Changes to Motor6Ds may be overriden, mainly C0 and C1
- Velocities of parts on character will always read 0,0,0
- Forces on character will always read 0
- Characters do not interact with seats
- Tools may not work as expected due to full range of motion and Touched behavior with head anchored
]]
local NexusVRCharacter = script:WaitForChild("NexusVRCharacter")
local Configuration = script:WaitForChild("Configuration")
Configuration.Parent = NexusVRCharacter
for _,Player in pairs(game.Players:GetPlayers()) do
spawn(function()
local PlayerScripts = Player:FindFirstChild("PlayerScripts")
NexusVRCharacter:Clone().Parent = (PlayerScripts or Player:WaitForChild("PlayerGui",120))
end)
end
NexusVRCharacter.Parent = game:GetService("StarterPlayer"):WaitForChild("StarterPlayerScripts")
if game:GetService("Workspace").FilteringEnabled then
local Players = game:GetService("Players")
local UpdateCFramesForCharacter = Instance.new("RemoteEvent")
UpdateCFramesForCharacter.Name = "NexusVRCharacter_Replicator"
UpdateCFramesForCharacter.Parent = game:GetService("ReplicatedStorage")
UpdateCFramesForCharacter.OnServerEvent:Connect(function(Player,HeadCF,LeftControllerCF,RightControllerCF,LeftFootCF,RightFootCF)
if Player and HeadCF and LeftControllerCF and RightControllerCF and LeftFootCF and RightFootCF then
for _,OtherPlayer in pairs(Players:GetPlayers()) do
if OtherPlayer ~= Player then
UpdateCFramesForCharacter:FireClient(OtherPlayer,Player,HeadCF,LeftControllerCF,RightControllerCF,LeftFootCF,RightFootCF)
end
end
end
end)
end
|
-- This software is copyright Kong Inc. and its licensors.
-- Use of the software is subject to the agreement between your organization
-- and Kong Inc. If there is no such agreement, use is governed by and
-- subject to the terms of the Kong Master Software License Agreement found
-- at https://konghq.com/enterprisesoftwarelicense/.
-- [ END OF LICENSE 0867164ffc95e54f04670b5169c09574bdbd9bba ]
local ngx = ngx
local kong = kong
local EnableBuffering = {
PRIORITY = math.huge
}
function EnableBuffering:access()
kong.service.request.enable_buffering()
end
function EnableBuffering:header_filter(conf)
if conf.phase == "header_filter" then
if conf.mode == "modify-json" then
local body = assert(kong.service.response.get_body())
body.modified = true
return kong.response.exit(kong.response.get_status(), body, {
Modified = "yes",
})
end
if conf.mode == "md5-header" then
local body = kong.service.response.get_raw_body()
kong.response.set_header("MD5", ngx.md5(body))
end
end
end
return EnableBuffering
|
local M = { }
M.main = function()
return "m2"
end
return M
|
return function(...)
dofile("shell/cat.lua")(unpack(arg)) -- later when user interaction (hitting space) is available this code changes
end
|
--Copyright 2019 Control4 Corporation. All rights reserved.
--MERGE
function OnDriverInit ()
PASSTHROUGH_PROXY = 5001 -- set this to the proxy ID that should handle all passthrough commands from minidrivers
SWITCHER_PROXY = 5999 -- set this to the proxy ID of the SET_INPUT capable device that has the RF_MINI_APP connections (may be the same as PASSTHROUGH_PROXY)
USES_DEDICATED_SWITCHER = true -- set this to false if the driver did not need the dedicated avswitch proxy (e.g. this is a TV/receiver)
MINIAPP_BINDING_START = 3101 -- set this to the first binding ID in the XML for the RF_MINI_APP connections
MINIAPP_BINDING_END = 3125 -- set this to the last binding ID in the XML for the RF_MINI_APP connections
MINIAPP_TYPE = 'UM_ROKU' -- set this to your unique name as defined in the minidriver SERVICE_IDS table
end
--MERGE
function OnDriverLateInit ()
if (USES_DEDICATED_SWITCHER) then
HideProxyInAllRooms (SWITCHER_PROXY)
end
RegisterRooms ()
end
--MERGE
function OnSystemEvent (event)
local eventname = string.match (event, '.-name="(.-)"')
if (eventname == 'OnPIP') then
RegisterRooms ()
end
end
--MERGE
function OnWatchedVariableChanged (idDevice, idVariable, strValue)
if (RoomIDs and RoomIDs [idDevice]) then
local roomId = tonumber (idDevice)
if (idVariable == 1000) then
local deviceId = tonumber (strValue) or 0
RoomIDSources [roomId] = deviceId
end
end
end
--MERGE
function ReceivedFromProxy (idBinding, strCommand, tParams)
if (idBinding == nil or strCommand == nil) then
return -- this shouldn't happen, but is a good defensive programming practice
end
if (tParams == nil) then
tParams = {} -- this often happens, especially with basic transport commands. This protects against nil table referencing.
end
-- this test should be included before any other logic tests the value of idBinding; it is required for passthrough mode to work
if (idBinding == SWITCHER_PROXY and strCommand == 'PASSTHROUGH') then
idBinding = PASSTHROUGH_PROXY
strCommand = tParams.PASSTHROUGH_COMMAND
end
if (idBinding == SWITCHER_PROXY) then
if (strCommand == 'SET_INPUT') then
local input = tonumber (tParams.INPUT)
if (input >= MINIAPP_BINDING_START and input <= MINIAPP_BINDING_END) then
-- Get the device ID of the proxy handling the miniapp switch on this driver
local proxyDeviceId, _ = next (C4:GetBoundConsumerDevices (C4:GetDeviceID (), idBinding))
-- Get the device ID of the minidriver proxy connected to the requested input on this driver
local appProxyId = C4:GetBoundProviderDevice (proxyDeviceId, input)
-- Get the device ID of the minidriver protocol connected to the minidriver proxy
local appDeviceId = C4:GetBoundProviderDevice (appProxyId, 5001)
-- get the details for the app for this kind of universal-minidriver-compatible type
local appId = GetRelevantUniversalAppId (appDeviceId, MINIAPP_TYPE)
local appName = GetRelevantUniversalAppId (appDeviceId, 'APP_NAME')
-- there is now enough information to launch the application using the protocol for this device
-- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-- =-=-=-=-=-=-=-= YOUR DEVICE-SPECIFIC APP LAUNCHING CODE GOES HERE... -=-=-=-=-=-=-=
-- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-- there is now enough information to launch the application using the protocol for this device
if ((Properties ['Passthrough Mode'] or 'On') ~= 'On') then
local passthroughProxyDeviceId, _ = next (C4:GetBoundConsumerDevices (C4:GetDeviceID (), PASSTHROUGH_PROXY))
local _timer = function (timer)
print ('Looking for ' .. appProxyId)
for roomId, deviceId in pairs (RoomIDSources) do
if (deviceId == appProxyId) then
C4:SendToDevice (roomId, 'SELECT_VIDEO_DEVICE', {deviceid = passthroughProxyDeviceId})
end
end
end
C4:SetTimer (500, _timer)
end
end
end
end
end
--COPY
function GetRelevantUniversalAppId (deviceId, source)
local vars = C4:GetDeviceVariables (deviceId)
for _, var in pairs (vars) do
if (var.name == source) then
return (var.value)
end
end
if (source ~= 'APP_ID') then
-- try getting pre-universal minidriver app ID to launch.
return (GetRelevantUniversalAppId (deviceId, 'APP_ID'))
end
end
--COPY
function HideProxyInAllRooms (idBinding)
idBinding = idBinding or 0
if (idBinding == 0) then return end -- silently fail if no binding passed in
-- Get Bound Proxy's Device ID / Name.
local id, name = next (C4:GetBoundConsumerDevices (C4:GetDeviceID (), idBinding))
dbg ('Hiding ' .. name .. ' in all rooms')
-- Send hide command to all rooms, for 'ALL' Navigator groups.
for roomId, roomName in pairs (C4:GetDevicesByC4iName ('roomdevice.c4i') or {}) do
dbg ('Hiding ' .. name .. ' in ' .. roomName)
C4:SendToDevice (roomId, 'SET_DEVICE_HIDDEN_STATE', {PROXY_GROUP = 'ALL', DEVICE_ID = id, IS_HIDDEN = true})
end
end
--COPY
function RegisterRooms ()
RoomIDs = C4:GetDevicesByC4iName ('roomdevice.c4i')
RoomIDSources = {}
for roomId, _ in pairs (RoomIDs) do
RoomIDSources [roomId] = tonumber (C4:GetDeviceVariable (roomId, 1000)) or 0
C4:UnregisterVariableListener (roomId, 1000)
C4:RegisterVariableListener (roomId, 1000)
end
end
|
local L = Tetromino:extend()
function L:new(x, y)
L.super.new(self)
self.block_one = Block(x, y)
self.block_two = Block(x + block_size, y)
self.block_three = Block(x + (block_size * 2), y)
self.block_four = Block(x, y + block_size)
end
function L:up()
local success = L:rotateClockwise(L.block_two, L.block_one, L.block_three, L.block_four)
end
function L:update(dt)
end
function L:draw()
love.graphics.setColor(1.0, 0.509, 0.039)
L.super.draw(self)
end
return L
|
name = ""
description = ""
author = ""
version = ""
forumthread = ""
api_version = 10
dst_compatible = true
dont_starve_compatible = false
reign_of_giants_compatible = false
all_clients_require_mod = true
icon_atlas = "<NAME>.xml"
icon = "<NAME>_modicon.tex"
server_filter_tags =
{
"character",
}
configuration_options =
{
}
|
local path = ({reaper.get_action_context()})[2]:match('^.+[\\//]')
package.path = package.path .. ';' .. path .. '?.lua'
package.path = package.path .. ';' .. path .. 'ReaWrap/models/?.lua'
require('ReaWrap.models')
|
object_tangible_loot_mustafar_trophey_blistmok_skin = object_tangible_loot_mustafar_shared_trophey_blistmok_skin:new {
}
ObjectTemplates:addTemplate(object_tangible_loot_mustafar_trophey_blistmok_skin, "object/tangible/loot/mustafar/trophey_blistmok_skin.iff")
|
--
-- Created by IntelliJ IDEA.
-- User: ouyanyu
-- Date: 2016-04-14
-- Time: 17:58
-- To change this template use File | Settings | File Templates.
--
local lor = require("lor.index")
local dict_model = require("app.model.dict")
local dict_router = lor:Router()
local function save_new(arr,parent_value)
local return_arr = {}
for di,dv in pairs(arr) do
local result, err = dict_model:new(dv.name,dv.value,parent_value,di)
if not result or err then
table.insert(return_arr,{msg=dv.name,success=dv.value,i=di,p=parent_value})
end
end
return return_arr
end
-- 创建一条词典,创建最高层级的,parent_value可不传,name 和 value必须填写
dict_router:post("/create",function(req, res, next)
local sort = req.body.sort
local name = req.body.name
local value = req.body.value
local parent_value = req.body.parent_value
-- 参数不能为空,sort可以
if not value or not name or name == "" then
return res:json({
success = false,
msg = "参数不得为空."
})
end
if not parent_value then
parent_value = ""
end
-- 当sort为空,获取最大的
if not sort then
local result, err = dict_model:query_max_sort(parent_value)
if not result or err then
sort = 1
else
sort = result["sort"]+1
end
end
-- 查看是否存在,value不能重复
local result, err = dict_model:query_dict(parent_value,value)
local isExist = false
if result and not err then
isExist = true
end
if isExist == true then
return res:json({
success = false,
msg = "值已经被占用,请选用其他."
})
else
local result, err = dict_model:create(name, value, parent_value, sort)
if result and not err then
return res:json({
success = true,
msg = "添加成功."
})
else
return res:json({
success = false,
msg = "添加失败."
})
end
end
end)
-- new parent dict
dict_router:get("/newParent", function(req, res, next)
dict_array = {
{name='行业',value=10000},
{name='投资阶段',value=20000},
{name='投资领域',value=30000},
}
return_arr = {}
for di,dv in pairs(dict_array) do
local result, err = dict_model:new_parent(dv.name,dv.value,di)
if not result or err then
table.insert(return_arr,{msg=dv.name,success=dv.value})
end
end
return res:json(return_arr)
end)
-- new dict
dict_router:get("/:parant_value/new", function(req, res, next)
local parant_value = req.params.parant_value
local invest_arr = {{name='行业',value=10001},{name='投资',value=10002},{name='中介',value=10003},{name='金融',value=10004},{name='创业',value=10005},{name='实创',value=10006},{name='产业投资',value=10007},{name='媒体',value=10008},{name='其他',value=10009} }
local invest_stag_arr = {
{name='种子轮',value=20001},
{name='天使轮',value=20002},
{name='A轮',value=20003},
{name='B轮',value=20004},
{name='C轮',value=20005},
{name='D轮',value=20006},
{name='E轮',value=20007},
{name='F轮及以后',value=20008},
{name='并购',value=20009 },
{name='新三板挂牌',value=20010}
}
local invest_filed_arr = {
{name='电子商务',value=30001},
{name='O2O',value=30002},
{name='游戏',value=30003},
{name='旅游',value=30004},
{name='在线教育',value=30005},
{name='互联网金融',value=30006},
{name='互联网保险',value=30007},
{name='社交',value=30008},
{name='娱乐',value=30009 },
{name='医疗健康',value=30010},
{name='餐饮',value=30011},
{name='汽车交通',value=30012},
{name='企业服务',value=30013},
{name='B2B',value=30014},
{name='智能硬件',value=30015},
{name='通信及IT',value=30016},
{name='房产',value=30017},
{name='文化艺术',value=30018},
}
local return_arr = {}
if parant_value == "10000" then
return_arr = save_new(invest_arr,parant_value)
elseif parant_value == "20000" then
return_arr = save_new(invest_stag_arr,parant_value)
elseif parant_value == "30000" then
return_arr = save_new(invest_filed_arr,parant_value)
end
return res:json(return_arr)
end)
-- dict relation stop
return dict_router
|
-- _.flattenDeep.lua
--
-- Recursively flattens a nested array.
-- @usage _.print(_.flattenDeep({1, 2, {3, 4, {5, 6}}}))
-- --> {1, 2, 3, 4, 5, 6}
--
-- @param array The array to flatten.
-- @return Returns the new flattened array.
_.flattenDeep = function (array)
return _.flatten(array, true)
end
|
ys = ys or {}
ys.Battle.BattleBuffDeath = class("BattleBuffDeath", ys.Battle.BattleBuffEffect)
ys.Battle.BattleBuffDeath.__name = "BattleBuffDeath"
ys.Battle.BattleBuffDeath.Ctor = function (slot0, slot1)
slot0.super.Ctor(slot0, slot1)
end
ys.Battle.BattleBuffDeath.SetArgs = function (slot0, slot1, slot2)
if slot0._tempData.arg_list.time then
slot0._time = slot3.time + pg.TimeMgr.GetInstance():GetCombatTime()
end
slot0._maxX = slot3.maxX
slot0._minX = slot3.minX
slot0._maxY = slot3.maxY
slot0._minY = slot3.minY
slot0._countType = slot3.countType
end
ys.Battle.BattleBuffDeath.onUpdate = function (slot0, slot1, slot2, slot3)
if slot0._time and slot0._time < slot3 then
slot1:SetDeathReason(slot0.Battle.BattleConst.UnitDeathReason.DESTRUCT)
slot0:DoDead(slot1)
else
slot4 = slot1:GetPosition()
if slot0._maxX and slot0._maxX <= slot4.x then
slot1:SetDeathReason(slot0.Battle.BattleConst.UnitDeathReason.LEAVE)
slot0:DoDead(slot1)
elseif slot0._minX and slot4.x <= slot0._minX then
slot1:SetDeathReason(slot0.Battle.BattleConst.UnitDeathReason.LEAVE)
slot0:DoDead(slot1)
elseif slot0._maxY and slot0._maxY <= slot4.z then
slot1:SetDeathReason(slot0.Battle.BattleConst.UnitDeathReason.LEAVE)
slot0:DoDead(slot1)
elseif slot0._minY and slot4.z <= slot0._minY then
slot1:SetDeathReason(slot0.Battle.BattleConst.UnitDeathReason.LEAVE)
slot0:DoDead(slot1)
end
end
end
ys.Battle.BattleBuffDeath.onBattleBuffCount = function (slot0, slot1, slot2, slot3)
if slot3.countType == slot0._countType then
slot0:DoDead(slot1)
end
end
ys.Battle.BattleBuffDeath.DoDead = function (slot0, slot1)
slot1:SetCurrentHP(0)
slot1:DeadAction()
end
return
|
function nested_loops(n)
local x = 0;
local a = 0
while a<n do
local b = 0
while b<n do
local c = 0
while c<n do
local d = 0
while d<n do
local e = 0
while e<n do
local f = 0
while f<n do
x = x + 1
f = f + 1
end
e = e + 1
end
d = d + 1
end
c = c + 1
end
b = b + 1
end
a = a + 1
end
return x
end
print(nested_loops(20))
|
---------------------------------------------------------------------------------
--
-- @type TransformProxy
--
---------------------------------------------------------------------------------
local TransformProxy = Class( "TransformProxy" )
function TransformProxy:init()
self.proxy = MOAITransform.new()
end
---------------------------------------------------------------------------------
function TransformProxy:setTarget( target )
self.target = target
end
function TransformProxy:attachToTransform( trans )
self.proxy:setAttrLink ( MOAITransform.INHERIT_TRANSFORM, trans, MOAITransform.TRANSFORM_TRAIT )
end
function TransformProxy:syncFromTarget()
local target, proxy = self.target, self.proxy
target:forceUpdate()
proxy:forceUpdate()
self:onSyncFromTarget()
proxy:forceUpdate()
end
function TransformProxy:syncToTarget(
drx, dry, drz, ssx ,ssy, ssz,
updateTranslation, updateRotation, updateScale
)
local target, proxy = self.target, self.proxy
target:forceUpdate()
proxy:forceUpdate()
self:onSyncToTarget( drx, dry, drz, ssx ,ssy, ssz )
target:forceUpdate()
-- if updateTranslation then
-- mock.markProtoInstanceOverrided( target, 'loc' )
-- end
-- if updateRotation then
-- mock.markProtoInstanceOverrided( target, 'rot' )
-- end
-- if updateScale then
-- mock.markProtoInstanceOverrided( target, 'scl' )
-- end
end
-- function markProtoInstanceOverrided( obj, fid )
-- if not obj.__proto_history then return false end
-- local overridedFields = obj.__overrided_fields
-- if not overridedFields then
-- overridedFields = {}
-- obj.__overrided_fields = overridedFields
-- end
-- if not overridedFields[ fid ] then
-- overridedFields[ fid ] = true
-- return true
-- end
-- return false
-- end
function TransformProxy:onSyncToTarget( drx, dry, drz, ssx ,ssy, ssz )
local target, proxy = self.target, self.proxy
CTHelper.setWorldLoc( target:getProp(), proxy:getWorldLoc() )
-- target:getProp():setLoc( proxy:getLoc() ) WHy?
local sx, sy, sz = proxy:getScl()
local rx, ry, rz = proxy:getRot()
target:setScl( sx*ssx, sy*ssy, sz*ssz )
target:setRot( rx+drx, ry+dry, rz+drz )
end
function TransformProxy:onSyncFromTarget()
local target, proxy = self.target, self.proxy
CTHelper.setWorldLoc( proxy, target:modelToWorld( target:getPiv() ) )
-- proxy:setLoc( target:modelToWorld( target:getPiv() ) ) WHy?
proxy:setScl( target:getScl() )
proxy:setRot( target:getRot() )
end
---------------------------------------------------------------------------------
return TransformProxy
|
num_enemies = 1
boss_fight = false
experience=310
gold=150
function start()
addEnemy("Efreet", 40, 100)
end
function get_speech()
return nil
end
function get_item()
if (randint(2) == 0) then
return ITEM_ELIXIR
else
return -1
end
end
|
-- Script pour la gestion de l'émetteur IR à 38kHz (LED, infrared, infrarouge)
-- permet l'envoi d'un code (4bits seulement) avec le protocole zIR, protocole de mon invention ;-)
-- exprès pas standard afin de ne pas être parasité par les autres sources IR !
-- ATTENTION, on utilise ici l'astuce du gpio.serout pour faire la pulse de 26uS (38kHz),
-- car on n'arrive pas avec le gpio.write à faire une pulse plus courte que 400uS
print("\n ir_send.lua zf180918.1826 \n")
pin_ir_send = 7
gpio.mode(pin_ir_send,gpio.OUTPUT)
gpio.write(pin_ir_send,gpio.HIGH)
Mark_Coeff = 0.5
-- en mS/uS
Mark_Start = 3 *Mark_Coeff *1000
Mark_Bit1 = 2 *Mark_Coeff *1000
Mark_Bit0 = 1 *Mark_Coeff *1000
Mark_Space = 0.5 *Mark_Coeff *1000
-- envoi une série de pulses à 38kHz de durée zduration en uS
function pulse_ir(zduration)
-- print("pulse: "..zduration)
gpio.serout(pin_ir_send,gpio.LOW,{1,25},zduration/26)
end
-- attention, 4 bits seulement
function send_code_ir(zcode)
pulse_ir(Mark_Start)
print("Mark_Space:"..Mark_Space)
tmr.delay(Mark_Space)
for i=0, 3 do
if bit.isset(zcode,i) then
-- print("bit: "..i..",1")
pulse_ir(Mark_Bit1)
else
-- print("bit: "..i..",0")
pulse_ir(Mark_Bit0)
end
-- print("Mark_Space:"..Mark_Space)
tmr.delay(Mark_Space)
end
end
sendir_tmr1=tmr.create()
tmr.alarm(sendir_tmr1, 1000, tmr.ALARM_AUTO, function()
send_code_ir(0x05)
end)
|
local tag = "AFK"
afk = afk or {}
afk.AFKTime = CreateConVar("sv_afktimeout", "120", {FCVAR_ARCHIVE, FCVAR_REPLICATED, FCVAR_NOTIFY}, "Tempo pra ativar a HUD AFK de um jogador..")
local PLAYER = FindMetaTable("Player")
function PLAYER:IsAFK()
return GAMEMODE.Player:GetSharedGameVar(self, "afk", false) or self:GetNWBool("IsAFK", false)
end
function PLAYER:AFKTime()
return self.afkTime
end
function PLAYER:AFKTimeReal()
if not self.afkTime then return 0 end
return math.abs(math.max(CurTime() - self.afkTime, 0))
end
PLAYER.TotalAFKTime = PLAYER.AFKTimeReal
if SERVER then
util.AddNetworkString(tag)
net.Receive(tag, function(_, ply)
local is = net.ReadBool()
--if not is and ply.isAFK2 then return end
if ply.isAFK == is then return end
ply.isAFK = is
GAMEMODE.Player:SetSharedGameVar(ply, "afk", is)
ply:SetNWBool("IsAFK", is)
ply.afkTime = is and CurTime() - afk.AFKTime:GetInt() or nil
hook.Run("AFK", ply, is)
net.Start(tag)
net.WriteUInt(ply:EntIndex(), 8)
net.WriteBool(is)
net.Broadcast()
if is then
Msg(ply:Nick() .. " [ " .. ply:RealName() .. " ] is AFK.\n")
else
Msg(ply:Nick() .. " [ " .. ply:RealName() .. " ] is no longer AFK.\n")
end
end)
hook.Add("AFK", "AFKSound", function(ply, is)
ply:EmitSound(not is and "replay/cameracontrolmodeentered.wav" or "replay/cameracontrolmodeexited.wav")
end)
elseif CLIENT then
afk.Mouse = {
x = 0,
y = 0
}
afk.Focus = system.HasFocus()
afk.Is = false
afk.Network = true
hook.Add("Initialize", tag, function()
afk.Start = true
end)
local lastsent
local function Input()
if not afk.When or not afk.Start then return end
if lastsent and lastsent >= CurTime() then return end
lastsent = CurTime() + 5
afk.When = CurTime() + afk.AFKTime:GetInt()
if afk.Is and afk.Network then
chat.AddText(Color(100, 255, 100, 255), "Olá!", Color(50, 200, 50, 255), "!", Color(255, 255, 255, 255), " Você esteve afk por: ", Color(0, 2555, 78, 255), string.TimeFormated(_G.MYAFKTIME or 0), Color(100, 255, 100, 255), ".")
net.Start(tag)
net.WriteBool(false)
net.SendToServer()
end
--afk.Is = false
end
hook.Add("StartCommand", tag, function(ply, cmd)
if ply ~= LocalPlayer() or not afk.When or not afk.Start then return end
local mouseMoved = (system.HasFocus() and (afk.Mouse.x ~= gui.MouseX() or afk.Mouse.y ~= gui.MouseY()) or false)
if mouseMoved or cmd:GetMouseX() ~= 0 or cmd:GetMouseY() ~= 0 or cmd:GetButtons() ~= 0 or (afk.Focus == false and afk.Focus ~= system.HasFocus()) then
Input()
end
if afk.When < CurTime() and not afk.Is then
afk.Is = true
if afk.Network then
net.Start(tag)
net.WriteBool(true)
net.SendToServer()
end
end
end, -2)
hook.Add("KeyPress", tag, function()
if not IsFirstTimePredicted() then return end
Input()
end, -2)
hook.Add("KeyRelease", tag, function()
if not IsFirstTimePredicted() then return end
Input()
end, -2)
hook.Add("PlayerBindPress", tag, function()
if not IsFirstTimePredicted() then return end
Input()
end, -2)
local function getAFKtime()
return math.abs(math.max(CurTime() - afk.When, 0))
end
net.Receive(tag, function()
if not afk.Network then return end
local ply = Entity(net.ReadUInt(8))
local is = net.ReadBool()
if IsValid(ply) and ply == LocalPlayer() then
afk.Is = is
afk.When = is and CurTime() - afk.AFKTime:GetInt() or nil
else
ply.isAFK = is
ply.afkTime = is and CurTime() - afk.AFKTime:GetInt() or nil
end
hook.Run("AFK", ply, is)
end)
surface.CreateFont(tag, {
font = "Montserrat Bold",
size = 38,
italic = true,
weight = 800
})
surface.CreateFont(tag .. "Normal", {
font = "Montserrat Regular",
size = 48,
italic = false,
weight = 800
})
local function plural(num)
return ((num > 1 or num == 0) and "s" or "")
end
local function DrawTranslucentText(txt, x, y, a, col)
-- surface.SetTextPos(x + 2, y + 2)
-- surface.SetTextColor(Color(255,255,255) )
-- surface.DrawText(txt)
surface.SetTextPos(x, y)
if col then
surface.SetTextColor(Color(col.r, col.g, col.b, 255 ))
else
surface.SetTextColor(Color(255, 255, 255, 255) )
end
surface.DrawText(txt)
end
local a = 0
_G.MYAFKTIME = 0
afk.Draw = CreateConVar("cl_afk_hud_draw", "1", {FCVAR_ARCHIVE}, "Should we draw the AFK HUD?")
hook.Add("HUDPaint", tag, function()
if not afk.Draw:GetBool() then return end
if not afk.When then
afk.When = CurTime() + afk.AFKTime:GetInt()
end
afk.Focus = system.HasFocus()
if not afk.Is then
a = 0
return
end
a = math.Clamp(a + FrameTime() * 120, 0, 255)
local AFKTime = getAFKtime()
if AFKTime == 0 then return end
--[[
local h = math.floor(AFKTime / 60 / 60)
local m = math.floor(AFKTime / 60 - h * 60)
local s = math.floor(AFKTime - m * 60 - h * 60 * 60)
local timeString = ""
if h > 0 then
timeString = timeString .. h .. " hour" .. plural(h) .. ", "
end
if m > 0 then
timeString = timeString .. m .. " minute" .. plural(m) .. ", "
end
timeString = timeString .. s .. " second" .. plural(s)
]]
_G.MYAFKTIME = AFKTime
local timeString = string.TimeFormated(AFKTime)
surface.SetFont(tag)
local txt = "TEMPO AFK"
local txtW, txtH = surface.GetTextSize(txt)
surface.SetFont(tag .. "Normal")
local timeW, timeH = surface.GetTextSize(timeString)
local wH = txtH + timeH
surface.SetDrawColor(Color(0, 0, 0, 127 * (a / 255)))
-- draw.RoundedBox(cornerRadius, x, y, width, height, color)
draw.RoundedBox(8, ScrW()/2 - (txtW) , ScrH() * 0.5 * 0.5 - wH * 0.5 - txtH * 0.33, txtW*2, wH + txtH * 0.33 * 2 - 3, Color(26, 26, 26) )
-- surface.DrawRect(0, ScrH() * 0.5 * 0.5 - wH * 0.5 - txtH * 0.33, ScrW(), wH + txtH * 0.33 * 2 - 3)
surface.SetFont(tag)
DrawTranslucentText(txt, ScrW() / 2 - txtW / 2, ScrH() / 2 / 2 - wH / 2, a * 0.5)
surface.SetFont(tag .. "Normal")
DrawTranslucentText(timeString, ScrW() / 2 - timeW / 2, ScrH() / 2 / 2 - wH / 2 + txtH, a, Color(0,255,78))
end)
local afkrings_convar = CreateClientConVar("afkrings", "1")
-- Uncomment for development
local font_name = "afkrings_font" -- ..os.time()
local rt_name = "afkrings_rt" -- ..os.time()
surface.CreateFont(font_name, {
font = "Montserrat Bold",
size = 32,
weight = 800
})
--------------------------------------------------------------------------------
-- MESH GENERATORS --
--------------------------------------------------------------------------------
local function generate_mesh_cylinder(sides, radius, height, offset, angle, flip)
local offset = offset or Vector()
local angle = angle or Angle()
local points = {}
for i = 1, sides do
local normal = Vector(math.cos((i + 0.5) * (2 * math.pi / sides)), math.sin((i + 0.5) * (2 * math.pi / sides)), 0)
if flip then
normal = normal * -1
end
normal:Rotate(angle)
local l_u = (i - 1) / (sides / 5)
local r_u = (i) / (sides / 5)
points[#points + 1] = {
pos = Vector(math.cos(i * (2 * math.pi / sides)) * radius, math.sin(i * (2 * math.pi / sides)) * radius, 0),
normal = normal,
u = l_u,
v = 1
}
points[#points + 1] = {
pos = Vector(math.cos(i * (2 * math.pi / sides)) * radius, math.sin(i * (2 * math.pi / sides)) * radius, height),
normal = normal,
u = l_u,
v = 0
}
points[#points + 1] = {
pos = Vector(math.cos((i + 1) * (2 * math.pi / sides)) * radius, math.sin((i + 1) * (2 * math.pi / sides)) * radius, height),
normal = normal,
u = r_u,
v = 0
}
points[#points + 1] = {
pos = Vector(math.cos((i + 1) * (2 * math.pi / sides)) * radius, math.sin((i + 1) * (2 * math.pi / sides)) * radius, height),
normal = normal,
u = r_u,
v = 0
}
points[#points + 1] = {
pos = Vector(math.cos((i + 1) * (2 * math.pi / sides)) * radius, math.sin((i + 1) * (2 * math.pi / sides)) * radius, 0),
normal = normal,
u = r_u,
v = 1
}
points[#points + 1] = {
pos = Vector(math.cos(i * (2 * math.pi / sides)) * radius, math.sin(i * (2 * math.pi / sides)) * radius, 0),
normal = normal,
u = l_u,
v = 1
}
end
for k, v in pairs(points) do
v.pos:Rotate(angle)
v.pos = v.pos + offset
end
if flip then
local tmp = points
points = {}
for i = #tmp, 1, -1 do
points[#points + 1] = tmp[i]
end
end
return points
end
local function generate_mesh_hollow_circle(sides, radius_inner, radius_outer, offset, angle)
local offset = offset or Vector()
local angle = angle or Angle()
local points = {}
for i = 1, sides do
local normal = Vector(math.cos((i + 0.5) * (2 * math.pi / sides)), math.sin((i + 0.5) * (2 * math.pi / sides)), 0)
normal:Rotate(angle)
local l_u = (i - 1) / sides
local r_u = (i) / sides
points[#points + 1] = {
pos = Vector(math.cos(i * (2 * math.pi / sides)) * radius_outer, math.sin(i * (2 * math.pi / sides)) * radius_outer, 0),
normal = normal,
u = l_u,
v = 1
}
points[#points + 1] = {
pos = Vector(math.cos(i * (2 * math.pi / sides)) * radius_inner, math.sin(i * (2 * math.pi / sides)) * radius_inner, 0),
normal = normal,
u = l_u,
v = 0
}
points[#points + 1] = {
pos = Vector(math.cos((i + 1) * (2 * math.pi / sides)) * radius_inner, math.sin((i + 1) * (2 * math.pi / sides)) * radius_inner, 0),
normal = normal,
u = r_u,
v = 0
}
points[#points + 1] = {
pos = Vector(math.cos((i + 1) * (2 * math.pi / sides)) * radius_inner, math.sin((i + 1) * (2 * math.pi / sides)) * radius_inner, 0),
normal = normal,
u = r_u,
v = 0
}
points[#points + 1] = {
pos = Vector(math.cos((i + 1) * (2 * math.pi / sides)) * radius_outer, math.sin((i + 1) * (2 * math.pi / sides)) * radius_outer, 0),
normal = normal,
u = r_u,
v = 1
}
points[#points + 1] = {
pos = Vector(math.cos(i * (2 * math.pi / sides)) * radius_outer, math.sin(i * (2 * math.pi / sides)) * radius_outer, 0),
normal = normal,
u = l_u,
v = 1
}
end
for k, v in pairs(points) do
v.pos:Rotate(angle)
v.pos = v.pos + offset
end
return points
end
function generate_mesh_ring(sides, radius_inner, radius_outer, height, offset, angle)
local points = {}
local offset = offset or Vector()
local angle = angle or Angle()
table.Add(points, generate_mesh_cylinder(sides, radius_inner, height, offset, angle, true))
table.Add(points, generate_mesh_cylinder(sides, radius_outer, height, offset, angle))
table.Add(points, generate_mesh_hollow_circle(sides, radius_inner, radius_outer, offset, Angle(0, 0, 180) + angle))
table.Add(points, generate_mesh_hollow_circle(sides, radius_inner, radius_outer, offset + Vector(0, 0, height), angle))
return points
end
--------------------------------------------------------------------------------
-- Render Target --
--------------------------------------------------------------------------------
local rt_mat = CreateMaterial(rt_name, "UnlitGeneric", {
["$vertexalpha"] = 1
})
------- Render AFK TEXT --------------------------------------------------------
hook.Add("DrawMonitors", "AFKRings", function()
hook.Remove("DrawMonitors", "AFKRings")
local rt_tex = GetRenderTarget(rt_name, 256, 64, true)
rt_mat:SetTexture("$basetexture", rt_tex)
render.PushRenderTarget(rt_tex)
render.SetViewPort(0, 0, 256, 64)
render.OverrideAlphaWriteEnable(true, true)
cam.Start2D()
render.Clear(0, 0, 0, 150)
surface.SetFont(font_name)
surface.SetTextColor(Color(255, 255, 255))
surface.SetTextPos(30, 10)
surface.DrawText("OFF-RP | AUSENTE")
cam.End2D()
render.OverrideAlphaWriteEnable(false)
render.PopRenderTarget()
end)
--------------------------------------------------------------------------------
-- AFK RING RENDER --
--------------------------------------------------------------------------------
------- Generate Meshes --------------------------------------------------------
local mesh_rings = Mesh()
local mesh_text = Mesh()
local mesh_points = {}
-- Rings
table.Add(mesh_points, generate_mesh_ring(25, 34, 35, 1, Vector(0, 0, -5)))
table.Add(mesh_points, generate_mesh_ring(25, 34, 35, 1, Vector(0, 0, 5)))
mesh_rings:BuildFromTriangles(mesh_points)
mesh_points = {}
-- Text Cylinder
table.Add(mesh_points, generate_mesh_cylinder(40, 34.5, 10, Vector(0, 0, -5), nil, true))
table.Add(mesh_points, generate_mesh_cylinder(40, 34.5, 10, Vector(0, 0, -5)))
mesh_text:BuildFromTriangles(mesh_points)
------- Render The AFK Rings ---------------------------------------------------
local afk_players = {}
timer.Create("AFKRings_Update", 1, 0, function()
afk_players = {}
if afkrings_convar:GetInt() == 0 then return end
-- -- hide if we're watching something
if MediaPlayer and MediaPlayer.GetAll and #MediaPlayer.GetAll() > 0 then return end
if PlayX then
for _, instance in pairs(PlayX.GetInstances()) do
if instance.IsPlaying then return end
end
end
for _, ply in pairs(player.GetAll()) do
if not ply:IsAFK() then continue end
-- print("AFK")
afk_players[#afk_players + 1] = ply
end
end)
local convar_distance = CreateClientConVar("afkrings_distance", "256")
local ring_mat = Material("color")
hook.Add("PostDrawOpaqueRenderables", "AFKRings", function()
if #afk_players == 0 then return end
local distance = convar_distance:GetInt()
local loc_pos = LocalPlayer():EyePos()
local m_rings = Matrix()
local ppos = LocalPlayer():GetPos()
render.OverrideDepthEnable(true, true)
for _, ply in ipairs(afk_players) do
if not ply:IsValid() then continue end
local ply_pos = ply:GetPos()
if (ply_pos:Distance(ppos) > distance and ply ~= LocalPlayer()) or ply:IsDormant() or not ply:IsAFK() or ply:GetColor().a < 255 or IsValid(ply:GetVehicle()) or (HnS and HnS.InGame and HnS.InGame(ply)) or (ply_pos:DistToSqr(loc_pos) > (2000) ^ 2) then continue end
local bounds_min, bounds_max = ply:WorldSpaceAABB()
local bounds_scale = bounds_max - bounds_min
local ring_pos = ply_pos + Vector(0, 0, (bounds_scale.z) / math.Clamp(2 - math.abs(math.sin((RealTime()) * 0.65)), 1.5, 2))
m_rings:Identity()
m_rings:Translate(ring_pos)
-- Rings
cam.PushModelMatrix(m_rings)
render.SetMaterial(ring_mat)
mesh_rings:Draw()
cam.PopModelMatrix()
m_rings:Rotate(Angle(0, -RealTime() * 30, 0))
-- Text Cylinder
cam.PushModelMatrix(m_rings)
render.SetMaterial(rt_mat)
mesh_text:Draw()
cam.PopModelMatrix()
end
render.OverrideDepthEnable(false)
end)
end
|
name = "Redfriday"
version = 1
me = { like = "football", gender = "male", single = "true" }
function add(a,b)
return a+b, true
end
|
-- This software is released under the MIT License. See LICENSE.txt for details.
--T-Bone Class version 0.2
local class = {}
class.__index=class
class._bobbyTables={}
function class:init() end
function class:_init() self:init() end
function class:newInstance()
local o = {}
setmetatable(o,self)
if self._bobbyTables then
for i=1,#self._bobbyTables do
o[self._bobbyTables[i]]={}
end
end
o:_init()
return o
end
function newClass(tables)
local o = {}
setmetatable(o,class)
o.__index=o
o._bobbyTables=tables
return o
end
function class:addTable(tab)
table.insert(self._bobbyTables,tab)
end
function class:newSubClass(tables)
local o = {}
setmetatable(o,self)
o.__index=o
if tables then
if not o._bobbyTables then
o._bobbyTables=tables
else
local a = #o._bobbyTables
for i = a,a + #tables do
o._bobbyTables[i]=tables[i-a]
end
end
end
return o
end
function newSubClass(mother,tables)
return mother:newSubClass(tables)
end
|
---
-- @class PANEL
-- @section DColoredTextBoxTTT2
local PANEL = {}
---
-- @ignore
function PANEL:Init()
self:SetText("")
self.contents = {
title = "",
title_font = "DermaTTT2Text",
opacity = 1.0,
align = TEXT_ALIGN_CENTER,
color = COLOR_WHITE,
flashcolor = false,
icon = nil,
parent = nil,
shift = 0
}
end
---
-- @param Panel parent
-- @param number shift
-- @realm client
function PANEL:SetDynamicColor(parent, shift)
self.contents.parent = parent
self.contents.shift = shift
end
---
-- @return boolean
-- @realm client
function PANEL:HasDynamicColor()
return self.contents.parent ~= nil
end
---
-- @return Color
-- @realm client
function PANEL:GetDynamicParentColor()
return self.contents.parent.dynBaseColor
end
---
-- @return Color
-- @realm client
function PANEL:GetDynamicParentColorShift()
return self.contents.shift
end
---
-- @param string title
-- @realm client
function PANEL:SetTitle(title)
self.contents.title = title or ""
end
---
-- @return string
-- @realm client
function PANEL:GetTitle()
return self.contents.title
end
---
-- @param string title_font
-- @realm client
function PANEL:SetTitleFont(title_font)
self.contents.title_font = title_font or ""
end
---
-- @return string
-- @realm client
function PANEL:GetTitleFont()
return self.contents.title_font
end
---
-- @param number opacity
-- @realm client
function PANEL:SetTitleOpacity(opacity)
self.contents.opacity = opacity or 1.0
end
---
-- @return number
-- @realm client
function PANEL:GetTitleOpacity()
return self.contents.opacity
end
---
-- @param number align
-- @realm client
function PANEL:SetTitleAlign(align)
self.contents.align = align or TEXT_ALIGN_CENTER
end
---
-- @return number
-- @realm client
function PANEL:GetTitleAlign()
return self.contents.align
end
---
-- @param Color color
-- @realm client
function PANEL:SetColor(color)
self.contents.color = color or COLOR_WHITE
end
---
-- @return Color
-- @realm client
function PANEL:GetColor()
return self.contents.color
end
---
-- @param Color color
-- @realm client
function PANEL:EnableFlashColor(enb)
self.contents.flashcolor = enb
end
---
-- @return boolean
-- @realm client
function PANEL:HasFlashColor()
return self.contents.flashcolor or false
end
---
-- @param Material icon
-- @realm client
function PANEL:SetIcon(icon)
self.contents.icon = icon
end
---
-- @return Material
-- @realm client
function PANEL:GetIcon()
return self.contents.icon
end
---
-- @return boolean
-- @realm client
function PANEL:HasIcon()
return self.contents.icon ~= nil
end
---
-- @param number w
-- @param number h
-- @realm client
function PANEL:Paint(w, h)
derma.SkinHook("Paint", "ColoredTextBoxTTT2", self, w, h)
return false
end
derma.DefineControl("DColoredTextBoxTTT2", "", PANEL, "DPanelTTT2")
|
local mqttRegex = require "mqttRegex"
local Router = {}
Router.__index = Router
setmetatable(Router, {
__call = function (cls, ...)
return cls.new(...)
end,
})
function Router.new()
local self = setmetatable({}, Router)
self.listeners = {}
return self
end
function Router:emit(topic, data)
for pattern, listeners in pairs(self.listeners) do
local params, isMatched = mqttRegex.parse(pattern, topic)
if isMatched then
for i, listener in ipairs(listeners) do listener(data, params, topic) end
end
end
end
-- listener: (data, params, topic) => void
function Router:on(pattern, listener)
if self.listeners[pattern] == nil then
self.listeners[pattern] = {}
end
table.insert(self.listeners[pattern], listener)
end
function Router:once(pattern, listener)
local function onceListener(...)
listener(unpack(arg))
self:removeListener(pattern, onceListener)
end
self:on(pattern, onceListener)
end
function Router:removeListener(pattern, target)
if self.listeners[pattern] then
for i, listener in ipairs(self.listeners[pattern]) do
if listener == target then
table.remove(self.listeners[pattern],i)
if #self.listeners[pattern] == 0 then
self.listeners[pattern] = nil
collectgarbage()
end
return true
end
end
end
return false
end
return Router
|
local gloveboxData = nil
RegisterNetEvent("InitInventaire:openGloveboxInventory")
AddEventHandler(
"InitInventaire:openGloveboxInventory",
function(data, blackMoney, inventory, weapons)
setGloveboxInventoryData(data, blackMoney, inventory, weapons)
openGloveboxInventory()
end
)
RegisterNetEvent("InitInventaire:refreshGloveboxInventory")
AddEventHandler(
"InitInventaire:refreshGloveboxInventory",
function(data, blackMoney, inventory, weapons)
setGloveboxInventoryData(data, blackMoney, inventory, weapons)
end
)
function setGloveboxInventoryData(data, blackMoney, inventory, weapons)
gloveboxData = data
SendNUIMessage(
{
action = "setInfoText",
text = data.text
}
)
items = {}
if blackMoney > 0 then
accountData = {
label = _U("black_money"),
count = blackMoney,
type = "item_account",
name = "black_money",
usable = false,
rare = false,
weight = -1,
canRemove = false
}
table.insert(items, accountData)
end
if inventory ~= nil then
for key, value in pairs(inventory) do
if inventory[key].count <= 0 then
inventory[key] = nil
else
inventory[key].type = "item_standard"
inventory[key].usable = false
inventory[key].rare = false
inventory[key].weight = -1
inventory[key].canRemove = false
table.insert(items, inventory[key])
end
end
end
if Config.IncludeWeapons and weapons ~= nil then
for key, value in pairs(weapons) do
local weaponHash = GetHashKey(weapons[key].name)
if weapons[key].name ~= "WEAPON_UNARMED" then
table.insert(
items,
{
label = weapons[key].label,
count = weapons[key].ammo,
weight = -1,
type = "item_weapon",
name = weapons[key].name,
usable = false,
rare = false,
canRemove = false
}
)
end
end
end
SendNUIMessage(
{
action = "setSecondInventoryItems",
itemList = items
}
)
end
function openGloveboxInventory()
loadPlayerInventory()
isInInventory = true
SendNUIMessage(
{
action = "display",
type = "glovebox"
}
)
SetNuiFocus(true, true)
end
RegisterNUICallback(
"PutIntoGlovebox",
function(data, cb)
if type(data.number) == "number" and math.floor(data.number) == data.number then
local count = tonumber(data.number)
if data.item.type == "item_weapon" then
count = GetAmmoInPedWeapon(PlayerPedId(), GetHashKey(data.item.name))
end
TriggerServerEvent("esx_glovebox:putItem", gloveboxData.plate, data.item.type, data.item.name, count, gloveboxData.max, gloveboxData.myVeh, data.item.label)
end
Wait(500)
loadPlayerInventory()
cb("ok")
end
)
RegisterNUICallback(
"TakeFromGlovebox",
function(data, cb)
if type(data.number) == "number" and math.floor(data.number) == data.number then
TriggerServerEvent("esx_glovebox:getItem", gloveboxData.plate, data.item.type, data.item.name, tonumber(data.number), gloveboxData.max, gloveboxData.myVeh)
end
Wait(500)
loadPlayerInventory()
cb("ok")
end
)
|
-- This is a profile_sharing policy.
local policy = require('apicast.policy')
local _M = policy.new('profile_sharing')
local setmetatable = setmetatable
local concat = table.concat
local insert = table.insert
local len = string.len
local format = string.format
local pairs = pairs
local sub = string.sub
local ts = require ('apicast.threescale_utils')
local redis = require('resty.redis')
local http_ng = require('resty.http_ng')
local http_ng_resty = require('resty.http_ng.backend.resty')
local user_agent = require('apicast.user_agent')
local resty_url = require('resty.url')
local resty_env = require('resty.env')
local cjson = require('cjson')
local inspect = require('inspect')
local new = _M.new
--- Utilities (local functions)
---
local function obtain_app_id(context)
if not context then
return nil
end
if context.credentials and context.credentials.app_id then
return context.credentials.app_id
end
local service = context.service
if not service then
ngx.log(ngx.WARN, 'unable to find credentials nor service in context')
return nil
end
local service_creds = service:extract_credentials()
if not service_creds or
not service_creds.app_id then
return nil
end
return service_creds.app_id
end
local function build_url(self, path_and_params)
local endpoint = self.base_url
if self.openshift_env and self.openshift_env == '1' then
endpoint = 'http://system-provider:3000'
end
if not endpoint then
return nil, 'missing endpoint'
end
return resty_url.join(endpoint, '', path_and_params)
end
-- Get the associated `account_id` using the `app_id` or `jwt.client_id` params from 3scale API.
local function application_find(self, app_id)
local http_client = self.http_client
if not http_client then
return nil, 'http_client not initialized'
end
path = '/admin/api/applications/find.json?'
local url = build_url(self, path .. 'app_id=' .. ngx.escape_uri(app_id) .. '&access_token=' .. ngx.escape_uri(self.access_token))
ngx.log(ngx.INFO, 'Calling url: ', url)
local res, err = http_client.get(url)
if not res and err then
ngx.log(ngx.DEBUG, 'application_find() get error: ', err, ' url: ', url)
return nil
end
ngx.log(ngx.INFO, 'http client uri: ', url, ' ok: ', res.ok, ' status: ', res.status, ' body: ', res.body)
if res.status == 200 and res.body and res.body ~= cjson.null then
return cjson.decode(res.body)
else
return nil
end
end
-- Get the extra_fields data for that account using the `accound_id` param from 3scale API.
local function accound_read(self, id)
if not id or id == '' then
return nil, 'app_id is empty'
end
local http_client = self.http_client
if not http_client then
return nil, 'not initialized'
end
path = '/admin/api/accounts/' .. id .. '.json?'
local url = build_url(self, path .. 'access_token=' .. self.access_token)
local res, err = http_client.get(url)
if not res and err then
ngx.log(ngx.DEBUG, 'application_find() get error: ', err, ' url: ', url)
return nil
end
ngx.log(ngx.INFO, 'http client uri: ', url, ' ok: ', res.ok, ' status: ', res.status, ' body: ', res.body)
if res.status == 200 and res.body and res.body ~= cjson.null then
return cjson.decode(res.body)
else
return nil
end
end
local function fetch_profile_from_backend(self, app_id)
local app_response = application_find(self, app_id)
ngx.log(ngx.INFO, 'application_find response:', app_response)
if not app_response or
app_response == cjson.null or
not app_response.application or
app_response.application == cjson.null then
return nil
end
local accound_id = app_response.application.account_id or app_response.application.user_account_id
if not accound_id then
return nil
end
local plan = nil
if app_response.application.plan then
plan = app_response.application.plan
elseif app_response.application.plan_id and app_response.application.plan_name then
plan = { id = app_response.application.plan_id,
name = app_response.application.plan_name }
end
local acc_response = accound_read(self, accound_id)
if not acc_response or
acc_response == cjson.null or
not acc_response.account or
acc_response.account == cjson.null or
not acc_response.account.id or
acc_response.account.id == cjson.null then
return nil
end
return acc_response.account, plan
end
local function set_request_header(header_name, value)
ngx.req.set_header(header_name, value)
end
local function set_profile_headers(self, profile)
set_request_header(self.header_keys.id, profile.id)
set_request_header(self.header_keys.name, profile.name)
set_request_header(self.header_keys.info, cjson.encode(profile.info))
set_request_header(self.header_keys.plan_id, profile.plan_id)
set_request_header(self.header_keys.plan_name, profile.plan_name)
end
--- Initialize a profile_sharing module
-- @tparam[opt] table config Policy configuration.
--
function _M.new(config)
local self = new(config)
-- define header keys to be used.
self.header_keys = {
id = 'X-Api-Gateway-Account-Id',
name = 'X-Api-Gateway-Account-Name',
info = 'X-Api-Gateway-Account-Info',
plan_id = 'X-Api-Gateway-Account-Plan-Id',
plan_name = 'X-Api-Gateway-Account-Plan-Name',
}
-- load environment variables for admin APIs access.
self.base_url = resty_env.value("THREESCALE_ADMIN_API_URL") or ''
self.access_token = resty_env.value("THREESCALE_ADMIN_API_ACCESS_TOKEN") or ''
self.openshift_env = resty_env.value("OPENSHIFT_ENV") or '0'
self.cache_key_prefix = 'customer-info-'
-- build local http client, or used pre-defined one (if injected).
local client = http_ng.new {
backend = config and config.backend or http_ng_resty,
options = {
headers = {
host = self.base_url,
user_agent = user_agent(),
['X-Forwarded-Proto'] = 'https',
},
ssl = { verify = resty_env.enabled('OPENSSL_VERIFY') }
}
}
self.http_client = client
return self
end
--- Rewrite phase: add profile-share info before content phase done by upstream/backend.
---
function _M:rewrite(context)
local app_id = obtain_app_id(context)
if not app_id then
ngx.log(ngx.DEBUG, 'app_id not found in context.')
return
end
ngx.log(ngx.DEBUG, 'app_id is assigned from context: ', app_id)
-- Assign the cahce key with app_id and prefix.
local cache_key = self.cache_key_prefix .. tostring(app_id)
-- Use redis for reading from cache first.
local redis, err = self.safe_connect_redis()
if not redis then
ngx.log(ngx.WARN, 'cannot connect to redis instance, error:', inspect(err))
else
local cached_data = redis:get(cache_key)
ngx.log(ngx.INFO, 'account data found in cache: ', cjson.encode(cached_data))
if cached_data and cached_data ~= nil and type(cached_data) == 'string' then
local cached_profile = cjson.decode(cached_data)
if cached_profile and cached_profile ~= nil then
set_profile_headers(self, cached_profile)
return
end
end
end
-- Otherwise, fall back to APIs.
local account, plan = fetch_profile_from_backend(self, app_id)
if not account then
ngx.log(ngx.WARN, 'account information is not found in the system. app_id = ' .. app_id)
return
end
local profile = {
id = account.id,
name = account.org_name,
info = account.organization_number or account.extra_fields,
plan_id = nil,
plan_name = nil,
}
if plan then
profile.plan_id = plan.id
profile.plan_name = plan.name
end
-- Cache profile info into redis by app-id as the cache key, value is the profile table.
if redis then
redis:set(cache_key, cjson.encode(profile))
end
-- Change the request before it reaches upstream or backend.
set_profile_headers(self, profile)
end
function _M.safe_connect_redis(options)
local opts = {}
local url = options and options.url or resty_env.get('REDIS_URL')
local redis_conf = {
timeout = 3000, -- 3 seconds
keepalive = 10000, -- milliseconds
poolsize = 1000 -- # connections
}
if url then
url = resty_url.split(url, 'redis')
if url then
opts.host = url[4]
opts.port = url[5]
opts.db = url[6] and tonumber(sub(url[6], 2))
opts.password = url[3] or url[2]
end
elseif options then
opts.host = options.host
opts.port = options.port
opts.db = options.db
opts.password = options.password
end
opts.timeout = options and options.timeout or redis_conf.timeout
local host = opts.host or resty_env.get('REDIS_HOST') or "127.0.0.1"
local port = opts.port or resty_env.get('REDIS_PORT') or 6379
local red = redis:new()
red:set_timeout(opts.timeout)
local ok, err = red:connect(ts.resolve(host, port))
if not ok then
ngx.log(ngx.WARN, "failed to connect to redis on ", host, ":", port, ": ", err)
return nil
end
if opts.password then
ok = red:auth(opts.password)
if not ok then
ngx.log(ngx.WARN, "failed to auth on redis ", host, ":", port)
return nil
end
end
if opts.db then
ok = red:select(opts.db)
if not ok then
ngx.log(ngx.WARN, "failed to select db ", opts.db, " on redis ", host, ":", port)
return nil
end
end
return red
end
return _M
|
local CELL_SIZE = 60
local SpatialHash = class {
init = function(self, size)
self.elements = {}
self.size = size or CELL_SIZE
end,
add = function(self, obj)
local x = Math.ceil(obj.x / self.size) * self.size
local y = Math.ceil(obj.y / self.size) * self.size
local key = x .. ',' .. y
if not self.element[key] then
self.element[key] = {}
end
-- table.insert(
end
}
Bunny = Entity("Bunny", {
x = 0,
y = 0,
sprite = "bunny.bmp",
is_spinning = true
})
System(All("sprite", "x", "y", "is_spinning", Not("dead")),{
order = "post",
added = function(ent)
local spr = ent.sprite
spr.x = ent.x
spr.y = ent.y
spr.align = "center"
--spr.angle = Math.rad(45)
--spr.scale = 3
end,
update = function(ent, dt)
--ent.sprite.angle = ent.sprite.angle + Math.rad(10) * dt
ent.sprite.scale = ent.sprite.scale + 5 * dt
end
})
System(All("sprite"), {
order = "pre",
added = function(ent)
ent.sprite = Image(ent.sprite)
ent.sprite.debug = true
ent.sprite:addDrawable()
end,
removed = function(ent)
ent.sprite:destroy()
end
})
State("spatialhash",{
enter = function()
Bunny{x = Game.width / 2, y = Game.height / 2}
end,
draw = function()
Draw.color('red')
Draw.line(0,Game.height/2,Game.width,Game.height/2)
Draw.line(Game.width/2,0,Game.width/2,Game.height)
end
})
|
local premio = {
[1] = {item = 2160, count = 30},
}
local configs = {
hours = 1, -- quantas em quantas horas, vai acontecer.
winners = 3 -- qntos players podem ganhar.
}
function onThink(interval, lastExecution)
local p = getPlayersOnline()
local winners = configs.winners
if #p < winners then
winners = #p
end
for i = 1, winners do
local p = getPlayersOnline()
local c, w = #p, #premio
local d, e = math.random(c), math.random(w)
local playerwin = p[d]
doPlayerAddItem(playerwin, premio[e].item, premio[e].count)
doBroadcastMessage("[" .. i .. "ST PLACE] Winner: " .. getCreatureName(playerwin) .. ", Reward: " .. premio[e].count .. " " .. getItemNameById(premio[e].item) .. ", Congratulations!")
if i == winners then
doBroadcastMessage("(Next Lottery in " .. configs.hours .. " hours.)")
end
doSendMagicEffect(getThingPos(playerwin), 12)
end
return true
end
|
local setmetatable = setmetatable
local io = io
local ipairs = ipairs
local loadstring = loadstring
local print = print
local tonumber = tonumber
local beautiful = require( "beautiful" )
local button = require( "awful.button" )
local widget2 = require( "awful.widget" )
local config = require( "forgotten" )
local vicious = require( "extern.vicious" )
local menu = require( "radical.context" )
local util = require( "awful.util" )
local wibox = require( "wibox" )
local themeutils = require( "blind.common.drawing" )
local radtab = require( "radical.widgets.table" )
local embed = require( "radical.embed" )
local radical = require( "radical" )
local color = require( "gears.color" )
local cairo = require( "lgi" ).cairo
local allinone = require( "widgets.allinone" )
local data = {}
local procMenu = nil
local capi = { screen = screen , client = client ,
mouse = mouse , timer = timer }
local module = {}
local function match_icon(arr,name)
for k2,v2 in ipairs(arr) do
if k2:find(name) ~= nil then
return v2
end
end
end
local function reload_top(procMenu,data)
procMenu:clear()
if data.process then
local procIcon = {}
for k2,v2 in ipairs(capi.client.get()) do
if v2.icon then
procIcon[v2.class:lower()] = v2.icon
end
end
for i=1,#data.process do
local wdg = {}
wdg.percent = wibox.widget.textbox()
wdg.percent.fit = function()
return 42,procMenu.item_height
end
wdg.percent.draw = function(self,w, cr, width, height)
cr:save()
cr:set_source(color(procMenu.bg_alternate))
cr:rectangle(0,0,width-height/2,height)
cr:fill()
cr:set_source_surface(themeutils.get_beg_arrow2({bg_color=procMenu.bg_alternate}),width-height/2,0)
cr:paint()
cr:restore()
wibox.widget.textbox.draw(self,w, cr, width, height)
end
wdg.kill = wibox.widget.imagebox()
wdg.kill:set_image(config.iconPath .. "kill.png")
wdg.percent:set_text((data.process[i].percent or "N/A").."%")
procMenu:add_item({text=data.process[i].name,suffix_widget=wdg.kill,prefix_widget=wdg.percent})
end
end
end
--util.spawn("/bin/bash -c 'while true;do "..util.getdir("config") .."/Scripts/cpuInfo2.sh > /tmp/cpuStatistic.lua && sleep 5;done'")
--util.spawn("/bin/bash -c 'while true; do "..util.getdir("config") .."/Scripts/topCpu3.sh > /tmp/topCpu.lua;sleep 5;done'")
local function new(margin, args)
local cpuModel
local spacer1
local volUsage
local modelWl
local cpuWidgetArrayL
local main_table
local function loadData()
util.spawn("/bin/bash -c '"..util.getdir("config") .."/Scripts/cpuInfo2.sh > /tmp/cpuStatistic.lua'")
local f = io.open('/tmp/cpuStatistic.lua','r')
local cpuStat = {}
if f ~= nil then
local text3 = f:read("*all")
text3 = text3.." return cpuInfo"
f:close()
local afunction = loadstring(text3)
if afunction ~= nil then
cpuStat = afunction()
infoNotFound = nil
else
infoNotFound = "N/A"
end
else
infoNotFound = "N/A"
end
if cpuStat then
data.cpuStat = cpuStat
cpuModel:set_text(cpuStat.model or "")
end
local process = {}
util.spawn("/bin/bash -c '"..util.getdir("config") .."/Scripts/topCpu3.sh > /tmp/topCpu.lua'")
f = io.open('/tmp/topCpu.lua','r')
if f ~= nil then
text3 = f:read("*all")
text3 = text3.." return cpuStat"
f:close()
local afunction = loadstring(text3) or nil
if afunction ~= nil then
process = afunction()
else
process = nil
end
end
if process then
data.process = process
end
end
local function createDrawer()
cpuModel = wibox.widget.textbox()
spacer1 = wibox.widget.textbox()
volUsage = widget2.graph()
topCpuW = {}
local tab,widgets = radtab({
{"","",""},
{"","",""},
{"","",""},
{"","",""},
{"","",""},
{"","",""},
{"","",""},
{"","",""}},
{row_height=20,v_header = {"C1","C2","C3","C4","C5", "C6","C7","C8" },
h_header = {"MHz","Temp","Used"}
})
main_table = widgets
modelWl = wibox.layout.fixed.horizontal()
modelWl:add ( cpuModel )
loadData()
cpuWidgetArrayL = wibox.layout.margin()
cpuWidgetArrayL:set_margins(3)
cpuWidgetArrayL:set_bottom(10)
cpuWidgetArrayL:set_widget(tab)
cpuModel:set_text(data.cpuStat and data.cpuStat.model or "N/A")
cpuModel.width = 312
volUsage:set_width ( 312 )
volUsage:set_height ( 30 )
volUsage:set_scale ( true )
volUsage:set_border_color ( beautiful.fg_normal )
volUsage:set_color ( beautiful.fg_normal )
vicious.register ( volUsage, vicious.widgets.cpu,'$1',1 )
local f2 = io.popen("cat /proc/cpuinfo | grep processor | tail -n1 | grep -e'[0-9]*' -o")
local coreNb = f2:read("*all") or "0"
f2:close()
end
local function updateTable()
local cols = {
CLOCK = 1,
TEMP = 2,
USED = 3,
IO = 4,
IDLE = 5,
}
if data.cpuStat ~= nil and data.cpuStat["core0"] ~= nil and main_table ~= nil then
for i=0 , data.cpuStat["core"] do --TODO add some way to correct the number of core, it usually fail on load --Solved
if i <= (#main_table or 1) and main_table[i+1] then
main_table[i+1][cols[ "CLOCK" ]]:set_text(tonumber(data.cpuStat["core"..i]["speed"]) .. "Mhz" )
main_table[i+1][cols[ "TEMP" ]]:set_text(data.cpuStat["core"..i].temp )
main_table[i+1][cols[ "USED" ]]:set_text(data.cpuStat["core"..i].usage )
end
end
end
end
local function regenMenu()
local imb = wibox.widget.imagebox()
imb:set_image(beautiful.path .. "Icon/reload.png")
aMenu = menu({item_width=298,width=300,arrow_type=radical.base.arrow_type.CENTERED})
aMenu:add_widget(radical.widgets.header(aMenu,"INFO") , {height = 20 , width = 300})
aMenu:add_widget(modelWl , {height = 40 , width = 300})
aMenu:add_widget(radical.widgets.header(aMenu,"USAGE") , {height = 20 , width = 300})
aMenu:add_widget(volUsage , {height = 30 , width = 300})
aMenu:add_widget(cpuWidgetArrayL , {width = 300})
aMenu:add_widget(radical.widgets.header(aMenu,"PROCESS",{suffix_widget=imb}) , {height = 20 , width = 300})
procMenu = embed({max_items=6})
aMenu:add_embeded_menu(procMenu)
return aMenu
end
local function show()
if not data.menu then
createDrawer()
data.menu = regenMenu()
else
end
if not data.menu.visible then
loadData()
updateTable()
reload_top(procMenu,data)
end
data.menu.visible = not data.menu.visible
end
local volumewidget2 = allinone()
volumewidget2:set_icon(config.iconPath .. "brain.png")
vicious.register(volumewidget2, vicious.widgets.cpu,'$1',1)
volumewidget2:buttons (util.table.join(button({ }, 1, function (geo) show(); data.menu.parent_geometry = geo end)))
return volumewidget2
end
return setmetatable(module, { __call = function(_, ...) return new(...) end })
-- kate: space-indent on; indent-width 2; replace-tabs on;
|
-- Define global variables.
state.var {
Name = state.value(),
My_map = state.map()
}
-- Initialize a name in this contract.
function constructor()
-- a constructor is called at a deployment, only one times
-- set initial name
Name:set("world")
My_map["key"] = "value"
end
-- Update a name.
-- @call
-- @param name string: new name.
function set_name(name)
Name:set(name)
end
-- Say hello.
-- @query
-- @return string: 'hello ' + name
function hello()
return "hello " .. Name:get()
end
-- register functions to expose
abi.register(set_name, hello)
|
local M = {}
M.make_result_table = function(current, latest, line_number)
return {
current = current,
latest = latest,
line_number = line_number,
}
end
return M
|
local lamda = {}
function lamda.flip(fn)
return function(a, b, ...)
return fn(b, a, ...)
end
end
function lamda.append(elem, tbl)
local copy = {table.unpack(tbl)}
table.insert(copy, elem)
return copy
end
function lamda.reduce(fn, acc, tbl)
return #tbl == 0 and acc or lamda.reduce(fn, fn(acc, tbl[1]), {table.unpack(tbl, 2)})
end
function lamda.map(fn, tbl)
return lamda.reduce(function(acc, value) return lamda.append(fn(value), acc) end, {}, tbl)
end
function lamda.filter(predicate, tbl)
return lamda.reduce(function(acc, value) return predicate(value) and lamda.append(fn(value), acc) or acc end, {}, tbl)
end
local function split(pattern, acc, str)
if str == '' then return acc end
if pattern == '' then return split(pattern, lamda.append(str:sub(1, 1), acc), str:sub(2)) end
local from, to = str:find(pattern)
return not from and lamda.append(str, acc) or split(pattern, from == 1 and acc or lamda.append(str:sub(1, from - 1), acc), str:sub(to + 1))
end
function lamda.split(pattern, str)
return split(pattern, {}, str)
end
lamda.join = lamda.flip(table.concat)
function lamda.concat(first_table, second_table)
return lamda.reduce(lamda.flip(lamda.append), first_table, second_table)
end
function lamda.pipe(fn, ...)
local fns = {...}
return function(...)
return lamda.reduce(function(acc, value) return value(acc) end, fn(...), fns)
end
end
function lamda.partial(fn, ...)
local arguments = {...}
return function(...)
return fn(table.unpack(lamda.concat(arguments, {...})))
end
end
function lamda.partial_right(fn, ...)
local arguments = {...}
return function(...)
return fn(table.unpack(lamda.concat({...}, arguments)))
end
end
function lamda.any_pass(predicate, ...)
local rest = {...}
return function(argument)
if #rest == 0 then return predicate(argument) end
return predicate(argument) or lamda.any_pass(table.unpack(rest))(argument)
end
end
function lamda.sort(comparator, tbl)
local copy = {table.unpack(tbl)}
table.sort(copy, comparator)
return copy
end
return lamda
|
object_mobile_tcg_familiar_hutt_fighter = object_mobile_shared_tcg_familiar_hutt_fighter:new {
}
ObjectTemplates:addTemplate(object_mobile_tcg_familiar_hutt_fighter, "object/mobile/tcg_familiar_hutt_fighter.iff")
|
local core = require 'core.reference'
local files = require 'files'
local function catch_target(script)
local list = {}
local cur = 1
while true do
local start, finish = script:find('<[!?].-[!?]>', cur)
if not start then
break
end
list[#list+1] = { start + 2, finish - 2 }
cur = finish + 1
end
return list
end
local function founded(targets, results)
if #targets ~= #results then
return false
end
for _, target in ipairs(targets) do
for _, result in ipairs(results) do
if target[1] == result[1] and target[2] == result[2] then
goto NEXT
end
end
do return false end
::NEXT::
end
return true
end
function TEST(script)
files.removeAll()
local target = catch_target(script)
local start = script:find('<[?~]')
local finish = script:find('[?~]>')
local pos = (start + finish) // 2 + 1
local new_script = script:gsub('<[!?~]', ' '):gsub('[!?~]>', ' ')
files.setText('', new_script)
local results = core('', pos)
if results then
local positions = {}
for i, result in ipairs(results) do
positions[i] = { result.target.start, result.target.finish }
end
assert(founded(target, positions))
else
assert(#target == 0)
end
end
TEST [[
local <?a?> = 1
<!a!> = <!a!>
]]
TEST [[
<?a?> = 1
<!a!> = <!a!>
]]
TEST [[
local t
t.<?a?> = 1
t.<!a!> = t.<!a!>
]]
TEST [[
t.<?a?> = 1
t.<!a!> = t.<!a!>
]]
TEST [[
:: <!LABEL!> ::
goto <?LABEL?>
if true then
goto <!LABEL!>
end
]]
TEST [[
:: <?LABEL?> ::
goto <!LABEL!>
if true then
goto <!LABEL!>
end
]]
TEST [[
local a = 1
local <?a?> = 1
<!a!> = <!a!>
]]
TEST [[
local t = {
<!a!> = 1
}
print(t.<?a?>)
]]
TEST [[
local t = {
<?a?> = 1
}
print(t.<!a!>)
]]
TEST [[
local t = {
[<?'a'?>] = 1
}
print(t.<!a!>)
]]
--TEST [[
--local <!mt!> = {}
--function <!mt!>:a()
-- <?self?>:remove()
--end
--]]
TEST [[
local function f()
return <~function~> ()
end
end
local <!f2!> = f()
]]
TEST [[
local function f()
return nil, <~function~> ()
end
end
local _, <!f2!> = f()
]]
TEST [[
table.<!dump!>()
function table.<?dump?>()
end
]]
TEST [[
local mt = {}
local <?obj?> = setmetatable({}, mt)
]]
TEST [[
local mt = {}
mt.x = 1
local obj = setmetatable({}, mt)
print(obj.<?x?>)
]]
TEST [[
local x
local function f()
return x
end
local <?y?> = f()
]]
TEST [[
local <?x?>
local function f()
return <!x!>
end
local y = f()
]]
TEST [[
local x
local function f()
return function ()
return x
end
end
local <?y?> = f()()
]]
TEST [[
local <?x?>
local function f()
return function ()
return <!x!>
end
end
local y = f()()
]]
TEST [[
local mt = {}
mt.__index = mt
function mt:add(a, b)
end
local function init()
return setmetatable({}, mt)
end
local <!t!> = init()
<?t?>:add()
]]
TEST [[
local mt = {}
mt.__index = mt
function mt:add(a, b)
end
local function init()
return setmetatable({}, mt)
end
local t = init()
t:<?add?>()
]]
TEST [[
local t = {}
t.<?x?> = 1
t[a.b.x] = 1
]]
--TEST [[
--local t = {}
--t.x = 1
--t[a.b.<?x?>] = 1
--]]
TEST [[
local t
local f = t.<?f?>
f()
return {
f = f,
}
]]
TEST [[
self = {
results = {
<?labels?> = {},
}
}
self[self.results.<!labels!>] = lbl
]]
TEST [[
a.b.<?c?> = 1
print(a.b.<!c!>)
]]
--TEST [[
-----@class <!Class!>
-----@type <?Class?>
-----@type <!Class!>
--]]
--
--TEST [[
-----@class <?Class?>
-----@type <!Class!>
-----@type <!Class!>
--]]
|
return {'email','emailleeroven','emaillen','emailleren','emanatie','emancipatie','emancipatiebeleid','emancipatiebeweging','emancipatiegolf','emancipatieproces','emancipatieraad','emancipatiestrijd','emancipatiezaken','emancipatoir','emancipator','emancipatorisch','emanciperen','emaneren','emancipatiegedachte','emancipatienota','emancipatiestreven','emancipatiepartij','emancipatieambtenaar','emaillering','emanuelle','eman','emanuel','emaus','emanuelson','emailleer','emailleerde','emailleert','emanaties','emancipatoire','emancipatorische','emancipeer','emancipeerde','emancipeerden','emancipeert','emailleerovens','emancipatiebewegingen','emanciperend','emanciperende','emaneerde','emans','emanuels','emancipatieprocessen','emancipatiegolven'}
|
#!/usr/bin/env lua5.3
-- Forth style reverse polish calculator impletation in lua
function string:split(delimiter)
local sep, fields = delimiter or " ", {}
local pattern = string.format("([^%s]+)", sep)
self:gsub(pattern, function(c) fields[#fields+1] = c end)
return fields
end
local function calc(stack, elem)
local tmp
if elem == "+" then
tmp = table.remove(stack)
table.insert(stack, table.remove(stack) + tmp)
elseif elem == "-" then
tmp = table.remove(stack)
table.insert(stack, table.remove(stack) - tmp)
elseif elem == "*" then
tmp = table.remove(stack)
table.insert(stack, table.remove(stack) * tmp)
elseif elem == "/" then
tmp = table.remove(stack)
table.insert(stack, table.remove(stack) / tmp)
elseif elem == "." then
print(table.remove(stack))
elseif elem == ".s" then
print(table.concat(stack, ", "))
else
table.insert(stack, elem)
end
end
local stack = {}
while true do
local line = io.read():split(" ")
for _, v in ipairs(line) do
calc(stack, v)
end
end
|
ESX = ESX
if Config.UseOldESX then
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj)
ESX = obj
end)
end
RegisterNetEvent('mb_blackout:triggerblackout')
AddEventHandler('mb_blackout:triggerblackout', function()
BlackoutOn()
Wait(Config.BlackoutDuration *1000)
BlackoutOff()
end)
RegisterNetEvent('mb_blackout:triggeranim')
AddEventHandler('mb_blackout:triggeranim', function(source)
local playerPed = PlayerPedId()
local pedCoords = GetEntityCoords(playerPed)
local tabletProp = GetHashKey('prop_cs_tablet')
local animdict = 'amb@code_human_in_bus_passenger_idles@female@tablet@idle_a'
local anim = 'idle_a'
local pedX, pedY, pedZ = table.unpack(pedCoords)
prop = CreateObject(tabletProp, pedX, pedY, pedZ + 0.2, true, true, true)
AttachEntityToEntity(prop, playerPed, GetPedBoneIndex(playerPed, 28422), -0.05, 0.0, 0.0, 0.0, 0.0, 0.0, true, true, false, true, 1, true) -- Thanks to Dullpear_dev since the prop placement is taken from dpEmotes
RequestAnimDict(animdict)
while not HasAnimDictLoaded(animdict) do
Wait(0)
end
TaskPlayAnim(playerPed, animdict, anim, 8.0, -8, -1, 49, 0, 0, 0, 0)
Wait(Config.HackingTime *1000)
ClearPedSecondaryTask(playerPed)
DeleteObject(prop)
end)
function BlackoutOn()
if not Config.UsevSync then
SetArtificialLightsState(true)
end
if Config.Soundeffect then
PlaySoundFrontend(-1, "Power_Down", "DLC_HEIST_HACKING_SNAKE_SOUNDS", 1)
end
if Config.ShowVehicleLights then
SetArtificialLightsStateAffectsVehicles(false)
end
if Config.SendNotification then
ESX.ShowAdvancedNotification(Config.BlackoutOnNotifyTitle, '', Config.BlackoutOnNotifyText, Config.NotifyImageBlackoutON, 5, false)
end
end
function BlackoutOff()
if not Config.UsevSync then
SetArtificialLightsState(false)
end
if Config.Soundeffect then
PlaySoundFrontend(-1, "police_notification", "DLC_AS_VNT_Sounds", 1)
end
if Config.ShowVehicleLights then
SetArtificialLightsStateAffectsVehicles(true)
end
if Config.SendNotification then
ESX.ShowAdvancedNotification(Config.BlackoutOffNotifyTitle, '', Config.BlackoutOffNotifyText, Config.NotifyImageBlackoutOFF, 5, false)
end
end
AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
BlackoutOff()
end
end)
|
local ltml = require("ltml")
local utils = require("ltml.utils")
local files = {...}
for _, v in pairs(files) do
local template = utils.readAll(v..".ltml.lua")
local htmlTree = ltml.execute(template)
local htmlSource = ltml.render(htmlTree)
utils.writeAll(v..".html", htmlSource)
end
|
local ns, queue, id, message, timestamp = ARGV[1], ARGV[2], ARGV[3], ARGV[4], ARGV[5]
redis.call('SADD', ns..':queues', queue)
redis.call('HSET', ns..':'..queue..':messages', id, message)
redis.call('SREM', ns..':'..queue..':queued_ids', id)
redis.call('LREM', ns..':'..queue..':queue', 1, id)
local joined = queue..'||'..id
redis.call('ZREM', ns..':schedule', joined)
redis.call('ZADD', ns..':schedule', timestamp, joined)
|
-- unit-test.lua
-- Helper functions for doing unit tests.
require "table-helpers"
unit_test = unit_test or {}
function get_printable(val)
if val == nil then
return "nil"
end
if type(val) == "boolean" then
if val then
return "true"
else
return "false"
end
end
return val
end
function unit_test.assert(expected, actual, failure_message)
local success = true
if type(actual) == "table" and not table.equal(expected, actual) then
success = false
elseif type(actual) ~= "table" and expected ~= actual then
success = false
end
if not success then
print("== FAILURE! ==\n" .. failure_message)
print("Expected: " .. get_printable(expected))
print("Actual: " .. get_printable(actual))
print("==============\n")
return false
end
return true
end
function unit_test.run_test(test, name)
local result = test()
if result then
print(name .. " [SUCCESS]")
else
print(name .. " [FAIL ]")
end
end
|
-- CONFIGURATION:
-- tweak these variables however you like.
-- let me know if you need any more.
lmn = lmn or {}
lmn.config = {
-- whether or not you should start with the perk
spawn_perk_at_new_game = false,
-- whether or not the perk should add the vanilla leg attack
enable_leg_attacks = false,
-- not sure if the following option still works or not
ignores_oil_slippyness = false,
-- speed multiplier when enough legs are touching
velocity_multiplier_at_full_grip = 1.50,
-- how fast velocity should change in up/down directions
climb_acceleration = 500,
-- number of limbs from 1 perk
limb_count = 6,
-- length of legs from 1 perk
limb_length = 45,
stack_perk = {
-- additional speed multiplier for each stacked perk beyond the first
velocity_multiplier_at_full_grip = 0.25,
-- the upper limit for speed multiplier from stacking the perk
velocity_multiplier_limit = 3.00,
-- additional leg count for each stacked perk beyond the first
limb_count_add = 1,
-- the upper limit for leg count from stacking the perk
limb_count_limit = 8,
-- additional leg length as a portion of original 'limb_length' for each stacked perk beyond the first
limb_length_multiplier = 0.2,
-- the upper limit for leg length from stacking the perk
limb_length_limit = 70,
}
}
|
g_Settings = {}
addEventHandler("onClientResourceStart", resourceRoot,
function ()
triggerServerEvent("onClientResourceStart", localPlayer)
end,
false)
addEvent("ipb.syncSettings", true)
addEventHandler("ipb.syncSettings", localPlayer,
function (settings)
g_Settings = settings
end,
false)
addEvent("ipb.updateSetting", true)
addEventHandler("ipb.updateSetting", resourceRoot,
function (name, value)
g_Settings[name] = value
end,
false)
|
local cutorch = require "cutorch"
local cunn = require "cunn"
local nn = require "nn"
local nngraph = require "nngraph"
local argparse = require "argparse"
-- get command line arguments
local parser = argparse()
parser:flag("--gates", "whether to concatenate the gate for input to the model")
parser:option("--test", "which test file to use")
parser:option("--model", "which model to use")
local args = parser:parse()
-- set parameters
local opt = {}
opt.testFile = '/local/filespace/lr346/disco/experiments/negation/nncg-negation/traindata/' .. args['test'] .. '.test'
opt.modelFile = '/local/filespace/lr346/disco/experiments/negation/nncg-negation/eacl17/models/' .. args['test'] .. '/model_' .. args['model'] .. '.net'
opt.predFile = '/local/filespace/lr346/disco/experiments/negation/nncg-negation/eacl17/predictions/' .. args['test'] .. '/model_' .. args['model'] .. '.out'
opt.forwardGates = args['gates']
opt.embedSize = 300
opt.gateSize = 300
opt.useGPU = true -- use CUDA_VISIBLE_DEVICES to set the GPU you want to use
-- read model
print ("Reading model", opt.modelFile)
ged = torch.load(opt.modelFile)
print("Counting test examples")
io.input(opt.testFile)
linecount = 0
for line in io.lines() do
linecount = linecount + 1
end
io.input():close()
opt.numTestExx = linecount
print("...", tostring(opt.numTestExx))
print ("Reading test data")
testdata = torch.Tensor(opt.numTestExx, 2*opt.embedSize)
testwords = {}
io.input(opt.testFile)
linecount = 0
for line in io.lines() do
linecount = linecount + 1
valcount = 0
for num in string.gmatch(line, "%S+") do
valcount = valcount + 1
if valcount == 1 then
testwords[linecount] = num
else
testdata[linecount][valcount - 1] = tonumber(num)
end
end
end
print "Predicting"
print(ged)
predFileStream = io.open(opt.predFile, "w")
for t = 1, testdata:size(1) do
local input_word = testwords[t]
local input = testdata[t]:narrow(1, 1, opt.embedSize):resize(1, opt.embedSize)
local gate = testdata[t]:narrow(1, opt.embedSize + 1, opt.embedSize):resize(1, opt.embedSize)
if opt.useGPU then
input = input:cuda()
gate = gate:cuda()
end
local output = torch.zeros(opt.embedSize)
if opt.forwardGates then
output = ged:forward(torch.cat(input, gate))
else
output = ged:forward(input)
end
predFileStream:write(input_word .. "\t[")
for k = 1, output:size(2) do
predFileStream:write(output[1][k] .. ", ")
end
predFileStream:write("]\n")
end
|
-- utility for lua 5.2
local setfenv = setfenv or
function(fn, env)
local i = 1
while true do
local name = debug.getupvalue(fn, i)
if name == "_ENV" then
debug.upvaluejoin(fn, i, (function()
return env
end), 1)
break
elseif not name then
break
end
i = i + 1
end
return fn
end
local function newproxygc(func)
local proxy
if newproxy then -- 5.1
proxy = newproxy(true)
getmetatable(proxy).__gc = func
else -- 5.2
proxy = {}
setmetatable(proxy, {__gc=func})
end
return proxy
end
return function(func, mutex)
local threads = require 'threads'
assert(type(func) == 'function', 'function, [mutex] expected')
assert(mutex == nil or getmetatable(threads.Mutex).__index == getmetatable(mutex).__index, 'function, [mutex] expected')
-- make sure mutex is freed if it is our own
local proxy
if not mutex then
mutex = threads.Mutex()
proxy = newproxygc(
function()
mutex:free()
end
)
end
local mutexid = mutex:id()
local safe =
function(...)
local threads = require 'threads'
local mutex = threads.Mutex(mutexid)
local unpack = unpack or table.unpack
mutex:lock()
local res = {func(...)}
mutex:unlock()
return unpack(res)
end
-- make sure mutex is freed if it is our own
if proxy then
setfenv(safe, {require=require, unpack=unpack, table=table, proxy=proxy})
end
return safe
end
|
Locales['es'] = {
['press_collect_coke'] = 'Presiona ~INPUT_CONTEXT~ para cosechar la Coca',
['press_process_coke'] = 'Presiona ~INPUT_CONTEXT~ para tratar la Coca',
['press_sell_coke'] = 'Presiona ~INPUT_CONTEXT~ para vender la Coca',
['press_collect_meth'] = 'Presiona ~INPUT_CONTEXT~ para recoger ingredientes del LSD',
['press_process_meth'] = 'Presiona ~INPUT_CONTEXT~ para cocinar el LSD',
['press_sell_meth'] = 'Presiona ~INPUT_CONTEXT~ para vender el LSD',
['press_collect_weed'] = 'Presiona ~INPUT_CONTEXT~ para cosechar el Hierbón',
['press_process_weed'] = 'Presiona ~INPUT_CONTEXT~ para embolsar el Hierbón',
['press_sell_weed'] = 'Presiona ~INPUT_CONTEXT~ para vender el Hierbón',
['press_collect_opium'] = "Presiona ~INPUT_CONTEXT~ para cosechar el Opio",
['press_process_opium'] = "Presiona ~INPUT_CONTEXT~ para tratar el Opio",
['press_sell_opium'] = "Presiona ~INPUT_CONTEXT~ para vender el Opio",
['act_imp_police'] = 'Acción ~r~imposible~s~, ~b~policias~s~: ',
['inv_full_coke'] = 'No puedes recoger mas cocaina, tu inventario está ~r~lleno~s~',
['pickup_in_prog'] = '~y~Recogida en curso~s~...',
['too_many_pouches'] = 'Tienes demasiadas bolsas',
['not_enough_coke'] = 'No tienes suficiente hoja de coca para ~r~fabricar~s~',
['packing_in_prog'] = '~y~Fabricación en curso~s~...',
['no_pouches_sale'] = 'No tienes mas bolsas para ~r~vender~s~',
['sold_one_coke'] = 'Has vendido ~g~1 Gramo de Coca~s~',
['sale_in_prog'] = '~g~Venta en curso~s~...',
['inv_full_meth'] = 'No puedes recoger mas ingredientes, tu inventario está ~r~lleno~s~',
['not_enough_meth'] = 'No tienes suficientes ingredientes para ~r~fabricar~s~ mas LSD',
['sold_one_meth'] = 'Has vendido ~g~1 Bote de LSD~s~',
['inv_full_weed'] = 'No puedes recoger mas hierba, tu inventario está ~r~lleno~s~',
['not_enough_weed'] = 'No tienes suficiente hierba para ~r~embolsar~s~',
['sold_one_weed'] = 'Has vendido ~g~1 Bolsa de Hierbón~s~',
['used_one_weed'] = 'Has gastado una bolsa de ~b~hierbón',
['inv_full_opium'] = 'No puedes recoger mas hierba, tu inventario está ~r~lleno~s~',
['not_enough_opium'] = 'No tienes sufiente Opio para ~r~fabricar~s~',
['sold_one_opium'] = 'Has vendido ~g~1 Bolsa de Opio~s~',
['used_one_opium'] = 'Has gastado una bolsa de ~b~Opio',
}
|
Locales['es'] = {
-- Errores
['ERROR'] = "Ocurrio un error, vuelve a intentarlo. Si esto vuelve a ocurrir contacta con un administrador.",
['NOT_ENOUGH_MONEY'] = "~r~No~w~ tienes suficiente dinero.",
['PLAYER_IN_VEHICLE'] = "No puedes hacer abrir este menu en un vehiculo.",
['NOT_OWNED_VEHICLES'] = "No tienes ningun vehiculo a tu nombre.",
-- Garage
['GARAGE_BLIP_NAME'] = "Garage",
['GARAGE_SPAWN_MARKER'] = "Presiona ~g~[E]~w~ para ~o~sacar tu vehiculo~w~.",
['GARAGE_DELETE_MARKER'] = "Presiona ~g~[E]~w~ para ~o~guardar tu vehiculo~w~.",
-- Guardar vehiculo
['TITLE_FIX_VEHICLE'] = "Debes reparar el vehiculo para poder guardarlo",
['FIX_VEHICLE_MENU_YES'] = "Reparar (<font color=green>%s$</font>)",
['FIX_VEHICLE_MENU_NO'] = "No guardar",
['VEHICLE_STORED_SUCCESS'] = "Tu vehiculo fue guardado ~g~correctamente~w~.",
['NOT_YOUR_VEHICLE'] = "Este vehiculo ~r~no~w~ es tuyo",
-- Sacar vehiculos
['TITLE_MY_VEHICLES'] = "Mis vehiculos",
['SHOW_VEHICLE_STORED'] = '%s - <font color="green">En el garage</font>',
['SHOW_VEHICLE_IMPOUNDED'] = '%s - <font color="red">Embargado</font>',
['NO_SPAWN_POINT'] = "No se encontro ningun lugar para poder spawnear el vehiculo, intentalo nuevamente en unos momentos.",
['TITLE_IMPOUNDED_VEHICLE'] = "El auto fue remolcado, debes pagar para retirarlo.",
['IMPOUNDED_VEHICLE_YES'] = 'Pagar (<font color="green">%d$</font>)',
['IMPOUNDED_VEHICLE_NO'] = "Ir atras",
['IMPOUND_COOLDOWN'] = "Todavia no puedes volver a utilizar el remolcado.",
-- Mensajes exclusivos cuando el embargado (impound) esta desactivado.
['SHOW_VEHICLE_NOT_STORED'] = '%s - <font color="red">Fuera del garage</font>',
['VEHICLE_NOT_IN_GARAGE'] = 'Este vehiculo ~r~no esta~w~ en el garage.'
}
|
local Font_raceMessageText = {}
Font_raceMessageText.font = "Mister Belvedere"
Font_raceMessageText.size = ScreenScale(40)
Font_raceMessageText.weight = 400
Font_raceMessageText.blursize = 0
Font_raceMessageText.scanlines = 0
Font_raceMessageText.antialias = true
Font_raceMessageText.additive = false
Font_raceMessageText.underline = false
Font_raceMessageText.italic = false
Font_raceMessageText.strikeout = false
Font_raceMessageText.symbol = false
Font_raceMessageText.rotary = false
Font_raceMessageText.shadow = false
Font_raceMessageText.outline = false
surface.CreateFont("raceMessageText", Font_raceMessageText )
--surface.CreateFont("Mister Belvedere", ScreenScale(40), 400, true, false, "raceMessageText")
local message = ""
local messages = {}
local messageStartDel = 2
local messageStayDel = 1
local messageEndDel = 1
local messageStage = 0
local messageTime = CurTime()
local isWideScreen = true
local noInterruptDel = CurTime()
local startPosX = 0
local startPosY = 0
local newPosX = 0
local newPosY = 0
local percent = 0
local col = Color(255,255,255,255)
local sepSign = "@"
local theTime = 0
local forceShowMessage = false
local lastId = 0
function SCarRaceMesasge_DrawHud()
if LocalPlayer().Alive and !LocalPlayer():Alive() then return end
if(LocalPlayer().GetActiveWeapon and (LocalPlayer():GetActiveWeapon() == NULL or LocalPlayer():GetActiveWeapon() == "Camera")) then return end
if GetViewEntity():GetClass() == "gmod_cameraprop" then return end
local veh = LocalPlayer():GetVehicle()
local ply = LocalPlayer()
if (IsValid(veh) or forceShowMessage == true) && messageStage >= 1 then
--Checking if the user have a widescreen res or not.
isWideScreen = true
if (ScrW() / ScrH()) <= (4 / 3) then
isWideScreen = false
end
if messageStage == 1 then
percent = ((messageTime - CurTime()) / messageStartDel)
col = Color(255,255,255, ((1-math.Clamp( percent, 0, 1 )) * 255))
elseif messageStage == 2 then
percent = ((messageTime - CurTime()) / messageStayDel)
col = Color(255,255,255,255)
elseif messageStage == 3 then
percent = ((messageTime - CurTime()) / messageEndDel)
col = Color(255,255,255, (math.Clamp( percent, 0, 1 ) * 255))
end
newPosX = (ScrW() / 2)
newPosY = (ScrH() / 2)
if lastId == 1 or lastId == 2 then
newPosX = (ScrW() / 2)
newPosY = (ScrH() / 10)
end
if percent <= 0 then
messageStage = messageStage + 1
if messageStage == 2 then
messageTime = CurTime() + messageStayDel
elseif messageStage == 3 then
messageTime = CurTime() + messageEndDel
elseif messageStage > 3 then
messageStage = 0
forceShowMessage = false
end
end
for k, v in ipairs(messages) do
draw.SimpleTextOutlined( v, "raceMessageText", newPosX, (newPosY + (k-1) * ScreenScale(30)), col, 1, 1, 2, Color( 0, 0, 0, 255 ) )
end
else
messageStage = 0
end
end
hook.Add( "HUDPaint", "SCarRaceMesasge_DrawHud", SCarRaceMesasge_DrawHud )
--UserMessages
function GetSCarRaceMessageFromServer( data )
if noInterruptDel <= CurTime() or id == 6 then
message = data:ReadString()
local id = data:ReadShort()
messageStage = 1
startPosX = 0
startPosY = ScrH()
if id == 1 then
LocalPlayer():EmitSound("buttons/button17.wav",100,100)
message = SCar_ConvertTimeToString(data:ReadFloat())
elseif id == 2 then
LocalPlayer():EmitSound("buttons/button17.wav",100,50)
message = "Lap "..SCar_ConvertTimeToString(data:ReadFloat())
elseif id == 3 then
LocalPlayer():EmitSound("car/raceSignal.mp3",100,100)
message = "Finish "..SCar_ConvertTimeToString(data:ReadFloat())
elseif id == 4 then
LocalPlayer():EmitSound("car/raceSignal.mp3",100,200)
forceShowMessage = true
elseif id == 5 then
forceShowMessage = true
elseif id == 6 then
forceShowMessage = true
message = "Back up!@Too close to starting line!"
noInterruptDel = CurTime() + 1
end
messageTime = CurTime() + messageStartDel
messages = string.Explode(sepSign, message)
lastId = id
end
end
usermessage.Hook( "GetSCarRaceMessageFromServer", GetSCarRaceMessageFromServer )
|
-- create our global container object
local shippingCo = {
configConstants = {
MAX_ITEMS_PER_ORDER = 3,
SCALE_FACTOR = 0.2,
SHIPPING_CO_STARTING_LEVEL = 1
},
objectiveItems = {
"factory-shipping-package",
"oil-shipping-package",
"rail-shipping-package",
"modular-shipping-package"
}
}
local function isItemAlreadyListedInOrder(order, itemName)
for key, item in pairs(order) do
if item.name == itemName then
return true
end
end
return false
end
-- set the circuit signals for one or all receiver entities
local function update_receivers(entity)
if entity or ((not entity) and #global.receivers) then
local signalParameters = { parameters = {{index=1,signal={type="virtual",name="signal-offworldshippingco-level"},count=global.shippingCoLevel}} }
if global.shippingCoOrder then
for index, item in ipairs(global.shippingCoOrder) do
table.insert(signalParameters.parameters,
{index=index+1,signal={type="item",name=item.name},count=item.quantityRequired-item.quantityLaunched}
)
end
end
for index, receiver in ipairs(entity and {{entity = entity}} or global.receivers) do
if receiver.entity.valid then
receiver.entity.get_control_behavior().parameters = signalParameters
else
if not entity then
table.remove(global.receivers, index)
end
end
end
end
end
-- generate an order
local function generate_order(number_of_items)
-- hardcoded for now, we will try and randomly generate these later.
local order = {}
for i=1, number_of_items do
local randomName = ""
repeat
randomName = shippingCo.objectiveItems[math.random(#shippingCo.objectiveItems)]
until (isItemAlreadyListedInOrder(order, randomName) == false)
local item = {
name = randomName,
quantityRequired = math.ceil( math.random(5) * (shippingCo.configConstants.SCALE_FACTOR + global.shippingCoLevel) ),
quantityLaunched = 0
}
table.insert(order, item)
end
global.shippingCoOrderIsComplete = false
return order
end
local function gui_open_frame(player)
local frame = player.gui.left["shipping-co-order-frame"]
if frame then
frame.destroy()
end
frame = player.gui.left.add {
type = "frame",
caption = string.format("Shipping Order Details (Level: %s)", global.shippingCoLevel),
name = "shipping-co-order-frame",
direction = "vertical"
}
if global.shippingCoOrder then
for index, item in ipairs(global.shippingCoOrder) do
frame.add {
type = "label",
caption = string.format("%s launched : %d / %d", item.name, item.quantityLaunched, item.quantityRequired)
}
end
end
end
local function check_order_complete()
if global.shippingCoOrder then
for index, item in ipairs(global.shippingCoOrder) do
if (item.quantityLaunched < item.quantityRequired) then
return false
end
end
end
return true
end
script.on_event( defines.events.on_tick, function(event)
if not global.shippingCoLevel then
global.shippingCoLevel = shippingCo.configConstants.SHIPPING_CO_STARTING_LEVEL
end
if not global.shippingCoOrder then
global.shippingCoOrder = generate_order(math.random(shippingCo.configConstants.MAX_ITEMS_PER_ORDER))
update_receivers()
end
for i, player in pairs(game.connected_players) do
if game.forces.player.technologies["shipping-packages"].researched then
if player.gui.top.shippingCoOrderButton == nil then
player.gui.top.add{ type = "button", name="shippingCoOrderButton", caption = "Shipping Order" }
end
if global.shippingCoOrderIsComplete then
player.print("Shipping Order complete! Recieving new order!")
end
end
end
if global.shippingCoOrderIsComplete then
global.shippingCoLevel = global.shippingCoLevel + 1
global.shippingCoOrder = generate_order(math.random(shippingCo.configConstants.MAX_ITEMS_PER_ORDER))
update_receivers()
for i, player in pairs(game.connected_players) do
gui_open_frame(player)
end
end
end)
script.on_event(defines.events.on_rocket_launched, function(event)
if global.shippingCoOrder then
for index, item in ipairs(global.shippingCoOrder) do
item.quantityLaunched = item.quantityLaunched + event.rocket.get_item_count(item.name)
end
update_receivers()
global.shippingCoOrderIsComplete = check_order_complete()
end
for _, player in pairs(game.players) do
gui_open_frame(player)
end
end)
script.on_event( defines.events.on_gui_click, function(event)
local element = event.element
local player = game.players[event.player_index]
if element.name == "shippingCoOrderButton" then
local frame = player.gui.left["shipping-co-order-frame"]
if frame then
frame.destroy()
else
gui_open_frame(player)
end
end
end )
local function on_built_entity( event )
local entity = event.created_entity
if entity.name == "shipping-order-receiver" then
table.insert( global.receivers, {entity = entity} )
update_receivers(entity)
end
end
script.on_event(defines.events.on_built_entity, on_built_entity )
script.on_event(defines.events.on_robot_built_entity, on_built_entity )
local function disable_satelite_dialog()
-- just to make sure we don't accidently finish the game!
if remote.interfaces["silo_script"] then
remote.call("silo_script","set_show_launched_without_satellite", false)
end
end
local function destroy_gui()
for i, player in pairs(game.connected_players) do
button = player.gui.top["shippingCoOrderButton"]
frame = player.gui.left["shipping-co-order-frame"]
if frame then
frame.destroy()
end
if button then
button.destroy()
end
end
end
script.on_init(function()
disable_satelite_dialog()
destroy_gui()
global.receivers = global.receivers or {}
end)
script.on_configuration_changed(function()
disable_satelite_dialog()
destroy_gui()
global.receivers = global.receivers or {}
end)
|
part_type{
name1 : int,
whatsup : int32,
test_bool : bool,
interactions : uint32,
}
sym_pairwise_kernel test_kernel(part1, part2, r2)
part1.interactions = part1.interactions + 1
part2.interactions = part2.interactions + 1
local x = 3 + 2
end
kernel name_kernel( part1, config)
if part1.core_part_space.cutoff == 2.3 then
part1.core_part_space.pos_x = 2.534
end
end
function lua_function(someargs, ...)
for i=1, select("#", ...) do
print(select(i, ...))
end
local k = "blah"
local a = {"thing1", "thing2", k, sin(30)}
a["food"] = "pizza"
a.also_food = "potato"
a.long_quote = [[ thing1
whoami
thing2]]
end
local format = require("std/format")
dsl_main ()
local timestep = 0.001
local end_time = 1.0
local time = 0.0
while time < end_time do
dsl_invoke(name_kernel, test_kernel)
format.println("Hello")
time = time + timestep
end
end
|
local conf_login = {}
conf_login.c2s = [[
.package {
type 0 : integer
session 1 : integer
}
handshake 1 {
request {
ckey 0 : string
openid 1 : string
}
response {
skey 0 : string
challenge 1 : string
}
}
auth 2 {
request {
hchallenge 0 : string
etoken 1 : string
}
response {
code 0 : integer
sessionid 1 : integer
token 2 : string
}
}
]]
conf_login.s2c = [[
.package {
type 0 : integer
session 1 : integer
}
]]
return conf_login
|
local test = {}
local stream = require 'stream'
function test.new()
local x = 0
local function tail()
x = x + 1
return stream.new(x, tail)
end
local s0 = stream.new(x, tail)
local s1 = s0.tail
local s2 = s1.tail
assert(s0.head == 0)
assert(s1.head == 1)
assert(s2.head == 2)
assert(s2 == s0.tail.tail)
end
function test.cons()
local s = stream.cons('X', 'STREAM')
assert(s.head == 'X')
assert(s.tail == 'STREAM')
end
function test.make()
local s = stream.make(ipairs{'A', 'B', 'C'})
assert(s.head[1] == 1 and s.head[2] == 'A')
assert(s.tail.head[1] == 2 and s.tail.head[2] == 'B')
assert(s.tail.tail.head[1] == 3 and s.tail.tail.head[2] == 'C')
end
function test.zip()
local s1 = stream.sequence(0)
local s2 = stream.cons('A', stream.cons('B', stream.cons('C')))
local s3 = stream.duplicate('*')
local s = stream.zip(s1, s2, s3)
local h0 = s.head
local h1 = s.tail.head
local h2 = s.tail.tail.head
assert(s.tail.tail.tail == nil)
assert(h0[1] == 0)
assert(h0[2] == 'A')
assert(h0[3] == '*')
assert(h1[1] == 1)
assert(h1[2] == 'B')
assert(h1[3] == '*')
assert(h2[1] == 2)
assert(h2[2] == 'C')
assert(h2[3] == '*')
end
function test.duplicate()
local s = stream.duplicate('X')
assert(s.head == 'X')
assert(s.tail.head == 'X')
assert(s.tail.tail.head == 'X')
end
function test.sequence()
local s = stream.sequence(0)
assert(s.head == 0)
assert(s.tail.head == 1)
assert(s.tail.tail.head == 2)
end
function test.all()
assert(stream.make(ipairs{1, 2, 3, 4, 5}):all(function(x)
return x[2] > 0
end))
assert(not stream.make(ipairs{0, 2, 3, 4, 5}):all(function(x)
return x[2] > 0
end))
assert(not stream.make(ipairs{1, 2, 0, 4, 5}):all(function(x)
return x[2] > 0
end))
assert(not stream.make(ipairs{1, 2, 3, 4, 0}):all(function(x)
return x[2] > 0
end))
end
function test.any()
assert(not stream.make(ipairs{1, 2, 3, 4, 5}):any(function(x)
return x[2] == 0
end))
assert(stream.make(ipairs{0, 2, 3, 4, 5}):any(function(x)
return x[2] == 0
end))
assert(stream.make(ipairs{1, 2, 0, 4, 5}):any(function(x)
return x[2] == 0
end))
assert(stream.make(ipairs{1, 2, 3, 4, 0}):any(function(x)
return x[2] == 0
end))
end
function test.fold()
local s = stream.make(ipairs{3, 1, 7, 4, 9}):fold(0, function(a, x)
return a + x[2]
end)
assert(s == 24)
end
function test.force()
local l = {'A', 'B', 'C'}
local s0 = stream.make(ipairs(l))
local s1 = s0:force()
l[1], l[2], l[3] = 'X', 'Y', 'Z'
assert(s0 == s1)
assert(s0.head[2] == 'A')
assert(s0.tail.head[2] == 'B')
assert(s0.tail.tail.head[2] == 'C')
end
function test.walk()
local xs = ''
local s0 = stream.make(ipairs{'A', 'B', 'C'})
local s1 = s0:walk(function(x)
xs = xs .. x[2]
end)
assert(s0 == s1)
assert(xs == 'ABC')
end
function test.map()
local s = stream.sequence(0):map(function(x)
return 2 * x
end)
assert(s.head == 0)
assert(s.tail.head == 2)
assert(s.tail.tail.head == 4)
end
function test.filter()
local s0 = stream.sequence(0):filter(function(x)
return x % 2 == 0
end)
assert(s0.head == 0)
assert(s0.tail.head == 2)
assert(s0.tail.tail.head == 4)
local s1 = stream.sequence(0):filter(function(x)
return x % 2 == 1
end)
assert(s1.head == 1)
assert(s1.tail.head == 3)
assert(s1.tail.tail.head == 5)
end
function test.take()
assert(stream.sequence(0):take(1000):fold(0, function(a, x)
return a + x
end) == 499500)
assert(stream.sequence(0):take(function(x)
return x < 1000
end):fold(0, function(a, x)
return a + x
end) == 499500)
end
function test.drop()
assert(stream.sequence(0):drop(1000).head == 1000)
assert(stream.sequence(0):drop(function(x)
return x < 1000
end).head == 1000)
end
function test.cut()
assert(stream.sequence(0):take(1000):cut(500):fold(0, function(a, x)
return a + x
end) == 124750)
assert(stream.sequence(0):take(1000):cut(function(x)
return x >= 500
end):fold(0, function(a, x)
return a + x
end) == 124750)
end
function test.concat()
local s1 = stream.cons('A', stream.cons('B'))
local s2 = stream.duplicate('*'):take(2)
local s3 = stream.sequence(0)
local s = nil .. s1 .. nil .. s2 .. nil .. s3 .. nil
assert(s.head == 'A')
assert(s.tail.head == 'B')
assert(s.tail.tail.head == '*')
assert(s.tail.tail.tail.head == '*')
assert(s.tail.tail.tail.tail.head == 0)
assert(s.tail.tail.tail.tail.tail.head == 1)
assert(s.tail.tail.tail.tail.tail.tail.head == 2)
end
return test
|
return LoadActor( THEME:GetPathS("", "_prompt") ) .. {
StartTransitioningCommand=cmd(play);
};
|
-------------------------------------------------------------------------------
--
-- tek.ui.class.handle
-- Written by Timm S. Mueller <tmueller at schulze-mueller.de>
-- See copyright notice in COPYRIGHT
--
-- OVERVIEW::
-- [[#ClassOverview]] :
-- [[#tek.class : Class]] /
-- [[#tek.class.object : Object]] /
-- [[#tek.ui.class.element : Element]] /
-- [[#tek.ui.class.area : Area]] /
-- [[#tek.ui.class.frame : Frame]] /
-- [[#tek.ui.class.widget : Widget]] /
-- Handle ${subclasses(Handle)}
--
-- Implements a handle that can be dragged along the axis of the Group's
-- orientation. It reassigns Weights to its flanking elements.
--
-- OVERRIDES::
-- - Area:askMinMax()
-- - Area:checkFocus()
-- - Area:draw()
-- - Class.new()
-- - Area:passMsg()
-- - Area:show()
--
-------------------------------------------------------------------------------
local ui = require "tek.ui".checkVersion(112)
local Widget = ui.require("widget", 25)
local floor = math.floor
local insert = table.insert
local ipairs = ipairs
local max = math.max
local min = math.min
local Handle = Widget.module("tek.ui.class.handle", "tek.ui.class.widget")
Handle._VERSION = "Handle 7.2"
-------------------------------------------------------------------------------
-- Class implementation:
-------------------------------------------------------------------------------
function Handle.new(class, self)
self = self or { }
self.AutoPosition = false
self.Mode = self.Mode or "button"
self.Move0 = false
self.MoveMinMax = { }
self.Orientation = false
self.SizeList = false
return Widget.new(class, self)
end
-------------------------------------------------------------------------------
-- setup: overrides
-------------------------------------------------------------------------------
function Handle:setup(app, win)
local o = self:getGroup().Orientation == "horizontal"
self.Orientation = o
if o then
self.Width = "auto"
self.MaxHeight = "none"
else
self.MaxWidth = "none"
self.Height = "auto"
end
Widget.setup(self, app, win)
end
-------------------------------------------------------------------------------
-- startMove: internal
-------------------------------------------------------------------------------
function Handle:startMove(x, y)
local g = self:getGroup()
local i1, i3
if self.Orientation then
i1, i3 = 1, 3
self.Move0 = x
else
i1, i3 = 2, 4
self.Move0 = y
end
local free0, free1 = 0, 0 -- freedom
-- local max0, max1 = 0, 0
local nfuc = 0 -- free+unweighted children
local tw, fw = 0, 0 -- totweight, weight per unweighted child
for _, e in ipairs(g.Children) do
local df = 0 -- delta free
local mf = 0 -- max free
local mm = { e.MinMax:get() }
if mm[i3] > mm[i1] then
local er = { e:getRect() }
local emb = { e:getMargin() }
if e.Weight then
tw = tw + e.Weight
else
local s = er[i3] - er[i1] + 1
if s < mm[i3] then
nfuc = nfuc + 1
fw = fw + 0x10000
end
end
df = er[i3] - er[i1] + 1 + emb[i1] +
emb[i3] - mm[i1]
mf = mm[i3] - (er[i3] - er[i1] + 1 + emb[i1] + emb[i3])
end
free1 = free1 + df
-- max1 = max1 + mf
if e == self then
free0 = free1
-- max0 = max1
end
end
free1 = free1 - free0
-- max1 = max1 - max0
-- free0 = min(max1, free0)
-- free1 = min(max0, free1)
if tw < 0x10000 then
if fw == 0 then
fw, tw = 0, 0x10000
else
fw, tw = floor((0x10000 - tw) * 0x100 / (fw / 0x100)), 0x10000
end
else
fw, tw = 0, tw
end
self.SizeList = { { }, { } } -- left, right
local li = self.SizeList[1]
local n = 0
local w = 0x10000
for _, e in ipairs(g.Children) do
local mm = { e:getMinMax() }
local nw
if mm[i3] > mm[i1] then
if not e.Weight then
n = n + 1
if n == nfuc then
nw = w -- rest
else
nw = fw -- weight of an unweighted child
end
else
nw = e.Weight
end
w = w - nw
insert(li, { element = e, weight = nw })
end
if e == self then
li = self.SizeList[2] -- second list
end
end
self.MoveMinMax[1] = -free0
self.MoveMinMax[2] = free1
return self
end
-------------------------------------------------------------------------------
-- doMove: internal
-------------------------------------------------------------------------------
function Handle:doMove(x, y)
local g = self:getGroup()
local xy = (self.Orientation and x or y) -
self.Move0
if xy < self.MoveMinMax[1] then
xy = self.MoveMinMax[1]
elseif xy > self.MoveMinMax[2] then
xy = self.MoveMinMax[2]
end
local tot = self.MoveMinMax[2] - self.MoveMinMax[1]
local totw = xy * 0x10000 / tot
local totw2 = totw
if xy < 0 then
-- left:
for i = #self.SizeList[1], 1, -1 do
local c = self.SizeList[1][i]
local e = c.element
local nw = max(c.weight + totw, 0)
totw = totw + (c.weight - nw)
e.Weight = nw
end
-- right:
for i = 1, #self.SizeList[2] do
local c = self.SizeList[2][i]
local e = c.element
local nw = min(c.weight - totw2, 0x10000)
totw2 = totw2 - (c.weight - nw)
e.Weight = nw
end
elseif xy > 0 then
-- left:
for i = #self.SizeList[1], 1, -1 do
local c = self.SizeList[1][i]
local e = c.element
local nw = min(c.weight + totw, 0x10000)
totw = totw - (nw - c.weight)
e.Weight = nw
end
-- right:
for i = 1, #self.SizeList[2] do
local c = self.SizeList[2][i]
local e = c.element
local nw = max(c.weight - totw2, 0)
totw2 = totw2 + (nw - c.weight)
e.Weight = nw
end
end
g:rethinkLayout(1, true)
end
-------------------------------------------------------------------------------
-- passMsg: overrides
-------------------------------------------------------------------------------
function Handle:passMsg(msg)
local mx, my = self:getMsgFields(msg, "mousexy")
if msg[2] == ui.MSG_MOUSEBUTTON then
if msg[3] == 1 then -- leftdown:
if self.Window.HoverElement == self and not self.Disabled then
if self:startMove(mx, my) then
self.Window:setMovingElement(self)
end
end
elseif msg[3] == 2 then -- leftup:
if self.Window.MovingElement == self then
self.SizeList = false
self.Window:setMovingElement()
end
self.Move0 = false
end
elseif msg[2] == ui.MSG_MOUSEMOVE then
if self.Window.MovingElement == self then
self:doMove(mx, my)
-- do not pass message to other elements while dragging:
return false
end
end
return Widget.passMsg(self, msg)
end
-------------------------------------------------------------------------------
-- checkFocus: overrides
-------------------------------------------------------------------------------
function Handle:checkFocus()
return false
end
return Handle
|
module("resty.sha", package.seeall)
_VERSION = '0.06'
local ffi = require "ffi"
ffi.cdef[[
typedef unsigned long SHA_LONG;
typedef unsigned long long SHA_LONG64;
enum {
SHA_LBLOCK = 16
};
]];
|
#!/Scr/scr-test-steven/local/bin/lua
-----------------------------------------
---- Tidy Up the NAMD run directory ----
-----------------------------------------
---- Author: Yuhang Wang ----------------
----
---- Date: 06/12/2015 -------------------
----
---- Update:
---- 06/16/2015 ~ clean up & redesign
----
---- Usage: Tidy.lua STAGE --------------
---- Example: "Tidy.lua 1" --------------
-----------------------------------------
-----------------------------------------
-- Load external modules
-----------------------------------------
local Path_M_ = require("path_module")
local Posix_M_ = require("posix")
local File_M_ = require("file_module")
local Sys_M_ = require("lfs")
local TableUtils_M_ = require("tableUtils_module")
-----------------------------------------
-----------------------------------------
-- Check-point: user must specify 1 argument
-----------------------------------------
if #arg ~= 1 then
local msg = "PLEASE SPECIFY YOUR MD STAGE\n"
msg = msg .. "USAGE: tidy.lua stage_number\n"
msg = msg .. "EXAMPLE: tidy.lua 1"
print(msg)
os.exit()
end
-----------------------------------------
-- Read command line arguments
-----------------------------------------
local stage = arg[1]
-----------------------------------------
-----------------------------------------
-- Store all file types and its destination directory
-----------------------------------------
local dict_ext_and_directory = {} -- crate a table
-----------------------------------------
-- Routines
-----------------------------------------
function mkdir_and_amend_dict(dir_target, list_file_extensions, dict_ext_and_directory, Sys_M_)
-- GOAL:
-- 1. make a new directory
-- 2. add a new entry to the dictionary for each item in the 'list_file_extensions'
--
-- INPUT:
-- dir_target: target directory
-- list_file_extensions: list of file extensions
-- dict_ext_and_directory: the target dictionary to be modified
-- Sys_M_: a proxy for the module that has method ".mkdir()"
--
-- USAGE:
-- mkdir_and_amend_dict(dir_target, list_file_extensions, dict_ext_and_directory, Sys_M_)
--
Sys_M_.mkdir(dir_target)
for i, file_extension in pairs(list_file_extensions) do
dict_ext_and_directory[file_extension] = dir_target
end
end
-----------------------------------------
-- Make a global list of lists
-----------------------------------------
local list_all_dir_target = {}
local list_all_file_extensions = {}
-----------------------------------------
-- 1. Restart files
-----------------------------------------
table.insert(list_all_dir_target, Path_M_.join({"..", "restart", "md" .. stage}))
table.insert(list_all_file_extensions, {"coor", "vel", "xsc", "xst"})
-----------------------------------------
-----------------------------------------
-- 2. DCD files
-----------------------------------------
table.insert(list_all_dir_target, Path_M_.join({"..", "dcds", "all"}))
table.insert(list_all_file_extensions, {"dcd"})
-----------------------------------------
-- 3. Log files
-----------------------------------------
table.insert(list_all_dir_target, Path_M_.join({"..", "logs", "md" .. stage}))
table.insert(list_all_file_extensions, {"log"})
-----------------------------------------
-- 4. Submission files
-----------------------------------------
table.insert(list_all_dir_target, Path_M_.join({"..", "submit"}))
table.insert(list_all_file_extensions, {"submit"})
-----------------------------------------
-- 5. NAMD configuration files
-----------------------------------------
table.insert(list_all_dir_target, Path_M_.join({"..", "config"}))
table.insert(list_all_file_extensions, {"conf"})
-----------------------------------------------------
-- Make directories and amend the global dict
-----------------------------------------------------
for i = 1, #list_all_dir_target do
local dir_target = list_all_dir_target[i]
local list_file_extensions = list_all_file_extensions[i]
mkdir_and_amend_dict(dir_target, list_file_extensions, dict_ext_and_directory, Sys_M_)
end
-----------------------------------------------------
----------------------- Main -----------------------
-----------------------------------------------------
print("-----------------------------------------------")
for key,value in pairs(dict_ext_and_directory) do
print(key, value)
end
print("-----------------------------------------------")
local list_files = File_M_.ls(".")
for i, file_name in pairs(list_files) do
local ext = File_M_.get_file_ext(file_name)
local dir_destination = dict_ext_and_directory[ext]
if dir_destination ~= nil then
local cmd = table.concat({"mv", file_name, dir_destination}, " ")
print(cmd)
os.execute(cmd)
end
end
|
include("shared.lua");
AddCSLuaFile("cl_init.lua");
AddCSLuaFile("shared.lua");
-- Called when the entity initializes.
function ENT:Initialize()
self:SetModel("models/props_junk/rock001a.mdl") ;
self:PhysicsInit(SOLID_VPHYSICS);
self:SetMoveType(MOVETYPE_VPHYSICS);
self:SetSolid(SOLID_VPHYSICS);
self:SetMaterial("models/effects/splode1_sheet");
local phys = self:GetPhysicsObject();
if phys:IsValid() then
phys:Wake();
phys:EnableMotion(false);
end;
self:SpawnProps();
self:startFire();
end;
-- Called when the entity is spawned.
function ENT:SpawnProps()
local rotation1 = Vector(0, 0, 45);
local angle1 = self:GetAngles();
angle1:RotateAroundAxis(angle1:Forward(), rotation1.z);
local rotation2 = Vector(90, 0, 45);
local angle2 = self:GetAngles();
angle2:RotateAroundAxis(angle2:Up(), rotation2.x);
angle2:RotateAroundAxis(angle2:Forward(), rotation2.z);
local rotation3 = Vector(180, 0, 45);
local angle3 = self:GetAngles();
angle3:RotateAroundAxis(angle3:Up(), rotation3.x);
angle3:RotateAroundAxis(angle3:Forward(), rotation3.z);
local rotation4 = Vector(270, 0, 45);
local angle4 = self:GetAngles();
angle4:RotateAroundAxis(angle4:Up(), rotation4.x);
angle4:RotateAroundAxis(angle4:Forward(), rotation4.z);
local Up = 16;
local wood1 = ents.Create("prop_dynamic");
wood1:SetPos(self:GetPos() + self:GetUp() * Up);
wood1:SetAngles(angle1);
wood1:SetModel("models/props_debris/wood_chunk01b.mdl")
wood1:Activate();
wood1:SetParent(self);
wood1:Spawn();
wood1:DeleteOnRemove(self);
local wood2 = ents.Create("prop_dynamic");
wood2:SetPos(self:GetPos() + self:GetUp() * Up);
wood2:SetAngles(angle2);
wood2:SetModel("models/props_debris/wood_chunk01b.mdl")
wood2:Activate();
wood2:SetParent(self);
wood2:Spawn();
wood2:DeleteOnRemove(self);
local wood3 = ents.Create("prop_dynamic");
wood3:SetPos(self:GetPos() + self:GetUp() * Up);
wood3:SetAngles(angle3);
wood3:SetModel("models/props_debris/wood_chunk01b.mdl")
wood3:Activate();
wood3:SetParent(self);
wood3:Spawn();
wood3:DeleteOnRemove(self);
local wood4 = ents.Create("prop_dynamic");
wood4:SetPos(self:GetPos() + self:GetUp() * Up);
wood4:SetAngles(angle4);
wood4:SetModel("models/props_debris/wood_chunk01b.mdl")
wood4:Activate();
wood4:SetParent(self);
wood4:Spawn();
wood4:DeleteOnRemove(self);
end;
function ENT:OnRemove()
self:stopFire();
end;
function ENT:startFire()
self:Ignite(1);
timer.Create( tostring(self:GetCreationID()), 1, 0,
function()
self:Ignite(1);
end);
end;
function ENT:stopFire()
timer.Destroy( tostring(self:GetCreationID()) )
self:Extinguish();
end;
|
local cobras = {
createObject (8397, 2986.353515625, 2110.4641113281, -24.1),
createObject ( 4242, 1657.09998, -4614.7998, -6.7 ),
createObject ( 896, 1555.1, -4426.7002, -74.1, 4.23, 252.488, 62.331 ),
createObject ( 4242, 3312.188, 2075.0918, 1.90003, 0, 0, 94 ),
createObject ( 4242, 3312.188, 2075.0918, -6.89998, 0, 0, 94 ),
createObject ( 4242, 3326.1106, 1875.9769, -6.89998, 0, 0, 94 ),
createObject ( 4242, 3075.229, 1858.4338, -6.89998, 0, 0, 94 ),
createObject ( 4242, 3047.4807, 2256.668, -6.89998, 0, 0, 94 ),
createObject ( 4242, 3298.3652, 2274.2129, -6.89998, 0, 0, 93.999 ),
createObject ( 4242, 3549.2537, 2291.7568, -6.89998, 0, 0, 94 ),
createObject ( 4242, 3563.0706, 2092.7354, -6.89998, 0, 0, 94 ),
createObject ( 4242, 3304.7, 2113.1001, -65.2 ),
createObject ( 9551, 3435.4834, 2077.999, -6.79994, 0, 0, 182.248 ),
createObject ( 900, 3439.0303, 2185.0078, 0.10002, 0, 169.997, 215.998 ),
createObject ( 17029, 3450.1631, 2173.4561, -12.09996, 0, 0, 29.994 ),
createObject ( 17029, 3413.9624, 2189.3682, -12.09996, 0, 0, 13.998 ),
createObject ( 17029, 3454.1013, 2167.3154, -19.39997, 0, 0, 29.994 ),
createObject ( 17029, 3464.467, 2172.4512, -19.39997, 0, 0, 29.994 ),
createObject ( 6295, 3369.0244, 2282.9629, 21.80008, 0, 0, 184 ),
createObject ( 6417, 3369.1987, 2241.7739, -14.4, 0, 0, 184 ),
createObject ( 16350, 3375.4482, 2179.6592, -9.09996, 0, 0, 94 ),
createObject ( 16350, 3350.5081, 2177.9141, -9.09996, 0, 0, 94 ),
createObject ( 16350, 3325.5703, 2176.1714, -9.09996, 0, 0, 94 ),
createObject ( 12817, 3321.2275, 2093.4678, 2.01001, 0, 0, 3.999 ),
createObject ( 13169, 3379.7847, 2107.5854, 2.00003, 0, 0, 4 ),
createObject ( 12818, 3251.6396, 2053.6162, 2.10001, 0, 0, 3.999 ),
createObject ( 8373, 3352.2588, 2210.2158, -31.49993, 270, 179.995, 183.999 ),
createObject ( 7344, 3319.5801, 2210.2373, -39.69992, 0, 0, 94.499 ),
createObject ( 8373, 3339.7888, 2209.3442, -31.49993, 270, 179.995, 184 ),
createObject ( 987, 3343.1187, 2177.4995, 1.90003, 0, 0, 4 ),
createObject ( 987, 3342.2888, 2189.3687, 1.80002, 0, 0, 273.995 ),
createObject ( 987, 3341.458, 2201.2407, 1.80002, 0, 0, 273.995 ),
createObject ( 987, 3366.9397, 2179.4658, 1.90003, 0, 0, 94 ),
createObject ( 987, 3366.1033, 2191.4365, 1.90003, 0, 0, 94 ),
createObject ( 987, 3365.2666, 2203.4072, 1.90003, 0, 0, 94 ),
createObject ( 987, 3364.4287, 2215.3779, 1.90003, 0, 0, 93.999 ),
createObject ( 987, 3363.6912, 2227.3545, 1.90003, 0, 0, 184 ),
createObject ( 8168, 3363.3311, 2182.3198, 3.80002, 0, 0, 289.991 ),
createObject ( 16088, 3360.0146, 2179.582, 0.60001, 0, 0, 93.999 ),
createObject ( 996, 3351.2681, 2179.9741, 2.40003, 0, 0, 184 ),
createObject ( 7893, 3424.0837, 2100.5601, 2.50003, 0, 0, 94 ),
createObject ( 9254, 3415.0784, 2073.0645, 2.60001, 0, 0, 4 ),
createObject ( 18227, 3457.0186, 2032.3894, -15.19995, 0, 0, 325.993 ),
createObject ( 16312, 3387.5999, 2087.583, 2.60001, 0, 344.993, 175.497 ),
createObject ( 9254, 3415.0784, 2073.0645, 2.00003, 0, 0, 4 ),
createObject ( 16312, 3429.1641, 2090.9912, 2.60001, 0, 344.993, 175.497 ),
createObject ( 8406, 3413.708, 2089.8096, 7.50002, 0, 0, 184 ),
createObject ( 4639, 3403.4316, 2087.6875, 3.80002, 0, 0, 3.999 ),
createObject ( 4639, 3419.698, 2088.7251, 3.80002, 0, 0, 4 ),
createObject ( 18239, 3382.9055, 2083.0439, 1.90003, 0, 0, 274.5 ),
createObject ( 7535, 3364.9658, 2021.342, 5.00003, 0, 0, 201.743 ),
createObject ( 10976, 3192.3777, 2023.7428, 2.30002, 0, 0, 94 ),
createObject ( 7191, 3216.6082, 1968.2633, 1.70001, 0, 0, 273.995 ),
createObject ( 7191, 3216.6082, 1968.2633, -3.89995, 0, 0, 273.995 ),
createObject ( 7191, 3216.6082, 1968.2633, -7.79997, 0, 0, 273.995 ),
createObject ( 5114, 3403.2935, 1957.7595, -2.89995, 0, 0, 325.993 ),
createObject ( 12960, 3282.781, 2125.7646, 2.40003, 0, 0, 273.995 ),
createObject ( 12929, 3424.9165, 2048.4912, 2.00003, 0, 0, 273.995 ),
createObject ( 12928, 3424.9165, 2048.4912, 2.00003, 0, 0, 273.995 ),
createObject ( 16092, 3423.2134, 2057.0913, -6.09996, 0, 0, 94 ),
createObject ( 16092, 3407.9495, 2056.0259, -6.09996, 0, 0, 94 ),
createObject ( 4850, 3220.6565, 2060.8726, 4.80002, 0, 0, 4 ),
createObject ( 4850, 3218.5789, 2090.5991, 4.80002, 0, 0, 3.995 ),
createObject ( 13296, 3252.8149, 2115.6489, 4.90003, 0, 0, 273.995 ),
createObject ( 18229, 3217.3711, 2107.8574, -8.19997, 0, 0, 94 ),
createObject ( 18229, 3219.0884, 2079.0068, -8.19997, 0, 0, 94 ),
createObject ( 18229, 3211.448, 2043.4862, -8.19997, 0, 0, 273.995 ),
createObject ( 4022, 3223.3125, 2116.0923, 5.00003, 0, 0, 94 ),
createObject ( 1532, 3228.1931, 2116.5327, 2.10001, 0, 0, 94 ),
createObject ( 3862, 3418.511, 2048.3438, 3.00003, 0, 0, 283.998 ),
createObject ( 3863, 3421.9719, 2037.5581, 3.00003, 0, 0, 257.993 ),
createObject ( 3863, 3412.7185, 2052.3486, 3.10001, 0, 0, 153.991 ),
createObject ( 6450, 3129.4014, 2140.2012, -3.89995, 1.747, 0, 93.999 ),
createObject ( 9345, 3257.2102, 2077.1621, 2.10001, 0, 0, 4.242 ),
createObject ( 5184, 3231.3999, 2192, 20.9, 0, 0, 184 ),
createObject ( 7955, 3239.7788, 2141.5034, 2.40003, 355.496, 0, 93.495 ),
createObject ( 808, 3297.6572, 2100.8408, 3.20001, 0, 0, 94 ),
createObject ( 10828, 3296.0938, 2202.0781, 5e-005, 0, 0, 93.999 ),
createObject ( 10828, 3295.3269, 2167.1392, 5e-005, 0, 0, 83.492 ),
createObject ( 17068, 3297.9165, 2184.5625, 1.90003, 0, 0, 91.49 ),
createObject ( 16350, 3300.6313, 2174.4272, -9.09996, 0, 0, 94 ),
createObject ( 1461, 3307.927, 2184.7612, 2.80002, 0, 0, 285.992 ),
createObject ( 13486, 3274.3313, 1962.776, -47.59991, 359.495, 4.499, 0.034 ),
createObject ( 17029, 3154.8103, 1945.9989, -8.19997, 0, 0, 94 ),
createObject ( 900, 3156.9304, 1952.9625, 11.90008, 0, 0, 85.244 ),
createObject ( 898, 3152.0454, 1941.094, 8.40001, 0, 0, 94 ),
createObject ( 898, 3153.0269, 1972.9401, -4.59996, 16.469, 78.492, 39.662 ),
createObject ( 896, 3439.9912, 1980.5758, 2.80002, 0, 0, 94 ),
createObject ( 897, 3516.6328, 1998.4664, -4.49995, 0, 0, 263.997 ),
createObject ( 897, 3507.9346, 2003.8719, -5.79997, 0, 0, 263.997 ),
createObject ( 897, 3500.9453, 2007.7941, -3.99992, 0, 63.99, 19.991 ),
createObject ( 900, 3485.8357, 2024.5806, -4.19994, 287.287, 291.984, 73.769 ),
createObject ( 17034, 3457.168, 2017.3643, -11.69997, 0, 0, 29.994 ),
createObject ( 900, 3466.9756, 2010.4308, 1.60001, 287.276, 291.984, 48.517 ),
createObject ( 900, 3477.3569, 1992.4116, -3.49992, 287.276, 291.984, 48.517 ),
createObject ( 1637, 3415.6182, 1976.4678, 3.00003, 0, 0, 93.999 ),
createObject ( 3983, 3349.4077, 2013.0358, 4.00003, 0, 0, 273.995 ),
createObject ( 900, 3448.4243, 2007.6298, -4.29991, 1.511, 275.801, 324.164 ),
createObject ( 16281, 3377.7939, 1981.2401, 4.30002, 0, 0, 5.747 ),
createObject ( 8674, 3245.4006, 2139.9912, 4.80002, 0, 0, 94 ),
createObject ( 8674, 3252.0232, 2134.1392, 4.60001, 0, 0, 184 ),
createObject ( 8674, 3264.9976, 2134.9458, 4.60001, 0, 0, 184 ),
createObject ( 8674, 3264.3462, 2147.1284, 4.60001, 0, 0, 184 ),
createObject ( 8674, 3251.4712, 2146.3301, 4.60001, 0, 0, 184 ),
createObject ( 7921, 3246.4519, 2134.9512, 5.10001, 0, 0, 184 ),
createObject ( 7921, 3246.4519, 2134.9512, 2.30002, 0, 0, 184 ),
createObject ( 7921, 3246.5315, 2145.2837, 2.30002, 0, 0, 94 ),
createObject ( 7921, 3246.5315, 2145.2837, 5.10001, 0, 0, 94 ),
createObject ( 7921, 3269.5515, 2135.7651, 2.10001, 0, 0, 273.995 ),
createObject ( 7921, 3269.5515, 2135.7651, 4.90003, 0, 0, 273.995 ),
createObject ( 7921, 3269.4041, 2146.4819, 5.10001, 0, 0, 4 ),
createObject ( 7921, 3269.4041, 2146.4819, 2.30002, 0, 0, 4 ),
createObject ( 3437, 3258.521, 2134.3926, 2.60001, 0, 0, 179.99 ),
createObject ( 3437, 3257.9619, 2146.6836, 2.60001, 0, 0, 179.99 ),
createObject ( 3440, 3270.2393, 2143.1313, 5.40003, 90, 157.786, 26.198 ),
createObject ( 3440, 3270.5674, 2138.4434, 5.40003, 90, 157.786, 26.198 ),
createObject ( 13813, 3145.179, 2042.1602, -11.49999, 0, 0, 315.99 ),
createObject ( 12961, 3257.1897, 2140.5146, 2.60001, 0, 0, 273.995 ),
createObject ( 14402, 3250.0293, 2139.7139, 2.80002, 0, 0, 23.99 ),
createObject ( 14469, 3279.9973, 2135.4927, 2.80002, 0, 0, 94 ),
createObject ( 14469, 3289.6248, 2136.8682, 2.80002, 0, 0, 94 ),
createObject ( 14469, 3289.1428, 2143.7524, 2.80002, 0, 0, 93.742 ),
createObject ( 14469, 3277.1108, 2145.2163, 2.80002, 0, 0, 183.742 ),
createObject ( 2949, 3370.1956, 2283.4468, 46.10024, 0, 0, 163.994 ),
createObject ( 3440, 3368.9075, 2284.6616, 47.30025, 0, 0, 94 ),
createObject ( 3440, 3369.3623, 2283.8877, 44.1002, 0, 0, 94 ),
createObject ( 4178, 3189.1108, 2071.8984, 5.70005, 0, 0, 184 ),
createObject ( 896, 3173.7859, 2066.0161, -3.89995, 0, 0, 222.749 ),
createObject ( 896, 3167.5376, 2072.1938, -3.89995, 0, 0, 319.989 ),
createObject ( 896, 3151.4404, 2123.1953, -4.29991, 0, 2, 210.976 ),
createObject ( 896, 3162.8262, 2122.3896, -4.89998, 0, 2, 210.977 ),
createObject ( 896, 3172.5967, 2124.5747, -5.59999, 0, 2, 210.977 ),
createObject ( 896, 3178.9109, 2126.0195, -5.29997, 0, 2, 210.977 ),
createObject ( 9314, 3199.6228, 2063.5112, 11.20009, 0, 0, 104.245 ),
createObject ( 5142, 3250.2661, 1988.6621, 8.60003, 0, 0, 4 ),
createObject ( 18264, 3294.1104, 2006.7643, 1.90003, 0, 0, 4 ),
createObject ( 2898, 3265.844, 1976.6189, 3.4, 0, 0, 94 ),
createObject ( 2898, 3271.2458, 1976.7946, 3.4, 0, 0, 94 ),
createObject ( 2898, 3260.5293, 1976.6478, 3.4, 0, 0, 91.99 ),
createObject ( 9163, 3292.0566, 1991.6833, 5.60001, 0, 0, 182.495 ),
createObject ( 9163, 3309.2441, 1992.4849, 5.60001, 0, 0, 182.495 ),
createObject ( 7956, 3306.8545, 1976.4786, 2.30002, 0, 0, 302.499 ),
createObject ( 2957, 3282.2161, 1976.1597, 2.30002, 0, 0, 177.749 ),
createObject ( 1365, 3277.6086, 1973.2307, 5.00003, 359.253, 6.493, 4.824 ),
createObject ( 2957, 3248.4844, 1972.5977, 3.10001, 0, 0, 184 ),
createObject ( 2957, 3225.1401, 1970.9651, 3.10001, 0, 0, 184 ),
createObject ( 2957, 3254.4683, 1973.016, 3.10001, 0, 0, 184 ),
createObject ( 16012, 3202.5054, 1990.7349, 1.80002, 0, 0, 273.995 ),
createObject ( 9361, 3290.9202, 2184.2739, 4.60001, 0, 0, 41.991 ),
createObject ( 4100, 3286.397, 2184.46, 3.9, 0, 0, 47.748 ),
createObject ( 3860, 3284.7385, 2180.9346, 3.30002, 0, 0, 267.749 ),
createObject ( 3860, 3284.8433, 2185.1523, 3.30002, 0, 0, 267.749 ),
createObject ( 1232, 3195.9163, 2024.7576, 4.80002, 0, 0, 94 ),
createObject ( 994, 3232.4209, 2203.7407, 2.20001, 0, 0, 94 ),
createObject ( 4100, 3234.5735, 2214.5171, 3.4, 0, 0, 143.999 ),
createObject ( 4100, 3248.2402, 2215.4731, 3.4, 0, 0, 143.999 ),
createObject ( 4100, 3261.906, 2216.4272, 3.4, 0, 0, 143.999 ),
createObject ( 4100, 3275.573, 2217.3843, 3.4, 0, 0, 143.999 ),
createObject ( 4100, 3289.2397, 2218.3394, 3.4, 0, 0, 143.999 ),
createObject ( 10972, 3184.4688, 1959.0986, -2.19995, 359.253, 351.744, 191.64 ),
createObject ( 8648, 3182.4453, 2016.6973, 2.60001, 0, 0, 6.493 ),
createObject ( 900, 3180.2407, 2028.1726, -9.79997, 67.61, 100.388, 7.274 ),
createObject ( 3920, 3198.2771, 1993.8477, 5.00003, 0, 0, 94 ),
createObject ( 900, 3184.8884, 1991.8082, -0.99994, 359.242, 179.995, 108.744 ),
createObject ( 4172, 3179.4006, 2000.045, 3.9, 9.998, 0, 104.492 ),
createObject ( 6230, 3167.4185, 1982.1658, -6.69993, 0, 0, 11.74 ),
createObject ( 900, 3177.2231, 1939.447, 2.20001, 4.719, 321.839, 109.694 ),
createObject ( 792, 3333.7322, 2156.9585, 2.38327, 0, 0, 94 ),
createObject ( 11497, 3218.2668, 2100.8022, 2.60001, 0, 0, 184 ),
createObject ( 10841, 3387.0005, 2067.4927, 2.70002, 0, 0, 94 ),
createObject ( 7922, 3387.8794, 2054.9229, 3.00003, 0, 0, 94 ),
createObject ( 7922, 3388.7756, 2054.9863, 3.00003, 0, 0, 94 ),
createObject ( 8652, 3403.1963, 2055.1919, 2.70002, 0, 0, 184 ),
createObject ( 17880, 3374.9648, 2066.1484, -1.19993, 8.553, 12.129, 264.908 ),
createObject ( 899, 3386.0273, 2180.2993, -8.49995, 0, 0, 94 ),
createObject ( 1335, 3343.7222, 2176.0371, 3.00003, 0, 0, 4 ),
createObject ( 3886, 3337.6733, 2176.5166, 2.40003, 0, 0, 94 ),
createObject ( 3886, 3327.2996, 2175.791, 2.40003, 0, 0, 94 ),
createObject ( 3886, 3316.9243, 2175.0659, 2.40003, 0, 0, 94 ),
createObject ( 3886, 3306.5515, 2174.3398, 2.40003, 0, 0, 94 ),
createObject ( 3257, 3349.6387, 2196.0996, 2.10001, 0, 0, 93.999 ),
createObject ( 8673, 3345.2483, 2210.1274, 13.40005, 0, 0, 94.5 ),
createObject ( 16325, 3162.2083, 2056.686, 1.90003, 0, 0, 88.749 ),
createObject ( 3522, 3354.3, 2084.8999, 2.2, 0, 0, 93.999 ),
createObject ( 10987, 3375.4785, 2153.3975, 3.60001, 0, 0, 3.999 ),
createObject ( 1497, 3373.5093, 2170.1016, 2.20001, 0, 0, 45.99 ),
createObject ( 3458, 3376.2981, 2181.8232, 4.90003, 0, 0, 273.995 ),
createObject ( 7662, 3373.4819, 2194.8594, 2.60001, 0, 0, 184 ),
createObject ( 7662, 3374.5217, 2179.9951, 2.60001, 0, 0, 184 ),
createObject ( 2244, 3199.7224, 1973.198, 2.80002, 0, 0, 94 ),
createObject ( 2244, 3199.46, 1978.3925, 2.80002, 0, 0, 94 ),
createObject ( 8578, 3405.2053, 2131.1182, 9.30004, 0, 0.242, 94 ),
createObject ( 901, 3392.7048, 2179.4629, -2.49994, 0, 0, 94 ),
createObject ( 901, 3400.5857, 2181.418, -1.99992, 0, 0, 94 ),
createObject ( 1569, 3409.8574, 2130.5396, 2.50003, 0, 0, 94 ),
createObject ( 16312, 3426.0925, 2110.5234, 2.30002, 358.77, 348.492, 354.75 ),
createObject ( 14400, 3420.5808, 2111.9429, 2.00003, 0, 0, 4.742 ),
createObject ( 14400, 3424.3174, 2114.4092, 2.00003, 0, 359.742, 278.741 ),
createObject ( 14400, 3423.4351, 2119.8623, 2.00003, 0, 359.742, 278.741 ),
createObject ( 14400, 3423.0862, 2124.8496, 2.00003, 0, 359.742, 281.493 ),
createObject ( 14400, 3421.7766, 2130.6714, 2.00003, 0, 359.742, 283.487 ),
createObject ( 14400, 3420.3721, 2139.2944, 2.00003, 0, 359.742, 283.487 ),
createObject ( 14400, 3419.2466, 2143.9282, 2.00003, 0, 359.742, 283.487 ),
createObject ( 14400, 3417.7258, 2151.3394, 2.00003, 0, 359.742, 283.487 ),
createObject ( 14400, 3416.374, 2157.7612, 2.00003, 0, 359.742, 283.487 ),
createObject ( 14400, 3415.1343, 2162.585, 2.00003, 0, 359.742, 285.492 ),
createObject ( 14400, 3414.0364, 2166.8203, 2.00003, 0, 359.742, 285.492 ),
createObject ( 618, 3425.3628, 2136.7378, 4.40003, 0, 0, 94 ),
createObject ( 652, 3429.7312, 2108.6724, 1.80002, 0, 0, 94 ),
createObject ( 652, 3428.9861, 2096.3911, 1.80002, 0, 0, 94 ),
createObject ( 652, 3433.3843, 2073.6426, 1.80002, 0, 0, 94 ),
createObject ( 656, 3434.2, 2033.3, 1, 0, 0, 94 ),
createObject ( 669, 3287.436, 2117.9702, 2.00003, 0, 0, 94 ),
createObject ( 669, 3289.4824, 2133.1504, 1.80002, 0, 0, 93.999 ),
createObject ( 671, 3180.095, 2007.3113, 2.20001, 0, 0, 94 ),
createObject ( 671, 3178.7854, 2013.1343, 2.20001, 0, 0, 94 ),
createObject ( 688, 3174.209, 1996.876, 2.40003, 0, 0, 93.999 ),
createObject ( 782, 3278.6475, 2114.6484, 2.00003, 0, 0, 93.999 ),
createObject ( 782, 3261.7603, 2142.5381, 2.00003, 0, 0, 94 ),
createObject ( 3520, 3232.6553, 2155.9419, 2.20001, 358.303, 15.255, 192.454 ),
createObject ( 3520, 3231.8679, 2167.2148, 1.80002, 358.303, 15.255, 192.454 ),
createObject ( 3520, 3231.4839, 2172.7007, 2.00003, 358.303, 15.255, 192.454 ),
createObject ( 3520, 3231.0925, 2178.2861, 1.70001, 358.303, 15.255, 192.454 ),
createObject ( 3520, 3232.1494, 2180.3657, 2.00003, 358.303, 15.244, 10.449 ),
createObject ( 3520, 3232.4773, 2175.6772, 2.60001, 358.303, 15.244, 10.449 ),
createObject ( 3520, 3232.373, 2171.458, 2.10001, 358.303, 15.244, 346.444 ),
createObject ( 3520, 3233.5422, 2163.3213, 1.90003, 358.292, 15.244, 18.447 ),
createObject ( 3520, 3232.8083, 2168.082, 1.60001, 358.292, 15.244, 18.447 ),
createObject ( 3520, 3233.7046, 2158.1201, 2.00003, 358.292, 15.244, 196.437 ),
createObject ( 3520, 3234.7803, 2152.7813, 2.00003, 358.292, 15.244, 196.437 ),
createObject ( 3520, 3234.5696, 2150.0601, 2.10001, 358.292, 15.244, 196.437 ),
createObject ( 8623, 3259.3975, 2077.416, 3.10001, 0, 0, 179.496 ),
createObject ( 792, 3254.5745, 2077.5791, 2.10001, 0, 0, 94 ),
createObject ( 792, 3263.4287, 2077.0962, 2.10001, 0, 357.99, 96 ),
createObject ( 3380, 3400.3982, 2093.791, 2.10001, 0, 0, 273.495 ),
createObject ( 16399, 3213.7419, 2033.6226, 2.30002, 0, 0, 273.995 ),
createObject ( 9247, 3205.9573, 2058.9409, 8.70003, 0, 0, 184 ),
createObject ( 10841, 3175.9861, 2132.0288, -0.19997, 0, 0, 121.746 ),
createObject ( 16530, 3152.0039, 2132.3584, -4.49995, 357.49, 0, 93.999 ),
createObject ( 6458, 3130.3213, 2139.9629, 7.60003, 1.747, 0, 94 ),
createObject ( 910, 3216.678, 2106.3052, 3.70001, 0, 0, 211.999 ),
createObject ( 2971, 3216.2092, 2111.5859, 2.50003, 0, 0, 94 ),
createObject ( 2971, 3206.5999, 2117.1279, 2.50003, 0, 0, 94 ),
createObject ( 2971, 3207.6309, 2102.3647, 2.40003, 0, 0, 191.993 ),
createObject ( 2971, 3210.4219, 2066.7729, 2.50003, 0, 3.994, 91.99 ),
createObject ( 1449, 3212.3064, 2045.5502, 3.00003, 0, 0, 94 ),
createObject ( 1442, 3219.1506, 2039.4142, 3.10001, 0, 0, 94 ),
createObject ( 1440, 3217.9119, 2049.9541, 3.00003, 0, 0, 94 ),
createObject ( 1440, 3217.0383, 2065.3311, 3.00003, 0, 0, 95 ),
createObject ( 1440, 3208.7737, 2080.2915, 3.00003, 0, 0, 95 ),
createObject ( 1439, 3206.3601, 2114.8066, 2.50003, 0, 0, 94 ),
createObject ( 16061, 3311.5068, 1967.2813, 3.20001, 0, 0, 93.999 ),
createObject ( 16015, 3210.4614, 2126.4209, 18.50007, 343.658, 193.03, 340.72 ),
createObject ( 3459, 3217.2415, 2129.8022, 9.20003, 0, 0, 97.741 ),
createObject ( 900, 3172.7668, 1990.259, -4.99995, 0, 0, 94 ),
createObject ( 900, 3165.9189, 2009.3284, -4.99995, 0, 0, 94 ),
createObject ( 900, 3184.1846, 1907.2533, -5.79997, 0, 0, 74.994 ),
createObject ( 900, 3178.009, 1926.769, -6.19993, 0, 3.994, 74.994 ),
createObject ( 900, 3176.6719, 1938.7057, -3.49992, 0, 3.994, 74.994 ),
createObject ( 900, 3181.3503, 1940.6365, 1.40002, 0, 5.999, 74.994 ),
createObject ( 900, 3182.5579, 1924.782, -0.09999, 9.608, 343.757, 77.768 ),
createObject ( 900, 3190.2236, 1901.1582, -2.79991, 9.608, 343.757, 77.767 ),
createObject ( 900, 3205.1545, 1908.4187, -4.19994, 9.987, 357.957, 58.586 ),
createObject ( 900, 3209.6631, 1921.3644, -6.19993, 9.987, 357.957, 88.584 ),
createObject ( 900, 3205.9871, 1940.9565, -4.39996, 11.893, 352.568, 89.765 ),
createObject ( 900, 3197.2771, 1939.3457, -4.39996, 11.97, 356.655, 88.919 ),
createObject ( 900, 3192.4255, 1929.8822, -4.39996, 11.97, 356.655, 88.919 ),
createObject ( 900, 3488.1604, 1974.1198, -5.79997, 287.276, 291.984, 308.514 ),
createObject ( 901, 3307.532, 2173.2051, -3.59993, 0, 0, 94 ),
createObject ( 901, 3312.7759, 2172.772, -6.59996, 349.997, 0, 313.996 ),
createObject ( 901, 3325.4805, 2174.562, -6.59996, 349.997, 0, 331.986 ),
createObject ( 901, 3334.4792, 2174.8892, -6.59996, 349.986, 0, 331.986 ),
createObject ( 901, 3343.2793, 2175.2046, -6.59996, 349.986, 0, 331.986 ),
createObject ( 901, 3294.0974, 2217.6782, -6.79994, 354.172, 88.539, 112.666 ),
createObject ( 900, 3144.5945, 2218.2505, -6.39995, 0, 0, 162 ),
createObject ( 900, 3149.0579, 2144.3813, -8.79997, 73.911, 119.169, 243.843 ),
createObject ( 900, 3156.5903, 2145.6094, -8.79997, 73.911, 119.169, 243.843 ),
createObject ( 900, 3163.5481, 2143.5894, -8.89995, 63.913, 107.776, 254.34 ),
createObject ( 6006, 3408.5076, 2162.7246, 2.00003, 0, 0, 4.242 ),
createObject ( 901, 3391.8816, 2192.6367, 1.80002, 47.417, 71.807, 104.536 ),
createObject ( 901, 3393.8101, 2195.1777, -4.19994, 47.417, 71.807, 104.536 ),
createObject ( 896, 3406.1797, 2191.7319, -1.89996, 0, 0, 94 ),
createObject ( 896, 3425.5513, 2191.3848, -1.89996, 0, 0, 67.99 ),
createObject ( 896, 3423.03, 2172.9629, 6.80002, 0, 2, 27.989 ),
createObject ( 896, 3428.8198, 2180.4844, 3.10001, 0, 2, 137.984 ),
createObject ( 900, 3385.8611, 2187.0029, -2.69993, 302.69, 264.128, 180.545 ),
createObject ( 9019, 3408.4729, 2171.8433, 4.60001, 0, 0, 184 ),
createObject ( 1281, 3408.082, 2173.1201, 3.70001, 0, 0, 94 ),
createObject ( 1281, 3407.6079, 2179.9043, 3.70001, 0, 0, 94 ),
createObject ( 1368, 3403.3208, 2170.9824, 3.60001, 0, 0, 94 ),
createObject ( 1368, 3395.7007, 2173.8564, 3.60001, 0, 0, 177.491 ),
createObject ( 1364, 3179.1482, 2059.5732, 2.80002, 0, 0, 287.25 ),
createObject ( 3532, 3178.9993, 2060.2651, 2.20001, 0, 0, 180.49 ),
createObject ( 3532, 3175.126, 2061.1978, 2.20001, 0, 0, 265.744 ),
createObject ( 3660, 3382.5979, 2003.6284, 3.70001, 0, 0, 94 ),
createObject ( 3660, 3374.7964, 1992.5565, 3.50003, 0, 0, 4 ),
createObject ( 3660, 3355.2446, 1991.1892, 3.50003, 0, 0, 4 ),
createObject ( 3660, 3335.6921, 1989.823, 3.50003, 0, 0, 4 ),
createObject ( 3660, 3318.1194, 1997.4152, 4.50003, 0, 0, 94 ),
createObject ( 2940, 3322.9868, 1988.0331, -4.09993, 289.243, 179.995, 184 ),
createObject ( 8673, 3311.5854, 2010.5913, 3.4, 0, 0, 186 ),
createObject ( 17881, 3309.7966, 2000.3414, 2.10001, 0, 0, 271.248 ),
createObject ( 9351, 3317.0254, 2013.0776, 2.00003, 0, 0, 191.74 ),
createObject ( 9351, 3320.3259, 2018.9226, 2.00003, 0, 0, 234.246 ),
createObject ( 3361, 3315.0615, 2013.9424, 4.40003, 0, 0, 94 ),
createObject ( 2946, 3315.9414, 2012.8015, 5.20002, 0, 0, 92.495 ),
createObject ( 8659, 3308.0491, 2013.854, 2.20001, 0, 0, 13.24 ),
createObject ( 1231, 3310.9121, 2017.3613, 4.80002, 0, 0, 93.999 ),
createObject ( 707, 3319.1973, 2012.127, 2.50003, 359.242, 0, 235.745 ),
createObject ( 768, 3354.4202, 2034.5389, 1.90003, 0, 0, 94 ),
createObject ( 1344, 3282.8579, 1991.3414, 2.9, 0, 0, 94 ),
createObject ( 1558, 3281.4668, 1977.0098, 2.47873, 0, 0, 94 ),
createObject ( 3605, 3415.3137, 2010.9287, 7.90004, 0, 0, 94 ),
createObject ( 3626, 3291.9067, 1990.9722, 9.90004, 0, 0, 94 ),
createObject ( 6959, 3393.8801, 2027.8752, 2.01111, 0, 0, 94 ),
createObject ( 6959, 3396.0869, 2069.4316, 2.00003, 0, 0, 93.999 ),
createObject ( 6959, 3358.7993, 2019.2069, 2.00003, 0, 0, 103.24 ),
createObject ( 11091, 3345.4158, 2012.7567, 2.60001, 0, 0, 94 ),
createObject ( 17866, 3321.2937, 1952.0271, -11.69997, 341.252, 1.055, 98.587 ),
createObject ( 14400, 3321.981, 2006.7095, 2.80002, 0, 0, 94 ),
createObject ( 14400, 3321.9651, 2001.193, 2.80002, 0, 0, 94 ),
createObject ( 14400, 3321.9895, 1997.9869, 2.80002, 0, 0, 94 ),
createObject ( 14400, 3322.1187, 1993.2842, 2.80002, 0, 357.99, 94 ),
createObject ( 14400, 3321.2468, 1991.4181, 2.80002, 0, 357.99, 94 ),
createObject ( 14400, 3322.45, 1991.4031, 2.80002, 0, 357.99, 94 ),
createObject ( 1346, 3318.6899, 2030.8367, 3.4, 0, 0, 94 ),
createObject ( 1346, 3230.8025, 2007.548, 3.50003, 0, 0, 94 ),
createObject ( 6959, 3411.3782, 2008.4484, 2.00003, 0, 0, 142.741 ),
createObject ( 8990, 3388.8591, 2000.7579, 2.60001, 0, 0, 142.494 ),
createObject ( 8990, 3397.9033, 1993.2716, 2.60001, 0, 0, 142.494 ),
createObject ( 8990, 3408.814, 1984.9103, 2.60001, 0, 0, 143.241 ),
createObject ( 8990, 3390.6733, 1999.1808, 2.60001, 0, 0, 142.494 ),
createObject ( 8990, 3395.2427, 1995.4907, 2.60001, 0, 0, 142.494 ),
createObject ( 8990, 3392.5366, 1996.9065, 2.60001, 0, 0, 322.494 ),
createObject ( 8990, 3400.9136, 1990.3734, 2.60001, 0, 0, 322.494 ),
createObject ( 8990, 3406.0012, 1986.4194, 2.60001, 0, 0, 322.494 ),
createObject ( 1640, 3407.239, 1980.1904, 1.90003, 0, 0, 94 ),
createObject ( 984, 3387.1638, 1981.9949, 2.50003, 0, 0, 94 ),
createObject ( 984, 3397.5618, 1993.849, 2.50003, 0, 0, 51.247 ),
createObject ( 984, 3392.3254, 2004.2084, 2.50003, 0, 0, 2.495 ),
createObject ( 984, 3394.2627, 2016.6735, 2.50003, 0, 0, 339.995 ),
createObject ( 984, 3399.0396, 2028.6373, 2.50003, 0, 0, 336.485 ),
createObject ( 984, 3404.0293, 2040.413, 2.50003, 0, 0, 337.979 ),
createObject ( 984, 3400.1064, 2046.3539, 2.50003, 0, 0, 269.979 ),
createObject ( 984, 3387.3455, 2046.7651, 2.50003, 0, 0, 265.969 ),
createObject ( 1452, 3417.197, 2178.9692, 3.9, 0, 0, 94 ),
createObject ( 730, 3434.4163, 2015.8734, 1.90003, 0, 0, 94 ),
createObject ( 656, 3417.9075, 2029.7551, 2.00003, 0, 0, 94 ),
createObject ( 671, 3416.7319, 2030.7743, 1.90003, 0, 0, 334.991 ),
createObject ( 671, 3419.1365, 2027.9373, 1.90003, 0, 358.495, 140.747 ),
createObject ( 3660, 3413.7556, 2040.391, 4.50003, 0, 0, 94 ),
createObject ( 8674, 3428.4592, 2020.7692, 3.10001, 0, 0, 142.994 ),
createObject ( 14402, 3429.9512, 2022.3772, 2.70002, 0, 0, 51.994 ),
createObject ( 14402, 3430.4109, 2025.8184, 2.70002, 0, 0, 51.994 ),
createObject ( 822, 3429.8606, 2032.2959, 2.60001, 0, 0, 94 ),
createObject ( 822, 3430.3154, 2037.2383, 2.30002, 0, 0, 94 ),
createObject ( 1231, 3357.9983, 2138.9712, 2.4588, 0, 0, 94 ),
createObject ( 1231, 3331.8621, 2170.6201, 4.62305, 0, 0, 94 ),
createObject ( 1231, 3298.554, 2138.1943, 4.80002, 0, 0, 89.99 ),
createObject ( 1231, 3314.301, 2110.8257, 4.80002, 0, 0, 89.99 ),
createObject ( 1231, 3244.1523, 2106.2197, 4.80002, 0, 0, 89.989 ),
createObject ( 6959, 3265.4348, 2117.2334, 2.00003, 0, 0, 94 ),
createObject ( 18014, 3249.9629, 2133.4941, 2.40003, 0, 0, 94 ),
createObject ( 18014, 3255.25, 2133.8643, 2.40003, 0, 0, 94 ),
createObject ( 18014, 3262.1462, 2134.145, 2.40003, 0, 0, 94 ),
createObject ( 18014, 3267.4336, 2134.5146, 2.40003, 0, 0, 94 ),
createObject ( 738, 3264.7483, 2134.2256, 2.00003, 0, 0, 94 ),
createObject ( 738, 3252.5635, 2133.5742, 2.00003, 0, 0, 94 ),
createObject ( 715, 3240.667, 2144.5723, 10.10005, 0, 0, 65.748 ),
createObject ( 715, 3243.0371, 2142.2314, 10.40007, 0, 0, 135.989 ),
createObject ( 8623, 3240.9414, 2142.085, 2.50003, 0, 0, 133.749 ),
createObject ( 762, 3240.3662, 2143.1475, 1.60001, 0, 0, 63.991 ),
createObject ( 1686, 3246.9409, 2117.9438, 2.00003, 0, 0, 184 ),
createObject ( 1686, 3247.1001, 2115.6504, 2.00003, 0, 0, 184 ),
createObject ( 1686, 3247.2676, 2113.2568, 2.00003, 0, 0, 184 ),
createObject ( 1686, 3247.4287, 2110.9614, 2.00003, 0, 0, 184 ),
createObject ( 17951, 3247.6997, 2111.3818, 1.20001, 0, 0, 184 ),
createObject ( 17951, 3247.1689, 2117.5591, 1.20001, 0, 358.995, 184.5 ),
createObject ( 637, 3258.5876, 2131.9902, 2.10001, 0, 0, 94 ),
createObject ( 637, 3252.5967, 2131.6729, 2.10001, 0, 0, 94 ),
createObject ( 1339, 3368.3323, 2172.4453, 2.50003, 0, 0, 2.995 ),
createObject ( 792, 3345.1157, 2087.416, 2.03247, 0, 0, 94 ),
createObject ( 1281, 3194.8281, 1982.9795, 3.4, 0, 0, 77.993 ),
createObject ( 1281, 3192.1855, 1987.8076, 3.4, 0, 0, 149.991 ),
createObject ( 1281, 3195.0928, 1993.5234, 3.4, 0, 0, 5.999 ),
createObject ( 1281, 3190.7996, 1996.1313, 3.4, 0, 0, 61.997 ),
createObject ( 1281, 3191.4858, 2006.4041, 3.4, 0, 0, 94 ),
createObject ( 1281, 3188.8201, 1981.4572, 3.4, 0, 0, 111.996 ),
createObject ( 3660, 3211.719, 1992.282, 3.30002, 0, 0, 94 ),
createObject ( 3660, 3220.3069, 2007.1166, 3.80002, 0, 0, 2.495 ),
createObject ( 896, 3141.5522, 2142.7544, -3.59993, 0, 0, 15.992 ),
createObject ( 3520, 3346.9148, 2176.2603, 2.00003, 0, 0, 94 ),
createObject ( 3520, 3351.8882, 2176.8086, 2.00003, 0, 0, 94 ),
createObject ( 900, 3200.1812, 1950.876, 1.70001, 0, 0, 140 ),
createObject ( 1428, 3164.0962, 2014.0529, 4.00003, 61.996, 3.994, 94 ),
createObject ( 3985, 3194.7979, 2168.3311, 1.30002, 0, 0, 183.999 ),
createObject ( 4186, 3190.5, 2229.8999, 8.7, 0, 0, 183.999 ),
createObject ( 4141, 3255, 2186.8999, 13, 0, 0, 93.999 ),
createObject ( 7662, 3376.7317, 2148.373, 2.60001, 0, 0, 184 ),
createObject ( 900, 3386.3687, 2169.6968, -12.79994, 15.458, 88.951, 359.397 ),
createObject ( 8171, 3446.9004, 2252.9004, 2.6, 0, 0, 93.999 ),
createObject ( 4874, 3190.4146, 2086.2241, 3.20001, 0, 0, 273.995 ),
createObject ( 3522, 3326.9604, 2053.0684, 2.20001, 0, 0, 273.995 ),
createObject ( 792, 3328.1292, 2050.145, 2.345, 0, 0, 94 ),
createObject ( 1231, 3360.1001, 2055.8, 4.2, 0, 0, 89.989 ),
createObject ( 10932, 3275.8806, 2065.3354, 8.00002, 0, 0, 94 ),
createObject ( 11353, 3278.6375, 2027.3341, 5.60001, 0, 0, 94 ),
createObject ( 11353, 3274.6123, 2084.8955, 5.20002, 0, 0, 94 ),
createObject ( 1231, 3359.5398, 2086.0215, 4.80002, 0, 0, 89.99 ),
createObject ( 3520, 3232.1509, 2161.7192, 2.20001, 358.303, 15.255, 192.454 ),
createObject ( 3520, 3233.1106, 2150.8604, 2.20001, 358.303, 15.255, 192.454 ),
createObject ( 10763, 3341.7, 2070, 34.7, 0, 0, 227.999 ),
createObject ( 6450, 2997.5, 2130.98, 0.1, 1.747, 0, 93.999 ),
createObject ( 9931, 3335.5, 2129.3999, 18.3, 0, 0, 273.999 ),
createObject ( 3533, 3064.8999, 2132.5, 10.4 ),
createObject ( 3533, 3068.3, 2132.8, 6.5, 0, 90, 4.5 ),
createObject ( 3533, 3068.3, 2132.8, 14.8, 0, 90, 4.499 ),
createObject ( 3533, 3079.3999, 2133.2, 14.2, 0, 90, 4.499 ),
createObject ( 3533, 3075.8999, 2132.7, 10.1 ),
createObject ( 3533, 3083.8, 2133.2, 9.7 ),
createObject ( 3533, 3079.3999, 2133.2, 6.1, 0, 90, 4.499 ),
createObject ( 3533, 3093.8999, 2133.6001, 5.7, 0, 90, 4.499 ),
createObject ( 3533, 3090.3999, 2133.2, 9.5 ),
createObject ( 3533, 3093.8, 2133.6001, 13.8, 0, 90, 4.499 ),
createObject ( 3533, 3121.6001, 2136.3, 3.2 ),
createObject ( 3533, 3119.2, 2136.3, 10.9, 180, 32, 2 ),
createObject ( 3533, 3123.6001, 2136.5, 10.1, 0, 31.998, 0 ),
createObject ( 3533, 3103.1001, 2134.8999, 9 ),
createObject ( 3533, 3110.7, 2135.2, 13.5, 0, 90, 4.499 ),
createObject ( 3533, 3110.8999, 2135.2, 9 ),
createObject ( 896, 3121.6001, 2135.3, -3.6, 0, 2, 210.976 ),
createObject ( 8130, 3190.3, 2246.8999, 12.1, 0, 0, 4 ),
createObject ( 715, 3254.3999, 2031.1, 10.4, 0, 0, 135.989 ),
createObject ( 707, 3155.8, 2040.3, 2.5, 359.242, 0, 235.745 ),
createObject ( 688, 3172.8999, 1992.9, 2.4, 0, 0, 93.999 ),
createObject ( 688, 3175, 1984.7, 2.4, 0, 0, 93.999 ),
createObject ( 688, 3174.3999, 1981.9, 2.4, 0, 0, 93.999 ),
createObject ( 688, 3174.3999, 1977.2, 2.4, 0, 0, 93.999 ),
createObject ( 688, 3174.7, 1998.4, 2.4, 0, 0, 261.999 ),
createObject ( 16061, 3243.3, 1964, 3.2, 0, 0, 93.999 ),
createObject ( 900, 3193.2, 1931.6, -2.8, 9.608, 343.757, 77.767 ),
createObject ( 900, 3194.3999, 1918.6, -2.8, 9.608, 343.757, 77.767 ),
createObject ( 900, 3166.5, 1932.8, -2.8, 9.608, 343.757, 77.767 ),
createObject ( 900, 3452.5, 1972.6, -2.8, 9.608, 343.757, 77.767 ),
createObject ( 900, 3493.3999, 2000.2, -2.8, 9.608, 343.757, 77.767 ),
createObject ( 900, 3459.3999, 2177.3, -2.8, 9.608, 343.757, 77.767 ),
createObject ( 10828, 3396.8999, 2230, 0, 0, 0, 4.25 ),
createObject ( 10828, 3432.1001, 2232.6001, 0, 0, 0, 4.246 ),
createObject ( 10828, 3464.7, 2275.2, 0, 0, 0, 4.246 ),
createObject ( 10828, 3499.6001, 2237.6001, 0, 0, 0, 4.246 ),
createObject ( 10828, 3496.8, 2277.6001, 0, 0, 0, 4.246 ),
createObject ( 10828, 3467.4004, 2235.2002, 0, 0, 0, 4.246 ),
createObject ( 10828, 3429.3999, 2272.6001, 0, 0, 0, 4.246 ),
createObject ( 10828, 3394.1001, 2270, 0, 0, 0, 4.246 ),
createObject ( 14675, 3252.8999, 2184.5, 13.1, 0, 0, 93.25 ),
createObject ( 669, 3217.3999, 2164.1001, 1.8, 0, 0, 93.999 ),
createObject ( 669, 3172.5, 2160.8999, 1.8, 0, 0, 93.999 ),
createObject ( 688, 3176, 2222.3, 1.9, 0, 0, 261.996 ),
createObject ( 688, 3212.7, 2225.5, 1.9, 0, 0, 261.996 ),
createObject ( 715, 3194, 2202.3, 10.1, 0, 0, 65.748 ),
createObject ( 782, 3184.6001, 2202.5, 2, 0, 0, 93.999 ),
createObject ( 782, 3202.2, 2203.2, 2, 0, 0, 93.999 ),
createObject ( 782, 3287.2, 2109.7, 2, 0, 0, 93.999 ),
createObject ( 782, 3274, 2136.8999, 2, 0, 0, 93.999 ),
createObject ( 782, 3253.2, 2139.8999, 2, 0, 0, 93.999 ),
createObject ( 6965, 3194.1001, 2175.8, 5.8 ),
createObject ( 878, 3188.3, 2171.8999, 4.1 ),
createObject ( 878, 3191.8999, 2168.8, 4.1 ),
createObject ( 878, 3194.8, 2171.2, 4.1 ),
createObject ( 878, 3187.1001, 2175.8999, 4.1 ),
createObject ( 878, 3189, 2179.5, 4.1 ),
createObject ( 878, 3193.2, 2180.8999, 4.1 ),
createObject ( 878, 3193.2002, 2180.9004, 4.1 ),
createObject ( 878, 3195.5, 2183.3999, 4.1 ),
createObject ( 878, 3199.1001, 2175, 4.1 ),
createObject ( 878, 3198.7, 2179.5, 4.1 ),
createObject ( 878, 3202.8, 2176.3999, 4.1 ),
createObject ( 878, 3203, 2179.3999, 4.1 ),
createObject ( 878, 3200.1001, 2171.1001, 4.1, 0, 0, 238 ),
createObject ( 878, 3196.3999, 2168.2, 4.1, 0, 0, 267.997 ),
createObject ( 1281, 3194.1001, 2000.8, 3.4, 0, 0, 5.999 ),
createObject ( 1281, 3194, 1977.9, 3.4, 0, 0, 149.991 ),
createObject ( 1637, 3377.8, 1943, 6.1, 0, 0, 93.999 ),
createObject ( 1231, 3325.7, 2036.5, 4.8, 0, 0, 93.999 ),
createObject ( 1231, 3324.5, 2050.3999, 4.8, 0, 0, 93.999 ),
createObject ( 1231, 3312.6001, 2138.8, 4.8, 0, 0, 93.999 ),
createObject ( 1231, 3343, 2157.7, 4.8, 0, 0, 93.999 ),
createObject ( 1231, 3323.8, 2156.2, 4.8, 0, 0, 93.999 ),
createObject ( 1231, 3358.7, 2117.3, 4.8, 0, 0, 93.999 ),
createObject ( 1231, 3382.3999, 2118.3999, 4.8, 0, 0, 93.999 ),
createObject ( 1231, 3381.6001, 2138.8999, 4.8, 0, 0, 93.999 ),
createObject ( 1231, 3380.5, 2160.2, 4.8, 0, 0, 93.999 ),
createObject ( 1231, 3400.6001, 2184.3, 4.8, 0, 0, 93.999 ),
createObject ( 1231, 3390.3, 2168.1001, 4.8, 0, 0, 93.999 ),
createObject ( 1231, 3186.7, 2002, 4.2, 0, 0, 89.989 ),
createObject ( 1231, 3167.3999, 2016.4, 4.2, 0, 0, 89.989 ),
createObject ( 1231, 3171.3, 1997.5, 4.2, 0, 0, 89.989 ),
createObject ( 1231, 3176, 2032.7, 4.2, 0, 0, 89.989 ),
createObject ( 1231, 3181.8999, 2162.3999, 4.2, 0, 0, 89.989 ),
createObject ( 1231, 3209.1001, 2161.8, 4.2, 0, 0, 89.989 ),
createObject ( 1231, 3214.3999, 2196.3999, 4.2, 0, 0, 89.989 ),
createObject ( 1231, 3172.2, 2191.1001, 4.2, 0, 0, 89.989 ),
createObject ( 1231, 3377.3, 2043.7, 4.2, 0, 0, 89.989 ),
createObject ( 1231, 3409.2, 2035.3, 4.2, 0, 0, 89.989 ),
createObject ( 1231, 3398.6001, 2085.6001, 4.2, 0, 0, 89.989 ),
createObject ( 1231, 3425.1001, 2088.5, 4.2, 0, 0, 89.989 ),
createObject ( 1231, 3261.8, 2096.5, 4.8, 0, 0, 89.989 ),
createObject ( 3851, 3316, 2078, 17.6, 0, 0, 4 ),
createObject ( 3851, 3316, 2078, 13.6, 0, 0, 3.999 ),
createObject ( 3851, 3316, 2078, 9.6, 0, 0, 3.999 ),
createObject ( 3851, 3316, 2078, 5.6, 0, 0, 3.999 ),
createObject ( 3851, 3316, 2078, 1.6, 0, 0, 3.999 ),
createObject ( 3851, 3328.3999, 2069.8, 17.6, 0, 0, 93.5 ),
createObject ( 3851, 3328.3999, 2069.8, 13.6, 0, 0, 93.499 ),
createObject ( 3851, 3328.3999, 2069.8, 9.6, 0, 0, 93.499 ),
createObject ( 3851, 3328.3999, 2069.8, 5.6, 0, 0, 93.499 ),
createObject ( 3851, 3328.3999, 2069.8, 1.6, 0, 0, 93.499 ),
createObject ( 3851, 3339.7, 2070.5, 17.6, 0, 0, 93.499 ),
createObject ( 3851, 3339.7, 2070.5, 13.6, 0, 0, 93.499 ),
createObject ( 3851, 3339.7, 2070.5, 9.6, 0, 0, 93.499 ),
createObject ( 3851, 3339.7, 2070.5, 5.6, 0, 0, 93.499 ),
createObject ( 3851, 3339.7, 2070.5, 1.6, 0, 0, 93.499 ),
createObject ( 3851, 3352.8, 2078, 17.4, 0, 0, 93.499 ),
createObject ( 3851, 3352.3999, 2082.1001, 17.4, 0, 0, 93.499 ),
createObject ( 3851, 3336.3, 2088, 17.4, 0, 0, 93.499 ),
createObject ( 3851, 3336.3, 2088, 13.5, 0, 0, 93.499 ),
createObject ( 3851, 3336.3, 2088, 9.5, 0, 0, 93.499 ),
createObject ( 3851, 3336.3, 2088, 5.5, 0, 0, 93.499 ),
createObject ( 3851, 3336.3, 2088, 1.5, 0, 0, 93.499 ),
createObject ( 3851, 3325.1001, 2087.3999, 17.4, 0, 0, 93.499 ),
createObject ( 3851, 3325.1001, 2087.3999, 13.5, 0, 0, 93.499 ),
createObject ( 3851, 3325.1001, 2087.3999, 9.5, 0, 0, 93.499 ),
createObject ( 3851, 3325.1001, 2087.3999, 5.5, 0, 0, 93.499 ),
createObject ( 3851, 3325.1001, 2087.3999, 1.5, 0, 0, 93.499 ),
createObject ( 18102, 3282.8, 2064.3, 11.6051 ),
createObject ( 18102, 3289, 2059.5, 11.5 ),
createObject ( 18102, 3297.8, 2067.7, 11.5 ),
createObject ( 18102, 3300.8, 2061.8, 11.50065 ),
createObject ( 18102, 3286.7, 2053.5, 11.8 ),
createObject ( 18102, 3276.8, 2057.8999, 11.85698 ),
createObject ( 18102, 3272.3, 2067.3, 11.8 ),
createObject ( 18102, 3267, 2060.8, 11.8 ),
createObject ( 18102, 3264.3, 2054.2, 11.8 ),
createObject ( 18102, 3260.3, 2048.5, 11.8 ),
createObject ( 18102, 3259, 2053.3, 11.8 ),
createObject ( 18102, 3259.3, 2067.8, 11.8 ),
createObject ( 715, 3269.8, 2033.2, 10.4, 0, 0, 135.989 ),
createObject ( 715, 3283, 2034.5, 10.4, 0, 0, 135.989 ),
createObject ( 715, 3296.3, 2035.9, 10.4, 0, 0, 135.989 ),
createObject ( 18090, 3290.2, 2030.3, 4.5, 0, 0, 275 ),
createObject ( 14537, 3275.8999, 2064.6001, 3.8 ),
createObject ( 14560, 3256.8, 2059.3, 6.4 ),
createObject ( 14560, 3293.7, 2062.2, 6.4 ),
createObject ( 1350, 3248.3, 2094.5, 2.1, 0, 0, 90 ),
createObject ( 1350, 3237.3, 2027.4, 2.1, 0, 0, 188 ),
createObject ( 1350, 3321.3999, 2049.3999, 2.1, 0, 0, 93.998 ),
createObject ( 1350, 3361.5, 2107, 2.1, 0, 0, 183.994 ),
createObject ( 1350, 3302, 2102.3, 2.1, 0, 0, 183.994 ),
createObject ( 10828, 3236.7, 2232.3999, 0, 0, 0, 93.75 ),
createObject ( 10828, 3235.5, 2249.3999, 0, 0, 0, 93.746 ),
createObject ( 10828, 3218.3999, 2265.1001, 0, 0, 0, 181.996 ),
createObject ( 10828, 3183.3999, 2264, 0, 0, 0, 181.994 ),
createObject ( 10828, 3162.3999, 2263.3, 0, 0, 0, 181.994 ),
createObject ( 10828, 3144.7, 2246.5, 0, 0, 0, 92.496 ),
createObject ( 10828, 3146.2, 2212.1001, 0, 0, 0, 92.494 ),
createObject ( 10828, 3148.1001, 2177.5, 0, 0, 0, 94.244 ),
createObject ( 10828, 3149.5, 2159, 0, 0, 0, 94.241 ),
createObject ( 8832, 3193.80005, 2148.5, 3.7, 0, 0, 2 ),
createObject ( 8397, 3144.6001, 2262.3, -24.1 ),
createObject ( 8397, 3234.3999, 2265, -24.1 ),
createObject ( 8493, 3316.2, 2221.8999, 14.6, 0, 0, 2 ),
createObject ( 3749, 2987, 2120.7, 14.2, 0, 0, 94 ),
createObject ( 987, 2984.6001, 2130.3, 8.7, 0, 0, 93.999 ),
createObject ( 987, 2983.8999, 2137.8999, 8.7, 0, 0, 93.999 ),
createObject ( 987, 2971.3999, 2148.3, 8.7, 0, 0, 6.75 ),
createObject ( 987, 2959.5, 2146.8999, 8.7, 0, 0, 6.746 ),
createObject ( 987, 2947.6001, 2145.5, 8.7, 0, 0, 6.746 ),
createObject ( 8397, 2982.2, 2147.5, -24.1 ),
createObject ( 8397, 3065.2, 2154.3999, -24.1 ),
createObject ( 8397, 3113.2, 2155.3, -24.1 ),
createObject ( 2780, 3075.8, 2132.7, 6.5 ),
createObject ( 2780, 3064.7, 2132.3, 6.5 ),
createObject ( 2780, 3083.7, 2133.1001, 6.5 ),
createObject ( 2780, 3090.6001, 2133.6001, 5 ),
createObject ( 2780, 3103.1001, 2134.8999, 5 ),
createObject ( 2780, 3110.8999, 2134.8999, 5 ),
createObject ( 2780, 3121.6001, 2136.3999, 5 ),
}
for k,v in ipairs(cobras) do
setElementDoubleSided(v,true)
setObjectBreakable(v, false)
end
|
local state = {}
state._NAME = ...
require'hcm'
local vector = require'vector'
local util = require'util'
local movearm = require'movearm'
local libArmPlan = require 'libArmPlan'
local arm_planner = libArmPlan.new_planner()
local stage
local plan_valid = true
function check_override()
local override = hcm.get_state_override()
for i=1,7 do if override[i]~=0 then return true end end
return false
end
local function update_override()
local override = hcm.get_state_override()
local tool_model = hcm.get_tool_model()
tool_model[1],tool_model[2],tool_model[3], tool_model[4] =
tool_model[1] + override[1],
tool_model[2] + override[2],
tool_model[3] + override[3],
tool_model[4] + override[6], --yaw
hcm.get_tool_model()
hcm.set_tool_model(tool_model)
print( util.color('Tool model:','yellow'), string.format("%.2f %.2f %.2f / %.1f",
tool_model[1],tool_model[2],tool_model[3],tool_model[4]*180/math.pi ))
hcm.set_state_proceed(0)
end
local function revert_override()
print("revert")
local override = hcm.get_state_override()
local tool_model = hcm.get_tool_model()
tool_model[1],tool_model[2],tool_model[3], tool_model[4] =
tool_model[1] - override[1],
tool_model[2] - override[2],
tool_model[3] - override[3],
tool_model[4] - override[6], --yaw
hcm.get_tool_model()
hcm.set_tool_model(tool_model)
print( util.color('Tool model:','yellow'), string.format("%.2f %.2f %.2f / %.1f",
tool_model[1],tool_model[2],tool_model[3],tool_model[4]*180/math.pi ))
hcm.set_state_proceed(0)
hcm.set_state_override({0,0,0,0,0,0,0})
end
local function confirm_override() hcm.set_state_override({0,0,0,0,0,0,0}) end
local function get_tool_tr()
local tool_model = hcm.get_tool_model()
local hand_pos = vector.slice(tool_model,1,3)
local tool_tr = {hand_pos[1],hand_pos[2],hand_pos[3], 0,0,tool_model[4]}
return tool_tr
end
function state.entry()
print(state._NAME..' Entry' )
local t_entry_prev = t_entry -- Update the time of entry
t_entry = Body.get_time()
t_update = t_entry
arm_planner:set_hand_mass(0,0)
mcm.set_arm_endpoint_compensation({0,1}) -- compensate for torso movement for only right hand (left arm fixed)
-- arm_planner:set_shoulder_yaw_target(nil,nil)
-- arm_planner:reset_torso_comp(qLArm0,qRArm0)
plan_valid,stage = arm_planner:plan_arm_sequence(Config.armfsm.teleop.arminit,stage,"arminit")
end
function state.update()
-- print(state._NAME..' Update' )
if not plan_valid then
print("PLANNING ERROR!!!!")
return "done" end
local t = Body.get_time()
local dt = t - t_update
t_update = t
local trLArm,trRArm=arm_planner:load_current_condition()
--DESIRED WRIST ANGLE: L 90,-90 R -90, 90
if stage=="arminit" then --Turn yaw angles first
if arm_planner:play_arm_sequence(t) then
hcm.set_tool_model({trRArm[1],trRArm[2],trRArm[3],trRArm[6]})
stage="teleopwait"
end
elseif stage=="teleopwait" then
if hcm.get_state_proceed(0)== -1 then
plan_valid,stage = arm_planner:plan_arm_sequence(Config.armfsm.teleop.armuninit,stage,"armuninit")
if not plan_valid then
print("cannot return to initial pose!")
plan_valid=true
end
elseif hcm.get_state_proceed()==2 then --override
local trRArmTarget = hcm.get_hands_right_tr_target()
local trLArmTarget = hcm.get_hands_left_tr_target()
local arm_seq = {{'move',nil,trRArmTarget}}
plan_valid,stage = arm_planner:plan_arm_sequence(arm_seq,stage,"teleopmove")
if plan_valid then
hcm.set_tool_model({trRArmTarget[1],trRArmTarget[2],trRArmTarget[3],trRArmTarget[6]})
else
hcm.set_hands_right_tr_target(hcm.get_hands_right_tr_target_old())
plan_valid,stage=true,"teleopwait"
end
hcm.set_state_proceed(0)
else
if check_override() then --Model modification
update_override()
local arm_seq = {{'move',nil,get_tool_tr()}}
plan_valid,stage = arm_planner:plan_arm_sequence(arm_seq,stage,"teleopmove")
if plan_valid then confirm_override()
else revert_override()
plan_valid,stage=true,"teleopwait"
end
end
end
elseif stage=="teleopmove" then
if arm_planner:play_arm_sequence(t) then
print("Current rarm:",util.print_transform(trRArm,3))
stage="teleopwait"
end
elseif stage=="armuninit" then
--TODO: arm is not going back exactly to the initial position (due to the body movement)
if arm_planner:play_arm_sequence(t) then return "done" end
end
hcm.set_state_proceed(0)
end
function state.exit()
print(state._NAME..' Exit' )
end
return state
|
Image = {}
function Image.create(properties)
if type(properties) ~= "table" then
properties = {}
end
local widget = Widget.create(properties)
widget.texture = properties.texture
function widget:draw()
if self.texture then
Drawing.image(self.x, self.y, self.width, self.height, self.texture)
end
end
return widget
end
|
function test.index_name()
for _, k in ipairs(df.units_other_id) do
expect.eq(df.global.world.units.other[k]._kind, 'container')
end
end
function test.index_name_bad()
expect.error_match('not found.$', function()
expect.eq(df.global.world.units.other.SOME_FAKE_NAME, 'container')
end)
end
function test.index_id()
for i in ipairs(df.units_other_id) do
expect.eq(df.global.world.units.other[i]._kind, 'container', df.units_other_id[i])
end
end
function test.index_id_bad()
expect.error_match('Cannot read field', function()
expect.eq(df.global.world.units.other[df.units_other_id._first_item - 1], 'container')
end)
expect.error_match('Cannot read field', function()
expect.eq(df.global.world.units.other[df.units_other_id._last_item + 1], 'container')
end)
end
|
remote = require 'net.box'
fiber = require 'fiber'
test_run = require('test_run').new()
test_run:cmd("push filter ".."'\\.lua.*:[0-9]+: ' to '.lua...\"]:<line>: '")
test_run:cmd("setopt delimiter ';'")
function x_select(cn, space_id, index_id, iterator, offset, limit, key, opts)
local ret = cn:_request(remote._method.select, opts, nil, nil, space_id,
index_id, iterator, offset, limit, key)
return ret
end
function x_fatal(cn)
cn._transport.perform_request(nil, nil, false, remote._method.inject,
nil, nil, nil, nil, '\x80')
end
test_run:cmd("setopt delimiter ''");
LISTEN = require('uri').parse(box.cfg.listen)
space = box.schema.space.create('net_box_test_space')
index = space:create_index('primary', { type = 'tree' })
function test_foo(a,b,c) return { {{ [a] = 1 }}, {{ [b] = 2 }}, c } end
box.schema.user.grant('guest', 'read,write', 'space', 'net_box_test_space')
box.schema.user.grant('guest', 'execute', 'universe')
cn = remote.connect(box.cfg.listen)
x_select(cn, space.id, space.index.primary.id, box.index.EQ, 0, 0xFFFFFFFF, 123)
space:insert{123, 345}
x_select(cn, space.id, space.index.primary.id, box.index.EQ, 0, 0, 123)
x_select(cn, space.id, space.index.primary.id, box.index.EQ, 0, 1, 123)
x_select(cn, space.id, space.index.primary.id, box.index.EQ, 1, 1, 123)
cn.space[space.id] ~= nil
cn.space.net_box_test_space ~= nil
cn.space.net_box_test_space ~= nil
cn.space.net_box_test_space.index ~= nil
cn.space.net_box_test_space.index.primary ~= nil
cn.space.net_box_test_space.index[space.index.primary.id] ~= nil
cn.space.net_box_test_space.index.primary:select(123)
cn.space.net_box_test_space.index.primary:select(123, { limit = 0 })
cn.space.net_box_test_space.index.primary:select(nil, { limit = 1, })
cn.space.net_box_test_space:insert{234, 1,2,3}
cn.space.net_box_test_space:insert{234, 1,2,3}
cn.space.net_box_test_space.insert{234, 1,2,3}
cn.space.net_box_test_space:replace{354, 1,2,3}
cn.space.net_box_test_space:replace{354, 1,2,4}
cn.space.net_box_test_space:select{123}
space:select({123}, { iterator = 'GE' })
cn.space.net_box_test_space:select({123}, { iterator = 'GE' })
cn.space.net_box_test_space:select({123}, { iterator = 'GT' })
cn.space.net_box_test_space:select({123}, { iterator = 'GT', limit = 1 })
cn.space.net_box_test_space:select({123}, { iterator = 'GT', limit = 1, offset = 1 })
cn.space.net_box_test_space:select{123}
cn.space.net_box_test_space:update({123}, { { '+', 2, 1 } })
cn.space.net_box_test_space:update(123, { { '+', 2, 1 } })
cn.space.net_box_test_space:select{123}
cn.space.net_box_test_space:insert(cn.space.net_box_test_space:get{123}:update{ { '=', 1, 2 } })
cn.space.net_box_test_space:delete{123}
cn.space.net_box_test_space:select{2}
cn.space.net_box_test_space:select({234}, { iterator = 'LT' })
cn.space.net_box_test_space:update({1}, { { '+', 2, 2 } })
cn.space.net_box_test_space:delete{1}
cn.space.net_box_test_space:delete{2}
cn.space.net_box_test_space:delete{2}
-- test one-based indexing in splice operation (see update.test.lua)
cn.space.net_box_test_space:replace({10, 'abcde'})
cn.space.net_box_test_space:update(10, {{':', 2, 0, 0, '!'}})
cn.space.net_box_test_space:update(10, {{':', 2, 1, 0, '('}})
cn.space.net_box_test_space:update(10, {{':', 2, 2, 0, '({'}})
cn.space.net_box_test_space:update(10, {{':', 2, -1, 0, ')'}})
cn.space.net_box_test_space:update(10, {{':', 2, -2, 0, '})'}})
cn.space.net_box_test_space:delete{10}
cn.space.net_box_test_space:select({}, { iterator = 'ALL' })
-- gh-841: net.box uses incorrect iterator type for select with no arguments
cn.space.net_box_test_space:select()
cn.space.net_box_test_space.index.primary:min()
cn.space.net_box_test_space.index.primary:min(354)
cn.space.net_box_test_space.index.primary:max()
cn.space.net_box_test_space.index.primary:max(234)
cn.space.net_box_test_space.index.primary:count()
cn.space.net_box_test_space.index.primary:count(354)
cn.space.net_box_test_space:get(354)
-- reconnects after errors
box.schema.user.revoke('guest', 'execute', 'universe')
box.schema.func.create('test_foo')
box.schema.user.grant('guest', 'execute', 'function', 'test_foo')
-- -- 1. no reconnect
x_fatal(cn)
cn.state
cn:ping()
cn:call('test_foo')
cn:wait_state('active')
-- -- 2 reconnect
cn = remote.connect(LISTEN.host, LISTEN.service, { reconnect_after = .1 })
cn.space ~= nil
cn.space.net_box_test_space:select({}, { iterator = 'ALL' })
x_fatal(cn)
cn:wait_connected()
cn:wait_state('active')
cn:wait_state({active=true})
cn:ping()
cn.state
cn.space.net_box_test_space:select({}, { iterator = 'ALL' })
x_fatal(cn)
x_select(cn, space.id, 0, box.index.ALL, 0, 0xFFFFFFFF, {})
cn.state
cn:ping()
-- -- dot-new-method
cn1 = remote.new(LISTEN.host, LISTEN.service)
x_select(cn1, space.id, 0, box.index.ALL, 0, 0xFFFFFFF, {})
cn1:close()
-- -- error while waiting for response
type(fiber.create(function() fiber.sleep(.5) x_fatal(cn) end))
function pause() fiber.sleep(10) return true end
box.schema.func.create('pause')
box.schema.user.grant('guest', 'execute', 'function', 'pause')
cn:call('pause')
cn:call('test_foo', {'a', 'b', 'c'})
box.schema.func.drop('pause')
-- call
remote.self:call('test_foo', {'a', 'b', 'c'})
cn:call('test_foo', {'a', 'b', 'c'})
box.schema.func.drop('test_foo')
box.schema.func.create('long_rep')
box.schema.user.grant('guest', 'execute', 'function', 'long_rep')
-- long replies
function long_rep() return { 1, string.rep('a', 5000) } end
res = cn:call('long_rep')
res[1] == 1
res[2] == string.rep('a', 5000)
function long_rep() return { 1, string.rep('a', 50000) } end
res = cn:call('long_rep')
res[1] == 1
res[2] == string.rep('a', 50000)
box.schema.func.drop('long_rep')
-- a.b.c.d
u = '84F7BCFA-079C-46CC-98B4-F0C821BE833E'
X = {}
X.X = X
function X.fn(x,y) return y or x end
box.schema.user.grant('guest', 'execute', 'universe')
cn:close()
cn = remote.connect(LISTEN.host, LISTEN.service)
cn:call('X.fn', {u})
cn:call('X.X.X.X.X.X.X.fn', {u})
cn:call('X.X.X.X:fn', {u})
box.schema.user.revoke('guest', 'execute', 'universe')
cn:close()
-- auth
cn = remote.connect(LISTEN.host, LISTEN.service, { user = 'netbox', password = '123', wait_connected = true })
cn:is_connected()
cn.error
cn.state
|
local preview = {}
-- whether to fade out the default background
preview.hide_background = false
function preview:init(mod, button, menu)
-- code here gets called when the mods are loaded
self.particles = {}
self.particle_timer = 0
button.color = {1, 1, 0.7}
self.menu = menu
end
function preview:update(dt)
-- code here gets called every frame, before any draws
-- to only update while the mod is selected, check self.selected (or self.fade)
local to_remove = {}
for _,particle in ipairs(self.particles) do
particle.radius = particle.radius
particle.radius = particle.radius - (dt * 4)
particle.y = particle.y - particle.speed * (dt / FRAMERATE)
if particle.radius <= 0 then
table.insert(to_remove, particle)
end
end
for _,particle in ipairs(to_remove) do
Utils.removeFromTable(self.particles, particle)
end
self.particle_timer = self.particle_timer + dt
if self.particle_timer >= 0.25 then
self.particle_timer = 0
local radius = math.random() * 48 + 16
table.insert(self.particles, {radius = radius, x = math.random() * SCREEN_WIDTH, y = SCREEN_HEIGHT + radius, max_radius = radius, speed = math.random() * 0.5 + 0.5})
end
end
function preview:draw()
-- code here gets drawn to the background every frame!!
-- make sure to check self.fade or self.selected here
if self.fade > 0 then
love.graphics.setBlendMode("add")
for _,particle in ipairs(self.particles) do
local alpha = (particle.radius / particle.max_radius) * self.fade
love.graphics.setColor(1, 1, 0.5, alpha)
love.graphics.circle("fill", particle.x, particle.y, particle.radius)
end
love.graphics.setBlendMode("alpha")
end
end
function preview:drawOverlay()
-- code here gets drawn above the menu every frame
-- so u can make cool effects
-- if u want
end
return preview
|
--------------------------------------------------------------------------------
-- Module Declaration
--
local mod, CL = BigWigs:NewBoss("Fetid Devourer", 1861, 2146)
if not mod then return end
mod:RegisterEnableMob(133298)
mod.engageId = 2128
mod.respawnTime = 31
--------------------------------------------------------------------------------
-- Locals
--
local trashCount = 0
local stompCount = 1
--------------------------------------------------------------------------------
-- Localization
--
local L = mod:GetLocale()
if L then
L.breath = "{262292} ({18609})" -- Rotting Regurgitation (Breath)
L.breath_desc = 262292
L.breath_icon = 262292
end
--------------------------------------------------------------------------------
-- Initialization
--
function mod:GetOptions()
return {
{262277, "TANK"}, -- Thrashing Terror
"breath", -- Rotting Regurgitation
262288, -- Shockwave Stomp
{262313, "ME_ONLY", "SAY", "SAY_COUNTDOWN"}, -- Malodorous Miasma
{262314, "ME_ONLY", "FLASH", "SAY", "SAY_COUNTDOWN"}, -- Putrid Paroxysm
262364, -- Enticing Essence -- XXX Used for CL.adds right now
262378, -- Fetid Frenzy
"berserk",
}
end
function mod:OnBossEnable()
self:Log("SPELL_CAST_START", "TerribleThrash", 262277)
self:Log("SPELL_CAST_START", "RottingRegurgitation", 262292)
self:Log("SPELL_CAST_START", "ShockwaveStomp", 262288)
self:Log("SPELL_CAST_SUCCESS", "ShockwaveStompSuccess", 262288) -- sometimes doesn't finish the cast, increasing counter on _SUCCESS
self:Log("SPELL_AURA_APPLIED", "MalodorousMiasmaApplied", 262313)
self:Log("SPELL_AURA_APPLIED_DOSE", "MalodorousMiasmaApplied", 262313)
self:Log("SPELL_AURA_REMOVED", "MalodorousMiasmaRemoved", 262313)
self:Log("SPELL_AURA_APPLIED", "PutridParoxysmApplied", 262314)
self:Log("SPELL_AURA_APPLIED_DOSE", "PutridParoxysmApplied", 262314)
self:Log("SPELL_AURA_REMOVED", "PutridParoxysmRemoved", 262314)
self:Log("SPELL_CAST_START", "EnticingEssence", 262364)
self:Log("SPELL_AURA_APPLIED", "FetidFrenzy", 262378)
-- Adds spawning
self:Log("SPELL_CAST_SUCCESS", "TrashChuteVisualState", 274470)
end
function mod:OnEngage()
trashCount = 0
stompCount = 1
self:CDBar(262277, 5.5) -- Terrible Thrash
self:CDBar("breath", self:Easy() and 30.5 or 41.5, 18609, 262292) -- Breath (Rotting Regurgitation)
if not self:Easy() then
self:Bar(262288, 26, CL.count:format(self:SpellName(262288), stompCount)) -- Shockwave Stomp
end
self:Bar(262364, self:Easy() and 50 or 35.5, self:SpellName(-18875)) -- Waste Disposal Units
self:Berserk(330)
end
--------------------------------------------------------------------------------
-- Event Handlers
--
function mod:TerribleThrash(args)
self:Message2(args.spellId, "purple")
self:PlaySound(args.spellId, "alert")
self:CDBar(args.spellId, 6)
end
function mod:RottingRegurgitation(args)
self:Message2("breath", "yellow", 18609, 262292) -- Breath (Rotting Regurgitation)
self:PlaySound("breath", "alert")
self:CDBar("breath", self:Easy() and 30.5 or 46, 18609, 262292) -- 41.3, 52.1, 46.3, 41.9, 32.6, 34.1 XXX
self:CastBar("breath", 6.5, 18609, 262292)
end
function mod:ShockwaveStomp(args)
self:Message2(args.spellId, "orange", CL.count:format(args.spellName, stompCount))
self:PlaySound(args.spellId, "alarm")
end
function mod:ShockwaveStompSuccess(args)
stompCount = stompCount + 1
self:Bar(args.spellId, 26.5, CL.count:format(args.spellName, stompCount))
end
function mod:MalodorousMiasmaApplied(args)
local amount = args.amount or 1
if amount == 1 then
self:TargetMessage2(args.spellId, "orange", args.destName)
else
self:StackMessage(args.spellId, args.destName, args.amount, "orange")
end
self:PlaySound(args.spellId, self:Mythic() and "warning" or "info", nil, args.destName) -- spread in Mythic
if self:Mythic() and self:Me(args.destGUID) then
if amount == 1 then
self:Say(args.spellId)
end
self:CancelSayCountdown(args.spellId)
self:SayCountdown(args.spellId, 18)
end
end
function mod:MalodorousMiasmaRemoved(args)
if self:Mythic() and self:Me(args.destGUID) then
self:CancelSayCountdown(args.spellId)
end
end
function mod:PutridParoxysmApplied(args)
local amount = args.amount or 1
if amount == 1 then
self:TargetMessage2(args.spellId, "orange", args.destName)
else
self:StackMessage(args.spellId, args.destName, args.amount, "orange")
end
self:PlaySound(args.spellId, "warning", nil, args.destName)
if self:Me(args.destGUID) then
self:Flash(args.spellId)
if self:Mythic() then
if amount == 1 then
self:Say(args.spellId)
end
self:CancelSayCountdown(args.spellId)
self:SayCountdown(args.spellId, 6)
end
end
end
function mod:PutridParoxysmRemoved(args)
if self:Mythic() and self:Me(args.destGUID) then
self:CancelSayCountdown(args.spellId)
end
end
do
local prev = 0
function mod:EnticingEssence(args)
local t = args.time
if t-prev > 2 then
prev = t
self:Message2(args.spellId, "red")
self:PlaySound(args.spellId, "warning")
end
end
end
function mod:FetidFrenzy(args)
self:Message2(args.spellId, "cyan")
self:PlaySound(args.spellId, "info")
end
function mod:TrashChuteVisualState()
trashCount = trashCount + 1
if (self:Mythic() and trashCount % 3 == 2) or (not self:Mythic() and trashCount % 2 == 1) then -- Small add
self:Message2(262364, "cyan", CL.incoming:format(self:SpellName(-17867)))
self:PlaySound(262364, "long")
if not self:Mythic() then
self:Bar(262364, self:Mythic() and 75 or self:Easy() and 60 or 55, self:SpellName(-18875)) -- Waste Disposal Units
self:Bar(262364, 10, CL.spawning:format(CL.adds)) -- Adds / Enticing Essence
end
elseif (self:Mythic() and trashCount % 3 == 1) then -- Big Add
self:Message2(262364, "cyan", CL.incoming:format(self:SpellName(-18565)))
self:PlaySound(262364, "long")
self:Bar(262364, 75, self:SpellName(-18875)) -- Waste Disposal Units
self:Bar(262364, 20, CL.spawning:format(CL.adds)) -- Adds
end
end
|
-- Wifi
-- Notify on wifi changes
-----------------------------------------------
local m = {}
local alert = require('hs.alert').show
local wifi = require('hs.wifi')
-- keep track of the previously connected network
local lastNetwork = wifi.currentNetwork()
-- Open Hotspot Dashboard once connected to WiFi network at home.
local homeWifi = "Lau1A"
local loginSiteURL = "http://hotspot.in/login"
local defaultBrowser = "Google Chrome"
m.config = {
icon = 'assets/icons/wifi/airport.png'
}
-- callback called when wifi network changes
local function ssidChangedCallback()
local newNetwork = wifi.currentNetwork()
-- send notification if we're on a different network than we were before
if lastNetwork ~= newNetwork then
hs.notify.new({
title = 'Wi-Fi Status',
subTitle = newNetwork and 'Network:' or 'Disconnected',
informativeText = newNetwork,
contentImage = m.config.icon,
autoWithdraw = true,
hasActionButton = false,
}):send()
lastNetwork = newNetwork
end
end
-- Get the wifi status
m.status = function()
output = io.popen("networksetup -getairportpower en0", "r")
result = output:read()
return result:find(": On") and "on" or "off"
end
-- Toggle the wifi on and off
m.toggle = function()
if m.status() == "on" then
alert("Wi-Fi: Off")
os.execute("networksetup -setairportpower en0 off")
else
alert("Wi-Fi: On")
os.execute("networksetup -setairportpower en0 on")
end
end
m.loginWifi = function ()
local currentWifi = hs.wifi.currentNetwork()
-- short-circuit if disconnecting
if not currentWifi then return end
local note = hs.notify.new({
title="Connected to WiFi",
informativeText="Now connected to " .. currentWifi
}):send()
--Dismiss notification in 3 seconds
--Notification does not auto-withdraw if Hammerspoon is set to use "Alerts"
--in System Preferences > Notifications
hs.timer.doAfter(3, function ()
note:withdraw()
note = nil
end)
if currentWifi == homeWifi then
-- Allowance for internet connectivity delays.
hs.timer.doAfter(3, function ()
hs.network.ping.ping(
"8.8.8.8", 1, 0.01, 1.0, "any",
function(object, message, seqnum, error)
if message == "didFinish" then
avg = tonumber(string.match(object:summary(), '/(%d+.%d+)/'))
if avg == 0.0 then
-- @todo: Explore possibilities of using `hs.webview`
hs.execute("open " .. loginSiteURL)
--Make notification clickable. Browser window will be focused on click:
hs.notify.new(function ()
hs.application.launchOrFocus(defaultBrowser)
end, {title="No network. Open Wifi Login page!"}):send()
end
end
end
)
end)
end
end
m.reconnectWifi = function()
local ssid = hs.wifi.currentNetwork()
if not ssid then
return
end
hs.alert.show("Reconnecting to: " .. ssid)
hs.execute("networksetup -setairportpower en0 off")
hs.execute("networksetup -setairportpower en0 on")
end
function pingResult(object, message, seqnum, error)
if message == "didFinish" then
avg = tonumber(string.match(object:summary(), '/(%d+.%d+)/'))
if avg == 0.0 then
hs.alert.show("No network")
elseif avg < 200.0 then
hs.alert.show("Network good (" .. avg .. "ms)")
elseif avg < 500.0 then
hs.alert.show("Network poor (" .. avg .. "ms)")
else
hs.alert.show("Network bad (" .. avg .. "ms)")
end
end
end
m.ping = function()
hs.network.ping.ping("8.8.8.8", 1, 0.01, 1.0, "any", pingResult)
end
-- Start the module
m.start = function()
m.watcher = wifi.watcher.new(ssidChangedCallback)
m.watcher:start()
end
-- Stop the module
m.stop = function()
m.watcher:stop()
m.watcher = nil
end
-- Add triggers
-----------------------------------------------
m.triggers = {}
m.triggers["WiFi Toggle"] = m.toggle
m.triggers["WiFi Reconnect"] = m.reconnectWifi
m.triggers["Ping"] = m.ping
----------------------------------------------------------------------------
return m
|
local M = {}
function M.attach_node()
local dap = require 'dap'
print 'attaching'
dap.run {
type = 'node2',
request = 'attach',
cwd = vim.fn.getcwd(),
sourceMaps = true,
protocol = 'inspector',
skipFiles = { '<node_internals>/**/*.js' },
}
end
return M
|
local ArrayT = require('restructure.Array')
local NumberT = require('restructure.Number').Number
local utils = require('restructure.utils')
local LazyArray = {}
LazyArray.__index = LazyArray
local LazyArrayT = {}
LazyArrayT.__index = LazyArrayT
setmetatable(LazyArrayT, ArrayT)
function LazyArrayT.new(...)
local a = ArrayT.new(...)
setmetatable(a, LazyArrayT)
return a
end
function LazyArrayT:decode(stream, parent)
local pos = stream.buffer.pos
local length = utils.resolveLength(self.length, stream, parent)
if utils.instanceOf(length, NumberT) then
parent = {
parent = parent,
_startOffset = pos,
_currentOffset = 0,
_length = length
}
end
local res = LazyArray.new(self.type, length, stream, parent)
return res
end
function LazyArrayT:size(val, ctx)
if utils.instanceOf(val,LazyArray) then val = val:toArray() end
return ArrayT.size(self, val, ctx)
end
function LazyArrayT:encode(stream, val, ctx)
if utils.instanceOf(val, LazyArray) then val = val:toArray() end
return ArrayT.encode(self, stream, val, ctx)
end
function LazyArray.new(type, length, stream, ctx)
local a = setmetatable({}, LazyArray)
a.type = type
a.length = length
a.stream = stream
a.ctx = ctx
a.base = a.stream.buffer.pos
a.items = {}
return a
end
function LazyArray:get(index)
if index < 0 or index >= self.length then return nil end
if not self.items[index + 1] then
local pos = self.stream.buffer.pos
self.stream.buffer.pos = self.base + self.type:size(nil, self.ctx) * index
self.items[index + 1] = self.type:decode(self.stream, self.ctx)
self.stream.buffer.pos = pos
end
return self.items[index + 1]
end
function LazyArray:toArray()
local a = {}
for i = 1, self.length do
a[i] = self:get(i - 1)
end
return a
end
return LazyArrayT
|
--[[
# ClassModel Class
refs: http://lua-users.org/wiki/ObjectOrientationTutorial
author: Alysson Bruno <[email protected]>
This model of class for lua is make with function. One class can be a Child.
]]
MAKE_CLASS = function(dad, child)
local this = {
self={},
public={ Class=child},
instance={},
init_values={},
owner=nil,
super = require 'ClassModel'
}
table.insert(this.instance,this.public.Class)
local s = dad()
if s then
table.insert(this.instance,s.Class)
for key, data in pairs(s) do
if not this.public[key] then
this.public[key] = data
end
end
this.self = s.getpublicdata()
end
return this
end
local Class = function (...)
local super = nil -- for child class make require 'dadclass' -- inheritance implemantation
local owner = nil -- composition implemantation
local public = { Class='ClassModel'}
local self = {}
local init_values = {...}
local instance = {}
local init = function (obj)
local self = obj or {}
return self
end
--[[ Class Definition functions ]]--
public.getpublicdata = function()
return self
end
public.isinstanceof = function(class)
for _,c in pairs(instance) do
if c == class then
return true
end
end
return false
end
public.getowner = function()
return owner
end
table.insert(instance,public.Class)
-- composition
local c = init_values[1]
if (type(c) == 'function') or (c and c.isinstanceof and c.isinstanceof('ClassModel')) then
owner = table.remove(init_values,1)
c=nil
end
-- inheritance
local s = super and super(init_values[1]) or false
if s then
table.insert(instance,s.Class)
for key, data in pairs(s) do
if not public[key] then
public[key] = data
end
end
self = init(s.getpublicdata())
s=nil
else
self = init(init_values[1])
end
return public
end
local ClassExport = Class
return ClassExport
|
--utility.lua
local otime = os.time
local odate = os.date
local log_err = logger.err
local tunpack = table.unpack
local dsethook = debug.sethook
local dtraceback = debug.traceback
local ssplit = string_ext.split
local KernCode = enum("KernCode")
local PeriodTime = enum("PeriodTime")
local SUCCESS = KernCode.SUCCESS
local DAY_S = PeriodTime.DAY_S
utility = {}
function utility.check_success(code)
return code == SUCCESS
end
function utility.check_failed(code)
return code ~= SUCCESS
end
-- 启动死循环监控
local check_close_loop = true
function utility.check_endless_loop()
if check_close_loop then
local debug_hook = function()
local now = otime()
if now - quanta.now >= 10 then
log_err("check_endless_loop:%s", dtraceback())
end
end
dsethook(debug_hook, "l")
end
end
--获取utc时间戳
local utc_diff_time = nil
function utility.utc_time(time)
if not time or time <= 0 then
time = quanta.now
end
if not utc_diff_time then
local nowt = odate("*t", time)
local utct = odate("!*t", time)
utc_diff_time = (nowt.hour - utct.hour) * PeriodTime.HOUR_S
end
return time - utc_diff_time
end
--获取一个类型的时间版本号
function utility.edition(period, time, offset)
local edition = 0
if not time or time <= 0 then
time = quanta.now
end
local t = odate("*t", time - (offset or 0))
if period == "hour" then
edition = time // PeriodTime.HOUR_S
elseif period == "day" then
edition = time // DAY_S
elseif period == "week" then
--19700101是星期四,周日为每周第一天
edition = ((time // DAY_S) + 4) // 7
elseif period == "month" then
edition = t.year * 100 + t.month
elseif period == "year" then
edition = t.year
end
return edition
end
--获取UTC的时间版本号
function utility.edition_utc(period, time, offset)
local utime = utility.utc_time(time)
return utility.edition(period, utime, offset)
end
--解析ip地址
function utility.addr(addr)
return tunpack(ssplit(addr, ":"))
end
|
object_static_structure_dathomir_decal_smear_03 = object_static_structure_dathomir_shared_decal_smear_03:new {
}
ObjectTemplates:addTemplate(object_static_structure_dathomir_decal_smear_03, "object/static/structure/dathomir/decal_smear_03.iff")
|
-- 原作:ShestakUI 的一个通告组件
-- 原作者:Shestak (http://www.wowinterface.com/downloads/info19033-ShestakUI.html)
-- 修改:houshuu
-------------------
-- 主要修改条目:
-- 模块化
-- 职业染色
-- 修改函数判定参数
-- 修正宠物打断不通告问题
-- 添加嘲讽模块
-- 增减了部分光环通告
-- 汉化使其更加适合中文语法
-- 频道检测更加多样化
-- 添加了一些可设置项
local E, L, V, P, G = unpack(ElvUI)
local WT = E:GetModule("WindTools")
local AnnounceSystem = E:NewModule('Wind_AnnounceSystem', 'AceHook-3.0', 'AceEvent-3.0', 'AceTimer-3.0');
local format = string.format
local pairs = pairs
local myName = UnitName("player")
local simpleline = "|cffe84393----------------------|r"
local simplestart = "|cffe84393|--|r"
local ASL = {}
if GetLocale() == "zhTW" then
ASL = {
["AS"] = "通告系統",
["UseSpellNoTarget"] = "%s 使用了 %s",
["UseSpellTarget"] = "%s 使用了 %s -> %s",
["UseSpellTargetInChat"] = "|cffd63031通告系統:|r %s |cff00ff00使用了|r %s -> |cfffdcb6e%s|r",
["PutNormal"] = "%s 放置了 %s",
["PutFeast"] = "天啊,土豪 %s 竟然擺出了 %s!",
["PutPortal"] = "%s 開啟了 %s",
["PutRefreshmentTable"] = "%s 使用了 %s,各位快來領餐包哦!",
["RitualOfSummoning"] = "%s 正在進行 %s,請配合點門哦!",
["SoulWell"] = "%s 發糖了,快點拿喲!",
["Interrupt"] = "我打斷了 %s 的 >%s<!",
["InterruptInChat"] = "|cffd63031通告系統:|r |cff00ff00成功打斷|r -> |cfffdcb6e%s|r >%s<!",
["Thanks"] = "%s,謝謝你復活我:)",
["Taunt"] = "我成功嘲諷了 %s!",
["TauntInChat"] = "|cffd63031通告系統:|r |cff00ff00成功嘲諷|r -> |cfffdcb6e%s|r!",
["PetTaunt"] = "我的寵物成功嘲諷了 %s!",
["PetTauntInChat"] = "|cffd63031通告系統:|r |cff00ff00寵物成功嘲諷|r -> |cfffdcb6e%s|r!",
["OtherTankTaunt"] = "%s 成功嘲諷了 %s",
["OtherTankTauntInChat"] = "|cffd63031通告系統:|r %s |cff00ff00成功嘲諷|r -> |cfffdcb6e%s|r!",
["TauntMiss"] = "我嘲諷 %s 失敗!",
["TauntMissInChat"] = "|cffd63031通告系統:|r |cffff0000嘲諷失敗|r -> |cfffdcb6e%s|r!",
["PetTauntMiss"] = "我的寵物嘲諷了 %s 失敗!",
["PetTauntMissInChat"] = "|cffd63031通告系統:|r |cffff0000寵物嘲諷失敗|r -> |cfffdcb6e%s|r!",
["OtherTankTauntMiss"] = "%s 嘲諷 %s 失敗!",
["OtherTankTauntMissInChat"] = "|cffd63031通告系統:|r %s |cffff0000嘲諷失敗|r -> |cfffdcb6e%s|r!",
}
elseif GetLocale() == "zhCN" then
ASL = {
["AS"] = "通告系统",
["UseSpellNoTarget"] = "%s 使用了 %s",
["UseSpellTarget"] = "%s 使用了 %s -> %s",
["UseSpellTargetInChat"] = "|cffd63031通告系统:|r %s |cff00ff00使用了|r %s -> |cfffdcb6e%s|r",
["PutNormal"] = "%s 放置了 %s",
["PutFeast"] = "天啊,土豪 %s 竟然摆出了 %s!",
["PutPortal"] = "%s 开启了 %s",
["PutRefreshmentTable"] = "%s 使用了 %s,各位快來领面包哦!",
["RitualOfSummoning"] = "%s 正在进行 %s,请配合点门哦!",
["SoulWell"] = "%s 发糖了,快点拿哟!",
["Interrupt"] = "我打断了 %s 的 >%s<!",
["InterruptInChat"] = "|cffd63031通告系统:|r |cff00ff00成功打断|r -> |cfffdcb6e%s|r >%s<!",
["Thanks"] = "%s,谢谢你复活我:)",
["Taunt"] = "我成功嘲讽了 %s!",
["TauntInChat"] = "|cffd63031通告系統:|r |cff00ff00成功嘲讽|r -> |cfffdcb6e%s|r!",
["PetTaunt"] = "我的宠物成功嘲讽了 %s!",
["PetTauntInChat"] = "|cffd63031通告系统:|r |cff00ff00宠物成功嘲讽|r -> |cfffdcb6e%s|r!",
["OtherTankTaunt"] = "%s 成功嘲讽了 %s",
["OtherTankTauntInChat"] = "|cffd63031通告系统:|r %s |cff00ff00成功嘲讽|r -> |cfffdcb6e%s|r!",
["TauntMiss"] = "我嘲讽 %s 失败!",
["TauntMissInChat"] = "|cffd63031通告系统:|r |cffff0000嘲讽失败|r -> |cfffdcb6e%s|r!",
["PetTauntMiss"] = "我的宠物嘲讽了 %s 失败!",
["PetTauntMissInChat"] = "|cffd63031通告系统:|r |cffff0000宠物嘲讽失败|r -> |cfffdcb6e%s|r!",
["OtherTankTauntMiss"] = "%s 嘲讽 %s 失败!",
["OtherTankTauntMissInChat"] = "|cffd63031通告系统:|r %s |cffff0000嘲讽失败|r -> |cfffdcb6e%s|r!",
}
else
ASL = {
["AS"] = "Announce System",
["UseSpellNoTarget"] = "%s casted %s",
["UseSpellTarget"] = "%s casted %s -> %s",
["UseSpellTargetInChat"] = "|cffd63031Announce System:|r %s |cff00ff00casted|r %s -> |cfffdcb6e%s|r",
["PutNormal"] = "%s puts %s",
["PutFeast"] = "OMG, wealthy %s puts %s!",
["PutPortal"] = "%s opened %s",
["PutRefreshmentTable"] = "%s casted %s, today's special is Anchovy Pie!",
["RitualOfSummoning"] = "%s is casting %s, please assist!",
["SoulWell"] = "%s is handing out cookies, go and get one!",
["Interrupt"] = "I interrupted %s 's >%s<!",
["InterruptInChat"] = "|cffd63031Announce System:|r |cff00ff00interrupted|r -> |cfffdcb6e%s|r >%s<!",
["Thanks"] = "%s, thank you for reviving me:)",
["Taunt"] = "I taunted %s successfully!",
["TauntInChat"] = "|cffd63031Announce System:|r |cff00ff00taunted|r -> |cfffdcb6e%s|rsuccessfully!",
["PetTaunt"] = "My pet taunted %s successfully!",
["PetTauntInChat"] = "|cffd63031Announce System:|r |cff00ff00My pet taunted|r -> |cfffdcb6e%s|rsuccessfully!",
["OtherTankTaunt"] = "%s taunted %s successfully",
["OtherTankTauntInChat"] = "|cffd63031Announce System:|r %s |cff00ff00taunted|r -> |cfffdcb6e%s|rsuccessfully!",
["TauntMiss"] = "I failed on taunting %s!",
["TauntMissInChat"] = "|cffd63031Announce System:|r |cffff0000failed on taunting|r -> |cfffdcb6e%s|r!",
["PetTauntMiss"] = "My pet failed on taunting %s!",
["PetTauntMissInChat"] = "|cffd63031Announce System:|r |cffff0000My pet failed on taunting|r -> |cfffdcb6e%s|r!",
["OtherTankTauntMiss"] = "%s failed on taunting %s!",
["OtherTankTauntMissInChat"] = "|cffd63031Announce System:|r %s |cffff0000failed on taunting|r -> |cfffdcb6e%s|r!",
}
end
----------------------------------------------------------------------------------------
-- 名字染色
----------------------------------------------------------------------------------------
local function AddClassColor(playerID)
local _, englishClass, _, _, _, playerName = GetPlayerInfoByGUID(playerID)
if englishClass then
local color = RAID_CLASS_COLORS[englishClass]
local colorString = string.format("ff%02x%02x%02x", color.r*255, color.g*255, color.b*255)
return "|c"..colorString..playerName.."|r"
else
return playerName
end
end
----------------------------------------------------------------------------------------
-- 智能頻道檢測
----------------------------------------------------------------------------------------
local function CheckChat(warning)
-- 随机团队频道 > 副本警告频道 > 副本频道 > 队伍频道 > 说频道
if IsInGroup(LE_PARTY_CATEGORY_INSTANCE) then
return "INSTANCE_CHAT"
elseif IsInRaid(LE_PARTY_CATEGORY_HOME) then
if warning and (UnitIsGroupLeader("player") or UnitIsGroupAssistant("player") or IsEveryoneAssistant()) then
return "RAID_WARNING"
else
return "RAID"
end
elseif IsInGroup(LE_PARTY_CATEGORY_HOME) then
return "PARTY"
end
return "SAY"
end
----------------------------------------------------------------------------------------
-- 打断频道检测
----------------------------------------------------------------------------------------
local function CheckChatInterrupt ()
-- 随机团队频道 > 副本频道 > 队伍频道 > 大喊频道(设定的话) > 聊天框显示
if IsInGroup(LE_PARTY_CATEGORY_INSTANCE) then
return "INSTANCE_CHAT"
elseif IsInRaid(LE_PARTY_CATEGORY_HOME) then
return "RAID"
elseif IsInGroup(LE_PARTY_CATEGORY_HOME) then
return "PARTY"
elseif E.db.WindTools["More Tools"]["Announce System"]["Interrupt"]["SoloYell"] then
return "YELL"
end
return "ChatFrame"
end
----------------------------------------------------------------------------------------
-- 嘲讽频道检测
----------------------------------------------------------------------------------------
local function CheckChatTaunt ()
if IsInGroup(LE_PARTY_CATEGORY_INSTANCE) then
return "INSTANCE_CHAT"
elseif IsInRaid(LE_PARTY_CATEGORY_HOME) then
return "RAID"
elseif IsInGroup(LE_PARTY_CATEGORY_HOME) then
return "PARTY"
end
return "YELL"
end
local ThanksSpells = {
-- 复活技能
[20484] = true, -- 復生
[61999] = true, -- 盟友復生
[20707] = true, -- 靈魂石
[50769] = true, -- 復活
[2006] = true, -- 復活術
[7328] = true, -- 救贖
[2008] = true, -- 先祖之魂
[115178] = true, -- 回命訣
}
local CombatResSpells = {
-- 战复技能
[61999] = true, -- 盟友復生
[20484] = true, -- 復生
[20707] = true, -- 靈魂石
}
local TransferThreatSpells = {
-- 仇恨转移技能
[34477] = true, -- 誤導
[57934] = true, -- 偷天換日
}
local FeastSpells = {
-- 大餐通報列表
[126492] = true, -- 燒烤盛宴
[126494] = true, -- 豪华燒烤盛宴
[126495] = true, -- 快炒盛宴
[126496] = true, -- 豪华快炒盛宴
[126501] = true, -- 烘烤盛宴
[126502] = true, -- 豪华烘烤盛宴
[126497] = true, -- 燉煮盛宴
[126498] = true, -- 豪华燉煮盛宴
[126499] = true, -- 蒸煮盛宴
[126500] = true, -- 豪華蒸煮盛宴
[104958] = true, -- 熊貓人盛宴
[126503] = true, -- 美酒盛宴
[126504] = true, -- 豪華美酒盛宴
[145166] = true, -- 拉麵推車
[145169] = true, -- 豪華拉麵推車
[145196] = true, -- 熊貓人國寶級拉麵推車
[188036] = true, -- 灵魂药锅
[201351] = true, -- 丰盛大餐
[201352] = true, -- 苏拉玛奢华大餐
[259409] = true, -- 海帆盛宴
[259410] = true, -- 船长盛宴佳肴
[276972] = true, -- 秘法药锅
}
local Bots = {
-- 機器人通報列表
[22700] = true, -- 修理機器人74A型
[44389] = true, -- 修理機器人110G型
[54711] = true, -- 廢料機器人
[67826] = true, -- 吉福斯
[126459] = true, -- 布靈登4000型
[161414] = true, -- 布靈登5000型
[200061] = true, -- 召唤里弗斯
[200204] = true, -- 自動鐵錘模式(里弗斯)
[200205] = true, -- 自動鐵錘模式(里弗斯)
[200210] = true, -- 故障检测模式(里弗斯)
[200211] = true, -- 故障检测模式(里弗斯)
[200212] = true, -- 烟花表演模式(里弗斯)
[200214] = true, -- 烟花表演模式(里弗斯)
[200215] = true, -- 零食发放模式(里弗斯)
[200216] = true, -- 零食发放模式(里弗斯)
[200217] = true, -- 华丽模式(布靈登6000型)(里弗斯)
[200218] = true, -- 华丽模式(布靈登6000型)(里弗斯)
[200219] = true, -- 驾驶战斗模式(里弗斯)
[200220] = true, -- 驾驶战斗模式(里弗斯)
[200221] = true, -- 虫洞发生器模式(里弗斯)
[200222] = true, -- 虫洞发生器模式(里弗斯)
[200223] = true, -- 热砧模式(里弗斯)
[200225] = true, -- 热砧模式(里弗斯)
[199109] = true, -- 自動鐵錘
[226241] = true, -- 宁神圣典
[256230] = true, -- 静心圣典
}
local Toys = {
-- 玩具
[61031] = true, -- 玩具火車組
[49844] = true, -- 恐酒遙控器
}
local PortalSpells = {
-- 傳送門通報列表
-- 聯盟
[10059] = true, -- 暴風城
[11416] = true, -- 鐵爐堡
[11419] = true, -- 達納蘇斯
[32266] = true, -- 艾克索達
[49360] = true, -- 塞拉摩
[33691] = true, -- 撒塔斯
[88345] = true, -- 托巴拉德
[132620] = true, -- 恆春谷
[176246] = true, -- 暴風之盾
-- 部落
[11417] = true, -- 奧格瑪
[11420] = true, -- 雷霆崖
[11418] = true, -- 幽暗城
[32267] = true, -- 銀月城
[49361] = true, -- 斯通納德
[35717] = true, -- 撒塔斯
[88346] = true, -- 托巴拉德
[132626] = true, -- 恆春谷
[176244] = true, -- 戰爭之矛
-- 中立
[53142] = true, -- 達拉然
[120146] = true, -- 遠古達拉然
}
local TauntSpells = {
[355] = true, -- Warrior
-- [114198] = true, -- Warrior (Mocking Banner)
[2649] = true, -- Hunter (Pet)
[20736] = true, -- Hunter (Distracting Shot)
[123588] = true, -- Hunter (Distracting Shot - glyphed)
[6795] = true, -- Druid
[17735] = true, -- Warlock (Voidwalker)
[97827] = true, -- Warlock (Provocation (Metamorphosis))
[49560] = true, -- Death Knight (Death Grip (aura))
[56222] = true, -- Death Knight
[73684] = true, -- Shaman (Unleash Earth)
[62124] = true, -- Paladin
[116189] = true, -- Monk (Provoke (aura))
[118585] = true, -- Monk (Leer of the Ox)
[118635] = true, -- Monk (Black Ox Provoke)
}
----------------------------------------------------------------------------------------
-- 团队战斗有用技能提示
----------------------------------------------------------------------------------------
function AnnounceSystem:RaidUsefulSpells()
local frame = CreateFrame("Frame")
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
frame:SetScript("OnEvent", function(self, event)
local _, subEvent, _, _, srcName, _, _, _, destName, _, _, spellID = CombatLogGetCurrentEventInfo()
if not IsInGroup() or InCombatLockdown() or not subEvent or not spellID or not srcName then return end
if not UnitInRaid(srcName) and not UnitInParty(srcName) then return end
local srcName = srcName:gsub("%-[^|]+", "")
if subEvent == "SPELL_CAST_SUCCESS" then
-- 召喚餐點桌
if spellID == 43987 then
SendChatMessage(format(ASL["PutRefreshmentTable"], srcName, GetSpellLink(spellID)), CheckChat(true))
-- 召喚儀式
elseif spellID == 698 then
SendChatMessage(format(ASL["RitualOfSummoning"], srcName, GetSpellLink(spellID)), CheckChat(true))
-- 大餐
elseif FeastSpells[spellID] then
SendChatMessage(format(ASL["PutFeast"], srcName, GetSpellLink(spellID)), CheckChat(true))
end
elseif subEvent == "SPELL_SUMMON" then
-- 修理機器人
if Bots[spellID] then
SendChatMessage(format(ASL["PutNormal"], srcName, GetSpellLink(spellID)), CheckChat(true))
end
elseif subEvent == "SPELL_CREATE" then
-- MOLL-E 郵箱
if spellID == 54710 then
SendChatMessage(format(ASL["PutNormal"], srcName, GetSpellLink(spellID)), CheckChat(true))
-- 靈魂之井
elseif spellID == 29893 then
SendChatMessage(format(ASL["SoulWell"], srcName), CheckChat(true))
-- 玩具
elseif Toys[spellID] then
SendChatMessage(format(ASL["PutNormal"], srcName, GetSpellLink(spellID)), CheckChat())
-- 傳送門
elseif PortalSpells[spellID] then
SendChatMessage(format(ASL["PutPortal"], srcName, GetSpellLink(spellID)), CheckChat(true))
end
-- elseif subEvent == "SPELL_AURA_APPLIED" then
-- -- 火鷄羽毛 及 派對手榴彈
-- if spellID == 61781 or ((spellID == 51508 or spellID == 51510)) then
-- SendChatMessage(format(ASL["UseSpellNoTarget"], srcName, GetSpellLink(spellID)), CheckChat())
-- end
end
end)
end
----------------------------------------------------------------------------------------
-- 战复 / 误导
----------------------------------------------------------------------------------------
function AnnounceSystem:ResAndThreat()
local frame = CreateFrame("Frame")
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
frame:SetScript("OnEvent", function(self, event)
local _, event, _, sourceGUID, sourceName, _, _, destGUID, destName, _, _, spellID = CombatLogGetCurrentEventInfo()
local _, _, difficultyID = GetInstanceInfo()
if event ~= "SPELL_CAST_SUCCESS" then return end
if destName then destName = destName:gsub("%-[^|]+", "") end
if sourceName then sourceName = sourceName:gsub("%-[^|]+", "") else return end
-- 在副本里启用战复技能提示
if difficultyID ~= 0 then
if CombatResSpells[spellID] then
if destName == nil then
SendChatMessage(format(ASL["UseSpellNoTarget"], sourceName, GetSpellLink(spellID)), CheckChat())
else
SendChatMessage(format(ASL["UseSpellTarget"], sourceName, GetSpellLink(spellID), destName), CheckChat())
end
end
end
-- 仇恨转移技能提示
if TransferThreatSpells[spellID] then
if destName == myName or sourceName == myName then
-- 如果自己被误导或者自己误导别人,用表情进行通告
-- 其他时候则显示在聊天框
SendChatMessage(format(": "..ASL["UseSpellTarget"], sourceName, GetSpellLink(spellID), destName), "EMOTE")
else
-- 如果确认转移目标是玩家的话,进行职业染色
if strsplit("-", destGUID) == "Player" then
ChatFrame1:AddMessage(format(ASL["UseSpellTargetInChat"], AddClassColor(sourceGUID), GetSpellLink(spellID), AddClassColor(destGUID)))
else
ChatFrame1:AddMessage(format(ASL["UseSpellTargetInChat"], AddClassColor(sourceGUID), GetSpellLink(spellID), destName))
end
end
end
end)
end
----------------------------------------------------------------------------------------
-- 复活感谢
----------------------------------------------------------------------------------------
function AnnounceSystem:ResThanks()
local frame = CreateFrame("Frame")
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
frame:SetScript("OnEvent", function(self,event)
local _, subEvent, _, _, buffer, _, _, _, player, _, _, spell = CombatLogGetCurrentEventInfo()
for key, value in pairs(ThanksSpells) do
if spell == key and value == true and player == myName and buffer ~= myName and subEvent == "SPELL_CAST_SUCCESS" then
local thanksTargetName = buffer:gsub("%-[^|]+", "") -- 去除服务器名
SendChatMessage(format(ASL["Thanks"], thanksTargetName), "WHISPER", nil, buffer)
end
end
end)
end
----------------------------------------------------------------------------------------
-- 打断
----------------------------------------------------------------------------------------
function AnnounceSystem:Interrupt()
local frame = CreateFrame("Frame")
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
frame:SetScript("OnEvent", function(self,event)
-- 回復原版本,待查看
local _, event, _, sourceGUID, _, _, _, _, destName, _, _, _, _, _, spellID = CombatLogGetCurrentEventInfo()
-- 1.3.0 @Someblu 貌似改錯了
-- local _, event, _, sourceGUID, _, _, _, _, destName, _, _, spellID = CombatLogGetCurrentEventInfo()
-- 打断
if not (event == "SPELL_INTERRUPT" and spellID) then return end
local canAnnounce = false
if sourceGUID == UnitGUID("player") then
canAnnounce = true
elseif sourceGUID == UnitGUID("pet") and E.db.WindTools["More Tools"]["Announce System"]["Interrupt"]["IncludePet"] then
canAnnounce = true
else
canAnnounce = false
end
if canAnnounce then
local destChannel = CheckChatInterrupt()
if destChannel == "ChatFrame" then
-- 如果没有设定个人情况发送到大喊频道,就在聊天框显示一下(就自己能看到)
ChatFrame1:AddMessage(format(ASL["InterruptInChat"], destName, GetSpellLink(spellID)))
else
-- 智能检测频道并发送信息
SendChatMessage(format(ASL["Interrupt"], destName, GetSpellLink(spellID)), destChannel)
end
end
end)
end
----------------------------------------------------------------------------------------
-- 嘲讽
----------------------------------------------------------------------------------------
function AnnounceSystem:Taunt()
local frame = CreateFrame("Frame")
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
frame:SetScript("OnEvent", function(self, event)
-- 回復原版本,待查看
local _, event, _, sourceGUID, sourceName, _, _, _, destName, _, _, spellID, _, _, missType = CombatLogGetCurrentEventInfo()
-- 1.3.0 @Someblu 貌似改錯了
-- local _, event, _, sourceGUID, sourceName, _, _, _, destName, _, _, spellID = CombatLogGetCurrentEventInfo()
-- 嘲讽
if event == "SPELL_AURA_APPLIED" and TauntSpells[spellID] then
-- 如果施放嘲讽技能成功
if sourceGUID == UnitGUID("player") then
-- 玩家嘲讽
if E.db.WindTools["More Tools"]["Announce System"]["Taunt"]["PlayerSmart"] then
-- 玩家嘲讽智能喊话
SendChatMessage(format(ASL["Taunt"], destName), CheckChatTaunt())
else
-- 玩家嘲讽信息显示于综合
ChatFrame1:AddMessage(format(ASL["TauntInChat"], destName))
end
elseif sourceGUID == UnitGUID("pet") and E.db.WindTools["More Tools"]["Announce System"]["Taunt"]["IncludePet"] then
-- 宠物嘲讽
if E.db.WindTools["More Tools"]["Announce System"]["Taunt"]["PetSmart"] then
-- 宠物嘲讽智能喊话
SendChatMessage(format(ASL["PetTaunt"], destName), CheckChatTaunt())
else
-- 宠物嘲讽信息显示于综合
ChatFrame1:AddMessage(format(ASL["PetTauntInChat"], destName))
end
elseif E.db.WindTools["More Tools"]["Announce System"]["Taunt"]["IncludeOtherTank"] and UnitGroupRolesAssigned(sourceName) == "TANK" then
-- 他人嘲讽
-- 去除服务器信息
local oriSourceName = sourceName
sourceName = sourceName:gsub("%-[^|]+", "")
if E.db.WindTools["More Tools"]["Announce System"]["Taunt"]["OtherTankSmart"] then
-- 他人嘲讽智能喊话
SendChatMessage(format(ASL["OtherTankTaunt"], sourceName, destName), CheckChatTaunt())
else
-- 他人嘲讽信息显示于聊天框架
ChatFrame1:AddMessage(format(ASL["OtherTankTauntInChat"], AddClassColor(sourceGUID), destName))
end
end
end
if not E.db.WindTools["More Tools"]["Announce System"]["Taunt"]["missenabled"] then return end
if event == "SPELL_MISSED" and TauntSpells[spellID] then
-- 如果施放嘲讽技能失败
if sourceGUID == UnitGUID("player") then
-- 玩家嘲讽
if E.db.WindTools["More Tools"]["Announce System"]["Taunt"]["PlayerSmart"] then
-- 玩家嘲讽智能喊话
SendChatMessage(format(ASL["TauntMiss"], destName), CheckChatTaunt())
else
-- 玩家嘲讽信息显示于综合
ChatFrame1:AddMessage(format(ASL["TauntMissInChat"], destName))
end
elseif sourceGUID == UnitGUID("pet") and E.db.WindTools["More Tools"]["Announce System"]["Taunt"]["IncludePet"] then
-- 宠物嘲讽
if E.db.WindTools["More Tools"]["Announce System"]["Taunt"]["PetSmart"] then
-- 宠物嘲讽智能喊话
SendChatMessage(format(ASL["PetTauntMiss"], destName), CheckChatTaunt())
else
-- 宠物嘲讽信息显示于综合
ChatFrame1:AddMessage(format(ASL["PetTauntMissInChat"], destName))
end
elseif E.db.WindTools["More Tools"]["Announce System"]["Taunt"]["IncludeOtherTank"] and UnitGroupRolesAssigned(sourceName) == "TANK" then
-- 他坦嘲讽
-- 去除服务器信息
local oriSourceName = sourceName
sourceName = sourceName:gsub("%-[^|]+", "")
if E.db.WindTools["More Tools"]["Announce System"]["Taunt"]["OtherTankSmart"] then
-- 他人嘲讽智能喊话
SendChatMessage(format(ASL["OtherTankTauntMiss"], sourceName, destName), CheckChatTaunt())
else
-- 他人嘲讽信息显示于综合
ChatFrame1:AddMessage(format(ASL["OtherTankTauntMissInChat"], AddClassColor(sourceGUID), destName))
end
end
end
end)
end
function AnnounceSystem:Initialize()
--if not (GetLocale() == "zhCN" or GetLocale() == "zhTW") then return end
if not E.db.WindTools["More Tools"]["Announce System"]["enabled"] then return end
if E.db.WindTools["More Tools"]["Announce System"]["Interrupt"]["enabled"] then
AnnounceSystem:Interrupt()
end
if E.db.WindTools["More Tools"]["Announce System"]["Taunt"]["enabled"] then
AnnounceSystem:Taunt()
end
if E.db.WindTools["More Tools"]["Announce System"]["ResAndThreat"]["enabled"] then
AnnounceSystem:ResAndThreat()
end
if E.db.WindTools["More Tools"]["Announce System"]["ResThanks"]["enabled"] then
AnnounceSystem:ResThanks()
end
if E.db.WindTools["More Tools"]["Announce System"]["RaidUsefulSpells"]["enabled"] then
AnnounceSystem:RaidUsefulSpells()
end
end
local function InitializeCallback()
AnnounceSystem:Initialize()
end
E:RegisterModule(AnnounceSystem:GetName(), InitializeCallback)
|
local SceneTemplate = {}
-- this kills performance, but is good for lining things up
local RELOAD = true
-- called when this loads
function SceneTemplate:load()
end
-- called when some othe rscene is chosen
function SceneTemplate:unload()
end
-- called to update logic
function SceneTemplate:update(dt, totaltime)
end
if RELOAD then
local lurker = require("lib.lurker")
lurker.preswap = function(f)
set_current_scene(scene_name)
end
function SceneTemplate:update()
lurker.update()
end
end
-- called when a button is pressed
function SceneTemplate:pressed(button)
end
-- called when a button is released
function SceneTemplate:released(button)
end
-- callled in main draw loop
function SceneTemplate:draw()
love.graphics.setColor(1, 1, 1, 1)
love.graphics.setBackgroundColor( 0.1, 0.1, 0.1, 1 )
end
return SceneTemplate
|
local float = class()
function float:new(e, body, float_acceleration)
self.body = body
self.e = e
self.in_water = nil
self.old_acc = self.body.acc:copy()
self.float_acceleration = float_acceleration
self.splash_limit = timer(0.1)
end
function float:update(dt)
self.splash_limit:update(dt)
if self.in_water ~= self.body.zones.water then
self.in_water = self.body.zones.water
if self.in_water then
self.old_acc:vector_set(self.body.acc)
self.body.acc:vector_set(self.float_acceleration)
--lose velocity when entering water
self.body.vel:scalar_mul_inplace(0.2)
else
self.body.acc:vector_set(self.old_acc)
end
if self.splash_limit:expired() then
--spawn some splash particles based on entry/exit vel
local particles_amount = math.floor(math.lerp(-1, 10, math.clamp01(self.body.vel:length() / 50)))
for i = 1, particles_amount do
require("src.shared_entities.particle")(self.e.systems, {
frame = love.math.random(2, 3),
pos = self.body.pos:add(
vec2(0, self.body.radius)
:scalar_mul_inplace(love.math.random())
:rotate_inplace(math.tau * love.math.random())
),
vel = self.body.vel:copy()
:scalar_mul_inplace(-0.2) --against the splash
:vector_add_inplace(
vec2(0, 10)
:scalar_mul_inplace(love.math.random())
:rotate_inplace(math.tau * love.math.random())
),
gravity = 10,
friction = 2,
z = 10,
})
end
self.splash_limit:reset()
end
end
end
return float
|
--[[
Copyright (C) 2014 HarpyWar ([email protected])
This file is a part of the PvPGN Project http://pvpgn.pro
Licensed under the same terms as Lua itself.
]]--
-- Config table can be extended here with your own variables
-- values are preloaded from bnetd.conf
config = {
-- Path to "var" directory (with slash at the end)
-- Usage: config.vardir()
vardir = function()
return string.replace(config.statusdir, "status", "")
end,
flood_immunity_users = { "admin", "" }, -- ignore flood protection for these users
-- Quiz settings
quiz = true,
quiz_filelist = "misc, dota, warcraft", -- display available files in "/quiz start"
quiz_competitive_mode = true, -- top players loses half of points which last player received; at the end top of records loses half of points which players received in current game
quiz_max_questions = 100, -- from start to end
quiz_question_delay = 5, -- delay before send next question
quiz_hint_delay = 20, -- delay between prompts
quiz_users_in_top = 15, -- how many users display in TOP list
quiz_channel = nil, -- (do not modify!) channel when quiz has started (it assigned with start)
-- AntiHack (Starcraft)
ah = true,
ah_interval = 60, -- interval for send memory request to all players in games
-- GHost++ (https://github.com/OHSystem/ohsystem)
ghost = false, -- enable GHost commands
ghost_bots = { "hostbot1", "hostbot2" }, -- list of authorized bots
ghost_dota_server = true, -- replace normal Warcraft 3 stats with DotA
ghost_ping_expire = 90, -- interval when outdated botpings should be removed (bot ping updates for each user when he join a game hosted by ghost); game list shows to user depending on the best ping to host bot
}
|
--[[
@author Sebastian "CrosRoad95" Jura <[email protected]>
@copyright 2011-2021 Sebastian Jura <[email protected]>
@license MIT
]]--
addEventHandler("onMarkerHit", resourceRoot, function(el,md)
if getElementType(el)~="player" or not md then return end
if getElementInterior(el)~=getElementInterior(source) then return end
local tpto=getElementData(source,"tpto")
if not tpto then return end
setElementPosition(el, tpto[1], tpto[2],tpto[3])
setElementInterior(el, 0)
setElementDimension(el, 0)
if tpto[4] then
setPedRotation(el, tpto[4])
end
end)
|
local gui = require("__flib__.gui")
local table = require("__flib__.table")
local constants = require("constants")
local formatter = require("scripts.formatter")
local recipe_book = require("scripts.recipe-book")
local shared = require("scripts.shared")
local util = require("scripts.util")
local components = {
list_box = require("scripts.gui.info.list-box"),
table = require("scripts.gui.info.table")
}
local function tool_button(sprite, tooltip, ref, action, style_mods)
return {
type = "sprite-button",
style = "tool_button",
style_mods = style_mods,
sprite = sprite,
tooltip = tooltip,
mouse_button_filter = {"left"},
ref = ref,
actions = {
on_click = action
}
}
end
local root = {}
function root.build(player, player_table, context, sticky)
local id = player_table.guis.info._next_id
player_table.guis.info._next_id = id + 1
local root_elem
if sticky then
root_elem = player_table.guis.search.refs.window
else
root_elem = player.gui.screen
end
local refs = gui.build(root_elem, {
{
type = "frame",
style_mods = {width = 430},
direction = "vertical",
ref = {"window"},
actions = {
on_click = {gui = "info", id = id, action = "set_as_active"},
on_closed = {gui = "info", id = id, action = "close"}
},
{
type = "flow",
style = "flib_titlebar_flow",
ref = {"titlebar", "flow"},
actions = {
on_click = {gui = sticky and "search" or "info", id = id, action = "reset_location"},
},
util.frame_action_button(
"rb_nav_backward",
nil,
{"titlebar", "nav_backward_button"},
{gui = "info", id = id, action = "navigate", delta = -1}
),
util.frame_action_button(
"rb_nav_forward",
nil,
{"titlebar", "nav_forward_button"},
{gui = "info", id = id, action = "navigate", delta = 1}
),
{
type = "label",
style = "frame_title",
style_mods = {left_margin = 4},
ignored_by_interaction = true,
ref = {"titlebar", "label"}
},
{
type = "empty-widget",
style = "flib_titlebar_drag_handle",
ignored_by_interaction = true,
ref = {"titlebar", "drag_handle"}
},
{
type = "textfield",
style_mods = {
top_margin = -3,
right_padding = 3,
width = 120
},
clear_and_focus_on_right_click = true,
visible = false,
ref = {"titlebar", "search_textfield"},
actions = {
on_text_changed = {gui = "info", id = id, action = "update_search_query"}
}
},
util.frame_action_button(
"utility/search",
{"gui.rb-search-instruction"},
{"titlebar", "search_button"},
{gui = "info", id = id, action = "toggle_search"}
),
sticky and util.frame_action_button(
"rb_detach",
{"gui.rb-detach-instruction"},
nil,
{gui = "info", id = id, action = "detach_window"}
) or {},
util.frame_action_button(
"utility/close",
{"gui.close"},
{"titlebar", "close_button"},
{gui = "info", id = id, action = "close"}
)
},
{
type = "frame",
style = "inside_shallow_frame",
style_mods = {vertically_stretchable = sticky},
direction = "vertical",
ref = {"page_frame"},
action = {
on_click = {gui = "info", id = id, action = "set_as_active"},
},
{type = "frame", style = "rb_subheader_frame", direction = "vertical",
{
type = "flow",
style_mods = {vertical_align = "center"},
visible = false,
ref = {"header", "list_nav", "flow"},
action = {
on_click = {gui = "info", id = id, action = "set_as_active"},
},
tool_button(
"rb_list_nav_backward_black",
{"gui.rb-go-backward"},
{"header", "list_nav", "back_button"},
nil,
{padding = 3}
),
{type = "empty-widget", style = "flib_horizontal_pusher"},
{
type = "label",
style = "bold_label",
style_mods = {horizontally_squashable = true},
ref = {"header", "list_nav", "source_label"}
},
{
type = "label",
style = "bold_label",
style_mods = {font_color = constants.colors.info.tbl},
ref = {"header", "list_nav", "position_label"}
},
{type = "empty-widget", style = "flib_horizontal_pusher"},
tool_button(
"rb_list_nav_forward_black",
{"gui.rb-go-forward"},
{"header", "list_nav", "forward_button"},
nil,
{padding = 3}
),
},
{type = "line", style = "rb_dark_line", direction = "horizontal", visible = false, ref = {"header", "line"}},
{type = "flow", style_mods = {vertical_align = "center"},
{type = "label", style = "rb_toolbar_label", ref = {"header", "label"}},
{type = "empty-widget", style = "flib_horizontal_pusher"},
tool_button(
"rb_technology_gui_black",
{"gui.rb-open-in-technology-window"},
{"header", "open_in_tech_window_button"},
{gui = "info", id = id, action = "open_in_tech_window"}
),
tool_button(
"rb_fluid_black",
{"gui.rb-view-base-fluid"},
{"header", "go_to_base_fluid_button"},
{gui = "info", id = id, action = "go_to_base_fluid"}
),
tool_button(
"rb_clipboard_black",
{"gui.rb-toggle-quick-ref-window"},
{"header", "quick_ref_button"},
{gui = "info", id = id, action = "toggle_quick_ref"}
),
tool_button(
"rb_favorite_black",
{"gui.rb-add-to-favorites"},
{"header", "favorite_button"},
{gui = "info", id = id, action = "toggle_favorite"}
)
}
},
{
type = "scroll-pane",
style = "rb_page_scroll_pane",
style_mods = {maximal_height = 900},
ref = {"page_scroll_pane"},
action = {
on_click = {gui = "info", id = id, action = "set_as_active"},
},
},
{type = "flow", style = "rb_warning_flow", direction = "vertical", visible = false, ref = {"warning_flow"},
{type = "label", style = "bold_label", caption = {"gui.rb-no-content-warning"}, ref = {"warning_text"}}
}
}
}
})
if sticky then
refs.titlebar.flow.drag_target = root_elem
refs.root = root_elem
else
refs.titlebar.flow.drag_target = refs.window
refs.window.force_auto_center()
end
refs.page_components = {}
player_table.guis.info[id] = {
refs = refs,
state = {
components = {},
history = {_index = 0},
id = id,
search_opened = false,
search_query = "",
selected_tech_level = 0,
sticky = sticky,
warning_shown = false
}
}
player_table.guis.info._active_id = id
if sticky then
player_table.guis.info._sticky_id = id
end
root.update_contents(player, player_table, id, {new_context = context})
end
function root.destroy(player_table, id)
local gui_data = player_table.guis.info[id]
if gui_data then
gui_data.refs.window.destroy()
player_table.guis.info[id] = nil
if gui_data.state.sticky then
player_table.guis.info._sticky_id = nil
end
end
end
function root.destroy_all(player_table)
for id in pairs(player_table.guis.info) do
if not constants.ignored_info_ids[id] then
root.destroy(player_table, id)
end
end
end
function root.find_open_context(player_table, context)
local open = {}
for id, gui_data in pairs(player_table.guis.info) do
if not constants.ignored_info_ids[id] then
local state = gui_data.state
if not state.sticky then
local opened_context = state.history[state.history._index]
if opened_context and opened_context.class == context.class and opened_context.name == context.name then
open[#open + 1] = id
end
end
end
end
return open
end
function root.update_contents(player, player_table, id, options)
options = options or {}
local new_context = options.new_context
local refresh = options.refresh
local gui_data = player_table.guis.info[id]
local state = gui_data.state
local refs = gui_data.refs
-- HISTORY
-- Add new history if needed
local history = state.history
if new_context then
-- Remove all entries after this
for i = history._index + 1, #history do
history[i] = nil
end
-- Insert new entry
local new_index = #history + 1
history[new_index] = new_context
history._index = new_index
-- Limit the length
local max_size = constants.session_history_size
if new_index > max_size then
history._index = max_size
for _ = max_size + 1, new_index do
table.remove(history, 1)
end
end
end
local context = new_context or history[history._index]
if not refresh then
shared.update_global_history(player, player_table, context)
end
-- COMMON DATA
local obj_data = recipe_book[context.class][context.name]
local player_data = formatter.build_player_data(player, player_table)
local gui_translations = player_data.translations.gui
-- TECH LEVEL
if not refresh and obj_data.research_unit_count_formula then
state.selected_tech_level = player_data.force.technologies[context.name].level
end
-- TITLEBAR
-- Nav buttons
-- Generate tooltips
local history_index = history._index
local history_len = #history
local entries = {}
for i, history_context in ipairs(history) do
local obj_data = recipe_book[history_context.class][history_context.name]
local info = formatter(obj_data, player_data, {always_show = true, label_only = true})
local caption = info.caption
if not info.researched then
caption = formatter.rich_text("color", "unresearched", caption)
end
entries[history_len - (i - 1)] = formatter.rich_text(
"font",
"default-semibold",
formatter.rich_text("color", history_index == i and "green" or "invisible", ">")
).." "..caption
end
local entries = table.concat(entries, "\n")
local base_tooltip = formatter.rich_text(
"font",
"default-bold",
formatter.rich_text("color", "heading", gui_translations.session_history)
).."\n"..entries
-- Apply button properties
local nav_backward_button = refs.titlebar.nav_backward_button
if history._index == 1 then
nav_backward_button.enabled = false
nav_backward_button.sprite = "rb_nav_backward_disabled"
else
nav_backward_button.enabled = true
nav_backward_button.sprite = "rb_nav_backward_white"
end
nav_backward_button.tooltip = base_tooltip
..formatter.control(gui_translations.click, gui_translations.go_backward)
..formatter.control(gui_translations.shift_click, gui_translations.go_to_the_back)
local nav_forward_button = refs.titlebar.nav_forward_button
if history._index == #history then
nav_forward_button.enabled = false
nav_forward_button.sprite = "rb_nav_forward_disabled"
else
nav_forward_button.enabled = true
nav_forward_button.sprite = "rb_nav_forward_white"
end
nav_forward_button.tooltip = base_tooltip
..formatter.control(gui_translations.click, gui_translations.go_forward)
..formatter.control(gui_translations.shift_click, gui_translations.go_to_the_front)
-- Label
local label = refs.titlebar.label
label.caption = gui_translations[context.class]
-- Reset search when moving pages
if not options.refresh and state.search_opened then
state.search_opened = false
local search_button = refs.titlebar.search_button
local search_textfield = refs.titlebar.search_textfield
search_button.sprite = "utility/search_white"
search_button.style = "frame_action_button"
search_textfield.visible = false
if state.search_query ~= "" then
-- Reset query
search_textfield.text = ""
state.search_query = ""
end
end
-- HEADER
-- List navigation
-- List nav is kind of weird because it doesn't respect your settings, but making it respect the settings would be
-- too much work
local list_context = context.list
if list_context then
local source = list_context.context
local source_data = recipe_book[source.class][source.name]
local list = source_data[list_context.source]
local list_len = #list
local index = list_context.index
local list_refs = refs.header.list_nav
list_refs.flow.visible = true
-- Labels
local source_info = formatter(source_data, player_data, {always_show = true})
local source_label = list_refs.source_label
source_label.caption = formatter.rich_text("color", "heading", source_info.caption)
.." - "
..gui_translations[list_context.source]
local position_label = list_refs.position_label
position_label.caption = " ("..index.." / "..list_len..")"
-- Buttons
for delta, button in pairs{[-1] = list_refs.back_button, [1] = list_refs.forward_button} do
local new_index = index + delta
if new_index < 1 then
new_index = list_len
elseif new_index > list_len then
new_index = 1
end
local ident = list[new_index]
gui.set_action(button, "on_click", {
gui = "info",
id = id,
action = "navigate_to_plain",
context = {
class = ident.class,
name = ident.name,
list = {
context = source,
index = new_index,
source = list_context.source
}
}
})
end
refs.header.line.visible = true
else
refs.header.list_nav.flow.visible = false
refs.header.line.visible = false
end
-- Label
local title_info = formatter(obj_data, player_data, {always_show = true, is_label = true})
local label = refs.header.label
label.caption = title_info.caption
label.tooltip = title_info.tooltip
label.style = title_info.researched and "rb_toolbar_label" or "rb_unresearched_toolbar_label"
-- Buttons
if context.class == "technology" then
refs.header.open_in_tech_window_button.visible = true
else
refs.header.open_in_tech_window_button.visible = false
end
if context.class == "fluid" and obj_data.temperature_ident then
local base_fluid_button = refs.header.go_to_base_fluid_button
base_fluid_button.visible = true
gui.set_action(base_fluid_button, "on_click", {
gui = "info",
id = id,
action = "navigate_to_plain",
context = obj_data.base_fluid
})
else
refs.header.go_to_base_fluid_button.visible = false
end
if context.class == "recipe" then
local button = refs.header.quick_ref_button
button.visible = true
local is_selected = player_table.guis.quick_ref[context.name]
button.style = is_selected and "flib_selected_tool_button" or "tool_button"
button.tooltip = {"gui.rb-"..(is_selected and "close" or "open").."-quick-ref-window"}
else
refs.header.quick_ref_button.visible = false
end
local favorite_button = refs.header.favorite_button
if player_table.favorites[context.class.."."..context.name] then
favorite_button.style = "flib_selected_tool_button"
favorite_button.tooltip = {"gui.rb-remove-from-favorites"}
else
favorite_button.style = "tool_button"
favorite_button.tooltip = {"gui.rb-add-to-favorites"}
end
-- PAGE
local pane = refs.page_scroll_pane
local page_refs = refs.page_components
local page_settings = player_table.settings.pages[context.class]
local i = 0
local visible = false
local component_variables = {
context = context,
gui_id = id,
search_query = state.search_query,
selected_tech_level = state.selected_tech_level
}
-- Add or update relevant components
for _, component_ident in pairs(constants.pages[context.class]) do
i = i + 1
local component = components[component_ident.type]
local component_refs = page_refs[i]
if not component_refs or component_refs.type ~= component_ident.type then
-- Destroy old elements
if component_refs then
component_refs.root.destroy()
end
-- Create new elements
component_refs = component.build(pane, i, component_ident, component_variables)
component_refs.type = component_ident.type
page_refs[i] = component_refs
end
local component_settings = page_settings[component_ident.label or component_ident.source]
if not refresh then
state.components[i] = component.default_state(component_settings)
end
component_variables.component_index = i
component_variables.component_state = state.components[i]
local comp_visible = component.update(
component_ident,
component_refs,
obj_data,
player_data,
component_settings,
component_variables
)
visible = visible or comp_visible
end
-- Destroy extraneous components
for j = i + 1, #page_refs do
page_refs[j].root.destroy()
page_refs[j] = nil
end
-- Show error frame if nothing is visible
if not visible and not state.warning_shown then
state.warning_shown = true
pane.visible = false
refs.page_frame.style = "rb_inside_warning_frame"
refs.page_frame.style.vertically_stretchable = state.sticky
refs.warning_flow.visible = true
if state.search_query == "" then
refs.warning_text.caption = {"gui.rb-no-content-warning"}
else
refs.warning_text.caption = {"gui.rb-no-results"}
end
elseif visible and state.warning_shown then
state.warning_shown = false
pane.visible = true
refs.page_frame.style = "inside_shallow_frame"
refs.page_frame.style.vertically_stretchable = state.sticky
refs.warning_flow.visible = false
end
end
function root.update_all(player, player_table)
for id in pairs(player_table.guis.info) do
if not constants.ignored_info_ids[id] then
root.update_contents(player, player_table, id, {refresh = true})
end
end
end
function root.bring_all_to_front(player_table)
for id, gui_data in pairs(player_table.guis.info) do
if not constants.ignored_info_ids[id] then
if gui_data.state.sticky then
gui_data.refs.root.bring_to_front()
else
gui_data.refs.window.bring_to_front()
end
end
end
end
return root
|
---------------------------------------------
-- Regeneration
--
-- Description: Adds a Regen tpz.effect.
-- Type: Enhancing
-- Utsusemi/Blink absorb: N/A
-- Range: Self
---------------------------------------------
require("scripts/globals/monstertpmoves")
require("scripts/globals/settings")
require("scripts/globals/status")
---------------------------------------------
function onMobSkillCheck(target, mob, skill)
return 0
end
function onMobWeaponSkill(target, mob, skill)
local power = mob:getMainLvl()/10 * 4 + 5
local duration = 60
local typeEffect = tpz.effect.REGEN
skill:setMsg(MobBuffMove(mob, typeEffect, power, 3, duration))
return typeEffect
end
|
object_mobile_dressed_myyydril_treesh = object_mobile_shared_dressed_myyydril_treesh:new {
}
ObjectTemplates:addTemplate(object_mobile_dressed_myyydril_treesh, "object/mobile/dressed_myyydril_treesh.iff")
|
slot0 = class("PlayerResChangeCommand", pm.SimpleCommand)
slot0.execute = function (slot0, slot1)
slot3 = slot1:getBody().oldPlayer
slot4 = slot1.getBody().newPlayer
slot5 = false
for slot10 = #pg.player_resource.all, 11, -1 do
if slot3:getResource(slot11) ~= slot4:getResource(slot6[slot10]) then
slot5 = true
break
end
end
if slot5 then
slot0:UpdateActivies(slot3, slot4)
end
end
slot0.UpdateActivies = function (slot0, slot1, slot2)
slot0.activityProxy = slot0.activityProxy or getProxy(ActivityProxy)
slot3 = {}
for slot7, slot8 in ipairs(slot0.activityProxy:getActivitiesByType(ActivityConst.ACTIVITY_TYPE_PT_RANK)) do
slot3[slot9] = slot3[slot8:getConfig("config_id")] or slot2:getResource(slot9) - slot1:getResource(slot9)
slot0.UpdateActivity(slot8, slot3[slot9])
end
for slot7, slot8 in ipairs(slot0.activityProxy:getActivitiesByType(ActivityConst.ACTIVITY_TYPE_BOSS_RANK)) do
slot3[slot9] = slot3[slot8:getConfig("config_id")] or slot2:getResource(slot9) - slot1:getResource(slot9)
slot0.UpdateActivity(slot8, slot3[slot9])
end
for slot7, slot8 in ipairs(slot0.activityProxy:getActivitiesByType(ActivityConst.ACTIVITY_TYPE_PT_ACCUM)) do
slot10 = nil
slot3[slot9] = slot3[slot8:getDataConfig("pt")] or slot2:getResource(slot9) - slot1:getResource(slot9)
slot0.UpdateActivity(slot8, slot3[slot9])
end
for slot7, slot8 in ipairs(slot0.activityProxy:getActivitiesByType(ActivityConst.ACTIVITY_TYPE_RETURN_AWARD)) do
slot3[slot10] = slot3[pg.activity_template_headhunting[slot8.id].pt] or slot2:getResource(slot10) - slot1:getResource(slot10)
slot0.UpdateActivity(slot8, slot3[slot10])
end
for slot7, slot8 in ipairs(slot0.activityProxy:getActivitiesByType(ActivityConst.ACTIVITY_TYPE_PIZZA_PT)) do
slot3[slot9] = slot3[slot8:getDataConfig("pt")] or slot2:getResource(slot9) - slot1:getResource(slot9)
slot0.UpdateActivity(slot8, slot3[slot9])
end
for slot7, slot8 in ipairs(slot0.activityProxy:getActivitiesByType(ActivityConst.ACTIVITY_TYPE_PT_BUFF)) do
slot3[slot9] = slot3[slot8:getDataConfig("pt")] or slot2:getResource(slot9) - slot1:getResource(slot9)
slot0.UpdateActivity(slot8, slot3[slot9])
end
end
slot0.UpdateActivity = function (slot0, slot1)
slot2 = getProxy(ActivityProxy)
if slot0:getConfig("type") == ActivityConst.ACTIVITY_TYPE_PT_RANK then
if not slot0:isEnd() and slot1 > 0 then
slot0.data1 = slot0.data1 + slot1
slot2:updateActivity(slot0)
end
elseif slot3 == ActivityConst.ACTIVITY_TYPE_BOSS_RANK then
if slot1 ~= 0 then
slot0.data1 = slot0.data1 + slot1
slot2:updateActivity(slot0)
end
elseif slot3 == ActivityConst.ACTIVITY_TYPE_PT_ACCUM then
slot1 = (slot0:getDataConfig("type") ~= 1 or math.max(slot1, 0)) and (slot0:getDataConfig("type") ~= 2 or math.min(slot1, 0)) and 0
if not slot0:isEnd() and slot1 ~= 0 then
slot0.data1 = slot0.data1 + math.abs(slot1)
slot2:updateActivity(slot0)
end
elseif slot3 == ActivityConst.ACTIVITY_TYPE_RETURN_AWARD then
slot4 = pg.activity_template_headhunting[slot0.id]
if slot1 ~= 0 then
slot0.data3 = slot0.data3 + slot1
slot2:updateActivity(slot0)
end
elseif slot3 == ActivityConst.ACTIVITY_TYPE_PIZZA_PT then
slot4 = slot0:getDataConfig("pt")
slot1 = (slot0:getDataConfig("type") ~= 1 or math.max(slot1, 0)) and (slot0:getDataConfig("type") ~= 2 or math.min(slot1, 0)) and 0
if not slot0:isEnd() and slot1 ~= 0 then
slot0.data1 = slot0.data1 + math.abs(slot1)
slot2:updateActivity(slot0)
end
elseif slot3 == ActivityConst.ACTIVITY_TYPE_PT_BUFF and slot0:getDataConfig("pt") > 0 then
slot1 = (slot0:getDataConfig("type") ~= 1 or math.max(slot1, 0)) and (slot0:getDataConfig("type") ~= 2 or math.min(slot1, 0)) and 0
if not slot0:isEnd() and slot1 > 0 then
slot0.data1 = slot0.data1 + math.abs(slot1)
slot2:updateActivity(slot0)
end
end
end
return slot0
|
local class = require('middleclass')
local Controller = require('mvc.Controller')
local HasSignals = require('HasSignals')
local ApplyController = class("ApplyController", Controller):include(HasSignals)
local tools = require('app.helpers.tools')
function ApplyController:initialize(desk)
Controller.initialize(self)
HasSignals.initialize(self)
self.desk = desk
end
function ApplyController:viewDidLoad()
self.view:layout(self.desk)
local app = require("app.App"):instance()
self.listener = {
self.view:on('apply', function(type)
self:apply(type)
end),
self.desk:on('overgame', function(msg)
self:fresh()
end),
self.desk:on('overgameResult', function(type)
self:fresh()
end),
}
self:fresh()
end
function ApplyController:apply(type)
local answer = 2
if type == 'agree' then
answer = 1
end
self.desk:answer(answer)
end
function ApplyController:fresh()
local overSuggest, overTickInfo = self.desk:getDismissInfo()
if (not overSuggest) and (not overTickInfo) then return end
-- 解散失败
local result = overSuggest.result
for uid, status in pairs(result) do
if status ~= 0 and status ~= 1 then
local info = self.desk:getPlayerInfo(uid)
if info then
local nickname = info.player:getNickname()
tools.showRemind('玩家 '.. nickname .. ' 拒绝了解散申请, 游戏继续.')
end
self:clickBack()
return
end
end
self.view:loadData(overSuggest, overTickInfo)
end
function ApplyController:clickBack()
self.emitter:emit('back')
end
function ApplyController:finalize()-- luacheck: ignore
for i = 1, #self.listener do
self.listener[i]:dispose()
end
end
return ApplyController
|
--[=[
@class RxLinkUtility
]=]
local Brio = require(script.Parent.Brio)
local Janitor = require(script.Parent.Parent.Parent.Parent.Janitor)
local Observable = require(script.Parent.Observable)
local Rx = require(script.Parent.Rx)
local RxBrioUtility = require(script.Parent.RxBrioUtility)
local RxInstanceUtility = require(script.Parent.RxInstanceUtility)
local RxLinkUtility = {}
-- Emits valid links in format Brio.new(link, linkValue)
function RxLinkUtility.ObserveValidLinksBrio(LinkName, Parent)
assert(type(LinkName) == "string", "linkName should be 'string'")
assert(typeof(Parent) == "Instance", "parent should be 'Instance'")
return RxInstanceUtility.ObserveChildrenBrio(Parent):Pipe({
Rx.FlatMap(function(MapBrio)
local Object = MapBrio:GetValue()
if not Object:IsA("ObjectValue") then
return Rx.EMPTY
end
return RxBrioUtility.CompleteOnDeath(MapBrio, RxLinkUtility.ObserveValidityBrio(LinkName, Object))
end);
})
end
-- Fires off everytime the link is reconfigured into a valid link
-- Fires with link, linkValue
function RxLinkUtility.ObserveValidityBrio(LinkName: string, Link: ObjectValue)
assert(typeof(Link) == "Instance" and Link:IsA("ObjectValue"), "Bad link")
assert(type(LinkName) == "string", "Bad linkName")
return Observable.new(function(Subscription)
local ObserveJanitor = Janitor.new()
local function UpdateValidity()
if not (Link.Name == LinkName and Link.Value) then
return ObserveJanitor:Remove("LastValid")
end
Subscription:Fire(ObserveJanitor:Add(Brio.new(Link, Link.Value), "Destroy", "LastValid"))
end
ObserveJanitor:Add(Link:GetPropertyChangedSignal("Value"):Connect(UpdateValidity), "Disconnect")
ObserveJanitor:Add(Link:GetPropertyChangedSignal("Name"):Connect(UpdateValidity), "Disconnect")
UpdateValidity()
return ObserveJanitor
end)
end
table.freeze(RxLinkUtility)
return RxLinkUtility
|
local function dual_delayer_get_input_rules(node)
local rules = {{x=1, y=0, z=0}}
for _ = 0, node.param2 do
rules = mesecon.rotate_rules_left(rules)
end
return rules
end
local function dual_delayer_get_output_rules(node)
local rules = {{x=0, y=0, z=1}, {x=0, y=0, z=-1}}
for _ = 0, node.param2 do
rules = mesecon.rotate_rules_left(rules)
end
return rules
end
local dual_delayer_activate = function(pos, node)
mesecon.receptor_on(pos, {dual_delayer_get_output_rules(node)[1]}) -- Turn on the port 1
minetest.swap_node(pos, {name = "moremesecons_dual_delayer:dual_delayer_10", param2 = node.param2})
minetest.after(0.4, function()
mesecon.receptor_on(pos, {dual_delayer_get_output_rules(node)[2]}) -- Turn on the port 2
minetest.swap_node(pos, {name = "moremesecons_dual_delayer:dual_delayer_11", param2 = node.param2})
end)
end
local dual_delayer_deactivate = function(pos, node, link)
mesecon.receptor_off(pos, {dual_delayer_get_output_rules(node)[2]}) -- Turn off the port 2
minetest.swap_node(pos, {name = "moremesecons_dual_delayer:dual_delayer_10", param2 = node.param2})
minetest.after(0.4, function()
mesecon.receptor_off(pos, {dual_delayer_get_output_rules(node)[1]}) -- Turn off the port 1
minetest.swap_node(pos, {name = "moremesecons_dual_delayer:dual_delayer_00", param2 = node.param2})
end)
end
for n,i in pairs({{0,0},{1,0},{1,1}}) do
local i1,i2 = unpack(i)
local groups = {dig_immediate = 2}
if n ~= 1 then
groups.not_in_creative_inventory = 1
end
local top_texture = "^moremesecons_dual_delayer_overlay.png^[makealpha:255,126,126"
if i1 == i2 then
if i1 == 0 then
top_texture = "mesecons_wire_off.png"..top_texture
else
top_texture = "mesecons_wire_on.png"..top_texture
end
else
local pre = "mesecons_wire_off.png^[lowpart:50:mesecons_wire_on.png^[transformR"
if i1 == 0 then
pre = pre.. 90
else
pre = pre.. 270
end
top_texture = pre..top_texture
end
local use_texture_alpha
if minetest.features.use_texture_alpha_string_modes then
use_texture_alpha = "opaque"
end
minetest.register_node("moremesecons_dual_delayer:dual_delayer_"..i1 ..i2, {
description = "Dual Delayer",
drop = "moremesecons_dual_delayer:dual_delayer_00",
inventory_image = top_texture,
wield_image = top_texture,
paramtype = "light",
paramtype2 = "facedir",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {{-6/16, -8/16, -8/16, 6/16, -7/16, 1/16 },
{-8/16, -8/16, 1/16, -6/16, -7/16, -1/16},
{8/16, -8/16, -1/16, 6/16, -7/16, 1/16}}
},
groups = groups,
tiles = {top_texture, "moremesecons_dual_delayer_bottom.png", "moremesecons_dual_delayer_side_left.png", "moremesecons_dual_delayer_side_right.png", "moremesecons_dual_delayer_ends.png", "moremesecons_dual_delayer_ends.png"},
use_texture_alpha = use_texture_alpha,
mesecons = {
receptor = {
state = mesecon.state.off,
rules = dual_delayer_get_output_rules
},
effector = {
rules = dual_delayer_get_input_rules,
action_on = dual_delayer_activate,
action_off = dual_delayer_deactivate
}
}
})
end
minetest.register_craft({
type = "shapeless",
output = "moremesecons_dual_delayer:dual_delayer_00 2",
recipe = {"mesecons_delayer:delayer_off_1", "mesecons_delayer:delayer_off_1"}
})
|
---------------------------
-- Default awesome theme --
---------------------------
theme = {}
theme.font = "Droid Serif 11"
theme.bg_normal = "#222222"
theme.bg_focus = "#535d6c"
theme.bg_urgent = "#ff0000"
theme.bg_minimize = "#444444"
theme.fg_normal = "#aaaaaa"
theme.fg_focus = "#ffffff"
theme.fg_urgent = "#ffffff"
theme.fg_minimize = "#ffffff"
theme.border_width = "1"
theme.border_normal = "#000000"
theme.border_focus = "#535d6c"
theme.border_marked = "#91231c"
-- There are another variables sets
-- overriding the default one when
-- defined, the sets are:
-- [taglist|tasklist]_[bg|fg]_[focus|urgent]
-- titlebar_[bg|fg]_[normal|focus]
-- Example:
--taglist_bg_focus = #ff0000
-- Display the taglist squares
theme.taglist_squares_sel = "/usr/share/awesome/themes/default/taglist/squarefw.png"
theme.taglist_squares_unsel = "/usr/share/awesome/themes/default/taglist/squarew.png"
theme.tasklist_floating_icon = "/usr/share/awesome/themes/default/tasklist/floatingw.png"
-- Variables set for theming menu
-- menu_[bg|fg]_[normal|focus]
-- menu_[border_color|border_width]
theme.menu_submenu_icon = "/usr/share/awesome/themes/default/submenu.png"
theme.menu_height = "15"
theme.menu_width = "100"
-- You can add as many variables as
-- you wish and access them by using
-- beautiful.variable in your rc.lua
--bg_widget = #cc0000
-- Define the image to load
theme.titlebar_close_button_normal = "/usr/share/awesome/themes/default/titlebar/close_normal.png"
theme.titlebar_close_button_focus = "/usr/share/awesome/themes/default/titlebar/close_focus.png"
theme.titlebar_ontop_button_normal_inactive = "/usr/share/awesome/themes/default/titlebar/ontop_normal_inactive.png"
theme.titlebar_ontop_button_focus_inactive = "/usr/share/awesome/themes/default/titlebar/ontop_focus_inactive.png"
theme.titlebar_ontop_button_normal_active = "/usr/share/awesome/themes/default/titlebar/ontop_normal_active.png"
theme.titlebar_ontop_button_focus_active = "/usr/share/awesome/themes/default/titlebar/ontop_focus_active.png"
theme.titlebar_sticky_button_normal_inactive = "/usr/share/awesome/themes/default/titlebar/sticky_normal_inactive.png"
theme.titlebar_sticky_button_focus_inactive = "/usr/share/awesome/themes/default/titlebar/sticky_focus_inactive.png"
theme.titlebar_sticky_button_normal_active = "/usr/share/awesome/themes/default/titlebar/sticky_normal_active.png"
theme.titlebar_sticky_button_focus_active = "/usr/share/awesome/themes/default/titlebar/sticky_focus_active.png"
theme.titlebar_floating_button_normal_inactive = "/usr/share/awesome/themes/default/titlebar/floating_normal_inactive.png"
theme.titlebar_floating_button_focus_inactive = "/usr/share/awesome/themes/default/titlebar/floating_focus_inactive.png"
theme.titlebar_floating_button_normal_active = "/usr/share/awesome/themes/default/titlebar/floating_normal_active.png"
theme.titlebar_floating_button_focus_active = "/usr/share/awesome/themes/default/titlebar/floating_focus_active.png"
theme.titlebar_maximized_button_normal_inactive = "/usr/share/awesome/themes/default/titlebar/maximized_normal_inactive.png"
theme.titlebar_maximized_button_focus_inactive = "/usr/share/awesome/themes/default/titlebar/maximized_focus_inactive.png"
theme.titlebar_maximized_button_normal_active = "/usr/share/awesome/themes/default/titlebar/maximized_normal_active.png"
theme.titlebar_maximized_button_focus_active = "/usr/share/awesome/themes/default/titlebar/maximized_focus_active.png"
-- You can use your own command to set your wallpaper
-- theme.wallpaper_cmd = { "awsetbg /usr/share/awesome/themes/default/background.png" }
theme.wallpaper_cmd = { "awsetbg /home/zhou/leonidas-1-noon.jpg" }
-- You can use your own layout icons like this:
theme.layout_fairh = "/usr/share/awesome/themes/default/layouts/fairhw.png"
theme.layout_fairv = "/usr/share/awesome/themes/default/layouts/fairvw.png"
theme.layout_floating = "/usr/share/awesome/themes/default/layouts/floatingw.png"
theme.layout_magnifier = "/usr/share/awesome/themes/default/layouts/magnifierw.png"
theme.layout_max = "/usr/share/awesome/themes/default/layouts/maxw.png"
theme.layout_fullscreen = "/usr/share/awesome/themes/default/layouts/fullscreenw.png"
theme.layout_tilebottom = "/usr/share/awesome/themes/default/layouts/tilebottomw.png"
theme.layout_tileleft = "/usr/share/awesome/themes/default/layouts/tileleftw.png"
theme.layout_tile = "/usr/share/awesome/themes/default/layouts/tilew.png"
theme.layout_tiletop = "/usr/share/awesome/themes/default/layouts/tiletopw.png"
theme.awesome_icon = "/usr/share/awesome/icons/awesome16.png"
return theme
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
package.cpath = package.cpath ..";G:/program/lua/lua_mysql_catch/?.dll";
package.path = package.path..";G:/tool/Lua/5.1/lua/?.lua";
require("luasql.mysql");
local socket = require("socket");
rs_tip = {"select:", "insert:", "delete:", "update:"};
cfg = {dbname="phone_monster",dbuser="root", dbpwd="zuzhang202", dbip="192.168.1.222", dbport=3306};
nod = {};
od = {};
function print_t(r)
ss = '';
for i,v in pairs(r) do
ss = ss .."["..i.."]="..v;
end
--print(ss);
local vn = r["Variable_name"];
od[vn] = tonumber(r["Value"]);
end
function print_od()
print("------------------ mysql total ---------------");
for i,v in pairs(od) do
if (nod[i] ~= nil) then
print("["..i.."]="..(v - nod[i]));
end
nod[i] = v;
end
end
function mysql_push_info(cfg)
r = {0, 0, 0, 0};
local env = luasql.mysql();
local con, err = env:connect(cfg.dbname, cfg.dbuser, cfg.dbpwd, cfg.dbip, cfg.dbport);
if (con) then
for i=1,10 do
cur,er = con:execute("show global status where Variable_name in('com_select','com_insert','com_delete','com_update');");
local rs = cur:fetch({}, "a");
while (rs) do
print_t(rs);
rs = cur:fetch({}, "a");
end
print_od();
socket.sleep(1)
end
con:close();
con = nil;
cr = nil;
else
print(err);
end
end
function start_data()
mysql_push_info(cfg);
end
start_data();
|
-- サイズを持ったQueue
-- Queueのwrapperだけど、それぞれ適切な名前があるやも・・・
Array = {}
Array.new = function(size)
if size == nil or size <= 0 then
return
end
local this = {}
this.maxSize = size
this.list = Queue.new()
-- リストのサイズ
this.size = function(self)
return self.list:size()
end
-- すでに満杯以上か?
this.isOver = function(self)
if self:size() >= self.maxSize then
return true
end
return false
end
-- リストの最後に追加
-- sizeオーバーなら無視
this.add = function(self, data)
if self:isOver() then
return self
end
return self.list:add(data)
end
-- 先頭を取得して削除
this.shift = function(self)
return self.list:shift()
end
-- 後方を取得して削除
this.pop = function(self)
return self.list:pop()
end
-- 先頭に割り込み追加
-- リストがフローした場合、同時に後方の要素を削除する
this.unshift = function(self, data)
if self:isOver() then
self.list:pop()
end
self.list:unshift(data)
return self
end
-- 後方から押し出し追加
-- リストがフローした場合、同時に前方の要素を削除する
this.push = function(self, data)
if self:isOver() then
self.list:shift()
end
self.list:add(data)
return self
end
-- リストのクリア
this.clear = function(self)
return self.list:clear()
end
-- 値リスト取得
-- headからtailまで順になったリストを返す
this.values = function(self)
return self.list:values()
end
-- 同一性確認
-- サイズが同じで、格納されたvaluesが同一か?
this.isEqual = function(self, other)
return self.list:isEqual(other)
end
-- ランダムに一つ選択する
-- 要素は削除しない
this.pickup = function(self, other)
return self.list:pickup()
end
-- デバッグ用print
this.print = function(self)
print('maxSize:'..self.maxSize)
self.list:print()
end
return this
end
-- 初期値つきnew
-- 第一引数のsizeを超えた分は無視される
Array.create = function(size, l)
local a = Array.new(size)
if a == nil then return end
for i, v in pairs(l) do
a:add(v)
end
return a
end
|
-- [[
-- Created on 2022-01-04
-- Marcus Grant (https://github.com/marcus-grant)
-- GPLv3
--
-- Appearance based configs, should be loaded fairly early
-- ]]
-- print('Module Loaded: Appearance')
-- Setup color scheme plugins
-- require('newpaper').setup()
-- Default to gruvbox (for now)
-- vim.o.background = 'dark'
-- vim.cmd([[colorscheme gruvbox]])
-- TODO implement os-aware dark mode detection
local isdarkmode = true -- this should be a function call to fill in the bool
local darkmode_theme = 'gruvbox'
local darkmode_line_theme = darkmode_theme
local litemode_theme = 'newpaper'
local litemode_line_theme = 'papercolor'
local lualine_theme = isdarkmode and darkmode_line_theme or litemode_line_theme
-- Set the color scheme & background
if isdarkmode then
vim.o.background = 'dark'
vim.cmd('colorscheme ' .. darkmode_theme)
else
vim.o.background = 'light'
vim.cmd('colorscheme ' .. litemode_theme)
end
-- LuaLine
require('lualine').setup {
options = {
icons_enabled = true,
theme = lualine_theme,
-- theme = 'auto',
-- component_separators = { left = '', right = ''},
-- section_separators = { left = '', right = ''},
disabled_filetypes = {},
always_divide_middle = true,
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff', 'diagnostics'},
lualine_c = {'filename'},
lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_y = {'progress'},
lualine_z = {'location'}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'location'},
lualine_y = {},
lualine_z = {}
},
tabline = {},
extensions = {}
}
|
local MOUDLE_COMMENT_NAME = "// 内置触摸按键参数配置 //"
local comment_begin = cfg:i32("lp touch key注释开始", 0);
local lp_touch_comment_begin_htext = module_output_comment(comment_begin, MOUDLE_COMMENT_NAME);
local TOUCH_KEY_SENSITY_TABLE = cfg:enumMap("触摸按键电容检测灵敏度(0~9级):",
{
[0] = "电容检测灵敏度级数0",
[1] = "电容检测灵敏度级数1",
[2] = "电容检测灵敏度级数2",
[3] = "电容检测灵敏度级数3",
[4] = "电容检测灵敏度级数4",
[5] = "电容检测灵敏度级数5",
[6] = "电容检测灵敏度级数6",
[7] = "电容检测灵敏度级数7",
[8] = "电容检测灵敏度级数8",
[9] = "电容检测灵敏度级数9",
}
)
--[[
//==========================================================================================//
// 配置项: TOUCH_KEY_CFG //
//==========================================================================================//
--]]
--[[=============================== 配置子项1-0: lp_touch_cfg_en ================================--]]
local en = cfg:enum("触摸按键灵敏度配置使能开关", ENABLE_SWITCH, 1)
en:setOSize(1)
en:setTextOut(
function (ty)
if (ty == 3) then
return "#define TCFG_LP_TOUCH_CFG_ENABLE" .. TAB_TABLE[5] .. ENABLE_SWITCH_TABLE[en.val] .. NLINE_TABLE[1]
end
end
)
-- 子项显示
local lp_touch_key_en_view = cfg:hBox {
cfg:stLabel(en.name .. ":"),
cfg:enumView(en),
cfg:stLabel("(ON:使用配置工具配置值, OFF:使用固件默认值)"),
cfg:stSpacer(),
};
--[[=============================== 配置子项1-1: touch_key_sensity ================================--]]
local touch_key_sensity = cfg:enum("触摸按键灵敏度配置", TOUCH_KEY_SENSITY_TABLE, 5)
touch_key_sensity:setOSize(1)
touch_key_sensity:setTextOut(
function (ty)
if (ty == 3) then
return "#define TCFG_TOUCH_KEY_CH0_SENSITY" .. TAB_TABLE[5] .. touch_key_sensity.val .. NLINE_TABLE[1]
end
end
)
touch_key_sensity:addDeps{en}
touch_key_sensity:setDepChangeHook(function ()
if (en.val == 0) then
touch_key_sensity:setShow(false);
else
touch_key_sensity:setShow(true);
end
end);
-- 子项显示
local touch_key_sensity_hbox_view = cfg:hBox {
cfg:stLabel(touch_key_sensity.name .. ":"),
cfg:enumView(touch_key_sensity),
cfg:stLabel("该参数配置与触摸时电容变化量有关, 触摸时电容变化量跟模具厚度, 触摸片材质, 面积等有关, \n触摸时电容变化量越小, 推荐选择灵敏度级数越大, \n触摸时电容变化量越大, 推荐选择灵敏度级数越小, \n用户可以从灵敏度级数为0开始调试, 级数逐渐增大, 直到选择一个合适的灵敏度配置值。"),
cfg:stSpacer(),
};
--[[=============================== 配置子项1-1: earin_key_sensity ================================--]]
local earin_key_sensity = cfg:enum("入耳检测按键灵敏度配置", TOUCH_KEY_SENSITY_TABLE, 5)
earin_key_sensity:setOSize(1)
earin_key_sensity:setTextOut(
function (ty)
if (ty == 3) then
return "#define TCFG_EARIN_KEY_CH1_SENSITY" .. TAB_TABLE[5] .. earin_key_sensity.val .. NLINE_TABLE[1]
end
end
)
earin_key_sensity:addDeps{en}
earin_key_sensity:setDepChangeHook(function ()
if (en.val == 0) then
earin_key_sensity:setShow(false);
else
earin_key_sensity:setShow(true);
end
end);
-- 子项显示
local earin_key_sensity_hbox_view = cfg:hBox {
cfg:stLabel(earin_key_sensity.name .. ":"),
cfg:enumView(earin_key_sensity),
cfg:stSpacer(),
};
--[[===================================================================================
==================================== 模块返回汇总 =====================================
====================================================================================--]]
-- A. 输出htext
local lp_touch_key_output_htext = {};
insert_item_to_list(lp_touch_key_output_htext, lp_touch_comment_begin_htext);
insert_item_to_list(lp_touch_key_output_htext, touch_key_sensity);
--insert_list_to_list(board_output_text_tabs, lp_touch_key_output_htext);
if enable_moudles["lp_touch_key"] == false then
return;
end
-- B. 输出ctext:无
-- C. 输出bin:
local lp_touch_key_output_bin_list = {
en,
touch_key_sensity,
earin_key_sensity,
};
local lp_touch_key_output_bin = cfg:group("LP_TOUCH_KEY_CFG",
BIN_ONLY_CFG["HW_CFG"].lp_touch_key.id,
1,
lp_touch_key_output_bin_list
);
insert_item_to_list(board_output_bin_tabs, lp_touch_key_output_bin);
-- E. 默认值
local lp_touch_key_cfg_default_table = {};
insert_item_to_list(lp_touch_key_cfg_default_table, en);
insert_item_to_list(lp_touch_key_cfg_default_table, touch_key_sensity);
insert_item_to_list(lp_touch_key_cfg_default_table, earin_key_sensity);
-- D. 显示
local lp_touch_key_group_view_list = {}
insert_item_to_list(lp_touch_key_group_view_list, lp_touch_key_en_view);
insert_item_to_list(lp_touch_key_group_view_list, touch_key_sensity_hbox_view);
--insert_item_to_list(lp_touch_key_group_view_list, earin_key_sensity_hbox_view);
local lp_touch_key_group_view = cfg:stGroup("",
cfg:vBox(lp_touch_key_group_view_list)
);
local lp_touch_key_default_button_view = cfg:stButton(" 触摸配置恢复默认值 ", reset_to_default(lp_touch_key_cfg_default_table));
local lp_touch_key_view_list = cfg:vBox {
cfg:stHScroll(cfg:vBox {
lp_touch_key_group_view,
})
};
local lp_touch_key_view = {"内置触摸按键参数配置",
cfg:vBox {
lp_touch_key_view_list,
lp_touch_key_default_button_view,
}
};
insert_item_to_list(board_view_tabs, lp_touch_key_view);
-- F. bindGroup:无
|
----------------------------------------------------------------------------------------------------------------------------------------
-- create polls for players to vote on
-- by MewMew -- with some help from RedLabel, Klonan, Morcup, BrainClot
----------------------------------------------------------------------------------------------------------------------------------------
local event = require 'utils.event'
local poll_duration_in_seconds = 99
local function create_poll_gui(player)
if player.gui.top.poll then return end
local button = player.gui.top.add { name = "poll", type = "sprite-button", sprite = "item/programmable-speaker", tooltip = "Show current poll" }
button.style.font = "default-bold"
button.style.minimal_height = 38
button.style.minimal_width = 38
button.style.top_padding = 2
button.style.left_padding = 4
button.style.right_padding = 4
button.style.bottom_padding = 2
end
local function poll_show(player)
if player.gui.left["poll-panel"] then player.gui.left["poll-panel"].destroy() end
local frame = player.gui.left.add { type = "frame", name = "poll-panel", direction = "vertical" }
frame.add { type = "table", name = "poll_panel_table", column_count = 2 }
local poll_panel_table = frame.poll_panel_table
if not (global.poll_question == "") then
local str = "Poll #" .. global.score_total_polls_created .. ":"
if global.score_total_polls_created > 1 then
local x = game.tick
x = ((x / 60) / 60) / 60
x = global.score_total_polls_created / x
x = math.round(x, 0)
str = str .. " (Polls/hour: "
str = str .. x
str = str .. ")"
end
poll_panel_table.add { type = "label", caption = str, single_line = false, name = "poll_number_label" }
poll_panel_table.poll_number_label.style.font_color = { r=0.75, g=0.75, b=0.75}
poll_panel_table.add { type = "label"}
poll_panel_table.add { type = "label", caption = global.poll_question, name = "question_label" }
poll_panel_table.question_label.style.maximal_width = 208
poll_panel_table.question_label.style.maximal_height = 170
poll_panel_table.question_label.style.font = "default-bold"
poll_panel_table.question_label.style.font_color = { r=0.98, g=0.66, b=0.22}
poll_panel_table.question_label.style.single_line = false
poll_panel_table.add { type = "label" }
end
local y = 1
while (y < 4) do
if not (global.poll_answers[y] == "") then
local z = tostring(y)
local l = poll_panel_table.add { type = "label", caption = global.poll_answers[y], name = "answer_label_" .. z }
l.style.maximal_width = 208
l.style.minimal_width = 208
l.style.maximal_height = 165
l.style.font = "default"
l.style.single_line = false
local answerbutton = poll_panel_table.add { type = "button", caption = global.poll_button_votes[y], name = "answer_button_" .. z }
answerbutton.style.font = "default-listbox"
answerbutton.style.minimal_width = 32
end
y = y + 1
end
frame.add { type = "table", name = "poll_panel_button_table", column_count = 3 }
local poll_panel_button_table = frame.poll_panel_button_table
poll_panel_button_table.add { type = "button", caption = "New Poll", name = "new_poll_assembler_button" }
if not global.poll_panel_creation_times then global.poll_panel_creation_times = {} end
global.poll_panel_creation_times[player.index] = {player_index = player.index, tick = 5940}
local str = "Hide (" .. poll_duration_in_seconds
str = str .. ")"
poll_panel_button_table.add { type = "button", caption = str, name = "poll_hide_button" }
poll_panel_button_table.poll_hide_button.style.minimal_width = 70
poll_panel_button_table.new_poll_assembler_button.style.font = "default-bold"
poll_panel_button_table.new_poll_assembler_button.style.minimal_height = 38
poll_panel_button_table.poll_hide_button.style.font = "default-bold"
poll_panel_button_table.poll_hide_button.style.minimal_height = 38
poll_panel_button_table.add { type = "checkbox", caption = "Show Polls", state = global.autoshow_polls_for_player[player.name], name = "auto_show_polls_checkbox" }
end
local function poll(player)
local frame = player.gui.left["poll-assembler"]
frame = frame.table_poll_assembler
if frame.textfield_question.text == "" then return end
if frame.textfield_answer_1.text == "" and frame.textfield_answer_2.text == "" and frame.textfield_answer_3.text == "" then return end
global.poll_question = frame.textfield_question.text
global.poll_answers = {frame.textfield_answer_1.text, frame.textfield_answer_2.text, frame.textfield_answer_3.text}
local msg = player.name
msg = msg .. " has created a new Poll!"
global.score_total_polls_created = global.score_total_polls_created + 1
local frame = player.gui.left["poll-assembler"]
frame.destroy()
global.poll_voted = nil
global.poll_voted = {}
global.poll_button_votes = {0,0,0}
for _, player in pairs(game.players) do
if player.gui.left["poll-panel"] then
player.gui.left["poll-panel"].destroy()
end
if global.autoshow_polls_for_player[player.name] == true then
poll_show(player)
end
player.print(msg, { r=0.22, g=0.99, b=0.99})
end
end
local function poll_refresh()
for _, player in pairs(game.players) do
if player.gui.left["poll-panel"] then
local frame = player.gui.left["poll-panel"]
frame = frame.poll_panel_table
if frame.answer_button_1 then frame.answer_button_1.caption = global.poll_button_votes[1] end
if frame.answer_button_2 then frame.answer_button_2.caption = global.poll_button_votes[2] end
if frame.answer_button_3 then frame.answer_button_3.caption = global.poll_button_votes[3] end
end
end
end
local function poll_assembler(player)
local frame = player.gui.left.add { type = "frame", name = "poll-assembler", caption = "" }
local frame_table = frame.add { type = "table", name = "table_poll_assembler", column_count = 2 }
frame_table.add { type = "label", caption = "Question:" }
frame_table.add { type = "textfield", name = "textfield_question", text = "" }
frame_table.add { type = "label", caption = "Answer #1:" }
frame_table.add { type = "textfield", name = "textfield_answer_1", text = "" }
frame_table.add { type = "label", caption = "Answer #2:" }
frame_table.add { type = "textfield", name = "textfield_answer_2", text = "" }
frame_table.add { type = "label", caption = "Answer #3:" }
frame_table.add { type = "textfield", name = "textfield_answer_3", text = "" }
frame_table.add { type = "label", caption = "" }
frame_table.add { type = "button", name = "create_new_poll_button", caption = "Create" }
end
function on_player_joined_game(event)
if not global.poll_init_done then
global.poll_voted = {}
global.poll_question = ""
global.poll_answers = {"","",""}
global.poll_button_votes = {0,0,0}
global.poll_voted = {}
global.autoshow_polls_for_player = {}
global.score_total_polls_created = 0
global.poll_init_done = true
end
local player = game.players[event.player_index]
if global.autoshow_polls_for_player[player.name] == nil then
global.autoshow_polls_for_player[player.name] = true
end
create_poll_gui(player)
if global.poll_question == "" then return end
poll_show(player)
end
local function on_gui_click(event)
if not event then return end
if not event.element then return end
if not event.element.valid then return end
local player = game.players[event.element.player_index]
local name = event.element.name
if name == "poll" then
local frame = player.gui.left["poll-panel"]
if frame then
frame.destroy()
else
poll_show(player)
end
local frame = player.gui.left["poll-assembler"]
if frame then
frame.destroy()
end
end
if name == "new_poll_assembler_button" then
local frame = player.gui.left["poll-assembler"]
if (frame) then
frame.destroy()
else
poll_assembler(player)
end
end
if name == "create_new_poll_button" then
poll(player)
end
if name == "poll_hide_button" then
local frame = player.gui.left["poll-panel"]
if (frame) then
frame.destroy()
end
local frame = player.gui.left["poll-assembler"]
if frame then
frame.destroy()
end
end
if name == "auto_show_polls_checkbox" then
global.autoshow_polls_for_player[player.name] = event.element.state
end
if global.poll_voted[event.player_index] == nil then
if name == "answer_button_1" then
global.poll_button_votes[1] = global.poll_button_votes[1] + 1
global.poll_voted[event.player_index] = player.name
poll_refresh()
end
if name == "answer_button_2" then
global.poll_button_votes[2] = global.poll_button_votes[2] + 1
global.poll_voted[event.player_index] = player.name
poll_refresh()
end
if name == "answer_button_3" then
global.poll_button_votes[3] = global.poll_button_votes[3] + 1
global.poll_voted[event.player_index] = player.name
poll_refresh()
end
end
end
local function process_timeout(creation_time)
local player = game.players[creation_time.player_index]
local frame = player.gui.left["poll-panel"]
if not frame then global.poll_panel_creation_times[player.index] = nil return end
global.poll_panel_creation_times[player.index].tick = global.poll_panel_creation_times[player.index].tick - 60
if global.poll_panel_creation_times[player.index].tick <= 0 then
frame.destroy()
global.poll_panel_creation_times[player.index] = nil
return
end
frame.poll_panel_button_table.poll_hide_button.caption = "Hide (" .. math.ceil(global.poll_panel_creation_times[player.index].tick / 60) .. ")"
end
local function on_tick()
if game.tick % 60 ~= 0 then return end
if not global.poll_panel_creation_times then return end
if #global.poll_panel_creation_times == 0 then
global.poll_panel_creation_times = nil
return
end
for _, creation_time in pairs(global.poll_panel_creation_times) do
process_timeout(creation_time)
end
end
event.add(defines.events.on_tick, on_tick)
event.add(defines.events.on_gui_click, on_gui_click)
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
local request = require 'http.functional.request'
local writer = require 'http.functional.response'
local describe, it, assert = describe, it, assert
local function test_cases(app)
assert.not_nil(app)
it('responds with absolute url for user', function()
local paths = {'/en/user/123', '/de/user/234'}
for _, path in next, paths do
local w, req = writer.new(), request.new {path = path}
app(w, req)
assert.same({'http://localhost:8080' .. path .. '\n'}, w.buffer)
end
end)
it('responds with not found if locale does not match', function()
local w, req = writer.new(), request.new {path = '/ru/user/123'}
app(w, req)
assert.same(404, w.status_code)
end)
it('responds with not found', function()
local w, req = writer.new(), request.new {path = '/unknown'}
app(w, req)
assert.same(404, w.status_code)
end)
describe('single path', function()
it('mapped to http verb get', function()
local w, req = writer.new(), request.new {
path = '/api/users'
}
app(w, req)
assert.same({req.path}, w.buffer)
end)
it('mapped to http verb post', function()
local w, req = writer.new(), request.new {
method = 'POST',
path = '/api/users'
}
app(w, req)
assert.same({'user added'}, w.buffer)
end)
end)
end
describe('demos.http.routing', function()
local app = require 'demos.http.routing'
test_cases(app)
it('responds to any http verb', function()
local http_verbs = {
'DELETE', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'UNKNOWN'
}
for _, m in next, http_verbs do
local w = writer.new()
local req = request.new {method = m, path = '/all'}
app(w, req)
assert.same({'all'}, w.buffer)
end
end)
end)
describe('demos.web.routing', function()
test_cases(require 'demos.web.routing')
end)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.