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.
Reading Components Info
- Attachments
-
- CompScore.hpp
- (1.91KiB)Downloaded 516 times
-
- CompScore.cpp
- (2.67KiB)Downloaded 563 times
-
- CompHumanPlayer.hpp
- (9.86KiB)Downloaded 534 times
-
- CompHumanPlayer.cpp
- (66.95KiB)Downloaded 532 times
-
- Score.lua
- (795Bytes)Downloaded 544 times
-
- HumanPlayer.lua
- (7.25KiB)Downloaded 558 times
-
- HUD_main.cgui
- (4.56KiB)Downloaded 539 times
Re: Reading Components Info
Overall, this is looking good!
Have you added a Score component instance to a newly instantiated player?
See method
As an alternative, it would probably be possible (and maybe easier) to use the Inventory component for additional custom counters. It would save you from customizing the C++ code (which is probably not what you want, though ), and I've not verified that this works.
Have you added a Score component instance to a newly instantiated player?
See method
CaServerWorldT::InsertHumanPlayerEntityForNextFrame()
in file Ca3DE/Server/ServerWorld.cpp
for details, adding the Score component at about line 132 should work.As an alternative, it would probably be possible (and maybe easier) to use the Inventory component for additional custom counters. It would save you from customizing the C++ code (which is probably not what you want, though ), and I've not verified that this works.
Best regards,
Carsten
Carsten
Re: Reading Components Info
Thanks for the advice. I added the score component into the serverworld file and all works great
Well, at least the GUI does, I don't have anyone to shoot at to see if the kills register!!
I am now adding the team number component. I think I have figured out how to integrate my gamerules code into the scripts already there. It just took me a little while to think about it in the right way
Well, at least the GUI does, I don't have anyone to shoot at to see if the kills register!!
I am now adding the team number component. I think I have figured out how to integrate my gamerules code into the scripts already there. It just took me a little while to think about it in the right way
Who is online
Users browsing this forum: No registered users and 18 guests