So, I'm trying to write a basic plugin to get a feel for how the plugins work. This is what I've gotten so far, and it doesn't work.
[13:38:52] LUA: Plugins/PluginTest/main.lua:23: attempt to index global 'cItemCa
tegory' (a nil value)
I assume this is because cItemCategory isn't declared anywhere, and nothing is #include'ed. The thing is, I'm just following the example in the API documentation. How do I get this to work?
EDIT: Fixed the showcode. (The show code button glitched before and I didn't know the manual tags, so I just rolled with it.)
PLUGIN = nil
function Initialize(Plugin)
Plugin:SetName("PluginTest")
Plugin:SetVersion(1)
-- Hooks
cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICKING_ENTITY, ExplodeHoe)
PLUGIN = Plugin -- NOTE: only needed if you want OnDisable() to use Get() name or something like that
-- Command Bindings
[undefined=undefined]
LOG("Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
return true
end
function OnDisable()
LOG(PLUGIN:GetName() .. " is shutting down...")
end
function ExplodeHoe(Player, Entity)
local HeldItem = Player:GetEquippedItem();
if (cItemCategory:IsHoe(HeldItem.m_ItemType)) then
Player:GetWorld():DoExplosionAt(0,Entity:GetPosX(), Entity:GetPosY(), Entity:GetPosZ(), false, esPlugin)
end
end
Now, what happens is that I get a complaint from the Server Console. It says:[13:38:52] LUA: Plugins/PluginTest/main.lua:23: attempt to index global 'cItemCa
tegory' (a nil value)
I assume this is because cItemCategory isn't declared anywhere, and nothing is #include'ed. The thing is, I'm just following the example in the API documentation. How do I get this to work?
EDIT: Fixed the showcode. (The show code button glitched before and I didn't know the manual tags, so I just rolled with it.)

