Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
how to debug visual-scripting?

veganpete.
Registered User
Quote
2024-05-31 10:32:35

Thanks for this! Sorry for the delay GUEST (I think there's a time-gap)

Yes, I (was using arrays (I think that's the term, but I may be wrong - my understanding of coding methods/terminology is not great) and luckily, the 1st version seemed to work with arrays.

I'll give the new version a whirl today and see if it works with what I've done already.

I'm really not confident with coding, but to give you more context of how I'm working in my recent card game...


1- I'm displaying random enemies, using a default "special js script" action in the "before first draw" behaviour of the root scene-node, as follows:

enemy=[];
enemy[0]="Empty Slot";
enemy[1]="Amazon Warrior";
enemy[2]="Anubis";
enemy[3]="Battle Toad";
enemy[4]="Beholder";
enemy[5]="Beserker";
enemy[6]="Black Dragon";
etc, etc...

2- Then I'm using a "set random variable" action (looped every 100ms) to set variable "enemyID" between value 1 and 160

3- Then I'm using a default "special js script" to match the random value back to the relevant array to get/display the enemy-name, as follows:

var e = ccbGetCopperCubeVariable("enemyID");
var enemy_hud = ccbGetSceneNodeFromName("enemyHUD_name");
ccbSetSceneNodeProperty(enemy_hud, 'Text', enemy[e] );

4- Then, your original "conditional action executor" plugin comes in finally to switch the card-texture to match the card-name, as follows:

Condition 0: enemyID = 1
Action 0: change texture of "card" node to "enemy1.png"
Condition 1: enemyID = 2
Action 1: change texture of "card" node to "enemy2.png"
Condition 2: enemyID = 3
Action 2: change texture of "card" node to "enemy3.png"
Condition 3: enemyID = 4
Action 3: change texture of "card" node to "enemy4.png"


Like I say, probably a weird/long/inefficient way of doing it, but it works - I'm continually updating my logic/methods as I learn more.

Thanks again for the new version, I'll report back with my success in using it.


Guest
Guest
Quote
2024-05-31 19:30:03

Ah, ok. Then you should be able to get the CC variable using $ like:

Condition 0: $enemyID = 1
Action 0: change texture of "card" node to "enemy1.png"
Condition 1: $enemyID = 2
Action 1: change texture of "card" node to "enemy2.png"
Condition 2: $enemyID = 3
Action 2: change texture of "card" node to "enemy3.png"
Condition 3: $enemyID = 4
Action 3: change texture of "card" node to "enemy4.png"

The first version of the action had the first part of the condition string assumed to be a CC variable. It would then get that variable's value and compare it to the value you wanted to check: a = 10, b = hello, etc. This is fine if all you are doing is checking CC variables against strings and numbers, but checking two CC variables against one another was something it couldn't do. The use of sigils is needed because CC's variables default to 0 (very annoying), so I have no means of telling whether or not that 0 is intentional, or if the name of the variable is actually a string. If CC's variables (the "ccbGetCopperCubeVariable()") defaulted to null, I wouldn't need them. Try the above and see if it works for you.


VP
Guest
Quote
2024-06-25 14:14:53

Thanks Guest.

That's what I thought, for me it doesn't seem to work properly.

Here's what I have...
🔎︎

..am I using it correctly, or doing something wrong here? Maybe I'm expecting it to do something it's not supposed to.

After around 6 hours of play-testing/fault-finding today, I managed to narrowed it to the actions in the screenshot; oddly, sometimes it works, 99% of the time it doesn't - but if I set each variable manually (using set variable action), it seems to work fine.

I have 156 conditions and actions (split over 2 of the conditional-variable-executor extensions) and have checked each one letter-by-letter (and paid particular attention to those that work and those that don't work) - I can't see any issues (no typos, no missing spaces, no extra spaces etc).

The conditions are all sequential: eg:
$enemy ID = 1
$enemy ID = 2
$enemy ID = 3
etc...

The actions are also sequential: eg:
set variable "e1" = 1
set variable "e2" = 1
set variable "e3" = 1
etc...

I'm using coppercubes default "set variable" action to set the variables.

At runtime, I expect the e number variables to change and match the random enemyID. Sometimes the variables will match, most times they will not.

When I added a 2d Overlay to output the
e" numbers, it usually says:

enemyID= 1, e1= $e1$
enemyID= 2, e2= $e2$
enemyID= 3, e3= $e3$

but sometimes (randomly, without any changes being made), it will work as follows...

enemyID= 1, e1= 1
enemyID= 2, e2= 1
enemyID= 3, e3= 1

I also tried defining all variables as value "0", on the first draw of the scene but it didn't make any difference.

Any ideas please? Thank you.


vp
Guest
Quote
2024-07-11 09:14:36

Doh, I think, as you pointed out already, it's because I'm trying to call the array, not the variable.I've got it all working now. Thank you!


vp
Guest
Quote
2024-07-11 10:32:03

...and I notice one can edit notes to the top of the window, that's a really handy feature.


Create reply:


Posted by: (you are not logged in)


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