Skip to main content
GameDev.net gamedev.net
🔒 Locked

Local variables with scripts

Started by M4573R Jun 28, 2011 at 11:25 PM 0 replies 900+ views
Original Post
M4573R
M4573R
I was just curious what methods people are using to store per-instance data for scripts. The way I did it in the past was that each script component for an object would have a map of string->floats and string->string and I just queried them from lua. It seems like it wouldn't scale very well though. Although if you used variants in your code for object properties, then I could see this working so well that the performance hit would be worth it, and there wouldn't be separation between script / code object data. Just curious how other people are doing it.
Ashaman73
Ashaman73

I was just curious what methods people are using to store per-instance data for scripts. The way I did it in the past was that each script component for an object would have a map of string->floats and string->string and I just queried them from lua. It seems like it wouldn't scale very well though. Although if you used variants in your code for object properties, then I could see this working so well that the performance hit would be worth it, and there wouldn't be separation between script / code object data. Just curious how other people are doing it.

I do it this way:
All engine depedent properties (render model, sounds, effects etc.) are part of the engine(C++), all game relevant parts (hitpoints, ai data etc.) are part of the script component. Eventually I have a 1:1 association between engine object and script data, whereas the script data consists of one or more (lua) tables.

Thought there's a grey zone (should I put in into the engine or script part ?). In this case I start out with putting it into the script part and if the performance hit is too high, I would try to move parts of it into the engine.

Eventually it seems to look like your approach

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.