Test Pluggin: Noooo....
#1
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.
 
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.)
Reply
Thanks given by:


Messages In This Thread
Test Pluggin: Noooo.... - by Narroo - 02-19-2014, 04:40 AM
RE: Test Pluggin: Noooo.... - by NiLSPACE - 02-19-2014, 04:45 AM
RE: Test Pluggin: Noooo.... - by Narroo - 02-19-2014, 05:10 AM
RE: Test Pluggin: Noooo.... - by NiLSPACE - 02-19-2014, 05:16 AM
RE: Test Pluggin: Noooo.... - by xoft - 02-19-2014, 07:18 AM
RE: Test Pluggin: Noooo.... - by Narroo - 02-19-2014, 10:09 AM
RE: Test Pluggin: Noooo.... - by NiLSPACE - 02-19-2014, 07:39 AM
RE: Test Pluggin: Noooo.... - by worktycho - 02-19-2014, 10:52 AM
RE: Test Pluggin: Noooo.... - by Narroo - 02-19-2014, 12:32 PM
RE: Test Pluggin: Noooo.... - by xoft - 02-19-2014, 05:29 PM
RE: Test Pluggin: Noooo.... - by worktycho - 02-19-2014, 11:23 PM



Users browsing this thread: 3 Guest(s)