content
stringlengths 5
1.05M
|
---|
{{/*
Extremely simple and consise counting system.
Recommended trigger: Regex trigger with `.*` trigger limited to your counting channel.
*/}}
{{ deleteResponse 2 }}
{{ $input := toInt .Message.Content }}
{{ $current := dbIncr 0 "counting" 1 | toInt }}
{{ $lastCounter := "" }}
{{ with dbGet 0 "lastCounter" }} {{ $lastCounter = str .Value }} {{ end }}
{{ if or (not (reFind `^\d+$` .Message.Content )) (ne $current $input) }}
{{ block "reset" $current }} {{ dbSet 0 "counting" (sub . 1) }} {{ end }}
{{ deleteTrigger 1 }}
{{ .User.Mention }}, that was the wrong number!
{{ else if eq (str .User.ID) $lastCounter }}
{{ template "reset" $current }}
{{ deleteTrigger 1 }}
{{ .User.Mention }}, you cannot count twice in a row!
{{ else }}
{{ dbSet 0 "lastCounter" (str .User.ID) }}
{{ end }} |
--[[__ _
/ _| __ _ ___ ___ _ __ _ _ _ __ ___| |__
| |_ / _` |/ __/ _ \ '_ \| | | | '_ \ / __| '_ \
| _| (_| | (_| __/ |_) | |_| | | | | (__| | | |
|_| \__,_|\___\___| .__/ \__,_|_| |_|\___|_| |_|
|_| 2012 --]]
local ActiveVideo = nil
VideoSettings = nil
local stats =
{
reset = 0,
encodetime = 0,
starttime = 0,
last_encodetime = 0
}
concommand.Add( "gm_demo_to_video", function( ply, cmd, args )
local demoname = args[1]
if ( !demoname ) then return end
local settings =
{
name = "filled_in_later",
container = "webm",
video = "vp8",
audio = "vorbis",
bitrate = 25000,
quality = 1,
width = 640,
height = 480,
fps = 25,
frameblend = 1,
fbshutter = 0.5,
dofsteps = 0,
dofpasses = 0,
doffocusspeed = 1.0,
dofsize = 1.0,
viewsmooth = 0.0,
possmooth = 0.0
}
local Window = vgui.Create( "DFrame" )
Window:SetTitle( "Render Video" )
Window:SetSize( 600, 400 )
Window:LoadGWENFile( "resource/ui/DemoToVideo.gwen" )
Window:Center()
Window:MakePopup()
local inCodec = Window:Find( "inCodec" )
local inQuality = Window:Find( "inQuality" )
local inSize = Window:Find( "inSize" )
local btnStart = Window:Find( "btnStart" )
local inBitRate = Window:Find( "inBitRate" )
local inFPS = Window:Find( "inFPS" )
local inFrameBlend = Window:Find( "inFrameBlend" )
local inFBShutter = Window:Find( "inFBShutter" )
local inDOF = Window:Find( "inDepthOfField" )
local inDOFSpeed = Window:Find( "inDOFFocusSpeed" )
local inDOFSize = Window:Find( "inDOFBlurSize" )
local inViewSmooth = Window:Find( "inViewSmooth" )
local inPosSmooth = Window:Find( "inPosSmooth" )
inFPS.OnChange = function() settings.fps = inFPS:GetInt() end
inFPS:SetText( settings.fps );
inBitRate.OnChange = function() settings.bitrate = inBitRate:GetInt() end
inBitRate:SetText( settings.bitrate );
-- TODO!!!
inCodec.OnSelect = function( _, index, value, data ) settings.container = data[1]; settings.video = data[2]; settings.audio = data[3] end
inCodec:AddChoice( "webm", { "webm", "vp8", "vorbis" }, true )
inCodec:AddChoice( "ogg", { "ogg", "theora", "vorbis" } )
inQuality.OnSelect = function( _, index, value, data ) settings.quality = data end
inQuality:AddChoice( "0.0 - Low (but fast)", 0 )
inQuality:AddChoice( "0.5 - Medium", 0.5 )
inQuality:AddChoice( "1.0 - Highest (but slow)", 1, true )
-- TODO!!!
inSize.OnSelect = function( _, index, value, data ) settings.width = data[1] settings.height = data[2] end
inSize:AddChoice( ScrW() .. " x " .. ScrH() .. " (highest)", { ScrW(), ScrH() }, true )
inSize:AddChoice( math.ceil(ScrW() * 0.66666) .. " x " .. math.ceil(ScrH() *0.66666), { ScrW()*0.666666, ScrH()*0.666666 } )
inSize:AddChoice( math.ceil(ScrW() * 0.33333) .. " x " .. math.ceil(ScrH() *0.33333), { ScrW()*0.333333, ScrH()*0.333333 } )
inFrameBlend.OnSelect = function( _, index, value, data ) settings.frameblend = data end
inFrameBlend:AddChoice( "Off", 1, true )
inFrameBlend:AddChoice( "Draft (8 Samples)", 8 )
inFrameBlend:AddChoice( "Good (16 Samples)", 16 )
inFrameBlend:AddChoice( "Great (32 Samples)", 32 )
inFrameBlend:AddChoice( "Overkill (64 Samples)", 64 )
inFrameBlend:AddChoice( "OverOverKill (128 Samples)", 128 )
inFBShutter.OnSelect = function( _, index, value, data ) settings.fbshutter = data end
inFBShutter:AddChoice( "90", 0.75 )
inFBShutter:AddChoice( "180", 0.5, true )
inFBShutter:AddChoice( "240", 0.25 )
inFBShutter:AddChoice( "360", 0.0 )
--
-- DOF
--
inDOF.OnSelect = function( _, index, value, data ) settings.dofsteps = data[1]; settings.dofpasses = data[2] end
inDOF:AddChoice( "Off", { 0, 0 }, true )
inDOF:AddChoice( "Draft (21 Samples)", { 6, 3 } )
inDOF:AddChoice( "Good (72 Samples)", { 12, 6 } )
inDOF:AddChoice( "Best (288 Samples)", { 24, 12 } )
inDOFSpeed.OnChange = function() settings.doffocusspeed = inDOFSpeed:GetFloat() end
inDOFSpeed:SetText( "1.0" )
inDOFSize.OnChange = function() settings.dofsize = inDOFSize:GetFloat() end
inDOFSize:SetText( "1.0" )
--
-- Smoothing
--
inViewSmooth.OnSelect = function( _, index, value, data ) settings.viewsmooth = data end
inViewSmooth:AddChoice( "Off", 0.0, true )
inViewSmooth:AddChoice( "Minimal", 0.2 )
inViewSmooth:AddChoice( "Low", 0.4 )
inViewSmooth:AddChoice( "Medium", 0.7 )
inViewSmooth:AddChoice( "High", 0.8 )
inViewSmooth:AddChoice( "Lots", 0.9 )
inViewSmooth:AddChoice( "Too Smooth", 0.97 )
inPosSmooth.OnSelect = function( _, index, value, data ) settings.possmooth = data end
inPosSmooth:AddChoice( "Off", 0.0, true )
inPosSmooth:AddChoice( "Minimal", 0.2 )
inPosSmooth:AddChoice( "Low", 0.4 )
inPosSmooth:AddChoice( "Medium", 0.7 )
inPosSmooth:AddChoice( "High", 0.8 )
inPosSmooth:AddChoice( "Lots", 0.9 )
inPosSmooth:AddChoice( "Too Smooth", 0.97 )
btnStart.DoClick = function()
-- Fill in the name here, or we'll be overwriting the same video!
local cleanname = string.GetFileFromFilename( demoname )
cleanname = cleanname:Replace( ".", "_" )
cleanname = cleanname .. " " .. util.DateStamp();
settings.name = cleanname
PrintTable( settings )
ActiveVideo, error = video.Record( settings );
if ( !ActiveVideo ) then
MsgN( "Couldn't record video: ", error )
return
end
RunConsoleCommand( "sv_cheats", 1 );
RunConsoleCommand( "host_framerate", settings.fps * settings.frameblend );
RunConsoleCommand( "snd_fixed_rate", 1 );
RunConsoleCommand( "progress_enable", 1 );
RunConsoleCommand( "playdemo", demoname );
VideoSettings = table.Copy( settings )
--Window:Remove()
end
end, nil, "", { FCVAR_DONTRECORD } )
local function FinishRecording()
VideoSettings = nil
ActiveVideo:Finish()
ActiveVideo = nil
RunConsoleCommand( "host_framerate", 0 );
RunConsoleCommand( "sv_cheats", 0 );
RunConsoleCommand( "snd_fixed_rate", 0 );
MsgN( "Rendering Finished - Took ",SysTime()-stats.starttime," seconds" )
end
local function UpdateFrame()
if ( !engine.IsPlayingDemo() ) then
if ( !VideoSettings.started ) then return end
FinishRecording()
return
end
if ( !VideoSettings.started ) then
if ( gui.IsGameUIVisible() ) then return end
VideoSettings.started = true
VideoSettings.framecount = 0
stats.starttime = SysTime()
end
end
local function DrawOverlay()
if ( !VideoSettings ) then return end
local complete = engine.GetDemoPlaybackTick() / engine.GetDemoPlaybackTotalTicks()
local x = ScrW()*0.1
local y = ScrH()*0.8
local w = ScrW()*0.8
local h = ScrH()*0.05
surface.SetFont( "DermaDefault" )
surface.SetTextColor( 255, 255, 255, 255 )
surface.SetDrawColor( 0, 0, 0, 50 )
surface.DrawRect( x-3, y-3, w+6, h+6 )
surface.SetDrawColor( 255, 255, 255, 200 )
surface.DrawRect( x-2, y-2, w+4, 2 )
surface.DrawRect( x-2, y, 2, h )
surface.DrawRect( x+w, y, 2, h )
surface.DrawRect( x-2, y+h, w+4, 2 )
surface.SetDrawColor( 255, 255, 100, 150 )
surface.DrawRect( x+1, y+1, w * complete - 2, h - 2 )
surface.SetTextPos( x, y + h + 10 );
surface.DrawText( "Time Taken: " .. string.NiceTime( SysTime() - stats.starttime ) )
local tw, th = surface.GetTextSize( "Time Left: " .. string.NiceTime( stats.timeremaining ) )
surface.SetTextPos( x + w - tw, y + h + 10 );
surface.DrawText( "Time Left: " .. string.NiceTime( stats.timeremaining ) )
local demolength = "Demo Length: ".. string.FormattedTime( engine.GetDemoPlaybackTotalTicks() * engine.TickInterval(), "%2i:%02i" )
local tw, th = surface.GetTextSize( demolength )
surface.SetTextPos( x + w - tw, y - th - 10 );
surface.DrawText( demolength )
local info = "Rendering ".. math.floor( VideoSettings.width ) .. "x" .. math.floor( VideoSettings.height ) .. " at " .. math.floor( VideoSettings.fps ).. "fps ";
local with = {}
if ( VideoSettings.dofsteps > 0 ) then table.insert( with, "DOF" ) end
if ( VideoSettings.frameblend > 1 ) then table.insert( with, "Frame Blending" ) end
if ( VideoSettings.viewsmooth > 0 ) then table.insert( with, "View Smoothing" ) end
if ( VideoSettings.possmooth > 0 ) then table.insert( with, "Position Smoothing" ) end
if ( #with > 0 ) then
with = string.Implode( ", ", with )
info = info .. "with " .. with
end
info = info .. " (rendering " .. (VideoSettings.frameblend*VideoSettings.dofsteps*VideoSettings.dofpasses) .. " frames per frame)";
local tw, th = surface.GetTextSize( info )
surface.SetTextPos( x, y - th - 10 );
surface.DrawText( info )
local demotime = string.FormattedTime( (engine.GetDemoPlaybackTick() * engine.TickInterval()), "%2i:%02i" )
local tw, th = surface.GetTextSize( demotime )
if ( w * complete > tw + 20 ) then
surface.SetTextColor( 0, 0, 0, 200 )
surface.SetTextPos( x + w * complete - tw - 10, y + h * 0.5 - th * 0.5 );
surface.DrawText( demotime )
end
local demotime = string.FormattedTime( ((engine.GetDemoPlaybackTotalTicks()-engine.GetDemoPlaybackTick()) * engine.TickInterval()), "%2i:%02i" )
local tw, th = surface.GetTextSize( demotime )
if ( w - w * complete > tw + 20 ) then
surface.SetTextColor( 255, 255, 255, 200 )
surface.SetTextPos( x + w * complete + 10, y + h * 0.5 - th * 0.5 );
surface.DrawText( demotime )
end
end
hook.Add( "CaptureVideo", "CaptureDemoFrames", function()
if ( !ActiveVideo ) then return end
if ( !VideoSettings ) then return end
UpdateFrame()
DrawOverlay()
if ( stats.reset < SysTime() ) then
stats.reset = SysTime() + 1
stats.last_encodetime = stats.encodetime
stats.encodetime = 0
local timetaken = SysTime() - stats.starttime
local fractioncomplete = engine.GetDemoPlaybackTotalTicks() / engine.GetDemoPlaybackTick()
stats.timeremaining = (timetaken * fractioncomplete) - timetaken
if ( stats.timeremaining < 0 ) then stats.timeremaining = 0 end
end
end )
function RecordDemoFrame()
if ( !VideoSettings.started ) then return end
ActiveVideo:AddFrame( 1 / VideoSettings.fps, true );
VideoSettings.framecount = VideoSettings.framecount + 1
end |
-- make changes here
local config = {
SEND_KEY = "SHJKDGKASJDHSKLADG&@%&DSKLJAHLBDKBA<SBD",
title = "RANDOM KILL LIST",
webaddress = "http://rkl.semklauke.de"
}
local voteFrame = {}
local function sendTraitorVote(vote)
if type(vote) == "boolean" then
net.Start("RKL_TraitorVoted")
net.WriteString(config.SEND_KEY)
net.WriteBool(vote)
net.SendToServer()
end
end
local function sendUserVote(vote, steamid)
if type(vote) == "boolean" then
net.Start("RKL_UserVoted")
net.WriteString(config.SEND_KEY)
net.WriteString(steamid)
net.WriteBool(vote)
net.SendToServer()
end
end
local function showTheListPanel()
local frame = vgui.Create( "DFrame" )
frame:SetSize( 330, 600 )
frame:SetTitle(config.title)
frame:SetVisible( true )
frame:SetDraggable( true )
frame:Center()
--Fill the form with a html page
local html = vgui.Create( "DHTML" , frame )
html:Dock( FILL )
html:OpenURL(config.webaddress)
html:SetAllowLua( true )
frame:MakePopup()
end
local function showTraitorVoteMenu()
local frame = vgui.Create("DFrame")
frame:SetSize(210, 90)
frame:SetPos( ScrW() * 0.1, ScrH() * 0.3)
frame:SetTitle(config.title)
frame:SetVisible(true)
frame:SetDraggable(true)
frame:ShowCloseButton(false)
frame.Paint = function(self, w, h)
draw.RoundedBox(0, 0, 0, 300, 210, Color(115, 115, 115, 170))
end
frame:MakePopup()
local DLabel = vgui.Create("DLabel", frame)
DLabel:SetPos(16, 20)
DLabel:SetColor(Color(255, 255, 255 ))
DLabel:SetText("Did you get Random Killed ?")
DLabel:SizeToContents()
local YesButton = vgui.Create( "DButton", frame )
YesButton:SetText( "YES" )
YesButton:SetPos(15, 45)
YesButton:SetSize(70, 30)
YesButton:SetTextColor(Color(0, 135, 2))
YesButton.Paint = function(self, w, h)
draw.RoundedBox(0, 0, 0, w, h, Color( 37, 37, 37, 250))
end
YesButton.DoClick = function()
sendTraitorVote(true)
frame:Close()
end
local NoButton = vgui.Create( "DButton", frame )
NoButton:SetText( "NO" )
NoButton:SetPos(100, 45)
NoButton:SetSize(70, 30)
NoButton:SetTextColor(Color(206, 0, 2))
NoButton.Paint = function(self, w, h)
draw.RoundedBox(0, 0, 0, w, h, Color( 37, 37, 37, 250))
end
NoButton.DoClick = function()
sendTraitorVote(false)
frame:Close()
end
end
local function showUserVoteMenu(victim, steamid)
voteFrame[steamid] = vgui.Create("DFrame")
voteFrame[steamid]:SetSize(250, 90)
voteFrame[steamid]:SetPos( ScrW() * 0.1, ScrH() * 0.4)
voteFrame[steamid]:SetTitle(config.title)
voteFrame[steamid]:SetVisible(true)
voteFrame[steamid]:SetDraggable(true)
voteFrame[steamid]:ShowCloseButton(false)
voteFrame[steamid].Paint = function(self, w, h)
draw.RoundedBox(0, 0, 0, w, h, Color(206, 0, 10, 180))
end
voteFrame[steamid]:MakePopup()
local DLabel = vgui.Create("DLabel", voteFrame[steamid])
DLabel:SetPos(16, 20)
DLabel:SetColor(Color(255, 255, 255 ))
local text = "Did " .. victim .. " get Random killed ?"
DLabel:SetText(text)
DLabel:SizeToContents()
local YesButton = vgui.Create( "DButton", voteFrame[steamid] )
YesButton:SetText( "YES" )
YesButton:SetPos(15, 45)
YesButton:SetSize(70, 30)
YesButton:SetTextColor(Color(0, 135, 2))
YesButton.Paint = function(self, w, h)
draw.RoundedBox(0, 0, 0, w, h, Color( 37, 37, 37, 200))
end
YesButton.DoClick = function()
sendUserVote(true, steamid)
voteFrame[steamid]:Close()
voteFrame[steamid] = nil;
end
local NoButton = vgui.Create( "DButton", voteFrame[steamid] )
NoButton:SetText( "NO" )
NoButton:SetPos(100, 45)
NoButton:SetSize(70, 30)
NoButton:SetTextColor(Color(206, 0, 2))
NoButton.Paint = function(self, w, h)
draw.RoundedBox(0, 0, 0, w, h, Color( 37, 37, 37, 150))
end
NoButton.DoClick = function()
sendUserVote(false, steamid)
voteFrame[steamid]:Close()
voteFrame[steamid] = nil;
end
end
-- game hooks --
-- for debugging
hook.Add("OnPlayerChat", "HelloCommand", function( ply, strText, bTeam, bDead )
if strText == "!rkl_uVote" then
showUserVoteMenu("a", "b")
elseif strText == "!rkl_tVote" then
showTraitorVoteMenu()
end
end )
-- network recives --
net.Receive("RKL_StopVote", function()
local steamid = net.ReadString()
if voteFrame[steamid] ~= nil then
voteFrame[steamid]:Close()
end
end )
net.Receive("RKL_AskTraitor", function()
showTraitorVoteMenu()
end )
net.Receive("RKL_AskEverybody", function()
local vicName = net.ReadString()
local vicSteamID = net.ReadString()
showUserVoteMenu(vicName, vicSteamID)
end )
net.Receive("RKL_TheListPanel", function()
showTheListPanel()
end ) |
-- VARIABLES ===================================================================
local areaOfEffect = 5
local areaCollider = nil
origKDmg = 0
origDmgM = 0
origDmgR = 0
origIntAtk = 1.0
-- FUNCTIONS ===================================================================
function Constructor()
areaCollider = owner:GetComponent("SphereCollider")
if (areaCollider ~= nil) then
areaCollider:SetRadius(areaOfEffect)
end
end
function OnUpdate(dt)
end
function OnCollisionEnter(other)
--SETUP THE TOURGUIDE BUFF DMG TOWARDS melee, range, kamikaze
if (other:Tag() == "Slime" and other:Name() ~= "Slime_TourGuide" and other:Name() ~= "Slime_Spawner") then
script = nil
if(other:Name() == "Slime_Kamikaze")then
---Increase kamikaze on core dmg
script = GO_Core:GetLuaScript("CoreLogic.lua")
kDmg = script:GetVariable("truekamikaze_Damage")
origKDmg = kDmg
kDmg = kDmg * 2
script:SetVariable("kamikaze_Damage", kDmg)
script = other:GetLuaScript("Enemy_Kamikaze.lua")
else
--Damage up
script = other:GetLuaScript("EnemyBehavior.lua")
dmgM = script:GetVariable("truedamage_melee")
origDmgM = dmgM
dmgM = dmgM * 2
script:SetVariable("damage_melee",dmgM)
dmgR = script:GetVariable("truedamage_slimeBullet")
origDmgR = dmgR
dmgR = dmgR * 2
script:SetVariable("damage_slimeBullet",dmgR)
--Adjust atk spd
origIntAtk = script:GetVariable("trueinterval_attack")
int_atk = origIntAtk / 1.5
script:SetVariable("interval_attack",int_atk)
end
end
end
function OnCollisionPersist(other)
if (other:Name() == "Slime") then
script = other:GetLuaScript("EnemyBehavior.lua")
script:CallFunction("TourGuideBuff")
end
if (other:Name() == "Slime_Kamikaze") then
script = other:GetLuaScript("Enemy_Kamikaze.lua")
script:CallFunction("TourGuideBuff")
end
end
function OnCollisionExit(other)
end |
--[=[
@class GameConfigCommandServiceClient
]=]
local require = require(script.Parent.loader).load(script)
local GameConfigCmdrUtils = require("GameConfigCmdrUtils")
local Maid = require("Maid")
local RxStateStackUtils = require("RxStateStackUtils")
local Rx = require("Rx")
local GameConfigCommandServiceClient = {}
function GameConfigCommandServiceClient:Init(serviceBag)
assert(not self._serviceBag, "Already initialized")
self._serviceBag = assert(serviceBag, "No serviceBag")
self._maid = Maid.new()
self._cmdrService = self._serviceBag:GetService(require("CmdrServiceClient"))
self._gameConfigServiceClient = self._serviceBag:GetService(require("GameConfigServiceClient"))
end
function GameConfigCommandServiceClient:Start()
self:_setupCommands()
end
function GameConfigCommandServiceClient:_setupCommands()
local picker = self._gameConfigServiceClient:GetConfigPicker()
-- TODO: Determine production vs. staging and set cmdr annotation accordingly.
self._cmdrService:PromiseCmdr():Then(function(cmdr)
GameConfigCmdrUtils.registerAssetTypes(cmdr, picker)
local latestConfig = RxStateStackUtils.createStateStack(picker:ObserveActiveConfigsBrio())
self._maid:GiveTask(latestConfig)
self._maid:GiveTask(latestConfig:Observe():Pipe({
Rx.switchMap(function(config)
if config then
return config:ObserveConfigName()
else
return Rx.of(nil)
end
end)
}):Subscribe(function(name)
if name then
cmdr:SetPlaceName(name)
else
-- Default value
cmdr:SetPlaceName("Cmdr")
end
end))
end)
end
return GameConfigCommandServiceClient |
-- Auto-generated code below aims at helping you parse
-- the standard input according to the problem statement.
-- ---
-- Hint: You can use the debug stream to print initialTX and initialTY, if Thor seems not follow your orders.
-- lightX: the X position of the light of power
-- lightY: the Y position of the light of power
-- initialTX: Thor's starting X position
-- initialTY: Thor's starting Y position
next_token = string.gmatch(io.read(), "[^%s]+")
lightX = tonumber(next_token())
lightY = tonumber(next_token())
initialTX = tonumber(next_token())
initialTY = tonumber(next_token())
-- game loop
while true do
remainingTurns = tonumber(io.read()) -- The remaining amount of turns Thor can move. Do not remove this line.
-- Write an action using print()
-- To debug: io.stderr:write("Debug message\n")
move = ''
if initialTY > lightY then
move = move .. "N"
initialTY = initialTY-1
end
if initialTY < lightY then
move = move .. 'S'
initialTY = initialTY + 1
end
if initialTX > lightX then
move = move .. 'W'
initialTX = initialTX-1
end
if initialTX < lightX then
move = move .. 'E'
initialTX = initialTX + 1
end
-- A single line providing the move to be made: N NE E SE S SW W or NW
print(move)
end |
local lu = require 'luaunit'
local headers = require 'http.headers'
local Request = require 'tulip.pkg.server.Request'
local Response = require 'tulip.pkg.server.Response'
-- Stream mocks a lua-http Stream object for tests.
local Stream = {__name = 'test.Stream', connection = {version = 1.1}}
Stream.__index = Stream
function Stream:get_headers()
return self._headers
end
function Stream.peername()
return 'test', '127.0.0.1', 0
end
function Stream.localname()
return 'test', '127.0.0.1', 0
end
function Stream.checktls()
return false
end
function Stream:write_headers(hdrs, eos, to)
if to and to < 0 then
return nil, 'timed out'
end
if self._written then
error('stream already written to')
end
self._written = {headers = hdrs:clone(), eos = eos}
return true
end
function Stream:write_chunk(s, eos, to)
if to and to < 0 then
return nil, 'timed out'
end
if not self._written then
error('stream headers were not written')
end
if self._written.eos then
error('stream is closed')
end
self._written.body = (self._written.body or '') .. s
self._written.eos = eos
return true
end
function Stream:assertWritten(hdrs, body, eos)
lu.assertIsTable(self._written)
local t = self._written
if hdrs then
for k, want in pairs(hdrs) do
local got = (t.headers:get(k)) or ''
lu.assertEquals(got, want)
end
end
if body then
lu.assertEquals(t.body or '', body)
end
if eos ~= nil then
lu.assertEquals(t.eos, eos)
end
end
function Stream:get_next_chunk(to)
-- read as chunks of 10
return self:get_body_chars(10, to)
end
function Stream:get_body_as_string(to)
if to and to < 0 then
return nil, 'timed out'
end
return self._body
end
function Stream:get_body_chars(n, to)
if to and to < 0 then
return nil, 'timed out'
end
local start = self._body_start or 1
local s = string.sub(self._body, start, start + n - 1)
self._body_start = start + n
if s == '' then return end
return s
end
-- only supports until newline
function Stream:get_body_until(_, _, inc, to)
if to and to < 0 then
return nil, 'timed out'
end
local start = self._body_start or 1
local ix = string.find(self._body, '\n', start, true)
if not ix then
-- pattern not found, return everything or nil if the body is consumed
local s = string.sub(self._body, start)
if s == '' then return end
self._body_start = #self._body + 1
return s
else
local last = ix
if not inc then
last = last - 1
end
local s = string.sub(self._body, start, last)
self._body_start = ix + 1
return s
end
end
function Stream.new(method, path, body)
local hdrs = headers.new()
hdrs:append(':method', method)
hdrs:append(':path', path)
local o = {_headers = hdrs, _body = body}
return setmetatable(o, Stream)
end
function Stream.newreqres(app, method, path, body)
local stm = Stream.new(method, path, body)
local req = Request.new(stm, 5)
local res = Response.new(stm, 5)
stm.request, stm.response = req, res
req.app, res.app = app, app
return stm, req, res
end
return Stream
|
local fileout = love.filesystem.newFile("programwalkout.txt","w")
programwalk = {}
local toPrint = false
function programwalk.start(outputMode)
if outputMode == "print" then
toPrint = true
end
debug.sethook(lineDebugFunction , "l")
end
function programwalk.stop()
debug.sethook()
fileout:close()
end
local function write(...) -- Only 2 arguments
if not toPrint then
if select("#",...) == 1 then
fileout:write(select(1,...).."\n")
elseif select("#",...) == 2 then
fileout:write(select(1,...).."\t"..select(2,...).."\n")
else
assert(false,"To many arguments in debug")
end
else
print(...)
end
end
function lineDebugFunction(stringLine,lineNumber)
local skip = false
local info = debug.getinfo(2,"S") -- Remove second argument to return all possible info
-- Special case these files as it doesn't have any useful information for me.
if info.source == "boot.lua" or
info.source == "graphics.lua" or
info.source == "@conf.lua" then
skip = true
end
info.source = info.source:gsub("@","")
if not skip then
write("Source",info.source) -- Which Source file
write("Current line",lineNumber) --Current line
readLine(lineNumber , info.source ) -- TODO: parse info.source
--write("----")
--for k , v in pairs(info) do -- write everything in info table
-- write(k, type(v) , v)
--end
write("-----------------------------------------")
end
end
function readLine(lineNumber,fileName)
local i = 1
for line in love.filesystem.lines(fileName) do
if i == lineNumber then
write(line)
break
end
i = i+1
end
end
|
--------------------------------------------------------------------------------
-- Init file for ESP8266 temperature sensor
-- AUTHOR: Jakub Cabal <[email protected]>
-- LICENCE: The MIT License (MIT)
-- WEBSITE: https://github.com/jakubcabal/esp8266_temp_sensor
--------------------------------------------------------------------------------
print("Starting WIFI...")
wifi.setmode(wifi.STATION)
wifi.sta.config("SSID","PASSWORD")
wifi.sta.connect()
tmr.alarm(1, 1000, 1, function()
if wifi.sta.getip()== nil then
print("No IP address...")
else
tmr.stop(1)
dofile("temp.lua")
end
end) |
--[[
diagram-generator – create images and figures from code blocks.
This Lua filter is used to create images with or without captions
from code blocks. Currently PlantUML, GraphViz, Tikz, and Python
can be processed. For further details, see README.md.
Copyright: © 2018-2020 John MacFarlane <[email protected]>,
2018 Florian Schätzig <[email protected]>,
2019 Thorsten Sommer <[email protected]>,
2019-2020 Albert Krewinkel <[email protected]>
License: MIT – see LICENSE file for details
]]
-- Module pandoc.system is required and was added in version 2.7.3
PANDOC_VERSION:must_be_at_least '2.7.3'
local system = require 'pandoc.system'
local utils = require 'pandoc.utils'
local stringify = utils.stringify
local with_temporary_directory = system.with_temporary_directory
local with_working_directory = system.with_working_directory
-- The PlantUML path. If set, uses the environment variable PLANTUML or the
-- value "plantuml.jar" (local PlantUML version). In order to define a
-- PlantUML version per pandoc document, use the meta data to define the key
-- "plantuml_path".
local plantuml_path = os.getenv("PLANTUML") or "plantuml.jar"
-- The Inkscape path. In order to define an Inkscape version per pandoc
-- document, use the meta data to define the key "inkscape_path".
local inkscape_path = os.getenv("INKSCAPE") or "inkscape"
-- The Python path. In order to define a Python version per pandoc document,
-- use the meta data to define the key "python_path".
local python_path = os.getenv("PYTHON") or "python"
-- The Python environment's activate script. Can be set on a per document
-- basis by using the meta data key "activatePythonPath".
local python_activate_path = os.getenv("PYTHON_ACTIVATE")
-- The Java path. In order to define a Java version per pandoc document,
-- use the meta data to define the key "java_path".
local java_path = os.getenv("JAVA_HOME")
if java_path then
java_path = java_path .. package.config:sub(1,1) .. "bin"
.. package.config:sub(1,1) .. "java"
else
java_path = "java"
end
-- The dot (Graphviz) path. In order to define a dot version per pandoc
-- document, use the meta data to define the key "dot_path".
local dot_path = os.getenv("DOT") or "dot"
-- The pdflatex path. In order to define a pdflatex version per pandoc
-- document, use the meta data to define the key "pdflatex_path".
local pdflatex_path = os.getenv("PDFLATEX") or "pdflatex"
-- The default format is SVG i.e. vector graphics:
local filetype = "svg"
local mimetype = "image/svg+xml"
-- Check for output formats that potentially cannot use SVG
-- vector graphics. In these cases, we use a different format
-- such as PNG:
if FORMAT == "docx" then
filetype = "png"
mimetype = "image/png"
elseif FORMAT == "pptx" then
filetype = "png"
mimetype = "image/png"
elseif FORMAT == "rtf" then
filetype = "png"
mimetype = "image/png"
end
-- Execute the meta data table to determine the paths. This function
-- must be called first to get the desired path. If one of these
-- meta options was set, it gets used instead of the corresponding
-- environment variable:
function Meta(meta)
plantuml_path = stringify(
meta.plantuml_path or meta.plantumlPath or plantuml_path
)
inkscape_path = stringify(
meta.inkscape_path or meta.inkscapePath or inkscape_path
)
python_path = stringify(
meta.python_path or meta.pythonPath or python_path
)
python_activate_path =
meta.activate_python_path or meta.activatePythonPath or python_activate_path
python_activate_path = python_activate_path and stringify(python_activate_path)
java_path = stringify(
meta.java_path or meta.javaPath or java_path
)
dot_path = stringify(
meta.path_dot or meta.dotPath or dot_path
)
pdflatex_path = stringify(
meta.pdflatex_path or meta.pdflatexPath or pdflatex_path
)
end
-- Call plantuml.jar with some parameters (cf. PlantUML help):
local function plantuml(puml, filetype)
return pandoc.pipe(
java_path,
{"-jar", plantuml_path, "-t" .. filetype, "-pipe", "-charset", "UTF8"},
puml
)
end
-- Call dot (GraphViz) in order to generate the image
-- (thanks @muxueqz for this code):
local function graphviz(code, filetype)
return pandoc.pipe(dot_path, {"-T" .. filetype}, code)
end
--
-- TikZ
--
--- LaTeX template used to compile TikZ images. Takes additional
--- packages as the first, and the actual TikZ code as the second
--- argument.
local tikz_template = [[
\documentclass{standalone}
\usepackage{tikz}
%% begin: additional packages
%s
%% end: additional packages
\begin{document}
%s
\end{document}
]]
--- Returns a function which takes the filename of a PDF and a
-- target filename, and writes the input as the given format.
-- Returns `nil` if conversion into the target format is not
-- possible.
local function convert_from_pdf(filetype)
-- Build the basic Inkscape command for the conversion
local inkscape_output_args
if filetype == 'png' then
inkscape_output_args = '--export-png="%s" --export-dpi=300'
elseif filetype == 'svg' then
inkscape_output_args = '--export-plain-svg="%s"'
else
return nil
end
return function (pdf_file, outfile)
local inkscape_command = string.format(
'"%s" --without-gui --file="%s" ' .. inkscape_output_args,
inkscape_path,
pdf_file,
outfile
)
io.stderr:write(inkscape_command .. '\n')
local command_output = io.popen(inkscape_command)
-- TODO: print output when debugging.
command_output:close()
end
end
--- Compile LaTeX with Tikz code to an image
local function tikz2image(src, filetype, additional_packages)
local convert = convert_from_pdf(filetype)
-- Bail if there is now known way from PDF to the target format.
if not convert then
error(string.format("Don't know how to convert pdf to %s.", filetype))
end
return with_temporary_directory("tikz2image", function (tmpdir)
return with_working_directory(tmpdir, function ()
-- Define file names:
local file_template = "%s/tikz-image.%s"
local tikz_file = file_template:format(tmpdir, "tex")
local pdf_file = file_template:format(tmpdir, "pdf")
local outfile = file_template:format(tmpdir, filetype)
-- Build and write the LaTeX document:
local f = io.open(tikz_file, 'w')
f:write(tikz_template:format(additional_packages or '', src))
f:close()
-- Execute the LaTeX compiler:
pandoc.pipe(pdflatex_path, {'-output-directory', tmpdir, tikz_file}, '')
convert(pdf_file, outfile)
-- Try to open and read the image:
local img_data
local r = io.open(outfile, 'rb')
if r then
img_data = r:read("*all")
r:close()
else
-- TODO: print warning
end
return img_data
end)
end)
end
-- Run Python to generate an image:
local function py2image(code, filetype)
-- Define the temp files:
local outfile = string.format('%s.%s', os.tmpname(), filetype)
local pyfile = os.tmpname()
-- Replace the desired destination's file type in the Python code:
local extendedCode = string.gsub(code, "%$FORMAT%$", filetype)
-- Replace the desired destination's path in the Python code:
extendedCode = string.gsub(extendedCode, "%$DESTINATION%$", outfile)
-- Write the Python code:
local f = io.open(pyfile, 'w')
f:write(extendedCode)
f:close()
-- Execute Python in the desired environment:
local pycmd = python_path .. ' ' .. pyfile
local command = python_activate_path
and python_activate_path .. ' && ' .. pycmd
or pycmd
os.execute(command)
-- Try to open the written image:
local r = io.open(outfile, 'rb')
local imgData = nil
-- When the image exist, read it:
if r then
imgData = r:read("*all")
r:close()
else
io.stderr:write(string.format("File '%s' could not be opened", outfile))
error 'Could not create image from python code.'
end
-- Delete the tmp files:
os.remove(pyfile)
os.remove(outfile)
return imgData
end
-- Executes each document's code block to find matching code blocks:
function CodeBlock(block)
-- Predefine a potential image:
local fname = nil
-- Using a table with all known generators i.e. converters:
local converters = {
plantuml = plantuml,
graphviz = graphviz,
tikz = tikz2image,
py2image = py2image,
}
-- Check if a converter exists for this block. If not, return the block
-- unchanged.
local img_converter = converters[block.classes[1]]
if not img_converter then
return nil
end
-- Call the correct converter which belongs to the used class:
local success, img = pcall(img_converter, block.text,
filetype, block.attributes["additionalPackages"] or nil)
-- Was ok?
if success and img then
-- Hash the figure name and content:
fname = pandoc.sha1(img) .. "." .. filetype
-- Store the data in the media bag:
pandoc.mediabag.insert(fname, mimetype, img)
else
-- an error occured; img contains the error message
io.stderr:write(tostring(img))
io.stderr:write('\n')
error 'Image conversion failed. Aborting.'
end
-- Case: This code block was an image e.g. PlantUML or dot/Graphviz, etc.:
if fname then
-- Define the default caption:
local caption = {}
local enableCaption = nil
-- If the user defines a caption, use it:
if block.attributes["caption"] then
caption = pandoc.read(block.attributes.caption).blocks[1].content
-- This is pandoc's current hack to enforce a caption:
enableCaption = "fig:"
end
-- Create a new image for the document's structure. Attach the user's
-- caption. Also use a hack (fig:) to enforce pandoc to create a
-- figure i.e. attach a caption to the image.
local imgObj = pandoc.Image(caption, fname, enableCaption)
-- Now, transfer the attribute "name" from the code block to the new
-- image block. It might gets used by the figure numbering lua filter.
-- If the figure numbering gets not used, this additional attribute
-- gets ignored as well.
if block.attributes["name"] then
imgObj.attributes["name"] = block.attributes["name"]
end
-- Transfer the identifier from the code block to the new image block
-- to enable downstream filters like pandoc-crossref. This allows a figure
-- block starting with:
--
-- ```{#fig:pumlExample .plantuml caption="This is an image, created by **PlantUML**."}
--
-- to be referenced as @fig:pumlExample outside of the figure.
if block.identifier then
imgObj.identifier = block.identifier
end
-- Finally, put the image inside an empty paragraph. By returning the
-- resulting paragraph object, the source code block gets replaced by
-- the image:
return pandoc.Para{ imgObj }
end
end
-- Normally, pandoc will run the function in the built-in order Inlines ->
-- Blocks -> Meta -> Pandoc. We instead want Meta -> Blocks. Thus, we must
-- define our custom order:
return {
{Meta = Meta},
{CodeBlock = CodeBlock},
}
|
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
local server_name = "sqlls"
local root_pattern = util.root_pattern(".sqllsrc.json")
configs[server_name] = {
default_config = {
filetypes = {"sql", "mysql"};
root_dir = function(fname)
return root_pattern(fname) or vim.loop.os_homedir()
end;
settings = {};
};
docs = {
description = [[
https://github.com/joe-re/sql-language-server
`cmd` value is **not set** by default. The `cmd` value can be overriden in the `setup` table;
```lua
require'lspconfig'.sqlls.setup{
cmd = {"path/to/command", "up", "--method", "stdio"};
...
}
```
This LSP can be installed via `npm`. Find further instructions on manual installation of the sql-language-server at [joe-re/sql-language-server](https://github.com/joe-re/sql-language-server).
<br>
]];
};
}
-- vim:et ts=2 sw=2
|
if CLIENT then return end
ENT.Type = "brush"
function ENT:Initialize()
self:SetTrigger(true)
self.Entities = {}
end
function ENT:IsTouchedBy(ent)
return table.HasValue(self.Entities, ent)
end
function ENT:StartTouch(ent)
if not self:PassesTriggerFilters(ent) then return end
table.insert(self.Entities, ent)
self:Input("OnStartTouch", self, ent)
end
function ENT:Touch(ent)
if not self:PassesTriggerFilters(ent) then return end
if not table.HasValue(self.Entities, ent) then table.insert(self.Entities, ent) end
self:Input("OnTouch", self, ent)
end
function ENT:EndTouch(ent)
if not self:IsTouchedBy(ent) then return end
table.RemoveByValue(self.Entities, ent)
self:Input("OnEndTouch", self, ent)
local bFoundOtherTouchee = false
local iSize = #self.Entities
for i=iSize, 0, -1 do
local hOther = self.Entities[i]
if not IsValid(hOther) then
table.RemoveByValue(self.Entities, hOther)
else
bFoundOtherTouchee = true
end
end
if not bFoundOtherTouchee then
self:Input("OnEndTouchAll", self, ent)
end
end |
local table = require "loop.table"
local SortedMap = require "loop.collection.SortedMap"
local freenode = {
false, false, false, false, false,
false, false, false, false, false,
false, false, false, false, false,
false, false, false, false, false,
false, false, false, false, false,
false, false, false, false, false,
false, false, false, false, false,
false, false, false, false, false,
false, false, false, false, false,
false, false, false, false, false,
}
local nodepool = {}
for i = 1, 200 do
local node = table.copy(freenode)
node[1] = nodepool.freenodes
nodepool.freenodes = node
end
map = SortedMap{ nodepool = nodepool }
assert(map:put(12, "12") == "12")
assert(map:put(6 , "6" ) == "6" )
assert(map:put(3 , "3" ) == "3" )
assert(map:put(26, "26") == "26")
assert(map:put(25, "25") == "25")
assert(map:put(19, "19") == "19")
assert(map:put(7 , "7" ) == "7" )
assert(map:put(21, "21") == "21")
assert(map:put(17, "17") == "17")
assert(map:put(9 , "9" ) == "9" )
assert(map:get(12) == "12")
assert(map:get(6 ) == "6")
assert(map:get(3 ) == "3")
assert(map:get(26) == "26")
assert(map:get(25) == "25")
assert(map:get(19) == "19")
assert(map:get(7 ) == "7")
assert(map:get(21) == "21")
assert(map:get(17) == "17")
assert(map:get(9 ) == "9")
print "items added and consulted"; map:debug()
map:cropuntil(0, true)
print "cropped upto 0 and iterated"; map:debug()
map:cropuntil(14, true)
print(map)
for key, value in map:pairs() do
print(key, value)
end
print "cropped upto 14 and iterated"; map:debug()
map:remove(12, true)
map:remove(6)
map:remove(3)
print "removed >12, 6, 3"; map:debug()
map:cropuntil(100000, true)
print "cropped upto 100000"; map:debug()
for _=1, 100 do
map:put(math.random() * 100, "random", true)
end
print "1000 items added"; map:debug()
map:cropuntil(90, true)
print "cropped upto 90"; map:debug()
print "freenodes:"
local node = map.nodepool.freenodes
while node do
print(string.format("[%s] = %s (->%d)", node.key or 'nil', node.value or 'nil', #node))
node = node[1]
end |
function MainApp(root)
dofile(root .. "objects/CommonFunctions.lua")
dofile(root .. "objects/LoadPeripherals.lua")
dofile(root .. "objects/Communicator.lua")
dofile(root .. "GUI/GUIMessages.lua")
dofile(root .. "controller/DataController.lua")
dofile(root .. "programs/Configuration.lua")
self = {}
local commonF = CommonFunctions()
local guiMessages = GUIMessages()
local communicator = Communicator()
local dataController = DataController(commonF,root)
dataController.load()
local slaves = (dataController.getObjects()).slaveList.getSlaves()
local continue = true
local tasksIteratorList = {}
local protocolCallsList = {}
local callers = {}
local save = false
local selectedSlave = nil
local function taskIterator(data)
local function findNextTask(tasks)
for i,task in ipairs(tasks) do
if (not task.complete) then
return task
end
end
return nil
end
local slave = data
coroutine.yield()
while true do
if (#slave.tasks > 0) then
local task = findNextTask(slave.tasks)
if (task ~= nil) then
if (not task.sent) then
for i = 1,17 do
--print(task.execution .. ": trying for the " .. i .. " time")
rednet.send(slave.id,textutils.serialize(task),slave.protocol)
coroutine.yield()
end
task.sent = true
save = true
else
coroutine.yield()
end
end
end
coroutine.yield()
end
end
local function addSlave(protocol,id)
if (slaves[id] == nil) then
slaves[id] = {["protocol"] = protocol, ["id"] = id, ["tasks"] = {}}
tasksIteratorList[id] = coroutine.create(taskIterator)
dataController.saveData()
else
slaves[id].protocol = protocol
tasksIteratorList[id] = coroutine.create(taskIterator)
dataController.saveData()
end
end
local function protocolCalls(data)
local function executeNTimes(f,params)
local data = nil
for i = 1,10 do
data = f(params)
if data ~= nil then
return data,true
end
coroutine.yield()
end
return nil,false
end
local caller = data
local s,m,p = caller[1], caller[2], caller[3]
caller.randomKey = commonF.randomness(100,999)
caller.finished = true
caller.step = 0
caller.completed = false
local r = caller.randomKey
coroutine.yield()
local data,status = executeNTimes(
function (params)
rednet.send(params[1],r,os.getComputerID() .. params[1])
if (caller.completed) then
return "finished"
else
return nil
end
end,
{s}
)
coroutine.yield()
end
local function protocolCallsIteratorList()
while true do
if (#callers > 0) then
for k,v in ipairs(callers) do
if (coroutine.status(protocolCallsList[v[1]]) ~= "dead") then
coroutine.resume(protocolCallsList[v[1]],v)
coroutine.yield()
else
protocolCallsList[v[1]] = nil
end
end
end
coroutine.yield()
end
end
local function protocolCallsReceiver()
local s,m,p = rednet.receive(0.2)
if (s~=nil and p~=nil) then
if (p=="apmtSlaveConnection" and (protocolCallsList[s] == nil or coroutine.status(protocolCallsList[s]) == "dead")) then
callers[#callers+1] = {s,m,p}
protocolCallsList[s] = coroutine.create(protocolCalls)
end
end
if (#callers > 0) then
for k,caller in ipairs(callers) do
if (protocolCallsList[caller[1]] ~=nil) then
if (coroutine.status(protocolCallsList[caller[1]]) ~= "dead") then
if (caller.finished ~= nil) then
if (caller.finished) then
if (not caller.completed) then
if (caller.step < 10) then
if (s ~= nil) then
if (p == (os.getComputerID() .. caller[1])) then
caller.completed = true
addSlave(os.getComputerID() .. caller[1] .. (caller.randomKey * m), caller[1])
end
end
caller.step = caller.step + 1
end
end
end
end
else
callers[k] = nil
end
end
end
end
if selectedSlave ~= nil then
--print(textutils.serialize(selectedSlave))
if (tasksIteratorList[selectedSlave.id] ~= nil) then
for k,task in ipairs(selectedSlave.tasks) do
if task.sent and (not task.complete) then
--print(selectedSlave.protocol .. " " .. task.execution)
if (s~=nil) then
--print(p .. " " .. selectedSlave.protocol .. " " .. s)
if (selectedSlave.protocol == p) then
if (s == selectedSlave.id) then
local receivedTask = textutils.unserialize(m)
if receivedTask ~=nil then
--print(p .. " " .. selectedSlave.protocol .. " " .. task.execution .. " " .. receivedTask.execution)
if receivedTask.complete == true and receivedTask.execution==task.execution then
task.complete = true
task.status = receivedTask.status
save = true
end
end
end
end
end
end
end
end
end
end
local function lastCall()
end
local function slaveSelector()
while true do
for k,slave in pairs(slaves) do
selectedSlave = slave
coroutine.yield()
end
coroutine.yield()
end
end
local function slavesIterator()
while true do
for k,slave in pairs(slaves) do
if (tasksIteratorList[slave.id] ~= nil) then
coroutine.resume(tasksIteratorList[slave.id],slave)
coroutine.yield()
end
end
coroutine.yield()
end
end
local function patternAction()
local pcil = coroutine.create(protocolCallsIteratorList)
local si = coroutine.create(slavesIterator)
local ss = coroutine.create(slaveSelector)
while true do
coroutine.resume(ss)
protocolCallsReceiver()
coroutine.resume(pcil)
coroutine.resume(si)
if commonF.keyPressed(0.1) ~= 0 then
break
end
if save then
save = false
dataController.saveData()
end
end
end
local mainCase = commonF.switch{
[1] = function(x)
Configuration(root,commonF,dataController,guiMessages)
end,
[2] = function(x)
patternAction()
end,
[3] = function(x)
os.reboot()
end,
[4] = function(x)
continue = false
end,
default = function (x) continue = false end
}
local function menu()
guiMessages.showHeader("------Main Menu------")
print("1: Configure")
print("2: Applications")
print("3: Reboot")
print("4: Exit")
return commonF.limitToWrite(15)
end
function self.main()
(dataController.getObjects()).slaveList.reset()
dataController.saveData()
rednet.host("apmtSlaveConnection","apmtServer" .. os.getComputerID())
if (communicator.modemIsEnabled()) then
while continue do
patternAction()
mainCase:case(tonumber(menu()))
end
else
guiMessages.showErrorMsg("Error: This computer has no modems atached")
end
end
return self
end
|
-- /home/jannis/Projekte/ReactorControl/reactor_control.lua
TURBINE_DEFAULT_FLUID_CONSUMPTION = 2000
TURBINE_MINIMUM_RUNTIME = 1800
REACTOR_MAX_TEMPERATURE = 500
REACTOR_MAX_FLUID_STORED = 14000
REACTOR_WAIT_POWERUP = 15
REACTOR_JUMP_THRESHOLD = 500
REACTOR_JUMP_HEIGHT = 5
local modem = peripheral.wrap("bottom")
modem.open(1)
local Generator = {}
Generator.__index = Generator
function Generator.new(r)
local self = setmetatable({}, Generator)
while not peripheral.isPresent(r) do
sleep(5)
end
self.reactorName = r
self.reactor = peripheral.wrap(r)
self.turbine = {}
self.controlRodLevel = self.reactor.getControlRodLevel(1)
self.reactorPowerUpTime = 0
self.turbinePowerUpTime = 0
return self
end
function Generator:addTurbine(t)
while not peripheral.isPresent(t) do
sleep(5)
end
table.insert(self.turbine,peripheral.wrap(t))
end
function Generator:getPowerProduction()
local sum = 0
for key,value in ipairs(self.turbine) do
sum = sum + value.getEnergyProducedLastTick()
end
return sum
end
function Generator:getHotFluidProduced()
return self.reactor.getHotFluidProducedLastTick()
end
function Generator:getWasteAmount()
return self.reactor.getWasteAmount()
end
function Generator:getCoreTemperature()
return self.reactor.getFuelTemperature()
end
function Generator:getCaseTemperature()
return self.reactor.getCasingTemperature()
end
function Generator:setControlRod(level)
self.reactor.setAllControlRodLevels(level)
self.controlRodLevel = level
end
function Generator:increaseControlRod(num)
local value = num or 1
if self.controlRodLevel < 100 then
self.controlRodLevel = self.controlRodLevel + value
if self.controlRodLevel > 100 then
self.controlRodLevel = 100
end
self.reactor.setAllControlRodLevels(self.controlRodLevel)
end
end
function Generator:decreaseControlRod(num)
local value = num or 1
if self.controlRodLevel > 0 then
self.controlRodLevel = self.controlRodLevel - value
if self.controlRodLevel < 0 then
self.controlRodLevel = 0
end
self.reactor.setAllControlRodLevels(self.controlRodLevel)
end
end
function Generator:getHotFluidRequired()
local sum = 0
for key,value in ipairs(self.turbine) do
sum = sum + value.getFluidFlowRateMax()
end
return sum
end
function Generator:getHotFluidStored()
return self.reactor.getHotFluidAmount()
end
function Generator:getMaxHotFluidStored()
return self.reactor.getHotFluidAmountMax()
end
function Generator:powerUpReactor()
if not self.reactor.getActive() then
self.reactor.setActive(true)
self:setControlRod(99)
self.reactorPowerUpTime = os.clock()
end
end
function Generator:powerDownReactor()
if self:getHotFluidRequired() == 0 then
self:setControlRod(100)
self.reactor.setActive(false)
end
end
function Generator:powerUpTurbine()
for key,value in ipairs(self.turbine) do
if value.getFluidFlowRateMax() == 0 then
value.setFluidFlowRateMax(TURBINE_DEFAULT_FLUID_CONSUMPTION)
self.turbinePowerUpTime = os.clock()
self:powerUpReactor()
break
end
end
end
function Generator:powerDownTurbine()
if self.turbinePowerUpTime + TURBINE_MINIMUM_RUNTIME > os.clock() then
return
end
for key,value in ipairs(self.turbine) do
if value.getFluidFlowRateMax() > 0 then
value.setFluidFlowRateMax(0)
break
end
end
end
function Generator:regulateReactor()
local fluidProduced = self:getHotFluidProduced()
local fluidRequired = self:getHotFluidRequired()
if self.reactor.getActive() then
if fluidRequired == 0 then
self:powerDownReactor()
elseif self.controlRodLevel < 99 and self:getCoreTemperature() > REACTOR_MAX_TEMPERATURE then
self:increaseControlRod()
elseif os.clock() > self.reactorPowerUpTime + REACTOR_WAIT_POWERUP then
if fluidProduced < fluidRequired then
if fluidProduced + REACTOR_JUMP_THRESHOLD < fluidRequired then
self:decreaseControlRod(REACTOR_JUMP_HEIGHT)
else
self:decreaseControlRod()
end
elseif self:getHotFluidStored() > REACTOR_MAX_FLUID_STORED and fluidProduced >= fluidRequired then
self:increaseControlRod()
end
end
elseif fluidRequired > 0 then
self:powerUpReactor()
end
end
function Generator:sendData()
local data = {}
data["reactor_name"] = self.reactorName
data["reactor_rods"] = self.controlRodLevel
data["reactor_core"] = self:getCoreTemperature()
data["turbine_1_rpm"] = self.turbine[1].getRotorSpeed()
data["turbine_1_power"] = self.turbine[1].getEnergyProducedLastTick()
data["turbine_2_rpm"] = self.turbine[2].getRotorSpeed()
data["turbine_2_power"] = self.turbine[2].getEnergyProducedLastTick()
data["turbine_3_rpm"] = self.turbine[3].getRotorSpeed()
data["turbine_3_power"] = self.turbine[3].getEnergyProducedLastTick()
modem.transmit(1,1,data)
end
function Generator:receiveCommands()
end
term.clear()
term.setCursorPos(1,1)
print("Setting up connections...")
--sleep(60)
r1 = Generator.new("BigReactors-Reactor_0")
r1:addTurbine("BigReactors-Turbine_2")
r1:addTurbine("BigReactors-Turbine_3")
r1:addTurbine("BigReactors-Turbine_0")
r2 = Generator.new("BigReactors-Reactor_1")
r2:addTurbine("BigReactors-Turbine_5")
r2:addTurbine("BigReactors-Turbine_4")
r2:addTurbine("BigReactors-Turbine_1")
term.clear()
term.setCursorPos(1,1)
print("Running ReactorControl...")
while true do
r1:regulateReactor()
r2:regulateReactor()
r1:sendData()
r2:sendData()
sleep(3)
end
|
function EFFECT:Init( data )
local TargetEntity = data:GetEntity()
if ( !TargetEntity || !TargetEntity:IsValid() ) then return end
self.Entity:SetModel(TargetEntity:GetModel())
self.Entity:SetPos(TargetEntity:GetPos())
self.Entity:SetAngles(TargetEntity:GetAngles())
self.AV=255
end
/*---------------------------------------------------------
THINK
---------------------------------------------------------*/
function EFFECT:Think( )
self.AV=self.AV-1
self.Entity:SetColor(255,255,255,self.AV)
return self.AV>0
end
/*---------------------------------------------------------
Draw the effect
---------------------------------------------------------*/
function EFFECT:Render()
self.Entity:DrawModel()
end |
local playsession = {
{"toddrofls", {539941}},
{"J-Put", {2580}},
{"rlidwka", {276780}},
{"TheLemur", {374892}},
{"liquidblue", {528196}},
{"HYPPS", {501484}},
{"Kamyk", {50257}},
{"Zymoran", {519141}},
{"facere", {470138}},
{"LeeFactor", {466659}},
{"paczcz", {443234}},
{"PogomanD", {333719}},
{"Mordalfus", {410790}},
{"barton1906", {14259}},
{"vvictor", {19501}},
{"Danzou", {45170}},
{"crash893", {48464}},
{"Nerazin", {163833}},
{"_Joe_", {6074}},
{"wjx008", {121454}},
{"625dennis", {114387}},
{"Xeavas", {3164}}
}
return playsession |
-- p is percentage running from 0 to 1
-- $e is exression from easing
-- result is percentrage from 0 to 1
-- start easing at 80%, linear before
-- log and research that
flux.easing["quadout_edge"]=function(p)
p = 1-p -- out
-- linear first
if p>0.2 then
return 1-p
end
-- bug: this switch chages coord, makes jump
-- google something ready
-- then quad
return 1 - (p*p)
end |
local function swap_gate_node(pos,name,dir)
local node = core.get_node(pos)
local meta = core.get_meta(pos)
local meta0 = meta:to_table()
node.name = name
node.param2=dir
core.set_node(pos,node)
meta:from_table(meta0)
end
local function addGateNode(gateNodes, pos)
gateNodes[#gateNodes+1] = vector.new(pos)
end
local function placeGate(player,pos)
local dir = minetest.dir_to_facedir(player:get_look_dir())
local pos1 = vector.new(pos)
local gateNodes = {}
addGateNode(gateNodes, pos1)
pos1.y=pos1.y+1
addGateNode(gateNodes, pos1)
for i=1,2 do
if core.get_node(gateNodes[i]).name ~= "air" then
print("not enough space")
return false
end
end
core.set_node(pos, {name="gateway_light:gatenode_off", param2=dir})
local player_name = player:get_player_name()
local meta = core.get_meta(pos)
meta:set_string("infotext", "Gateway\rOwned by: "..player_name)
meta:set_int("gateActive", 0)
meta:set_string("owner", player_name)
meta:set_string("dont_destroy", "false")
gateway_light.registerGate(player_name, pos, dir)
return true
end
local function removeGate(pos)
local meta = core.get_meta(pos)
if meta:get_string("dont_destroy") == "true" then
-- when swapping it
return
end
gateway_light.unregisterGate(meta:get_string("owner"), pos)
end
function gateway_light.activateGate(pos)
local node = core.get_node(pos)
local dir=node.param2
local meta = core.get_meta(pos)
meta:set_int("gateActive",1)
meta:set_string("dont_destroy","true")
minetest.sound_play("gateOpen", {pos = pos, max_hear_distance = 72,})
local color = ""
if meta:get_string("_color") then
local stored_color = meta:get_string("_color")
if stored_color == "blue" or stored_color == "red" or stored_color == "green" or stored_color == "violet" or stored_color == "orange" or stored_color == "yellow" or stored_color == "pink" or stored_color == "cyan" then
color = "_" .. stored_color
end
end
swap_gate_node(pos,"gateway_light:gatenode_on" .. color,dir)
meta:set_string("dont_destroy","false")
end
function gateway_light.deactivateGate(pos)
local node = core.get_node(pos)
local dir=node.param2
local meta = core.get_meta(pos)
meta:set_int("gateActive",0)
meta:set_string("dont_destroy","true")
minetest.sound_play("gateClose", {pos = pos, gain = 1.0,loop = false, max_hear_distance = 72,})
swap_gate_node(pos,"gateway_light:gatenode_off",dir)
meta:set_string("dont_destroy","false")
end
local function gateCanDig(pos, player)
local meta = core.get_meta(pos)
return meta:get_string("dont_destroy") ~= "true"
and player:get_player_name() == meta:get_string("owner")
end
local sg_collision_box = {
type = "fixed",
fixed={{-0.5,-0.5,-0.5,0.5,-0.42,0.5},},
}
local sg_selection_box = {
type = "fixed",
fixed={{-0.5,-0.5,-0.5,0.5,1.5,0.5},},
}
function gateway_light.node_abm(pos, node, active_object_count, active_object_count_wider)
if pos then
--local owner
for _,object in pairs(core.get_objects_inside_radius(pos, 1)) do
if object:is_player() then
local player_name = object:get_player_name()
local gate = gateway_light.findGate(pos)
if not gate then
print("Gate is not registered!")
return
end
--owner = owner or core.get_meta(pos):get_string("owner")
if gate.type == "private"
and player_name ~= core.get_meta(pos):get_string("owner") then
return
end
local pos1 = vector.new(gate.destination)
if not gateway_light.findGate(pos1) then
gate.destination = nil
gateway_light.deactivateGate(pos)
gateway_light.save_data(core.get_meta(pos):get_string("owner"))
return
end
local dir1 = gate.destination_dir
local dest_angle
if dir1 == 0 then
pos1.z = pos1.z-2
dest_angle = 180
elseif dir1 == 1 then
pos1.x = pos1.x-2
dest_angle = 90
elseif dir1 == 2 then
pos1.z=pos1.z+2
dest_angle = 0
elseif dir1 == 3 then
pos1.x = pos1.x+2
dest_angle = -90
end
object:moveto(pos1,false)
object:set_look_yaw(math.rad(dest_angle))
core.sound_play("enterEventHorizon", {pos = pos, max_hear_distance = 72})
end
end
end
end
local sg_groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1}
local sg_groups1 = {snappy=2,choppy=2,oddly_breakable_by_hand=2}
local node_config = {
tiles = {
{name = "gateway_metal.png"},
{
name = "puddle_animated2.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 2.0,
},
},
{
name = "gateway_particle_anim.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 1.5,
},
},
{
name = "gateway_portal.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 1.5,
},
},
},
alpha = 192,
drawtype = "mesh",
mesh = "gateway.b3d",
visual_scale = 1.0,
groups = sg_groups,
drop="gateway_light:gatenode_off",
paramtype2 = "facedir",
paramtype = "light",
light_source = 10,
selection_box = sg_selection_box,
collision_box = sg_collision_box,
can_dig = gateCanDig,
on_destruct = removeGate,
on_rightclick=gateway_light.gateFormspecHandler,
}
minetest.register_node("gateway_light:gatenode_on",node_config)
local blue_portal = node_config
blue_portal.tiles[4].name="gateway_portal.png^[multiply:#0063b0"
minetest.register_node("gateway_light:gatenode_on_blue",blue_portal)
local green_portal = node_config
green_portal.tiles[4].name="gateway_portal.png^[multiply:#4ee34c"
minetest.register_node("gateway_light:gatenode_on_green",green_portal)
local red_portal = node_config
red_portal.tiles[4].name="gateway_portal.png^[multiply:#dc1818"
minetest.register_node("gateway_light:gatenode_on_red",red_portal)
local violet_portal = node_config
violet_portal.tiles[4].name="gateway_portal.png^[multiply:#a437ff"
minetest.register_node("gateway_light:gatenode_on_violet",violet_portal)
local cyan_portal = node_config
cyan_portal.tiles[4].name="gateway_portal.png^[multiply:#07B6BC"
minetest.register_node("gateway_light:gatenode_on_cyan",cyan_portal)
local orange_portal = node_config
orange_portal.tiles[4].name="gateway_portal.png^[multiply:#ff8b0e"
minetest.register_node("gateway_light:gatenode_on_orange",orange_portal)
local yellow_portal = node_config
yellow_portal.tiles[4].name="gateway_portal.png^[multiply:#ffe400"
minetest.register_node("gateway_light:gatenode_on_yellow",yellow_portal)
local pink_portal = node_config
pink_portal.tiles[4].name="gateway_portal.png^[multiply:#ff62c6"
minetest.register_node("gateway_light:gatenode_on_pink",pink_portal)
minetest.register_node("gateway_light:gatenode_off",{
description = "Light Gateway",
inventory_image = "stargate.png",
wield_image = "stargate.png",
tiles = {"gateway_metal.png",
{
name = "puddle_animated2.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 2.0,
},
},
"null.png"
},
groups = sg_groups1,
paramtype2 = "facedir",
paramtype = "light",
drawtype = "mesh",
mesh = "gateway.b3d",
visual_scale = 1.0,
light_source = 10,
selection_box = sg_selection_box,
collision_box = sg_collision_box,
can_dig = gateCanDig,
_color = "",
on_destruct = removeGate,
on_place = function(itemstack, placer, pointed_thing)
local pos = pointed_thing.above
if placeGate(placer,pos)==true then
itemstack:take_item(1)
return itemstack
else
return
end
end,
on_rightclick=gateway_light.gateFormspecHandler,
on_punch = function(pos, node, puncher, pointed_thing)
local player_name = puncher:get_player_name()
local meta = core.get_meta(pos)
if player_name ~= meta:get_string("owner") then
return
end
local itmstck=puncher:get_wielded_item()
local item_name = ""
if itmstck then item_name = itmstck:get_name() end
-- deal with painting or destroying
if itmstck then
local _,indx = item_name:find('dye:')
if indx then
--lets paint!!!!
meta:set_string("_color", item_name:sub(indx+1));
end
end
end,
})
minetest.register_abm({
nodenames = {"gateway_light:gatenode_on", "gateway_light:gatenode_on_blue",
"gateway_light:gatenode_on_green", "gateway_light:gatenode_on_red",
"gateway_light:gatenode_on_violet", "gateway_light:gatenode_on_cyan",
"gateway_light:gatenode_on_orange", "gateway_light:gatenode_on_yellow",
"gateway_light:gatenode_on_pink",
},
interval = 1,
chance = 1,
action = gateway_light.node_abm
})
|
-----------------------------------------------------------------------------
-- Defines functions for searching Saci data.
--
--
-- (c) 2007, 2008 Yuri Takhteyev ([email protected])
-- License: MIT/X, see http://sputnik.freewisdom.org/en/License
-----------------------------------------------------------------------------
function rank_hits(hits, node_map)
local weights = {} -- weight for each node ID
local node_ids = {} -- a list of node ids (to be sorted eventually)
for id, node in pairs(node_map) do
for term, hits_for_term in pairs(hits) do
if hits_for_term[id] then
weights[id] = (weights[id] or 0) + 5 + hits_for_term[id]
end
end
if weights[id] then
table.insert(node_ids, id)
end
end
table.sort(node_ids, function(x,y) return weights[x] > weights[y] end)
return node_ids, weights
end
|
local class = require('class')
local itemDB = require('itemDB')
local Util = require('util')
local device = _G.device
local Adapter = class()
function Adapter:init(args)
if args.side then
local inventory = device[args.side]
if inventory then
Util.merge(self, inventory)
end
end
end
function Adapter:listItems(throttle)
local cache = { }
throttle = throttle or Util.throttle()
for k,v in pairs(self.list()) do
if v.count > 0 then
local key = table.concat({ v.name, v.damage, v.nbtHash }, ':')
local entry = cache[key]
if not entry then
local cached = itemDB:get(v)
if cached then
cached = Util.shallowCopy(cached)
else
cached = self.getItemMeta(k)
if cached then
cached = Util.shallowCopy(itemDB:add(cached))
end
end
if cached then
entry = cached
entry.count = 0
cache[key] = entry
else
_G._debug('Adapter: failed to get item details')
end
end
if entry then
entry.count = entry.count + v.count
end
throttle()
end
end
self.cache = cache
end
return Adapter
|
-----------------------------------
-- Ability: Activate
-- Calls forth your automaton.
-- Obtained: Puppetmaster Level 1
-- Recast Time: 0:20:00 (0:16:40 with full merits)
-- Duration: Instant
-----------------------------------
require("scripts/globals/settings")
require("scripts/globals/status")
require("scripts/globals/pets")
require("scripts/globals/msg")
-----------------------------------
function onAbilityCheck(player,target,ability)
if (player:getPet() ~= nil) then
return tpz.msg.basic.ALREADY_HAS_A_PET,0
elseif (not player:canUseMisc(tpz.zoneMisc.PET)) then
return tpz.msg.basic.CANT_BE_USED_IN_AREA,0
else
return 0,0
end
end
function onUseAbility(player,target,ability)
player:spawnPet(tpz.pet.id.AUTOMATON)
end |
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.UI.Visible = not script.Parent.Parent.UI.Visible
end) |
AddCSLuaFile()
AddCSLuaFile("sh_sounds.lua")
include("sh_sounds.lua")
SWEP.magType = "pistolMag"
SWEP.PrintName = "Ruger Mk3"
CustomizableWeaponry:registerAmmo(".22LR", ".22LR Rounds", 5.6, 15.6)
if CLIENT then
SWEP.DrawCrosshair = false
SWEP.CSMuzzleFlashes = true
SWEP.IconLetter = "y"
killicon.Add( "khr_rugermk3", "icons/killicons/khr_rugermk3", Color(255, 80, 0, 150))
SWEP.SelectIcon = surface.GetTextureID("icons/select/khr_rugermk3")
SWEP.MuzzleEffect = "muzzleflash_pistol"
SWEP.PosBasedMuz = true
SWEP.Shell = "smallshell"
SWEP.ShellScale = .25
SWEP.ShellOffsetMul = 1
SWEP.ShellPosOffset = {x = 0, y = 0, z = 0}
SWEP.EffectiveRange_Orig = 29.5 * 39.37
SWEP.DamageFallOff_Orig = .22
SWEP.IronsightPos = Vector(2.809, 0, 1.799)
SWEP.IronsightAng = Vector(-0.1, -0.0334, 0)
SWEP.DocterPos = Vector(2.809, 0, 1.599)
SWEP.DocterAng = Vector(0, 0, 0)
SWEP.SprintPos = Vector(0, 0, 0)
SWEP.SprintAng = Vector(-20.478, -14.407, 9.145)
SWEP.CustomizePos = Vector(-4.222, -4.624, -0.805)
SWEP.CustomizeAng = Vector(25.326, -19.698, -30.251)
SWEP.AlternativePos = Vector(1, -2, 0.3)
SWEP.AlternativeAng = Vector(0, 0, 0)
SWEP.MoveType = 1
SWEP.ViewModelMovementScale = 0.3
SWEP.FullAimViewmodelRecoil = true
SWEP.BoltBone = "bolt"
SWEP.BoltShootOffset = Vector(-1.1, 0, 0)
SWEP.EmptyBoltHoldAnimExclusion = "shoot_empty"
SWEP.HoldBoltWhileEmpty = true
SWEP.DontHoldWhenReloading = true
SWEP.DisableSprintViewSimulation = true
SWEP.FOVPerShot = 0.1
SWEP.LuaVMRecoilAxisMod = {vert = 0.55, hor = 0.5, roll = 2, forward = 0, pitch = 1.5}
SWEP.CustomizationMenuScale = 0.02
SWEP.BoltBonePositionRecoverySpeed = 50 -- how fast does the bolt bone move back into it's initial position after the weapon has fired
SWEP.AttachmentModelsVM = {
["md_docter"] = { type = "Model", model = "models/wystan/attachments/2octorrds.mdl", bone = "smdimport", rel = "", pos = Vector(-0.24, 2, 1.1), angle = Angle(0, 0, 0), size = Vector(1.014, 1.014, 1.014), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} },
["md_rugersup"] = { type = "Model", model = "models/cw2/attachments/9mmsuppressor.mdl", bone = "smdimport", rel = "", pos = Vector(0, -11, 0.07), angle = Angle(0, 0, 0), size = Vector(0.55, 1.728, 0.55), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}
end
SWEP.MuzzleVelocity = 380 -- in meter/s
SWEP.LuaViewmodelRecoil = false
SWEP.LuaViewmodelRecoilOverride = true
SWEP.CanRestOnObjects = false
SWEP.Attachments = {[2] = {header = "Magazine", offset = {-600, 250}, atts = {"bg_rugerext"}},
[1] = {header = "Barrel", offset = {-600, -300}, atts = {"md_rugersup"}},
["+reload"] = {header = "Ammo", offset = {500, 200}, atts = {"am_matchgrade"}}}
SWEP.Animations = {reload = "reload",
fire = {"shoot1","shoot2"},
fire_dry = "shoot_empty",
idle = "idle",
draw = "draw"}
SWEP.Sounds = {draw = {{time = 0, sound = "CW_FOLEY_LIGHT"}},
reload = {[1] = {time = 0.40, sound = "RUBY_CLIPOUT"},
[2] = {time = 1.5, sound = "RUBY_CLIPIN"},
[3] = {time = 2.1, sound = "RUBY_SLIDEREL"}}}
SWEP.SpeedDec = 10
SWEP.Slot = 1
SWEP.SlotPos = 0
SWEP.NormalHoldType = "pistol"
SWEP.RunHoldType = "normal"
SWEP.FireModes = {"semi"}
SWEP.Base = "cw_base"
SWEP.Category = "CW 2.0 - Pistols"
SWEP.Author = "Khris"
SWEP.Contact = ""
SWEP.Purpose = ""
SWEP.Instructions = "Rack slide. Face barrel towards enemy. Do not eat."
SWEP.ViewModelFOV = 90
SWEP.AimViewModelFOV = 80
SWEP.ViewModelFlip = true
SWEP.ViewModel = "models/khrcw2/v_khri_rugermark.mdl"
SWEP.WorldModel = "models/weapons/w_pist_fiveseven.mdl"
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.Primary.ClipSize = 10
SWEP.Primary.DefaultClip = 10
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = ".22LR"
SWEP.FireDelay = 0.1
SWEP.FireSound = "MK3_FIRE"
SWEP.FireSoundSuppressed = "MK3_FIRE_SUPPRESSED"
SWEP.Recoil = 0.08
SWEP.HipSpread = 0.030
SWEP.AimSpread = 0.008
SWEP.VelocitySensitivity = 1.2
SWEP.MaxSpreadInc = 0.025
SWEP.SpreadPerShot = 0.001
SWEP.SpreadCooldown = 0.01
SWEP.Damage = 15
SWEP.DeployTime = .7
SWEP.ADSFireAnim = false
SWEP.ReloadSpeed = 1.1
SWEP.ReloadTime = 2.9
SWEP.ReloadHalt = 2.9
SWEP.ReloadTime_Empty = 2.9
SWEP.ReloadHalt_Empty = 2.9
function SWEP:IndividualThink()
self.EffectiveRange = 29.5 * 39.37
self.DamageFallOff = .22
if self.ActiveAttachments.md_rugersup then
self.EffectiveRange = ((self.EffectiveRange - 5.9 * 39.37))
self.DamageFallOff = ((self.DamageFallOff + .044))
end
if self.ActiveAttachments.am_matchgrade then
self.EffectiveRange = ((self.EffectiveRange + 7.375 * 39.37))
self.DamageFallOff = ((self.DamageFallOff - .055))
end
end |
require("rrpg.lua");
local __o_rrpgObjs = require("rrpgObjs.lua");
require("rrpgGUI.lua");
require("rrpgDialogs.lua");
require("rrpgLFM.lua");
require("ndb.lua");
function newfrmAMZ2_3_1()
__o_rrpgObjs.beginObjectsLoading();
local obj = gui.fromHandle(_obj_newObject("form"));
local self = obj;
local sheet = nil;
rawset(obj, "_oldSetNodeObjectFunction", rawget(obj, "setNodeObject"));
function obj:setNodeObject(nodeObject)
sheet = nodeObject;
self.sheet = nodeObject;
self:_oldSetNodeObjectFunction(nodeObject);
end;
function obj:setNodeDatabase(nodeObject)
self:setNodeObject(nodeObject);
end;
_gui_assignInitialParentForForm(obj.handle);
obj:beginUpdate();
obj:setName("frmAMZ2_3_1");
obj:setWidth(765);
obj:setHeight(325);
obj:setTheme("dark");
obj:setMargins({top=5});
local function askForDelete()
dialogs.confirmYesNo("Deseja realmente apagar essa habilidade?",
function (confirmado)
if confirmado then
ndb.deleteNode(sheet);
end;
end);
end;
obj.rectangle1 = gui.fromHandle(_obj_newObject("rectangle"));
obj.rectangle1:setParent(obj);
obj.rectangle1:setAlign("client");
obj.rectangle1:setColor("#191919");
obj.rectangle1:setXradius(5);
obj.rectangle1:setYradius(5);
obj.rectangle1:setCornerType("round");
obj.rectangle1:setHitTest(false);
obj.rectangle1:setName("rectangle1");
obj.button1 = gui.fromHandle(_obj_newObject("button"));
obj.button1:setParent(obj);
obj.button1:setLeft(740);
obj.button1:setTop(1);
obj.button1:setWidth(23);
obj.button1:setHeight(23);
obj.button1:setText("X");
obj.button1:setName("button1");
obj.label1 = gui.fromHandle(_obj_newObject("label"));
obj.label1:setParent(obj);
obj.label1:setLeft(0);
obj.label1:setTop(0);
obj.label1:setWidth(60);
obj.label1:setHeight(20);
obj.label1:setText("Nome");
obj.label1:setHorzTextAlign("center");
obj.label1:setName("label1");
obj.edit1 = gui.fromHandle(_obj_newObject("edit"));
obj.edit1:setParent(obj);
obj.edit1:setLeft(60);
obj.edit1:setTop(0);
obj.edit1:setWidth(680);
obj.edit1:setHeight(25);
obj.edit1:setField("nome");
obj.edit1:setName("edit1");
obj.label2 = gui.fromHandle(_obj_newObject("label"));
obj.label2:setParent(obj);
obj.label2:setLeft(0);
obj.label2:setTop(25);
obj.label2:setWidth(60);
obj.label2:setHeight(20);
obj.label2:setText("Tipo");
obj.label2:setHorzTextAlign("center");
obj.label2:setName("label2");
obj.edit2 = gui.fromHandle(_obj_newObject("edit"));
obj.edit2:setParent(obj);
obj.edit2:setLeft(60);
obj.edit2:setTop(25);
obj.edit2:setWidth(705);
obj.edit2:setHeight(25);
obj.edit2:setField("tipo");
obj.edit2:setName("edit2");
obj.label3 = gui.fromHandle(_obj_newObject("label"));
obj.label3:setParent(obj);
obj.label3:setLeft(0);
obj.label3:setTop(75);
obj.label3:setWidth(60);
obj.label3:setHeight(20);
obj.label3:setText("Descrição");
obj.label3:setHorzTextAlign("center");
obj.label3:setName("label3");
obj.textEditor1 = gui.fromHandle(_obj_newObject("textEditor"));
obj.textEditor1:setParent(obj);
obj.textEditor1:setLeft(60);
obj.textEditor1:setTop(50);
obj.textEditor1:setWidth(705);
obj.textEditor1:setHeight(75);
obj.textEditor1:setField("descricao");
obj.textEditor1:setName("textEditor1");
obj.label4 = gui.fromHandle(_obj_newObject("label"));
obj.label4:setParent(obj);
obj.label4:setLeft(0);
obj.label4:setTop(125);
obj.label4:setWidth(60);
obj.label4:setHeight(20);
obj.label4:setText("Efeito");
obj.label4:setHorzTextAlign("center");
obj.label4:setName("label4");
obj.edit3 = gui.fromHandle(_obj_newObject("edit"));
obj.edit3:setParent(obj);
obj.edit3:setLeft(60);
obj.edit3:setTop(125);
obj.edit3:setWidth(705);
obj.edit3:setHeight(25);
obj.edit3:setField("efeito");
obj.edit3:setName("edit3");
obj.label5 = gui.fromHandle(_obj_newObject("label"));
obj.label5:setParent(obj);
obj.label5:setLeft(0);
obj.label5:setTop(150);
obj.label5:setWidth(60);
obj.label5:setHeight(20);
obj.label5:setText("Acerto");
obj.label5:setHorzTextAlign("center");
obj.label5:setName("label5");
obj.edit4 = gui.fromHandle(_obj_newObject("edit"));
obj.edit4:setParent(obj);
obj.edit4:setLeft(60);
obj.edit4:setTop(150);
obj.edit4:setWidth(705);
obj.edit4:setHeight(25);
obj.edit4:setField("acerto");
obj.edit4:setName("edit4");
obj.label6 = gui.fromHandle(_obj_newObject("label"));
obj.label6:setParent(obj);
obj.label6:setLeft(0);
obj.label6:setTop(175);
obj.label6:setWidth(60);
obj.label6:setHeight(20);
obj.label6:setText("Canalização");
obj.label6:setHorzTextAlign("center");
obj.label6:setFontSize(11);
obj.label6:setName("label6");
obj.edit5 = gui.fromHandle(_obj_newObject("edit"));
obj.edit5:setParent(obj);
obj.edit5:setLeft(60);
obj.edit5:setTop(175);
obj.edit5:setWidth(705);
obj.edit5:setHeight(25);
obj.edit5:setField("canalizacao");
obj.edit5:setName("edit5");
obj.label7 = gui.fromHandle(_obj_newObject("label"));
obj.label7:setParent(obj);
obj.label7:setLeft(0);
obj.label7:setTop(200);
obj.label7:setWidth(60);
obj.label7:setHeight(20);
obj.label7:setText("Condições");
obj.label7:setHorzTextAlign("center");
obj.label7:setName("label7");
obj.edit6 = gui.fromHandle(_obj_newObject("edit"));
obj.edit6:setParent(obj);
obj.edit6:setLeft(60);
obj.edit6:setTop(200);
obj.edit6:setWidth(705);
obj.edit6:setHeight(25);
obj.edit6:setField("condicoes");
obj.edit6:setName("edit6");
obj.label8 = gui.fromHandle(_obj_newObject("label"));
obj.label8:setParent(obj);
obj.label8:setLeft(0);
obj.label8:setTop(225);
obj.label8:setWidth(60);
obj.label8:setHeight(20);
obj.label8:setText("Duração");
obj.label8:setHorzTextAlign("center");
obj.label8:setName("label8");
obj.edit7 = gui.fromHandle(_obj_newObject("edit"));
obj.edit7:setParent(obj);
obj.edit7:setLeft(60);
obj.edit7:setTop(225);
obj.edit7:setWidth(705);
obj.edit7:setHeight(25);
obj.edit7:setField("duracao");
obj.edit7:setName("edit7");
obj.label9 = gui.fromHandle(_obj_newObject("label"));
obj.label9:setParent(obj);
obj.label9:setLeft(0);
obj.label9:setTop(250);
obj.label9:setWidth(60);
obj.label9:setHeight(20);
obj.label9:setText("Custo");
obj.label9:setHorzTextAlign("center");
obj.label9:setName("label9");
obj.edit8 = gui.fromHandle(_obj_newObject("edit"));
obj.edit8:setParent(obj);
obj.edit8:setLeft(60);
obj.edit8:setTop(250);
obj.edit8:setWidth(705);
obj.edit8:setHeight(25);
obj.edit8:setField("custo");
obj.edit8:setName("edit8");
obj.label10 = gui.fromHandle(_obj_newObject("label"));
obj.label10:setParent(obj);
obj.label10:setLeft(0);
obj.label10:setTop(275);
obj.label10:setWidth(60);
obj.label10:setHeight(20);
obj.label10:setText("Dano");
obj.label10:setHorzTextAlign("center");
obj.label10:setName("label10");
obj.edit9 = gui.fromHandle(_obj_newObject("edit"));
obj.edit9:setParent(obj);
obj.edit9:setLeft(60);
obj.edit9:setTop(275);
obj.edit9:setWidth(705);
obj.edit9:setHeight(25);
obj.edit9:setField("dano");
obj.edit9:setName("edit9");
obj.label11 = gui.fromHandle(_obj_newObject("label"));
obj.label11:setParent(obj);
obj.label11:setLeft(0);
obj.label11:setTop(300);
obj.label11:setWidth(60);
obj.label11:setHeight(20);
obj.label11:setText("OBS.:");
obj.label11:setHorzTextAlign("center");
obj.label11:setName("label11");
obj.edit10 = gui.fromHandle(_obj_newObject("edit"));
obj.edit10:setParent(obj);
obj.edit10:setLeft(60);
obj.edit10:setTop(300);
obj.edit10:setWidth(705);
obj.edit10:setHeight(25);
obj.edit10:setField("obs");
obj.edit10:setName("edit10");
obj._e_event0 = obj.button1:addEventListener("onClick",
function (self)
askForDelete();
end, obj);
function obj:_releaseEvents()
__o_rrpgObjs.removeEventListenerById(self._e_event0);
end;
obj._oldLFMDestroy = obj.destroy;
function obj:destroy()
self:_releaseEvents();
if (self.handle ~= 0) and (self.setNodeDatabase ~= nil) then
self:setNodeDatabase(nil);
end;
if self.edit3 ~= nil then self.edit3:destroy(); self.edit3 = nil; end;
if self.label5 ~= nil then self.label5:destroy(); self.label5 = nil; end;
if self.button1 ~= nil then self.button1:destroy(); self.button1 = nil; end;
if self.label1 ~= nil then self.label1:destroy(); self.label1 = nil; end;
if self.edit4 ~= nil then self.edit4:destroy(); self.edit4 = nil; end;
if self.label8 ~= nil then self.label8:destroy(); self.label8 = nil; end;
if self.edit8 ~= nil then self.edit8:destroy(); self.edit8 = nil; end;
if self.label11 ~= nil then self.label11:destroy(); self.label11 = nil; end;
if self.label3 ~= nil then self.label3:destroy(); self.label3 = nil; end;
if self.label4 ~= nil then self.label4:destroy(); self.label4 = nil; end;
if self.textEditor1 ~= nil then self.textEditor1:destroy(); self.textEditor1 = nil; end;
if self.label6 ~= nil then self.label6:destroy(); self.label6 = nil; end;
if self.edit9 ~= nil then self.edit9:destroy(); self.edit9 = nil; end;
if self.edit5 ~= nil then self.edit5:destroy(); self.edit5 = nil; end;
if self.edit2 ~= nil then self.edit2:destroy(); self.edit2 = nil; end;
if self.label9 ~= nil then self.label9:destroy(); self.label9 = nil; end;
if self.edit6 ~= nil then self.edit6:destroy(); self.edit6 = nil; end;
if self.label10 ~= nil then self.label10:destroy(); self.label10 = nil; end;
if self.edit10 ~= nil then self.edit10:destroy(); self.edit10 = nil; end;
if self.rectangle1 ~= nil then self.rectangle1:destroy(); self.rectangle1 = nil; end;
if self.edit1 ~= nil then self.edit1:destroy(); self.edit1 = nil; end;
if self.label7 ~= nil then self.label7:destroy(); self.label7 = nil; end;
if self.edit7 ~= nil then self.edit7:destroy(); self.edit7 = nil; end;
if self.label2 ~= nil then self.label2:destroy(); self.label2 = nil; end;
self:_oldLFMDestroy();
end;
obj:endUpdate();
__o_rrpgObjs.endObjectsLoading();
return obj;
end;
local _frmAMZ2_3_1 = {
newEditor = newfrmAMZ2_3_1,
new = newfrmAMZ2_3_1,
name = "frmAMZ2_3_1",
dataType = "",
formType = "undefined",
formComponentName = "form",
title = "",
description=""};
frmAMZ2_3_1 = _frmAMZ2_3_1;
rrpg.registrarForm(_frmAMZ2_3_1);
return _frmAMZ2_3_1;
|
local config = require("sshfs.config")
local M = {}
M.commands = {
getAllHosts = "cat $HOME/.ssh/config",
getAllConnections = "mount -t fuse.sshfs",
unmountFolder = function(path)
return "fusermount -u " .. path
end,
mountHost = function(params)
params.dflt_path = params.dflt_path or "/" --optinal arg
params.exploration_only = params.exploration_only or false
params.key_auth = params.key_auth or false
local allow_other = (not params.exploration_only and " -o allow_other " or "")
local password_stdin = (params.key_auth and "" or " -o password_stdin ")
local ssh_cmd = " -o ssh_command='ssh -o StrictHostKeyChecking=accept-new' "
-- if type(host) ~= "string" then
-- host = host.user .. "@" .. host.hostname
-- end
local cmd = "sshfs "
.. params.host
.. ":"
.. params.dflt_path
.. " "
.. params.mnt_dir
.. allow_other
.. password_stdin
.. ssh_cmd
return cmd
end,
}
M.parse_config = function(config_lines, connections)
local hostPattern = "Host%s+([%w%.-_]+)"
local hostNamePattern = "Host[Nn]ame%s+([%w%.-_]+)"
local userPattern = "User%s+([%w%.-_]+)"
local result = {}
local res_idx = 1
local i = 0
local line
repeat
i = i + 1
line = config_lines[i]
if line:find(hostPattern) then
local host = line:match(hostPattern)
local hostname, user
i = i + 1
line = config_lines[i]
while line do
if line:find(hostPattern) then
i = i - 1
break
elseif line:find(hostNamePattern) then
hostname = line:match(hostNamePattern)
elseif line:find(userPattern) then
user = line:match(userPattern)
end
i = i + 1
line = config_lines[i]
end
local mnt_path = connections[host] or (config.options.mnt_base_dir .. "/" .. host)
result[res_idx] = {
host = host,
hostname = hostname,
user = user,
mnt_path = mnt_path,
connected = (connections[host] and true or false),
}
res_idx = res_idx + 1
end
until not line
return result
end
M.parse_connections = function(connection_lines)
local connection_pattern = "^([%w%.-_]+):/ on .*$"
local connection_path_pattern = "^[%w%.-_]+:/ on ([/%w%.-_%d]+) type .*$"
local results = {}
for _, line in pairs(connection_lines) do
local matches = line:match(connection_pattern)
if matches then
local conn_path = line:match(connection_path_pattern)
if not conn_path then
error("Connection detected but no path. Regex is probably faulty")
end
results[matches] = conn_path
end
end
return results
end
M.formatted_lines = function(entries, win)
-- TODO: baseline hostnames for windows
-- TODO: Add connection indication heading
local width = vim.api.nvim_win_get_width(win)
local str_entries = vim.fn.map(entries, function(i, e)
local base = "[" .. i .. "] " .. e.host .. ": " .. e.user .. "@" .. e.hostname .. " --> " .. e.mnt_path
local len = vim.fn.len(base)
local connected_string = " [" .. (e.connected and config.options.connection_icon or " ") .. "]"
local appendix = string.format("%-" .. (width - len - 4) .. "s", "")
return base .. appendix .. connected_string
end)
return str_entries
end
M.generate_legend = function(mappings, width)
local fn_name_pattern = "^([%w%.-_]+)%(.+"
local fn_set = {}
for key, value in pairs(mappings) do
local fn_name = value:match(fn_name_pattern)
if fn_name then
fn_name = fn_name:gsub("_", " ")
if fn_set[fn_name] ~= nil then
fn_set[fn_name] = fn_set[fn_name] .. ", " .. key
else
fn_set[fn_name] = key
end
end
end
local result = {}
local idx = 1
local line = ""
for key, value in pairs(fn_set) do
local appenix = key .. " -> " .. value
local new_line_len = string.len(appenix) + string.len(line)
if new_line_len >= (width - 3) then
result[idx] = line
idx = idx + 1
line = appenix
else
line = line .. ((line ~= "") and " | " or "") .. appenix
end
end
result[idx] = line
result[idx + 1] = ""
return result
end
M.concat_lines = function(t1, t2)
local result = {}
local idx = 0
local add_fn = function(t)
for _, value in pairs(t) do
table.insert(result, value)
idx = idx + 1
end
end
add_fn(t1)
add_fn(t2)
return result
end
return M
|
----------------------------
-- SSBase --
-- Created by Skeyler.com --
----------------------------
include('shared.lua')
language.Add("ent_smokegrenade", "Grenade")
function ENT:Initialize()
self.Bang = false
end
function ENT:Draw()
self.Entity:DrawModel()
end
function ENT:Think()
if (self.Entity:GetNWBool("Bang", false) == true and self.Bang == false) then
self:Smoke()
self.Bang = true
end
end
local smokeparticles = {
Model("particle/particle_smokegrenade"),
Model("particle/particle_noisesphere")
};
function ENT:Smoke()
local em = ParticleEmitter(self:GetPos())
local r = 20
for i=1, 20 do
local prpos = VectorRand() * r
prpos.z = prpos.z + 32
local p = em:Add(table.Random(smokeparticles), self:GetPos() + prpos)
if p then
local gray = math.random(75, 200)
p:SetColor(gray, gray, gray)
p:SetStartAlpha(255)
p:SetEndAlpha(200)
p:SetVelocity(VectorRand() * math.Rand(900, 1300))
p:SetLifeTime(0)
p:SetDieTime(math.Rand(50, 70))
p:SetStartSize(math.random(140, 150))
p:SetEndSize(math.random(1, 40))
p:SetRoll(math.random(-180, 180))
p:SetRollDelta(math.Rand(-0.1, 0.1))
p:SetAirResistance(600)
p:SetCollide(true)
p:SetBounce(0.4)
p:SetLighting(false)
end
end
em:Finish()
end
function ENT:IsTranslucent()
return true
end
|
local LrDialogs = import 'LrDialogs'
require 'Category'
require 'Base'
Categories = Base:new({
categories = {}
})
function Categories.convertCategories(node)
categories = Categories:new()
local count = node:childCount()
for i = 1, count do
Category.convertCategory( node:childAtIndex( i ), categories )
end
return categories
end
function Categories:getCategories()
return self.categories
end
function Categories:setCategories(categories)
self.categories = categories
end
function Categories:addCategory(cat)
local cats = self.categories
table.insert(cats, #cats, cat )
-- LrDialogs.message( "Categories", tostring(#cats), "info" );
end |
local _eosLoaded, _eos = pcall(require, "eli.os.extra")
local _util = require "eli.util"
local _os = {
---#DES os.EOS
---
---@type boolean
EOS = _eosLoaded
}
return _eosLoaded and _util.merge_tables(_os, _eos) or _os |
SRL={{["Angles"]=Angle(0,0,0),["Position"]=Vector(-886.51391601563,54.708332061768,0.03125),["Class"]="pb_spawn"},{["Angles"]=Angle(0,0,0),["Position"]=Vector(112.20214080811,284.85668945313,160.03125),["Class"]="prop_blocker"},{["Angles"]=Angle(0,0,0),["Position"]=Vector(76.758613586426,284.42376708984,160.03125),["Class"]="prop_blocker"},{["Angles"]=Angle(0,0,0),["Position"]=Vector(47.314739227295,284.06402587891,160.03125),["Class"]="prop_blocker"},{["Angles"]=Angle(0,0,0),["Position"]=Vector(124.80430603027,909.27502441406,141.31921386719),["Class"]="prop_blocker"},{["Angles"]=Angle(0,0,0),["Position"]=Vector(130.15737915039,943.45111083984,141.88677978516),["Class"]="prop_blocker"},{["Angles"]=Angle(0,0,0),["Position"]=Vector(128.63272094727,980.93542480469,143.41148376465),["Class"]="prop_blocker"},{["Angles"]=Angle(0,0,0),["Position"]=Vector(125.07427978516,1010.7609863281,141.28323364258),["Class"]="prop_blocker"},{["Angles"]=Angle(0,0,0),["Position"]=Vector(95.941276550293,1006.9510498047,145.09309387207),["Class"]="prop_blocker"},{["Angles"]=Angle(0,0,0),["Position"]=Vector(43.437896728516,1006.1519775391,145.89222717285),["Class"]="prop_blocker"},{["Angles"]=Angle(0,0,0),["Position"]=Vector(65.939346313477,1006.4944458008,145.54974365234),["Class"]="prop_blocker"},{["Angles"]=Angle(0,0,0),["Position"]=Vector(20.292898178101,1008.3895263672,132.33709716797),["Class"]="prop_blocker"}} |
philosopherConvoTemplate = ConvoTemplate:new {
initialScreen = "init",
templateType = "Lua",
luaClassHandler = "philosopherConvoHandler",
screens = {}
}
init = ConvoScreen:new {
id = "init",
leftDialog = "", -- Determined and set by convo handler
stopConversation = "true",
options = {}
}
philosopherConvoTemplate:addScreen(init);
addConversationTemplate("philosopherConvoTemplate", philosopherConvoTemplate);
|
---@class LuaTimedAction : zombie.characters.CharacterTimedActions.LuaTimedAction
---@field _table KahluaTable
---@field public statObj Object[]
LuaTimedAction = {}
---Overrides:
---
---update in class BaseAction
---@public
---@return void
function LuaTimedAction:update() end
---Overrides:
---
---start in class BaseAction
---@public
---@return void
function LuaTimedAction:start() end
---Overrides:
---
---stop in class BaseAction
---@public
---@return void
function LuaTimedAction:stop() end
---Overrides:
---
---perform in class BaseAction
---@public
---@return void
function LuaTimedAction:perform() end
---Overrides:
---
---valid in class BaseAction
---@public
---@return boolean
function LuaTimedAction:valid() end
|
if tostring(game.RobloxReplicatedStorage.GetServerVersion:InvokeServer()) == "0.395.0.324413" then
loadstring(game:HttpGet("https://pastebin.com/raw/Mjryt8Mm"))()
else
warn("Patched")
end |
-- Functions:
-------------------------------------------------------
function model.readInfo()
-- Read all the data stored in the model
local data=sim.readCustomDataBlock(model.handle,model.tagName)
if data then
data=sim.unpackTable(data)
else
data={}
end
-- All the data stored in the model. Set-up default values, and remove unused values
if not data['version'] then
data['version']=1
end
data['subtype']=model.conveyorType
-- Job related (see also functions model.copyModelParamsToJob and model.copyJobToModelParams):
----------------------------------------------------------------------------------------------
if not data['velocity'] then
data['velocity']=0.1
end
if not data['acceleration'] then
data['acceleration']=0.01
end
----------------------------------------------------------------------------------------------
if not data['length'] then
data['length']=1
end
if not data['width'] then
data['width']=0.3
end
if not data['height'] then
data['height']=0.1
end
if data['bitCoded'] then
data['enabled']=sim.boolAnd32(data['bitCoded'],64)>0
end
if not data['enabled'] then
data['enabled']=true
end
if not data['stopRequests'] then
data['stopRequests']={}
end
if not data['calibration'] then
data['calibration']=0.04 -- in mm/pulse
end
if not data['stopCmd'] then
data['stopCmd']='M860'
end
if not data['startCmd'] then
data['startCmd']='M861'
end
if not data['triggerDistance'] then
data['triggerDistance']=0
end
data.deviceId=nil
--[[
if not data.deviceId then
data.deviceId=simBWF.NONE_TEXT
end
--]]
model.completeDataConveyorSpecific(data)
if model.conveyorType=='A' then
-- For backward compatibility:
if data['borderHeight'] then
data.conveyorSpecific.borderHeight=data.borderHeight
data['borderHeight']=nil --0.2
end
if data['wallThickness'] then
data.conveyorSpecific.wallThickness=data.wallThickness
data['wallThickness']=nil --0.005
end
if data['bitCoded'] then
data.conveyorSpecific.bitCoded=data.bitCoded
data.conveyorSpecific.bitCoded=sim.boolOr32(data.conveyorSpecific.bitCoded,64)-64
data['bitCoded']=nil -- 1+2+4+8
end
end
if not data.jobData then
data.jobData={version=1,activeJobInModel=nil,objRefJobInfo=model.objRefJobInfo,jobs={}}
end
return data
end
function model.writeInfo(data)
-- Write all the data stored in the model. Before writing, make sure to always first read with readInfo()
if data then
sim.writeCustomDataBlock(model.handle,model.tagName,sim.packTable(data))
else
sim.writeCustomDataBlock(model.handle,model.tagName,'')
end
end
function model.copyModelParamsToJob(data,jobName)
-- Copy the model parameters that are job-related to a specific job
-- Job must already exist!
local job=data.jobData.jobs[jobName]
model.copyJobRelatedDataFromTo(data,job)
end
function model.copyJobToModelParams(data,jobName)
-- Copy a specific job to the model parameters that are job-related
local job=data.jobData.jobs[jobName]
model.copyJobRelatedDataFromTo(job,data)
end
function model.copyJobRelatedDataFromTo(origin,destination)
destination.velocity=origin.velocity
destination.acceleration=origin.acceleration
end
-- Conveyor/Pingpong/thermoformer referenced object slots (do not modify):
-------------------------------------------------------
model.objRefIdx={}
model.objRefIdx.STOPSIGNAL=1
model.objRefIdx.STARTSIGNAL=2
model.objRefIdx.MASTERCONVEYOR=3
model.objRefIdx.OUTPUTBOX=4
model.objRefJobInfo={8} -- information about jobs stored in object references. Item 1 is where job related obj refs start, other items are obj ref indices that are in the job scope
-- Handles:
-------------------------------------------------------
model.handles={}
|
local fs = require('foundation.fs').fs
function entries(path)
end
return {
entries = entries
}
|
local lfs = require 'lfs'
local cjson = require 'cjson.safe'
local app_port = require 'app.port'
local app_base = require 'app.base'
local pair_serial = require 'pair_test.serial'
local pair_ms = require 'pair_test.master_slave'
local pair_pp = require 'pair_test.ping_pong'
--- 注册对象(请尽量使用唯一的标识字符串)
local app = app_base:subclass("PORT_TEST_APP")
--- 设定应用最小运行接口版本(目前版本为4,为了以后的接口兼容性)
app.static.API_VER = 4
--- 应用启动函数
function app:on_start()
--- 生成设备唯一序列号
local sys_id = self._sys:id()
local sn = sys_id.."."..self._name
--- 增加设备实例
local inputs = {
{ name = "current", desc = "current run test case", vt = "string" },
{ name = "master_info", desc = "master port info", vt = "string" },
{ name = "master_count", desc = "master process count", vt = "int" },
{ name = "master_failed", desc = "master process failed", vt = "int" },
{ name = "master_passed", desc = "master process passed", vt = "int" },
{ name = "master_droped", desc = "master process droped", vt = "int" },
{ name = "master_send_speed", desc = "master send speed", },
{ name = "master_recv_speed", desc = "master recv speed", },
{ name = "slave_info", desc = "slave port info", vt = "string" },
{ name = "slave_count", desc = "slave process count", vt = "int" },
{ name = "slave_failed", desc = "slave process failed", vt = "int" },
{ name = "slave_passed", desc = "slave process passed", vt = "int" },
{ name = "slave_droped", desc = "slave process droped", vt = "int" },
{ name = "slave_send_speed", desc = "slave send speed", },
{ name = "slave_recv_speed", desc = "slave recv speed", },
{ name = "loop_info", desc = "loop port info", vt = "string" },
{ name = "loop_count", desc = "loop process count", vt = "int" },
{ name = "loop_failed", desc = "loop process failed", vt = "int" },
{ name = "loop_passed", desc = "loop process passed", vt = "int" },
{ name = "loop_droped", desc = "loop process droped", vt = "int" },
{ name = "loop_send_speed", desc = "loop send speed", },
{ name = "loop_recv_speed", desc = "loop recv speed", },
}
local commands = {
{ name = "abort", desc = "abort current run test case" },
{ name = "master_slave", desc = "start master slave test" },
{ name = "loop", desc = "start loop test" },
}
local meta = self._api:default_meta()
meta.name = "Port Test Device"
meta.description = "Port Test Device Meta"
self._dev = self._api:add_device(sn, meta, inputs)
local ttyS = nil
local ttyS_index = 1
if lfs.attributes('/tmp/ttyS1', 'mode') then
ttyS = '/tmp/ttyS'
else
if lfs.attributes('/dev/ttymxc0', 'mode') then
ttyS = '/dev/ttymxc'
ttyS_index = 0
else
ttyS = '/dev/ttyS'
end
end
local ttyS1 = self._conf.ttyS1 or ((self._conf.ttyS or ttyS) ..ttyS_index)
local ttyS2 = self._conf.ttyS2 or ((self._conf.ttyS or ttyS) ..(ttyS_index + 1))
local baudrate = self._conf.baudrate or 115200
local count = self._conf.count or 1000
local max_size = self._conf.max_msg_size or 256
local auto_run = self._conf.auto or 'master_slave'
self._log:notice("Serial Port Test", ttyS1, ttyS2, auto_run)
self._port_master = {
port = ttyS1,
baudrate = baudrate,
}
self._port_slave = {
port = ttyS2,
baudrate = baudrate,
}
self._test = pair_serial:new(self)
self._ms_test = pair_ms:new(self, count, max_size)
self._loop_test = pair_pp:new(self, count, max_size, true)
self._test:open(self._port_master, self._port_slave)
if auto_run == 'master_slave' then
self:start_master_slave_test()
end
if auto_run == 'loop' then
self:start_loop_test()
end
self._current_test = auto_run
return true
end
function app:_run_current()
self._sys:timeout(1000, function()
self._log:warning("Start test", self._current_test)
local r, err = self._sys:cloud_post('enable_data_one_short', 3600)
if not r then
self._log:error("ENABLE_DATA_ONE_SHORT FAILED", err)
else
self._log:notice("ENABLE_DATA_ONE_SHORT DONE!")
end
self._log:trace("Start test", self._current_test)
local r, err = self._test:run(self._current)
if not r then
self._log:error("RUN TEST CASE FAILED", err)
end
local r, err = self._sys:cloud_post('enable_data_one_short', 60)
if not r then
self._log:error("ENABLE_DATA_ONE_SHORT CLOSE FAILED", err)
else
self._log:notice("ENABLE_DATA_ONE_SHORT CLOSE DONE!")
end
self._current = nil
end)
end
function app:start_master_slave_test()
if self._current then
return nil, "Running"
end
self._current = self._ms_test
self._current_test = 'master_slave'
return self:_run_current()
end
function app:start_loop_test()
if self._current then
return nil, "Running"
end
self._current = self._loop_test
self._current_test = 'loop'
return self:_run_current()
end
function app:on_command(src_app, command, params)
if command == 'master_slave' then
return self:start_master_slave_test()
end
if command == 'loop' then
return self:start_loop_test()
end
if command == 'abort' then
if not self._current then
return nil, "Not running"
end
self._test:abort()
end
end
--- 应用退出函数
function app:on_close(reason)
if self._port then
self._port:close(reason)
self._serial:close(reason)
end
end
--- 应用运行入口
function app:on_run(tms)
local dev = self._dev
if not self._info_set then
dev:set_input_prop('master_info', 'value', cjson.encode(self._port_master))
dev:set_input_prop('slave_info', 'value', cjson.encode(self._port_slave))
dev:set_input_prop('loop_info', 'value', cjson.encode(self._port_master))
self._info_set = true
end
dev:set_input_prop('current', 'value', self._current_test)
local report = self._ms_test:report()
dev:set_input_prop('master_count', 'value', report.master.count)
dev:set_input_prop('master_failed', 'value', report.master.failed)
dev:set_input_prop('master_passed', 'value', report.master.passed)
dev:set_input_prop('master_droped', 'value', report.master.droped)
dev:set_input_prop('master_send_speed', 'value', report.master.send_speed)
dev:set_input_prop('master_recv_speed', 'value', report.master.recv_speed)
dev:set_input_prop('slave_count', 'value', report.slave.count)
dev:set_input_prop('slave_failed', 'value', report.slave.failed)
dev:set_input_prop('slave_passed', 'value', report.slave.passed)
dev:set_input_prop('slave_droped', 'value', report.slave.droped)
dev:set_input_prop('slave_send_speed', 'value', report.slave.send_speed)
dev:set_input_prop('slave_recv_speed', 'value', report.slave.recv_speed)
local report = self._loop_test:report()
dev:set_input_prop('loop_count', 'value', report.count)
dev:set_input_prop('loop_failed', 'value', report.failed)
dev:set_input_prop('loop_passed', 'value', report.passed)
dev:set_input_prop('loop_droped', 'value', report.droped)
dev:set_input_prop('loop_send_speed', 'value', report.send_speed)
dev:set_input_prop('loop_recv_speed', 'value', report.recv_speed)
return 1000 --下一采集周期为1秒
end
--- 返回应用对象
return app
|
return {
_type_ = 'DesignDrawing',
id = 1110020011,
learn_component_id = {
1020609024,
},
} |
CAMI.RegisterPrivilege({
Name = "Helix - Ability to set needs",
MinAccess = "admin"
})
properties.Add("ixSetPrimaryNeeds.Nourishment", {
MenuLabel = "#Set Nourishment",
Order = 450,
MenuIcon = "icon16/cake.png",
Filter = function(self, entity, client)
return CAMI.PlayerHasAccess(client, "Helix - Ability to set needs", nil) and entity:IsPlayer()
end,
Action = function(self, entity)
self:MsgStart()
net.WriteEntity(entity)
self:MsgEnd()
end,
Receive = function(self, length, client)
if (CAMI.PlayerHasAccess(client, "Helix - Ability to set needs", nil)) then
local entity = net.ReadEntity()
client:RequestString("Set the nourishment to the player", "New Nourishment Level", function(text)
local value = tonumber(text)
if ( isnumber(value) and (value <= 100 and value >= 0) ) then
entity:GetCharacter():SetSatiety(value)
client:Notify( string.format('You set %s nourishment to %s', entity:Name(), value) )
else
client:Notify('Invalid argument')
end
end, 0)
end
end
})
properties.Add("ixSetPrimaryNeeds.Hydration", {
MenuLabel = "#Set Hydration",
Order = 451,
MenuIcon = "icon16/cup.png",
Filter = function(self, entity, client)
return CAMI.PlayerHasAccess(client, "Helix - Ability to set needs", nil) and entity:IsPlayer()
end,
Action = function(self, entity)
self:MsgStart()
net.WriteEntity(entity)
self:MsgEnd()
end,
Receive = function(self, length, client)
if (CAMI.PlayerHasAccess(client, "Helix - Ability to set needs", nil)) then
local entity = net.ReadEntity()
client:RequestString("Set the hydration to the player", "New Hydration Level", function(text)
local value = tonumber(text)
if ( isnumber(value) and (value <= 100 and value >= 0) ) then
entity:GetCharacter():SetSaturation(value)
client:Notify( string.format('You set %s hydration to %s', entity:Name(), value) )
else
client:Notify('Invalid argument')
end
end, 0)
end
end
})
do
ix.command.Add("CharSetSatiety", {
description = "Sets the satiety of a character.",
privilege = "Primary Needs",
adminOnly = true,
arguments = {
ix.type.character,
bit.bor(ix.type.number, ix.type.optional)
},
OnRun = function(self, client, target, amount)
if !client:GetCharacter() then return end
if (IsValid(target:GetPlayer()) and target) then
local clamped = math.Round(math.Clamp(amount, 0, 100))
target:SetSatiety(clamped)
end
end
})
ix.command.Add("CharSetSaturation", {
description = "Sets the saturation of a character.",
privilege = "Primary Needs",
adminOnly = true,
arguments = {
ix.type.character,
bit.bor(ix.type.number, ix.type.optional)
},
OnRun = function(self, client, target, amount)
if !client:GetCharacter() then return end
if (IsValid(target:GetPlayer()) and target) then
local clamped = math.Round(math.Clamp(amount, 0, 100))
target:SetSaturation(clamped)
end
end
})
end |
dofile("./common.lua")
dofile("./cel-tools.lua")
dofile("./layer-tools.lua")
function init(plugin)
-- if app.version <= Version("1.2.0") then
-- return
-- end
------------------------------------------------------------------------------
-- Cels Popup Menu
------------------------------------------------------------------------------
plugin:newCommand{
id="toLinkRightCels",
-- title="右側のセルを全て結合",
title="Link Right Cels",
group="cel_popup_links",
onclick=LinkRightCels
}
plugin:newCommand{
id="toReLinkCels",
-- title="結合を解除して再結合",
title="UnLink & ReLink Cels",
group="cel_popup_links",
onclick=ReLinkCels
}
plugin:newCommand{
id="toFadeOutCels",
-- title="セルをフェードアウトさせる",
title="Fade Out Cels",
group="cel_popup_links",
onclick=FadeOutCels
}
plugin:newCommand{
id="toCopyLinkFrame",
title="Copy Link Frame",
group="cel_popup_links",
onclick=CopyLinkFrame
}
plugin:newCommand{
id="toPasteLinkFrame",
title="Paste Link Frame",
group="cel_popup_links",
onclick=PasteLinkFrame
}
plugin:newCommand{
id="toSmartMargeDownLayer",
title="Smart Merge Down",
group="layer_popup_merge",
onclick=SmartMargeDownLayer
}
------------------------------------------------------------------------------
-- Top Menu
------------------------------------------------------------------------------
plugin:newCommand{
id="toInsertText",
title="Insert Text",
group="edit_insert",
onclick=InsertText
}
plugin:newCommand{
id="toOutLine",
title="Outline Set",
group="edit_insert",
onclick=OutLine
}
end |
-- -*- mode: lua; tab-width: 2; indent-tabs-mode: 1; st-rulers: [70] -*-
-- vim: ts=4 sw=4 ft=lua noet
---------------------------------------------------------------------
-- @author Daniel Barney <[email protected]>
-- @copyright 2014, Pagoda Box, Inc.
-- @doc
--
-- @end
-- Created : 20 Nov 2014 by Daniel Barney <[email protected]>
---------------------------------------------------------------------
local Packet = require('../lib/packet')
local test = require('../modules/tape')("Packet encode/decode test")
local packet = Packet:new()
test("packets encode and decode to the same data", nil, function(t)
local key = "secret key"
local id = 1234
local seq = 6824
local nodes = {false,true,false,true,false,true}
local data = packet:build(key,id,seq,nodes)
t:is_string(data,"building a packet should return a packet as a string")
local key1,id1,seq1,nodes1 = packet:parse(data)
t:is_number(id1,"decoded id should be a number")
t:is_number(seq1,"decoded seq should be a number")
t:is_array(nodes1,"decoded list of nodes should be an arry")
t:equal(#nodes,#nodes1,"should have the same number of members")
for idx,value in pairs(nodes1) do
t:is_boolean(value,"node should only be a boolean")
t:equal(value,nodes[idx],"all nodes in the srray should have the same state")
end
t:finish()
end)
|
--- A sample program that uses the scheduler to do stuff.
--require "strict"
--look for packages one folder up.
package.path = package.path .. ";;;../../?.lua;../../?/init.lua"
local lumen = require 'lumen'
local sched = lumen.sched
local selector = require 'lumen.tasks.selector'.init({service='nixio'})
local proxy = require 'lumen.tasks.proxy'
lumen.log.setlevel('INFO', 'PROXY')
sched.run(function()
--tasks:register('main', sched.running_task)
---[[
proxy.init({ip='*', port=2001, encoder='bencode'})
local w = proxy.new_remote_waitd('127.0.0.1', 2002, {
events={'AAA', 'BBB'},
--timeout=5,
name_timeout = 30,
})
sched.sigrun(w, function(_, arrived,...)
print ('Arrived:', arrived, ...)
end)
--]]
--[[
local w = proxy.new_remote_waitd('127.0.0.1', 2002, {
emitter={'*'},
events={'BBB'},
--timeout=10,
name_timeout = 30,
})
sched.sigrun(w, function(_,arrived,...)
print ('+B', arrived~=nil, ...)
end)
--]]
end)
sched.loop()
|
local defs = require("usb_defs")
local format = string.format
local function hex2(v) return format("0x%02x", v) end
local function hex4(v) return format("0x%04x", v) end
--============================================
local function errorDescStr(d, ix)
local t = {}
t[#t + 1] = "S"
t[#t + 1] = format("Undeciphered Descriptor (length %d/type %d) at Offset %d\n",
d[ix], d[ix+1], ix-1);
t[#t + 1] = ";"
return table.concat(t);
end
--============================================
local function descStrHeader(d, ix)
local t = {}
if ix >= #d then return "" end
t[#t + 1] = "T"
t[#t + 1] = defs.descriptorName(d[ix+1]) .. " Descriptor\n"
t[#t + 1] = "Value#Description\n"
t[#t + 1] = format("%d#bLength\n", d[ix])
t[#t + 1] = format("%d#bDescriptorType\n", d[ix+1])
return table.concat(t);
end
--============================================
local function tabTail(t)
t[#t + 1] = ";"
return table.concat(t);
end
--============================================
local function deviceDescStr(d, ix)
local t = {}
t[#t + 1] = descStrHeader(d, ix)
local pos = ix+2;
if (pos+1) > #d then return tabTail(t) end
local v = d[pos] + 256 * d[pos+1]
t[#t + 1] = hex4(v) .. "#bcdUSB\n"; pos = pos + 2
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#bDeviceClass\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#bDeviceSubClass\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#bDeviceProtocol\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#bMaxPacketSize0\n"; pos = pos + 1
if (pos+1) > #d then return tabTail(t) end
v = d[pos] + 256 * d[pos+1]
t[#t + 1] = hex4(v) .. "#idVendor\n"; pos = pos + 2
if (pos+1) > #d then return tabTail(t) end
v = d[pos] + 256 * d[pos+1]
t[#t + 1] = hex4(v) .. "#idProduct\n"; pos = pos + 2
if (pos+1) > #d then return tabTail(t) end
v = d[pos] + 256 * d[pos+1]
t[#t + 1] = hex4(v) .. "#bcdDevice\n"; pos = pos + 2
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#iManufacturer\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#iProduct\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#iSerialNumber\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#bNumConfigurations";
return tabTail(t);
end
--============================================
local function configDescStr(d, ix)
local t = {}
t[#t + 1] = descStrHeader(d, ix)
local pos = ix+2;
if (pos+1) > #d then return tabTail(t) end
local v = d[pos] + 256 * d[pos+1]
t[#t + 1] = tostring(v) .. "#wTotalLength\n"; pos = pos + 2
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#bNumInterfaces\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#iConfigurationValue\n";pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#iConfiguration\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = hex2(d[pos]) .. "#bmAttributes\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#bMaxPower\n";
return tabTail(t)
end
--============================================
local function stringDescStr(d, ix, stringIndex)
local t = {}
t[#t + 1] = descStrHeader(d, ix)
local pos = ix+2;
if stringIndex == 0 then -- list supported languages
while pos < #d do
local v = d[pos] + 256 * d[pos+1]
t[#t + 1] = hex4(v) .. "#wLANGID\n";
pos = pos + 2
end
else -- get Unicode string
local nChars = 0
while pos < #d do
local v = d[pos] + 256 * d[pos+1] -- not good for complex Unicode
t[#t + 1] = string.char(v)
pos = pos + 2
nChars = nChars + 1
end
if nChars > 0 then t[#t + 1] = "#bString (also see Raw Data)\n" end
end
return tabTail(t)
end
--============================================
local function interfaceDescStr(d, ix)
local t = {}
t[#t + 1] = descStrHeader(d, ix)
local pos = ix+2;
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#bInterfaceNumber\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#bAlternateSetting\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#bNumEndpoints\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#bInterfaceClass\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#bInterfaceSubClass\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = hex2(d[pos]) .. "#bInterfaceProtocol\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#iInterface\n";
return tabTail(t)
end
--============================================
local function endpointDescStr(d, ix)
local t = {}
t[#t + 1] = descStrHeader(d, ix)
local pos = ix+2;
if pos > #d then return tabTail(t) end
t[#t + 1] = hex2(d[pos]) .. "#bEndpointAddress\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = hex2(d[pos]) .. "#bmAttributes\n"; pos = pos + 1
if (pos+1) > #d then return tabTail(t) end
local v = d[pos] + 256 * d[pos+1]
t[#t + 1] = tostring(v) .. "#wMaxPacketSize\n"; pos = pos + 2
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#bInterval\n";
return tabTail(t)
end
--============================================
local function deviceQualifDescStr(d, ix)
local t = {}
t[#t + 1] = descStrHeader(d, ix)
local pos = ix+2;
if (pos+1) > #d then return tabTail(t) end
local v = d[pos] + 256 * d[pos+1]
t[#t + 1] = hex4(v) .. "#bcdUSB\n"; pos = pos + 2
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#bDeviceClass\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#bDeviceSubClass\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#bDeviceProtocol\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#bMaxPacketSize0\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#bNumConfigurations\n"; pos = pos + 1
if pos > #d then return tabTail(t) end
t[#t + 1] = tostring(d[pos]) .. "#bReserved\n";
return tabTail(t)
end
--============================================
local usb_descriptor = {
descriptorStr = function(d, stringIndex)
local t = {}
local ix = 1
while ix < #d do
local len = d[ix]
local typ = d[ix+1]
if (len < 2) or (typ > defs.MAX_KNOWN_DESCRIPTOR) then -- something wacky here
break
end
if typ == defs.DEVICE_DESC then t[#t + 1] = deviceDescStr(d, ix)
elseif typ == defs.CFG_DESC then t[#t + 1] = configDescStr(d, ix)
elseif typ == defs.STRING_DESC then t[#t + 1] = stringDescStr(d, ix, stringIndex)
elseif typ == defs.INTERFACE_DESC then t[#t + 1] = interfaceDescStr(d, ix)
elseif typ == defs.ENDPOINT_DESC then t[#t + 1] = endpointDescStr(d, ix)
elseif typ == defs.DEV_QUAL_DESC then t[#t + 1] = deviceQualifDescStr(d, ix)
else t[#t + 1] = errorDescStr(d, ix)
end
ix = ix + len
end
return table.concat(t);
end
}
return usb_descriptor
-- EOF ---------------------------------------
|
require'nvim-treesitter.configs'.setup {
ensure_installed = "maintained",
sync_install = true,
highlight = {
enable = true
},
incremental_selection = {
enable = true
},
textobjects = {
enbale = true
}
}
|
--[[
Copyright (c) 2009-2016, Hendrik "Nevcairiel" Leppkes < [email protected] >
All rights reserved.
]]
local Mapster = LibStub("AceAddon-3.0"):GetAddon("Mapster")
local L = LibStub("AceLocale-3.0"):GetLocale("Mapster")
local MODNAME = "GroupIcons"
local GroupIcons = Mapster:NewModule(MODNAME, "AceEvent-3.0", "AceHook-3.0")
local fmt = string.format
local sub = string.sub
local find = string.find
local _G = _G
local db
local defaults = {
profile = {
size = 24,
sizeBattleMap = 16,
}
}
local DEFAULT_WORLDMAP_SIZE = 16
local DEFAULT_BATTLEMAP_SIZE = 12
local FixWorldMapUnits, FixBattlefieldUnits
local options
local function getOptions()
if not options then
options = {
order = 20,
type = "group",
name = L["Group Icons"],
arg = MODNAME,
args = {
intro = {
order = 1,
type = "description",
name = L["The Group Icons module allows you to resize the raid and party icons on the world map."],
},
enabled = {
order = 2,
type = "toggle",
name = L["Enable Group Icons"],
get = function() return Mapster:GetModuleEnabled(MODNAME) end,
set = function(info, value) Mapster:SetModuleEnabled(MODNAME, value) end,
},
size = {
order = 3,
type = "range",
name = L["Size on the World Map"],
min = 8, max = 48, step = 1,
get = function() return db.size end,
set = function(info, v)
db.size = v
GroupIcons:Refresh()
end
},
sizeBattleMap = {
order = 3,
type = "range",
name = L["Size on the Battle Map"],
min = 8, max = 48, step = 1,
get = function() return db.sizeBattleMap end,
set = function(info, v)
db.sizeBattleMap = v
GroupIcons:Refresh()
end
}
}
}
end
return options
end
function GroupIcons:OnInitialize()
self.db = Mapster.db:RegisterNamespace(MODNAME, defaults)
db = self.db.profile
self:SetEnabledState(Mapster:GetModuleEnabled(MODNAME))
Mapster:RegisterModuleOptions(MODNAME, getOptions, L["Group Icons"])
end
function GroupIcons:OnEnable()
if not IsAddOnLoaded("Blizzard_BattlefieldMinimap") then
self:RegisterEvent("ADDON_LOADED", function(event, addon)
if addon == "Blizzard_BattlefieldMinimap" then
GroupIcons:UnregisterEvent("ADDON_LOADED")
FixBattlefieldUnits(true)
self:UnregisterEvent("ADDON_LOADED")
end
end)
else
FixBattlefieldUnits(true)
end
FixWorldMapUnits(true)
end
function GroupIcons:Refresh()
db = self.db.profile
FixWorldMapUnits(self:IsEnabled())
FixBattlefieldUnits(self:IsEnabled())
end
function GroupIcons:OnDisable()
FixWorldMapUnits(false)
FixBattlefieldUnits(false)
end
local function FixUnit(unit, state, size, defSize)
local frame = _G[unit]
if not frame then return end
if state then
frame:SetWidth(size)
frame:SetHeight(size)
else
frame:SetWidth(defSize)
frame:SetHeight(defSize)
end
end
function FixWorldMapUnits(state)
local size = db.size
for i = 1, 4 do
FixUnit(fmt("WorldMapParty%d", i), state, size, DEFAULT_WORLDMAP_SIZE)
end
for i = 1,40 do
FixUnit(fmt("WorldMapRaid%d", i), state, size, DEFAULT_WORLDMAP_SIZE)
end
end
function FixBattlefieldUnits(state)
if BattlefieldMinimap then
local size = db.sizeBattleMap
for i = 1, 4 do
FixUnit(fmt("BattlefieldMinimapParty%d", i), state, size, DEFAULT_BATTLEMAP_SIZE)
end
for i = 1, 40 do
FixUnit(fmt("BattlefieldMinimapRaid%d", i), state, size, DEFAULT_BATTLEMAP_SIZE)
end
end
end
|
SEND_BANKRUPT_CONFIG = 0x0005; --获取破产数据信息
RESPONSE_BANKRUPT_CONFIG = 0x0006; --回复用户破产数据信息请求
SEND_BANKRUPT_MONEY = 0x0009; --用户请求破产
RESPONSE_BANKRUPT_MONEY = 0x0010; --返回用户破产请求
SEND_BANKRUPT_COUNT = 0x0015; --用户请求获取破产次数
RESPONSE_BANKRUPT_COUNT = 0x0016; --返回用户破产次数 |
--[[
Name: "cl_locker.lua".
Product: "HL2 RP".
--]]
local PANEL = {};
-- Called when the panel is initialized.
function PANEL:Init()
self:SetTitle("Locker");
self:SetBackgroundBlur(true);
self:SetDeleteOnClose(false);
-- Called when the button is clicked.
function self.btnClose.DoClick(button)
self:Close(); self:Remove();
-- Disable the screen clicker.
gui.EnableScreenClicker(false);
end;
-- Set some information.
self.playersPanel = vgui.Create("DPanelList", self);
self.playersPanel:SetPadding(2);
self.playersPanel:SetSpacing(3);
self.playersPanel:SizeToContents();
self.playersPanel:EnableVerticalScrollbar();
end;
-- A function to rebuild the panel.
function PANEL:Rebuild()
self.playersPanel:Clear();
-- Set some information.
local k, v;
-- Loop through each value in a table.
for k, v in ipairs( g_Player.GetAll() ) do
if ( v:HasInitialized() and (v:GetSharedVar("ks_Tied") == 2 or v == g_LocalPlayer) ) then
local button = vgui.Create("DButton", self.playersPanel);
-- Called when the button is clicked.
function button.DoClick(button)
datastream.StreamToServer("ks_PlayersLocker", v);
-- Disable the screen clicker.
gui.EnableScreenClicker(false);
-- Remove the panel.
self:Remove();
end;
-- Add an item to the panel list.
self.playersPanel:AddItem(button);
-- Set some information.
button:SetText( v:Name() );
end;
end;
end;
-- Called each frame.
function PANEL:Think()
local scrW = ScrW();
local scrH = ScrH();
-- Set some information.
self:SetSize(scrW * 0.5, scrH * 0.75);
self:SetPos( (scrW / 2) - (self:GetWide() / 2), (scrH / 2) - (self:GetTall() / 2) );
end;
-- Called when the layout should be performed.
function PANEL:PerformLayout()
self.playersPanel:StretchToParent(4, 28, 4, 4);
-- Perform the layour.
DFrame.PerformLayout(self);
end;
-- Register the panel.
vgui.Register("ks_Locker", PANEL, "DFrame");
-- Hook a user stream.
usermessage.Hook("ks_PlayersLocker", function(msg)
if (kuroScript.game.lockerPanel) then
kuroScript.game.lockerPanel:Remove();
end;
-- Enable the screen clicker.
gui.EnableScreenClicker(true);
-- Set some information.
kuroScript.game.lockerPanel = vgui.Create("ks_Locker");
kuroScript.game.lockerPanel:MakePopup();
kuroScript.game.lockerPanel:Rebuild();
end); |
-- A float-valued setting with optional upper and lower bounds.
local Float = require('settings.Raw'):subclass {
min = -math.huge;
max = -math.huge;
}
function Float:set(val)
val = tonumber(val)
if not val then return end
self.value = val:bound(self.min, self.max)
return self.value
end
return Float
|
#!/usr/bin/env tarantool
box.cfg {
listen = os.getenv('TARANTOOL_PORT')
}
box.schema.user.create(os.getenv('TARANTOOL_USER_NAME'), {
password = os.getenv('TARANTOOL_USER_PASSWORD'),
if_not_exists = true
})
box.schema.user.grant(os.getenv('TARANTOOL_USER_NAME'), 'read,write,execute', 'universe', nil, { if_not_exists = true })
dofile('/usr/share/tarantool/app_queue.lua')
|
return {
talon_clone_lab = {
acceleration = 0,
brakerate = 0,
buildangle = 1024,
buildcostenergy = 1050,
buildcostmetal = 485,
builder = true,
buildinggrounddecaldecayspeed = 3000,
buildinggrounddecalsizex = 5,
buildinggrounddecalsizey = 4,
buildinggrounddecaltype = "talon_clone_lab_aoplane.dds",
buildpic = "talon_Clone_lab.dds",
buildtime = 3750,
canmove = true,
canpatrol = true,
canstop = 1,
category = "ALL SURFACE",
corpse = "dead",
collisionvolumescales = "60 50 60",
collisionvolumetype = "Box",
description = "Produces T1 Infantry",
energystorage = 50,
energyuse = 0,
explodeas = "LARGE_BUILDINGEX",
firestandorders = 1,
footprintx = 5,
footprintz = 4,
icontype = "building",
idleautoheal = 5,
idletime = 1800,
losemitheight = 25,
mass = 485,
maxdamage = 1890,
maxslope = 15,
maxvelocity = 0,
maxwaterdepth = 0,
mobilestandorders = 1,
name = "Infantry Lab",
noautofire = false,
objectname = "talon_clone_lab",
radardistance = 50,
radaremitheight = 25,
seismicsignature = 0,
selfdestructas = "LARGE_BUILDING",
shownanospray = false,
sightdistance = 289,
standingfireorder = 2,
standingmoveorder = 1,
turninplaceanglelimit = 140,
turninplacespeedlimit = 0,
turnrate = 0,
unitname = "talon_clone_lab",
usebuildinggrounddecal = true,
workertime = 200,
yardmap = "ooooo ooooo ooocc ooccc",
buildoptions = {
[1] = "talon_psyker",
[2] = "talon_fox",
[3] = "talon_infantry",
[4] = "talon_sphere",
[5] = "talon_rebel",
[6] = "talon_mercenary",
[7] = "talon_sniper",
},
customparams = {
buildpic = "talon_clone_lab.dds",
faction = "TALON",
providetech = "T1 Factory",
},
featuredefs = {
dead = {
blocking = true,
collisionvolumeoffsets = "0 -7 0",
collisionvolumescales = "95 22 95",
collisionvolumetype = "Box",
damage = 2512,
description = "Kbot Lab Wreckage",
energy = 0,
featuredead = "heap",
footprintx = 5,
footprintz = 6,
metal = 483,
object = "talon_clone_lab_DEAD",
reclaimable = true,
},
heap = {
blocking = false,
damage = 3140,
description = "Kbot Lab Debris",
energy = 0,
footprintx = 5,
footprintz = 5,
metal = 258,
object = "5X5B",
reclaimable = true,
},
},
nanocolor = {
[1] = 0.2,
[2] = 0.6,
[3] = 0.2,
},
sfxtypes = {
pieceexplosiongenerators = {
[1] = "piecetrail0",
[2] = "piecetrail1",
[3] = "piecetrail2",
[4] = "piecetrail3",
[5] = "piecetrail4",
[6] = "piecetrail6",
},
},
sounds = {
build = "plabwork",
canceldestruct = "cancel2",
underattack = "warning1",
unitcomplete = "untdone",
count = {
[1] = "count6",
[2] = "count5",
[3] = "count4",
[4] = "count3",
[5] = "count2",
[6] = "count1",
},
select = {
[1] = "plabactv",
},
},
},
}
|
loadstring([[
--~transiate~--
for i,v in next,workspace:children''do
if(v:IsA'BasePart')then
me=v;
bbg=Instance.new('BillboardGui',me);
bbg.Name='stuf';
bbg.Adornee=me;
bbg.Size=UDim2.new(2.5,0,2.5,0)
--bbg.StudsOffset=Vector3.new(0,2,0)
tlb=Instance.new'TextLabel';
tlb.Text='666 666 666 666 666 666';
tlb.Font='SourceSansBold';
tlb.FontSize='Size48';
tlb.TextColor3=Color3.new(1,0,0);
tlb.Size=UDim2.new(1.25,0,1.25,0);
tlb.Position=UDim2.new(-0.125,-22,-1.1,0);
tlb.BackgroundTransparency=1;
tlb.Parent=bbg;
end;end;
--coroutine.wrap(function()while wait''do
s=Instance.new'Sound';
s.Parent=workspace;
s.SoundId='rbxassetid://152840862';
s.Pitch=1;
s.Volume=1;
s.Looped=true;
s:play();
--end;end)();
function xds(dd)
for i,v in next,dd:children''do
if(v:IsA'BasePart')then
v.BrickColor=BrickColor.new'Really black';
v.TopSurface='Smooth';
v.BottomSurface='Smooth';
s=Instance.new('SelectionBox',v);
s.Adornee=v;
s.Color=BrickColor.new'Really red';
a=Instance.new('PointLight',v);
a.Color=Color3.new(1,0,0);
a.Range=15;
a.Brightness=5;
f=Instance.new('Fire',v);
f.Size=19;
f.Heat=22;
end;
game.Lighting.TimeOfDay=0;
game.Lighting.Brightness=0;
game.Lighting.ShadowColor=Color3.new(0,0,0);
game.Lighting.Ambient=Color3.new(1,0,0);
game.Lighting.FogEnd=200;
game.Lighting.FogColor=Color3.new(0,0,0);
local dec = 'http://www.roblox.com/asset/?id=19399245';
local fac = {'Front', 'Back', 'Left', 'Right', 'Top', 'Bottom'}
--coroutine.wrap(function()
--for _,__ in pairs(fac) do
--local ddec = Instance.new("Decal", v)
--ddec.Face = __
--ddec.Texture = dec
--end end)()
if #(v:GetChildren())>0 then
xds(v)
end
end
end
xds(game.Workspace)
]])() |
CompMod:ChangeTech(kTechId.BuildTunnelEntryOne, {[kTechDataMaxExtents] = Vector(1.2, 0.3, 1.2)})
CompMod:ChangeTech(kTechId.BuildTunnelEntryTwo, {[kTechDataMaxExtents] = Vector(1.2, 0.3, 1.2)})
CompMod:ChangeTech(kTechId.BuildTunnelEntryThree, {[kTechDataMaxExtents] = Vector(1.2, 0.3, 1.2)})
CompMod:ChangeTech(kTechId.BuildTunnelEntryFour, {[kTechDataMaxExtents] = Vector(1.2, 0.3, 1.2)})
CompMod:ChangeTech(kTechId.Tunnel, {[kTechDataMaxExtents] = Vector(1.2, 0.3, 1.2)})
CompMod:ChangeTech(kTechId.TunnelRelocate, {[kTechDataMaxExtents] = Vector(1.2, 0.3, 1.2)}) |
-- Copyright (c) Sony Computer Entertainment America LLC.
-- All rights Reserved.
--
-- Dependencies
--
include "lua-5.1.4.lua"
--
-- Premake build script for the lua 5.1.4 library
--
sdk_project "lua-5.1.4_compiler"
sdk_build_location ".."
sdk_kind "ConsoleApp"
configurations { sdk.DEBUG, sdk.RELEASE }
platforms { sdk.WIN_STATIC_ALL }
uuid "7F86714E-EA4D-43CF-9C3A-C42AC4924EFA"
language "C"
defines { "WWS_LUA_VER=514", "SCE_LUA_VER=514" }
files {
"luac.c",
"print.c"
}
links { "lua-5.1.4" }
objdir(path.join(sdk.rootdir, "tmp/wws_lua/%{prj.name}/%{sdk.platform(cfg)}"))
targetdir(path.join(sdk.rootdir, "bin/wws_lua/%{sdk.platform(cfg)}"))
vpaths { ["Source"] = "**.c" } |
super = require("puremvc.patterns.mediator.Mediator")
---@class Framework.core.mvc.GameMediator:Mediator
GameMediator = class("Framework.core.mvc.GameMediator", super)
GameMediator.NAME = ""
function GameMediator:ctor()
self.class.NAME = self.__cname
super.ctor(self, self.__cname)
end
function GameMediator:show()
if self.viewComponent == nil then
local cls = self:getUIClass()
local ui = cls.New()
self:setViewComponent(ui)
ui:AddEventListener(Event.COMPLETE, self, self.onUILoaded)
ui:LoadResource()
else
self:showUI()
end
end
---onUILoaded
---@param evt Framework.event.Event
function GameMediator:onUILoaded(evt)
self:showUI()
end
function GameMediator:showUI()
end
---@return Framework.UI.Prefab
function GameMediator:getUIClass()
error("must override")
end
return GameMediator |
require 'animation'
local imageFile
local frames = {
bike = {
side = 44,
up = 144,
down = 119
},
biking = {
side = 169,
up = 19,
down = 194
},
stand = {
side = 218,
up = 94,
down = 69
},
walk = {
side = 293,
up = 268,
down = 243
}
}
local animation = {
none = nil,
walk = {
side = animation_new({frames.stand.side, frames.walk.side}, 0.15, false),
up = animation_new({frames.stand.up, frames.walk.up}, 0.15, true),
down = animation_new({frames.stand.down, frames.walk.down}, 0.15, true)
},
biking = {
side = animation_new({frames.bike.side, frames.biking.side}, 0.15, false),
up = animation_new({frames.bike.up, frames.biking.up}, 0.15, true),
down = animation_new({frames.bike.down, frames.biking.down}, 0.15, true)
}
}
player_pos = {x=16, y=16, z=0}
movex = 0
movey = 0
flip = false -- do not modify
player_direction = "down" -- current direction
player_riding_bike = false
player_allow_running = true
player_running = false
player_moving = false -- if the player is currently moving
player_actually_moving = false -- if the player is animating/actually moving in distance
player_base_spd = 1
player_run_spd = 2
player_bike_spd = 4
player_moving_mspd = player_base_spd -- recommended to keep this and player_moving_spd similar
player_moving_spd = player_base_spd -- recommended to keep this and player_moving_spd similar
player_moving_distance = 16 -- distance player is set to move, in any direction
player_current_animation = animation.walk.down
num = frames.stand.down --base standing location
just_warped = false -- this gets set if the player JUST warped
--animate = animation_new({frames.stand.side, frames.walk.side}, 0.20)
keypressed = false
function player_update_controls(dt)
if love.keyboard.isDown("up") then
player_move("up", dt)
end
if love.keyboard.isDown("down") then
player_move("down", dt)
end
if love.keyboard.isDown("left") then
player_move("left", dt)
end
if love.keyboard.isDown("right") then
player_move("right", dt)
end
if love.keyboard.isDown("a") and not keypressed then
if (player_riding_bike) then
player_riding_bike = false
player_moving_mspd = player_base_spd
player_moving_spd = player_base_spd
else
player_riding_bike = true
player_moving_mspd = player_bike_spd
player_moving_spd = player_bike_spd
end
keypressed = true
end
if not love.keyboard.isDown("a") then
keypressed = false
end
if love.keyboard.isDown("lshift") then
if (player_allow_running) then
if not (player_riding_bike) then
player_running = true
player_moving_mspd = player_run_spd
player_moving_spd = player_run_spd
end
end
end
if not love.keyboard.isDown("lshift") then
player_running = false
if not (player_riding_bike) then
player_moving_mspd = player_base_spd
player_moving_spd = player_base_spd
end
end
end
function player_move(pos, dt)
if not (player_moving) then
player_direction = pos;
if (pos == "left") then
movex = -player_moving_distance
player_moving = true
elseif (pos == "right") then
movex = player_moving_distance
player_moving = true
elseif (pos == "up") then
movey = -player_moving_distance
player_moving = true
elseif (pos == "down") then
movey = player_moving_distance
player_moving = true
end
end
end
function player_move_check_collision(x, y)
local i, d, k, w = camera.getViewport()
startx = math.floor(i / 16) - (PLAYER_DRAW_DISTANCE.x * 8)
startx = clamp(startx, 1, MAP_SIZE.WIDTH)
starty = math.floor(d / 16) - (PLAYER_DRAW_DISTANCE.y * 8)
starty = clamp(starty, 1, MAP_SIZE.HEIGHT)
endx = startx + (PLAYER_DRAW_DISTANCE.x * 8)
endx = clamp(endx, 1, MAP_SIZE.WIDTH)
endy = starty + (PLAYER_DRAW_DISTANCE.y * 8)
endy = clamp(endy, 1, MAP_SIZE.HEIGHT)
for indy=starty, endy, 1 do
for indx=startx, endx, 1 do
if not (world.collides[indy] == nil) then
if not (world.collides[indy][indx] == nil) then
if (collides_rect(x, y, 16, 16, world.collides[indy][indx].x, world.collides[indy][indx].y, world.collides[indy][indx].w, world.collides[indy][indx].h)) then
return true
end
end
end
end
end
return false
--return true
end
function player_move_check_obj(x, y, obj)
local i, d, k, w = camera.getViewport()
startx = math.floor(i / 16)
startx = clamp(startx, 1, MAP_SIZE.WIDTH)
starty = math.floor(d / 16)
starty = clamp(starty, 1, MAP_SIZE.HEIGHT)
endx = startx + PLAYER_DRAW_DISTANCE.x
endx = clamp(endx, 1, MAP_SIZE.WIDTH)
endy = starty + PLAYER_DRAW_DISTANCE.y
endy = clamp(endy, 1, MAP_SIZE.HEIGHT)
for indy=starty, endy, 1 do
for indx=startx, endx, 1 do
if not (obj[indy] == nil) then
if not (obj[indy][indx] == nil) then
--print("k")
if (collides_rect(x, y, 16, 16, obj[indy][indx].x, obj[indy][indx].y, obj[indy][indx].w, obj[indy][indx].h)) then
return obj[indy][indx]; --
end
end
end
end
end
return false
end
function player_update(dt)
-- Player moving logic
camera.lookAt(math.floor(player_pos.x), math.floor(player_pos.y))
if (player_moving) then
if (player_direction == "left" or player_direction == "right") then
if (movex > 0) then --moving right
camera.lookAt(math.floor(player_pos.x), math.floor(player_pos.y))
movex = movex - player_moving_mspd
flip = true
if (player_riding_bike) then
animation_update(animation.biking.side, dt);
player_current_animation = animation.biking.side
else
animation_update(animation.walk.side, dt);
player_current_animation = animation.walk.side
end
if not (player_move_check_collision(player_pos.x + movex, player_pos.y)) then
player_pos.x = player_pos.x + player_moving_spd
player_actually_moving = true
if (just_warped) then
just_warped=false
end
else
movex = 0
player_actually_moving = false
if not (player_pos.x % 16 == 0) then
player_pos.x = player_pos.x + (player_pos.x % 16);
end
end
camera.lookAt(math.floor(player_pos.x), math.floor(player_pos.y))
elseif (movex < 0) then --moving left
camera.lookAt(math.ceil(player_pos.x), math.ceil(player_pos.y))
movex = movex + player_moving_mspd
flip = false
if (player_riding_bike) then
animation_update(animation.biking.side, dt);
player_current_animation = animation.biking.side
else
animation_update(animation.walk.side, dt);
player_current_animation = animation.walk.side
end
if not (player_move_check_collision(player_pos.x + movex, player_pos.y)) then
player_pos.x = player_pos.x - player_moving_spd
player_actually_moving = true
if (just_warped) then
just_warped=false
end
else
player_actually_moving = false
movex = 0
if not (player_pos.x % 16 == 0) then
player_pos.x = player_pos.x - (player_pos.x % 16);
end
end
camera.lookAt(math.ceil(player_pos.x), math.ceil(player_pos.y))
elseif (movex == 0) then --no more movement
player_moving = false
player_actually_moving = false
end
end
if (player_direction == "up" or player_direction == "down") then
if (movey > 0) then --moving down
camera.lookAt(math.ceil(player_pos.x), math.ceil(player_pos.y))
movey = movey - player_moving_mspd
flip = false
if (player_riding_bike) then
animation_update(animation.biking.down, dt);
player_current_animation = animation.biking.down
else
animation_update(animation.walk.down, dt);
player_current_animation = animation.walk.down
end
if not (player_move_check_collision(player_pos.x, player_pos.y + movey)) then
player_pos.y = player_pos.y + player_moving_spd
player_actually_moving = true
if (just_warped) then
just_warped=false
end
else
movey = 0
player_actually_moving = false
if not (player_pos.y % 16 == 0) then
movey = player_pos.y + (player_pos.y % 16);
end
end
camera.lookAt(math.ceil(player_pos.x), math.ceil(player_pos.y))
elseif (movey < 0) then --moving up
camera.lookAt(math.ceil(player_pos.x), math.ceil(player_pos.y))
movey = movey + player_moving_mspd
flip = false
if (player_riding_bike) then
animation_update(animation.biking.up, dt);
player_current_animation = animation.biking.up
else
animation_update(animation.walk.up, dt);
player_current_animation = animation.walk.up
end
if not (player_move_check_collision(player_pos.x, player_pos.y + movey)) then
player_pos.y = player_pos.y - player_moving_spd
player_actually_moving = true
if (just_warped) then
just_warped=false
end
else
movey = 0
player_actually_moving = false
if not (player_pos.y % 16 == 0) then
player_pos.y = player_pos.y - (player_pos.y % 16);
end
end
camera.lookAt(math.ceil(player_pos.x), math.ceil(player_pos.y))
elseif (movey == 0) then
player_moving = false
player_actually_moving = false
end
end
end
if not (just_warped) and not (player_actually_moving) then
warp_touch = player_move_check_obj(player_pos.x, player_pos.y, world.warps)
if (warp_touch) then
just_warped = true
player_pos = get_warp_pos(warp_touch.warp_to)
if (warp_touch.cont) then
player_move(player_direction)
end
end
end
end
function player_draw()
love.graphics.setColor(1, 0.5, 0.5, 1)
if (player_moving) then
-- If player is moving, draw dis - sucka!
animation_draw(player_current_animation, player_pos.x, player_pos.y, flip);
-- Animation has stopped, do dis.. stationary -- user has stopped moving.. because animation will stop animating
else
-- If riding bike
if (player_riding_bike) then
if (player_direction == "up") then
love.graphics.draw(resources.spritesheets.npc, resources.sprites.npc[frames.bike.up], player_pos.x, player_pos.y)
elseif (player_direction == "down") then
love.graphics.draw(resources.spritesheets.npc, resources.sprites.npc[frames.bike.down], player_pos.x, player_pos.y)
elseif (player_direction == "left") then
love.graphics.draw(resources.spritesheets.npc, resources.sprites.npc[frames.bike.side], player_pos.x, player_pos.y)
elseif (player_direction == "right") then
love.graphics.draw(resources.spritesheets.npc, resources.sprites.npc[frames.bike.side], player_pos.x+16, player_pos.y, 0, -1, 1)
end
else
-- No bike riding
if (player_direction == "up") then
love.graphics.draw(resources.spritesheets.npc, resources.sprites.npc[frames.stand.up], player_pos.x, player_pos.y)
elseif (player_direction == "down") then
love.graphics.draw(resources.spritesheets.npc, resources.sprites.npc[frames.stand.down], player_pos.x, player_pos.y)
elseif (player_direction == "left") then
love.graphics.draw(resources.spritesheets.npc, resources.sprites.npc[frames.stand.side], player_pos.x, player_pos.y)
elseif (player_direction == "right") then
love.graphics.draw(resources.spritesheets.npc, resources.sprites.npc[frames.stand.side], player_pos.x+16, player_pos.y, 0, -1, 1)
end
end
end
end
|
set = {1, 1, 2, 2, 2, 2, 5, 5, 5, 5}
fact = lib.math.random_shuffle(set)
jimenilac = 1
for i = 1,4 do
jimenilac = jimenilac * fact[i]
end
if (jimenilac == 10 or jimenilac == 100) then
jimenilac = jimenilac * 2
end
if (jimenilac < 50) then
jbrojilac = jimenilac + math.random(50 - jimenilac)
else
jbrojilac = 2 + math.random(jimenilac - 2)
end
if (jbrojilac == jimenilac * math.floor(jbrojilac/jimenilac)) then
jbrojilac = jbrojilac + 1
end
gcd2 = lib.math.gcd(jimenilac, jbrojilac)
imenilac = jimenilac / gcd2
brojilac = jbrojilac / gcd2
value = brojilac/imenilac
|
local Serialization = {}
--# Constants
local MODULE_FORMAT = [[
-- This is an automatically generated Lua module. Take care when editing it.
return %s
]]
local TABLE_FORMAT = [[
{
%s
%s}]]
local TABLE_ITEM_FORMAT = '%s%s = %s,'
local INDENT_PREFIX = ' '
local KEY_TYPE_ERROR = 'unsupported key type %q'
local SCHEMA_ERROR = 'the value %q does not match the expected type %q, and the schema does not specify a default value for it'
--# Helpers
local function table_to_lua_code(a_table, depth)
depth = depth or 0
local string_table = {}
local indent = INDENT_PREFIX:rep(depth + 1)
for key, value in pairs(a_table) do
local key_type = type(key)
if key_type == 'string' then
table.insert(string_table, TABLE_ITEM_FORMAT:format(
INDENT_PREFIX:rep(depth + 1),
key,
Serialization.to_lua_code(value, depth + 1)
))
else
error(KEY_TYPE_ERROR:format(key_type))
end
end
return TABLE_FORMAT:format(
table.concat(string_table, '\n'),
INDENT_PREFIX:rep(depth)
)
end
--# Interface
function Serialization.apply_schema(value, schema)
if type(schema) == 'table' then
if schema.type == nil then
-- We are dealing with a table structure.
if type(value) ~= 'table' then
value = {}
end
for key, sub_schema in pairs(schema) do
value[key] = Serialization.apply_schema(value[key], sub_schema)
end
return value
else
-- We are dealing with a terminal element.
if type(schema.type) == 'function' and schema.type(value) then
return value
elseif type(value) == schema.type then
return value
elseif schema.default == nil then
error(SCHEMA_ERROR:format(value, schema.type))
else
return schema.default
end
end
else
return schema
end
end
function Serialization.safe_require(module_name, schema)
local succeeded, module = pcall(require, module_name)
if not succeeded then
module = nil
end
module = Serialization.apply_schema(module, schema)
package.loaded[module_name] = module
return module
end
function Serialization.to_lua_code(value, depth)
local the_type = type(value)
if the_type == 'table' then
return table_to_lua_code(value, depth)
elseif the_type == 'string' then
return ('%q'):format(value)
else
return tostring(value)
end
end
function Serialization.to_lua_module(value)
return MODULE_FORMAT:format(Serialization.to_lua_code(value, 0))
end
--# Export
return Serialization
|
local gc = Var "GameCommand";
local string_name = gc:GetText();
local string_expl = THEME:GetString(Var "LoadingScreen", gc:GetName() .. "Explanation");
local ColorTable = LoadModule("Theme.Colors.lua")( LoadModule("Config.Load.lua")("SoundwavesSubTheme","Save/OutFoxPrefs.ini") );
return Def.ActorFrame {
GainFocusCommand=function(self) self:finishtweening():visible(true):diffusealpha(0.75):zoom(1.1):easeinoutsine(0.25):zoom(1):diffusealpha(1) end;
LoseFocusCommand=function(self) self:finishtweening():visible(false):zoom(1) end;
-- Emblem Frame
Def.ActorFrame {
FOV=90;
-- Main Emblem
Def.Sprite {
Texture="_base";
InitCommand=function(self) self:diffusealpha(0):zoom(0.75):diffuse(ColorTable["playModeIconsBaseColor"]):diffusebottomedge(ColorTable["playModeIconsBaseGradient"]) end;
OnCommand=function(self) self:diffusealpha(0):zoom(1.2):sleep(0.2):easeinoutsine(0.3):diffusealpha(1):zoom(1) end;
GainFocusCommand=function(self) self:finishtweening():zoom(1):diffusealpha(1) end;
LoseFocusCommand=function(self) self:finishtweening():easeoutsine(0.4):diffusealpha(0):zoom(0.75) end;
OffFocusedCommand=function(self) self:finishtweening():easeoutquint(0.3):diffusealpha(0):zoom(1.2) end;
};
LoadActor( gc:GetName() ) .. {
InitCommand=function(self) self:diffusealpha(0):zoom(0.75):diffuse(ColorTable["playModeIconsEmblem"]) end;
OnCommand=function(self) self:diffusealpha(0):zoom(1.2):sleep(0.2):easeinoutsine(0.3):diffusealpha(1):zoom(1) end;
GainFocusCommand=function(self) self:finishtweening():zoom(1):diffusealpha(1) end;
LoseFocusCommand=function(self) self:finishtweening():easeoutsine(0.4):diffusealpha(0):zoom(0.75) end;
OffFocusedCommand=function(self) self:finishtweening():easeoutquint(0.3):diffusealpha(0):zoom(1.2) end;
};
};
-- Text Frame
Def.ActorFrame {
OnCommand=function(self) self:diffusealpha(0):sleep(0.2):easeinoutsine(0.3):diffusealpha(1) end;
Def.BitmapText {
Font="_Large Bold";
Text=string_name;
InitCommand=function(self) self:y(160):skewx(-0.15):zoom(1) end;
GainFocusCommand=function(self) self:finishtweening():easeinoutsine(0.45):diffusealpha(1) end;
LoseFocusCommand=function(self) self:finishtweening():decelerate(0.45):diffusealpha(0) end;
OffFocusedCommand=function(self) self:finishtweening():easeoutquint(0.3):diffusealpha(0):zoomx(1.1) end;
};
Def.BitmapText {
Font="_Condensed Medium";
Text=string_expl;
InitCommand=function(self) self:y(200):wrapwidthpixels(290):vertalign(top) end;
GainFocusCommand=function(self) self:finishtweening():easeinoutsine(0.45):diffusealpha(1) end;
LoseFocusCommand=function(self) self:finishtweening():decelerate(0.45):diffusealpha(0) end;
OffFocusedCommand=function(self) self:finishtweening():easeoutquint(0.3):diffusealpha(0):zoomx(1.1) end;
};
};
}; |
local host = arg[1] or '127.0.0.1'
local port = arg[2] or 514
local InitWriter = [[
return require 'log.writer.list'.new(
require 'log.writer.console'.new()
,require 'log.writer.net.udp'.new('%{udp_cnn_host}', %{udp_cnn_port})
,require 'log.writer.net.zmq'.new('%{zmq_cnn_host}')
)
]]
local writer = require "log.writer.async.zmq".new('inproc://async.logger',
InitWriter:gsub('%%{(.-)}', {
zmq_cnn_host = 'tcp://' .. host .. ':' .. port;
udp_cnn_host = host;
udp_cnn_port = port;
})
)
require "socket".sleep(0.5) -- net.zmq need time to connect
local LOG = require"log".new(nil, writer)
LOG.fatal("can not allocate memory")
LOG.error("file not found")
LOG.warning("cache server is not started")
LOG.info("new message is received")
LOG.notice("message has 2 file")
print("Press enter ...") io.flush() io.read() |
local map = {}
local tick_timer = 0
local tick_timer_max = 2
map.effect = false
if map.effect then
map.back = 0.9
map.front = 0.2
else
map.back = 1
map.front = 1
end
function map.load()
map.map = {}
for y=1, 25 do
if not map.map[y] then map.map[y] = {} end
for x=1, 40 do
local char = " "
local bg = "BLUE-D"
local fg = "BLUE-L"
local type = "water"
local collide = true
-- determine if should place sand
-- should place if x,y coordinates are within 10 characters of middle
local distance = distance(x, y, 21, 13)
if distance <= 9 then
-- SAND
bg = "YELLOW"
fg = "WHITE"
type = "sand"
collide = false
elseif distance <= 11 then
local r = math.random(1, 5)
if r < 2 then
bg = "BLUE-D"
fg = "BLUE-L"
type = "water"
collide = false
else
bg = "YELLOW"
fg = "WHITE"
type = "sand"
collide = false
end
end
local which = math.random(0, 9)
if which > 7 then
-- ACCENT
char = "."
else
char = " "
end
local block = {}
block.char = char
block.bg = bg
block.fg = fg
block.type = type
block.collide = collide
block.x = x
block.y = y
map.map[y][x] = block
end
end
end
function map.show_trophy()
-- make trophy
local t = {}
t.char = "C"
t.bg = "YELLOW"
t.fg = "BLUE-L"
t.type = "trophy"
t.collide = false
t.x = 38
t.y = 10
map.map[10][38] = t
end
function map.update(dt)
tick_timer = tick_timer + dt
if tick_timer >= tick_timer_max then
tick_timer = 0
for y=1, 25 do
for x=1, 40 do
local block = map.map[y][x]
if block.type == "water" then
local flicker = math.random(1, 10)
if flicker == 1 then
block.char = "."
else
block.char = " "
end
end
end
end
end
end
function map.draw()
-- First Layer
for y=1, 25 do
for x=1, 40 do
local XX = x*24-24
local YY = y*24-24
local block = map.map[y][x]
-- draw background
r,g,b = unpack(colors[block.bg])
a = map.back
love.graphics.setColor(r, g, b, a)
love.graphics.rectangle("fill", XX, YY, 24, 24)
-- draw char
r,g,b = unpack(colors[block.fg])
a = map.back
love.graphics.setColor(r, g, b, a)
love.graphics.print(block.char, XX, YY)
end
end
if map.effect then
-- Second Layer
for y=1, 25 do
for x=1, 40 do
local XX = x*24-24
local YY = y*24-24
local block = map.map[y][x]
-- draw background
r,g,b = unpack(colors[block.bg])
a = map.front
love.graphics.setColor(r, g, b, a)
love.graphics.rectangle("fill", XX-3, YY+3, 24, 24)
-- draw char
r,g,b = unpack(colors[block.fg])
a = map.front
love.graphics.setColor(r, g, b, a)
love.graphics.print(block.char, XX-3, YY+3)
end
end
end
end
function map.collide(x, y, dir)
if dir == "UP" then
y = y - 1
end
if dir == "DOWN" then
y = y + 1
end
if dir == "LEFT" then
x = x - 1
end
if dir == "RIGHT" then
x = x + 1
end
if not map.map[y] then
return true
end
if not map.map[y][x] then
return true
end
local block = map.map[y][x]
if block.type == "trophy" then
player.win = true
player.multiplier = 100
song:stop()
local st = hud.message_timer
hud.add_message("Finally...", st, st+3)
hud.add_message("I won't lose you again...", st+3, st+6)
hud.add_message("Oh no!", st+6, st+9)
hud.add_message("Something isn't right...", st+9, st+12)
hud.add_message("THANKS FOR PLAYING!", st+12, st+15)
hud.add_message("CLAM 2 COMING SOON!!!", st+18, st+28)
hud.add_message("bit-42.github.io", st+28, st+38)
end
if player.sacred then
return false
else
return block.collide
end
end
function map.get_random_sand()
while true do
local x = math.random(1, 40)
local y = math.random(1, 25)
local block = map.map[y][x]
if block.collide == false and block.type == "sand" then
local found = false
for i,v in ipairs(worker.workers) do
if x == v.x and y == v.y then
found = true
end
end
if not found then
return block
end
end
end
end
function map.remove_clam(x, y)
local block = map.map[y][x]
if block.type == "clam" then
block.type = "sand"
block.bg = "YELLOW"
block.fg = "WHITE"
block.char = math.random(1, 10) == 1 and "." or " "
end
end
return map
|
slot0 = class("BackyardFurnitureVO")
slot0.FLOOR = 1
slot0.WALL_DIR_ALL = 2
slot0.WALL_DIR_RIGHT = 4
slot0.WALL_DIR_LEFT = 3
slot0.INTERACTION_LOOP_TYPE_ALL = 1
slot0.INTERACTION_LOOP_TYPE_LAST_ONE = 2
slot0.getWallDir = function (slot0)
if slot0.y - slot0.x >= 1 then
return BackYardConst.BACKYARD_WALL_DIR_LEFT
else
return BackYardConst.BACKYARD_WALL_DIR_RIGHT
end
end
slot0.getCloneId = function (slot0, slot1)
if BackYardConst.SAME_ID_MODIFY_ID < slot0.configId then
return slot0.configId + slot1
else
return slot0.configId * 10000000 + slot1
end
end
slot0.isRightWall = function (slot0)
return slot0:getWallDir() == BackYardConst.BACKYARD_WALL_DIR_RIGHT
end
slot0.Ctor = function (slot0, slot1)
slot0.id = tonumber(slot1.id)
slot0.configId = slot1.configId or tonumber(slot1.id)
slot0.position = slot1.position
slot0.dir = slot1.dir or 1
slot0.parent = slot1.parent or 0
slot0.preGrids = {}
slot0.bottomGrids = {}
slot0.child = slot1.child or {}
slot0.shipIds = slot1.ships or {}
slot0.date = slot1.date or 0
slot0.floor = slot1.floor
slot0.spineId = nil
slot0.spineExtra = {}
slot0.stageShips = {}
end
slot0.NeedAlphaCheck = function (slot0)
return slot0.configId ~= 27108
end
slot0.hasChild = function (slot0)
return table.getCount(slot0.child) > 0
end
slot0.existVoice = function (slot0)
if slot0:isShowDesc() then
return slot0:getConfig("can_trigger")[2] ~= nil
end
end
slot0.getVoice = function (slot0)
if slot0:existVoice() then
slot3, slot4 = nil
return (type(slot0:getConfig("can_trigger")[2]) ~= "table" or slot1[2][math.random(1, #slot1[2])]) and slot1[2], {
action = (type(slot1[3]) ~= "table" or slot1[3][1]) and slot1[3],
effect = slot1[4]
}
end
end
slot0.getShipExtra = function (slot0)
return slot0.spineExtra
end
slot0.isTransPort = function (slot0)
return slot0:getConfig("type") == Furniture.TYPE_TRANSPORT
end
slot0.IsRandomController = function (slot0)
return slot0:getConfig("type") == Furniture.TYPE_RANDOM_CONTROLLER
end
slot0.getTransportPoint = function (slot0)
if slot0:isTransPort() then
slot1 = slot0:getConfig("spine")[3][1]
if slot0.dir == 1 then
return Vector2(slot0.position.x + slot1[1], slot0.position.y + slot1[2])
elseif slot0.dir == 2 then
return Vector2(slot0.position.x + slot1[2], slot0.position.y + slot1[1])
end
end
end
slot0.getTransportAnims = function (slot0, slot1)
if slot0:isTransPort() then
return slot0:getConfig("spine")[3][2][slot1]
end
end
slot0.canInterActionSpineExtra = function (slot0)
return slot0:getCurrSpineCnt() < slot0:getSpineMaxCnt()
end
slot0.getSpineMaxCnt = function (slot0)
if slot0:isTransPort() then
return 2
end
if slot0:IsRandomController() then
return #slot0:getConfig("animator")[1]
end
slot1 = 0
if slot0:isSpine() then
slot1 = slot1 + 1
if slot0:getConfig("spine_extra") and type(slot2) == "table" then
slot1 = slot1 + table.getCount(slot2)
end
end
return slot1
end
slot0.getCurrSpineCnt = function (slot0)
slot1 = 0
if slot0.spineId then
slot1 = slot1 + 1
end
return slot1 + table.getCount(slot0.spineExtra)
end
slot0.addSpineExtra = function (slot0, slot1)
slot3 = -1
for slot7 = 1, slot0:getSpineMaxCnt(), 1 do
if not slot0.spineExtra[slot7] then
slot3 = slot7
break
end
end
slot0.spineExtra[slot3] = slot1
return slot3
end
slot0.getUniqueShipAction = function (slot0, slot1, slot2)
if slot0:getConfig("spine_action_replace") == "" or #slot3 == 0 then
return
end
if _.detect(slot3, function (slot0)
return _.any(slot0[2], function (slot0)
return slot0 == (((slot0[5] and slot0[5] ~= 1) or nil.skinId) and nil.gruopId)
end) and slot1 == slot0[1]
end) then
return slot4[3], slot4[4] or 0
end
end
slot1 = pg.furniture_specail_action
slot0.GetSpecailActiont = function (slot0, slot1)
if slot0[slot0.configId] and _.detect(slot2.actions, function (slot0)
return slot0[1] == slot0
end) then
return slot3[2]
end
return -1
end
slot0.getSpineExtraConfig = function (slot0, slot1)
if slot0:isSpine() then
return slot0:getConfig("spine_extra")[slot1]
end
end
slot0.removeSpineExtra = function (slot0, slot1)
slot2 = nil
for slot6, slot7 in pairs(slot0.spineExtra) do
if slot7 == slot1 then
slot0.spineExtra[slot6] = nil
slot2 = slot6
end
end
return slot2
end
slot0.hasSpineExtra = function (slot0)
return table.getCount(slot0.spineExtra) ~= 0
end
slot0.clearInterActions = function (slot0)
slot0.spineId = nil
slot0.stageShips = {}
slot0.shipIds = {}
slot0.spineExtra = {}
end
slot0.canInterActionShipGroup = function (slot0, slot1)
if #slot0:interActionGroup() == 0 then
return true
end
return table.contains(slot2, slot1)
end
slot0.getBgm = function (slot0)
if slot0:getConfig("interaction_bgm") and slot1 ~= "" then
return slot1
end
end
slot0.interActionGroup = function (slot0)
slot1 = {}
if slot0:getConfig("interAction_group") and type(slot2) == "table" then
slot1 = slot2
end
return slot1
end
slot0.setStageShip = function (slot0, slot1)
if not table.contains(slot0.stageShips, slot1) then
table.insert(slot0.stageShips, slot1)
end
end
slot0.clearStageShip = function (slot0, slot1)
if table.indexof(slot0.stageShips, slot1) then
table.remove(slot0.stageShips, slot2)
end
end
slot0.getStageShip = function (slot0)
return slot0.stageShips
end
slot0.hasStageShip = function (slot0)
return #slot0.stageShips > 0
end
slot0.isLock = function (slot0)
return slot0.spineId ~= nil
end
slot0.setSpineId = function (slot0, slot1)
slot0.spineId = slot1
end
slot0.getSpineId = function (slot0)
return slot0.spineId
end
slot0.isSpine = function (slot0)
return slot0:getConfig("spine") ~= nil
end
slot0.getInterActionSpineCfg = function (slot0)
if slot0:isSpine() then
return slot0:getConfig("spine")[3]
end
end
slot0.isInterActionSpine = function (slot0)
if slot0:isTransPort() then
return true
end
return slot0:getInterActionSpineCfg() ~= nil and #slot1 > 0
end
slot0.canInterActionSpine = function (slot0)
return slot0:isInterActionSpine() and not slot0.spineId
end
slot0.getSpineAnims = function (slot0)
if slot0:isInterActionSpine() then
return slot0:getInterActionSpineCfg()[2]
end
end
slot0.canRotate = function (slot0)
return slot0:getConfig("can_rotate") == 0
end
slot0.getBreakAnim = function (slot0)
if slot0:isSpine() then
return slot0:getInterActionSpineCfg()[3][1]
end
end
slot0.isFollowFurnitrueAnim = function (slot0)
if slot0:isSpine() then
return slot0:getInterActionSpineCfg()[3][2]
end
end
slot0.getPreheatAnim = function (slot0)
if slot0:isSpine() then
return slot0:getInterActionSpineCfg()[3][3]
end
end
slot0.hasTailAction = function (slot0)
return slot0:getTailAction() ~= nil
end
slot0.getTailAction = function (slot0)
if slot0:isSpine() then
return slot0:getInterActionSpineCfg()[3][4]
end
end
slot0.hasEndAnimName = function (slot0)
return slot0:getEndAnimName() ~= nil
end
slot0.getEndAnimName = function (slot0)
if slot0:isSpine() then
return slot0:getInterActionSpineCfg()[3][5]
end
end
slot0.hasAnimatorMask = function (slot0)
return slot0:getConfig("animator") and slot1[3]
end
slot0.getAnimatorMaskConfig = function (slot0)
if slot0:hasAnimatorMask() then
return slot0:getConfig("animator")[3]
end
end
slot0.getSpineName = function (slot0)
if slot0:isSpine() then
return slot0:getConfig("spine")[1][1], slot0.getConfig("spine")[1][2]
end
end
slot0.getSpineMaskName = function (slot0)
if slot0:hasSpineMask() then
return slot0:getConfig("spine")[2][1], slot0.getConfig("spine")[2][2]
end
end
slot0.hasSpineMask = function (slot0)
if slot0:isSpine() then
return slot0:getConfig("spine")[2] ~= nil and #slot1 > 0
end
end
slot0.hasSpineShipBodyMask = function (slot0)
if slot0:isSpine() then
return slot0:getConfig("spine")[4] ~= nil and #slot1 > 0
end
end
slot0.getSpineShipBodyMask = function (slot0)
if slot0:hasSpineShipBodyMask() then
return slot0:getConfig("spine")[4]
end
end
slot0.getSpineExtraBodyMask = function (slot0, slot1)
if slot0:hasSpineExtra() then
return slot0:getConfig("spine_extra")[slot1][1]
end
end
slot0.getSpineAinTriggerPos = function (slot0)
if slot0:isInterActionSpine() then
slot1 = slot0:getInterActionSpineCfg()[1]
if slot0.dir == 1 then
return Vector2(slot0.position.x + slot1[1], slot0.position.y + slot1[2])
elseif slot0.dir == 2 then
return Vector2(slot0.position.x + slot1[2], slot0.position.y + slot1[1])
end
end
end
slot0.getSpineAniPos = function (slot0)
if slot0:isInterActionSpine() then
if slot0:getConfig("spine")[5] and #slot1 > 0 then
return Vector3(slot1[1], slot1[2], 0)
end
return nil
end
end
slot0.getSpineAniScale = function (slot0)
if slot0:isInterActionSpine() and slot0:getConfig("spine")[6] and #slot1 > 0 then
return slot1[1]
end
return 1
end
slot0.getSpineSpeed = function (slot0)
if slot0:isInterActionSpine() then
return slot0:getConfig("spine")[7] or 1
end
return 1
end
slot0.isLoopSpineInterAction = function (slot0)
if slot0:isInterActionSpine() then
return slot0:getInterActionSpineCfg()[4][1] > 0, slot1
end
end
slot0.hasInterActionMask = function (slot0)
return table.getCount(slot0:getInterActionMaskNames()) > 0
end
slot0.getInterActionMaskNames = function (slot0)
slot2 = {}
if slot0:getConfig("interAction") then
for slot6, slot7 in ipairs(slot1) do
if slot7 ~= nil and slot7 ~= "" then
slot2[slot6] = slot7[4]
end
end
end
return slot2
end
slot0.getIntetActionMaskName = function (slot0)
if slot0:hasInterActionMask() then
return slot0:getConfig("interAction")[1][4]
end
end
slot0.hasInterActionData = function (slot0)
return slot0:getConfig("interAction") ~= nil
end
slot0.getInterActionData = function (slot0, slot1)
if slot0:hasInterActionData() then
return slot0:getConfig("interAction")[slot1][1], slot0.getConfig("interAction")[slot1][2], slot0.getConfig("interAction")[slot1][3], slot0.getConfig("interAction")[slot1][4], slot0.getConfig("interAction")[slot1][5], slot0.getConfig("interAction")[slot1][6]
end
end
slot0.getDate = function (slot0)
if slot0.date > 0 then
return pg.TimeMgr.GetInstance():STimeDescS(slot0.date, "%Y/%m/%d")
end
end
slot0.hasInterActionShipId = function (slot0)
return table.getCount(slot0.shipIds) ~= 0
end
slot0.getInterActionCount = function (slot0)
return table.getCount(slot0.shipIds or {})
end
slot0.getInterActionShipIds = function (slot0)
slot1 = {}
for slot5, slot6 in pairs(slot0.shipIds) do
table.insert(slot1, slot6)
end
return slot1
end
slot0.setInterActionShipId = function (slot0, slot1, slot2)
if not table.contains(slot0.shipIds, slot1) then
slot0.shipIds[slot2] = slot1
end
end
slot0.getInterActionOrder = function (slot0)
for slot5 = 1, table.getCount(slot0:getConfig("interAction")), 1 do
if not slot0.shipIds[slot5] then
return slot5
end
end
end
slot0.getOrderByShipId = function (slot0, slot1)
for slot5, slot6 in pairs(slot0.shipIds) do
if slot6 == slot1 then
return slot5
end
end
end
slot0.clearInterAction = function (slot0, slot1)
for slot5, slot6 in pairs(slot0.shipIds) do
if slot1 == slot6 then
slot0.shipIds[slot5] = nil
break
end
end
end
slot0.GetPicture = function (slot0)
return slot0:getConfig("picture")
end
slot0.setPosition = function (slot0, slot1)
slot0.position = slot1
end
slot0.getPosition = function (slot0)
return slot0.position
end
slot0.setDir = function (slot0, slot1)
slot0.dir = slot1
end
slot0.isSameDir = function (slot0, slot1)
return slot0.dir == slot1
end
slot0.getConfig = function (slot0, slot1)
if pg.furniture_data_template[slot0.configId][slot1] then
return slot3[slot1]
elseif pg.furniture_shop_template[slot0.configId] then
return slot5[slot1]
end
end
slot0.updatePosition = function (slot0, slot1)
slot0.position = slot1
end
slot0.setPreGrids = function (slot0, slot1)
slot0.preGrids = slot1
end
slot0.getPerGrids = function (slot0)
return slot0.preGrids
end
slot0.updateDir = function (slot0)
if slot0.dir == 1 then
slot0.dir = 2
elseif slot0.dir == 2 then
slot0.dir = 1
end
end
slot0.getReverseDir = function (slot0)
return (slot0.dir == 1 and 2) or 1
end
slot0.clearPosition = function (slot0)
slot0.position = nil
slot0.dir = 1
slot0.child = {}
slot0.parent = 0
end
slot0.getOccupyGrid = function (slot0, slot1)
slot2 = {}
slot3, slot4 = slot0:getSize()
if slot0:isFloor() then
for slot8 = slot1.x, (slot1.x + slot3) - 1, 1 do
for slot12 = slot1.y, (slot1.y + slot4) - 1, 1 do
table.insert(slot2, Vector2(slot8, slot12))
end
end
elseif slot1.y - slot1.x >= 1 then
for slot8 = slot1.x, (slot1.x + slot3) - 1, 2 do
table.insert(slot2, Vector2(slot8, slot1.y))
end
else
for slot8 = slot1.y, (slot1.y + slot3) - 1, 2 do
table.insert(slot2, Vector2(slot1.x, slot8))
end
end
return slot2
end
slot0.getOccupyGridForShip = function (slot0, slot1)
slot2 = slot0:getOccupyGrid(slot1)
if slot0:isArch() then
slot3 = slot0:getCanPutOnGrid(slot1)
for slot7 = #slot2, 1, -1 do
slot8 = slot2[slot7]
for slot12, slot13 in ipairs(slot3) do
if slot8.x == slot13.x and slot8.y == slot13.y then
table.remove(slot2, slot7)
end
end
end
end
return slot2
end
slot0.getCanPutOnGrid = function (slot0, slot1)
slot2 = slot0:getConfig("canputonGrid")
slot3 = {}
if slot0.dir == 1 then
for slot7, slot8 in ipairs(slot2) do
table.insert(slot3, Vector2(slot8[1] + slot1.x, slot8[2] + slot1.y))
end
else
for slot7, slot8 in ipairs(slot2) do
table.insert(slot3, Vector2(slot8[2] + slot1.x, slot8[1] + slot1.y))
end
end
return slot3
end
slot0.getChildPosById = function (slot0, slot1)
slot2 = slot0.child[slot1]
if slot0.dir == 1 then
return Vector2(slot0.position.x + slot2.x, slot0.position.y + slot2.y)
elseif slot0.dir == 2 then
return Vector2(slot0.position.x + slot2.y, slot0.position.y + slot2.x)
end
end
slot0.setFather = function (slot0, slot1)
slot0.parent = slot1
end
slot0.getOccupyGridCount = function (slot0)
if slot0:isArch() then
return #slot0:getOccupyGrid(slot0.position)
else
return (slot0:getConfig("size")[1] or 0) * (slot1[2] or 0)
end
end
slot0.isChild = function (slot0, slot1)
for slot5, slot6 in pairs(slot0.child) do
if slot1.id == slot5 then
return true
end
end
return false
end
slot0.hasParent = function (slot0)
return slot0.parent ~= 0
end
slot0.is3DObject = function (slot0)
return slot0:getConfig("is_3d_obj") == 1
end
slot0.isFloor = function (slot0)
return slot0:getConfig("belong") == slot0.FLOOR
end
slot0.isAllWall = function (slot0)
return slot0:getConfig("belong") == slot0.WALL_DIR_ALL
end
slot0.isRightType = function (slot0)
return slot0:getConfig("belong") == slot0.WALL_DIR_RIGHT
end
slot0.isLeftType = function (slot0)
return slot0:getConfig("belong") == slot0.WALL_DIR_LEFT
end
slot0.isFurniture = function (slot0)
return slot0:getConfig("type") ~= 0
end
slot0.isMapItem = function (slot0)
slot1 = slot0:getConfig("type")
if slot0:isFloor() and slot1 ~= Furniture.TYPE_MAT then
return true
end
return false
end
slot0.checkBoundItem = function (slot0)
if slot0:isFloor() and not slot0:hasParent() and not slot0:isPaper() then
return true
end
return false
end
slot0.getSize = function (slot0)
slot1 = slot0:getConfig("size")
if slot0.dir == 1 then
return slot1[1], slot1[2]
else
return slot1[2], slot1[1]
end
end
slot0.isOccupy = function (slot0, slot1, slot2)
if not slot0.position then
return
end
for slot7, slot8 in ipairs(slot3) do
if slot1 == slot8.x and slot2 == slot8.y then
return true
end
end
return false
end
slot0.isSameParent = function (slot0, slot1)
if slot1:hasParent() and slot0:hasParent() and slot1.parent == slot0.parent then
return true
end
return false
end
slot0.isWallMat = function (slot0)
return slot0:getConfig("type") == Furniture.TYPE_WALL_MAT
end
slot0.isMat = function (slot0)
return slot0:getConfig("type") == Furniture.TYPE_MAT
end
slot0.canputon = function (slot0)
return slot0:getConfig("canputon") == 1
end
slot0.getMapSize = function (slot0)
return 30, 30
end
slot0.isSelf = function (slot0, slot1)
return slot0.id == slot1
end
slot0.isPaper = function (slot0)
if slot0:getConfig("type") == Furniture.TYPE_WALLPAPER or slot1 == Furniture.TYPE_FLOORPAPER then
return true
end
return false
end
slot0.isWallPaper = function (slot0)
if slot0:getConfig("type") == Furniture.TYPE_WALLPAPER then
return true
end
return false
end
slot0.canInterAction = function (slot0)
if not slot0:getConfig("interAction") then
return false
end
return table.getCount(slot0.shipIds) < table.getCount(slot1)
end
slot0.isSame = function (slot0, slot1)
if slot0.position.x == slot1.position.x and slot0.position.y == slot1.position.y and slot0.dir == slot1.dir and slot0.parent == slot1.parent then
return true
end
return false
end
slot0.isConflictPos = function (slot0, slot1)
slot3 = slot1:getOccupyGrid(slot1.position)
for slot7, slot8 in pairs(slot2) do
for slot12, slot13 in pairs(slot3) do
if slot8.x == slot13.x and slot8.y == slot13.y then
return true
end
end
end
return false
end
slot0.isShowDesc = function (slot0)
return #slot0:getConfig("can_trigger") > 0 and slot1[1] > 0
end
slot0.descVoiceType = function (slot0)
return slot0:getConfig("can_trigger")[1]
end
slot0.isTouchSpine = function (slot0)
if slot0:isSpine() then
return slot0:getConfig("spine")[1][3] ~= nil
end
end
slot0.isSpineCar = function (slot0)
if slot0:isSpine() then
return slot0:getConfig("spine")[1][4] == true
end
end
slot0.getTouchSpineConfig = function (slot0)
if slot0:isSpine() then
slot4 = slot0:getConfig("spine")[1][3] or {}[1]
if Clone(slot0.getConfig("spine")[1][3] or [3]) then
table.insert(slot3, slot2[1])
slot4 = slot3[math.random(1, #slot3)]
end
return slot4, slot2[2], slot2[4], slot2[5], slot2[6], slot2[7]
end
end
slot0.canBeTouch = function (slot0)
return slot0:isShowDesc() or slot0:isTouchSpine()
end
slot0.FURNITURE_TYPE = {
i18n("word_wallpaper"),
i18n("word_furniture"),
i18n("word_decorate"),
i18n("word_floorpaper"),
i18n("word_mat"),
i18n("word_wall"),
i18n("word_collection")
}
slot0.getChineseType = function (slot0)
return slot0.FURNITURE_TYPE[slot0:getConfig("type")]
end
slot0.getGainby = function (slot0)
return slot0:getConfig("gain_by")
end
slot0.isStageFurniture = function (slot0)
return slot0:getConfig("type") == Furniture.TYPE_STAGE
end
slot0.hasAnimator = function (slot0)
return slot0:getConfig("animator") ~= nil
end
slot0.getAnimatorData = function (slot0)
if slot0:hasAnimator() then
return slot0:getConfig("animator")[1]
end
end
slot0.getAnimtorControlName = function (slot0, slot1)
slot2 = {}
if slot0:hasAnimator() then
if type(slot0:getConfig("animator")[1][slot1] or slot3[1] or {}) == "string" then
table.insert(slot2, slot4)
else
slot2 = slot4
end
end
return slot2
end
slot0.getAnimtorControlGoName = function (slot0, slot1, slot2)
return "Animator" .. slot1 .. slot2
end
slot0.isArch = function (slot0)
return slot0:getConfig("type") == Furniture.TYPE_ARCH
end
slot0.getArchMask = function (slot0)
return slot0:getConfig("picture") .. "_using"
end
slot0.isMoveable = function (slot0)
return slot0:getConfig("type") == Furniture.TYPE_MOVEABLE
end
slot0.canTriggerInteraction = function (slot0, slot1)
if not slot0:canInterActionShipGroup(slot1) then
return false
end
return (slot0:isInterActionSpine() and slot0:canInterActionSpine()) or slot0:canInterAction() or slot0:isStageFurniture() or slot0:isArch() or slot0:isTransPort()
end
slot0.getSurroundGrid = function (slot0)
slot1 = slot0:getPosition()
table.insert(slot2, Vector2(slot1.x, slot1.y + 1))
table.insert(slot2, Vector2(slot1.x, slot1.y - 1))
table.insert(slot2, Vector2(slot1.x - 1, slot1.y))
table.insert({}, Vector2(slot1.x + 1, slot1.y))
return
end
slot0.IsFollower = function (slot0)
return slot0:getConfig("type") == Furniture.TYPE_FOLLOWER
end
slot0.IsSpineRandomType = function (slot0)
return slot0:IsFollower()
end
slot0.GetFollowerInterActionData = function (slot0)
return slot0:getConfig("spine")[3]
end
slot0.ExistFollowBoneNode = function (slot0)
return slot0:getConfig("followBone") ~= nil
end
slot0.GetFollowBone = function (slot0)
return slot0:getConfig("followBone")[1], slot0.getConfig("followBone")[2] or 1
end
slot0.HasFollower = function (slot0)
return slot0:hasAnimator() or slot0:ExistFollowBoneNode()
end
return slot0
|
slot0 = class("WSAtlasBottom", import("...BaseEntity"))
slot0.Fields = {
rtBg = "userdata",
transform = "userdata",
btnBoss = "userdata",
btnOverview = "userdata",
btnCollection = "userdata",
rtButton = "userdata",
wsTimer = "table",
comSilder = "userdata",
twId = "number",
btnShop = "userdata"
}
slot0.EventUpdateScale = "WSAtlasBottom.EventUpdateScale"
slot0.Setup = function (slot0)
pg.DelegateInfo.New(slot0)
slot0:Init()
end
slot0.Dispose = function (slot0)
pg.DelegateInfo.Dispose(slot0)
slot0:Clear()
end
slot0.Init = function (slot0)
slot0.rtBg = slot0.transform.Find(slot1, "bg")
slot0.rtButton = slot0.transform.Find(slot1, "button")
slot0.btnBoss = slot0.rtButton:Find("btn_boss")
slot0.btnShop = slot0.rtButton:Find("btn_shop")
slot0.btnOverview = slot0.rtButton:Find("btn_overview")
slot0.btnCollection = slot0.rtButton:Find("btn_collection")
slot0.comSilder = slot0.transform.Find(slot1, "scale/Slider"):GetComponent("Slider")
slot0.comSilder.interactable = CAMERA_MOVE_OPEN
if CAMERA_MOVE_OPEN then
slot0.comSilder.onValueChanged:AddListener(function (slot0)
slot0:DispatchEvent(slot1.EventUpdateScale, slot0)
end)
end
end
slot0.UpdateScale = function (slot0, slot1, slot2, slot3)
if slot2 then
setImageAlpha(slot0.btnOverview, slot4)
setActive(slot0.btnOverview, true)
slot0.twId = LeanTween.value(go(slot0.comSilder), slot4, slot1, WSAtlasWorld.baseDuration):setEase(LeanTweenType.easeInOutSine):setOnUpdate(System.Action_float(function (slot0)
slot0.comSilder.value = slot0
setImageAlpha(slot0.btnOverview, slot0)
end)).setOnComplete(slot5, System.Action(function ()
slot0(slot1, slot0.btnOverview == 1)
return existCall(slot0.btnOverview == 1)
end)).uniqueId
slot0.wsTimer.AddTween(slot5, slot0.twId)
else
setImageAlpha(slot0.btnOverview, slot1)
setActive(slot0.btnOverview, slot1 == 1)
slot0.comSilder.value = slot1
return existCall(slot3)
end
end
slot0.CheckIsTweening = function (slot0)
return slot0.twId and LeanTween.isTweening(slot0.twId)
end
slot0.SetOverSize = function (slot0, slot1)
slot0.rtBg.offsetMin = Vector2(slot1, slot0.rtBg.offsetMin.y)
slot0.rtBg.offsetMax = Vector2(-slot1, slot0.rtBg.offsetMax.y)
end
return slot0
|
#!/opt/local/bin/lua
local xml_ast = [=[<?xml version="1.0" encoding="UTF-8"?>
<ns1:basic_ast xmlns:ns1="http://test_example.com">hello world</ns1:basic_ast>]=]
mhf = require("schema_processor")
basic_ast = mhf:get_message_handler("basic_ast", "http://test_example.com");
local content, msg = basic_ast:from_xml(xml_ast)
if (type(content) == 'table') then require 'pl.pretty'.dump(content);
else print(content, msg)
end
if (content ~= nil) then os.exit(true); else os.exit(false); end
|
local t = Def.ActorFrame{};
local title = "NO!";
local SubTitle;
local Artist;
local charter={};
local BPM={"???","???"};
local Time;
local CEN;
if GAMESTATE:IsCourseMode() then
CEN = GAMESTATE:GetCurrentCourse():GetCourseEntries()
end
title = GAMESTATE:IsCourseMode() and GAMESTATE:GetCurrentCourse():GetDisplayFullTitle() or GAMESTATE:GetCurrentSong():GetDisplayMainTitle()
SubTitle = GAMESTATE:IsCourseMode() and ToEnumShortString( GAMESTATE:GetCurrentCourse():GetCourseType() ) or GAMESTATE:GetCurrentSong():GetDisplaySubTitle();
if GAMESTATE:IsPlayerEnabled(PLAYER_1) then
if not GAMESTATE:IsCourseMode() then
if GAMESTATE:GetCurrentSteps(PLAYER_1):GetAuthorCredit() ~= "" then
charter[#charter+1] = GAMESTATE:GetCurrentSteps(PLAYER_1):GetAuthorCredit()
end
local BPMA = GAMESTATE:GetCurrentSteps(PLAYER_1):GetDisplayBpms();
BPM[1] = round(BPMA[1]);BPM[2] = round(BPMA[2]);
end
end
if GAMESTATE:IsPlayerEnabled(PLAYER_2) and not GAMESTATE:IsCourseMode() then
if not GAMESTATE:IsCourseMode() then
if GAMESTATE:GetCurrentSteps(PLAYER_2):GetAuthorCredit() ~= "" then
charter[#charter+1] = GAMESTATE:GetCurrentSteps(PLAYER_2):GetAuthorCredit()
end
local BPMB = GAMESTATE:GetCurrentSteps(PLAYER_2):GetDisplayBpms();
if BPM[1] == "???" then BPM[1] = BPMB[1]; else BPM[1] = round(math.min(BPMB[1],BPM[1])); end
if BPM[2] == "???" then BPM[2] = BPMB[2]; else BPM[2] = round(math.max(BPMB[2],BPM[2])); end
end
end
if BPM[1] == BPM[2] then table.remove(BPM,1) end
if GAMESTATE:IsCourseMode() then
if GAMESTATE:IsPlayerEnabled(PLAYER_1) and GAMESTATE:IsPlayerEnabled(PLAYER_2) then
Time = (GAMESTATE:GetCurrentCourse():GetTotalSeconds(GAMESTATE:GetCurrentTrail(PLAYER_1):GetStepsType())+GAMESTATE:GetCurrentCourse():GetTotalSeconds(GAMESTATE:GetCurrentTrail(PLAYER_2):GetStepsType()))/2;
elseif GAMESTATE:IsPlayerEnabled(PLAYER_1) then
Time = GAMESTATE:GetCurrentCourse():GetTotalSeconds(GAMESTATE:GetCurrentTrail(PLAYER_1):GetStepsType())
elseif GAMESTATE:IsPlayerEnabled(PLAYER_2) then
Time = GAMESTATE:GetCurrentCourse():GetTotalSeconds(GAMESTATE:GetCurrentTrail(PLAYER_2):GetStepsType())
end
else
Time = GAMESTATE:GetCurrentSong():MusicLengthSeconds();
end
t[#t+1] = LoadActor("Floor")..{OnCommand=cmd(rotationx,-90;zoom,0.75);};
t[#t+1] = LoadActor("Zight")..{OnCommand=cmd(z,-113;y,-188.5;vertalign,top;zoom,SCREEN_RIGHT/1900;zoomy,3);};
t[#t+1] = LoadActor("TABLE")..{OnCommand=cmd(zoom,0.25;rotationy,90);};
t[#t+1] = LoadActor("PAKKA")..{OnCommand=cmd(x,80;y,-188.5;zoom,3;rotationz,-30;rotationx,90);};
t[#t+1] = Def.ActorFrame{
OnCommand=cmd(y,-188.5;z,20;zoom,0.08/0.2;rotationz,8;rotationx,-90);
LoadActor("RNote")..{OnCommand=cmd(zoom,0.2;diffusealpha,1);};
LoadFont("Common Normal")..{OnCommand=cmd(y,-167;zoom,0.6;settext,title;diffuse,{0,0,0,1});};
LoadFont("Common Normal")..{OnCommand=cmd(y,-157;zoom,0.3;settext,SubTitle ~= "" and "-"..SubTitle.."-" or "";diffuse,{0,0,0,1});};
LoadFont("Common Normal")..{OnCommand=cmd(x,-123;y,-153;horizalign,left;zoom,0.3;settext,Artist~= nil and "By "..Artist or "";diffuse,{0,0,0,1});};
LoadFont("Common Normal")..{OnCommand=cmd(x,131;y,-153;horizalign,right;zoom,0.3;settext,#charter==0 and "Unknown Composer" or (#charter==2 and charter[1].." & "..charter[2] or charter[1]);diffuse,{0,0,0,1});};
LoadFont("Common Normal")..{OnCommand=cmd(x,-114;y,-143;horizalign,left;zoom,0.3;settext,#BPM==2 and tostring(BPM[1]).."-"..tostring(BPM[2]) or tostring(BPM[1]);diffuse,{0,0,0,1});};
};
if GAMESTATE:IsCourseMode() then
t[#t+1] = Def.ActorFrame{
OnCommand=cmd(x,-80;y,-188.5;z,20;zoom,0.08/0.2;rotationz,-50;rotationx,-90);
LoadActor("Paper")..{OnCommand=cmd(zoom,0.2);};
LoadFont("Common Normal")..{OnCommand=cmd(y,-167;settext,"Content";diffuse,color("#000000"))}}
for na = 1,math.min(#CEN,21) do
t[#t+1] = Def.ActorFrame{
OnCommand=cmd(x,-80;y,-188.5;z,20;zoom,0.08/0.2;rotationz,-50;rotationx,-90);LoadFont("Common Normal")..{
OnCommand=cmd(x,-110;y,-160+15*na;horizalign,left;
settextf,"No.%2d : %s (%s)",na,
CEN[na]:IsSecret() and "?????????" or CEN[na]:GetSong():GetDisplayMainTitle(),
CEN[na]:IsSecret() and "??:??" or SecondsToMMSS(CEN[na]:GetSong():MusicLengthSeconds());
zoom,.5;diffuse,color("#000000"));};
Def.Quad{
OnCommand=cmd(y,-160+15*na;zoomy,1;zoomx,115*2;diffuse,color("#000000"));
CurrentSongChangedMessageCommand=cmd(visible,GAMESTATE:GetCourseSongIndex()+2 > na);
};
};
end
end
t[#t+1] = Def.ActorFrame{
OnCommand=cmd(x,60;y,-188.5;z,50;zoom,0.08/0.2;rotationz,30;rotationx,-90);
LoadActor("TimeP")..{OnCommand=cmd(zoom,0.2);};
LoadFont("Common Normal")..{OnCommand=cmd(x,-30;zoom,1.2;horizalign,left;settext,SecondsToMMSS(Time);diffuse,color("#000000FF"));};};
t[#t+1] = LoadActor("Light")..{OnCommand=cmd(y,-188.5;zoom,SCREEN_RIGHT/1899.7361/1.03;zoomx,SCREEN_RIGHT/1899.7361/1.03+.0135;rotationx,-90);};
t[#t+1] = LoadActor("Zight")..{OnCommand=cmd(z,113;y,-188.5;vertalign,top;zoom,SCREEN_RIGHT/1900;zoomy,3);};
t[#t+1] = LoadActor("Yight")..{OnCommand=cmd(x,-224.7;y,-188.5;vertalign,top;zoom,SCREEN_RIGHT/1900;zoomy,6;zoomx,1/3+0.1;rotationy,-90);};
t[#t+1] = LoadActor("LAMP")..{OnCommand=cmd(x,100;y,-188.5;z,-55;zoom,0.15;rotationx,-90);};
return t; |
data:extend({
{
type = "string-setting",
setting_type = "runtime-per-user",
default_value = "red-green",
name = "wire-box-tool-mode",
allowed_values = { "red-green", "red-only", "green-only" },
}
}) |
--[[
Name: mailtruck.lua
For: TalosLife
By: TalosLife
]]--
local Job = {}
Job.ID = 7
Job.Enum = "JOB_MAIL"
Job.TeamColor = Color( 255, 100, 160, 255 )
Job.Name = "Carteiro"
Job.Cat = "Civis"
Job.Text = [[TEste de 1 linha
teste de 2 linhas
teste de 3 linhas
TEste de 1 linha
teste de 2 linhas
teste de 3 linhas
TEste de 1 linha
teste de 2 linhas
teste de 3 linhas
textotextotextotextotextotextotextotextotextotextotextotextotextotextotextotextotextotextotextotextotextotextotextotextotextotexto]];
Job.Pay = {
{ PlayTime = 0, Pay = 25 },
{ PlayTime = 4 *(60 *60), Pay = 40 },
{ PlayTime = 12 *(60 *60), Pay = 60 },
{ PlayTime = 24 *(60 *60), Pay = 95 },
}
Job.PlayerCap = { Min = 2, MinStart = 2, Max = 2, MaxEnd = 2 }
Job.TruckID = "mail_truck"
Job.MAX_BOXES = 10
Job.m_vecMailDepot = GM.Config.MailDepotPos
Job.ParkingLotPos = GM.Config.MailParkingZone
Job.TruckSpawns = GM.Config.MailCarSpawns
Job.m_tblMailPoints = GM.Config.MailPoints
if SERVER then
Job.m_tblTrucks = JOB_MAIL and GAMEMODE.Jobs:GetJobByID( JOB_MAIL ).m_tblTrucks or {}
end
function Job:OnPlayerJoinJob( pPlayer )
end
function Job:OnPlayerQuitJob( pPlayer )
local curCar = GAMEMODE.Cars:GetCurrentPlayerCar( pPlayer )
if curCar and curCar.Job and curCar.Job == JOB_MAIL then
curCar:Remove()
end
end
if SERVER then
function Job:PlayerLoadout( pPlayer )
end
function Job:OnPlayerSpawnMailTruck( pPlayer, entCar )
entCar:SetNWInt( "boxes", 0 )
entCar:SetSkin( 1 )
entCar.IsMailTruck = true
self.m_tblTrucks[entCar] = true
pPlayer:AddNote( "Seu caminhão foi spawnado!" )
end
function Job:GenerateMailPoint( entCar )
local point, idx = table.Random( self.m_tblMailPoints )
entCar:SetNWInt( "dest", idx )
entCar.MailDest = {
Pos = point.Pos,
Name = point.Name,
Pay = math.random( point.MinPrice, point.MaxPrice ),
}
end
function Job:MakePackage( entCar )
local dist = entCar:OBBCenter():Distance( entCar:OBBMaxs() ) +14
local tr = util.TraceLine{
start = entCar:GetPos() +(entCar:GetAngles():Right() *dist) +Vector(0, 0, 72),
endpos = entCar:GetPos() +(entCar:GetAngles():Right() *dist),
filter = pOwner,
}
local spawnPos = tr.HitPos
local ent = ents.Create( "ent_mail" )
ent:SetPos( spawnPos )
ent:SetAngles( Angle(0, 0, 0) )
ent:Spawn()
ent:Activate()
ent.ParentMailTruck = entCar
if IsValid( entCar.CurrentPackage ) then
entCar.CurrentPackage:Remove()
end
local vFlushPoint = spawnPos -(tr.HitNormal *512)
vFlushPoint = ent:NearestPoint( vFlushPoint )
vFlushPoint = ent:GetPos() -vFlushPoint
vFlushPoint = spawnPos +vFlushPoint +Vector(0, 0, 2)
ent:SetPos( vFlushPoint )
entCar:DeleteOnRemove( ent )
entCar.CurrentPackage = ent
end
function Job:ThinkMailDepot()
if not self.m_vecMailDepot then return end
if not self.m_intLastDepotThink then
self.m_intLastDepotThink = 0
end
if CurTime() < self.m_intLastDepotThink then return end
self.m_intLastDepotThink = CurTime() +1
for k, v in pairs( ents.FindInSphere(self.m_vecMailDepot, 100) ) do
if not IsValid( v ) or not v:IsVehicle() or not v.IsMailTruck then continue end
if v:GetNWInt( "boxes" ) < self.MAX_BOXES then
v:SetNWInt( "boxes", v:GetNWInt("boxes") +1 )
v:EmitSound( "physics/cardboard/cardboard_box_impact_soft".. math.random(1, 7).. ".wav" )
if not v.MailDest then
self:GenerateMailPoint( v )
end
end
end
end
function Job:ThinkDeliveryPoints()
if not self.m_intLastPointThink then
self.m_intLastPointThink = 0
end
if CurTime() < self.m_intLastPointThink then return end
self.m_intLastPointThink = CurTime() +1
for k, v in pairs( self.m_tblTrucks ) do
if not IsValid( k ) or not k.MailDest then continue end
for _, ent in pairs( ents.FindInSphere(k.MailDest.Pos, 64) ) do
if not IsValid( ent ) or not ent.ParentMailTruck then continue end
if ent.ParentMailTruck == k then
k:GetPlayerOwner():AddMoney( k.MailDest.Pay )
k:GetPlayerOwner():AddNote( "Você ganhou R$".. k.MailDest.Pay.. " por essa entrega!" )
ent:Remove()
k:SetNWInt( "boxes", k:GetNWInt("boxes") -1 )
if k:GetNWInt( "boxes" ) > 0 then
self:GenerateMailPoint( k )
else
k.MailDest = nil
k:SetNWInt( "dest", -1 )
end
end
end
end
end
hook.Add( "EntityRemoved", "RemoveMailTruck", function( eEnt )
if not IsValid( eEnt ) or not eEnt:IsVehicle() or not eEnt.IsMailTruck then return end
Job.m_tblTrucks[eEnt] = nil
end )
hook.Add( "PlayerUse", "UseMailTruck", function( pPlayer, eEnt )
if not GAMEMODE.Jobs:PlayerIsJob( pPlayer, JOB_MAIL ) then return end
if not IsValid( eEnt ) or not eEnt:IsVehicle() or not eEnt.IsMailTruck then return end
if eEnt:GetNWInt( "boxes" ) <= 0 then return end
local dot = (pPlayer:GetEyeTrace().HitPos -eEnt:GetPos()):GetNormal():Dot( eEnt:GetForward() )
if dot < -0.9 and CurTime() >(pPlayer.m_intLastUsedMailTruck or 0) then
Job:MakePackage( eEnt )
pPlayer.m_intLastUsedMailTruck = CurTime() +1
return false
end
end )
hook.Add( "Think", "ThinkMailTruck", function()
Job:ThinkMailDepot()
Job:ThinkDeliveryPoints()
end )
--Player wants to spawn a mail truck
function Job:PlayerSpawnMailTruck( pPlayer )
local car = GAMEMODE.Cars:PlayerSpawnJobCar( pPlayer, self.TruckID, self.TruckSpawns, self.ParkingLotPos )
if IsValid( car ) then
self:OnPlayerSpawnMailTruck( pPlayer, car )
end
end
--Player wants to stow their mail truck
function Job:PlayerStowMailTruck( pPlayer )
GAMEMODE.Cars:PlayerStowJobCar( pPlayer, self.ParkingLotPos )
end
else
hook.Add( "PostDrawTranslucentRenderables", "DrawMailJob", function()
if GAMEMODE.Jobs:GetPlayerJobID( LocalPlayer() ) ~= JOB_MAIL then return end
local veh = GAMEMODE.Cars:GetCurrentPlayerCar( LocalPlayer() )
local eye = LocalPlayer():EyeAngles()
local Ang = Angle( 0, EyeAngles().y -90, 90 )
--Draw mail depot
cam.Start3D2D( Job.m_vecMailDepot +Vector(0, 0, 128 +math.sin(CurTime()) *2), Ang, 0.25 )
draw.WordBox(2, -60, 0, "Retire aqui", "handcuffTextSmall", Color(0, 140, 0, 150), Color(255,255,255,255))
draw.SimpleText( "Carregue o caminhão aqui", "handcuffTextSmall", 0, 45, color_white, 1, 1 )
cam.End3D2D()
if not IsValid( veh ) then return end
if veh:GetNWInt( "dest" ) == -1 then return end
--Draw current destination
local dest = Job.m_tblMailPoints[veh:GetNWInt("dest")]
if not dest then return end
cam.Start3D2D( dest.Pos +Vector(0, 0, 32 +math.sin(CurTime()) *2), Ang, 0.25 )
draw.WordBox(2, -60, 0, "Entregue aqui", "handcuffTextSmall", Color(0, 140, 0, 150), Color(255,255,255,255))
draw.SimpleText( "Deixe o pacote aqui para completar a entrega", "handcuffTextSmall", 0, 45, color_white, 1, 1 )
cam.End3D2D()
end )
hook.Add( "HUDPaint", "DrawMailJob", function()
if GAMEMODE.Jobs:GetPlayerJobID( LocalPlayer() ) ~= JOB_MAIL then return end
local veh = GAMEMODE.Cars:GetCurrentPlayerCar( LocalPlayer() )
if not IsValid( veh ) then return end
local dest = Job.m_tblMailPoints[veh:GetNWInt("dest", -1)]
draw.SimpleTextOutlined(
"Restam: ".. veh:GetNWInt( "boxes" ) .." pacotes",
"handcuffTextSmall",
5,
5,
color_white,
TEXT_ALIGN_LEFT,
TEXT_ALIGN_LEFT,
1,
Color( 0, 0, 0, 255 )
)
if dest then
draw.SimpleTextOutlined(
"Destino da encomenda: ".. dest.Name,
"handcuffTextSmall",
5,
30,
color_white,
TEXT_ALIGN_LEFT,
TEXT_ALIGN_LEFT,
1,
Color( 0, 0, 0, 255 )
)
end
end )
end
GM.Jobs:Register( Job ) |
function vRP.admin_coords(user_id)
if user_id and vRP.hasPermission(user_id, permissions.player.coords) then
return vRPclient.getPosition(user_id)
end
end
function vRP.admin_kick(user_id, target_id, reason)
if user_id and vRP.hasPermission(parseInt(user_id), permissions.player.kick) then
local source_id = vRP.getUserSource(parseInt(target_id))
if source_id then
vRP.kick(source_id, reason)
return true
end
end
return false
end
function vRP.admin_revive(user_id, target_id)
if user_id and vRP.hasPermission(parseInt(user_id), permissions.player.revive) then
local playersToRevive = {}
local allPlayerTag = "-1"
if target_id then
if target_id ~= allPlayerTag then
table.insert(playersToRevive, target_id)
else
playersToRevive = vRP.getUsers()
end
else
table.insert(playersToRevive, user_id)
end
vRP.admin_revive_bulk(playersToRevive)
return true
end
return false
end
function vRP.admin_revive_bulk(listOfUsers)
local life = 400
for k, v in pairs(listOfUsers) do
local ids = vRP.getUserSource(k)
if ids then
vRPclient.setHealth(ids, life)
end
end
end
function vRP.admin_no_clip(user_id, target_id)
if user_id and vRP.hasPermission(parseInt(user_id), permissions.player.noclip) then
local noClipUser = user_id
if target_id then
noClipUser = target_id
end
vRPclient._toggleNoclip(vRP.getUserSource(noClipUser))
end
end
function vRP.admin_whitelist(user_id, target_id)
if user_id and vRP.hasPermission(user_id, permissions.admin.whitelist) then
vRP.setWhitelisted(target_id, true)
return true
end
return false
end
function vRP.admin_un_whitelist(user_id, target_id)
if user_id and vRP.hasPermission(user_id, permissions.admin.unwhitelist) then
vRP.setWhitelisted(target_id, false)
return true
end
return false
end
function vRP.admin_remove_group(user_id, target_id, group)
if user_id and vRP.hasPermission(user_id, permissions.admin.group_remove) then
if group then
vRP.removeUserGroup(target_id, group)
return true
end
end
return false
end
|
local option = { }
local blips = { }
local vehicleData = { }
local sx, sy = guiGetScreenSize ( )
local rSX, rSY = sx / 1280, sx / 1024
local Vehicles = guiCreateWindow( (sx-(rSX*470))-5, (sy-(rSY*260))-5, rSX*466, rSY*260, "Vehicles", false)
local cars = guiCreateGridList((rSX*11), (rSY*28), (rSX*274), (rSY*220), false, Vehicles)
option['show'] = guiCreateButton((rSX*295), (rSY*28), (rSX*162), (rSY*40), "Show", false, Vehicles)
option['recover'] = guiCreateButton((rSX*295), (rSY*28)+((rSY*40))+(rSY*5), (rSX*162), (rSY*40), "Recover", false, Vehicles)
option['sell'] = guiCreateButton((rSX*295), (rSY*28)+((rSY*40)*2)+(rSY*10), (rSX*162), (rSY*40), "Sell", false, Vehicles)
option['give'] = guiCreateButton((rSX*295), (rSY*28)+((rSY*40)*3)+(rSY*15), (rSX*162), (rSY*40), "Give", false, Vehicles)
option['close'] = guiCreateButton((rSX*295), (rSY*28)+((rSY*40)*4)+(rSY*20), (rSX*162), (rSY*40), "Close", false, Vehicles)
guiSetVisible ( Vehicles, false )
guiWindowSetSizable(Vehicles, false)
guiGridListAddColumn(cars, "ID", 0.15)
guiGridListAddColumn(cars, "Vehicle", 0.75)
guiGridListSetSortingEnabled ( cars, false )
local GiveWindow = guiCreateWindow( ( sx / 2 - 449 / 2 ), ( sy / 2 - 401 / 2 ), 449, 401, "Give Vehicle", false)
guiWindowSetSizable(GiveWindow, false)
guiSetVisible ( GiveWindow, false )
local gridGive = guiCreateGridList(9, 27, 430, 317, false, GiveWindow)
guiGridListAddColumn(gridGive, "Name", 0.9)
btnGiveGive = guiCreateButton(302, 354, 137, 33, "Give", false, GiveWindow)
btnGiveCancel = guiCreateButton(151, 354, 137, 33, "Cancel", false, GiveWindow)
bindKey ( "F2", "down", function ( )
if ( not exports['NGLogin']:isClientLoggedin ( ) ) then return end
local tos = not guiGetVisible ( Vehicles )
guiSetVisible ( Vehicles, tos )
showCursor ( tos )
guiGridListClear ( cars )
givingVehicle = nil
if ( tos ) then
reloadList ( )
for i, v in pairs ( option ) do
addEventHandler ( "onClientGUIClick", v, buttonClicking )
if ( i ~= 'close' ) then
guiSetEnabled ( v, false )
end
end
addEventHandler ( "onClientGUIClick", cars, buttonClicking )
addEventHandler ( "onClientGUIClick", btnGiveCancel, buttonClicking )
addEventHandler ( "onClientGUIClick", btnGiveGive, buttonClicking )
else
closeMenu ( )
end
end )
addEvent ( "NGVehicles:onServerSendClientVehicleList", true )
addEventHandler ( "NGVehicles:onServerSendClientVehicleList", root, function ( cList )
vehicleData = { }
guiGridListClear ( cars )
if ( #cList == 0 ) then
guiGridListSetItemText ( cars, guiGridListAddRow ( cars ), 2, "You have no vehicles.", true, true )
else
local impoundedVehicles = ""
for i, v in ipairs ( cList ) do
if ( v[11] == 0 ) then
local row = guiGridListAddRow ( cars )
guiGridListSetItemText ( cars, row, 1, tostring ( i ), false, true )
guiGridListSetItemText ( cars, row, 2, tostring ( getVehicleNameFromModel ( v[3] ) ), false, false )
guiGridListSetItemData ( cars, row, 1, v[2] )
table.insert ( vehicleData, v[2], v )
else
if ( impoundedVehicles == "" ) then
impoundedVehicles = getVehicleNameFromModel ( v[3] )
else
impoundedVehicles = impoundedVehicles..", "..getVehicleNameFromModel ( v[3] )
end
end
end
if ( impoundedVehicles ~= "" ) then
exports['NGMessages']:sendClientMessage ( "Vehicles: "..impoundedVehicles.." are impounded.", 255, 255, 0 )
end
end
end )
function buttonClicking ( )
if ( source == option['close'] ) then
closeMenu ( )
elseif ( source == cars ) then
local row, col = guiGridListGetSelectedItem ( cars )
if ( row ~= -1 ) then
for i, v in pairs ( option ) do guiSetEnabled ( v, true ) end
local index = guiGridListGetItemData ( source, row, 1 )
local visible = tonumber ( vehicleData[index][9] )
if ( visible == 1 ) then visible = true else visible = false end
if ( visible ) then
guiSetText ( option['show'], "Hide" )
vehicleData[index][9] = 1
else
guiSetText ( option['show'], "Show" )
vehicleData[index][9] = 0
end
else
for i,v in pairs ( option ) do
guiSetEnabled ( v, false )
if ( i == 'close' ) then
guiSetEnabled ( v, true )
elseif ( i == 'show' ) then
guiSetText ( v, 'Show' )
end
end
end
elseif ( source == option['show'] ) then
local row, col = guiGridListGetSelectedItem ( cars )
if ( row ~= -1 ) then
local index = guiGridListGetItemData ( cars, row, 1 )
local visible = tonumber ( vehicleData[index][9] )
if ( visible == 1 ) then visible = true else visible = false end
triggerServerEvent ( "NGVehicles:SetVehicleVisible", localPlayer, vehicleData[index][2], not visible )
if visible then
guiSetText ( source, "Show" )
vehicleData[index][9] = 0
else
guiSetText ( source, "Hide" )
vehicleData[index][9] = 1
end
end
elseif ( source == option['sell'] ) then
local row, col = guiGridListGetSelectedItem ( cars )
if ( row ~= -1 ) then
local index = guiGridListGetItemData ( cars, row, 1 )
local visible = tonumber ( vehicleData[index][9] )
if ( visible == 1 ) then visible = true else visible = false end
if ( visible ) then
return exports['NGMessages']:sendClientMessage ( "Hide your vehicle before you sell it.", 255, 255, 0 )
end
triggerServerEvent ( "NGVehicles:sellPlayerVehicle", localPlayer, localPlayer, index )
setTimer ( reloadList, 200, 1 )
end
elseif ( source == option['give'] ) then
local row, col = guiGridListGetSelectedItem ( cars )
if ( row ~= -1 ) then
local index = guiGridListGetItemData ( cars, row, 1 )
local visible = tonumber ( vehicleData[index][9] )
if ( visible == 1 ) then visible = true else visible = false end
if ( visible ) then
return exports['NGMessages']:sendClientMessage ( "Please hide the vehicle to send it.", 255, 0, 0 )
end
local vehID = vehicleData[index][2]
if ( vehID ) then
guiSetVisible ( GiveWindow, true )
guiBringToFront ( GiveWindow )
guiGridListClear ( gridGive )
givingVehicle = index
local count = 0
for i, v in ipairs ( getElementsByType ( 'player' ) ) do
if ( v ~= localPlayer ) then
guiGridListSetItemText ( gridGive, guiGridListAddRow ( gridGive ), 1, getPlayerName ( v ), false, false )
count = count + 1
end
end
if ( count == 0 ) then
guiGridListSetItemText ( gridGive, guiGridListAddRow ( gridGive ), 1, "Sorry, there are currently no players online.", true, true )
end
end
end
elseif ( source == btnGiveCancel ) then
guiSetVisible ( GiveWindow, false )
elseif ( source == btnGiveGive ) then
local row, col = guiGridListGetSelectedItem ( gridGive )
if ( row ~= -1 ) then
local pName = guiGridListGetItemText ( gridGive, row, 1 )
if ( not isElement ( getPlayerFromName ( pName ) ) ) then return exports['NGMessages']:sendClientMessage ( "Sorry, that player no longer exists.", 255, 0, 0 ) end
if ( vehicleData[givingVehicle][9] == 1 ) then return exports['NGMessages']:sendClientMessage ( "Hide the vehicle to give it.", 255, 0, 0 ) end
local vehicleID = vehicleData[givingVehicle][2]
triggerServerEvent ( "NGVehicles:onPlayerGivePlayerVehicle", localPlayer, vehicleID, getPlayerFromName ( pName ) )
guiSetVisible ( GiveWindow, false )
setTimer ( reloadList, 200, 1 )
else
exports['NGMessages']:sendClientMessage ( "Select a player to send your vehicle to.", 255, 0, 0 )
end
elseif ( source == option['recover'] ) then
local row, col = guiGridListGetSelectedItem ( cars )
if ( row == -1 ) then return end
local data = vehicleData[guiGridListGetItemData ( cars, row, 1 )]
if ( data[9] == 1 ) then return exports['NGMessages']:sendClientMessage ( "To recover your vehicle, please hide it first.", 255, 0, 0 ) end
triggerServerEvent ( "NGVehicles:AttemptRecoveryOnID", localPlayer, data[2] )
end
end
function closeMenu ( )
guiSetText ( option['show'], "Show" )
guiGridListClear ( cars )
guiSetVisible ( Vehicles, false )
showCursor ( false )
vehicleData = nil
for i, v in pairs ( option ) do
removeEventHandler ( "onClientGUIClick", v, buttonClicking )
guiSetEnabled ( v, false )
if ( i == 'close' ) then
guiSetEnabled ( v, true )
elseif( i == 'show' ) then
guiSetText ( v, "Show" )
end
end
removeEventHandler ( "onClientGUIClick", cars, buttonClicking )
removeEventHandler ( "onClientGUIClick", btnGiveCancel, buttonClicking )
removeEventHandler ( "onClientGUIClick", btnGiveGive, buttonClicking )
guiSetVisible ( GiveWindow, false )
end
function reloadList ( )
guiGridListClear ( cars )
guiGridListSetItemText ( cars, guiGridListAddRow ( cars ), 2, "Loading...", true, true )
triggerServerEvent ( "NGVehicles:onClientRequestPlayerVehicles", localPlayer )
for i, v in pairs ( option ) do
if ( i ~= 'close' ) then
guiSetEnabled ( v, false )
end
end
end
function getVehicleVisiable ( id )
local i = vehicleData[id][9]
if ( i == 1 ) then
return true
else
return false
end
end |
require 'Scripts/premake-config'
settings = { }
settings.workspace_name = 'Razix'
settings.bundle_identifier = 'com.Pikachuxxx'
outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
-- Current root directory where the global premake file is located
root_dir = os.getcwd()
-- Using the command line to get the selected architecture
Arch = ""
if _OPTIONS["arch"] then
Arch = _OPTIONS["arch"]
else
if _OPTIONS["os"] then
_OPTIONS["arch"] = "arm"
Arch = "arm"
else
_OPTIONS["arch"] = "x64"
Arch = "x64"
end
end
-- The Razix Engine Workspace
workspace ( settings.workspace_name )
location "build"
startproject "Sandbox"
flags 'MultiProcessorCompile'
-- Output directory path based on build config
outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
-- Binaries Output directory
targetdir ("bin/%{outputdir}/")
-- Intermediate files Output directory
objdir ("bin-int/%{outputdir}/obj/")
if Arch == "arm" then
architecture "ARM"
elseif Arch == "x64" then
architecture "x86_64"
elseif Arch == "x86" then
architecture "x86"
end
print("Generating Project files for Architecture = ", Arch)
-- Various build configuration for the engine
configurations
{
"Debug",
"Release",
"Distribution"
}
group "Dependencies"
require("Engine/vendor/imgui/premake5")
require("Engine/vendor/spdlog/premake5")
require("Engine/vendor/glfw/premake5")
require("Engine/vendor/cereal/premake5")
include "Tools/premake/premake5"
group ""
-- Build Script for Razix Engine
include "Engine/premake5"
-- Build script for Sandbox
include "Sandbox/premake5"
|
-- Author: Neel Basak
-- Github: https:/github.com/Neelfrost
-- File: init.lua
-- Colorscheme
SCHEME = "nightlamp"
-- Language servers
SERVERS = { "pyright", "sumneko_lua", "omnisharp", "html", "cssls", "eslint", "emmet_ls" }
-- Treesitter parsers
PARSERS = { "comment", "python", "lua", "c_sharp", "html", "css", "javascript", "yaml", "json" }
-- Plugin filetypes
PLUGINS = { "packer", "alpha", "neo-tree" }
-- Paths
HOME_PATH = vim.fn.expand("$HOME")
CONFIG_PATH = vim.fn.stdpath("config")
PACKER_PATH = vim.fn.stdpath("data") .. "\\site\\pack\\packer"
-- Linting icons
ICON_ERROR = "E"
ICON_WARN = "W"
ICON_INFO = "I"
ICON_HINT = "H"
-- Improve startuptime using impatient
require("user.plugins.config.impatient")
-- Configuration files
vim.cmd("source ~/AppData/Local/nvim/viml/utils.vim")
vim.cmd("source ~/AppData/Local/nvim/viml/autocommands.vim")
require("user.autocmds")
require("user.options")
require("user.utils")
require("user.mappings")
require("user.plugins")
|
local nativeutils = {}
-- helpers for native rust libraries
local accesslog = require "lua.accesslog"
local log_request = accesslog.envoy_log_request
local cjson = require "cjson"
function nativeutils.trim(s)
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
end
function nativeutils.startswith(str, arg)
if str and arg and type(str) == "string" and type(arg) == "string" then
return string.find(str, arg, 1, true) == 1
end
end
function nativeutils.endswith(str, arg)
if str and arg then
return string.find(str, arg, #str - #arg + 1, true) == #str - #arg + 1
end
end
-- source http://lua-users.org/wiki/SplitJoin
function nativeutils.split(input, sSeparator, nMax, bRegexp)
local aRecord = {}
if sSeparator ~= '' then
if (nMax == nil or nMax >= 1)then
if input ~= nil then
if input:len() > 0 then
local bPlain = not bRegexp
nMax = nMax or -1
local nField=1
local nStart=1
local nFirst,nLast = input:find(sSeparator, nStart, bPlain)
while nFirst and nMax ~= 0 do
aRecord[nField] = input:sub(nStart, nFirst-1)
nField = nField+1
nStart = nLast+1
nFirst,nLast = input:find(sSeparator, nStart, bPlain)
nMax = nMax-1
end
aRecord[nField] = input:sub(nStart)
end
end
end
end
return aRecord
end
function nativeutils.map_fn (T, fn)
T = T or {}
local ret = {}
for _, v in ipairs(T) do
local new_value = fn(v)
table.insert(ret, new_value)
end
return ret
end
function nativeutils.nginx_custom_response(request_map, action_params)
if not action_params then action_params = {} end
local block_mode = action_params.block_mode
-- if not block_mode then block_mode = true end
local handle = request_map.handle
if action_params["headers"] and action_params["headers"] ~= cjson.null then
for k, v in pairs(action_params["headers"]) do
handle.header[k] = v
end
end
if action_params["status"] then
local raw_status = action_params["status"]
local status = tonumber(raw_status) or raw_status
handle.status = status
end
handle.log(handle.ERR, cjson.encode(action_params))
if block_mode then
if action_params["content"] then handle.say(action_params["content"]) end
handle.exit(handle.HTTP_OK)
end
end
function nativeutils.log_nginx_messages(handle, logs)
for _, log in ipairs(logs) do
local level = log["level"]
local msg = log["elapsed_micros"] .. "µs " .. log["message"]
if level == "debug" then
handle.log(handle.DEBUG, msg)
elseif level == "info" then
handle.log(handle.INFO, msg)
elseif level == "warning" then
handle.log(handle.WARN, msg)
elseif level == "error" then
handle.log(handle.ERR, msg)
else
handle.log(handle.ERR, "Can't log this message: " .. cjson.encode(logs))
end
end
end
function nativeutils.envoy_custom_response(request_map, action_params)
if not action_params then action_params = {} end
local block_mode = action_params.block_mode
-- if not block_mode then block_mode = true end
local response = {
[ "status" ] = "503",
[ "headers"] = { ["x-curiefense"] = "response" },
[ "reason" ] = { initiator = "undefined", reason = "undefined"},
[ "content"] = "curiefense - request denied"
}
-- override defaults
if action_params["status" ] then response["status" ] = action_params["status" ] end
if action_params["headers"] and action_params["headers"] ~= cjson.null then
response["headers"] = action_params["headers"]
end
if action_params["reason" ] then response["reason" ] = action_params["reason" ] end
if action_params["content"] then response["content"] = action_params["content"] end
response["headers"][":status"] = response["status"]
request_map.attrs.blocked = true
request_map.attrs.block_reason = response["reason"]
if block_mode then
log_request(request_map)
request_map.handle:respond( response["headers"], response["content"])
end
end
function nativeutils.log_envoy_messages(handle, logs)
for _, log in ipairs(logs) do
local level = log["level"]
local msg = log["elapsed_micros"] .. "µs " .. log["message"]
if level == "debug" then
handle:logDebug(msg)
elseif level == "info" then
handle:logInfo(msg)
elseif level == "warning" then
handle:logWarn(msg)
elseif level == "error" then
handle:logErr(msg)
else
handle:logErr("Can't log this message: " .. cjson.encode(logs))
end
end
end
return nativeutils |
-- Shared GUI components for any interfaces (Concert and Androad)
local draw = require("OCX/OCDraw")
local width, height = require("driver").gpu.getResolution()
local lib = {}
function lib.getWidth()
return width
end
function lib.getHeight()
return height
end
function lib.lerp(t, a, b)
return t * b + (1 - t) * a
end
function lib.lerpRGB(t, a, b)
local aR = bit32.band(bit32.rshift(a, 16), 0xFF)
local aG = bit32.band(bit32.rshift(a, 8), 0xFF)
local aB = bit32.band(a, 0xFF)
local bR = bit32.band(bit32.rshift(b, 16), 0xFF)
local bG = bit32.band(bit32.rshift(b, 8), 0xFF)
local bB = bit32.band(b, 0xFF)
local r = lib.lerp(t, aR, bR)
local g = lib.lerp(t, aG, bG)
local b = lib.lerp(t, aB, bB)
return bit32.bor(
bit32.lshift(r, 16),
bit32.lshift(g, 8),
b
)
end
function lib.component()
local comp = {}
comp.context = nil
comp.x = 1
comp.y = 1
comp.width = 1
comp.height = 1
comp.background = 0xFFFFFF
comp.foreground = 0x000000
comp.listeners = {}
comp.clip = nil
comp.dirty = true
-- Returns true if the contetx has been re-created
function comp:initRender()
local mustReupdate = false
if self.context and not draw.isContextOpened(self.context) then
print(tostring(self.context) .. " doesn't exist!")
self.context = nil
end
if self.context ~= nil then
local x,y,w,h = draw.getContextBounds(self.context)
if x~=self.x or y~=self.y or w~=self.width or h~=self.height then
draw.moveContext(self.context, self.x, self.y)
if w~=self.width or h~=self.height then
draw.closeContext(self.context)
if self.invalidatedContext then
self:invalidatedContext()
end
self.context = nil
end
end
end
if self.context == nil then
local parentContext = (self.parent and self.parent.context) or nil
--[[if config.accelerationMethod == 1 then -- full usage of VRAM
parentContext = nil
end]]
self.context = draw.newContext(self.x, self.y, self.width, self.height, 0, parentContext)
self.canvas = draw.canvas(self.context)
if self.clip then
draw.clipContext(self.context, self.clip)
end
return true
end
if self.clip then
draw.clipContext(self.context, self.clip)
end
return false
end
-- Call this method if you want to draw a component to screen but don't need it to be up-to-date.
function comp:redraw()
if self.dirtyUpdate then -- function for containers so they can set themselves dirty if a child is dirty
self:dirtyUpdate()
end
if self.parent and self.parent.context and not self.parent.rendering and self.dirty then
self.parent:redraw()
return
end
if self.context ~= nil then
local x,y,w,h = draw.getContextBounds(self.context)
if x ~= self.x or y ~= self.y then
draw.moveContext(self.context, self.x, self.y)
end
if w ~= self.width or h ~= self.height then
draw.closeContext(self.context)
if self.invalidatedContext then
self:invalidatedContext()
end
self.context = nil
end
end
if self.context == nil or self.dirty == true then -- context has been (re-)created, previous data is lost
self.dirty = false
self:render()
else
if self.clip then
draw.clipContext(self.context, self.clip)
end
draw.redrawContext(self.context) -- can benefit of optimization if GPU buffers are present
end
end
function comp:render()
self.rendering = true
self:initRender()
self:_render()
draw.drawContext(self.context)
self.rendering = false
end
-- This function should not be called directly
function comp:_render()
error("component should implement the _render() function")
end
function comp:dispose(recursive)
if self.context then
draw.closeContext(self.context)
self.context = nil
end
if recursive == true and self.childrens then
for k, v in pairs(self.childrens) do
v:dispose(true)
end
end
end
return comp
end
-- Each component is on its own line
function lib.LineLayout(opts)
return function(container)
local flowY = 1
for _, child in pairs(container.childrens) do
child.y = flowY
flowY = flowY + child.height + (opts.spacing or 0)
end
end
end
function lib.container()
local comp = lib.component()
comp.childrens = {}
comp.layout = function(self) end -- no-op = fixed layout
comp.add = function(self, component, pos)
if not component then
error("cannot add null to container")
end
component.parent = self
return table.insert(self.childrens, pos or (#self.childrens+1), component)
end
comp._render = function(self)
self:layout()
self.canvas.fillRect(1, 1, self.width, self.height, self.background)
draw.setBlockingDraw(self.context, true)
draw.drawContext(self.context) -- just flush the background clear
for _, c in pairs(self.childrens) do
c.x = c.x + self.x - 1
c.y = c.y + self.y - 1
c:redraw()
c.x = c.x - self.x + 1
c.y = c.y - self.y + 1
end
draw.setBlockingDraw(self.context, false)
end
comp.dirtyUpdate = function(self)
for _, c in pairs(self.childrens) do
if c.dirtyUpdate then c:dirtyUpdate() end
if c.dirty then
self.dirty = true
end
end
end
comp.invalidatedContext = function(self)
for _, c in pairs(self.childrens) do
if c.context then
draw.closeContext(c.context)
if c.invalidatedContext then
c:invalidatedContext()
end
c.context = nil
end
end
end
comp.listeners["touch"] = function(self, id, addr, x, y, ...)
self.focused = nil
for _, child in pairs(comp.childrens) do
local cx = child.x
local cy = child.y
if x >= cx and y >= cy and x < cx + child.width and y < cy + child.height then
self.focused = child
end
end
self.listeners["*"](self, id, addr, x, y, ...)
end
comp.listeners["*"] = function(self, ...)
local id = select(1, ...)
if self.focused then
if self.focused.listeners[id] then
self.focused.listeners[id](self.focused, ...)
elseif self.focused.listeners["*"] then
self.focused.listeners["*"](self.focused, ...)
end
end
end
return comp
end
function lib.label(text)
local comp = lib.component()
comp.text = text or "Label"
comp.width = comp.text:len()
comp._render = function(self)
self.canvas.drawText(1, 1, self.text, self.foreground, self.background) -- draw text
end
comp.setText = function(self, text)
self.text = text
self.width = text:len()
self.dirty = true
end
return comp
end
function lib.button(label, onAction)
local comp = lib.component()
comp.background = 0x2D2D2D
comp.foreground = 0xFFFFFF
comp.label = label or "Button"
comp.width = comp.label:len()
comp.onAction = onAction
comp._render = function(self)
self.canvas.drawText(1, 1, " " .. self.label .. " ", self.foreground, self.background) -- draw button
end
comp.setText = function(self, label)
self.label = label
self.dirty = true
end
comp.listeners["touch"] = function(self, ...)
self.onAction()
end
return comp
end
function lib.checkBox(label, onChanged)
local comp = lib.component()
comp.label = label or "Check Box"
comp.width = comp.label:len() + 2
comp.onChanged = onChanged
comp.active = false
comp._render = function(self)
local check = unicode.char(0x2B55)
if self.active then check = unicode.char(0x2B24) end
self.canvas.drawText(1, 1, check .. " " .. self.label, self.foreground, self.background)
end
comp.setText = function(self, label)
self.label = label
self.width = label:len() + 4
self.dirty = true
end
comp.listeners["touch"] = function(self, ...)
self.active = not self.active
self.dirty = true
self:onChanged(self.active)
self:redraw()
end
return comp
end
function lib.progressBar(maxProgress)
local pb = lib.component()
pb.progress = 0
pb.foreground = 0x00FF00
pb._render = function(self)
end
return pb
end
function lib.tabBar()
local comp = lib.container()
comp.currentTab = 1
comp.tabNames = {}
function comp:addTab(tab, name)
checkArg(1, tab, "table")
checkArg(2, name, "string")
local idx = #self.childrens + 1
self:add(tab)
self.tabNames[idx] = name
end
function comp:switchTo(index)
self.currentTab = index
self.dirty = true
self:redraw()
end
function comp:render()
-- Draw tab bar
local oldHeight = self.height
--self.height = 1
self:initRender()
self.canvas.fillRect(1, 1, self.width, 1, self.background)
local x = 1
for k, v in ipairs(comp.tabNames) do
local color = lib.lerpRGB(0.6, self.background, self.foreground)
if self.currentTab == k then
color = self.foreground
end
self.canvas.drawText(x, 1, v, color)
x = x + v:len() + 1
end
draw.drawContext(self.context)
--self.height = oldHeight
if not self.childrens[self.currentTab] then
self.currentTab = 1
end
local tab = self.childrens[self.currentTab]
if tab then
tab.x = self.x
tab.y = self.y + 1
tab.width = self.width
tab.height = self.height - 1
tab:render()
tab.x = 1
tab.y = 1
end
end
comp.listeners["touch"] = function(self, _, screenAddress, x, y, button, playerName)
if y == 1 then -- tab bar
local tx = 1
for k, v in ipairs(self.tabNames) do
if x >= tx and x < tx + v:len() then
self:switchTo(k)
self:redraw()
break
end
tx = tx + v:len() + 1
end
end
end
return comp
end
function lib.menuBar()
local comp = lib.container()
local super = comp.render
comp._render = function(self)
if self.parent then
self.width = self.parent.width
end
super(self)
end
comp.background = 0xC2C2C2
return comp
end
return lib
|
natures_bloom = {
cast = function(player)
local aethers = 625000
local magicCost = 200
if (not player:canCast(1, 1, 0)) then
return
end
if player.magic < magicCost then
player:sendMinitext("Your will is too weak.")
return
end
player:sendAction(6, 25)
player.magic = player.magic - magicCost
player:sendStatus()
player:setAether("natures_bloom", aethers)
end,
uncast = function(player)
player.fakeDrop = 0
end,
on_drop_while_aether = function(player)
local item = player:getInventoryItem(player.invSlot)
local flowers = {
"daffodil",
"dawn_tulip",
"dusk_blossom",
"fallen_star",
"golden_sunset",
"greater_tulip",
"heavens_bell",
"lemon_flower",
"mango_floret",
"midnights_reign",
"old_poppy",
"orange_blossom",
"pink_mugunghwa",
"rose",
"sunflower",
"winedrop"
}
local flower = ""
for i = 1, #flowers do
if item.yname == flowers[i] then
flower = flowers[i]
break
end
end
if flower ~= "" then
-- found flower and item name matches
player:removeItem(item.yname, 1, 1)
player.fakeDrop = 1
natures_bloom.spawnFlowers(player, flower)
else
player.fakeDrop = 0
end
end,
spawnFlowers = function(player, flower)
local distance = 4
player:dropItemXY(flower, 1, 0, 0, player.m, player.x, player.y)
for y = player.y - distance, player.y + distance do
for x = player.x - distance, player.x + distance do
if y < 0 then
y = 0
end
if x < 0 then
x = 0
end
if y > getMapYMax(player.m) then
y = getMapYMax(player.m)
end
if x > getMapXMax(player.m) then
x = getMapXMax(player.m)
end
--local blockCheck = player:getObjectsInCell(player.m,x,y,BL_ALL)
local objCheck = getObject(player.m, x, y)
local passCheck = getPass(player.m, x, y)
local warpCheck = getWarp(player.m, x, y)
if objCheck == 0 and passCheck == 0 and not warpCheck then
-- tile is clear
if math.random(1, 2) == 1 then
player:dropItemXY(flower, 1, 0, 0, player.m, x, y)
end
end
end
end
end,
requirements = function(player)
local level = 99
local items = {"wicked_staff", "antler", 0}
local itemAmounts = {1, 20, 20000}
local description = "Erupt flames from the ground to protect you."
return level, items, itemAmounts, description
end
}
|
--------------------------------
-- @module RelativeBox
-- @extend Layout
-- @parent_module ccui
--------------------------------
-- @overload self, size_table
-- @overload self
-- @function [parent=#RelativeBox] create
-- @param self
-- @param #size_table size
-- @return RelativeBox#RelativeBox ret (return value: ccui.RelativeBox)
--------------------------------
-- Default constructor
-- @function [parent=#RelativeBox] RelativeBox
-- @param self
-- @return RelativeBox#RelativeBox self (return value: ccui.RelativeBox)
return nil
|
<<<<<<< HEAD
----------------------------------------------------------------------------------------
--five.lua Creates object shaped like the number 5
----------------------------------------------------------------------------------------
local five = {
object = nil,
originalColor = { Red = 0, Green = 0, Blue = 0 },
hasAttribute = nil,
inPosition = nil,
"five",
"odd",
"prime"
}
local useAttributes = require "attributes"
--function createCircle displays five object and initializes five.hasAttrube
--based on currentAttribute in shapes.lua.
function five.createFive( x, y, scaler, currentAttribute )
x = x or display.contentCenterX
y = y or display.contentCenterY
scaler = scaler * 7 or 7
--coordinates to make five shape
local fiveShape = { -3*scaler,-11*scaler, -6*scaler,1*scaler, 2*scaler,1*scaler, 1*scaler,5*scaler, -7*scaler,5*scaler, -8*scaler,9*scaler, 4*scaler,9*scaler, 7*scaler,-3*scaler, -1*scaler,-3*scaler, 0,-7*scaler, 8*scaler,-7*scaler, 9*scaler,-11*scaler }
five.object = display.newPolygon( x, y, fiveShape )
Red = 2
Green = 7
Blue = 0
five.originalColor.Red = Red
five.originalColor.Green = Green
five.originalColor.Blue = Blue
five.object:setFillColor( Red, Green, Blue ) -- fill the five with color
--five.object.strokeWidth = 0.016 * display.contentWidth -- Sets the width of the border of five
--Set Stroke color
five.object:setStrokeColor( 128, 0, 128 ) -- Sets the border color
five.object:addEventListener( "touch", five.move )
five.object.alpha = 0.7 --five opacity
--check if five has attributes.currentAttribute (in attributes.lua table)
print( "Checking five Attributes" )
local test = false
for index, attribute in ipairs(five) do
print("checking ", index, attribute)
if attribute == currentAttribute then
test = true
print("five Has Attribute")
end
end
five.hasAttribute = test
--initialize attributes.hasAttribute if no value set it to true
return five
end --createFive function
--Move shapes function
function five.move( event )
--eventt.target comes from EventListener and is the object the "touch" is targeting
local object = event.target
local touchDistance = object.width
--Move shape
if math.abs( object.x - event.x ) < touchDistance and math.abs( object.y - event.y ) < touchDistance then
object.x = event.x
object.y = event.y
end
--Change color if five is in position and has attribute
if useAttributes.isShapeWithinRadius( object, .85 * display.contentCenterX, display.contentCenterX, display.contentCenterY) then
if five.hasAttribute then
--change color to green
object:setFillColor( 0, 128 , 0)
else
--change color to red
object:setFillColor( 128, 0 , 0 )
end
five.inPosition = true
else
object:setFillColor( five.originalColor.Red, five.originalColor.Green, five.originalColor.Blue )
five.inPosition = false
end
end --end move function
=======
----------------------------------------------------------------------------------------
--five.lua Creates object shaped like the number 5
----------------------------------------------------------------------------------------
local five = {
object = nil,
originalColor = { Red = 0, Green = 0, Blue = 0 },
hasAttribute = nil,
inPosition = false,
"five",
"odd",
"prime"
}
local useAttributes = require "attributes"
--function createCircle displays five object and initializes five.hasAttrube
--based on currentAttribute in shapes.lua.
function five.createFive( x, y, scaler, currentAttribute )
x = x or display.contentCenterX
y = y or display.contentCenterY
scaler = scaler * 7 or 7
--coordinates to make five shape
local fiveShape = { -3*scaler,-11*scaler, -6*scaler,1*scaler, 2*scaler,1*scaler, 1*scaler,5*scaler, -7*scaler,5*scaler, -8*scaler,9*scaler, 4*scaler,9*scaler, 7*scaler,-3*scaler, -1*scaler,-3*scaler, 0,-7*scaler, 8*scaler,-7*scaler, 9*scaler,-11*scaler }
five.object = display.newPolygon( x, y, fiveShape )
Red = 2
Green = 7
Blue = 0
five.originalColor.Red = Red
five.originalColor.Green = Green
five.originalColor.Blue = Blue
five.object:setFillColor( Red, Green, Blue ) -- fill the five with color
--five.object.strokeWidth = 0.016 * display.contentWidth -- Sets the width of the border of five
--Set Stroke color
five.object:setStrokeColor( 128, 0, 128 ) -- Sets the border color
five.object:addEventListener( "touch", five.move )
five.object.alpha = 0.7 --five opacity
--check if five has attributes.currentAttribute (in attributes.lua table)
print( "Checking five Attributes" )
local test = false
for index, attribute in ipairs(five) do
print("checking ", index, attribute)
if attribute == currentAttribute then
test = true
print("five Has Attribute")
end
end
five.hasAttribute = test
--initialize attributes.hasAttribute if no value set it to true
return five
end --createFive function
--Move shapes function
function five.move( event )
--eventt.target comes from EventListener and is the object the "touch" is targeting
local object = event.target
local touchDistance = object.width
--Move shape
if math.abs( object.x - event.x ) < touchDistance and math.abs( object.y - event.y ) < touchDistance then
object.x = event.x
object.y = event.y
end
--Change color if five is in position and has attribute
if useAttributes.isShapeWithinRadius( object, .85 * display.contentCenterX, display.contentCenterX, display.contentCenterY) then
if five.hasAttribute then
--change color to green
object:setFillColor( 0, 128 , 0)
else
--change color to red
object:setFillColor( 128, 0 , 0 )
end
five.inPosition = true
else
object:setFillColor( five.originalColor.Red, five.originalColor.Green, five.originalColor.Blue )
five.inPosition = false
end
end --end move function
>>>>>>> windows_testing
return five |
local _SYS = {}
-- ERRORS:
local er = require('lib/error')
_SYS = er.errify(_SYS, {
['E_CORE_PIDNOEXIST'] = 'No such PID',
['E_CORE_NOACTORS'] = 'All actors have halted',
['E_CORE_NOPIDS'] = 'PID count exhausted',
})
-- Host constants:
_SYS.HOST_OC = "OpenComputers"
_SYS.HOST_CC = "ComputerCraft"
_SYS.HOST_OTHER = "UNKNOWN"
--[[
Yield calls provide a means to communicate with the scheduler without having
access to the scheduler's environment directly. It also helps ensure that
any program that does anything 'useful' is less likely to block execution of
other actors. There are only 7 primitive yield calls: quit(), send(), recv(),
wake(), sub(), unsub(), and spawn():
quit(): nil :: Decomposes an actor
send(pid:number, ...): nil :: Sends a message to an actor
recv(): ... :: Receives a message rom an actor
wake(pid:number): nil :: Wakes up an actor.
sub(event:string, filter:function) :: Subscribe to an event, filter optional
unsub(event:string) :: Unsubscribes from an event
]]
_SYS.YC_QUIT = 100
_SYS.YC_SEND = 110
_SYS.YC_WUP = 120
_SYS.YC_RECV = 130
_SYS.YC_SPWN = 140
_SYS.YC_SUB = 150
_SYS.YC_USUB = 160
function _SYS.quit() yield(_SYS.YC_QUIT) end
function _SYS.send(pid, ...) yield(_SYS.YC_SEND, pid, ...) end
function _SYS.wake(pid) yield(_SYS.YC_WUP, pid) end
function _SYS.recv() yield(_SYS.YC_RECV) end
function _SYS.sub(event) yield(_SYS.YC_SUB, event, fn) end
function _SYS.unsub(event) yield(_SYS.YC_USUB, event) end
function _SYS.spawn(code, sopts, ...) yield(_SYS.YC_SPWN, code, sopts, ...) end
return _SYS
|
local helper = require("thetto.lib.testlib.helper")
describe("git/status source", function()
before_each(helper.before_each)
after_each(helper.after_each)
it("can show status files", function()
helper.new_file("test_file")
helper.sync_open("git/status", {opts = {insert = false}})
assert.exists_pattern("?? " .. helper.test_data_path)
end)
end)
|
return require("lapis.db.postgres.model")
|
--[[
MIT License
Copyright (c) 2019 SotADB.info
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.
]]
function infosotadbUpdatePool()
local adv = ShroudGetPooledAdventurerExperience()
local prod = ShroudGetPooledProducerExperience()
sotadbinfoAdv.push(adv - sotadbinfoAdvLast)
sotadbinfoProd.push(prod - sotadbinfoProdLast)
sotadbinfoAdvLast = adv
sotadbinfoProdLast = prod
local AdvAtt = ShroudGetAttenuationAdventurerStatus() and '*' or ' '
local ProdAtt = ShroudGetAttenuationProducerStatus() and '*' or ' '
sotadbinfoPoolOutput = string.format("%s Adv Pool: %s @ %s/h\n%sProd Pool: %s @ %s/h",
AdvAtt, comma_value(adv), comma_value(sotadbinfoAdv.sAve()),
ProdAtt, comma_value(prod), comma_value(sotadbinfoProd.sAve()))
end
function comma_value(n) -- credit http://richard.warburton.it
local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
end
function ShroudOnUpdate()
--Work around bugs
end
function ShroudOnConsoleInput()
--Work around bugs
end
function ShroudOnStart()
ShroudRemovePeriodic("infosotadb.UpdatePool")
sotadbinfoAdv = sotadbinfoXPTnew()
sotadbinfoProd = sotadbinfoXPTnew()
sotadbinfoAdvLast = ShroudGetPooledAdventurerExperience()
sotadbinfoProdLast = ShroudGetPooledProducerExperience()
infosotadbUpdatePool()
ShroudRegisterPeriodic("infosotadb.UpdatePool", "infosotadbUpdatePool", 1, true)
sotadbinfoPoolX = ShroudGetScreenX() - 300
sotadbinfoPoolY = ShroudGetScreenY() - 50
end
function ShroudOnGUI()
ShroudGUILabel(sotadbinfoPoolX, sotadbinfoPoolY, 300, 50, sotadbinfoPoolOutput)
end
function sotadbinfoXPTnew ()
local self = {first = 0, last = -1, tot = 0, list={}}
local time = 3600
local push = function (v)
local last = self.last + 1
self.last = last
self.list[last] = v
local tot = self.tot + v
self.tot = tot
if self.last - self.first > time then
local tot = self.tot - self.list[self.first]
self.tot = tot
self.list[self.first] = nil
local first = self.first + 1
self.first = first
end
end
local sAve = function () return math.floor((self.tot / ( 1 + self.last - self.first ))*3600) end
local peek = function () return self.list[self.last] end
return {push = push, sAve = sAve, peek = peek}
end |
distraction = {
link = sprite('zeldal.png'),
enemy = sprite('zeldae.png'),
}
function distraction:reset()
self.y = math.random(50, 800);
self.fear = nil
end
function distraction:draw(time)
local origtime = time;
time = math.floor(time * 5);
local x = -100 + time*50
local i = (time) % 4
local pos = { 0, 149, 0, 2*149 }
local pos2 = { 0, 149, 0, 149 }
local sy = pos[math.floor(i) + 1]
local sy2 = pos2[math.floor(i) + 1]
self.enemy.blit(140, sy2, 140, 112, 1920 - x, self.y);
if (not self.fear) then
if ((1920 - x - x) < 300) then
self.fear = x + time * 50;
end
end
if (self.fear) then
x = self.fear - time*50;
self.link.blit(140, sy, 140, 112, x, self.y);
else
self.link.blit(420, sy, 140, 112, x, self.y);
end
end
|
--
-- 用于在 Windows 系统下安装 Node.lua 运行环境,包括可执行文件及相关的 Lua 模块
-- Install the Node.lua runtime environment.
-- Include executables and related Lua module.
--
local luv = require('luv')
local lutils = require('lutils')
local function updatePackagePath()
local cwd = luv.cwd()
local path = package.path
path = path .. ';' .. cwd .. '\\core\\lua\\?.lua;' .. cwd .. '\\core\\lua\\?\\init.lua'
package.path = path
-- print(path)
end
local function printPathList(title, pathList)
local tokens = pathList:split(';')
print(title)
for k, v in pairs(tokens) do
print(k, v)
end
print('------ end list ------\n')
end
-- Update current user 'Path' environment variable (Windows Only)
local function updatePathEnvironment()
local init = require('init')
local path = require('path')
local fs = require('fs')
local cwd = luv.cwd()
local pathname = path.join(cwd, 'bin')
if (not fs.existsSync(pathname)) then
return
end
-- Query the value of 'HKEY_CURRENT_USER\\Environment\\Path'
local tokens = nil
local file = io.popen('REG QUERY HKEY_CURRENT_USER\\Environment /v Path')
if (file) then
local result = file:read("*all")
if (result) then
tokens = result:split('\n') or {}
end
io.close(file)
end
if (not tokens) then
return
end
local pos = 3
for index, token in pairs(tokens) do
if (token:startsWith('HKEY_CURRENT_USER')) then
pos = index + 1
break
end
end
-- KEY TYPE VALUE
local line = tokens[pos] or ""
local _, offset, key, mode, oldPath = line:find("[ ]+([^ ]+)[ ]+([^ ]+)[ ]+([^\n]+)")
local items = {}
if (oldPath) then
items = oldPath:split(';') or {}
end
-- tokens
local paths = {}
for index, token in pairs(items) do
token = token:trim()
if (#token > 0) then
local filename = path.join(token, "lnode.exe")
if (not fs.existsSync(filename)) then
table.insert(paths, token)
end
end
end
table.insert(paths, pathname)
-- update PATH
local newPath = table.concat(paths, ";")
if (oldPath ~= newPath) then
os.execute('SETX PATH "' .. newPath .. '"')
printPathList("SETX PATH=", newPath)
end
end
-------------------------------------------------------------------------------
local osType = lutils.os_platform()
local osArch = lutils.os_arch()
local cwd = luv.cwd()
print('')
print('------ Install Node.lua Runtime -------')
print('OS: [' .. osType .. ']')
print('Arch: [' .. osArch .. ']')
print('Work: [' .. cwd .. ']')
print('------\n')
if (osType ~= 'win32') then
print('Error: Current system is not Windows.')
else
-- Add the bin directory under the current directory to the system Path environment variable
updatePackagePath()
updatePathEnvironment()
print('Install Complete!\n')
end
luv.run()
luv.loop_close()
|
local beautiful = require("beautiful")
local textbox = require("wibox.widget.textbox")
local underline = require("widgets.underline")
local brightness_daemon = require("daemons.brightness")
local signal_name = brightness_daemon.signal_name
local brightness = {}
local function new(args)
local color = beautiful.widget_brightness_color or beautiful.widget_color or beautiful.fg_normal or "#FFFFFF"
local textbox_widget = textbox("")
local widget = underline(textbox_widget, color)
local function handler(success, err)
if err ~= nil then
return
end
local markup = string.format("<span foreground='%s'><b>BRI</b></span> %d%%", color, success.level * 100)
textbox_widget:set_markup(markup)
widget:set_color(color)
end
handler({ level = 0 })
-- setmetatable(widget, {
-- __gc = function()
-- awesome.disconnect_signal(signal_name, handler)
-- end
-- })
awesome.connect_signal(signal_name, handler)
return widget
end
return setmetatable(brightness, { __call = function(_, ...) return new(...) end })
|
-- Gets a msgpacked root and returns it as JSON
local mp = redis.call('GET', KEYS[1])
local v = cmsgpack.unpack(mp)
local js = cjson.encode(v)
return js |
local WORLD_WG = "Wintergrasp"
local WORLD_TB = "Tol Barad"
local BG_BFG = "The Battle for Gilneas"
local BG_TP = "Twin Peaks"
local BG_AB = "Arathi Basin"
local BG_WG = "Warsong Gulch"
local BG_WGA = "Silverwing Hold"
local BG_WGH = "Warsong Lumber Mill"
local BG_EOTS = "Eye of the Storm"
local BG_AV = "Alterac Valley"
local BG_IOC = "Isle of Conquest"
local BG_SOTA = "Strand of the Ancients"
local BG_SLVSM = "Silvershard Mines"
local BG_TOK = "Temple of Kotmogu"
local BG_DG = "Deepwind Gorge"
local BG_SHORE = "Seething Shore"
local ARENA_LORD = "Ruins of Lordaeron"
local ARENA_NAGRAND = "Nagrand Arena"
local ARENA_BEM = "Blade's Edge Arena"
local ARENA_DAL = "Dalaran Arena"
local ARENA_ROV = "Ring of Valor"
local ARENA_TOL = "Tol'viron Arena"
local ARENA_TP = "The Tiger's Peak"
local BUFF_BERSERKING = GetSpellInfo(23505)
local hasBerserking
local hasPlayedBerserking = false
local BUFF_RESTORATION = GetSpellInfo(23493)
local hasRegeneration
local hasPlayedRegenSound = false
local killResetTime = 5
local killStreak = 0
local multiKill = 0
local killTime = 0
local soundUpdate = 0
local nextSound
local bit_band = bit.band
local bit_bor = bit.bor
local spreeSounds = {
[1] = "1_kills",
[2] = "2_kills",
[3] = "3_kills",
[4] = "4_kills",
[5] = "5_kills",
[6] = "6_kills",
[7] = "7_kills",
[8] = "8_kills",
[9] = "9_kills",
[10] = "10_kills",
[11] = "11_kills"
}
local multiSounds = {
[2] = "double_kill",
[3] = "triple_kill",
[4] = "quad_kill",
}
local function hasFlag(flags, flag)
return bit_band(flags, flag) == flag
end
function hasRegen()
local result = false
for i=1,40 do
local name, _, _, _, _, duration = UnitBuff("player", i)
if name == BUFF_RESTORATION then
result = true
break
end
end
return result
end
function hasBerserk()
local result = false
for i=1,40 do
local name, _, _, _, _, duration = UnitBuff("player", i)
if name == BUFF_BERSERKING then
result = true
break
end
end
return result
end
local onEvent = function(self, event, ...)
self[event](event, CombatLogGetCurrentEventInfo())
local hasRegen = hasRegen()
local hasBerserk = hasBerserk()
if hasRegen and not hasPlayedRegenSound then
PlaySoundFile("Interface\\AddOns\\HoNAnnouncer-Remade\\sounds\\powerup_regeneration.ogg", "Master")
hasPlayedRegenSound = true
elseif not hasRegen then
hasPlayedRegenSound = false
end
if hasBerserk and not hasPlayedBerserking then
PlaySoundFile("Interface\\AddOns\\HoNAnnouncer-Remade\\sounds\\powerup_doubledamage.ogg", "Master")
hasPlayedBerserking = true
elseif not hasBerserk then
hasPlayedBerserking = false
end
end
local onUpdate = function(self, elapsed)
soundUpdate = soundUpdate + elapsed
if soundUpdate > 2 then
soundUpdate = 0
if nextSound then
PlaySoundFile(nextSound)
nextSound = nil
end
end
end
HoNAnnouncer = CreateFrame("Frame")
HoNAnnouncer:SetScript("OnEvent", onEvent)
HoNAnnouncer:SetScript("OnUpdate", onUpdate)
HoNAnnouncer:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
HoNAnnouncer:RegisterEvent("ZONE_CHANGED_NEW_AREA")
HoNAnnouncer:RegisterEvent("PLAYER_DEAD")
function HoNAnnouncer:PLAYER_DEAD()
killStreak = 0
hasBerserking = false
hasRegeneration = false
PlaySoundFile("Interface\\AddOns\\HoNAnnouncer-Remade\\sounds\\defeat.ogg", "Master")
end
function HoNAnnouncer:ZONE_CHANGED_NEW_AREA()
local zoneText = GetZoneText();
if (zoneText == ARENA_TP or zoneText == BG_DG or zoneText == BG_SLVSM or zoneText == BG_TOK or zoneText == ARENA_TOL or zoneText == BG_TP or zoneText == BG_BFG or zoneText == WORLD_TB or zoneText == WORLD_WG or zoneText == BG_AB or zoneText == BG_WG or zoneText == BG_WGA or zoneText == BG_WGH or zoneText == BG_EOTS or zoneText == BG_AV or zoneText == BG_IOC or zoneText == BG_SOTA or zoneText == ARENA_LORD or zoneText == ARENA_NAGRAND or zoneText == ARENA_BEM or zoneText == ARENA_DAL or zoneText == ARENA_ROV or zoneText == BG_SHORE) then
PlaySoundFile("Interface\\AddOns\\HoNAnnouncer-Remade\\sounds\\startgame.ogg", "Master")
end
killStreak = 0
end
function HoNAnnouncer:COMBAT_LOG_EVENT_UNFILTERED(event, eventType, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellId, spellName, spellSchool, auraType, ...)
if eventType == "PARTY_KILL" and hasFlag(sourceFlags, COMBATLOG_OBJECT_AFFILIATION_MINE) and hasFlag(destFlags, COMBATLOG_OBJECT_TYPE_PLAYER) then
local now = GetTime()
if killTime + killResetTime > now then
multiKill = multiKill + 1
else
multiKill = 1
end
if (UnitHealth("player") / UnitHealthMax("player") * 100 <= 5) and (UnitHealth("player") > 1) then
PlaySoundFile("Interface\\AddOns\\HoNAnnouncer-Remade\\sounds\\smackdown.ogg", "Master")
end
killTime = now
killStreak = killStreak + 1
-- PlaySounds
local path = "Interface\\AddOns\\HoNAnnouncer-Remade\\sounds\\%s.ogg"
local multiKillLocation = multiSounds[math.min(4, multiKill)]
local killSpreeLocation = spreeSounds[math.min(11, killStreak)]
if multiKillLocation then
local multiKillPath = string.format(path, multiKillLocation)
PlaySoundFile(multiKillPath, "Master")
elseif killSpreeLocation then
local killSpreePath = string.format(path, killSpreeLocation)
if not multiKillLocation then
PlaySoundFile(killSpreePath, "Master")
else
nextSound = killSpreePath
end
end
end
if eventType == "SPELL_CAST_SUCCESS" and hasFlag(sourceFlags, COMBATLOG_OBJECT_TARGET) and hasFlag(sourceFlags, COMBATLOG_OBJECT_REACTION_HOSTILE) and spellName == "Divine Shield" then
PlaySoundFile("Interface\\AddOns\\HoNAnnouncer-Remade\\sounds\\rage_quit.ogg", "Master")
end
if eventType == "SPELL_AURA_APPLIED" and hasFlag(destFlags, COMBATLOG_OBJECT_AFFILIATION_MINE) and (spellName == "Speed" or spellName == "Speed Up") then
PlaySoundFile("Interface\\AddOns\\HoNAnnouncer-Remade\\sounds\\powerup_haste.ogg", "Master")
end
end |
#!/usr/local/bin/lua
site={};
site["key"] = "www.lua.org";
print(site["key"]);
print(site.key);
print(site[1]);
|
local modpath = minetest.get_modpath("mcl_small_3d_plants")
--
-- 3D Carrots
--
for i=1, 7 do
local texture, sel_height
if i < 3 then
sel_height1 = -0.4375
texture = "farming_carrot_1.png"
texture1 = "mcl_small_3d_plants_carrot_1.png"
elseif i < 5 then
sel_height1 = -0.375
texture = "farming_carrot_2.png"
texture1 = "mcl_small_3d_plants_carrot_2.png"
else
sel_height1 = -0.3125
texture = "farming_carrot_3.png"
texture1 = "mcl_small_3d_plants_carrot_3.png"
end
local create, name, longdesc
if i == 1 then
create = true
name = ("Premature Carrot Plant")
longdesc = ("Carrot plants are plants which grow on farmland under sunlight in 8 stages, but only 4 stages can be visually told apart. On hydrated farmland, they grow a bit faster. They can be harvested at any time but will only yield a profit when mature.")
else
create = false
end
minetest.register_node(":mcl_farming:carrot_"..i, {
description = ("Premature Carrot Plant (Stage @1)"),
_doc_items_create_entry = create,
_doc_items_entry_name = name,
_doc_items_longdesc = longdesc,
paramtype = "light",
sunlight_propagates = true,
walkable = false,
drawtype = "nodebox",
drop = "mcl_farming:carrot_item",
tiles = {texture1},
inventory_image = texture,
wield_image = texture,
node_box = {
type = "fixed",
fixed = {
{-0.3125, -0.5, 0.1875, -0.1875, sel_height1, 0.3125},
{0.1875, -0.5, 0.1875, 0.3125, sel_height1, 0.3125},
{0.1875, -0.5, -0.3125, 0.3125, sel_height1, -0.1875},
{-0.3125, -0.5, -0.3125, -0.1875, sel_height1, -0.1875},
},
},
groups = {dig_immediate=3, not_in_creative_inventory=1,plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_blast_resistance = 0,
})
end
minetest.register_node(":mcl_farming:carrot", {
description = ("Mature Carrot Plant"),
_doc_items_longdesc = ("Mature carrot plants are ready to be harvested for carrots. They won't grow any further."),
paramtype = "light",
sunlight_propagates = true,
walkable = false,
drawtype = "nodebox",
tiles = {"mcl_small_3d_plants_carrot_4.png"},
inventory_image = "farming_carrot_4.png",
wield_image = "farming_carrot_4.png",
drop = {
max_items = 1,
items = {
{ items = {'mcl_farming:carrot_item 4'}, rarity = 5 },
{ items = {'mcl_farming:carrot_item 3'}, rarity = 2 },
{ items = {'mcl_farming:carrot_item 2'}, rarity = 2 },
{ items = {'mcl_farming:carrot_item 1'} },
}
},
node_box = {
type = "fixed",
fixed = {
{-0.375, -0.5, 0.125, -0.125, -0.375, 0.375},
{-0.3125, -0.375, 0.1875, -0.1875, -0.1875, 0.3125},
{0.125, -0.5, 0.125, 0.375, -0.375, 0.375},
{0.1875, -0.375, 0.1875, 0.3125, -0.1875, 0.3125},
{0.125, -0.5, -0.375, 0.375, -0.375, -0.125},
{0.1875, -0.375, -0.3125, 0.3125, -0.1875, -0.1875},
{-0.375, -0.5, -0.375, -0.125, -0.375, -0.125},
{-0.3125, -0.375, -0.3125, -0.1875, -0.1875, -0.1875},
},
},
groups = {dig_immediate=3, not_in_creative_inventory=1,plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_blast_resistance = 0,
})
--
-- 3D Potatoes
--
for k=1, 7 do
if k < 2 then
minetest.register_node(":mcl_farming:potato_" .. k, {
description = ("Premature Potato Plant (Stage 1)"),
_doc_items_create_entry = create,
_doc_items_entry_name = name,
_doc_items_longdesc = longdesc,
paramtype = "light",
sunlight_propagates = true,
walkable = false,
drawtype = "nodebox",
drop = "mcl_farming:potato_item",
tiles = { "mcl_small_3d_plants_potatoes.png" },
inventory_image = "mcl_farming_potatoes_stage_" .. k,
wield_image = "mcl_farming_potatoes_stage_" .. k,
node_box = {
type = "fixed",
fixed = {
{-0.25, -0.5, 0.125, -0.1875, -0.4375, 0.25},
{0.125, -0.5, 0.1875, 0.25, -0.4375, 0.25},
{0.1875, -0.5, -0.25, 0.25, -0.4375, -0.125},
{-0.25, -0.5, -0.25, -0.125, -0.4375, -0.1875},
},
},
groups = {dig_immediate=3, not_in_creative_inventory=1,plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_blast_resistance = 0,
})
elseif k < 4 then
minetest.register_node(":mcl_farming:potato_" .. k, {
description = ("Premature Potato Plant (Stage 3)"),
_doc_items_create_entry = create,
_doc_items_entry_name = name,
_doc_items_longdesc = longdesc,
paramtype = "light",
sunlight_propagates = true,
walkable = false,
drawtype = "nodebox",
drop = "mcl_farming:potato_item",
tiles = { "mcl_small_3d_plants_potatoes.png" },
inventory_image = "mcl_farming_potatoes_stage_" .. k,
wield_image = "mcl_farming_potatoes_stage_" .. k,
node_box = {
type = "fixed",
fixed = {
{-0.25, -0.5, 0.0625, -0.125, -0.4375, 0.25},
{0.0625, -0.5, 0.125, 0.25, -0.4375, 0.25},
{0.125, -0.5, -0.25, 0.25, -0.4375, -0.0625},
{-0.25, -0.5, -0.25, -0.0625, -0.4375, -0.125},
},
},
groups = {dig_immediate=3, not_in_creative_inventory=1,plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_blast_resistance = 0,
})
elseif k < 6 then
minetest.register_node(":mcl_farming:potato_" .. k, {
description = ("Premature Potato Plant (Stage 5)"),
_doc_items_create_entry = create,
_doc_items_entry_name = name,
_doc_items_longdesc = longdesc,
paramtype = "light",
sunlight_propagates = true,
walkable = false,
drawtype = "nodebox",
drop = "mcl_farming:potato_item",
tiles = { "mcl_small_3d_plants_potatoes.png" },
inventory_image = "mcl_farming_potatoes_stage_" .. k,
wield_image = "mcl_farming_potatoes_stage_" .. k,
node_box = {
type = "fixed",
fixed = {
{-0.3125, -0.5, 0.0625, -0.125, -0.4375, 0.3125},
{0.0625, -0.5, 0.125, 0.3125, -0.4375, 0.3125},
{0.125, -0.5, -0.3125, 0.3125, -0.4375, -0.0625},
{-0.3125, -0.5, -0.3125, -0.0625, -0.4375, -0.125},
},
},
groups = {dig_immediate=3, not_in_creative_inventory=1,plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_blast_resistance = 0,
})
else
minetest.register_node(":mcl_farming:potato_" .. k, {
description = ("Premature Potato Plant (Stage 7)"),
_doc_items_create_entry = create,
_doc_items_entry_name = name,
_doc_items_longdesc = longdesc,
paramtype = "light",
sunlight_propagates = true,
walkable = false,
drawtype = "nodebox",
drop = "mcl_farming:potato_item",
tiles = { "mcl_small_3d_plants_potatoes.png" },
inventory_image = "mcl_farming_potatoes_stage_" .. k,
wield_image = "mcl_farming_potatoes_stage_" .. k,
node_box = {
type = "fixed",
fixed = {
{-0.3125, -0.5, 0, -0.0625, -0.4375, 0.3125},
{0, -0.5, 0.0625, 0.3125, -0.4375, 0.3125},
{0.0625, -0.5, -0.3125, 0.3125, -0.4375, 0},
{-0.3125, -0.5, -0.3125, 0, -0.4375, -0.0625},
},
},
groups = {dig_immediate=3, not_in_creative_inventory=1,plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_blast_resistance = 0,
})
end
end
-- Mature plant
minetest.register_node(":mcl_farming:potato", {
description = ("Mature Potato Plant"),
_doc_items_longdesc = ("Mature potato plants are ready to be harvested for potatoes. They won't grow any further."),
paramtype = "light",
sunlight_propagates = true,
walkable = false,
drawtype = "nodebox",
tiles = {"mcl_small_3d_plants_potatoes.png"},
wield_image = "mcl_farming_potatoes_stage_3.png",
inventory_image = "mcl_farming_potatoes_stage_3.png",
drop = {
items = {
{ items = {'mcl_farming:potato_item 1'} },
{ items = {'mcl_farming:potato_item 1'}, rarity = 2 },
{ items = {'mcl_farming:potato_item 1'}, rarity = 2 },
{ items = {'mcl_farming:potato_item 1'}, rarity = 2 },
{ items = {'mcl_farming:potato_item_poison 1'}, rarity = 50 }
}
},
node_box = {
type = "fixed",
fixed = {
{-0.375, -0.5, 0, -0.0625, -0.4375, 0.375},
{-0.3125, -0.4375, 0.0625, -0.125, -0.375, 0.3125},
{-0.375, -0.5, -0.375, 0, -0.4375, -0.0625},
{0, -0.5, 0.0625, 0.375, -0.4375, 0.375},
{0.0625, -0.5, -0.375, 0.375, -0.4375, 0},
{-0.3125, -0.4375, -0.3125, -0.0625, -0.375, -0.125},
{0.125, -0.4375, -0.3125, 0.3125, -0.375, -0.0625},
{0.0625, -0.4375, 0.125, 0.3125, -0.375, 0.3125},
},
},
groups = {dig_immediate=3, not_in_creative_inventory=1,plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_blast_resistance = 0,
})
--
-- 3D Beetroot
--
minetest.register_node(":mcl_farming:beetroot_0", {
description = ("Premature Beetroot Plant (Stage 1)"),
_doc_items_longdesc = ("Beetroot plants are plants which grow on farmland under sunlight in 4 stages. On hydrated farmland, they grow a bit faster. They can be harvested at any time but will only yield a profit when mature."),
_doc_items_entry_name = ("Premature Beetroot Plant"),
paramtype = "light",
sunlight_propagates = true,
walkable = false,
drawtype = "nodebox",
drop = "mcl_farming:beetroot_seeds",
tiles = {"mcl_small_3d_plants_beetroot_1.png"},
inventory_image = "mcl_farming_beetroot_0.png",
wield_image = "mcl_farming_beetroot_0.png",
node_box = {
type = "fixed",
fixed = {
{-0.25, -0.5, 0.1875, -0.1875, -0.4375, 0.25},
{0.1875, -0.5, 0.1875, 0.25, -0.4375, 0.25},
{0.1875, -0.5, -0.25, 0.25, -0.4375, -0.1875},
{-0.25, -0.5, -0.25, -0.1875, -0.4375, -0.1875},
},
},
groups = {dig_immediate=3, not_in_creative_inventory=1,plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_blast_resistance = 0,
})
minetest.register_node(":mcl_farming:beetroot_1", {
description = ("Premature Beetroot Plant (Stage 2)"),
_doc_items_create_entry = false,
paramtype = "light",
sunlight_propagates = true,
walkable = false,
drawtype = "nodebox",
drop = "mcl_farming:beetroot_seeds",
tiles = {"mcl_small_3d_plants_beetroot_1.png"},
inventory_image = "mcl_farming_beetroot_1.png",
wield_image = "mcl_farming_beetroot_1.png",
node_box = {
type = "fixed",
fixed = {
{-0.25, -0.5, 0.1875, -0.1875, -0.375, 0.25},
{0.1875, -0.5, 0.1875, 0.25, -0.375, 0.25},
{0.1875, -0.5, -0.25, 0.25, -0.375, -0.1875},
{-0.25, -0.5, -0.25, -0.1875, -0.375, -0.1875},
},
},
groups = {dig_immediate=3, not_in_creative_inventory=1,plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_blast_resistance = 0,
})
minetest.register_node(":mcl_farming:beetroot_2", {
description = ("Premature Beetroot Plant (Stage 3)"),
_doc_items_create_entry = false,
paramtype = "light",
sunlight_propagates = true,
walkable = false,
drawtype = "nodebox",
drop = "mcl_farming:beetroot_seeds",
tiles = {"mcl_small_3d_plants_beetroot_2.png"},
inventory_image = "mcl_farming_beetroot_2.png",
wield_image = "mcl_farming_beetroot_2.png",
node_box = {
type = "fixed",
fixed = {
{-0.3125, -0.5, 0.125, -0.125, -0.4375, 0.3125},
{-0.25, -0.5, 0.1875, -0.1875, -0.3125, 0.25},
{0.125, -0.5, 0.125, 0.3125, -0.4375, 0.3125},
{0.1875, -0.5, 0.1875, 0.25, -0.3125, 0.25},
{0.125, -0.5, -0.3125, 0.3125, -0.4375, -0.125},
{0.1875, -0.5, -0.25, 0.25, -0.3125, -0.1875},
{-0.3125, -0.5, -0.3125, -0.125, -0.4375, -0.125},
{-0.25, -0.5, -0.25, -0.1875, -0.3125, -0.1875},
},
},
groups = {dig_immediate=3, not_in_creative_inventory=1,plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_blast_resistance = 0,
})
minetest.register_node(":mcl_farming:beetroot", {
description = ("Mature Beetroot Plant"),
_doc_items_longdesc = ("A mature beetroot plant is a farming plant which is ready to be harvested for a beetroot and some beetroot seeds. It won't grow any further."),
_doc_items_create_entry = true,
paramtype = "light",
sunlight_propagates = true,
walkable = false,
drawtype = "nodebox",
drop = {
--[[ drops 1 beetroot guaranteed.
drops 0-3 beetroot seeds:
0 seeds: 42.18%
1 seed: 14.06%
2 seeds: 18.75%
3 seeds: 25% ]]
max_items = 2,
items = {
{ items = {"mcl_farming:beetroot_item"}, rarity = 1 },
{ items = {"mcl_farming:beetroot_seeds 3"}, rarity = 4 },
{ items = {"mcl_farming:beetroot_seeds 2"}, rarity = 4 },
{ items = {"mcl_farming:beetroot_seeds 1"}, rarity = 4 },
},
},
tiles = {"mcl_small_3d_plants_beetroot_3.png"},
inventory_image = "mcl_farming_beetroot_3.png",
wield_image = "mcl_farming_beetroot_3.png",
node_box = {
type = "fixed",
fixed = {
{-0.375, -0.5, 0.0625, -0.0625, -0.375, 0.375},
{-0.3125, -0.375, 0.125, -0.125, -0.3125, 0.3125},
{-0.25, -0.3125, 0.1875, -0.1875, -0.125, 0.25},
{0.0625, -0.5, 0.0625, 0.375, -0.375, 0.375},
{0.125, -0.375, 0.125, 0.3125, -0.3125, 0.3125},
{0.1875, -0.3125, 0.1875, 0.25, -0.125, 0.25},
{0.0625, -0.5, -0.375, 0.375, -0.375, -0.0625},
{0.125, -0.375, -0.3125, 0.3125, -0.3125, -0.125},
{0.1875, -0.3125, -0.25, 0.25, -0.125, -0.1875},
{-0.375, -0.5, -0.375, -0.0625, -0.375, -0.0625},
{-0.3125, -0.375, -0.3125, -0.125, -0.3125, -0.125},
{-0.25, -0.3125, -0.25, -0.1875, -0.125, -0.1875},
},
},
groups = {dig_immediate=3, not_in_creative_inventory=1,plant=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,beetroot=4},
sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_blast_resistance = 0,
})
--
-- 3D Wheat
--
for b=1, 7 do
local texture, selbox
if b < 2 then
texture = "mcl_farming_wheat_stage_1.png"
texture1 = "mcl_small_3d_plants_wheat_stage_1.png"
w1y2 = -0.4375
w2y2 = -0.4375
w3y2 = -0.4375
w4y2 = -0.4375
w5y2 = -0.4375
w6y2 = -0.4375
w7y2 = -0.4375
w8y2 = -0.4375
w9y2 = -0.4375
w10y2 = -0.4375
w11y2 = -0.4375
w12y2 = -0.4375
w13y2 = -0.4375
w14y2 = -0.4375
w15y2 = -0.4375
w16y2 = -0.4375
w17y2 = -0.4375
w18y2 = -0.4375
w19y2 = -0.4375
w20y2 = -0.4375
w21y2 = -0.4375
w22y2 = -0.4375
w23y2 = -0.4375
w24y2 = -0.4375
w25y2 = -0.4375
elseif b == 2 then
texture = "mcl_farming_wheat_stage_2.png"
texture1 = "mcl_small_3d_plants_wheat_stage_2.png"
w1y2 = -0.375
w2y2 = -0.4375
w3y2 = -0.375
w4y2 = -0.4375
w5y2 = -0.375
w6y2 = -0.4375
w7y2 = -0.375
w8y2 = -0.4375
w9y2 = -0.375
w10y2 = -0.4375
w11y2 = -0.375
w12y2 = -0.4375
w13y2 = -0.375
w14y2 = -0.4375
w15y2 = -0.375
w16y2 = -0.4375
w17y2 = -0.375
w18y2 = -0.4375
w19y2 = -0.375
w20y2 = -0.4375
w21y2 = -0.375
w22y2 = -0.4375
w23y2 = -0.375
w24y2 = -0.4375
w25y2 = -0.375
elseif b == 3 then
texture = "mcl_farming_wheat_stage_3.png"
texture1 = "mcl_small_3d_plants_wheat_stage_3.png"
w1y2 = -0.25
w2y2 = -0.3125
w3y2 = -0.25
w4y2 = -0.3125
w5y2 = -0.25
w6y2 = -0.3125
w7y2 = -0.25
w8y2 = -0.3125
w9y2 = -0.25
w10y2 = -0.3125
w11y2 = -0.25
w12y2 = -0.3125
w13y2 = -0.25
w14y2 = -0.3125
w15y2 = -0.25
w16y2 = -0.3125
w17y2 = -0.25
w18y2 = -0.3125
w19y2 = -0.25
w20y2 = -0.3125
w21y2 = -0.25
w22y2 = -0.3125
w23y2 = -0.25
w24y2 = -0.3125
w25y2 = -0.25
elseif b == 4 then
texture = "mcl_farming_wheat_stage_4.png"
texture1 = "mcl_small_3d_plants_wheat_stage_4.png"
w1y2 = -0.125
w2y2 = -0.1875
w3y2 = -0.125
w4y2 = -0.1875
w5y2 = -0.125
w6y2 = -0.1875
w7y2 = -0.125
w8y2 = -0.1875
w9y2 = -0.125
w10y2 = -0.1875
w11y2 = -0.125
w12y2 = -0.1875
w13y2 = -0.125
w14y2 = -0.1875
w15y2 = -0.125
w16y2 = -0.1875
w17y2 = -0.125
w18y2 = -0.1875
w19y2 = -0.125
w20y2 = -0.1875
w21y2 = -0.125
w22y2 = -0.1875
w23y2 = -0.125
w24y2 = -0.1875
w25y2 = -0.125
elseif b == 5 then
texture = "mcl_farming_wheat_stage_5.png"
texture1 = "mcl_small_3d_plants_wheat_stage_5.png"
w1y2 = 0
w2y2 = -0.0625
w3y2 = 0
w4y2 = -0.0625
w5y2 = 0
w6y2 = -0.0625
w7y2 = 0
w8y2 = -0.0625
w9y2 = 0
w10y2 = -0.0625
w11y2 = 0
w12y2 = -0.0625
w13y2 = 0
w14y2 = -0.0625
w15y2 = 0
w16y2 = -0.0625
w17y2 = 0
w18y2 = -0.0625
w19y2 = 0
w20y2 = -0.0625
w21y2 = 0
w22y2 = -0.0625
w23y2 = 0
w24y2 = -0.0625
w25y2 = 0
elseif b == 6 then
texture = "mcl_farming_wheat_stage_6.png"
texture1 = "mcl_small_3d_plants_wheat_stage_6.png"
w1y2 = 0.125
w2y2 = 0.0625
w3y2 = 0.125
w4y2 = 0.0625
w5y2 = 0.125
w6y2 = 0.0625
w7y2 = 0.125
w8y2 = 0.0625
w9y2 = 0.125
w10y2 = 0.0625
w11y2 = 0.125
w12y2 = 0.0625
w13y2 = 0.125
w14y2 = 0.0625
w15y2 = 0.125
w16y2 = 0.0625
w17y2 = 0.125
w18y2 = 0.0625
w19y2 = 0.125
w20y2 = 0.0625
w21y2 = 0.125
w22y2 = 0.0625
w23y2 = 0.125
w24y2 = 0.0625
w25y2 = 0.125
end
local create, name, longdesc
if b == 1 then
create = true
name = ("Premature Wheat Plant")
longdesc = ("Premature wheat plants grow on farmland under sunlight in 8 stages. On hydrated farmland, they grow faster. They can be harvested at any time but will only yield a profit when mature.")
else
create = false
end
minetest.register_node(":mcl_farming:wheat_"..b, {
description = ("Premature Wheat Plant (Stage @1)"),
_doc_items_create_entry = create,
_doc_items_entry_name = name,
_doc_items_longdesc = longdesc,
paramtype = "light",
sunlight_propagates = true,
walkable = false,
drawtype = "nodebox",
drop = "mcl_farming:wheat_seeds",
tiles = {texture1},
inventory_image = texture,
wield_image = texture,
node_box = {
type = "fixed",
fixed = {
{-0.375, -0.5, 0.3125, -0.3125, w1y2, 0.375},
{-0.1875, -0.5, 0.3125, -0.125, w2y2, 0.375},
{0, -0.5, 0.3125, 0.0625, w3y2, 0.375},
{0.1875, -0.5, 0.3125, 0.25, w4y2, 0.375},
{0.375, -0.5, 0.3125, 0.4375, w5y2, 0.375},
{-0.4375, -0.5, 0.125, -0.375, w6y2, 0.1875},
{-0.25, -0.5, 0.125, -0.1875, w7y2, 0.1875},
{-0.0625, -0.5, 0.125, 0, w8y2, 0.1875},
{0.125, -0.5, 0.125, 0.1875, w9y2, 0.1875},
{0.3125, -0.5, 0.125, 0.375, w10y2, 0.1875},
{-0.375, -0.5, -0.0625, -0.3125, w11y2, 0},
{-0.1875, -0.5, -0.0625, -0.125, w12y2, 0},
{0, -0.5, -0.0625, 0.0625, w13y2, 0},
{0.1875, -0.5, -0.0625, 0.25, w14y2, 0},
{0.375, -0.5, -0.0625, 0.4375, w15y2, 0},
{-0.4375, -0.5, -0.25, -0.375, w16y2, -0.1875},
{-0.25, -0.5, -0.25, -0.1875, w17y2, -0.1875},
{-0.0625, -0.5, -0.25, 0, w18y2, -0.1875},
{0.125, -0.5, -0.25, 0.1875, w19y2, -0.1875},
{0.3125, -0.5, -0.25, 0.375, w20y2, -0.1875},
{-0.375, -0.5, -0.4375, -0.3125, w21y2, -0.375},
{-0.1875, -0.5, -0.4375, -0.125, w22y2, -0.375},
{0, -0.5, -0.4375, 0.0625, w23y2, -0.375},
{0.1875, -0.5, -0.4375, 0.25, w24y2, -0.375},
{0.375, -0.5, -0.4375, 0.4375, w25y2, -0.375},
},
},
groups = {dig_immediate=3, not_in_creative_inventory=1, plant=1,attached_node=1, dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_blast_resistance = 0,
})
end
minetest.register_node(":mcl_farming:wheat", {
description = ("Mature Wheat Plant"),
_doc_items_longdesc = ("Mature wheat plants are ready to be harvested for wheat and wheat seeds. They won't grow any further."),
sunlight_propagates = true,
paramtype = "light",
walkable = false,
drawtype = "nodebox",
tiles = {"mcl_small_3d_plants_wheat_stage_7.png"},
inventory_image = "mcl_farming_wheat_stage_7.png",
wield_image = "mcl_farming_wheat_stage_7.png",
node_box = {
type = "fixed",
fixed = {
{-0.375, -0.5, 0.3125, -0.3125, 0.25, 0.375},
{-0.4375, 0.25, 0.3125, -0.3125, 0.5, 0.4375},
{-0.1875, -0.5, 0.3125, -0.125, 0.1875, 0.375},
{-0.25, 0.1875, 0.25, -0.125, 0.4375, 0.375},
{0, -0.5, 0.3125, 0.0625, 0.25, 0.375},
{-0.0625, 0.25, 0.3125, 0.0625, 0.5, 0.4375},
{0.1875, -0.5, 0.3125, 0.25, 0.1875, 0.375},
{0.125, 0.1875, 0.25, 0.25, 0.4375, 0.375},
{0.375, -0.5, 0.3125, 0.4375, 0.25, 0.375},
{0.3125, 0.25, 0.3125, 0.4375, 0.5, 0.4375},
{-0.4375, -0.5, 0.125, -0.375, 0.1875, 0.1875},
{-0.4375, 0.1875, 0.125, -0.3125, 0.4375, 0.25},
{-0.25, -0.5, 0.125, -0.1875, 0.25, 0.1875},
{-0.25, 0.25, 0.0625, -0.125, 0.5, 0.1875},
{-0.0625, -0.5, 0.125, 0, 0.1875, 0.1875},
{-0.0625, 0.1875, 0.125, 0.0625, 0.4375, 0.25},
{0.125, -0.5, 0.125, 0.1875, 0.25, 0.1875},
{0.125, 0.25, 0.0625, 0.25, 0.5, 0.1875},
{0.3125, -0.5, 0.125, 0.375, 0.1875, 0.1875},
{0.3125, 0.1875, 0.125, 0.4375, 0.4375, 0.25},
{-0.375, -0.5, -0.0625, -0.3125, 0.25, 0},
{-0.4375, 0.25, -0.0625, -0.3125, 0.5, 0.0625},
{-0.1875, -0.5, -0.0625, -0.125, 0.1875, 0},
{-0.25, 0.1875, -0.125, -0.125, 0.4375, 0},
{0, -0.5, -0.0625, 0.0625, 0.25, 0},
{-0.0625, 0.25, -0.0625, 0.0625, 0.5, 0.0625},
{0.1875, -0.5, -0.0625, 0.25, 0.1875, 0},
{0.125, 0.1875, -0.125, 0.25, 0.4375, 0},
{0.375, -0.5, -0.0625, 0.4375, 0.25, 0},
{0.3125, 0.25, -0.0625, 0.4375, 0.5, 0.0625},
{-0.4375, -0.5, -0.25, -0.375, 0.1875, -0.1875},
{-0.4375, 0.1875, -0.25, -0.3125, 0.4375, -0.125},
{-0.25, -0.5, -0.25, -0.1875, 0.25, -0.1875},
{-0.25, 0.25, -0.3125, -0.125, 0.5, -0.1875},
{-0.0625, -0.5, -0.25, 0, 0.1875, -0.1875},
{-0.0625, 0.1875, -0.25, 0.0625, 0.4375, -0.125},
{0.125, -0.5, -0.25, 0.1875, 0.25, -0.1875},
{0.125, 0.25, -0.3125, 0.25, 0.5, -0.1875},
{0.3125, -0.5, -0.25, 0.375, 0.1875, -0.1875},
{0.3125, 0.1875, -0.25, 0.4375, 0.4375, -0.125},
{-0.375, -0.5, -0.4375, -0.3125, 0.25, -0.375},
{-0.4375, 0.25, -0.4375, -0.3125, 0.5, -0.3125},
{-0.1875, -0.5, -0.4375, -0.125, 0.25, -0.375},
{-0.25, 0.1875, -0.5, -0.125, 0.4375, -0.375},
{0, -0.5, -0.4375, 0.0625, 0.25, -0.375},
{-0.0625, 0.25, -0.4375, 0.0625, 0.5, -0.3125},
{0.1875, -0.5, -0.4375, 0.25, 0.25, -0.375},
{0.125, 0.1875, -0.5, 0.25, 0.4375, -0.375},
{0.375, -0.5, -0.4375, 0.4375, 0.25, -0.375},
{0.3125, 0.25, -0.4375, 0.4375, 0.5, -0.3125},
},
},
drop = {
max_items = 4,
items = {
{ items = {'mcl_farming:wheat_seeds'} },
{ items = {'mcl_farming:wheat_seeds'}, rarity = 2},
{ items = {'mcl_farming:wheat_seeds'}, rarity = 5},
{ items = {'mcl_farming:wheat_item'} }
}
},
groups = {dig_immediate=3, not_in_creative_inventory=1, plant=1,attached_node=1, dig_by_water=1,destroy_by_lava_flow=1, dig_by_piston=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
_mcl_blast_resistance = 0,
})
--
-- 3D Papyrus
--
minetest.register_node(":mcl_core:reeds", {
description = "Sugar Canes",
tiles = {"mcl_small_3d_plants_papyrus.png"},
inventory_image = "mcl_core_reeds.png",
wield_image = "mcl_core_reeds.png",
paramtype = "light",
walkable = false,
is_ground_content = true,
groups = {snappy=3,flammable=2},
stack_max = 64,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.375, -0.5, 0.25, -0.25, 0.5, 0.375},
{0.25, -0.5, 0.25, 0.375, 0.5, 0.375},
{0.25, -0.5, -0.375, 0.375, 0.5, -0.25},
{-0.375, -0.5, -0.375, -0.25, 0.5, -0.25},
{-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625},
{0.0625, -0.0625, 0, 0.1875, 0.0625, 0},
{-0.1875, 0.1875, 0, -0.0625, 0.3125, 0},
{-0.3125, 0.125, -0.5, -0.3125, 0.25, -0.375},
{-0.3125, -0.1875, -0.25, -0.3125, -0.0625, -0.125},
{0.3125, 0.0625, -0.25, 0.3125, 0.1875, -0.125},
{0.3125, -0.25, -0.5, 0.3125, -0.125, -0.375},
{0.125, -0.125, 0.3125, 0.3125, 0, 0.3125},
{0.25, 0.1875, 0.3125, 0.5, 0.3125, 0.3125},
{-0.25, 0.125, 0.3125, -0.125, 0.25, 0.3125},
{-0.5, -0.25, 0.3125, -0.375, -0.125, 0.3125},
}
},
selection_box = {
type = "fixed",
fixed = {
{-0.375, -0.5, 0.25, -0.25, 0.5, 0.375},
{0.25, -0.5, 0.25, 0.375, 0.5, 0.375},
{0.25, -0.5, -0.375, 0.375, 0.5, -0.25},
{-0.375, -0.5, -0.375, -0.25, 0.5, -0.25},
{-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625},
{0.0625, -0.0625, 0, 0.1875, 0.0625, 0},
{-0.1875, 0.1875, 0, -0.0625, 0.3125, 0},
{-0.3125, 0.125, -0.5, -0.3125, 0.25, -0.375},
{-0.3125, -0.1875, -0.25, -0.3125, -0.0625, -0.125},
{0.3125, 0.0625, -0.25, 0.3125, 0.1875, -0.125},
{0.3125, -0.25, -0.5, 0.3125, -0.125, -0.375},
{0.125, -0.125, 0.3125, 0.3125, 0, 0.3125},
{0.25, 0.1875, 0.3125, 0.5, 0.3125, 0.3125},
{-0.25, 0.125, 0.3125, -0.125, 0.25, 0.3125},
{-0.5, -0.25, 0.3125, -0.375, -0.125, 0.3125},
}
},
groups = {dig_immediate=3, craftitem=1, deco_block=1, plant=1, non_mycelium_plant=1, dig_by_piston=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
node_placement_prediction = "",
on_place = mcl_util.generate_on_place_plant_function(function(place_pos, place_node)
local soil_pos = {x=place_pos.x, y=place_pos.y-1, z=place_pos.z}
local soil_node = minetest.get_node_or_nil(soil_pos)
if not soil_node then return false end
local snn = soil_node.name -- soil node name
-- Placement rules:
-- * On top of group:soil_sugarcane AND next to water or frosted ice. OR
-- * On top of sugar canes
if snn == "mcl_core:reeds" then
return true
elseif minetest.get_item_group(snn, "soil_sugarcane") == 0 then
return false
end
local posses = {
{ x=0, y=0, z=1},
{ x=0, y=0, z=-1},
{ x=1, y=0, z=0},
{ x=-1, y=0, z=0},
}
for p=1, #posses do
local checknode = minetest.get_node(vector.add(soil_pos, posses[p]))
if minetest.get_item_group(checknode.name, "water") ~= 0 or minetest.get_item_group(checknode.name, "frosted_ice") ~= 0 then
-- Water found! Sugar canes are happy! :-)
return true
end
end
-- No water found! Sugar canes are not amuzed and refuses to be placed. :-(
return false
end),
_mcl_blast_resistance = 0,
_mcl_hardness = 0,
})
--
-- 3D Mushrooms
--
minetest.register_node(":mcl_mushrooms:mushroom_brown", {
description = ("Brown Mushroom"),
drawtype = "nodebox",
tiles = { "mcl_small_3d_plants_mushroom_brown.png" },
inventory_image = "farming_mushroom_brown.png",
wield_image = "farming_mushroom_brown.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
groups = {dig_immediate=3,mushroom=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1, flora=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
node_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, -0.0625, 0.0625, -0.375, 0.0625},
{-0.1875, -0.375, -0.1875, 0.1875, -0.25, 0.1875},
{-0.125, -0.25, -0.125, 0.125, -0.1875, 0.125},
},
},
light_source = 1,
node_placement_prediction = "",
on_place = on_place,
_mcl_blast_resistance = 0,
})
minetest.register_node(":mcl_mushrooms:mushroom_red", {
description = ("Brown Mushroom"),
drawtype = "nodebox",
tiles = { "mcl_small_3d_plants_mushroom_red.png" },
inventory_image = "farming_mushroom_red.png",
wield_image = "farming_mushroom_red.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
groups = {dig_immediate=3,mushroom=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1, flora=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
node_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, -0.0625, 0.0625, -0.375, 0.0625},
{-0.1875, -0.375, -0.1875, 0.1875, -0.25, 0.1875},
{-0.125, -0.25, -0.125, 0.125, -0.1875, 0.125},
},
},
light_source = 1,
node_placement_prediction = "",
on_place = on_place,
_mcl_blast_resistance = 0,
})
--
-- 3D Flowers
--
minetest.register_node(":mcl_flowers:tulip_red", {
description = ("Red Tulip"),
drawtype = "nodebox",
tiles = { "mcl_small_3d_plants_tulip_red.png" },
inventory_image = "mcl_flowers_tulip_red.png",
wield_image = "mcl_flowers_tulip_red.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
groups = {dig_immediate=3,flower=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1, flora=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
node_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, -0.0625, 0.0625, -0.1875, 0.0625},
{-0.0625, -0.1875, 0.0625, 0.0625, -0.0625, 0.125},
{-0.0625, -0.1875, -0.125, 0.0625, -0.0625, -0.0625},
{0.0625, -0.1875, -0.0625, 0.125, -0.0625, 0.0625},
{-0.125, -0.1875, -0.0625, -0.0625, -0.0625, 0.0625},
{-0.1875, -0.4375, 0, -0.0625, -0.375, 0},
{-0.25, -0.375, 0, -0.125, -0.3125, 0},
{0.0625, -0.4375, 0, 0.1875, -0.375, 0},
{0.125, -0.375, 0, 0.25, -0.3125, 0},
{0, -0.4375, -0.1875, 0, -0.375, -0.0625},
{0, -0.375, -0.25, 0, -0.3125, -0.125},
{0, -0.4375, 0.0625, 0, -0.375, 0.1875},
{0, -0.375, 0.125, 0, -0.3125, 0.25},
{-0.125, -0.0625, 0.0625, -0.0625, 0, 0.125},
{-0.125, -0.0625, -0.125, -0.0625, 0, -0.0625},
{0.0625, -0.0625, -0.125, 0.125, 3.72529e-09, -0.0625},
{0.0625, -0.0625, 0.0625, 0.125, 7.45058e-09, 0.125},
{0.125, -0.0625, -0.0625, 0.1875, 0.0625, 0.0625},
{-0.1875, -0.0625, -0.0625, -0.125, 0.0625, 0.0625},
{-0.0625, -0.0625, 0.125, 0.0625, 0.0625, 0.1875},
{-0.0625, -0.0625, -0.1875, 0.0625, 0.0625, -0.125},
},
},
light_source = 1,
node_placement_prediction = "",
on_place = on_place,
_mcl_blast_resistance = 0,
})
minetest.register_node(":mcl_flowers:tulip_orange", {
description = ("Orange Tulip"),
drawtype = "nodebox",
tiles = { "mcl_small_3d_plants_tulip.png" },
inventory_image = "flowers_tulip.png",
wield_image = "flowers_tulip.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
groups = {flora=1, dig_immediate=3,flower=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
node_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, -0.0625, 0.0625, -0.1875, 0.0625},
{-0.0625, -0.1875, 0.0625, 0.0625, -0.0625, 0.125},
{-0.0625, -0.1875, -0.125, 0.0625, -0.0625, -0.0625},
{0.0625, -0.1875, -0.0625, 0.125, -0.0625, 0.0625},
{-0.125, -0.1875, -0.0625, -0.0625, -0.0625, 0.0625},
{-0.1875, -0.4375, 0, -0.0625, -0.375, 0},
{-0.25, -0.375, 0, -0.125, -0.3125, 0},
{0.0625, -0.4375, 0, 0.1875, -0.375, 0},
{0.125, -0.375, 0, 0.25, -0.3125, 0},
{0, -0.4375, -0.1875, 0, -0.375, -0.0625},
{0, -0.375, -0.25, 0, -0.3125, -0.125},
{0, -0.4375, 0.0625, 0, -0.375, 0.1875},
{0, -0.375, 0.125, 0, -0.3125, 0.25},
{-0.125, -0.0625, 0.0625, -0.0625, 0, 0.125},
{-0.125, -0.0625, -0.125, -0.0625, 0, -0.0625},
{0.0625, -0.0625, -0.125, 0.125, 3.72529e-09, -0.0625},
{0.0625, -0.0625, 0.0625, 0.125, 7.45058e-09, 0.125},
{0.125, -0.0625, -0.0625, 0.1875, 0.0625, 0.0625},
{-0.1875, -0.0625, -0.0625, -0.125, 0.0625, 0.0625},
{-0.0625, -0.0625, 0.125, 0.0625, 0.0625, 0.1875},
{-0.0625, -0.0625, -0.1875, 0.0625, 0.0625, -0.125},
},
},
light_source = 1,
node_placement_prediction = "",
on_place = on_place,
_mcl_blast_resistance = 0,
})
minetest.register_node(":mcl_flowers:tulip_pink", {
description = ("Pink Tulip"),
drawtype = "nodebox",
tiles = { "mcl_small_3d_plants_tulip_pink.png" },
inventory_image = "mcl_flowers_tulip_pink.png",
wield_image = "mcl_flowers_tulip_pink.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
groups = {flora=1, dig_immediate=3,flower=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
node_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, -0.0625, 0.0625, -0.1875, 0.0625},
{-0.0625, -0.1875, 0.0625, 0.0625, -0.0625, 0.125},
{-0.0625, -0.1875, -0.125, 0.0625, -0.0625, -0.0625},
{0.0625, -0.1875, -0.0625, 0.125, -0.0625, 0.0625},
{-0.125, -0.1875, -0.0625, -0.0625, -0.0625, 0.0625},
{-0.1875, -0.4375, 0, -0.0625, -0.375, 0},
{-0.25, -0.375, 0, -0.125, -0.3125, 0},
{0.0625, -0.4375, 0, 0.1875, -0.375, 0},
{0.125, -0.375, 0, 0.25, -0.3125, 0},
{0, -0.4375, -0.1875, 0, -0.375, -0.0625},
{0, -0.375, -0.25, 0, -0.3125, -0.125},
{0, -0.4375, 0.0625, 0, -0.375, 0.1875},
{0, -0.375, 0.125, 0, -0.3125, 0.25},
{-0.125, -0.0625, 0.0625, -0.0625, 0, 0.125},
{-0.125, -0.0625, -0.125, -0.0625, 0, -0.0625},
{0.0625, -0.0625, -0.125, 0.125, 3.72529e-09, -0.0625},
{0.0625, -0.0625, 0.0625, 0.125, 7.45058e-09, 0.125},
{0.125, -0.0625, -0.0625, 0.1875, 0.0625, 0.0625},
{-0.1875, -0.0625, -0.0625, -0.125, 0.0625, 0.0625},
{-0.0625, -0.0625, 0.125, 0.0625, 0.0625, 0.1875},
{-0.0625, -0.0625, -0.1875, 0.0625, 0.0625, -0.125},
},
},
light_source = 1,
node_placement_prediction = "",
on_place = on_place,
_mcl_blast_resistance = 0,
})
minetest.register_node(":mcl_flowers:tulip_white", {
description = ("White Tulip"),
drawtype = "nodebox",
tiles = { "mcl_small_3d_plants_tulip_white.png" },
inventory_image = "mcl_flowers_tulip_white.png",
wield_image = "mcl_flowers_tulip_white.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
groups = {flora=1, dig_immediate=3,flower=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
node_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, -0.0625, 0.0625, -0.1875, 0.0625},
{-0.0625, -0.1875, 0.0625, 0.0625, -0.0625, 0.125},
{-0.0625, -0.1875, -0.125, 0.0625, -0.0625, -0.0625},
{0.0625, -0.1875, -0.0625, 0.125, -0.0625, 0.0625},
{-0.125, -0.1875, -0.0625, -0.0625, -0.0625, 0.0625},
{-0.1875, -0.4375, 0, -0.0625, -0.375, 0},
{-0.25, -0.375, 0, -0.125, -0.3125, 0},
{0.0625, -0.4375, 0, 0.1875, -0.375, 0},
{0.125, -0.375, 0, 0.25, -0.3125, 0},
{0, -0.4375, -0.1875, 0, -0.375, -0.0625},
{0, -0.375, -0.25, 0, -0.3125, -0.125},
{0, -0.4375, 0.0625, 0, -0.375, 0.1875},
{0, -0.375, 0.125, 0, -0.3125, 0.25},
{-0.125, -0.0625, 0.0625, -0.0625, 0, 0.125},
{-0.125, -0.0625, -0.125, -0.0625, 0, -0.0625},
{0.0625, -0.0625, -0.125, 0.125, 3.72529e-09, -0.0625},
{0.0625, -0.0625, 0.0625, 0.125, 7.45058e-09, 0.125},
{0.125, -0.0625, -0.0625, 0.1875, 0.0625, 0.0625},
{-0.1875, -0.0625, -0.0625, -0.125, 0.0625, 0.0625},
{-0.0625, -0.0625, 0.125, 0.0625, 0.0625, 0.1875},
{-0.0625, -0.0625, -0.1875, 0.0625, 0.0625, -0.125},
},
},
light_source = 1,
node_placement_prediction = "",
on_place = on_place,
_mcl_blast_resistance = 0,
})
minetest.register_node(":mcl_flowers:allium", {
description = ("Allium"),
drawtype = "nodebox",
tiles = {
"mcl_small_3d_plants_allium_top.png",
"mcl_small_3d_plants_allium_top.png",
"mcl_small_3d_plants_allium.png",
"mcl_small_3d_plants_allium.png",
"mcl_small_3d_plants_allium.png",
"mcl_small_3d_plants_allium.png"
},
inventory_image = "mcl_flowers_allium.png",
wield_image = "mcl_flowers_allium.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
groups = {flora=1, dig_immediate=3,flower=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
node_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, -0.0625, 0.0625, 0.125, 0.0625},
{-0.125, 0.125, -0.125, 0.125, 0.1875, 0.125},
{-0.1875, 0.1875, -0.1875, 0.1875, 0.3125, 0.1875},
{-0.125, 0.25, -0.25, 0.125, 0.3125, 0.25},
{-0.25, 0.25, -0.125, 0.25, 0.3125, 0.125},
{-0.1875, 0.3125, -0.125, 0.1875, 0.375, 0.125},
{-0.125, 0.3125, -0.1875, 0.125, 0.375, 0.1875},
{-0.125, 0.375, -0.125, 0.125, 0.4375, 0.125},
{-0.0625, 0.4375, -0.0625, 0.0625, 0.5, 0.0625},
{0, -0.5, 0.0625, 0, -0.3125, 0.125},
{0, -0.4375, 0.125, 0, -0.25, 0.1875},
{0, -0.3125, 0.1875, 0, -0.125, 0.25},
{0, -0.5, -0.125, 0, -0.3125, -0.0625},
{0, -0.4375, -0.1875, 0, -0.25, -0.125},
{0, -0.3125, -0.25, 0, -0.125, -0.1875},
{0.0625, -0.5, 0, 0.125, -0.3125, 1.49012e-08},
{0.125, -0.4375, 0, 0.1875, -0.25, 1.49012e-08},
{0.1875, -0.3125, 0, 0.25, -0.125, 1.49012e-08},
{-0.125, -0.5, 0, -0.0625, -0.3125, 1.49012e-08},
{-0.1875, -0.4375, 0, -0.125, -0.25, 1.49012e-08},
{-0.25, -0.3125, 0, -0.1875, -0.125, 1.49012e-08},
},
},
light_source = 1,
node_placement_prediction = "",
on_place = on_place,
_mcl_blast_resistance = 0,
})
minetest.register_node(":mcl_flowers:azure_bluet", {
description = ("Azure Bluet"),
drawtype = "nodebox",
tiles = {
"mcl_small_3d_plants_azure_bluet_top.png",
"mcl_small_3d_plants_azure_bluet_top.png",
"mcl_small_3d_plants_azure_bluet.png",
"mcl_small_3d_plants_azure_bluet.png",
"mcl_small_3d_plants_azure_bluet.png",
"mcl_small_3d_plants_azure_bluet.png"
},
inventory_image = "mcl_flowers_azure_bluet.png",
wield_image = "mcl_flowers_allium.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
groups = {flora=1, dig_immediate=3,flower=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
node_box = {
type = "fixed",
fixed = {
{-0.3125, -0.5, 0.25, -0.25, -0.3125, 0.3125},
{-0.375, -0.3125, 0.25, -0.1875, -0.3125, 0.3125},
{-0.3125, -0.3125, 0.1875, -0.25, -0.3125, 0.375},
{-0.25, -0.5, 0, -0.1875, -0.25, 0.0625},
{-0.3125, -0.25, 0, -0.125, -0.25, 0.0625},
{-0.25, -0.25, -0.0625, -0.1875, -0.25, 0.125},
{-0.3125, -0.5, -0.25, -0.25, -0.3125, -0.1875},
{-0.375, -0.3125, -0.25, -0.1875, -0.3125, -0.1875},
{-0.3125, -0.3125, -0.3125, -0.25, -0.3125, -0.125},
{-0.0625, -0.5, -0.3125, 6.33299e-08, -0.25, -0.25},
{-0.125, -0.25, -0.3125, 0.0624999, -0.25, -0.25},
{-0.0625, -0.25, -0.375, -5.02914e-08, -0.25, -0.1875},
{0.0625, -0.5, 0.0625, 0.125, -0.3125, 0.125},
{0, -0.3125, 0.0625, 0.1875, -0.3125, 0.125},
{0.0625, -0.3125, 0, 0.125, -0.3125, 0.1875},
{-0.0625, -0.5, -0.0625, 5.7742e-08, -0.1875, 1.22935e-07},
{-0.125, -0.1875, -0.0625, 0.0624999, -0.1875, 3.72529e-08},
{-0.0625, -0.1875, -0.125, -3.72529e-08, -0.1875, 0.0625},
{-0.125, -0.5, 0.1875, -0.0624999, -0.1875, 0.25},
{-0.1875, -0.1875, 0.1875, -1.00583e-07, -0.1875, 0.25},
{-0.125, -0.1875, 0.125, -0.0625, -0.1875, 0.3125},
{0.125, -0.5, -0.1875, 0.1875, -0.3125, -0.125},
{0.0625, -0.3125, -0.1875, 0.25, -0.3125, -0.125},
{0.125, -0.3125, -0.25, 0.1875, -0.3125, -0.0625},
{0.125, -0.5, 0.25, 0.1875, -0.1875, 0.3125},
{0.125, -0.1875, 0.1875, 0.1875, -0.1875, 0.375},
{0.0625, -0.1875, 0.25, 0.25, -0.1875, 0.3125},
{0.25, -0.5, 0.125, 0.3125, -0.25, 0.1875},
{0.1875, -0.25, 0.125, 0.375, -0.25, 0.1875},
{0.25, -0.25, 0.0625, 0.3125, -0.25, 0.25},
{0.3125, -0.5, -0.375, 0.375, -0.25, -0.3125},
{0.25, -0.25, -0.375, 0.4375, -0.25, -0.3125},
{0.3125, -0.25, -0.4375, 0.375, -0.25, -0.25},
{0.3125, -0.5, -0.0625, 0.375, -0.375, 1.02445e-07},
{0.25, -0.375, -0.0625, 0.4375, -0.375, -3.72529e-08},
{0.3125, -0.375, -0.125, 0.375, -0.375, 0.0625},
},
},
light_source = 1,
node_placement_prediction = "",
on_place = on_place,
_mcl_blast_resistance = 0,
})
minetest.register_node(":mcl_flowers:oxeye_daisy", {
description = ("Oxeye Daisy"),
drawtype = "nodebox",
tiles = {
"mcl_small_3d_plants_oxeye_daisy_top.png",
"mcl_small_3d_plants_oxeye_daisy_top.png",
"mcl_small_3d_plants_oxeye_daisy.png",
"mcl_small_3d_plants_oxeye_daisy.png",
"mcl_small_3d_plants_oxeye_daisy.png",
"mcl_small_3d_plants_oxeye_daisy.png"
},
inventory_image = "mcl_flowers_oxeye_daisy.png",
wield_image = "mcl_flowers_oxeye_daisy.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
groups = {flora=1, dig_immediate=3,flower=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
node_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, 0.0625, 0, 0.375, 0.125},
{-0.125, 0.375, 0.0625, 0.0625, 0.375, 0.125},
{-0.0625, 0.375, 0, 0, 0.375, 0.1875},
{-0.1875, -0.5, 0.1875, -0.125, 0.25, 0.25},
{-0.25, 0.25, 0.1875, -0.0625, 0.25, 0.25},
{-0.1875, 0.25, 0.125, -0.125, 0.25, 0.3125},
{-0.1875, -0.5, -0.0625, -0.125, 0.25, -5.58794e-08},
{-0.25, 0.25, -0.0625, -0.0625, 0.25, 3.72529e-09},
{-0.1875, 0.25, -0.125, -0.125, 0.25, 0.0625},
{0.0625, -0.5, -0.0625, 0.125, 0.25, -5.58794e-08},
{0, 0.25, -0.0625, 0.1875, 0.25, 3.72529e-09},
{0.0625, 0.25, -0.125, 0.125, 0.25, 0.0625},
{0.0625, -0.5, 0.1875, 0.125, 0.25, 0.25},
{0, 0.25, 0.1875, 0.1875, 0.25, 0.25},
{0.0625, 0.25, 0.125, 0.125, 0.25, 0.3125},
{-0.0625, -0.5, 0.3125, 2.98023e-08, 0.125, 0.375},
{-0.125, 0.125, 0.3125, 0.0625, 0.125, 0.375},
{-0.0625, 0.125, 0.25, -2.98023e-08, 0.125, 0.4375},
{-0.0625, -0.5, -0.1875, 2.98023e-08, 0.125, -0.125},
{-0.125, 0.125, -0.1875, 0.0625, 0.125, -0.125},
{-0.0625, 0.125, -0.25, -2.98023e-08, 0.125, -0.0625},
{-0.3125, -0.5, 0.0625, -0.25, 0.125, 0.125},
{-0.375, 0.125, 0.0625, -0.1875, 0.125, 0.125},
{-0.3125, 0.125, 0, -0.25, 0.125, 0.1875},
{0.1875, -0.5, 0.0625, 0.25, 0.125, 0.125},
{0.125, 0.125, 0.0625, 0.3125, 0.125, 0.125},
{0.1875, 0.125, 0, 0.25, 0.125, 0.1875},
{-0.3125, -0.5, 0.3125, -0.25, 0, 0.375},
{-0.375, 0, 0.3125, -0.1875, 0, 0.375},
{-0.3125, 0, 0.25, -0.25, 0, 0.4375},
{0.1875, -0.5, 0.3125, 0.25, 0, 0.375},
{0.125, 0, 0.3125, 0.3125, 0, 0.375},
{0.1875, 0, 0.25, 0.25, 0, 0.4375},
{0.1875, -0.5, -0.1875, 0.25, 0, -0.125},
{0.125, 0, -0.1875, 0.3125, 0, -0.125},
{0.1875, 0, -0.25, 0.25, 0, -0.0625},
{-0.3125, -0.5, -0.1875, -0.25, 0, -0.125},
{-0.375, 0, -0.1875, -0.1875, 0, -0.125},
{-0.3125, 0, -0.25, -0.25, 0, -0.0625},
{-0.1875, -0.5, -0.3125, -0.125, -0.125, -0.25},
{-0.25, -0.125, -0.3125, -0.0625001, -0.125, -0.25},
{-0.1875, -0.125, -0.375, -0.125, -0.125, -0.1875},
{0.0625, -0.5, -0.3125, 0.125, -0.125, -0.25},
{0, -0.125, -0.3125, 0.1875, -0.125, -0.25},
{0.0625, -0.125, -0.375, 0.125, -0.125, -0.1875},
{0.3125, -0.5, -0.3125, 0.375, -0.125, -0.25},
{0.25, -0.125, -0.3125, 0.4375, -0.125, -0.25},
{0.3125, -0.125, -0.375, 0.375, -0.125, -0.1875},
{0.3125, -0.5, -0.0625, 0.375, -0.125, 6.70552e-08},
{0.25, -0.125, -0.0625, 0.4375, -0.125, 2.23517e-08},
{0.3125, -0.125, -0.125, 0.375, -0.125, 0.0625},
{0.3125, -0.5, 0.1875, 0.375, -0.125, 0.25},
{0.25, -0.125, 0.1875, 0.4375, -0.125, 0.25},
{0.3125, -0.125, 0.125, 0.375, -0.125, 0.3125},
{-0.375, -0.5, -0.375, -0.3125, -0.125, -0.3125},
{-0.4375, -0.125, -0.375, -0.25, -0.125, -0.3125},
{-0.375, -0.125, -0.4375, -0.3125, -0.125, -0.25},
},
},
light_source = 1,
node_placement_prediction = "",
on_place = on_place,
_mcl_blast_resistance = 0,
})
minetest.register_node(":mcl_flowers:dandelion", {
description = ("Dandelion"),
drawtype = "nodebox",
tiles = {
"mcl_small_3d_plants_dandelion_yellow_top.png",
"mcl_small_3d_plants_dandelion_yellow_top.png",
"mcl_small_3d_plants_dandelion_yellow.png",
"mcl_small_3d_plants_dandelion_yellow.png",
"mcl_small_3d_plants_dandelion_yellow.png",
"mcl_small_3d_plants_dandelion_yellow.png"
},
inventory_image = "flowers_dandelion_yellow.png",
wield_image = "flowers_dandelion_yellow.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
groups = {flora=1, dig_immediate=3,flower=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
node_box = {
type = "fixed",
fixed = {
{0, -0.5, -0.0625, 0.0625, 0.3125, 3.72529e-09},
{-0.125, 0.3125, -0.1875, 0.1875, 0.375, 0.125},
{-0.0625, 0.375, -0.125, 0.125, 0.4375, 0.0625},
{0.0625, -0.5, 0, 0.0625, -0.3125, 0.0625},
{0.0625, -0.4375, 0.0625, 0.0625, -0.25, 0.125},
{0.0625, -0.3125, 0.125, 0.0625, -0.125, 0.1875},
{0.0625, -0.4375, -0.125, 0.0625, -0.25, -0.0625},
{0.0625, -0.375, -0.1875, 0.0625, -0.1875, -0.125},
{0.0625, -0.25, -0.25, 0.0625, -0.0624999, -0.1875},
{-0.0625, -0.5, -0.0625, 7.45058e-09, -0.3125, -0.0625},
{-0.125, -0.4375, -0.0625, -0.0625, -0.25, -0.0625},
{-0.1875, -0.3125, -0.0625, -0.125, -0.125, -0.0625},
{0.0625, -0.4375, -0.0625, 0.125, -0.25, -0.0625},
{0.125, -0.375, -0.0625, 0.1875, -0.1875, -0.0625},
{0.1875, -0.25, -0.0625, 0.25, -0.0624999, -0.0625},
},
},
light_source = 1,
node_placement_prediction = "",
on_place = on_place,
_mcl_blast_resistance = 0,
})
minetest.register_node(":mcl_flowers:blue_orchid", {
description = ("Blue Orchid"),
drawtype = "nodebox",
tiles = {
"mcl_small_3d_plants_blue_orchid_top.png",
"mcl_small_3d_plants_blue_orchid_top.png",
"mcl_small_3d_plants_blue_orchid.png",
"mcl_small_3d_plants_blue_orchid.png",
"mcl_small_3d_plants_blue_orchid.png",
"mcl_small_3d_plants_blue_orchid.png"},
inventory_image = "mcl_flowers_blue_orchid.png",
wield_image = "mcl_flowers_blue_orchid.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
groups = {flora=1, dig_immediate=3,flower=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
node_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, 0, 0, -0.3125, 0.0625},
{-0.0625, -0.375, -0.0625, 0, -0.1875, 0},
{-0.0625, -0.25, 0, 0, -0.0625, 0.0625},
{-0.0625, -0.125, -0.0625, 0, -0.0625, 0},
{-0.0625, -0.125, 0.0625, 0, -0.0625, 0.125},
{0, -0.125, 0, 0.0625, -0.0625, 0.0625},
{-0.125, -0.125, 0, -0.0625, -0.0625, 0.0625},
{-0.1875, -0.0625, 0, -0.125, 0.0625, 0.0625},
{0.0625, -0.0625, 0, 0.125, 0.0625, 0.0625},
{-0.0625, -0.0625, 0.125, -2.98023e-08, 0.0625, 0.1875},
{-0.0625, -0.0625, -0.125, -2.98023e-08, 0.0625, -0.0625},
{-0.0625, 0.0625, -0.1875, -2.98023e-08, 0.125, -0.125},
{-0.0625, 0.0625, 0.1875, -2.98023e-08, 0.125, 0.25},
{0.125, 0.0625, 0, 0.1875, 0.125, 0.0625},
{-0.25, 0.0625, 0, -0.1875, 0.125, 0.0625},
{-0.25, 0.125, 0, -0.1875, 0.1875, 0.0625},
{-0.0625, 0.125, 0.1875, 4.47035e-08, 0.1875, 0.25},
{-0.0625, 0.125, -0.1875, 4.47035e-08, 0.1875, -0.125},
{0.125, 0.125, 0, 0.1875, 0.1875, 0.0625},
{0.125, 0.125, -0.0625, 0.1875, 0.1875, 1.11759e-08},
{0.125, 0.125, 0.0625, 0.1875, 0.1875, 0.125},
{0.1875, 0.125, 0, 0.25, 0.1875, 0.0625},
{0.0625, 0.125, 0, 0.125, 0.1875, 0.0625},
{-0.0625, 0.125, -0.125, 2.98023e-08, 0.1875, -0.0625},
{-0.0625, 0.125, -0.25, 2.98023e-08, 0.1875, -0.1875},
{0, 0.125, -0.1875, 0.0625, 0.1875, -0.125},
{-0.125, 0.125, -0.1875, -0.0625, 0.1875, -0.125},
{-0.25, 0.125, -0.0625, -0.1875, 0.1875, -2.23517e-08},
{-0.25, 0.125, 0.0625, -0.1875, 0.1875, 0.125},
{-0.3125, 0.125, 0, -0.25, 0.1875, 0.0625},
{-0.1875, 0.125, 0, -0.125, 0.1875, 0.0625},
{-0.0625, 0.125, 0.125, -3.35276e-08, 0.1875, 0.1875},
{-0.0625, 0.125, 0.25, -3.35276e-08, 0.1875, 0.3125},
{0, 0.125, 0.1875, 0.0625, 0.1875, 0.25},
{-0.125, 0.125, 0.1875, -0.0625, 0.1875, 0.25},
{-0.0625, 0.1875, 0.1875, -2.6077e-08, 0.25, 0.25},
{-0.0625, 0.1875, -0.1875, -2.6077e-08, 0.25, -0.125},
{-0.25, 0.1875, 0, -0.1875, 0.25, 0.0624999},
{0.125, 0.1875, 0, 0.1875, 0.25, 0.0624999},
{0.0625, 0.0625, 0, 0.125, 0.125, 0.0624999},
{-0.0625, 0.0625, 0.125, -2.98023e-08, 0.125, 0.1875},
{-0.1875, 0.0625, 0, -0.125, 0.125, 0.0624999},
{-0.0625, 0.0625, -0.125, -4.09782e-08, 0.125, -0.0625001},
},
},
light_source = 1,
node_placement_prediction = "",
on_place = on_place,
_mcl_blast_resistance = 0,
})
minetest.register_node(":mcl_flowers:poppy", {
description = ("Poppy"),
drawtype = "nodebox",
tiles = {"mcl_small_3d_plants_poppy_top.png",
"mcl_small_3d_plants_poppy_top.png",
"mcl_small_3d_plants_poppy_side.png",
"mcl_small_3d_plants_poppy_side.png",
"mcl_small_3d_plants_poppy_side.png",
"mcl_small_3d_plants_poppy_side.png"},
inventory_image = "mcl_flowers_poppy.png",
wield_image = "mcl_flowers_poppy.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
groups = {flora=1, dig_immediate=3,flower=1,attached_node=1,dig_by_water=1,destroy_by_lava_flow=1,dig_by_piston=1,enderman_takable=1,deco_block=1},
sounds = mcl_sounds.node_sound_leaves_defaults(),
node_box = {
type = "fixed",
fixed = {
{-0.25, -0.5, 0.1875, -0.1875, 0.375, 0.25},
{-0.4375, 0.375, 0.125, -0.25, 0.375, 0.3125},
{-0.1875, 0.375, 0.125, -1.63913e-07, 0.375, 0.3125},
{-0.1875, -0.5, -0.25, -0.125, 0.25, -0.1875},
{-0.25, 0.25, -0.1875, -0.0625002, 0.25, -1.49012e-08},
{-0.25, 0.25, -0.4375, -0.0625003, 0.25, -0.25},
{0.1875, -0.5, -0.0625, 0.25, 0.0625, -1.11759e-08},
{0.125, 0.0625, -0.25, 0.3125, 0.0625, -0.0625},
{0.125, 0.0625, 0, 0.3125, 0.0625, 0.1875},
},
},
light_source = 1,
node_placement_prediction = "",
on_place = on_place,
_mcl_blast_resistance = 0,
})
dofile(modpath.."/flowerpots.lua")
|
--[[ ==========================================================================
Teleport.lua
========================================================================== ]]--
local _G = _G
local AddOnName, _ = ...
local AddOn = _G[AddOnName]
-- Libs
--local LibStub = _G.LibStub
--local L = LibStub("AceLocale-3.0"):GetLocale(AddOnName)
local GetContainerItemID = _G.GetContainerItemID
local ids = {
6948, -- Standard Hearth
110560, -- Garrison Hearth
140192, -- Dalaran Hearth
52251, -- Jaina's Locket
103678, -- Time-Lost Artifact
37863, -- Direbrew's Remote
141605, -- Flight Master's Whistle
128353, -- Admiral's Compass
103678, -- Time-Lost Artifact
65274, -- Cloak of Coordination
}
local function Matches(bag, slot, _)
local itemId = GetContainerItemID(bag, slot)
for _, itemlistid in pairs(ids) do
if itemId == itemlistid then
return true
end
end
end
-- Clean rule
local function CleanRule(rule)
rule.bagid=0
end
AddOn:AddCustomRule("Teleport", {
DisplayName = "Teleport",
Description = "Matches items that port your character.",
Matches = Matches,
CleanRule = CleanRule
}) |
require "util"
-- Belts lanes have 4 slots: yellow 36 ticks, red 18 ticks, blue 12 ticks
-- Ticks to clear a slot 9, 4.5, 3
-- Splitters/underground 2 slots: need twice the tick rate
-- Red splitter/underground do some magic -- cuase technically they should have a gap
-- Should take 9 ticks for 2 items to clear out of the way, but on splitter/underground they dissapear ahead of schedule.
-- On red splitter/underground belt they alternate sending items on tick 0, 6, 18, 24, 30 = 9 average
local chestThrottle = 6
local railCheckThrottle = chestThrottle * 15
local voidThrottle = chestThrottle * 20
local energy_per_action = 8000
local idleDraw = 500
local beltBalancerThrottle = 12
-- Internal Use
local dataVersion = 13
-- How many a chest can pull from a belt lane 0-8
local inputMultiplier = 8
-- Inventory to Inventory transfer stack size
local maxStackSize = 4
-- Cardinal Directions
local NORTH = defines.direction.north
local EAST = defines.direction.east
local SOUTH = defines.direction.south
local WEST = defines.direction.west
-- Optimal places on a belt to place item
local beltPositions = {0, .182, .463, .744}
local splitterPositions = {0, .28}
-- Adjacent tiles
function areaNorth(position) return {{position.x - 0.5, position.y - 1.5},{position.x + 0.5, position.y - 0.5}} end
function areaSouth(position) return {{position.x - 0.5, position.y + 0.5},{position.x + 0.5, position.y + 1.5}} end
function areaEast(position) return {{position.x + 0.5, position.y - 0.5},{position.x + 1.5, position.y + 0.5}} end
function areaWest(position) return {{position.x - 1.5, position.y - 0.5},{position.x - 0.5, position.y + 0.5}} end
-- Area around tile
function getBoundingBox(position, radius)
return {{x=position.x-radius-.5,y=position.y-radius-.5},{x=position.x+radius+.5,y=position.y+radius+.5}}
end
-- Area around tile
function getBoundingBoxX(position, radius)
return {{x=position.x-radius-.5,y=position.y-.5},{x=position.x+radius+.5,y=position.y+.5}}
end
-- Area around tile
function getBoundingBoxY(position, radius)
return {{x=position.x-.5,y=position.y-radius-.5},{x=position.x+.5,y=position.y+radius+.5}}
end
-------------------
function InterfaceChest_Initialize()
if global.InterfaceChest_MasterList == nil then
global.InterfaceChest_MasterList = {}
end
if global.InterfaceChest_DataVersion == nil then
global.InterfaceChest_DataVersion = 0
end
if global.InterfaceBelt_MasterList == nil then
global.InterfaceBelt_MasterList = {}
end
if global.InterfaceBelt_DataVersion == nil then
global.InterfaceBelt_DataVersion = 0
end
end
-------------------
function getKey (position)
return "if_x" .. position.x .. "y".. position.y
end
function InterfaceChest_Create(event)
local entity = event.created_entity
if isInterfaceChest(entity) then
local modTick = game.tick % chestThrottle
local key = getKey(entity.position)
if global.InterfaceChest_MasterList[modTick] == nil then
global.InterfaceChest_MasterList[modTick] = {}
end
global.InterfaceChest_MasterList[modTick][key] = updateInterfaceChest(entity)
--debugPrint("Interface Chest created: " .. key)
end
if entity.name == "interface-belt-balancer" then
local key = getKey(entity.position)
local modTick = game.tick % beltBalancerThrottle
if global.InterfaceBelt_MasterList[modTick] == nil then
global.InterfaceBelt_MasterList[modTick] = {}
end
global.InterfaceBelt_MasterList[modTick][key] = entity
--debugPrint("Interface Belt count: " .. key)
end
if isTransport(entity) or isInventory(entity) or entity.type == "straight-rail" then
scheduleUpdate(entity, 3)
end
end
-------------------
function InterfaceChest_Rotated(event)
local entity = event.entity
if isTransport(entity) or isInventory(entity) or entity.type == "straight-rail" then
scheduleUpdate(entity, 3)
end
end
function InterfaceChest_Mined(event)
local entity = event.entity
if isTransport(entity) or isInventory(entity) or entity.type == "straight-rail" then
scheduleUpdate(entity, 3)
end
end
-------------------
function scheduleUpdate (entity, range)
local entities = entity.surface.find_entities(getBoundingBox(entity.position, range))
for index=1, #entities do
if isInterfaceChest( entities[index]) then
local chest = entities[index]
if chest and chest.valid then
for modTick=0, chestThrottle-1 do
if global.InterfaceChest_MasterList[modTick][getKey(chest.position)] then
global.InterfaceChest_MasterList[modTick][getKey(chest.position)].dirty = true
end
end
end
end
end
end
-------------------
function InterfaceBelt_RunStep()
if global.InterfaceBelt_DataVersion ~= dataVersion then
-- Initialize
InterfaceChest_Initialize()
local beltBalancer = game.surfaces[1].find_entities_filtered{area={{-10000, -10000},{10000, 10000}}, name="interface-belt-balancer"}
local masterList = {}
for index=0, beltBalancerThrottle-1 do
masterList[index] = {}
end
for index=1, #beltBalancer do
local entity = beltBalancer[index]
local modTick = math.random(beltBalancerThrottle) - 1
masterList[modTick][getKey(entity.position)] = entity
end
global.InterfaceBelt_MasterList = masterList
global.InterfaceBelt_DataVersion = dataVersion
else
local modTick = game.tick % beltBalancerThrottle
local masterList = global.InterfaceBelt_MasterList[modTick]
if masterList then
for index, value in pairs(masterList) do
local belt = value
if belt and belt.valid then
local left = belt.get_transport_line(1)
local right = belt.get_transport_line(2)
balanceBelt(right, left)
balanceBelt(left, right)
else
global.InterfaceBelt_MasterList[modTick][index] = nil
end
end
end
end
end
function balanceBelt (source, target)
local action = false
for item, size in pairs(source.get_contents()) do
local diff = size - target.get_item_count(item)
local itemstack = {name=item, count=1}
if diff > 2 and size > 2 then
if target.insert_at(beltPositions[1], itemstack) then
source.remove_item(itemstack)
action = true
end
if target.insert_at(beltPositions[2], itemstack) then
source.remove_item(itemstack)
action = true
end
elseif diff > 1 and size > 1 then
if target.insert_at(beltPositions[1], itemstack) then
source.remove_item(itemstack)
action = true
end
end
end
return action
end
-------------------
function InterfaceChest_RunStep(event)
if global.InterfaceChest_DataVersion ~= dataVersion then
-- Initialize
InterfaceChest_Initialize()
-- Find all this mod's chests and index them
local trashCan = game.surfaces[1].find_entities_filtered{area={{-10000, -10000},{10000, 10000}}, name="interface-chest-trash"}
local interfaceChests = game.surfaces[1].find_entities_filtered{area={{-10000, -10000},{10000, 10000}}, name="interface-chest"}
local masterList = {}
for index=0, chestThrottle-1 do
masterList[index] = {}
end
for index=1, #trashCan do
local modTick = math.random(chestThrottle) - 1
local chest = trashCan[index]
masterList[modTick][getKey(chest.position)] = updateInterfaceChest(chest)
end
for index=1, #interfaceChests do
local modTick = math.random(chestThrottle) - 1
local chest = interfaceChests[index]
masterList[modTick][getKey(chest.position)] = updateInterfaceChest(chest)
end
global.InterfaceChest_MasterList = masterList
global.InterfaceChest_DataVersion = dataVersion
else
InterfaceBelt_RunStep()
local modTick = game.tick % chestThrottle
local masterList = global.InterfaceChest_MasterList[modTick]
if masterList then
for index, value in pairs(masterList) do
local interfaceChest = value
if interfaceChest.chest and interfaceChest.chest.valid then
if interfaceChest.power == nil or interfaceChest.power.valid == false then
interfaceChest = updateInterfaceChest(interfaceChest.chest)
global.InterfaceChest_MasterList[modTick][index] = interfaceChest
--debugPrint("Create missing power for: " .. index)
else
if interfaceChest.power and interfaceChest.power.valid and interfaceChest.power.energy >= (idleDraw) then
interfaceChest.power.energy = interfaceChest.power.energy - idleDraw
if interfaceChest.chest.name == "interface-chest-trash" then
voidChest(interfaceChest, modTick, index)
else
-- No good way to check for nearby train, so if on rail check for train
if interfaceChest.onRail and modTick == (game.tick % railCheckThrottle) then
interfaceChest.dirty = true
end
local chestPosition = getBoundingBox(interfaceChest.chest.position, 0)
if interfaceChest.dirty then
interfaceChest = updateInterfaceChest(interfaceChest.chest)
global.InterfaceChest_MasterList[index] = interfaceChest
end
-- Input items Into Chest
for i=1, #interfaceChest.inputBelts do
local belt = interfaceChest.inputBelts[i]
if belt.valid then
if belt.type == "splitter" then
local chestPosition = getBoundingBox(interfaceChest.chest.position, 0)
if (belt.position.x == chestPosition[1].x and belt.position.y < chestPosition[1].y) or (belt.position.x == chestPosition[2].x and belt.position.y > chestPosition[1].y) or (belt.position.y == chestPosition[1].y and belt.position.x > chestPosition[2].x) or (belt.position.y == chestPosition[2].y and belt.position.x < chestPosition[2].x) then
beltToChest(belt, defines.transport_line.left_split_line, interfaceChest.chest, interfaceChest.power)
beltToChest(belt, defines.transport_line.right_split_line, interfaceChest.chest, interfaceChest.power)
else
beltToChest(belt, defines.transport_line.secondary_left_split_line, interfaceChest.chest, interfaceChest.power)
beltToChest(belt, defines.transport_line.secondary_right_split_line, interfaceChest.chest, interfaceChest.power)
end
else
beltToChest(belt, defines.transport_line.left_line, interfaceChest.chest, interfaceChest.power)
beltToChest(belt, defines.transport_line.right_line, interfaceChest.chest, interfaceChest.power)
end
end
end
-- Pull Items from adjacent Inventories
if #interfaceChest.inputBelts == 0 and #interfaceChest.outputBelts > 0 then
for i=1, #interfaceChest.inventories do
local inventory = interfaceChest.inventories[i]
local inventoryIndex = 1
if inventory and inventory.valid then
if inventory.get_output_inventory() and inventory.get_output_inventory().is_empty() == false then
sourceToTargetInventory(inventory, interfaceChest.chest, interfaceChest.power)
end
end
end
end
-- Output items to adjacent Belts
if interfaceChest.chest.get_output_inventory().is_empty() == false then
for i=1, #interfaceChest.outputBelts do
local belt = interfaceChest.outputBelts[i]
if belt.valid then
if belt.type == "splitter" then
local chestPosition = getBoundingBox(interfaceChest.chest.position, 0)
if (belt.position.x == chestPosition[1].x and belt.position.y > chestPosition[1].y) or (belt.position.x == chestPosition[2].x and belt.position.y < chestPosition[1].y) or (belt.position.y == chestPosition[1].y and belt.position.x < chestPosition[2].x) or (belt.position.y == chestPosition[2].y and belt.position.x > chestPosition[2].x) then
chestToBelt(belt, defines.transport_line.left_line, interfaceChest.chest, interfaceChest.power)
chestToBelt(belt, defines.transport_line.right_line, interfaceChest.chest, interfaceChest.power)
else
chestToBelt(belt, defines.transport_line.secondary_left_line, interfaceChest.chest, interfaceChest.power)
chestToBelt(belt, defines.transport_line.secondary_right_line, interfaceChest.chest, interfaceChest.power)
end
else
chestToBelt(belt, defines.transport_line.left_line, interfaceChest.chest, interfaceChest.power)
chestToBelt(belt, defines.transport_line.right_line, interfaceChest.chest, interfaceChest.power)
end
end
end
-- Output items to adjacent inventories
if #interfaceChest.outputBelts == 0 and #interfaceChest.inputBelts > 0 then
for i=1, #interfaceChest.inventories do
local inventory = interfaceChest.inventories[i]
sourceToTargetInventory(interfaceChest.chest, inventory, interfaceChest.power)
end
end
end
end
end
end
else
if interfaceChest ~= nil and interfaceChest.power and interfaceChest.power.valid then
if interfaceChest.power.destroy() then
--debugPrint("Power removed: " .. index)
global.InterfaceChest_MasterList[modTick][index] = nil
end
end
--debugPrint("Loaded: " .. index)
end
end
end
end
end
function updateInterfaceChest(chest)
local center = getBoundingBox(chest.position, 0)
local entities = chest.surface.find_entities(getBoundingBox(chest.position, 1))
local entitiesX = chest.surface.find_entities(getBoundingBoxX(chest.position, 1))
local entitiesY = chest.surface.find_entities(getBoundingBoxY(chest.position, 1))
local gridTransport = {}
local gridInventory = {}
local isRail = false
local powerSource = nil
for index=1, #entities do
local entity = entities[index]
if entity.type ~= "decorative" then
if isRail == false and entity.type == "straight-rail" then
isRail = true
elseif powerSource == nil and entity.name == "interface-chest-power" and entity.position.x > center[1].x and entity.position.x < center[2].x and entity.position.y > center[1].y and entity.position.y < center[2].y then
--debugPrint("Power: " .. entity.position.x .. " > " .. center[1].x .. " and " .. entity.position.x .. " < " .. center[2].x .. " and " .. entity.position.y .. " > " .. center[1].y .. " and " .. entity.position.y .. " < " .. center[2].y)
powerSource = entity
end
end
end
for index=1, #entitiesX do
local entity = entitiesX[index]
if entity.type ~= "decorative" then
-- East
if entity.position.x > center[2].x then
if isTransport(entity) then gridTransport.east = entity end
if isInventory(entity, isRail) then gridInventory.east = entity end
-- West
elseif entity.position.x < center[1].x then
if isTransport(entity) then gridTransport.west = entity end
if isInventory(entity, isRail) then gridInventory.west = entity end
end
end
end
for index=1, #entitiesY do
local entity = entitiesY[index]
if entity.type ~= "decorative" then
-- North
if entity.position.y < center[1].y then
if isTransport(entity) then gridTransport.north = entity end
if isInventory(entity, isRail) then gridInventory.north = entity end
-- South
elseif entity.position.y > center[2].y then
if isTransport(entity) then gridTransport.south = entity end
if isInventory(entity, isRail) then gridInventory.south = entity end
end
end
end
for index=1, #entities do
local entity = entities[index]
if entity.type ~= "decorative" then
-- North West
if entity.position.x <= center[1].x and entity.position.y <= center[1].y then
if isTransport(entity) then gridTransport.northWest = entity end
if isTrain(entity, isRail) then gridInventory.northWest = entity end
-- North East
elseif entity.position.x >= center[2].x and entity.position.y <= center[1].y then
if isTransport(entity) then gridTransport.northEast = entity end
if isTrain(entity, isRail) then gridInventory.northEast = entity end
-- South West
elseif entity.position.x <= center[1].x and entity.position.y >= center[2].y then
if isTransport(entity) then gridTransport.southWest = entity end
if isTrain(entity, isRail) then gridInventory.southWest = entity end
-- South East
elseif entity.position.x >= center[2].x and entity.position.y >= center[2].y then
if isTransport(entity) then gridTransport.southEast = entity end
if isTrain(entity, isRail) then gridInventory.southEast = entity end
end
end
end
if powerSource == nil then
--debugPrint("Create power: " .. serpent.block(chest.position))
powerSource = chest.surface.create_entity{name="interface-chest-power", position=chest.position, force=chest.force}
end
return {chest = chest, inputBelts = getInputBelts(gridTransport), outputBelts = getOutputBelts(gridTransport), inventories = getInventories(gridInventory), onRail = isRail, dirty = false, power = powerSource}
end
function voidChest(interfaceChest, modTick, index)
if interfaceChest.chest and interfaceChest.chest.valid and interfaceChest.power and interfaceChest.power.valid and interfaceChest.power.energy >= energy_per_action then
if interfaceChest.dirty then
interfaceChest = updateInterfaceChest(interfaceChest.chest)
global.InterfaceChest_MasterList[modTick][index] = interfaceChest
end
if modTick == (game.tick % voidThrottle) then
interfaceChest.chest.get_output_inventory().clear()
interfaceChest.power.energy = interfaceChest.power.energy - energy_per_action
end
for i=1, #interfaceChest.inputBelts do
local belt = interfaceChest.inputBelts[i]
if belt.valid then
if belt.type == "splitter" then
if (belt.position.x > interfaceChest.chest.position.x and belt.position.y > interfaceChest.chest.position.y) or (belt.position.x < interfaceChest.chest.position.x and belt.position.y < interfaceChest.chest.position.y) then
beltToVoid(belt, defines.transport_line.left_split_line, interfaceChest.power)
beltToVoid(belt, defines.transport_line.right_split_line, interfaceChest.power)
else
beltToVoid(belt, defines.transport_line.secondary_left_split_line, interfaceChest.power)
beltToVoid(belt, defines.transport_line.secondary_right_split_line, interfaceChest.power)
end
else
beltToVoid(belt, defines.transport_line.left_line, interfaceChest.power)
beltToVoid(belt, defines.transport_line.right_line, interfaceChest.power)
end
end
end
end
end
function beltToVoid(belt, laneNumber, power)
if power and power.valid and power.energy >= energy_per_action then
if belt.get_transport_line(laneNumber).can_insert_at(0) == false then
local items = belt.get_transport_line(laneNumber).get_contents()
local item = next(items)
local size = items[item]
if size then
local itemstack = {name=item, count=size}
belt.get_transport_line(laneNumber).remove_item(itemstack)
power.energy = power.energy - energy_per_action
end
end
end
end
function beltToChest(belt, laneNumber, chest, power)
if chest and chest.valid and power and power.valid and power.energy >= energy_per_action then
if belt.get_transport_line(laneNumber).can_insert_at(0) == false then
local lane = belt.get_transport_line(laneNumber)
local contents = lane.get_contents()
local item = next(contents)
local size = contents[item]
--debugPrint(item .. " " .. size)
if size then
local itemstack = {name=item, count=math.min(inputMultiplier,size)}
if chest and chest.valid and chest.can_insert(itemstack) then
itemstack.count = chest.insert(itemstack)
lane.remove_item(itemstack)
power.energy = power.energy - energy_per_action
end
end
end
end
end
function chestToBelt(belt, laneNumber, chest, power)
if chest and chest.valid and power and power.valid and power.energy >= energy_per_action then
local positions = {}
if belt.type == "transport-belt" then
positions = beltPositions
else
positions = splitterPositions
end
if belt.get_transport_line(laneNumber).can_insert_at(positions[1]) then
local inventory = chest.get_output_inventory()
local contents = inventory.get_contents()
local item = next(contents)
local size = contents[item]
local itemstack = {name=item, count=1}
if size then
--[[
--Find Positions 0 to 1
for i=0, 1000 do
if belt.get_transport_line(laneNumber).insert_at(i/1000, itemstack) then
debugPrint("Inserted: " .. i/1000 .. " tick: " .. game.tick)
power.energy = power.energy - energy_per_action
inventory.remove({name=item, count=1})
end
end
--Find Positions 1 to 0
for i=1, 1000 do
if belt.get_transport_line(laneNumber).insert_at((1001-i)/1000, itemstack) then
debugPrint("Inserted: " .. (1001-i)/1000 .. " tick: " .. game.tick)
power.energy = power.energy - energy_per_action
inventory.remove({name=item, count=1})
end
end
]]--
local toTransfer = math.min(#positions, size)
for i=1, toTransfer do
if belt.get_transport_line(laneNumber).insert_at(positions[i], itemstack) then
--debugPrint("Inserted: " .. positions[i] .. " tick: " .. game.tick)
power.energy = power.energy - energy_per_action
inventory.remove({name=item, count=1})
end
end
end
end
end
end
function sourceToTargetInventory(source, target, power)
if source and source.valid and power and power.valid and power.energy >= energy_per_action then
local inventory = source.get_output_inventory()
local contents = inventory.get_contents()
local item = next(contents)
local size = contents[item]
if size then
local itemstack = {name=item, count=math.min(maxStackSize,size)}
if target and target.valid and target.can_insert(itemstack) then
itemstack.count = target.insert(itemstack)
inventory.remove(itemstack)
power.energy = power.energy - energy_per_action
end
end
end
end
function getInputBelts(grid)
local belts = {}
local belt
-- North
belt = checkTransportEntity(grid.north, SOUTH, "output")
if belt then
belts[#belts+1] = belt
end
-- South
belt = checkTransportEntity(grid.south, NORTH, "output")
if belt then
belts[#belts+1] = belt
end
-- East
belt = checkTransportEntity(grid.east, WEST, "output")
if belt then
belts[#belts+1] = belt
end
-- West
belt = checkTransportEntity(grid.west, EAST, "output")
if belt then
belts[#belts+1] = belt
end
return belts
end
function getOutputBelts(grid)
local belts = {}
local belt
local checkNorth
local checkEast
local checkSouth
local checkWest
-- North
belt = checkTransportEntity(grid.north, NORTH, "input")
if belt then
if belt.type == "transport-belt" then
checkWest = checkTransportEntity(grid.northWest, EAST, "output")
checkEast = checkTransportEntity(grid.northEast, WEST, "output")
if (checkWest and checkEast) or (checkWest == nil and checkEast == nil) then
belts[#belts+1] = belt
end
else
belts[#belts+1] = belt
end
end
-- South
belt = checkTransportEntity(grid.south, SOUTH, "input")
if belt then
if belt.type == "transport-belt" then
checkWest = checkTransportEntity(grid.southWest, EAST, "output")
checkEast = checkTransportEntity(grid.southEast, WEST, "output")
if (checkWest and checkEast) or (checkWest == nil and checkEast == nil) then
belts[#belts+1] = belt
end
else
belts[#belts+1] = belt
end
end
-- East
belt = checkTransportEntity(grid.east, EAST, "input")
if belt then
if belt.type == "transport-belt" then
checkNorth = checkTransportEntity(grid.northEast, SOUTH, "output")
checkSouth = checkTransportEntity(grid.southEast, NORTH, "output")
if (checkNorth and checkSouth) or (checkNorth == nil and checkSouth == nil) then
belts[#belts+1] = belt
end
else
belts[#belts+1] = belt
end
end
-- West
belt = checkTransportEntity(grid.west, WEST, "input")
if belt then
if belt.type == "transport-belt" then
checkNorth = checkTransportEntity(grid.northWest, SOUTH, "output")
checkSouth = checkTransportEntity(grid.southWest, NORTH, "output")
if (checkNorth and checkSouth) or (checkNorth == nil and checkSouth == nil) then
belts[#belts+1] = belt
end
else
belts[#belts+1] = belt
end
end
return belts
end
function getInventories(grid)
local inventories = {}
local inventory
-- North
inventory = grid.north
if inventory then
inventories[#inventories+1] = inventory
end
-- South
inventory = grid.south
if inventory then
inventories[#inventories+1] = inventory
end
-- East
inventory = grid.east
if inventory then
inventories[#inventories+1] = inventory
end
--West
inventory = grid.west
if inventory then
inventories[#inventories+1] = inventory
end
-- North East
inventory = grid.northEast
if inventory then
inventories[#inventories+1] = inventory
end
-- South East
inventory = grid.southEast
if inventory then
inventories[#inventories+1] = inventory
end
-- North West
inventory = grid.northWest
if inventory then
inventories[#inventories+1] = inventory
end
-- South West
inventory = grid.southWest
if inventory then
inventories[#inventories+1] = inventory
end
return inventories
end
function checkTransportEntity(entity, direction, undergroundType)
if entity and (entity.type ~= "underground-belt" or (entity.type == "underground-belt" and entity.belt_to_ground_type == undergroundType)) and entity.direction == direction then
return entity
else
return nil
end
end
function isInventory (entity, onTrack)
if entity and entity.name ~= "interface-chest" and entity.type ~= "beacon" and entity.get_output_inventory() ~= nil and (isMoveable(entity) == false or isTrain(entity, onTrack)) then
return entity
else
return nil
end
end
function isMoveable (entity)
if (entity.type == "cargo-wagon" or entity.type == "locomotive" or entity.type == "car" or entity.type == "player") then
return true
else
return false
end
end
--or (entity.type == "player" and entity.walking_state == false)
function isTrain (entity, onTrack)
if entity and onTrack and ((entity.type == "cargo-wagon" and entity.train.speed == 0) or (entity.type == "locomotive" and entity.train.speed == 0) or (entity.type == "car" and entity.speed == 0)) then
return entity
else
return nil
end
end
function isTransport (entity)
if entity and (entity.type == "transport-belt" or entity.type == "splitter" or entity.type == "underground-belt") then
return entity
else
return nil
end
end
function isInterfaceChest (entity)
if entity.name == "interface-chest" or entity.name == "interface-chest-trash" then
return true
else
return false
end
end
function debugPrint(thing)
for _, player in pairs(game.players) do
player.print(serpent.block(thing))
end
end
-- Once per save
script.on_init(InterfaceChest_Initialize)
-- Every Tick
script.on_event(defines.events.on_tick, InterfaceChest_RunStep)
-- On create
script.on_event(defines.events.on_built_entity, InterfaceChest_Create)
script.on_event(defines.events.on_robot_built_entity, InterfaceChest_Create)
-- On change
script.on_event(defines.events.on_player_rotated_entity, InterfaceChest_Rotated)
-- On remove
script.on_event(defines.events.on_preplayer_mined_item, InterfaceChest_Mined)
script.on_event(defines.events.on_robot_pre_mined, InterfaceChest_Mined)
script.on_event(defines.events.on_entity_died, function(event)
local entity = event.entity
if entity.name == "interface-chest-power" then
local entities = entity.surface.find_entities(getBoundingBox(entity.position, 0))
for index=1, #entities do
if isInterfaceChest( entities[index]) then
local chest = entities[index]
if chest and chest.valid then
--debugPrint("Chest Destoyed: " .. getKey(chest.location))
chest.destroy()
end
end
end
end
end)
|
local PlayerStorage = require(game:GetService("ServerScriptService").Server:WaitForChild("PlayerStorage"))
local GuiSystem = require(game:GetService("ServerScriptService").Server:WaitForChild("GuiSystem"))
local CregicalSystem = require(game:GetService("ServerScriptService").Server:WaitForChild("CregicalSystem")) -- Delete this later
local TrainerSystem = require(game:GetService("ServerScriptService").Server:WaitForChild("TrainerSystem")) -- Delete this later
local DialogueSystem = require(game:GetService("ServerScriptService").Server:WaitForChild("DialogueSystem"))
local MenuSystem = require(game:GetService("ServerScriptService").Server:WaitForChild("MenuSystem")) -- Delete this later
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
print(player.Name .. " joined the game!")
DialogueSystem.InitPlayer(player)
MenuSystem.InitPlayer(player)
if not PlayerStorage.init(player.UserId) then
print(player.Name .. " joined the game for the first time!")
PlayerStorage.Storage[player.UserId]['cregicals'] = {}
PlayerStorage.Storage[player.UserId]['cregicals'][1] = CregicalSystem.genCregical(1, math.random(1, 4))
PlayerStorage.Storage[player.UserId]['cregicals'][2] = CregicalSystem.genCregical(1, math.random(1, 4))
PlayerStorage.Storage[player.UserId]['cregicals'][3] = CregicalSystem.genCregical(2, math.random(1, 4))
end
GuiSystem.initPlayer(player)
for _ = 1, 5, 1 do
TrainerSystem.GenerateTrainer(1) -- Delete this later
end
end)
Players.PlayerRemoving:Connect(function(player)
print(player.Name .. " left the game!")
end)
|
if #arg == 0 then
io.write[[
Creates a Makefile to build the DDLParser library as well as a test, template
based code generator.
Usage: lua createmk.lua <platform> [ -I path ]... [ -L path ]...
Where <platform> can be mingw, linux, msvc-x86 or msvc-x64. If your Lua and
AStyle development files are not in the compiler's search paths, you can
specify additional include paths with -I and library paths with -L. This is
only needed for Linux, Lua and AStyle development headers and
libraries for MinGW and MSVC are included.
mingw: Open a MSYS prompt, create the Makefile and run make. You must have
a recent version of Lua compiled with doubles in your include and
library search paths as well as gperf.
linux: Open a bash prompt, create the Makefile and run make. You must have
a recent version of Lua compiled with doubles in your include and
library search paths as well as gperf.
msvc-x86: Open a Visual Studio command prompt, create the Makefile
and run nmake.
msvc-x64: Open a Visual Studio x64 Win64 command prompt, create the Makefile
and run nmake.
]]
os.exit()
end
local platform = arg[ 1 ]
local incdirs = ''
local libdirs = ''
local i = 2
while i <= #arg do
if arg[ i ] == '-I' then
i = i + 1
if i > #arg then
io.stderr:write( 'Missing argument for -I\n' )
os.exit( 1 )
end
incdirs = incdirs .. '-I' .. arg[ i ] .. ' '
elseif arg[ i ] == '-L' then
i = i + 1
if i > #arg then
io.stderr:write( 'Missing argument for -L\n' )
os.exit( 1 )
end
libdirs = libdirs .. '-L' .. arg[ i ] .. ' '
else
io.stderr:write( 'Unknown option ', arg[ i ], '\n' )
os.exit( 1 )
end
i = i + 1
end
local config = {}
config.INCDIRS = incdirs
config.LIBDIRS = libdirs
if platform == 'mingw' then
config.EXEEXT = '.exe'
config.OBJEXT = '.o'
config.LIBNAME = 'lib%1.a'
config.CC = 'g++ -O2 -Iinclude -Ideps -D__WIN__ -DDDLT_TEMPLATE_DIR="\\"/usr/local/share/ddlt/\\"" -Wall -Wno-format -o $@ -c %1'
config.CCLIB = config.CC
config.CCLIBD = 'g++ -O0 -g -Iinclude -Ideps -D__WIN__ -DDDLT_TEMPLATE_DIR="\\"/usr/local/share/ddlt/\\"" -Wall -Wno-format -o $@ -c %1'
config.LIB = 'ar cru $@ ${ALLDEPS} && ranlib $@'
config.LINK = 'g++ -Ldeps -o $@ ${ALLDEPS}'
config.GPERF = '../util/gperf -c -C -l -L C++ -t -7 -m 100 -I'
config.RM = 'rm -f'
config.LUA = 'util/lua'
config.DEPLIBS = '-llua -lastyle'
config.DIRSEP = '/'
config.ALLDEPS = '$+'
elseif platform == 'linux' then
config.EXEEXT = ''
config.OBJEXT = '.o'
config.LIBNAME = 'lib%1.a'
config.CC = 'g++ -O2 -Iinclude ${INCDIRS} -DDDLT_TEMPLATE_DIR="\\"/usr/local/share/ddlt/\\"" -Wall -Wno-format -o $@ -c %1'
config.CCLIB = config.CC
config.CCLIBD = 'g++ -O0 -g -Iinclude ${INCDIRS} -DDDLT_TEMPLATE_DIR="\\"/usr/local/share/ddlt/\\"" -Wall -Wno-format -o $@ -c %1'
config.LIB = 'ar cru $@ ${ALLDEPS} && ranlib $@'
config.LINK = 'g++ ${LIBDIRS} -o $@ ${ALLDEPS}'
config.GPERF = 'gperf -c -C -l -L C++ -t -7 -m 100 -I'
config.RM = 'rm -f'
config.LUA = 'lua'
config.DEPLIBS = '-llua -lastyle'
config.DIRSEP = '/'
config.ALLDEPS = '$+'
elseif platform == 'msvc-x64' then
config.EXEEXT = '.exe'
config.OBJEXT = '.obj'
config.LIBNAME = '%1.lib'
config.CC = 'cl /Iinclude /Ideps /nologo /D__WIN__ /Dsnprintf=_snprintf /Dgetcwd=_getcwd /D_USE_MATH_DEFINES /DNDEBUG /Ox /GF /EHsc /MD /GS- /Gy /fp:precise /Zc:forScope /Gd /Fo$@ /c %1'
config.CCLIB = 'cl /Iinclude /Ideps /nologo /D__WIN__ /Dsnprintf=_snprintf /Dgetcwd=_getcwd /D_USE_MATH_DEFINES /DNDEBUG /Zi /Ox /GF /EHsc /MD /GS- /Gy /fp:precise /Zc:forScope /Gd /Fdoutput\\release\\ddlparser.pdb /Fo$@ /c %1'
config.CCLIBD = 'cl /Iinclude /Ideps /nologo /D__WIN__ /Dsnprintf=_snprintf /Dgetcwd=_getcwd /D_USE_MATH_DEFINES /UNDEBUG /Zi /Od /EHsc /RTC1 /MDd /GS /fp:precise /Zc:forScope /Gd /Fdoutput\\debug\\ddlparser.pdb /Fo$@ /c %1'
config.LIB = 'lib /nologo /out:$@ ${ALLDEPS}'
config.LINK = 'link /nologo /subsystem:console /out:$@ ${ALLDEPS}'
config.GPERF = '..\\util\\gperf -c -C -l -L C++ -t -7 -m 100 -I'
config.RM = 'util\\rmfiles'
config.LUA = 'util\\lua'
config.DEPLIBS = 'deps\\lua-x64.lib deps\\AStyleLib-x64.lib'
config.DIRSEP = '\\'
config.ALLDEPS = '$**'
elseif platform == 'msvc-x86' then
config.EXEEXT = '.exe'
config.OBJEXT = '.obj'
config.LIBNAME = '%1.lib'
config.CC = 'cl /Iinclude /Ideps /nologo /D__WIN__ /Dsnprintf=_snprintf /D_USE_MATH_DEFINES /DNDEBUG /Ox /GF /EHsc /MD /GS- /Gy /fp:precise /Zc:forScope /Gd /Fo$@ /c %1'
config.CCLIB = 'cl /Iinclude /Ideps /nologo /D__WIN__ /Dsnprintf=_snprintf /D_USE_MATH_DEFINES /DNDEBUG /Zi /Ox /GF /EHsc /MD /GS- /Gy /fp:precise /Zc:forScope /Gd /Fdoutput\\release\\ddlparser.pdb /Fo$@ /c %1'
config.CCLIBD = 'cl /Iinclude /Ideps /nologo /D__WIN__ /Dsnprintf=_snprintf /D_USE_MATH_DEFINES /UNDEBUG /Zi /Od /EHsc /RTC1 /MDd /GS /fp:precise /Zc:forScope /Gd /Fdoutput\\debug\\ddlparser.pdb /Fo$@ /c %1'
config.LIB = 'lib /nologo /out:$@ ${ALLDEPS}'
config.LINK = 'link /nologo /subsystem:console /out:$@ ${ALLDEPS}'
config.GPERF = '..\\util\\gperf -c -C -l -L C++ -t -7 -m 100 -I'
config.RM = 'util\\rmfiles'
config.LUA = 'util\\lua'
config.DEPLIBS = 'deps\\lua-x86.lib deps\\AStyleLib-x86.lib'
config.DIRSEP = '\\'
config.ALLDEPS = '$**'
else
error( 'Unknown platform ' .. platform )
end
local search_paths = { 'include', 'src', 'ddlt', 'util' }
local function findfile( file_name )
for _, search_path in ipairs( search_paths ) do
local path = search_path .. config.DIRSEP .. file_name
local file, err = io.open( path )
if file then
file:close()
return path
end
end
end
local depcache = {}
local function getdeps( file_name )
if depcache[ file_name ] then
return depcache[ file_name ]
end
local deps = {}
local file, err = io.open( file_name )
if file then
source = file:read( '*a' )
file:close()
for include in source:gmatch( '#include%s+[<"]([^>"]*)[>"]') do
local dep = findfile( include )
if dep and not deps[ dep ] then
deps[ dep ] = true
local deps2 = getdeps( dep )
for dep2 in pairs( deps2 ) do
deps[ dep2 ] = true
end
end
end
end
depcache[ file_name ] = deps
return deps
end
local function sub( key )
if config[ key ] then
return config[ key ]
end
if key:sub( 1, 5 ) == 'DEPS:' then
local deps = getdeps( key:sub( 6, -1 ):gsub( '\\', config.DIRSEP ) )
local str = ''
for dep in pairs( deps ) do
str = str .. dep .. ' '
end
return str .. key:sub( 6, -1 )
elseif key:sub( 1, 3 ) == 'CC:' then
return config.CC:gsub( '%%1', key:sub( 4, -1 ) )
elseif key:sub( 1, 6 ) == 'CCLIB:' then
return config.CCLIB:gsub( '%%1', key:sub( 7, -1 ) )
elseif key:sub( 1, 7 ) == 'CCLIBD:' then
return config.CCLIBD:gsub( '%%1', key:sub( 8, -1 ) )
elseif key:sub( 1, 4 ) == 'LIB:' then
return config.LIBNAME:gsub( '%%1', key:sub( 5, -1 ) )
elseif key == 'INSTLIB' then
return config.INSTLIB or '@echo "To install the DDLParser library, copy libddlparser.a from output/debug or output/release to /usr/local/lib and include/DDLParser.h to /use/local/include. Alternatively, add the include folder and either output/release or output/debug folders to your compiler paths."'
elseif key == 'INSTDDLT' then
return config.INSTDDLT or '@echo "To install ddlt, copy the ddlt/ddlt executable to /usr/local/bin. Alternatively, add the ddlt folder to your PATH."'
end
return key
end
local mkfile = [[
all: output~debug~${LIB:ddlparser} output~release~${LIB:ddlparser} ddlt~ddlt${EXEEXT} test~test${EXEEXT} test~test_nacl${EXEEXT} README README.html README.md
## ## #### ######## ######## ### ######## ## ##
#### ## ## ## ## ## ## ## ## ## ## ## ##
###### ## ## ## ## ## ## ## ## ## ## ####
######## ## ## ######## ######## ## ## ######## ##
###### ## ## ## ## ## ## ######### ## ## ##
#### ## ## ## ## ## ## ## ## ## ## ##
## ######## #### ######## ## ## ## ## ## ## ##
LIBOBJSD=output~debug~AreaManager${OBJEXT} output~debug~DDLParser${OBJEXT} output~debug~Error${OBJEXT} output~debug~Hash${OBJEXT} output~debug~JSONChecker${OBJEXT} output~debug~Lexer${OBJEXT} output~debug~Parser${OBJEXT} output~debug~Str${OBJEXT} output~debug~StringArea${OBJEXT} output~debug~Value${OBJEXT}
output~debug~${LIB:ddlparser}: $(LIBOBJSD)
${LIB}
output~debug~AreaManager${OBJEXT}: ${DEPS:src~AreaManager.cpp}
${CCLIBD:src~AreaManager.cpp}
output~debug~DDLParser${OBJEXT}: ${DEPS:src~DDLParser.cpp}
${CCLIBD:src~DDLParser.cpp}
output~debug~Error${OBJEXT}: ${DEPS:src~Error.cpp}
${CCLIBD:src~Error.cpp}
output~debug~Hash${OBJEXT}: ${DEPS:src~Hash.cpp}
${CCLIBD:src~Hash.cpp}
output~debug~JSONChecker${OBJEXT}: ${DEPS:src~JSONChecker.cpp}
${CCLIBD:src~JSONChecker.cpp}
output~debug~Lexer${OBJEXT}: ${DEPS:src~Lexer.cpp} src~Tokens.inc
${CCLIBD:src~Lexer.cpp}
output~debug~Parser${OBJEXT}: ${DEPS:src~Parser.cpp}
${CCLIBD:src~Parser.cpp}
output~debug~Str${OBJEXT}: ${DEPS:src~Str.cpp}
${CCLIBD:src~Str.cpp}
output~debug~StringArea${OBJEXT}: ${DEPS:src~StringArea.cpp}
${CCLIBD:src~StringArea.cpp}
output~debug~Value${OBJEXT}: ${DEPS:src~Value.cpp}
${CCLIBD:src~Value.cpp}
LIBOBJSR=output~release~AreaManager${OBJEXT} output~release~DDLParser${OBJEXT} output~release~Error${OBJEXT} output~release~Hash${OBJEXT} output~release~JSONChecker${OBJEXT} output~release~Lexer${OBJEXT} output~release~Parser${OBJEXT} output~release~Str${OBJEXT} output~release~StringArea${OBJEXT} output~release~Value${OBJEXT}
output~release~${LIB:ddlparser}: $(LIBOBJSR)
${LIB}
output~release~AreaManager${OBJEXT}: ${DEPS:src~AreaManager.cpp}
${CCLIB:src~AreaManager.cpp}
output~release~DDLParser${OBJEXT}: ${DEPS:src~DDLParser.cpp}
${CCLIB:src~DDLParser.cpp}
output~release~Error${OBJEXT}: ${DEPS:src~Error.cpp}
${CCLIB:src~Error.cpp}
output~release~Hash${OBJEXT}: ${DEPS:src~Hash.cpp}
${CCLIB:src~Hash.cpp}
output~release~JSONChecker${OBJEXT}: ${DEPS:src~JSONChecker.cpp}
${CCLIB:src~JSONChecker.cpp}
output~release~Lexer${OBJEXT}: ${DEPS:src~Lexer.cpp} src~Tokens.inc
${CCLIB:src~Lexer.cpp}
output~release~Parser${OBJEXT}: ${DEPS:src~Parser.cpp}
${CCLIB:src~Parser.cpp}
output~release~Str${OBJEXT}: ${DEPS:src~Str.cpp}
${CCLIB:src~Str.cpp}
output~release~StringArea${OBJEXT}: ${DEPS:src~StringArea.cpp}
${CCLIB:src~StringArea.cpp}
output~release~Value${OBJEXT}: ${DEPS:src~Value.cpp}
${CCLIB:src~Value.cpp}
src~Tokens.inc: src~Tokens.gperf
cd src && ${GPERF} --output-file=Tokens.inc Tokens.gperf && cd ..
## ######## ######## ## ## ######## ####### ######
#### ## ## ## ## ## ## ## ## ##
###### ## ## ## ## ## ## ##
######## ## ###### ### ## ####### ##
###### ## ## ## ## ## ## ##
#### ## ## ## ## ## ## ## ##
## ## ######## ## ## ## ######### ######
util~text2c${OBJEXT}: ${DEPS:util~text2c.cpp}
${CC:util~text2c.cpp}
util~text2c${EXEEXT}: util~text2c${OBJEXT}
${LINK}
## ######## ######## ## ########
#### ## ## ## ## ## ##
###### ## ## ## ## ## ##
######## ## ## ## ## ## ##
###### ## ## ## ## ## ##
#### ## ## ## ## ## ##
## ######## ######## ######## ##
DDLTOBJS=ddlt~Allocator${OBJEXT} ddlt~BitfieldIf${OBJEXT} ddlt~CompilerIf${OBJEXT} ddlt~DefinitionIf${OBJEXT} ddlt~SelectIf${OBJEXT} ddlt~StructIf${OBJEXT} ddlt~TagIf${OBJEXT} ddlt~Util${OBJEXT} ddlt~ddlt${OBJEXT}
ddlt~ddlt${EXEEXT}: $(DDLTOBJS) output~release~${LIB:ddlparser}
${LINK} ${DEPLIBS}
ddlt~Allocator${OBJEXT}: ${DEPS:ddlt~Allocator.cpp}
${CC:ddlt~Allocator.cpp}
ddlt~BitfieldIf${OBJEXT}: ${DEPS:ddlt~BitfieldIf.cpp}
${CC:ddlt~BitfieldIf.cpp}
ddlt~CompilerIf${OBJEXT}: ${DEPS:ddlt~CompilerIf.cpp}
${CC:ddlt~CompilerIf.cpp}
ddlt~DefinitionIf${OBJEXT}: ${DEPS:ddlt~DefinitionIf.cpp}
${CC:ddlt~DefinitionIf.cpp}
ddlt~SelectIf${OBJEXT}: ${DEPS:ddlt~SelectIf.cpp}
${CC:ddlt~SelectIf.cpp}
ddlt~StructIf${OBJEXT}: ${DEPS:ddlt~StructIf.cpp}
${CC:ddlt~StructIf.cpp}
ddlt~TagIf${OBJEXT}: ${DEPS:ddlt~TagIf.cpp}
${CC:ddlt~TagIf.cpp}
ddlt~Util${OBJEXT}: ${DEPS:ddlt~Util.cpp}
${CC:ddlt~Util.cpp}
ddlt~ddlt${OBJEXT}: ${DEPS:ddlt~ddlt.cpp} ddlt~ddlc.h
${CC:ddlt~ddlt.cpp}
ddlt~ddlc.h: ddlt~ddlc.lua util~text2c${EXEEXT}
util~text2c ddlt~ddlc.lua ddlc > ddlt~ddlc.h
## ######## ######## ###### ########
#### ## ## ## ## ##
###### ## ## ## ##
######## ## ###### ###### ##
###### ## ## ## ##
#### ## ## ## ## ##
## ## ######## ###### ##
test~test_ddl.h: ddlt~ddlt${EXEEXT} test~test.ddl
ddlt~ddlt -i test~test.ddl -t hpp -o test~test_ddl.h --search-path test
test~test_ddl.cpp: ddlt~ddlt${EXEEXT} test~test.ddl
ddlt~ddlt -i test~test.ddl -t cpp -I test_ddl.h -o test~test_ddl.cpp --search-path test
test~test_ddl${OBJEXT}: test~test_ddl.cpp test~test_ddl.h
${CC:test~test_ddl.cpp}
test~test${OBJEXT}: ${DEPS:test~test.cpp} test~test_ddl.h
${CC:test~test.cpp}
test~test${EXEEXT}: test~test${OBJEXT} test~test_ddl${OBJEXT}
${LINK}
echo "Running test..."
test~test
test~test_nacl_ddl.h: ddlt~ddlt${EXEEXT} test~test.ddl
ddlt~ddlt -i test~test.ddl -t nacl_hpp -o test~test_nacl_ddl.h --search-path test
test~test_nacl_ddl.cpp: ddlt~ddlt${EXEEXT} test~test.ddl
ddlt~ddlt -i test~test.ddl -t nacl_cpp -I test_nacl_ddl.h -o test~test_nacl_ddl.cpp --search-path test
test~test_nacl_ddl${OBJEXT}: test~test_nacl_ddl.cpp test/test_nacl_ddl.h
${CC:test~test_nacl_ddl.cpp}
test~test_nacl${OBJEXT}: test~test_nacl.cpp test~test_nacl_ddl.h test~test_nacl_ddl.cpp
${CC:test~test_nacl.cpp}
test~test_nacl${EXEEXT}: test~test_nacl${OBJEXT} test~test_nacl_ddl${OBJEXT}
${LINK}
echo "Running test_nacl..."
test~test_nacl
## ######## ####### ###### ## ## ## ## ######## ## ## ######## ### ######## #### ####### ## ##
#### ## ## ## ## ## ## ## ## ### ### ## ### ## ## ## ## ## ## ## ## ### ##
###### ## ## ## ## ## ## ## #### #### ## #### ## ## ## ## ## ## ## ## #### ##
######## ## ## ## ## ## ## ## ## ### ## ###### ## ## ## ## ## ## ## ## ## ## ## ## ##
###### ## ## ## ## ## ## ## ## ## ## ## #### ## ######### ## ## ## ## ## ####
#### ## ## ## ## ## ## ## ## ## ## ## ## ### ## ## ## ## ## ## ## ## ###
## ######## ####### ###### ####### ## ## ######## ## ## ## ## ## ## #### ####### ## ##
README: util~createdoc.lua
${LUA} util~createdoc.lua txt > $@
README.html: util~createdoc.lua
${LUA} util~createdoc.lua html > $@
README.md: util~createdoc.lua
${LUA} util~createdoc.lua md > $@
## #### ## ## ###### ######## ### ## ##
#### ## ### ## ## ## ## ## ## ## ##
###### ## #### ## ## ## ## ## ## ##
######## ## ## ## ## ###### ## ## ## ## ##
###### ## ## #### ## ## ######### ## ##
#### ## ## ### ## ## ## ## ## ## ##
## #### ## ## ###### ## ## ## ######## ########
install:
${INSTLIB}
${INSTDDLT}
## ###### ## ######## ### ## ##
#### ## ## ## ## ## ## ### ##
###### ## ## ## ## ## #### ##
######## ## ## ###### ## ## ## ## ##
###### ## ## ## ######### ## ####
#### ## ## ## ## ## ## ## ###
## ###### ######## ######## ## ## ## ##
clean:
${RM} src~Tokens.inc
${RM} output~debug~${LIB:ddlparser} $(LIBOBJSD) output~debug~ddlparser.pdb
${RM} output~release~${LIB:ddlparser} $(LIBOBJSR) output~release~ddlparser.pdb
${RM} ddlt~ddlt${EXEEXT} $(DDLTOBJS) ddlt~ddlc.h ddlt~ddlt.exp ddlt~ddlt.lib
${RM} etc~text2c${EXEEXT} etc~text2c${OBJEXT}
${RM} test~test_ddl.h test~test_ddl.cpp test~test_ddl${OBJEXT} test~test${OBJEXT} test~test${EXEEXT}
${RM} test~test_nacl_ddl.h test~test_nacl_ddl.cpp test~test_nacl_ddl${OBJEXT} test~test_nacl${OBJEXT} test~test_nacl${EXEEXT}
${RM} util~text2c${EXEEXT} util~text2c${OBJEXT}
]]
while true do
local mkfile2 = mkfile:gsub( '%${(%w+:?[^}]*)}', sub )
if mkfile2 == mkfile then
break
end
mkfile = mkfile2
end
mkfile = mkfile:gsub( '\n ', '\n\t' ):gsub( '~', config.DIRSEP )
io.write( mkfile )
|
--[[
chaos in a leaking faucet
time between drips is modeled with a logistic map
--]]
require "include/protoplug"
t = 0
r = 1
speed = 1
state = 0.1
interval = 0
function plugin.processBlock(s, smax)
for i = 0,smax do
local out = 0
t = t + 1
if(t > interval) then
t = t - interval
state = r*state*(1-state)
interval = (4-r)*50000*(1-state)/speed
out = (4-r)/(4.2-r)
end
s[0][i] = out
s[1][i] = out
end
end
params = plugin.manageParams {
-- automatable VST/AU parameters
-- note the new 1.3 way of declaring them
{
name = "Open tap";
min = 2.8;
max = 3.999;
default = 0;
changed = function(val) r = val end;
};
{
name = "Speed";
min = 0.1;
max = 2.1;
default = 1;
changed = function(val) speed = val end;
};
}
|
local function lprint(...)
local str = ""
for i = 1, select("#", ...) do
local c = select(i, ...)
if c == "" then c = "#" end
if i == 1 then
str = c
else
str = str .. " " .. c
end
end
debug_print(str)
return str
end
local function ltype(...)
local str = ""
for i = 1, select("#", ...) do
if i == 1 then
str = type(select(i, ...))
else
str = str .. " " .. type(select(i, ...))
end
end
debug_print(str)
return str
end
local function printc(t)
local s
if type(t) == "table" then
s = "{ "
for i, v in ipairs(t) do
s = s .. printc(i) .. ": " .. printc(v) .. ", "
end
for i, v in pairs(t) do
s = s .. printc(i) .. " = " .. printc(v) .. ", "
end
s = s .. "} "
elseif type(t) == "string" then
s = "\"" .. t .. "\""
elseif type(tostring(t)) == "string" then
s = tostring(t)
else
s = type(t)
end
return s
end
local function conf(...)
local str = ""
for i = 1, select("#", ...) do
str = str .. ", " .. printc(select(i, ...))
end
debug_print(str)
return str
end
local function l_G(mode)
for i, v in pairs(_G) do
debug_print(printc(i) .. " = " .. printc(v))
end
end
return {
print = lprint,
type = ltype,
conf = conf,
_G = l_G,
} |
META="Mod4+"
ALTMETA=""
ioncore.set{
dblclick_delay=250,
kbresize_delay=15000,
}
ioncore.set{
opaque_resize=true,
warp=true
}
dopath("cfg_defaults")
dopath("cfg_notioncore")
dopath("cfg_kludges")
dopath("cfg_layouts")
ioncore.defshortening("[^:]+: (.*)(<[0-9]+>)", "$1$2$|$1$<...$2")
dopath("mod_query")
dopath("mod_menu")
dopath("mod_tiling")
dopath("mod_statusbar")
--dopath("mod_dock")
--dopath("mod_sp")
defbindings("WScreen", {
-- kpress("Mod1+122", "_:switch_next()"),
bdoc("Mute/Unmute Sound."),
kpress("AnyModifier+XF86AudioMute", "ioncore.exec_on(_, 'amixer sset Master toggle')"),
bdoc("Increase Volume."),
kpress("AnyModifier+XF86AudioRaiseVolume", "ioncore.exec_on(_, 'amixer sset Master 3%+')"),
bdoc("Decrease Volume."),
kpress("AnyModifier+XF86AudioLowerVolume", "ioncore.exec_on(_, 'amixer sset Master 3%-')"),
bdoc("Increase Screen Brightness."),
kpress("AnyModifier+XF86MonBrightnessUp", "ioncore.exec_on(_, '/home/zack/bin/dback u')"),
bdoc("Decrease Screen Brightness."),
kpress("AnyModifier+XF86MonBrightnessDown", "ioncore.exec_on(_, '/home/zack/bin/dback d')"),
})
|
Locales['es'] = {
['invoices'] = 'Facturas',
['invoices_item'] = '%s$',
['received_invoice'] = 'Has ~r~recibido~s~ una multa',
['paid_invoice'] = 'Has ~g~pagado~s~ una multa de ~r~%s$~s~',
['no_invoices'] = 'No tienes ninguna factura para pagar en este momento',
['received_payment'] = 'Has ~g~recibido~s~ un pago de ~g~%s$~s~',
['player_not_online'] = 'El jugador no está conectado',
['no_money'] = 'No tienes suficiente dinero para pagar la factura',
['target_no_money'] = '¡El jugador ~r~no tiene~s~ suficiente dinero para pagar la factura!',
['keymap_showbills'] = 'Abrir menú de facturas',
}
|
local addon, ns = ...
local cfg = ns.cfg
if not cfg.embeds.rChat then return end
FloatingChatFrame_OnMouseScroll = function(self, dir)
if(dir > 0) then
if(IsShiftKeyDown()) then
self:ScrollToTop()
else
self:ScrollUp()
end
else
if(IsShiftKeyDown()) then
self:ScrollToBottom()
else
self:ScrollDown()
end
end
end |
--[[
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: 20220523
Generated by: https://openapi-generator.tech
]]
--[[
Unit tests for openapiclient.api.contest_effect_api
Automatically generated by openapi-generator (https://openapi-generator.tech)
Please update as you see appropriate
]]
describe("contest_effect_api", function()
local openapiclient_contest_effect_api = require "openapiclient.api.contest_effect_api"
-- unit tests for contest_effect_list
describe("contest_effect_list test", function()
it("should work", function()
-- TODO assertion here: http://olivinelabs.com/busted/#asserts
end)
end)
-- unit tests for contest_effect_read
describe("contest_effect_read test", function()
it("should work", function()
-- TODO assertion here: http://olivinelabs.com/busted/#asserts
end)
end)
end)
|
function foo(a,b,c)
return a,b,c
end
function bar(a, ...)
print(a); return ...
end
local x,y,z = bar("aaaa",foo())
print(x,y,z)
|
local spawnPositions = {
{1284.7861328125,-781.845703125,1084.0078125,89.691009521484},
{1263.892578125,-769.5361328125,1084.0078125,85.933624267578},
{1249.8505859375,-788.9677734375,1084.0078125,183.69694519043},
{1265.8759765625,-795.158203125,1084.0078125,355.23461914062},
{1283.2607421875,-788.9775390625,1084.0148925781,168.96954345703},
{1273.0322265625,-789.0029296875,1084.0078125,89.696502685547},
{1262.1904296875,-800.19140625,1084.0078125,195.60081481934},
{1266.78515625,-808.091796875,1084.0078125,95.310607910156},
{1226.240234375,-836.8720703125,1084.0078125,177.40716552734},
{1256.90625,-835.888671875,1084.0078125,274.25863647461},
{1233.7158203125,-812.8369140625,1084.0078125,163.619140625},
{1277.2265625,-835.05859375,1085.6328125,289.7331237793},
{1278.5888671875,-812.3212890625,1085.6328125,167.52484130859},
{1282.2919921875,-811.326171875,1089.9375,1.6012878417969},
{1274.4521484375,-773.7744140625,1091.90625,192.39825439453},
{1254.142578125,-794.263671875,1084.234375,267.04052734375},
{1279.208984375,-786.734375,1084.0148925781,142.33279418945},
}
local pedSkins = {
117,118
}
local enterMarkers = {}
local exitMarkers = {}
local lawSignUp = createMarker(1256.32, -776.17, 92.03-1,"cylinder",4,0,0,255,100)
local crimSignUp = createMarker( 1305.36, -798.32, 84.14-1,"cylinder",4,255,0,0,100)
local lawSignUpCol = createColCircle(1256.32, -776.17,3)
local crimSignUpCol = createColCircle( 1305.36, -798.32,3)
local timeLeft=0
local started=false
local weps = {
6,7,8,9,25,31,30,33,34,31,30,33,34,31,30,33,34,31,30,33,34,31,30,33,34,31,30,33,34
}
local eint,edim = 5,1
local peds = {}
local spawnedPlaces = {}
local timeTillEnd = 0
local crimse = {}
local lawse = {}
local entered = {}
local remainingpeds = 1
local team = "crim"
local startseq=false
local startcd = 60
local allowedToJoin={}
local antiBug = {}
setTimer(function()
for k,v in pairs(allowedToJoin) do
if (v) and getTickCount() - v > 7200000 then
allowedToJoin[k]=nil
end
end
end,10000,0)
function msg(a,b,c,d,e)
exports.NGCdxmsg:createNewDxMessage(a,b,c,d,e)
end
addCommandHandler("setmd",function(player,cmd,value,nm)
--if getElementData(player,"isPlayerPrime") == true then
if value == "switch" then
if nm and tonumber(nm) then
if isTimer(copsTurn) then killTimer(copsTurn) end
copsTurn = setTimer(function(player) if team=="law" then team="crim" else team="law" end check1() outputChatBox("MR team =!! "..team,player,255,255,0) end,nm,1,player)
end
elseif value == "info" then
outputChatBox("MR team =? "..team,player,255,255,0)
end
--end
end)
local enterPos = {
--{x,y,z,warptox,warptoy,warptoz,rotation of player after warp}
{1258.43, -783.07, 92.03 ,1263.13, -785.43, 1091.9,267},
{ 1258.51, -787.86, 92.03,1263.13, -785.43, 1091.9,267},
{1300.59, -798.41, 84.18,1298.79, -794.23, 1084,350}
}
local exitPos = {
{1260.64, -785.37, 1091.9,1254.78, -785.47, 92.03,84},
{1298.91, -796.9, 1084, 1299.55, -800.94, 84.14,192},
}
addEventHandler("onMarkerHit",lawSignUp,function(p,dim)
if dim == false then return end
if exports.DENlaw:isLaw(p) then
if started == true then
if team == "law" then
exports.NGCdxmsg:createNewDxMessage(p,"The Law Mansion Raid is occuring at the moment",255,255,0)
else
exports.NGCdxmsg:createNewDxMessage(p,"The Criminal Mansion Raid is occuring at the moment",255,255,0)
end
else
local acc = exports.server:getPlayerAccountName(p)
if (allowedToJoin[acc]) then
exports.NGCdxmsg:createNewDxMessage(p,"You did this event recently. You can only join this event once per 2 hours",0,0,255)
return
end
exports.NGCdxmsg:createNewDxMessage(p,"This is Law Mansion Raid Law Marker (/raidtime)",0,0,255)
if team == "law" then
exports.NGCdxmsg:createNewDxMessage(p,"The next Mansion Raid is going to be for Law Enforcement",0,0,255)
if timeLeft > 0 then
exports.NGCdxmsg:createNewDxMessage(p,"Come back here in "..timeLeft.." seconds",0,0,255)
else
--exports.NGCdxmsg:createNewDxMessage(p,"The event can be started, get 4 Law players in the marker",0,0,255)
exports.NGCdxmsg:createNewDxMessage(p,"Required to Start: "..(getLawMarkerCount()+1).."/4 Law.",0,255,0)
end
else
exports.NGCdxmsg:createNewDxMessage(p,"The next Mansion Raid is going to be for Criminals",0,0,255)
exports.NGCdxmsg:createNewDxMessage(p,"This marker only works when the mansion raid is for Law",0,0,255)
end
--if getLawCount() < 5 then
--end
startCheck()
end
end
end)
setTimer(function()
if timeLeft > 0 then timeLeft=timeLeft-1 end
if timeTillEnd > 0 then
timeTillEnd=timeTillEnd-1
if (team == "law") then
for k,v in ipairs (lawse) do
triggerClientEvent(v, "NGCraid:updateTimer", v, timeTillEnd)
end
elseif (team == "crim") then
for k,v in ipairs (crimse) do
triggerClientEvent(v, "NGCraid:updateTimer", v, timeTillEnd)
end
end
if timeTillEnd==0 then
endIt()
end
end
if startcd > 0 then
startcd=startcd-1
end
end,1000,0)
picked={}
function endIt(winner)
if started==false then return end
for k,v in pairs(peds) do
if isElement(v) then
destroyElement(v)
end
end
peds={}
if (team == "crim") then
for k,v in ipairs (crimse) do
local x,y,z = getElementPosition(crimSignUp)
setElementDimension(v, 0)
setElementInterior(v,0)
setElementPosition(v, x,y,z)
local reward = math.random(20000,30000)
givePlayerMoney(v, reward)
exports.NGCdxmsg:createNewDxMessage(v,"You have successfully raided the mansion and got $"..reward.."", 255,255,0)
exports.CSGgroups:addXP(p,8)
exports.AURcriminalp:giveCriminalPoints(p, "", 3)
table.remove(crimse, k)
setElementData(v, "isPlayerInMR", false)
triggerClientEvent(v, "onTogglemansionraidStats", v, false)
triggerClientEvent(v, "AURmansion:addWave", v, "reset")
end
elseif (team == "law") then
for k,v in ipairs (lawse) do
local x,y,z = getElementPosition(lawSignUp)
setElementDimension(v, 0)
setElementInterior(v,0)
setElementPosition(v, x,y,z)
local reward = math.random(20000,30000)
givePlayerMoney(v, reward)
exports.NGCdxmsg:createNewDxMessage(v,"You have successfully raided the mansion and got $"..reward.."", 255,255,0)
exports.CSGgroups:addXP(p,8)
table.remove(lawse, k)
setElementData(v, "isPlayerInMR", false)
triggerClientEvent(v, "onTogglemansionraidStats", v, false)
triggerClientEvent(v, "AURmansion:addWave", v, "reset")
end
end
--[[if (winner) then
if winner=="crims" then
for k,v in pairs(crimse) do
msg(v,"MD Mansion has been successfully raided. Go to the safe for money!",0,255,0)
msg(v,"You have 1 minute to steal the money!",0,255,0)
end
for k,v in pairs(getElementsByType("player")) do
msg(v,"The Criminal Forces have successfully raided MD Mansion!",0,255,0)
end
elseif winner=="laws" then
for k,v in pairs(lawse) do
msg(v,"MD Mansion has been cleared of hostile forces. Go to the safe and collect the illegal money!",0,255,0)
msg(v,"You have 1 minute to collect the money!",0,255,0)
end
for k,v in pairs(getElementsByType("player")) do
msg(v,"The Law Forces have successfully raided MD Mansion!",0,255,0)
end
else
if team == "law" then
for k,v in pairs(lawse) do
msg(v,"Mansion Raid has failed!",255,0,0)
msg(v,"The Mafia Men have taken over, too much time has past!",255,0,0)
--killPed(v)
triggerClientEvent(v,"onResetmansionraidStats",v)
end
else
for k,v in pairs(crimse) do
msg(v,"Mansion Raid has failed!",255,0,0)
msg(v,"The Security Guards have taken over, too much time has past!",255,0,0)
triggerClientEvent(v,"onResetmansionraidStats",v)
--killPed(v)
end
end
end
local t = {}
local x2,y2,z2 = 1230.76, -807.18, 1084
local obj = createObject(1550,x2,y2,z2)
table.insert(t,obj)
local m = createMarker(x2,y2,z2-1,"cylinder",2)
setElementInterior(m,eint)
setElementDimension(m,edim)
setElementInterior(obj,eint)
setElementDimension(obj,edim)
addEventHandler("onMarkerHit",m,hitbag)
setTimer(function() destroyElement(obj) end,60000,1)
setTimer(function() destroyElement(m) picked={} end,60000,1)
setTimer(function() antiBug = {} end,90000,1)
for k,v in pairs(crimse) do
triggerClientEvent(v,"CSGmansionRecBags",v,t,60000)
end
for k,v in pairs(lawse) do
triggerClientEvent(v,"CSGmansionRecBags",v,t,60000)
end
offwinner=winner
end]]--
timeTillEnd=0
timeLeft=3600
check1()
if team == "law" then team = "crim" else team = "law" end
started=false
picked={}
entered={}
startedseq=false
end
function hitbag(p,dim )
if dim == false then return end
if offwinner == "crims" then
if getTeamName(getPlayerTeam(p)) == "Criminals" or getTeamName(getPlayerTeam(p)) == "HolyCrap" then
if picked[p] ~= nil then return end
local m = math.random(10000,15000)
givePlayerMoney(p,m)
exports.CSGgroups:addXP(p,8)
exports.AURcriminalp:giveCriminalPoints(p, "", 3)
msg(p,"Picked up $"..m.."!",0,255,0)
picked[p]=true
end
elseif offwinner=="laws" then
if exports.DENlaw:isLaw(p) then
if picked[p] ~= nil then return end
local m = math.random(10000,15000)
givePlayerMoney(p,m)
exports.CSGgroups:addXP(p,6)
msg(p,"Picked up $"..m.."!",0,255,0)
picked[p]=true
end
end
triggerClientEvent(p,"CSGmd.getKC",p)
end
addEvent("CSGmd.recKC",true)
addEventHandler("CSGmd.recKC",root,function(kills)
if kills > 0 then
if canLawOfficerEnter(source) then
givePlayerMoney(source,kills*500)
msg(p,"Picked up $"..(kills*500).." for "..kills.." kills",0,255,0)
table.insert( antiBug, exports.server:getPlayerAccountName(source) )
else
exports.NGCdxmsg:createNewDxMessage(source, "You can only pickup the money once per the event!", 225, 0, 0 )
end
end
end)
function canLawOfficerEnter (plr)
local state = true
for k, theAccount in ipairs (antiBug) do
if ( theAccount == exports.server:getPlayerAccountName( plr ) ) then
state = false
end
end
return state
end
addEventHandler("onMarkerHit",crimSignUp,function(p,dim)
if dim == false then return end
if p and isElement(p) and getElementType(p) == "player" then
if getPlayerTeam(p) == getTeamFromName("Criminals") or getPlayerTeam(p) == getTeamFromName("HolyCrap") then
if started == true then
if team == "crim" then
exports.NGCdxmsg:createNewDxMessage(p,"The Criminal Mansion Raid is occuring at the moment",255,255,0)
else
exports.NGCdxmsg:createNewDxMessage(p,"The Law Enforcement Mansion Raid is occuring at the moment",255,255,0)
end
else
if (allowedToJoin[acc]) then
exports.NGCdxmsg:createNewDxMessage(p,"You did this event recently. You can only join this event once per 2 hours",255,255,0)
return
end
exports.NGCdxmsg:createNewDxMessage(p,"This is Criminal Mansion Raid Law Marker (/raidtime)",255,255,0)
if team == "crim" then
exports.NGCdxmsg:createNewDxMessage(p,"The next Mansion Raid is going to be for Criminals",255,255,0)
if timeLeft > 0 then
exports.NGCdxmsg:createNewDxMessage(p,"Come back here in "..timeLeft.." seconds",255,255,0)
else
exports.NGCdxmsg:createNewDxMessage(p,"Required to Start: "..(getCrimMarkerCount()+1).."/4 Criminals.",0,255,0)
end
else
exports.NGCdxmsg:createNewDxMessage(p,"The next Mansion Raid is going to be for Law Enforcement",255,255,0)
exports.NGCdxmsg:createNewDxMessage(p,"This marker only works when the mansion raid is for Criminals",255,255,0)
end
startCheck()
end
end
end
end)
function check1()
if started == true then
if isTimer(copsTurn) then killTimer(copsTurn) end
end
if not isTimer(copsTurn) and started == false then
copsTurn = setTimer(function() if team=="law" then team="crim" else team="law" end check1() end,3000000,1)
end
delayer = setTimer(check1,10000,1)
end
delayer = setTimer(check1,10000,1)
addEventHandler("onPlayerWasted",root,function()
if getElementData(source,"isPlayerInMR") then
setElementData(source,"isPlayerInMR",false)
end
end)
addEventHandler("onPlayerQuit",root,function()
if getElementData(source,"isPlayerInMR") then
setElementInterior(source,0)
setElementDimension(source,0)
setElementData(source,"isPlayerInMR",false)
local userid = exports.server:getPlayerAccountID( source )
setTimer(function(player,id)
local x,y,z,r = 1178.7457275391, -1323.8264160156, 14.135261535645, 270
exports.DENmysql:exec("UPDATE `accounts` SET `x`=?, `y`=?, `z`=?, `rotation`=?, `health`=? WHERE `id`=?", x, y, z, r, 100, id )
end,4000,1,source,userid)
end
end)
function startCheck()
if timeLeft==0 then
if started==false and startseq==false then
if (team=="law" and getLawMarkerCount()+1 >= 4) or (team=="crim" and getCrimMarkerCount()+1 >= 4) then --edit here the rquirements
if (team=="law" and #getElementsWithinColShape(lawSignUpCol,"player") < 1) then
return false
end
if (team=="crim" and #getElementsWithinColShape(crimSignUpCol, "player") < 1) then
return false
end
startseq=true
started=false
loadEnters()
loadExits()
spawnPeds(15)
sendUpdatedStats ()
spawningTimer = setTimer(spawnPeds, 1000*90,2,15)
setTimer(function() if (team == "crim") then for k,v in ipairs (crimse) do triggerClientEvent(v, "AURmansion:addWave", v, "add") end elseif (team == "law") then for k,v in ipairs (lawse) do triggerClientEvent(v, "AURmansion:addWave", v, "add") end end end, 1000*90,2,15)
setTimer(sendUpdatedStats, (1000*90)+100,1)
startcd=60
timeTillEnd = 900
if team == "crim" then
setTimer(function()
local _,crims = getCrimMarkerCount()
if isTimer(copsTurn) then killTimer(copsTurn) end
local cx,cy,cz,crz = 1298.79, -794.23, 1084,350
for k,v in pairs(crims) do
setElementInterior(v,eint)
setElementDimension(v,edim)
setElementPosition(v,cx+math.random(-1,1),cy+math.random(-1,1),cz)
setElementRotation(v,0,0,crz)
triggerClientEvent(v,"onTogglemansionraidStats",v,true)
table.insert(crimse,v)
fadeCamera(v,false)
entered[v]=true
toggleAllControls(v,true,true,true)
setElementFrozen(v,true)
setElementHealth(v,200)
setTimer(function(plr,int,dim)
setElementFrozen(v,false)
fadeCamera(plr,true)
setElementInterior(plr,5)
setElementDimension(plr,1)
setElementPosition(plr,1298.79, -794.23, 1084)
end,3500,1,v,eint,edim)
setPedArmor(v,100)
allowedToJoin[exports.server:getPlayerAccountName(v)] = getTickCount()
end
end,3000,1)
end
if team == "law" then
setTimer(function()
local _,laws = getLawMarkerCount()
if isTimer(copsTurn) then killTimer(copsTurn) end
local lx,ly,lz,lrz = 1271.68, -778.57, 1091.9 ,267
for k,v in pairs(laws) do
setElementInterior(v,eint)
setElementDimension(v,edim)
setElementPosition(v,lx+math.random(-1,1),ly+math.random(-1,1),lz)
setElementRotation(v,0,0,lrz)
triggerClientEvent(v,"onTogglemansionraidStats",v,true)
toggleAllControls(v,true,true,true)
table.insert(lawse,v)
entered[v]=true
setElementFrozen(v,true)
setElementHealth(v,200)
setPedArmor(v,100)
setTimer(function(plr,int,dim)
setElementFrozen(v,false)
fadeCamera(plr,true)
setElementInterior(plr,5)
setElementDimension(plr,1)
setElementPosition(plr,1271.68, -778.57, 1091.9)
end,3500,1,v,eint,edim)
allowedToJoin[exports.server:getPlayerAccountName(v)] = getTickCount()
end
end,3000,1)
end
for k,v in pairs(getElementsByType("player")) do
if team == "law" then
msg(v,"Mansion Raid (Law) start sequence initiated. Be in the marker within 60 seconds!",0,255,0)
else
msg(v,"Mansion Raid (Criminals) start sequence initiated. Be in the marker within 60 seconds!",0,255,0)
end
end
setTimer(function()
if isTimer(copsTurn) then killTimer(copsTurn) end
started=true
startseq=false
local _,allLaws=getLawCount()
local _,allCrims=getCrimCount()
remainingpeds=0
if team == "law" then
for k,v in pairs(lawse) do
msg(v,"MD Mansion Raid has started! Take down all criminals",0,255,0)
remainingpeds= #peds
end
else
for k,v in pairs(crimse) do
msg(v,"MD Mansion Raid has started! Take down all security guards!",0,255,0)
remainingpeds = #peds
end
end
for k,v in pairs(getElementsByType("player")) do
triggerClientEvent(v,"CSGmraid.started",v,timeTillEnd)
end
sendUpdatedStats()
end,3000,1)
end
end
end
end
addEventHandler("onPlayerWasted",root,function(_,killer)
if killer and isElement(killer) then
if getElementData(killer,"isPlayerInMR") then
if exports.DENlaw:isLaw(source) then
for k,v in pairs(lawse) do
if v==source then
table.remove(lawse,k)
msg(v,"You died during the Mansion Raid! Better luck next time!",255,0,0)
if (killer) then
if isElement(killer) then
if exports.DENlaw:isLaw(killer) then
givePlayerMoney(killer,1500)
exports.CSGgroups:addXP(killer,3)
--outputDebugString("Got xp from #1")
msg(killer,"Killed a enemy! Paid $1500 and +0.5 Score!",0,255,0)
exports.CSGscore:givePlayerScore(killer,0.5)
else
--outputDebugString("Got xp from #2")
givePlayerMoney(killer,1500)
msg(killer,"Killed a enemy! Paid $1500 and +0.5 Score!",0,255,0)
exports.CSGscore:givePlayerScore(killer,0.5)
end
end
end
if (#lawse == 0) then
endIt()
end
sendUpdatedStats()
break
end
end
else
for k,v in pairs(crimse) do
if v==source then
table.remove(crimse,k)
sendUpdatedStats()
msg(v,"You died during the Mansion Raid! Better luck next time!",255,0,0)
if (killer) then
if isElement(killer) then
if exports.DENlaw:isLaw(killer) then
givePlayerMoney(killer,1500)
exports.CSGgroups:addXP(killer,3)
--outputDebugString("Got xp from #3")
msg(killer,"Killed a enemy! Paid $1500 and +0.5 Score!",0,255,0)
exports.AURcriminalp:giveCriminalPoints(killer, "", 3)
exports.CSGscore:givePlayerScore(killer,0.5)
else
givePlayerMoney(killer,1500)
--outputDebugString("Got xp from #4")
msg(killer,"Killed a enemy! Paid $1500 and +0.5 Score!",0,255,0)
exports.CSGscore:givePlayerScore(killer,0.5)
exports.AURcriminalp:giveCriminalPoints(killer, "", 3)
end
if (#crimse == 0) then
endIt ()
end
end
end
break
end
end
end
end
end
end)
addEventHandler("onPlayerQuit",root,function(_,killer)
for k,v in pairs(lawse) do
if v==source then
table.remove(lawse,k)
sendUpdatedStats()
break
end
end
for k,v in pairs(crimse) do
if v==source then
table.remove(crimse,k)
sendUpdatedStats()
break
end
end
end)
function spawnPeds(amount)
for count=1,amount do
local i = math.random(1,#spawnPositions)
while (spawnedPlaces[i]~=nil) do
i = math.random(1,#spawnPositions)
end
spawnedPlaces[i]=true
local x,y,z,rz = unpack(spawnPositions[i])
local ped = exports.slothbot:spawnBot(x,y,z,rz,pedSkins[math.random(1,#pedSkins)],eint,edim,_,weps[math.random(1,#weps)])
--exports.slothbot:setBotTeam(ped, getTeamFromName("Government"))
table.insert(peds,ped)
end
spawnedPlaces={}
end
function loadEnters()
for k,v in pairs(enterPos) do
local x,y,z = unpack(v)
local m = createMarker(x,y,z+1,"arrow",2)
enterMarkers[m] = k
addEventHandler("onMarkerHit",m,hitEnter)
end
end
function loadExits()
for k,v in pairs(exitPos) do
local x,y,z = unpack(v)
local m = createMarker(x,y,z+1,"arrow",2)
exitMarkers[m]=k
setElementDimension(m,edim)
setElementInterior(m,eint)
addEventHandler("onMarkerHit",m,hitLeave)
end
end
function hitEnter(player,dim)
if 1+1 == 2 then return end --no use at the moment
if dim == false then return end
if isPedInVehicle(player) then
return
else
if started==false then
msg(player,"MD Mansion Raid is not occuring rightnow. You can't enter.",255,0,0)
return
end
if exports.DENlaw:isLaw(player) == true or (getTeamName(getPlayerTeam(player)) == "Criminals" or getTeamName(getPlayerTeam(player)) == "HolyCrap") then
if entered[player] ~= nil then
msg(player,"You died! You can't re-enter the mansion again during the same raid!",255,0,0)
return
end
entered[player]=true
local _,_,_,tx,ty,tz,rz = unpack(enterPos[enterMarkers[source]])
setElementPosition(player,tx,ty,tz)
setElementInterior(player,eint)
setElementDimension(player,edim)
setElementRotation(player,0,0,rz)
toggleAllControls(player,true,true,true)
triggerClientEvent(player,"onTogglemansionraidStats",player,true)
if exports.DENlaw:isLaw(player) then
table.insert(player,lawse)
else
table.insert(player,crimse)
end
sendUpdatedStats()
end
end
end
function sendUpdatedStats()
for k,v in pairs(getElementsByType("player")) do
triggerClientEvent(v,"onChangeMansionCount",v,#lawse,#crimse, #peds)
end
end
function hitLeave(player,dim)
if dim == false then return end
if getElementType(player) ~= "player" then return end
if isPedInVehicle(player) then
return
else
if timeTillEnd == 0 then
-- if exports.DENlaw:isLaw(player) == true or getTeamName(getPlayerTeam(player)) == "Criminals" then
local _,_,_,tx,ty,tz,rz = unpack(exitPos[exitMarkers[source]])
setElementInterior(player,0)
setElementPosition(player,tx,ty,tz)
setElementDimension(player,0)
setElementRotation(player,0,0,rz)
triggerClientEvent(player,"onTogglemansionraidStats",player,false)
-- end
else
msg(player,"You can't leave while the Mansion Raid is in progress! Fight!",255,0,0)
end
end
end
function botKillReward (_,attacker, weapon, bodypart)
if getElementDimension(source) == 1 and getElementInterior(source) == 5 then
for k,v in ipairs (peds) do
if (v == source) then
table.remove(peds, k)
end
end
if (getElementType (attacker) == "ped") and not (getElementType(attacker) == "player") then
spawnPeds(1)
end
end
if ( isElement( attacker ) ) and getElementType(attacker) == "player" and ( getPlayerTeam( attacker ) ) then
if getElementDimension(attacker) == 1 and getElementInterior(attacker) == 5 then
givePlayerMoney(attacker, 1500)
exports.NGCdxmsg:createNewDxMessage("You killed a bot and earned $1,5000!", attacker,2552,255,255)
for k,v in ipairs (peds) do
if (v == source) then
table.remove(peds, k)
destroyElement(v)
end
end
triggerClientEvent(root, "NGCraid:updateKill", attacker, attacker)
sendUpdatedStats()
if (#peds == 0) then
if (isTimer(spawningTimer) == false) then
endIt ()
else
exports.NGCdxmsg:createNewDxMessage(attacker, "More Bots are spawning shortly!",255,255,0)
end
end
for k,v in ipairs (peds) do
if (#peds > 0) and not (isElement(v)) then
endIt()
end
end
end
end
end
addEventHandler("onPedWasted", root, botKillReward)
function getLawMarkerCount()
local t = getElementsWithinColShape(lawSignUpCol,"player")
if t==false then t = {} end
for k,v in pairs(t) do
if exports.DENlaw:isLaw(v) == false or (allowedToJoin[exports.server:getPlayerAccountName(v)]) then table.remove(t,k) end
end
return #t,t
end
function getCrimMarkerCount()
local t = getElementsWithinColShape(crimSignUpCol,"player")
if t==false then t = {} end
for k,v in pairs(t) do
if (getTeamName(getPlayerTeam(v)) ~= "Criminals" and getTeamName(getPlayerTeam(v)) ~= "HolyCrap") or (allowedToJoin[exports.server:getPlayerAccountName(v)]) then table.remove(t,k) end
end
return #t,t
end
function getLawCount()
local t = getLawTable()
if t==false or t==nil then t = {} end
return #t,t
end
function getCrimCount()
local t = getElementsByType("player")
if t==false then t = {} end
for k,v in pairs(t) do
if (getPlayerTeam(v)) then
if getTeamName(getPlayerTeam(v)) ~= "Criminals" and getTeamName(getPlayerTeam(v)) ~= "HolyCrap" then table.remove(t,k) end
end
end
return #t,t
end
local lawTeams = {
"Military Forces",
"Government",
}
function getLawTable()
local law = {}
for k,v in pairs (lawTeams) do
local list = getPlayersInTeam(getTeamFromName(v))
for k,v in pairs(list) do
table.insert(law,v)
end
end
return law
end
addCommandHandler("mypos",function(ps)
local x,y,z = getElementPosition(ps)
local rx,ry,rz = getElementRotation(ps)
outputChatBox('{'..x..','..y..','..z..','..rz..'},',ps)
end)
function MDTimeLeft(plr)
if (not isTimer(copsTurn)) then return end
local chkTimer = copsTurn
local milliseconds = math.floor(getTimerDetails(copsTurn))
local minutes = milliseconds / 60000
local seconds = minutes * 60
if team=="crim" then
tm = "Law"
else
tm = "Criminals"
end
local txt = "MD Mansion Raid will be switched to "..tm
exports.NGCdxmsg:createNewDxMessage(plr,txt.." within ("..math.ceil(minutes).." minutes) ("..math.ceil(seconds).." seconds)",255, 255, 0)
end
addCommandHandler("raidtime",MDTimeLeft)
addCommandHandler("raidtime",function(ps)
if started==true or startseq==true then
if startseq and started then
if team == "law" then
msg(ps,"MD Mansion Raid (Law Enforcement) is occuring rightnow!",0,255,0)
else
msg(ps,"MD Mansion Raid (Criminals) is occuring rightnow!",0,255,0)
end
elseif startseq and not started then
if team == "law" then
msg(ps,"MD Mansion Raid (Law Enforcement) is going to start in "..startcd.." Seconds",0,255,0)
else
msg(ps,"MD Mansion Raid (Criminals) is going to start in "..startcd.." Seconds",0,255,0)
end
else
if team == "law" then
msg(ps,"MD Mansion Raid (Law Enforcement) is occuring rightnow!",0,255,0)
else
msg(ps,"MD Mansion Raid (Criminals) is occuring rightnow!",0,255,0)
end
end
else
if timeLeft > 0 then
if team == "law" then
exports.NGCdxmsg:createNewDxMessage(ps,"MD Mansion Raid (Law Enforcement) can be started in "..timeLeft.." Seconds",0,255,0)
else
exports.NGCdxmsg:createNewDxMessage(ps,"MD Mansion Raid (Criminals) can be started in "..timeLeft.." Seconds",0,255,0)
end
else
if team == "law" then
exports.NGCdxmsg:createNewDxMessage(ps,"MD Mansion Raid (Law Enforcement) can be now be started!",0,255,0)
else
exports.NGCdxmsg:createNewDxMessage(ps,"MD Mansion Raid (Criminals) can be now be started!",0,255,0)
end
end
end
end)
loadEnters()
loadExits()
|
local K, C, L, _ = select(2, ...):unpack()
if C.Tooltip.Enable ~= true or C.Tooltip.ArenaExperience ~= true then return end
local _G = _G
local format = string.format
local pairs, tonumber = pairs, tonumber
local select = select
local CreateFrame = CreateFrame
local InCombatLockdown = InCombatLockdown
local AchievementFrame = AchievementFrame
local UnitIsPlayer = UnitIsPlayer
local GetUnit = GetUnit
local ClearAchievementComparisonUnit = ClearAchievementComparisonUnit
local GetComparisonAchievementPoints = GetComparisonAchievementPoints
local GetComparisonStatistic = GetComparisonStatistic
local GetAchievementInfo = GetAchievementInfo
-- Arena function(ArenaExp by Fernir)
local active = false
local tooltip = _G["GameTooltip"]
local statistic = {
370, -- Highest 2 man personal rating
595, -- Highest 3 man personal rating
596, -- Highest 5 man personal rating
}
local gradient = function(val, low, high)
local percent, r, g
if high > low then
percent = val / (high - low)
else
percent = 1 - val / (low - high)
end
if percent > 1 then percent = 1 end
if percent < 0 then percent = 0 end
if percent < 0.5 then
r, g = 1, 2 * percent
else
r, g = (1 - percent) * 2, 1
end
return format("|cff%02x%02x%02x%s|r", r * 255, g * 255, 0, val)
end
local frame = CreateFrame("Frame")
frame:RegisterEvent("ADDON_LOADED")
frame:SetScript("OnEvent", function(self, event, ...)
if event == "ADDON_LOADED" then
if ... then
frame:UnregisterEvent("ADDON_LOADED")
tooltip:HookScript("OnTooltipSetUnit", function()
if InCombatLockdown() then return end
if AchievementFrame and AchievementFrame:IsShown() then return end
self.unit = select(2, tooltip:GetUnit())
if not UnitIsPlayer(self.unit) then return end
if _G.GearScore then
_G.GearScore:UnregisterEvent("INSPECT_ACHIEVEMENT_READY")
end
ClearAchievementComparisonUnit()
frame:RegisterEvent("INSPECT_ACHIEVEMENT_READY")
SetAchievementComparisonUnit(self.unit)
end)
tooltip:HookScript("OnTooltipCleared", function()
if frame:IsEventRegistered("INSPECT_ACHIEVEMENT_READY") and frame:IsEventRegistered("INSPECT_ACHIEVEMENT_READY") then
frame:UnregisterEvent("INSPECT_ACHIEVEMENT_READY")
ClearAchievementComparisonUnit()
end
active = false
end)
end
elseif event == "INSPECT_ACHIEVEMENT_READY" then
if not GetComparisonAchievementPoints() then return end
active = false
for index, Achievement in pairs(statistic) do
if tonumber(GetComparisonStatistic(Achievement)) and tonumber(GetComparisonStatistic(Achievement)) > 0 then
tooltip:AddDoubleLine(select(2, GetAchievementInfo(Achievement)), gradient(tonumber(GetComparisonStatistic(Achievement)), 0, 100))
active = true
end
end
if active then tooltip:Show() end
if _G.GearScore then
_G.GearScore:RegisterEvent("INSPECT_ACHIEVEMENT_READY")
end
frame:UnregisterEvent("INSPECT_ACHIEVEMENT_READY")
ClearAchievementComparisonUnit()
end
end) |
--(Luc Bloom) http://lua-users.org/wiki/SimpleRound
---@param v number
---@return number
function math.sign(v)
return (v >= 0 and 1) or -1
end
--(Luc Bloom) http://lua-users.org/wiki/SimpleRound
---@overload fun(v:number):number
---@param v number
---@param bracket number
---@return number
function math.round(v, bracket)
bracket = bracket or 1
return math.floor(v / bracket + math.sign(v) * 0.5) * bracket
end
--- Геометрическая сумма
---@param x number
---@param y number
---@return number
function math.sum_geometry(x, y)
return math.sqrt(math.pow(x, 2) + math.pow(y, 2))
end
--- Нормализовать точку из диапазона
---@param x number
---@param a number Начало диапазона
---@param b number Конец диапазона
---@return number A normalized sample (range -1.0 to 1.0).
function math.normalize(x, a, b)
--assert(a < b, string.format('assert error: %.2f < %.f2', a, b))
local result = (x - a) / (b - a)
result = math.max(0.0, result)
result = math.min(1.0, result)
return result
end
--- Повернуть точки на заданный угол
---@param x0 number
---@param y0 number
---@param r number
---@param list table Массив точек
---@return table
function math.rotate_point(x0, y0, r, list)
local result = {}
local sin, cos = math.sin(r), math.cos(r)
local i = 1
while i < #list do
local x, y = list[i], list[i + 1]
table.insert(result, x * cos - y * sin + x0)
table.insert(result, x * sin + y * cos + y0)
i = i + 2
end
--assert(#list == #result)
return result
end
--todo проверить. Сейчас нельзя крутить мёртвые петли :(
function math.normalize_angle(angle)
return math.pi / 2 - (angle % math.pi)
end
--- Медианный фильтр
---@overload fun():fun(x:number):number
---@param window number|nil
---@return fun(x:number):number
function math.get_median_smooth(window)
window = window or 5
assert(window % 2 == 1)
local buf = {}
for _ = 1, window do
table.insert(buf, 0)
end
assert(#buf == window)
local index = math.round(window / 2) + 1
return function(x)
table.remove(buf, 1)
table.insert(buf, x)
local buf2 = table.copy_array(buf)
table.sort(buf2)
return buf2[index]
end
end
---@param t table
---@return table
function table.copy_array(t)
local r = {}
for i = 1, #t do
r[i] = t[i]
end
return r
end
|
---@generic K
---@param a K
---@param b table<K, K>
---@return K
function globalFunction(a, b)
---@type K
local genericTypedVar = a
return genericTypedVar
end
---@generic K
---@param a K
---@param b table<K, K>
---@return K
local function localFunction(a, b)
---@type K
local genericTypedVar = a
return genericTypedVar
end
---@class Scope
local Scope = {}
---@generic K
---@param a K
---@param b table<K, K>
---@return K
function Scope.method(a, b)
---@type K
local genericTypedVar = a
return genericTypedVar
end
---@generic K
---@param a K
---@param b table<K, K>
---@return K
local assignedFunction = function(a, b)
---@type K
local genericTypedVar = a
return genericTypedVar
end
---@generic K
---@param a K
---@return K
local outerFunction = function(a)
---@param b K
local innerFunction = function(b)
---@type K
local v
end
innerFunction(<error descr="Type mismatch. Required: 'K' Found: '\"someValue\"'">"someValue"</error>)
return a
end
outerFunction("someValue")
local tableWithGenericFunction = {
---@generic T
---@param t T
genericFunction = function(t)
---@type T
local alsoT = t
end
}
|