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.
- (1.91 KiB) Downloaded 105 times
- (2.67 KiB) Downloaded 106 times
- (9.86 KiB) Downloaded 108 times
- (66.95 KiB) Downloaded 106 times
- (795 Bytes) Downloaded 106 times
- (7.25 KiB) Downloaded 103 times
- (4.56 KiB) Downloaded 105 times
Have you added a Score component instance to a newly instantiated player?
Ca3DE/Server/ServerWorld.cppfor 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.
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
Users browsing this forum: No registered users and 1 guest