Reading Components Info
Posted: 2014-08-30, 06:03
I have created a new component called CompScore. I have implemented the variables m_Score, m_Kills & m_Deaths. I have added the score component to CompHumanPlayer.
I have removed the code for AddFrags from HumanPlayer, and created AddKill(), AddScore() etc in the Score lua script.
I am now trying to update the player HUD to read the kills variable, instead of frags. I have done all the cosmetic changes, but my problem is calling the variable.
gui.Player only references variables available directly in the HumanPlayer Component, and when I try and call through gui.Entity with the following:
local kills = gui.Entity:GetComponent("Score"):get("Kills")
I get told I am trying to index a nil value. Here are my files.
I haven't yet been able to test the AddKills() code etc, as I can't get the GUI working with the component. If you could shed some light on it, I would be grateful.
I have removed the code for AddFrags from HumanPlayer, and created AddKill(), AddScore() etc in the Score lua script.
I am now trying to update the player HUD to read the kills variable, instead of frags. I have done all the cosmetic changes, but my problem is calling the variable.
gui.Player only references variables available directly in the HumanPlayer Component, and when I try and call through gui.Entity with the following:
local kills = gui.Entity:GetComponent("Score"):get("Kills")
I get told I am trying to index a nil value. Here are my files.
I haven't yet been able to test the AddKills() code etc, as I can't get the GUI working with the component. If you could shed some light on it, I would be grateful.