diff options
author | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-01 20:19:51 +0100 |
---|---|---|
committer | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-01 20:19:51 +0100 |
commit | 28ff03fcfe727f827c00078c4fa0319cb3c03421 (patch) | |
tree | 79a961e2c3bf9005556cbd7276dd4af2728fd76b /Plugins/MagicCarpet/plugin.lua | |
parent | VC2008: removed an unneeded file from zlib project (diff) | |
download | cuberite-28ff03fcfe727f827c00078c4fa0319cb3c03421.tar cuberite-28ff03fcfe727f827c00078c4fa0319cb3c03421.tar.gz cuberite-28ff03fcfe727f827c00078c4fa0319cb3c03421.tar.bz2 cuberite-28ff03fcfe727f827c00078c4fa0319cb3c03421.tar.lz cuberite-28ff03fcfe727f827c00078c4fa0319cb3c03421.tar.xz cuberite-28ff03fcfe727f827c00078c4fa0319cb3c03421.tar.zst cuberite-28ff03fcfe727f827c00078c4fa0319cb3c03421.zip |
Diffstat (limited to '')
-rw-r--r-- | Plugins/MagicCarpet/plugin.lua | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/Plugins/MagicCarpet/plugin.lua b/Plugins/MagicCarpet/plugin.lua new file mode 100644 index 000000000..22604c9d9 --- /dev/null +++ b/Plugins/MagicCarpet/plugin.lua @@ -0,0 +1,65 @@ +local PLUGIN = {}
+local Carpets = {}
+
+function Initialize( Plugin )
+ PLUGIN = Plugin
+
+ Plugin:SetName( "MagicCarpet" )
+ Plugin:SetVersion( 1 )
+
+ PluginManager = cRoot:Get():GetPluginManager()
+ PluginManager:AddHook( Plugin, cPluginManager.E_PLUGIN_PLAYER_MOVE)
+ PluginManager:AddHook( Plugin, cPluginManager.E_PLUGIN_DISCONNECT)
+
+ Plugin:AddCommand("/mc", " - Spawns a magical carpet!", "magiccarpet")
+ Plugin:BindCommand( "/mc", "magiccarpet", HandleCarpetCommand )
+
+ 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 OnPlayerMove( 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
\ No newline at end of file |