Is it possible to reference things outside of your plugin?

For developers using the Construct 2 Javascript SDK

Post » Tue Aug 19, 2014 8:08 pm

Don't worry I have NO intention of releasing any sort of plugin unless it conformed with whatever coding standards.

I really really love construct2 for how abstracted the code is, all of the features built in, and the top notch layout/map editor. I very rarely finish games so much as work on concepts, and feel much more comfortable slogging through code than a UI.

My current theory is that custom plugins/behaviors make it very easy to write the bulk of my game's code as custom plugins/behaviors but still retain all of the sweet features of the engine like exporting to different platforms.

I toyed with impactjs for years but it seems he only makes occassional bug fixes, so the community dev environment never hammered out good ways to export or extend. C2 has more features and actually gets updated. C2 is top notch. I wish I was a creative type to take better advantage.
Developing Surolace, the survival role playing space game.

surolace-survival-role-playing-space-game_t116953
B
13
S
4
Posts: 303
Reputation: 1,705

Post » Wed Aug 20, 2014 7:38 pm

I'm not sure if I still have anyone's attention, but related question:

please excuse the psuedo code but I want to accomplish something like
When this.runtime.trigger(someplugin.onCondition) , but I need to somehow daisy chain it to an action, so that when onCondition gets flagged my code knows to implement the Action

In other words I want to fully use ACE via javascript

"on condition" -> trigger(action).

I see the runtime object has an event queue but don't seem to find a way to add a condition check to it.

(I was able to figure out how to use the CR object to invoke actions on other instances/behaviors/plugins, but not how to connect an action to a condition).

"OnTrigger"s only fire once and I have no way to capture them.
Developing Surolace, the survival role playing space game.

surolace-survival-role-playing-space-game_t116953
B
13
S
4
Posts: 303
Reputation: 1,705

Post » Wed Aug 20, 2014 8:07 pm

It sounds like you want to hijack a condition on the event sheet to execute your plugin code as well as the action that was specified in the event sheet? If that's the case then the easiest solution is to just create an ACE action item for your plugin and then in the event sheet add it to the actions you call when a condition is triggered.

Your only other option is to override the ACE condition its self so when the condition is triggered its your code that executes. I have done this myself with regard to the Multiplayer plugin but it was much easier because the plugin used internal functions that triggered its own conditions so instead of overriding the ACE condition i just had to override the internal function and decide to either trigger my condition or the default one.

In your case you might try something like this to override the original.
Code: Select all
cr.plugins_.SOMEPLUGIN.prototype.cnds.CONDITIONAME = function(){
       //Copy all original code that is suppose to execute and then add you own
}


You will how ever need to override it during the instantiation of your plugin and not add it as a direct function because the this needs to be overridden after the original plugin has been interpreted.
B
20
S
7
G
1
Posts: 221
Reputation: 2,077

Post » Wed Aug 20, 2014 8:54 pm

I guess sometimes the simplest solution is the best. It really is the easiest method to just expose an action that can be called from the event sheet. Over riding is a pretty easy solution too depending on which thing you're over riding.

Thanks!

If there is something similar to an "add this condition to watch for then execute this action" function that anyone knows of please let me know!
Developing Surolace, the survival role playing space game.

surolace-survival-role-playing-space-game_t116953
B
13
S
4
Posts: 303
Reputation: 1,705

Post » Thu Aug 21, 2014 2:53 pm

@skelooth

Most of case, I am using an action to trigger a condition, like official function plugin, or ajax does. You could reference ajax plugin first, or see this.
B
108
S
26
G
258
Posts: 4,430
Reputation: 145,179

Post » Thu Nov 24, 2016 6:01 pm

I'm sorry to bump this old thread, but I have a related question to the subject.

I'm doing some tests for a new plugin which outputs some audio, and I would like to access the 'context' variable of the Audio plugin to do it, but I can't find the way to do it.

The info in this post (http://c2plugins.blogspot.com.es/2014/02/reuse-ace.html) is very useful (thanks, @rexrainbow!), but I still don't know how to access these kind of variables, the ones declared as "var context = null". These variables seems private to the anonymous function of each plugin/behavior. Is this correct or can I do what I need?

Thanks a lot!
B
15
S
4
Posts: 28
Reputation: 931

Post » Thu Nov 24, 2016 11:42 pm

@MChiz

Correct,
Code: Select all
var context = null
is local variable which could not been seen outside of scope.
B
108
S
26
G
258
Posts: 4,430
Reputation: 145,179

Post » Tue Nov 29, 2016 10:28 am

Thanks @rexrainbow!
B
15
S
4
Posts: 28
Reputation: 931

Previous

Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests