Miracle Dog

  • Content count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About Miracle Dog

  • Rank
  1. Hi, I've exposed my game_entity class to angelscript. in the constructor it adds the pointer of itself to a linked list of all game_entities. So how can I have something like this: int main(game_entity *this) { if(whatever = true) { game_entity bullet; bullet.set_position = 3; bullet.set_velocity = vector3d(0, 1, 0); } } And then still have the "bullet" entity available by the linked list afterwards? (it seems to delete any script-declared variables once the script finishes)
  2. Creating a link between a script context and game entity

    Thanks for your replies. I tried what abrken said, it worked until I tried calling a script from within a script (because the pointer would change halfway through, once the parent script regained control it wouldn't have the correct pointer). So I decided to rethink my implementation, and pass around pointers.
  3. I want to be able to give a script context a pointer to a class, and then have that class passed to all the functions called in that script without the user having to pass it manually. so I can have an enemy script like this: // spider.script int main() { if(get_health() < 10) { escape(); } else { // attack!! } } where "get_health()" looks something like this: int get_health(void *pointer_to_class) { return pointer_to_class->health; } Then I can have one script for each type of enemy, then in my program loop through each game_entity and call the relevant module, passing a pointer to itself. I hope that made sense. If there's a way better way of doing it, let me know, but I want to keep it relatively high level and avoid using OOP style scripting...