I need a hint for basic scripting in CryEngine 3

349 views Asked by At

I want to add some Parameters to the Player. e.g "Hunger", "Thirst" (Survival Stuff) Can I do this with a lua script? Because the Player is something that's already set up in the engine. Can I acess him? Or what would be the best way to do that?

1

There are 1 answers

0
Ryan Stein On

If it's the case that the player is immutable or you're otherwise unable to add new fields to it (userdata, etc.), then it's usually possible to construct a table which has the unchangeable data (in this case, the player) as an index key to fields representing the data you want to track.

local hunger = setmetatable({}, {__mode = 'k'}) -- Use weak keys for the GC.
hunger[Player1] = 10

For example, you could use this idiom any time you wanted to "add" more information to such an object, userdata, or table. This is just a general Lua idea, separate from any specific engine. Depending upon how CryEngine works, you might need to make hunger a global variable as opposed to a local one.