Jump to content
  • Advertisement

Wolfbrother

Member
  • Content Count

    8
  • Joined

  • Last visited

Community Reputation

118 Neutral

About Wolfbrother

  • Rank
    Newbie

Personal Information

  • Interests
    Programming
  1. Wolfbrother

    Prevent Reassignment Of Handle

    Yes, that works. Thanks again Marcus.
  2. Wolfbrother

    Prevent Reassignment Of Handle

    Ah, silly me. Yeah, that should work; I'll give it a try.   Thanks Marcus!
  3. I have registered a type in angelscript with a property that is a handle to an object:   RegisterObjectProperty("SomeType", "Object@ obj", 0);   That object's memory is handled by the application.   I would like to prevent script writers from assigning another object to that handle, without making the object constant. For example:   SomeType@ a = ...; SomeType@ b = ...;   a.obj.value = 4; // Script can edit obj   a.obj = b.obj; // I want this to fail   It needs to be a handle, because SomeType.obj may refer to another SomeType's obj. I just don't want the script to be able to change which object it refers to. Is there a way I can do this?
  4. Wolfbrother

    Deregister Angelscript Type

    Thanks Tangletail, I am familiar with the concepts you are presenting above.   I'll explain a bit about how my entity system works, because your solution will not work with the way I have things at the moment. I'll re-wirte it if it needs to be changed, but at the moment it is working well (except for this re-registering of types business).   My entity components are purely data, and are not managed by Angelscript. Component types are defined in a (non script) file, and changed in the editor. When a component is added to an entity, the ComponentType c++ class (which holds the definition of a component) will allocate memory for the component.   When the ComponentType is defined, it registers an interface in Angelscript. Scripts are then run that reference the type, and they load components from the entity manager like so: Health@ health = cast<Health>(GetEntityComponent(entity, "Health")); health.value -= 1; GetEntityComponent() returns a pointer to the component data that was allocated.   My reasons for implementing components this way are: It's easier to define c++ components. Just create a struct for the component, and map it to a ComponentType. No need to use inheritance, on the c++ or Angelscript side (the Angelscript component types are all inherited form a base, but ComponentType handles that, not the person defining the component). Since the component is purely data, you don't define it in a script, just a list of variable types and default values. In the editor, there is no need to open a script file to change a component (not that this would be a bad thing, it just seems more intuitive to use a GUI for this). I can see how defining the components in a script would allow me to recompile them when any changes were made. And I could then use metadata to hook them up to the GUI. But if I can find a way to make my current system work, that would be preferable.   Perhaps I could generate a script file from the ComponentType, and compile that into the script module, rather than defining them as global types?.   Or perhaps I could just restart the whole script engine if a component type is changed in the editor. Hmmmm...   Anyway, thanks again for your help, Tangletail
  5. Wolfbrother

    Deregister Angelscript Type

      Thanks Tangletail.   My purpose is a bit more general than changing a single, specific type, though. I want to be able to change any type at run-time, with any type/number of member variables.   Specifically, I'm making a game editor with an interface for creating entity component types. They have a corresponding type in Angelscript. When I change a type via the editor, the engine will handle any reallocation of memory to existing entity components of that type, and recompile scripts that use that type. In order for this to work, I need to be able to re-register the type.   I'm just having a look at Config Groups. I might be able to register the type in a config group, and then remove it, and recreate it and re-register the type.   Is there any reason not to have one config group for each component type? Otherwise, I could just recreate all types, and recompile all scripts, whenever a component changes in the editor.
  6. Is there a way that I can deregister a single type in Angelscript? The type is registered as follows: iResult = pkEngine->RegisterObjectType("TypeName", uiSize, asOBJ_REF | asOBJ_NOCOUNT); iResult = pkEngine->RegisterObjectProperty("TypeName", "int value", uiOffset); If I wanted to change the type of "value" to float, for example, is there a way to do so without rerunning the program, or restarting the script engine?   I would then have to recompile any scripts that use that type, of course.
  7. Wolfbrother

    Construct Angelscript object in memory

    I figured out that I need to find the type within the module I loaded the scripts into: asUINT uiSize = pkEngine->GetModule("Module")->GetObjectTypeByName("SomeClass")->GetSize(); I found a couple of functions that might allow me to create a default constructed object, and then copy it to my buffer. But this does not let me call a non-default constructor. void* pvObject = pkEngine->CreateScriptObject(type); pkEngine->AssignScriptObject(pvMemory, pvObject, type); pkEngine->ReleaseScriptObject(pvObject, type);
  8. I would like to construct a user defined Angelscript type (defined in a script file) in a pre-allocated memory buffer, using the type name and a parameter list. For example: // In Angelscript class SomeClass {     SomeClass(int a, int b)     { ... } int value; } Then the type name and some construction parameters are passed in from some other text file. Something like this:   "SomeClass", "(2, 5)"   Then I will allocate memory according to size of SomeClass asUINT uiSize = pkEngine->GetObjectTypeByName("SomeClass")->GetSize(); // allocate some memory Am I able to call the constructor "SomeClass(2, 5)" in that memory location? Do I need to know the parameter types?   Edit: GetObjectTypeByName("SomeClass") is not working actually; SomeClass does not seem to be recognised as an object type. If I iterate over all types, it is only picking up types I have registered through the c++ api.
  • 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!