Jump to content
  • Advertisement

immortius

Member
  • Content Count

    16
  • Joined

  • Last visited

Community Reputation

100 Neutral

About immortius

  • Rank
    Member
  1. immortius

    Garbage data output on operator+ member

    I think you have a comma in the wrong place in the registration of opAdd (you have it after the last const, instead of before).
  2. immortius

    Exposing the right functionality

    I should explain that coroutines are not actually a core Angelscript feature. Angelscript merely provides the ability to suspend script contexts and resume them later to the C++ code. yield() is just an arbitrary function that is registered for scripts to suspends a context until the next frame/cycle as part as the ContextManager add on. You can develop a coroutine system that provides other yield-like functions that suspend script contexts until future events occur - in the example given I intend WaitForSeconds() to be a yield style function that suspends the context until an amount of time passes, rather than just a single frame. You could have a whole suite of yield functions that suspend until different events occur - as long as you are willing to implement them in the C++/native code. I guess the other point is that the "DelayedExplosion" coroutine would not be activated immediately, but later in the same frame - the StartCoroutine function would queue it up, but the current context must end/suspend before it will start. That's the way I've implemented it anyhow, and I believe the context manager implementation is similar. Edit: I think I've just about convinced myself to cut back on coroutine use at this point. A timer system addresses a lot the need without the overhead of keeping contexts in memory. Rather than the timer-with-id style used in WitchLord's example I might mess with something where you register a function name (or pointer) to be called after the time has passed.
  3. immortius

    Exposing the right functionality

    I'm having a bit of a rethink of how I want coroutines to work in my integration now, based on your comments. I don't feel there is necessarily any conflict between coroutines and an event based model, although for that conflict to be removed coroutines need to be "named" and stoppable. I supposed that is reaching towards treating coroutines as states that can be entered and left, or possibly stacked. For example a placeable bomb script may look like: class Bomb : BaseObject { void Start() { StartCoroutine("DelayedExplode"); } void DelayedExplode() { for (int i = 0; i < 10; ++i) { Flash(); WaitForSeconds(1); } Explode(); } void Disarmed() { StopCoroutine("DelayedExplode"); BecomePickup(); } } Admittedly for something more complex like an AI involved in tactical behaviour (like presently engaging a player, as opposed to patrolling or pursing long-term activities) this may not work as well, as you want to be constantly reassessing the situation. There is probably room for both things to be mixed together in the same class though, for different purposes. Anyhow I'm looking at things in light of my previous experiences with UnrealScript and its State construct (with simple coroutine support) and Unity, and perhaps I need to review those previous learnings.
  4. immortius

    Opinion: What should I name the generic handle type?

    Yes, that is how it works. I just really meant it was the most similar thing besides void not that it was particularly close - really it is a compile-time construct where this is a runtime thing. It has uses outside of templates though - I like using it for STL iterators. // Don't have to specify the type for (auto iter = someSTLContainer.begin(); iter != someSTLContainer.end(); ++iter) { ... } or handling the returned value from make_shared<>(). I would be perfectly happy with ref or handle.
  5. immortius

    Exposing the right functionality

    There's obviously a number of ways to do this, and I'm not a long time user of AngelScript, but some thoughts based on how I've approached this: 1. Regarding running of the scripts, I'm a big fan of coroutines, as they allow you to express logic that occurs over a period of time cleanly. i.e. void PursueTarget(Creature enemy) { while(CanDetect(enemy) && !IsInRange(enemy)) { MoveTowards(enemy.GetPosition()); yield(); } if (CanDetect(enemy)) { Attack(enemy); } } To this end I run many events originating from the engine side as coroutines, which can be stopped for a frame with a yield command. I also don't give objects an update function that is called every frame, and instead let them start a coroutine or if they need this. In future I'll probably expand this so that couroutines can be stopped for a period of time, or while a long running engine function is being processed (i.e. pathfinding on a separate thread, or even the MoveTo(X) function). 2. The way I've done game objects in general is I have a C++ backing object that is wrapped by a base script controller object, which all other script objects can then inherit. The C++ backing object holds the world location/rendering information and is the bit that generally interacts with the engine subsystems and receives events from them - which are then promoted up to their script controller. For instance, the backing object is actually placed in the world (a 2D grid) and can then a engine exposes a function to query all objects in a grid square. This could actually be broken down into a component model, where a script object has a number of engine-implemented components - Display components that are rendered, collision components that exist in the world and block or detect other collision components, sound components, etc.
  6. immortius

    Opinion: What should I name the generic handle type?

    Closest thing in C++ besides void would be the C++0x auto keyword, but the connotations are somewhat different. Maybe the name could be explicitly untyped or untypedRef for clarity?
  7. immortius

    Newbie needs some advices

    You can get the typeId of each parameter from the asIScriptFunction object using the GetParamCount() and GetParamTypeId() functions, and ultimately look up those types and work out what they are. If only primitives are allowed, you can look up the type Ids of each primitive beforehand using asIScriptEngine's GetTypeIdByDecl() function. So you should be able to handle this with a loop over each parameter and a switch statement or function map or similar.
  8. I believe what WitchLord is saying is that ScriptBuilder out of the box gives you the second one, but you could modify it to achieve the first one.
  9. immortius

    Feature Suggestion: Disable Default Constructor

    Sounds good, although would T() default do anything T() {} doesn't (besides act the same way as adding in the other default methods)? Another feature that might be nice would be private constructors - primarily for having script classes that can only be created from the native end (possibly through a factory method).
  10. immortius

    Feature Suggestion: Disable Default Constructor

    remove Constructor() noauto Constructor() noop Constructor() pleaseno Constructor() Or perhaps it could copy the behavior of some other languages and only automatically produce a default constructor if no other constructor is present.
  11. immortius

    AngelScript 2.21.0

    Nice. Will update shortly.
  12. immortius

    std::string returned via reference

    Try changing eScripting->RegisterObjectType(" bspEntity",sizeof( bspEntity),asOBJ_VALUE | asOBJ_POD|asOBJ_APP_CLASS ); to eScripting->RegisterObjectType(" bspEntity",sizeof( bspEntity),asOBJ_VALUE | asOBJ_APP_CLASS ); I don't believe a class containing strings is valid for asOBJ_POD.
  13. I can see it might be awkward if an interface has a lot of methods, and only some of them should be implemented in the base class, since you'ld be forced to implement them all in the base class and lose compile check for proper implementations in the subclasses. I guess you can always split the interface in two, but that makes things awkward for users if they need to cast back and forth between them. Can interfaces inherit other interfaces in AngelScript? That would let you have a base interface (for the base class to implement) and the full interface that everything else works against.
  14. I'm probably doing something horribly wrong, but I'm getting a crash when attempting to store a vector3 (from the scriptmath3d add on) in a CScriptAny object in script. Basically: any storage; storage.store(vector3(1,1,1)); The issue seems to be with the reference pointer coming out of the script being invalid (in one case it was 0x01) Although this may be less a CScriptAny problem and more an issue with returning value types via a method with variable parameters. This is with version 2.20.3, VS2010, x86 compile.
  15. immortius

    Crash on 64bit *nix

    I don't know if this may be related, but I *think* there may be an issue with asIScriptContext bleeding an object's reference count if you Prepare(), SetObject() and then Unprepare() or Release() the context without Execute()ing it - because Unprepare() releases the object but its reference count is only incremented if you Execute() (I guess?). And if this happens repeatedly it can cause a crash in Unprepare(). I'm just getting started with AngelCode so I may be wrong though - I haven't been able to track through what is happening fully yet. This is on VS2010, x86 compile. At any rate I was forgetting to execute when I found it which is probably an uncommon occurrence.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!