diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-06-15 16:26:21 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-06-15 16:26:21 +0200 |
commit | 92fc62fb4bcb459e5fa8a0dc019f1a23ecd1078d (patch) | |
tree | fcb875431868b4a7b2372fab079c36ea2bbde781 /MCServer | |
parent | Fixed Linux compilation (diff) | |
download | cuberite-92fc62fb4bcb459e5fa8a0dc019f1a23ecd1078d.tar cuberite-92fc62fb4bcb459e5fa8a0dc019f1a23ecd1078d.tar.gz cuberite-92fc62fb4bcb459e5fa8a0dc019f1a23ecd1078d.tar.bz2 cuberite-92fc62fb4bcb459e5fa8a0dc019f1a23ecd1078d.tar.lz cuberite-92fc62fb4bcb459e5fa8a0dc019f1a23ecd1078d.tar.xz cuberite-92fc62fb4bcb459e5fa8a0dc019f1a23ecd1078d.tar.zst cuberite-92fc62fb4bcb459e5fa8a0dc019f1a23ecd1078d.zip |
Diffstat (limited to '')
-rw-r--r-- | MCServer/Plugins/MagicCarpet/plugin.lua | 166 |
1 files changed, 83 insertions, 83 deletions
diff --git a/MCServer/Plugins/MagicCarpet/plugin.lua b/MCServer/Plugins/MagicCarpet/plugin.lua index 2c9fb9160..b78c45f14 100644 --- a/MCServer/Plugins/MagicCarpet/plugin.lua +++ b/MCServer/Plugins/MagicCarpet/plugin.lua @@ -1,83 +1,83 @@ -local PLUGIN = {}
-local Carpets = {}
-
-function Initialize( Plugin )
- PLUGIN = Plugin
-
- Plugin:SetName( "MagicCarpet" )
- Plugin:SetVersion( 1 )
-
- PluginManager = cRoot:Get():GetPluginManager()
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_MOVING)
- PluginManager:AddHook(Plugin, cPluginManager.HOOK_DISCONNECT)
-
- PluginManager:BindCommand("/mc", "magiccarpet", HandleCarpetCommand, " - Spawns a magical carpet");
-
- Log( "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() )
- return true
-end
-
-
-
-
-
-function OnDisable()
- Log( PLUGIN:GetName() .. " v." .. PLUGIN:GetVersion() .. " is shutting down..." )
- for i, Carpet in pairs( Carpets ) do
- Carpet:remove()
- end
-end
-
-
-
-
-
-function HandleCarpetCommand( Split, Player )
- Carpet = Carpets[ Player ]
- if( Carpet == nil ) then
- Carpets[ Player ] = cCarpet:new()
- Player:SendMessage("You're on a magic carpet!" )
- else
- Carpet:remove()
- Carpets[ Player ] = nil
- Player:SendMessage("The carpet vanished!" )
- end
-
- return true
-end
-
-
-
-
-
-function OnDisconnect( Reason, Player )
- local Carpet = Carpets[ Player ]
- if( Carpet ~= nil ) then
- Carpet:remove()
- end
- Carpets[ Player ] = nil
-end
-
-
-
-
-
-function OnPlayerMoving(Player)
- local Carpet = Carpets[ Player ]
- if( Carpet == nil ) then
- return
- end
-
- if( Player:GetPitch() == 90 ) then
- Carpet:moveTo( cLocation:new( Player:GetPosX(), Player:GetPosY() - 1, Player:GetPosZ() ) )
- else
- if( Player:GetPosY() < Carpet:getY() ) then
- LOGINFO("Fell tru mc!")
- Player:TeleportTo( Player:GetPosX(), Carpet:getY(), Player:GetPosZ() )
- end
- Carpet:moveTo( cLocation:new( Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() ) )
- end
-end
-
-
-
+local PLUGIN = {} +local Carpets = {} + +function Initialize( Plugin ) + PLUGIN = Plugin + + Plugin:SetName( "MagicCarpet" ) + Plugin:SetVersion( 1 ) + + PluginManager = cRoot:Get():GetPluginManager() + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_MOVING) + PluginManager:AddHook(Plugin, cPluginManager.HOOK_DISCONNECT) + + PluginManager:BindCommand("/mc", "magiccarpet", HandleCarpetCommand, " - Spawns a magical carpet"); + + LOG( "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() ) + return true +end + + + + + +function OnDisable() + LOG( PLUGIN:GetName() .. " v." .. PLUGIN:GetVersion() .. " is shutting down..." ) + for i, Carpet in pairs( Carpets ) do + Carpet:remove() + end +end + + + + + +function HandleCarpetCommand( Split, Player ) + Carpet = Carpets[ Player ] + if( Carpet == nil ) then + Carpets[ Player ] = cCarpet:new() + Player:SendMessage("You're on a magic carpet!" ) + else + Carpet:remove() + Carpets[ Player ] = nil + Player:SendMessage("The carpet vanished!" ) + end + + return true +end + + + + + +function OnDisconnect( Reason, Player ) + local Carpet = Carpets[ Player ] + if( Carpet ~= nil ) then + Carpet:remove() + end + Carpets[ Player ] = nil +end + + + + + +function OnPlayerMoving(Player) + local Carpet = Carpets[ Player ] + if( Carpet == nil ) then + return + end + + if( Player:GetPitch() == 90 ) then + Carpet:moveTo( cLocation:new( Player:GetPosX(), Player:GetPosY() - 1, Player:GetPosZ() ) ) + else + if( Player:GetPosY() < Carpet:getY() ) then + LOGINFO("Fell tru mc!") + Player:TeleportTo( Player:GetPosX(), Carpet:getY(), Player:GetPosZ() ) + end + Carpet:moveTo( cLocation:new( Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() ) ) + end +end + + + |