Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
Action Not Invoking

ishmaru
Registered User
Quote
2018-02-16 13:02:45

I Am have this script that simply have an if/else check to perform a specified action. However this issue where in this script the actions specified never seem to happen, HOWEVER the print() does print to the console so I know that the line should have executed. Any Ideas what may be wrong?


/*
<action jsname="action_ActionSwap" description="DoAction on Variable Change">
<property name="VarToCheck" type="string" default="VariableName" />
<property name="ActionA" type="action" />
<property name="ActionB" type="action" />
<property name="ActionC" type="action" />
<property name="ActionD" type="action" />
</action>
*/



action_ActionSwap = function()
{
};

// called when the action is executed
action_ActionSwap.prototype.execute = function(currentNode)
{
var num = ccbGetCopperCubeVariable(this.VarToCheck);
var divisible = function(min, max){
var n = 0;
for(i = min; i <= max; i++){
if(n == 3){
n = 0;
}else{
n++;
}
if(i == max){
if(n == 1){
ccbInvokeAction(this.ActionA);
print(i+" - 1");
}else if(n == 2){
ccbInvokeAction(this.ActionB);
print(i+" - 2");
}else if(n == 3){
ccbInvokeAction(this.ActionC);
print(i+" - 3");
}else{
ccbInvokeAction(this.ActionD);
print(i + ' - 0')
}
}
}
};
divisible(1,num);
}



just_in_case
Moderator
Quote
2018-02-16 14:00:51

Variable name should be in inverted comma's

For example ccbgetcoppercubevariable('variablename')

That can be a reason the action isn't executing...


Ishmaru
Guest
Quote
2018-02-16 18:19:45

Thanks for messaging back, but that isn't the issue since print methods after the ccbInvokeActions print just fine.


niko
Moderator
Quote
2018-02-17 05:53:37

Try instead
ccbInvokeAction(this.ActionA, currentNode);

maybe that's it already. Otherwise: Do you get any error message?


Ishmaru
Guest
Quote
2018-02-17 18:45:28

I tried to pass the currentNode parameter and it's still no result. There is no error message either.


just_in_case
Moderator
Quote
2018-02-28 12:16:50

Will try the code on my machine today and then I will reply the solution if I got one..


ishmaru
Registered User
Quote
2018-03-01 04:35:24

Actually I figured out why this was giving me issues, it relates to the headache of the "this" object

within the action_ActionSwap.prototype.execute function there is another function I made called divisible

well within that function i tried to reference the actions specified by the user with "this.ActionA" however within the divisible function this is referencing something different there for this.ActionA does not exist and nothing happens.

To fix i just refactored action_ActionSwap.prototype.execute to not use the divisible function. But i could have passed this to it or save the reference to another variable accessible to that function. (Ex var me = this).


just_in_case
Moderator
Quote
2018-03-01 06:18:18

Great then!


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Intern?tional" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact