2012-10-16 04:20:45 -04:00
-- Global variables
PLUGIN = { } -- Reference to own plugin object
function Initialize ( Plugin )
PLUGIN = Plugin
Plugin : SetName ( " Debuggers " )
Plugin : SetVersion ( 1 )
PluginManager = cRoot : Get ( ) : GetPluginManager ( )
2013-01-13 06:10:26 -05:00
PluginManager : AddHook ( Plugin , cPluginManager.HOOK_PLAYER_USING_ITEM )
2012-12-21 06:22:46 -05:00
PluginManager : AddHook ( Plugin , cPluginManager.HOOK_TAKE_DAMAGE )
2012-10-16 04:20:45 -04:00
LOG ( " Initialized " .. Plugin : GetName ( ) .. " v. " .. Plugin : GetVersion ( ) )
return true
end
2013-01-13 06:10:26 -05:00
function OnPlayerUsingItem ( Player , BlockX , BlockY , BlockZ , BlockFace , CursorX , CursorY , CursorZ )
2012-10-16 04:20:45 -04:00
-- dont check if the direction is in the air
2013-01-13 06:10:26 -05:00
if ( BlockFace == BLOCK_FACE_NONE ) then
2012-10-16 04:20:45 -04:00
return false
end
2013-01-13 06:10:26 -05:00
local HeldItem = Player : GetEquippedItem ( ) ;
2012-10-16 04:20:45 -04:00
if ( HeldItem.m_ItemType == E_ITEM_STICK ) then
-- Magic sTick of ticking: set the pointed block for ticking at the next tick
Player : SendMessage ( cChatColor.LightGray .. " Setting next block tick to { " .. BlockX .. " , " .. BlockY .. " , " .. BlockZ .. " } " )
Player : GetWorld ( ) : SetNextBlockTick ( BlockX , BlockY , BlockZ ) ;
return true
end
if ( HeldItem.m_ItemType == E_ITEM_BLAZE_ROD ) then
-- Magic rod of query: show block types and metas for both neighbors of the pointed face
local Type = 0 ;
local Meta = 0 ;
2013-01-13 06:10:26 -05:00
local Valid = false ;
Valid , Type , Meta = Player : GetWorld ( ) : GetBlockTypeMeta ( BlockX , BlockY , BlockZ , Type , Meta ) ;
2012-10-16 04:20:45 -04:00
if ( Type == E_BLOCK_AIR ) then
Player : SendMessage ( cChatColor.LightGray .. " Block { " .. BlockX .. " , " .. BlockY .. " , " .. BlockZ .. " }: air: " .. Meta ) ;
else
local TempItem = cItem ( Type , 1 , Meta ) ;
Player : SendMessage ( cChatColor.LightGray .. " Block { " .. BlockX .. " , " .. BlockY .. " , " .. BlockZ .. " }: " .. ItemToFullString ( TempItem ) .. " ( " .. Type .. " : " .. Meta .. " ) " ) ;
end
local X = BlockX ;
local Y = BlockY ;
local Z = BlockZ ;
2013-01-13 06:10:26 -05:00
X , Y , Z = AddFaceDirection ( BlockX , BlockY , BlockZ , BlockFace ) ;
Valid , Type , Meta = Player : GetWorld ( ) : GetBlockTypeMeta ( X , Y , Z , Type , Meta ) ;
2012-10-16 04:20:45 -04:00
if ( Type == E_BLOCK_AIR ) then
Player : SendMessage ( cChatColor.LightGray .. " Block { " .. X .. " , " .. Y .. " , " .. Z .. " }: air: " .. Meta ) ;
else
local TempItem = cItem ( Type , 1 , Meta ) ;
Player : SendMessage ( cChatColor.LightGray .. " Block { " .. X .. " , " .. Y .. " , " .. Z .. " }: " .. ItemToFullString ( TempItem ) .. " ( " .. Type .. " : " .. Meta .. " ) " ) ;
return true ;
end
end
end
2012-12-21 06:22:46 -05:00
function OnTakeDamage ( Receiver , TDI )
-- Receiver is cPawn
-- TDI is TakeDamageInfo
LOG ( Receiver : GetClass ( ) .. " was dealt RawDamage " .. TDI.RawDamage .. " , FinalDamage " .. TDI.FinalDamage .. " (that is, " .. ( TDI.RawDamage - TDI.FinalDamage ) .. " HPs covered by armor) " ) ;
end