accessing your own object variables from another object

This forum is currently in read-only mode.
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I've gotten it to work so I can change the angle of a sprite from within an action

    is it possible to get variables you create for an object from an object taken as a parameter

    for instance:

    MyPlugin has a variable I'd like to be accessible like Angle is on sprites, call it MyValue

    MyPlugin2 has an action where you can choose a MyPlugin Object as a parameter

    and it will retrieve and change MyValue

    is that possible?,

    and how?

    because object->info seems to be only for retrieving values declared in the RunObjectHeaderInfo struct

  • Yes, using the 'GetData' and 'CallFunction' functions in Runtime.cpp.

  • If you mean private variables, you can't access other object's private variables right now.

  • Don't think he's talking about private variables? If so then no, it's not possible.

  • Don't think he's talking about private variables?

    right, not private variables, just ordinary c++ variable declared in the plugin's source. even if i have to do some extra steps to make it useable, itd be really useful

  • Using the two functions I mentioned above allows you to get/set variables from other objects.

  • I see lucid is doing what we discussed as a possibility to his idea

    Nice!

    ~Sol

  • I see lucid is doing what we discussed as a possibility to his idea l

    yes, thanks sol

    Using the two functions I mentioned above allows you to get/set variables from other objects.

    thanks rich. I have few questions, though, if anyone has a few moments

    from rts(just because the code's already there, I don't plan to use rts:

      795 // User defined functions
      796 long ExtObject::GetData(int id, void* param)
      797 {
      798 	switch (id) {
      799 	// If your extension uses a window, you can return it here
      800 	case 1337:
      801 		return (long)(pfLayoutMaps[pLayout].pfMap[params.cellsize]);
      802 	case 1338:
      803 		return (long)&waypoints;
      804 	case 1339:
      805 		return pfcellW;
      806 	case 1340:
      807 		return pfcellH;
      808 	}
      809 
      810 	return 0;
      811 }
      812 [/code:2luvbwu9]
    
    ok, so to use this, first I would get a pointer to the object the same way I did before:
    
    [code:2luvbwu9]CRunObject* Object = params[0].GetObjectParamFirstInstance(pRuntime);[/code:2luvbwu9]
    
    then could I just:
    
     [code:2luvbwu9]Object->GetData(1337)[/code:2luvbwu9]   ?
    is that correct?  What is the second void parameter for? 
    
    also, in:
    [quote:2luvbwu9]  813 long ExtObject::CallFunction(int id, void* param)
      814 {
      815 	switch (id) {
      816 
      817 		// Write speed to param
      818 	case CF_GETSPEED:
      819 		*(float*)param = speed;
      820 		break;
      821 	}
      822 
      823 	return 0;
    
    is CF_GETSPEED just an int const?
    and if so, for the sake of form, and keeping all the plugin code uniform, is there a specific file I should define these constants in?
    
    also, I got GetObjectParam from the ACE Table Wiki, and I got GetObjectParamFirstInstance from the RTS behavior, is there a list somewhere of all the possibilities that can be used?, and does GetObjectParamFirstInstance return the first picked instance? or just the first instance period?
    
    as an aside, I'm so damn excited  , so far this plugin thing is awesome.  it's exactly what I needed for my project
    thanks again for the suggestion Sol!
  • Try Construct 3

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

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

    got it...

    The SDK is just as awesome as the rest of construct.

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