summaryrefslogtreecommitdiffstats
path: root/MCServer/Plugins/MagicCarpet/objects.lua
diff options
context:
space:
mode:
authorAlexander Harkness <bearbin@gmail.com>2013-07-29 13:13:03 +0200
committerAlexander Harkness <bearbin@gmail.com>2013-07-29 13:13:03 +0200
commit53e22b11857fed62e2313d6d84d90f88ed412ffb (patch)
treec61e56725da7dff0154d566722651e2c39c9d6c6 /MCServer/Plugins/MagicCarpet/objects.lua
parentWebAdmin: Removed the duplicate memory usage querying (diff)
downloadcuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.gz
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.bz2
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.lz
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.xz
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.tar.zst
cuberite-53e22b11857fed62e2313d6d84d90f88ed412ffb.zip
Diffstat (limited to 'MCServer/Plugins/MagicCarpet/objects.lua')
-rw-r--r--MCServer/Plugins/MagicCarpet/objects.lua192
1 files changed, 96 insertions, 96 deletions
diff --git a/MCServer/Plugins/MagicCarpet/objects.lua b/MCServer/Plugins/MagicCarpet/objects.lua
index 7c19fc232..8d81623a5 100644
--- a/MCServer/Plugins/MagicCarpet/objects.lua
+++ b/MCServer/Plugins/MagicCarpet/objects.lua
@@ -1,97 +1,97 @@
--- Location object
-cLocation = {}
-function cLocation:new( x, y, z )
- local object = { x = x, y = y, z = z }
- setmetatable(object, { __index = cLocation })
- return object
-end
-
--- Offsets
-cFibers = { }
-function cFibers:new()
- local object = {
- cLocation:new( 2, -1, 2 ),
- cLocation:new( 2, -1, 1 ),
- cLocation:new( 2, -1, 0 ),
- cLocation:new( 2, -1, -1 ),
- cLocation:new( 2, -1, -2 ),
- cLocation:new( 1, -1, 2 ),
- cLocation:new( 1, -1, 1 ),
- cLocation:new( 1, -1, 0 ),
- cLocation:new( 1, -1, -1 ),
- cLocation:new( 1, -1, -2 ),
- cLocation:new( 0, -1, 2 ),
- cLocation:new( 0, -1, 1 ),
- cLocation:new( 0, -1, 0 ),
- cLocation:new( 0, -1, -1 ),
- cLocation:new( 0, -1, -2 ),
- cLocation:new( -1, -1, 2 ),
- cLocation:new( -1, -1, 1 ),
- cLocation:new( -1, -1, 0 ),
- cLocation:new( -1, -1, -1 ),
- cLocation:new( -1, -1, -2 ),
- cLocation:new( -2, -1, 2 ),
- cLocation:new( -2, -1, 1 ),
- cLocation:new( -2, -1, 0 ),
- cLocation:new( -2, -1, -1 ),
- cLocation:new( -2, -1, -2 ),
- imadeit = false,
- }
- setmetatable(object, { __index = cFibers })
- return object;
-end
-
--- Carpet object
-cCarpet = {}
-function cCarpet:new()
- local object = { Location = cLocation:new(0,0,0),
- Fibers = cFibers:new(),
- }
- setmetatable(object, { __index = cCarpet })
- return object
-end
-
-function cCarpet:remove()
- local World = cRoot:Get():GetDefaultWorld()
- for i, fib in ipairs( self.Fibers ) do
- local x = self.Location.x + fib.x
- local y = self.Location.y + fib.y
- local z = self.Location.z + fib.z
- local BlockID = World:GetBlock( x, y, z )
- if( fib.imadeit == true and BlockID == E_BLOCK_GLASS ) then
- World:SetBlock( x, y, z, 0, 0 )
- fib.imadeit = false
- end
- end
-end
-
-function cCarpet:draw()
- local World = cRoot:Get():GetDefaultWorld()
- for i, fib in ipairs( self.Fibers ) do
- local x = self.Location.x + fib.x
- local y = self.Location.y + fib.y
- local z = self.Location.z + fib.z
- local BlockID = World:GetBlock( x, y, z )
- if( BlockID == 0 ) then
- fib.imadeit = true
- World:SetBlock( x, y, z, E_BLOCK_GLASS, 0 )
- else
- fib.imadeit = false
- end
- end
-end
-
-function cCarpet:moveTo( NewPos )
- local x = math.floor( NewPos.x )
- local y = math.floor( NewPos.y )
- local z = math.floor( NewPos.z )
- if( self.Location.x ~= x or self.Location.y ~= y or self.Location.z ~= z ) then
- self:remove()
- self.Location = cLocation:new( x, y, z )
- self:draw()
- end
-end
-
-function cCarpet:getY()
- return self.Location.y
+-- Location object
+cLocation = {}
+function cLocation:new( x, y, z )
+ local object = { x = x, y = y, z = z }
+ setmetatable(object, { __index = cLocation })
+ return object
+end
+
+-- Offsets
+cFibers = { }
+function cFibers:new()
+ local object = {
+ cLocation:new( 2, -1, 2 ),
+ cLocation:new( 2, -1, 1 ),
+ cLocation:new( 2, -1, 0 ),
+ cLocation:new( 2, -1, -1 ),
+ cLocation:new( 2, -1, -2 ),
+ cLocation:new( 1, -1, 2 ),
+ cLocation:new( 1, -1, 1 ),
+ cLocation:new( 1, -1, 0 ),
+ cLocation:new( 1, -1, -1 ),
+ cLocation:new( 1, -1, -2 ),
+ cLocation:new( 0, -1, 2 ),
+ cLocation:new( 0, -1, 1 ),
+ cLocation:new( 0, -1, 0 ),
+ cLocation:new( 0, -1, -1 ),
+ cLocation:new( 0, -1, -2 ),
+ cLocation:new( -1, -1, 2 ),
+ cLocation:new( -1, -1, 1 ),
+ cLocation:new( -1, -1, 0 ),
+ cLocation:new( -1, -1, -1 ),
+ cLocation:new( -1, -1, -2 ),
+ cLocation:new( -2, -1, 2 ),
+ cLocation:new( -2, -1, 1 ),
+ cLocation:new( -2, -1, 0 ),
+ cLocation:new( -2, -1, -1 ),
+ cLocation:new( -2, -1, -2 ),
+ imadeit = false,
+ }
+ setmetatable(object, { __index = cFibers })
+ return object;
+end
+
+-- Carpet object
+cCarpet = {}
+function cCarpet:new()
+ local object = { Location = cLocation:new(0,0,0),
+ Fibers = cFibers:new(),
+ }
+ setmetatable(object, { __index = cCarpet })
+ return object
+end
+
+function cCarpet:remove()
+ local World = cRoot:Get():GetDefaultWorld()
+ for i, fib in ipairs( self.Fibers ) do
+ local x = self.Location.x + fib.x
+ local y = self.Location.y + fib.y
+ local z = self.Location.z + fib.z
+ local BlockID = World:GetBlock( x, y, z )
+ if( fib.imadeit == true and BlockID == E_BLOCK_GLASS ) then
+ World:SetBlock( x, y, z, 0, 0 )
+ fib.imadeit = false
+ end
+ end
+end
+
+function cCarpet:draw()
+ local World = cRoot:Get():GetDefaultWorld()
+ for i, fib in ipairs( self.Fibers ) do
+ local x = self.Location.x + fib.x
+ local y = self.Location.y + fib.y
+ local z = self.Location.z + fib.z
+ local BlockID = World:GetBlock( x, y, z )
+ if( BlockID == 0 ) then
+ fib.imadeit = true
+ World:SetBlock( x, y, z, E_BLOCK_GLASS, 0 )
+ else
+ fib.imadeit = false
+ end
+ end
+end
+
+function cCarpet:moveTo( NewPos )
+ local x = math.floor( NewPos.x )
+ local y = math.floor( NewPos.y )
+ local z = math.floor( NewPos.z )
+ if( self.Location.x ~= x or self.Location.y ~= y or self.Location.z ~= z ) then
+ self:remove()
+ self.Location = cLocation:new( x, y, z )
+ self:draw()
+ end
+end
+
+function cCarpet:getY()
+ return self.Location.y
end \ No newline at end of file