more questions (all will go here)

This forum is currently in read-only mode.
0 favourites
  • I'm going to flood the board if I keep starting new threads for all my questions, so they'll all go here


    in the template SDK resources, there's IDR_ACTIONS and IDR_CONDITIONS, and IDR_EXPRESSIONS menus.

    can I do something with these? like make a different kind of interface to the plugin, instead of the standard list thing that comes when you use add param and such?


    I can take a parameter for object types, and get

    CRunObjType* pObjType= params[0].GetObjectParam(pRuntime);
    [/code:31q7idtd] which I can use to [code:31q7idtd]pRuntime->CreateObject(pObjType, pLayer->number, pLayout);[/code:31q7idtd]
    what if I already know the object type beforehand?  is there a way to like
    [code:31q7idtd]pRuntime->CreateObject(specific_object_type, 1, pLayout)[/code:31q7idtd]
    [code:31q7idtd]CRunObjType* pObjType = my_object_type[/code:31q7idtd]?
  • 1. They're deprecated and no longer used. Ignore them.

    2. I'm not sure I understand the question. If you use pRuntime->CreateObject(specific_object_type, 1, pLayout), and specific_object_type is a valid CRunObjType*, that will work.

  • 2. I'm not sure I understand the question. If you use pRuntime->CreateObject(specific_object_type, 1, pLayout), and specific_object_type is a valid CRunObjType*, that will work.

    well for instance if I wanted to create a sprite

    how would I get the CRunObjType for sprite or my_object_type, when they aren't chosen as parameters

    just no matter what it's supposed to create a sprite,

    or to put it another way

    how do I get a CRunObjType* for sprite without using GetObjectParam?

    or my_object_type

  • There's the 'pType' member of CRunObject which is a CRunObjType* pointer to the object's type. Have a browse through the SDK headers some time, you'll probably find a lot of useful stuff in there.

  • Thanks again Ash

  • Ok,

    I have some pointer variables that I declared in main.h in the ExtObject definition

    but I realized at runtime all instances of my plugin shared these pointer variables

    but not the other variables

    for instance:

    class ExtObject : public CRunObject
    //...all the sdk code ...//
       CRunObject* pMyPointer;
    	int MyInt;
    at runtime MyInt stays unique to each instance of the plugin
    pMyPointer is like one variable shared by all instances of the plugin
    I say instances, but to clarify, this happens whether I have several instances of MyPlugin
    or if I have cloned MyPlugin several times so I have separate objects MyPlugin, MyPlugin2, etc...
    is there a way to avoid  this? I want each instance to have a unique pointer.
  • A pointer points to an area of memory. If the object the pointer is for is the same, the memory address is going to be the same.

  • at runtime MyInt stays unique to each instance of the plugin

    pMyPointer is like one variable shared by all instances of the plugin

    No it's not! If you wanted it shared, you'd declare it static, but since it's not, a copy of the pointer is held by every object instance. They could all point to the same object if your code does that - but each instance is holding a separate pointer which can be uniquely changed.

  • simple one

    how do I make an object destroy itself

    I can't find a aDestroy() action in the sprite cvs I'm assuming you need to


    either way, do I have to explicitly destroy them


    or is there a something in the sdk to do it?
    would it be pRuntime->DestroyObject(MyObjectPointer)?
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yes.

  • hi again, k, having trouble creating an object

    I'll show what I've done, maybe you can catch a mistake, or tell me what I'm missing

    there's some other less related stuff in there, but it involves extracting parameters or some other likely problem spot:

    ADDPARAM(PARAM_OBJECT, "TypeA", "Choose the a TypeA object to initialize the pointer.");
    ADDACT("InitPointer", "Initialization", "Initialize Pointer(%o)", &ExtObject::aInitializePointer, "InitializePointer", 0);
    long ExtObject::aInitializePointer(LPVAL params)
    	pTypeAPointer = params[0].GetObjectParam(pRuntime);
    	return 0;
    ADDPARAM(PARAM_VALUE, "Object Type", "Choose which object to create");
    ADDPARAMDEF(PARAM_VALUE, "Layer", "Layer name or number, to create the object on.", "1");
    ADDACT("Create Object", "Creation", "CreateObject", &ExtObject::aCreateObject,"hh",0);
    long ExtObject::aCreateObject(LPVAL params)//returns object pointer
    CRunLayer* pLayer = params[1].GetLayerParam(pRuntime, pLayout);
    if (params[0].GetInt() == 0)
    	{ObjectIndex[index]=pRuntime->CreateObject(pTypeAPointer,pLayer->number, pLayout);}
    EDIT, sorry, this may help:
    [code:rqvp7l0h]	CRunObject* ObjectIndex[500];
    	int index;
    	CRunObjType* pTypeAPointer;[/code:rqvp7l0h]
  • I've no idea what this code is meant to be doing, but some quick observations:

    • Don't use C++ terminology in events (avoid referring to pointers or other programming terms unless they are truly appropriate)
    • %o (letter 'o') in action text is your object icon, not the first parameter - the first parameter is %0 (number zero)
    • GetObjectParam, GetLayerParam and many other functions in the SDK are allowed to return NULL eg. if the user types the name of a layer that doesn't exist - always check for NULL pointers
    • Why does your 'create object' action define an object type parameter as PARAM_VALUE?

    Anyways, there's nothing in this snippet that tells me why it wouldn't work. If you debug the call to pRuntime->CreateObject, what are the values of the parameters?

  • thanks ash. I actually didn't know how to use the debugger, until I mentioned to david in chat that I didn't know how to use the debugger, and then he started to tell me, and then disappeared, so I messed around until I got it

    and the problem was actually pretty stupid

    I was returning a value before my object was created. I got used to the construct functions where you can do that

    anyway, as far as the object names and such. yeah. it's all going to be one huge initialize action at the beginning when it's final. it's separated into these actions as I go along, because I want to be able to test all these individual pieces out using triggers and events. so these smaller events are really just for debugging purposes until they work perfectly, and then it will only operate on the internal version

    on a side note though:

    it really is just initializing pointers. I have one main object that's going to contain pointers to everything in an index. all creation and destruction related to each of the plugins in the engine will go through the main object. when you run the initialize action, the dialog tells you what object type to choose for each parameter, this is how it gets pointers to all the object types it will be able to create.

  • I suppose this is more of a c++ question again, and I am looking elsewhere for answers as well.

    is it possible/what would be the best way to pass multiple parameters to the *void param to

    CallFunction(int id, void* param)

    as in CallFunction(SomeInt, *hellothere, 6,"what's up?", "how ya doin?")

    most of the time it will be just one type of variable, but I am curious about multiple types

    for now I am just calling the function several times, and it saves the params one by one

    and then there is a different id value I pass that let's it know when I'm done.

    can I pass a struct or an array, and is there a better way?

  • I'd say a struct would be the best way.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)