Neatro's Satellite Cybercafé
© 2024
Neatro
File
New
Open...
Save...
Reset
Options
Word wrap
Show hidden characters
Scroll past end
Show line numbers
Insert ...
Blocks ...
if ...
for ...
for k, v ...
while ...
Snippets ...
Lua example
Print table
Class ...
Class example
Hook example
Window example
Window and hook example
1024 cube benchmark
Device fold api
Perftest
Perftest2
Voxyllabus ...
Block definition
Block definition example
Block mesh example
Block event example
Utilities...
Boulder editor
Neatty websocket tester
Launch another Satellite
Powder
Help...
Satellite Lua library docs
Lua official manual
Garry's Mod Wiki
Tools
Hooks registry
Clear output
Execute
Output
title
text goes here
--example PrintClear() PrintColor('#7F9FFF') t = {test="test",t={foo='bar',any={h=2,depth={is={possible={wow={}}}}}}} --some table t.itself = t --table contains a reference to itself PrintTable(t) --print table! print('') print('<C#F00>t</C><C#FF0>e</C><C#0F0>s</C><C#00F>t</C>')
PrintTable(tbl)
function ClassName() local obj = {} obj.type = "ClassName"; ... return obj end
function Person( name, country ) local obj = {} obj.type = "ClassName"; obj.name = name obj.country = country function obj:getName() return self.name end function obj:getCountry() return self.country end return obj end local Neatro = Person('Neatro','Netherlands') return Neatro:getCountry()
if condition then ... end
for i = 1, 10 do ... end
for k, v in pairs( tbl ) do ... end
while condition do ... end
local Myblock = Voxy6.VoxelRegister( "Voxy:NewBlock" ) Voxy6.VoxelSetAtlassing( "Voxy:NewBlock", Atlas ) Voxy6.VoxelSetVisualStyle( "Voxy:NewBlock" )
local Rock = Voxy6.VoxelRegister( "Voxy:Rock" ) Voxy6.VoxelSetAtlassing( "Voxy:Rock", Voxy6.AtlasRegular( 6, 1 ) ) Voxy6.VoxelSetVisualStyle( "Voxy:Rock" )
Voxy6.VoxelSetVisualStyle( "Voxy:Rock", Voxy6.Geometry.Func, -1, function( quads, id, pos, world, vdata, localNeighbours ) local quadcount = 0 for i = 0, 12 do local mins = i / 16 local maxs = ( i + 4 ) / 16 quadcount = quadcount + Voxy6.MeshAddCuboidAutoUV( quads, pos, Vector(mins,mins,mins), Vector(maxs,maxs,maxs), vdata ) end return quadcount end )
Voxy6.VoxelSetEvent( "Voxy:Rock", "OnUpdate", function( world, id, pos ) world:SetBlock( pos, 0 ) --break when updated return 1 --update neighbourhood end )
hook.Add("Test", "first", function() end) hook.Add("Test", "second", function() end) hook.Add("Test", "last", function() end) hook.Add("Test2", "test", function() end) --Run this little script, then head to the Tools menu -> Hook registry. --You'll see all your defined hooks!
createWindow( "My window" ):setContent( "This is inside the window" )
--create the window local testwindow = createWindow( "My window" ) local starttime = os.clock() --move the window and make it small testwindow:setBounds( 'calc( 50% + 5px )','29px',0,0 ) --run every tick hook.Add( "tick", "test", function() local showtime = os.clock() - starttime testwindow:setContent( "Time since started: "..string.format( "%02d", math.floor( showtime / 3600 ) ).. ":"..string.format( "%02d", math.floor( showtime / 60 ) ).. ":"..string.format( "%05.2f", ( math.floor( ( showtime % 60 ) * 100 ) / 100 ) ) ) end )
context = threeContext() context:orbit() matl = loadMaterial( 'content/img/rock.png', false ) context:setMaterial( matl ); context:MeshBegin() context:MeshQuadUVC( Vector( 0, 4, 0 ), Vector( 0, 4, 4 ), Vector( 4, 4, 4 ), Vector( 4, 4, 0 ), 1, 0, 1, 1, 0, 1, 0, 0, Vector( 1, 0, 0 ), Vector( 0, 1, 0 ), Vector( 0, 0, 1 ), Vector( 0, 0, 0 ) ) context:MeshQuadUVC( Vector( 4, 4, 4 ), Vector( 0, 4, 4 ), Vector( 0, 0, 4 ), Vector( 4, 0, 4 ), 1, 0, 1, 1, 0, 1, 0, 0, Vector( 1, 0, 0 ), Vector( 0, 1, 0 ), Vector( 0, 0, 1 ), Vector( 0, 0, 0 ) ) context:MeshQuadUVC( Vector( 4, 4, 0 ), Vector( 4, 4, 4 ), Vector( 4, 0, 4 ), Vector( 4, 0, 0 ), 1, 0, 1, 1, 0, 1, 0, 0, Vector( 1, 0, 0 ), Vector( 0, 1, 0 ), Vector( 0, 0, 1 ), Vector( 0, 0, 0 ) ) mesh = context:MeshEnd( true, true, true ) context:sceneAdd( mesh )
context = threeContext() context:orbit() function cuboid( mins, maxs ) Mesh.QuadUVC( VectorF( mins.x, maxs.y, mins.z ), VectorF( mins.x, maxs.y, maxs.z ), VectorF( maxs.x, maxs.y, maxs.z ), VectorF( maxs.x, maxs.y, mins.z ), 1, 0, 1, 1, 0, 1, 0, 0, VectorF( 1, 0, 0 ), VectorF( 0, 1, 0 ), VectorF( 0, 0, 1 ), VectorF( 0, 0, 0 ) ) Mesh.QuadUVC( VectorF( maxs.x, mins.y, maxs.z ), VectorF( maxs.x, maxs.y, maxs.z ), VectorF( mins.x, maxs.y, maxs.z ), VectorF( mins.x, mins.y, maxs.z ), 1, 0, 1, 1, 0, 1, 0, 0, VectorF( 1, 0, 0 ), VectorF( 0, 1, 0 ), VectorF( 0, 0, 1 ), VectorF( 0, 0, 0 ) ) Mesh.QuadUVC( VectorF( maxs.x, maxs.y, mins.z ), VectorF( maxs.x, maxs.y, maxs.z ), VectorF( maxs.x, mins.y, maxs.z ), VectorF( maxs.x, mins.y, mins.z ), 1, 0, 1, 1, 0, 1, 0, 0, VectorF( 1, 0, 0 ), VectorF( 0, 1, 0 ), VectorF( 0, 0, 1 ), VectorF( 0, 0, 0 ) ) Mesh.QuadUVC( VectorF( maxs.x, mins.y, mins.z ), VectorF( maxs.x, mins.y, maxs.z ), VectorF( mins.x, mins.y, maxs.z ), VectorF( mins.x, mins.y, mins.z ), 1, 0, 1, 1, 0, 1, 0, 0, VectorF( 1, 0, 0 ), VectorF( 0, 1, 0 ), VectorF( 0, 0, 1 ), VectorF( 0, 0, 0 ) ) Mesh.QuadUVC( VectorF( maxs.x, maxs.y, mins.z ), VectorF( maxs.x, mins.y, mins.z ), VectorF( mins.x, mins.y, mins.z ), VectorF( mins.x, maxs.y, mins.z ), 1, 0, 1, 1, 0, 1, 0, 0, VectorF( 1, 0, 0 ), VectorF( 0, 1, 0 ), VectorF( 0, 0, 1 ), VectorF( 0, 0, 0 ) ) Mesh.QuadUVC( VectorF( mins.x, mins.y, mins.z ), VectorF( mins.x, mins.y, maxs.z ), VectorF( mins.x, maxs.y, maxs.z ), VectorF( mins.x, maxs.y, mins.z ), 1, 0, 1, 1, 0, 1, 0, 0, VectorF( 1, 0, 0 ), VectorF( 0, 1, 0 ), VectorF( 0, 0, 1 ), VectorF( 0, 0, 0 ) ) end matl = loadMaterial( 'content/img/rock.png', false ) context:setMaterial( matl ); Mesh.Begin() start = os.clock() for i=1, 1024 do rand = Vector( math.random( -8, 7 ), math.random( -8, 7 ), math.random( -8, 7 ) ) cuboid( rand, rand + Vector( 1, 1, 1 ) ) end mesh = Mesh.End() print( os.clock() - start ) context:sceneAdd( mesh )
hook.Add( "ondevicefold", "Example", function( posture ) print( posture ); end )
context = threeContext() context:orbit() context:getCamera().far = 6000 function cuboid( mins, maxs ) Mesh.QuadUVC( VectorF( mins.x, maxs.y, mins.z ), VectorF( mins.x, maxs.y, maxs.z ), VectorF( maxs.x, maxs.y, maxs.z ), VectorF( maxs.x, maxs.y, mins.z ), 1, 0, 1, 1, 0, 1, 0, 0, VectorF( 1, 0, 0 ), VectorF( 0, 1, 0 ), VectorF( 0, 0, 1 ), VectorF( 0, 0, 0 ) ) Mesh.QuadUVC( VectorF( maxs.x, mins.y, maxs.z ), VectorF( maxs.x, maxs.y, maxs.z ), VectorF( mins.x, maxs.y, maxs.z ), VectorF( mins.x, mins.y, maxs.z ), 1, 0, 1, 1, 0, 1, 0, 0, VectorF( 1, 0, 0 ), VectorF( 0, 1, 0 ), VectorF( 0, 0, 1 ), VectorF( 0, 0, 0 ) ) Mesh.QuadUVC( VectorF( maxs.x, maxs.y, mins.z ), VectorF( maxs.x, maxs.y, maxs.z ), VectorF( maxs.x, mins.y, maxs.z ), VectorF( maxs.x, mins.y, mins.z ), 1, 0, 1, 1, 0, 1, 0, 0, VectorF( 1, 0, 0 ), VectorF( 0, 1, 0 ), VectorF( 0, 0, 1 ), VectorF( 0, 0, 0 ) ) Mesh.QuadUVC( VectorF( maxs.x, mins.y, mins.z ), VectorF( maxs.x, mins.y, maxs.z ), VectorF( mins.x, mins.y, maxs.z ), VectorF( mins.x, mins.y, mins.z ), 1, 0, 1, 1, 0, 1, 0, 0, VectorF( 1, 0, 0 ), VectorF( 0, 1, 0 ), VectorF( 0, 0, 1 ), VectorF( 0, 0, 0 ) ) Mesh.QuadUVC( VectorF( maxs.x, maxs.y, mins.z ), VectorF( maxs.x, mins.y, mins.z ), VectorF( mins.x, mins.y, mins.z ), VectorF( mins.x, maxs.y, mins.z ), 1, 0, 1, 1, 0, 1, 0, 0, VectorF( 1, 0, 0 ), VectorF( 0, 1, 0 ), VectorF( 0, 0, 1 ), VectorF( 0, 0, 0 ) ) Mesh.QuadUVC( VectorF( mins.x, mins.y, mins.z ), VectorF( mins.x, mins.y, maxs.z ), VectorF( mins.x, maxs.y, maxs.z ), VectorF( mins.x, maxs.y, mins.z ), 1, 0, 1, 1, 0, 1, 0, 0, VectorF( 1, 0, 0 ), VectorF( 0, 1, 0 ), VectorF( 0, 0, 1 ), VectorF( 0, 0, 0 ) ) end matl = loadMaterial( 'content/img/rock.png', false ) context:setMaterial( matl ); Mesh.Begin() start = os.clock() for i=1, 1024 do rand = Vector( math.random( -8, 7 ), math.random( -8, 7 ), math.random( -8, 7 ) ) cuboid( rand, rand + Vector( 1, 1, 1 ) ) end mesh = Mesh.End() hook.Add( "render", "", function() --if os.clock() % 1 > 0.5 then for i=1, 64 do for j=1, 64 do mesh:setPosition( Vector( -i*16, -j*16, i*16 + j*16 - 100 ) ) render( mesh ) end end --end end ) print( os.clock() - start )
context = threeContext() context:orbit() context:getCamera().far = 6000 function cuboid( mins, maxs ) Mesh.QuadUVC( VectorF( mins.x, maxs.y, mins.z ), VectorF( mins.x, maxs.y, maxs.z ), VectorF( maxs.x, maxs.y, maxs.z ), VectorF( maxs.x, maxs.y, mins.z ), 1, 0, 1, 1, 0, 1, 0, 0, VectorF( 1, 0, 0 ), VectorF( 0, 1, 0 ), VectorF( 0, 0, 1 ), VectorF( 0, 0, 0 ) ) Mesh.QuadUVC( VectorF( maxs.x, mins.y, maxs.z ), VectorF( maxs.x, maxs.y, maxs.z ), VectorF( mins.x, maxs.y, maxs.z ), VectorF( mins.x, mins.y, maxs.z ), 1, 0, 1, 1, 0, 1, 0, 0, VectorF( 1, 0, 0 ), VectorF( 0, 1, 0 ), VectorF( 0, 0, 1 ), VectorF( 0, 0, 0 ) ) Mesh.QuadUVC( VectorF( maxs.x, maxs.y, mins.z ), VectorF( maxs.x, maxs.y, maxs.z ), VectorF( maxs.x, mins.y, maxs.z ), VectorF( maxs.x, mins.y, mins.z ), 1, 0, 1, 1, 0, 1, 0, 0, VectorF( 1, 0, 0 ), VectorF( 0, 1, 0 ), VectorF( 0, 0, 1 ), VectorF( 0, 0, 0 ) ) Mesh.QuadUVC( VectorF( maxs.x, mins.y, mins.z ), VectorF( maxs.x, mins.y, maxs.z ), VectorF( mins.x, mins.y, maxs.z ), VectorF( mins.x, mins.y, mins.z ), 1, 0, 1, 1, 0, 1, 0, 0, VectorF( 1, 0, 0 ), VectorF( 0, 1, 0 ), VectorF( 0, 0, 1 ), VectorF( 0, 0, 0 ) ) Mesh.QuadUVC( VectorF( maxs.x, maxs.y, mins.z ), VectorF( maxs.x, mins.y, mins.z ), VectorF( mins.x, mins.y, mins.z ), VectorF( mins.x, maxs.y, mins.z ), 1, 0, 1, 1, 0, 1, 0, 0, VectorF( 1, 0, 0 ), VectorF( 0, 1, 0 ), VectorF( 0, 0, 1 ), VectorF( 0, 0, 0 ) ) Mesh.QuadUVC( VectorF( mins.x, mins.y, mins.z ), VectorF( mins.x, mins.y, maxs.z ), VectorF( mins.x, maxs.y, maxs.z ), VectorF( mins.x, maxs.y, mins.z ), 1, 0, 1, 1, 0, 1, 0, 0, VectorF( 1, 0, 0 ), VectorF( 0, 1, 0 ), VectorF( 0, 0, 1 ), VectorF( 0, 0, 0 ) ) end matl = loadMaterial( 'content/img/rock.png', false ) context:setMaterial( matl ); Mesh.Begin() start = os.clock() for i=1, 1024 do rand = Vector( math.random( -8, 7 ), math.random( -8, 7 ), math.random( -8, 7 ) ) cuboid( rand, rand + Vector( 1, 1, 1 ) ) end mesh = Mesh.End() for i=1, 64 do for j=1, 64 do mesh:setPosition( Vector( -i*16, -j*16, i*16 + j*16 - 100 ) ); context:sceneAdd( mesh:clone() ); end end print( os.clock() - start )