accessing your own object variables from another object

Forum for plugin, effect and behavior programmers. Please use the Help & Support forum for help using Construct.

Post » Tue May 19, 2009 7:13 pm

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
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Tue May 19, 2009 8:02 pm

Yes, using the 'GetData' and 'CallFunction' functions in Runtime.cpp.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Tue May 19, 2009 8:04 pm

If you mean private variables, you can't access other object's private variables right now.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Tue May 19, 2009 8:05 pm

Don't think he's talking about private variables? If so then no, it's not possible.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Tue May 19, 2009 8:20 pm

[quote="Rich":2gyeibyh]Don't think he's talking about private variables? [/quote:2gyeibyh]
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
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Tue May 19, 2009 8:25 pm

Using the two functions I mentioned above allows you to get/set variables from other objects.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Wed May 20, 2009 12:28 am

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

Nice! :D

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
45
S
17
G
37
Posts: 2,853
Reputation: 25,966

Post » Wed May 20, 2009 7:52 am

[quote="SoldjahBoy":2luvbwu9]I see lucid is doing what we discussed as a possibility to his idea :Dl[/quote:2luvbwu9]
yes, thanks sol :D


[quote="Rich":2luvbwu9]Using the two functions I mentioned above allows you to get/set variables from other objects.[/quote:2luvbwu9]
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:
[code:2luvbwu9] 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;
[/quote:2luvbwu9]

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 :mrgreen: , so far this plugin thing is awesome. it's exactly what I needed for my project
thanks again for the suggestion Sol!
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Thu May 21, 2009 2:28 am

nevermind
got it...

The SDK is just as awesome as the rest of construct.
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461


Return to Construct engineering

Who is online

Users browsing this forum: No registered users and 0 guests