Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
JavaScript question

3dnoob
Registered User
Quote
2018-08-13 17:43:43

Can I create cubes or other forms directly via javascript?

Example:


function myFunction() {
var iMax = 400;
var jMax = 400;
var Level = new Array();

for (i=0;i<iMax;i++) {
Level[i]=new Array();
for (j=0;j<jMax;j++) {
Level[i][j]=0;
}
}

var level1 = "111111111111111111111110000000010000000011113110111010111011311110000000000000000011110110101111101011011110000100010001000011111110111212111011111222210122222221012222111110121121121011111000000221222122000000111110121111121011111222210122222221012222111110121111121011111110000000010000000011110110111010111011011113010000000000010311111010101111101010111110000100010001000011110111111010111111011110000000000000000011111111111111111111111";
var x = 0; var y = 0; var a = 0; var b = 0; var t = 0;
var ret = level1.split("");

for ( t = 1; t <= 442; t++ )
{
if ( ret[t-1] == "1" )
{
//CreateCube !!!
Level[a][b] = 1;

}
else if ( ret[t-1] == "0" )
{
//...
Level[a][b] = 0;
}
if ( a == 20 ) {
a = 0;
b = b + 1;
x = 0;
y = y + 32;
} else {
a = a + 1;
x = x + 32;
}
}
}


Without having to place ' thousands ' of cubes manually in the editor.

???

Thanks in advance.


3dnoob
Registered User
Quote
2018-08-13 18:15:27

I did a test once and it looks good.

Does anyone now have tips on path discovery and grid movement?

https://workupload.com/file/UuRF...

Test2:
https://workupload.com/file/rKfG...


3dnoob
Registered User
Quote
2018-08-13 20:00:13

How does my script work with WebGL or Android?

Currently it works only with Windows application.

How can I fix this?


3dnoob
Registered User
Quote
2018-08-13 20:09:06

Ok!

I fixed it.
I have now added the script as a start action (before the first drawing) as a behavior of the scene and enabled "AlsoOnReload".

Now it's working.


3dnoob
Registered User
Quote
2018-08-14 11:22:23

How can I access variables from another object within a JavaScript?

Example:
Variables in the Scene object (start):
Move_Up, Move_Down,...

Now I have e.g. a script in the player where I have the following query:

if (Move_Up == 1)
{
print("Move_Up");
}

The variable "Move_Up " exists in another script. How can I access this variable globally now?

(the variable is otherwise unknown.)

Thanks in advance.


3dnoob
Registered User
Quote
2018-08-14 12:00:00

Ok!
I just didn't use this command.

Example:
Ccbgetcoppercubevariable ( "Move_Up") = = 1

I like this 3d program more and more. (Since I covered it 2 days ago.)


Create reply:


Posted by: (you are not logged in)


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