Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Feature requests and bug reports
[bug?] click action, ccbSetCopperCubeVariable

elmigo
Registered User
Quote
2018-12-10 09:06:02

door has bihavior "when clicked on this do something" with my action OpenDoor
which has two subactions "change rotation of a scnene node" Open(rotate y 90) and Close(rotate y -90) then main action save door status by ccbSetCopperCubeVariable

camera has bihavior "when key is pressed do something" (LMB keypressed down) with action Shoot

probe 1. camera mode LookWhenMouseDown = false, aim at door then click
result 1. windows: door always doing action open and camera shoot
webgl: door open/close and camera shoot

probe 2. camera mode LookWhenMouseDown = true, aim cursor at door then click
result 2. windows: door open always doing action open and camera NOT shoot
webgl: door open/close and camera shoot

bug1: dont stop propagation event when door clicked with LookWhenMouseDown == false or (LookWhenMouseDown == true and webgl platform)
bug2: ccbSetCopperCubeVariable not work for windows

/*
<action jsname="action_OpenDoor" description="Open/Close door">
<property name="isClosed" type="bool" />
<property name="sid" type="string" />
<property name="Open" type="action" />
<property name="Close" type="action" />
</action>
*/


action_OpenDoor = function()
{
};

action_OpenDoor.prototype.execute = function(nod)
{
var cam = ccbGetActiveCamera();
var cam_pos = ccbGetSceneNodeProperty(cam, "Position");
var nod_pos = ccbGetSceneNodeProperty(nod, "Position");
var l = nod_pos.substract(cam_pos).getLength();
if ( l < 30) {
var status = ccbGetCopperCubeVariable(this.sid);
if (status == true) {
ccbSetCopperCubeVariable(this.sid, false);
ccbInvokeAction(this.Open, nod);
} else {
ccbSetCopperCubeVariable(this.sid, true);
ccbInvokeAction(this.Close, nod);
}

print("ops: "+ ccbGetCopperCubeVariable(this.sid));
}
}


test project http://www.elmigo.ru/test/dm3d.z...

my PC - os: win10x64, cpu: intel 7200u, vga: intel hd 620


elmigo
Registered User
Quote
2018-12-15 12:33:59

ccbGetCopperCubeVariable is work, my error


elmigo
Registered User
Quote
2018-12-15 12:57:57

sorry, not my error, this is engine "feature"

at windows


var myVar = ccbGetCopperCubeVariable('myVar');
if (myVar == true) {
ccbSetCopperCubeVariable(this.sid, false);
print('ok');
} else {
ccbSetCopperCubeVariable(this.sid, true);
print('wtf?');
}

console always print "wtf?"

if i using numbers instead bool value then work ok
for platform compatiblity dont use bool values, right code is


var myVar = ccbGetCopperCubeVariable('myVar');
if (myVar == 1) {
ccbSetCopperCubeVariable(this.sid, 0);
print('ok');
} else {
ccbSetCopperCubeVariable(this.sid, 1);
print('wtf?');
}



xanimalkingx
Registered User
Quote
2018-12-16 04:08:15

Yeah, its a feature of the engine. ccbSetCopperCubeVariable can only use numbers for a value. Its what I used in my double jump script. Its annoying but if you have the studio edition of CC6, then you could just fix it yourself. Otherwise... we have to deal with it. Instead, you could make a global function within your extension code that can take a value and set a bool based on the value. The only inconvenience is you have to use "Execute JavaScript" to change the value now, not the set variable function.

// Somewhere in your code should be the variable you want to modify that your extension uses
myFunc = function(newVal) {
myVar = newVal;
}

Then add `Execute JavaScript` with `myFunc(false);`.
This is just a workaround, however.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "I?ternational" (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