Updated MagicCarpet to work with current API
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1185 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
0be125aa07
commit
f00515ba2e
|
@ -52,7 +52,7 @@ function cCarpet:new()
|
||||||
end
|
end
|
||||||
|
|
||||||
function cCarpet:remove()
|
function cCarpet:remove()
|
||||||
local World = cRoot:Get():GetWorld()
|
local World = cRoot:Get():GetDefaultWorld()
|
||||||
for i, fib in ipairs( self.Fibers ) do
|
for i, fib in ipairs( self.Fibers ) do
|
||||||
local x = self.Location.x + fib.x
|
local x = self.Location.x + fib.x
|
||||||
local y = self.Location.y + fib.y
|
local y = self.Location.y + fib.y
|
||||||
|
@ -66,7 +66,7 @@ function cCarpet:remove()
|
||||||
end
|
end
|
||||||
|
|
||||||
function cCarpet:draw()
|
function cCarpet:draw()
|
||||||
local World = cRoot:Get():GetWorld()
|
local World = cRoot:Get():GetDefaultWorld()
|
||||||
for i, fib in ipairs( self.Fibers ) do
|
for i, fib in ipairs( self.Fibers ) do
|
||||||
local x = self.Location.x + fib.x
|
local x = self.Location.x + fib.x
|
||||||
local y = self.Location.y + fib.y
|
local y = self.Location.y + fib.y
|
||||||
|
|
|
@ -8,16 +8,19 @@ function Initialize( Plugin )
|
||||||
Plugin:SetVersion( 1 )
|
Plugin:SetVersion( 1 )
|
||||||
|
|
||||||
PluginManager = cRoot:Get():GetPluginManager()
|
PluginManager = cRoot:Get():GetPluginManager()
|
||||||
PluginManager:AddHook( Plugin, cPluginManager.E_PLUGIN_PLAYER_MOVE)
|
PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_MOVING)
|
||||||
PluginManager:AddHook( Plugin, cPluginManager.E_PLUGIN_DISCONNECT)
|
PluginManager:AddHook(Plugin, cPluginManager.HOOK_DISCONNECT)
|
||||||
|
|
||||||
Plugin:AddCommand("/mc", " - Spawns a magical carpet!", "magiccarpet")
|
PluginManager:BindCommand("/mc", "magiccarpet", HandleCarpetCommand, " - Spawns a magical carpet");
|
||||||
Plugin:BindCommand( "/mc", "magiccarpet", HandleCarpetCommand )
|
|
||||||
|
|
||||||
Log( "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() )
|
Log( "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() )
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function OnDisable()
|
function OnDisable()
|
||||||
Log( PLUGIN:GetName() .. " v." .. PLUGIN:GetVersion() .. " is shutting down..." )
|
Log( PLUGIN:GetName() .. " v." .. PLUGIN:GetVersion() .. " is shutting down..." )
|
||||||
for i, Carpet in pairs( Carpets ) do
|
for i, Carpet in pairs( Carpets ) do
|
||||||
|
@ -25,6 +28,10 @@ function OnDisable()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function HandleCarpetCommand( Split, Player )
|
function HandleCarpetCommand( Split, Player )
|
||||||
Carpet = Carpets[ Player ]
|
Carpet = Carpets[ Player ]
|
||||||
if( Carpet == nil ) then
|
if( Carpet == nil ) then
|
||||||
|
@ -39,6 +46,10 @@ function HandleCarpetCommand( Split, Player )
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function OnDisconnect( Reason, Player )
|
function OnDisconnect( Reason, Player )
|
||||||
local Carpet = Carpets[ Player ]
|
local Carpet = Carpets[ Player ]
|
||||||
if( Carpet ~= nil ) then
|
if( Carpet ~= nil ) then
|
||||||
|
@ -47,14 +58,18 @@ function OnDisconnect( Reason, Player )
|
||||||
Carpets[ Player ] = nil
|
Carpets[ Player ] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function OnPlayerMove( Player )
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function OnPlayerMoving(Player)
|
||||||
local Carpet = Carpets[ Player ]
|
local Carpet = Carpets[ Player ]
|
||||||
if( Carpet == nil ) then
|
if( Carpet == nil ) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if( Player:GetPitch() == 90 ) then
|
if( Player:GetPitch() == 90 ) then
|
||||||
Carpet:moveTo( cLocation:new( Player:GetPosX(), Player:GetPosY()-1, Player:GetPosZ() ) )
|
Carpet:moveTo( cLocation:new( Player:GetPosX(), Player:GetPosY() - 1, Player:GetPosZ() ) )
|
||||||
else
|
else
|
||||||
if( Player:GetPosY() < Carpet:getY() ) then
|
if( Player:GetPosY() < Carpet:getY() ) then
|
||||||
LOGINFO("Fell tru mc!")
|
LOGINFO("Fell tru mc!")
|
||||||
|
@ -63,3 +78,6 @@ function OnPlayerMove( Player )
|
||||||
Carpet:moveTo( cLocation:new( Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() ) )
|
Carpet:moveTo( cLocation:new( Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() ) )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user