-- Location object cLocation = {} function cLocation:new( x, y, z ) local object = { x = x, y = y, z = z } setmetatable(object, { __index = cLocation }) return object end -- Carpet object cHome = {} function cHome:new() local object = { Location = cLocation:new(0,0,0) } setmetatable(object, { __index = cHome }) return object end function cHome:remove() --local World = cRoot:Get():GetWorld() --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 cHome:setPos( 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 ) end end HomePlugin = {} HomePlugin.__index = HomePlugin function HomePlugin:new() local t = {} setmetatable(t, HomePlugin) local w = Lua__cPlugin:new() tolua.setpeer(w, t) w:tolua__set_instance(w) return w end function HomePlugin:Initialize() self:SetName( "Home" ) self:SetVersion( 1 ) PluginManager = cRoot:Get():GetPluginManager() PluginManager:AddHook( self, cPluginManager.E_PLUGIN_CHAT ) PluginManager:AddHook( self, cPluginManager.E_PLUGIN_DISCONNECT) PluginManager:AddHook( self, cPluginManager.E_PLUGIN_JOIN) self.Homes = {} Log( "Initialized " .. self:GetName() .. " v." .. self:GetVersion() ) return true end function HomePlugin:OnDisable() Log( self:GetName() .. " v." .. self:GetVersion() .. " is shutting down..." ) end function HomePlugin:OnPlayerJoin(player) { } function HomePlugin:OnChat( Message, Player ) if( GetChar(Message, 0) ~= '/' ) then -- Not a command return false end local Split = StringSplit(Message, " ") if( Split[1] == "/mhome" ) then if( not Player:HasPermission("mhome") ) then return false end Server = cRoot:Get():GetServer() if(Split[2] == "tp") then Player:TeleportTo(self.Homes[ Player ].Location.x,self.Homes[ Player ].Location.y, self.Homes[ Player ].Location.z ) else if(Split[2] == "set") then self.Homes[ Player ] = cHome:new() self.Homes[ Player]:setPos( cLocation:new( Player:GetPosX(), Player:GetPosY()-1, Player:GetPosZ() ) ) else if(Split[2] == "info") then Server:SendMessage("Home is at " .. self.Homes[ Player ].Location.x .. "/" .. self.Homes[ Player ].Location.y .. "/" .. self.Homes[ Player ].Location.z, Player ) self.Homes[ Player]:setPos( cLocation:new( Player:GetPosX(), Player:GetPosY()-1, Player:GetPosZ() ) ) else Server:SendMessage("Unknown Command!", Player ) end --Carpet = self.Carpets[ Player ] --if( Carpet == nil ) then -- self.Carpets[ Player ] = cCarpet:new() -- Server:SendMessage("You're on a magic carpet!", Player ) -- else -- Carpet:remove() -- self.Carpets[ Player ] = nil -- Server:SendMessage("The carpet vanished!", Player ) -- end return true end return false end end end Plugin = HomePlugin:new() cRoot:Get():GetPluginManager():AddPlugin( Plugin )