🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Structures
Is there no easier why to access scripted structures with application then the example found in the 'test_feature' source 'test_structintf.h'?
It seems like a lot of overhead just to get access to the scripted structure.
I just want to change some values within the structure and read some values.
If I have the following situation what would be my best option of access?
script:
struct npcFlavourStats
{
float hunger;
float fun;
float aggro;
float rest;
...
}
Now this structure is used by each NPC in a fictional game and needs to be updated
at time and event intervals. Do I have to create a 'asIScriptAny' structure for
each NPC instance? Also is it possible do destroy the 'asIScriptAny' instance and
keep the 'asIScriptStruct' instance and use it 'legaly'? (operating on valid data)
If the application needs to use the struct, you should probably declare it in the application and register it with the script like you would anything else.
If you are trying to do what I think you are, which is allow scripts to change what data is associated with entities, there are other ways to do it. In my MUD, I just gave entities key/value pairs with a simple interface for accessing them based on their string name.
If you are trying to do what I think you are, which is allow scripts to change what data is associated with entities, there are other ways to do it. In my MUD, I just gave entities key/value pairs with a simple interface for accessing them based on their string name.
The problem is that the application doesn't know about the script declared structures until the scripts have been compiled. Because of that, currently the only way you can pass a script declared structure to the application is through a asIScriptAny object.
I'm working on improving this though. You will have a couple of new ways of doing it, either have the application declare an interface that the script struct must adhere to, or use the base class common to all script declared objects. These things are not yet ready though, so you'll have to be patient a while longer.
Yes, you can release the asIScriptAny object and still use the asIScriptStruct you received through it. Just remember to call AddRef on the asIScriptStruct before releasing the asIScriptAny, and then call Release on the struct when you don't need it anymore.
Regards,
Andreas
I'm working on improving this though. You will have a couple of new ways of doing it, either have the application declare an interface that the script struct must adhere to, or use the base class common to all script declared objects. These things are not yet ready though, so you'll have to be patient a while longer.
Yes, you can release the asIScriptAny object and still use the asIScriptStruct you received through it. Just remember to call AddRef on the asIScriptStruct before releasing the asIScriptAny, and then call Release on the struct when you don't need it anymore.
Regards,
Andreas
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement