Modifying "player" base entity
Posted: Wed Feb 01, 2017 3:33 pm
Hey there. I am fairly new to lua and this games class/object structure, so I am not 100% sure if I am doing something wrong or if this is simply not possible.
I am trying to insert a new variable into the player entity. I need this to store and track a simple integer value, nothing fancy. I could do it outside of player as a global, but having it tied to each player individually would relief me of the need to maintain a table with all players and the value I need.
I figured this should normaly work:
This loads fine into the game, but when I try to print it to my screen with game.player.print(game.player.experience) I get an error telling me this key doesn't exist in game.player .
If I get this wrong or someone has any idea why this isn't working, please tell me. I've already asked google and the search function here for 4 hours now and I still have no clue.
I am trying to insert a new variable into the player entity. I need this to store and track a simple integer value, nothing fancy. I could do it outside of player as a global, but having it tied to each player individually would relief me of the need to maintain a table with all players and the value I need.
I figured this should normaly work:
Code: Select all
data.lua
table.insert(data.raw.player["player"], {experience = 0})
If I get this wrong or someone has any idea why this isn't working, please tell me. I've already asked google and the search function here for 4 hours now and I still have no clue.