Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Feature requests and bug reports
every 5th exec is a bug

guest
Guest
Quote
2022-04-26 19:35:09

my statement:

var myInt = somestring.charCodeAt(0);

does produce a integer BUT
every 5th execution produces a bug:

somestring.charCodeAt() is not a function

WHY?
myInt is calculated every 250ms then tried 500ms then 1000ms
etc. same result every 5th execution is a bug.
somestring did not change either.


sven
Registered User
Quote
2022-04-26 22:13:19

if i use:

Every 250ms execute javascript:
{
var somestring="a";
var c = somestring.charCodeAt(0);
print(c);
}

I dont see error.


VP
Guest
Quote
2022-04-26 22:44:19

@Guest -How are you using the script? - eg: are you using it in the "before first draw" section of the root node?

If so, you will sometimes get random errors when calling every few seconds.


guest
Guest
Quote
2022-04-27 04:02:45

yess, that must be it

i define global variables and global functions in the
"before first drawing" "execJS" field.

then at a 2d overlay that I named "debug"
I do a "do every xxx msec" "execJs" command
and there I call my global variables and functions to
see how they work. Also i have the print("myVar="+myVar) statements scattered around.

then, while testing the error console comes up
by these print statements. and
I can count the myVar=charcode lines pass by
they are all correct but the 5 th turns up the error

somestring.charCodeAt() is not a function


this must be a bug in CC itself
do you know of any options to this problem ?


VP
Guest
Quote
2022-04-27 08:06:31

I do have a work around, but it's not very graceful solution and the same problem eventually came back after I thought it was fixed. I can't code (I have number dyslexia/dyscalcula), so the way I fixed it was to use a separate folder node, then added the "every few seconds" action to that. To make it work as a crude "before first draw", I used "If" action and "set variable" action to switch variable: "start=0" to "start=1" on the very fist cycle of "every few seconds".

The "before first draw" was causing so many different (random) problems for me - objects would not "rotate", collisions suddenly stopped working, variables were not working as expected, fade-screen stopped, music wasn't playing properly, on proximity didn't trigger - it was driving me insane - this was the only workaround I found.

It seems that (for some reason), the "before first draw" will occasionally repeat itself over and over and over - and sometimes will not trigger at all - best to avoid using it at all if possible (attach the code to folder nodes, inside the scene, instead).

I think the bug is triggered when too many similar events happen at the same time - but I wasn't able to fully figure out why it happens - no-one else was experiencing the problem, so they assumed it was just a mistake I'd made somewhere. I was getting major problems if several things are using "every few seconds" action. I had around 6 things that worked perfectly, individually, but would break when I tried to run them together - same fix, I moved everything from "the root of the scene" to a folder node inside the scene and it fixed problems for a while - but then they came back as I added more and more content to the game.

For example... I could get my game running perfectly, but if I kept adding 3D objects (such as 100 coins) and apply the "rotate" action to them, they would eventually all stop rotating. When this happens, any variables I had set in the "before first draw" would also break - and "on proximity" would stop working. If I randomly deleted a few coins (or removed the "rotate" action from a few of them), everything would suddenly start working again. If I move the variables to a folder node instead, the coins would rotate and the variables and"on proximity" would work again.

There are also (possibly) quite a few "bugs" in the default coppercube actions/behaviours/plugins which could be triggering/breaking things too. A few times, people commented that I must have been making mistakes in my code or game loginc - I hadn't actually coded anything, I only ever used the default Coppercube actions/behaviours/plugins.

I really hope it gets addressed soon but I genuinely don't think anyone else encounters the problem. I restarted my projects several times but I eventually gave up because of this.

I really hope you can figure it out with a bit of experimentation. Please let me know if you find a better fix.


sven
Registered User
Quote
2022-04-27 10:55:17

If you can provide example .ccb file then we can take a look at it.. because i cant reproduce it.

I use globals and functions all the time.
Doesnt matter if i declare my variables in main script or in onbeforedraw i still can use them as they should be used.


Arcanjo
Guest
Quote
2022-04-27 21:25:18

Guest Guest, all the things get bug in Coppercube. You have to discover the shortcut without bug and execute your job.


veganpete
Registered User
Quote
2022-04-28 07:36:38

Thanks Sven, here's an example ccb which I had uploaded to itch.io last year. If you want to take a look to see if anything is wrong with it, I'd really appreciate it. It's been made with CC 6.5.1

https://drive.google.com/file/d/...

Thanks.


guest
Guest
Quote
2022-04-28 13:38:42

good gracious js ?


sTile = "H5";
// a string ranging from: A1 to Z99

var Tchar = sTile.match(/([A-Z]{1})/g);
var Tnum = Number(sTile.match(/([0-9]{1,2})/g));
// product of "string.match()" is not a string and not an integer !!!

var west = String.fromCharCode((""+Tchar).charCodeAt(0) - 1);
var east = String.fromCharCode((""+Tchar).charCodeAt(0) + 1);

I seem to have solved the bug
true these statements, wonder if it holds on android

thanks for the help


sven
Registered User
Quote
2022-04-29 13:30:16

wrote:
Thanks Sven, here's an example ccb which I had uploaded to itch.io last year. If you want to take a look to see if anything is wrong with it, I'd really appreciate it. It's been made with CC 6.5.1

https://drive.google.com/file/d/...

Thanks.


Its a huge project to parse.. can you specify what problems you get ?- i played it and it plays fine..(nb i have no audio files so i cant tell about audio)..

There may be conflict with switching and restarting scenes.. reseting variables on reload and do something later action..
I will look into more but it takes time..because first i need to learn logic behind your project :D
(i am more code person so its easier to read code than this visual scripting style-but i do my best)


VP
Guest
Quote
2022-04-29 14:57:33

Thanks Sven! I do appreciate it but please don't let it stress you or take up too much of your time.

This project is actually the working one which I uploaded to itchio - it has no bugs - but is incomplete as I kept running into problems whenever I tried to add more content to it.

I deleted all the non-working ones to prevent me getting confused by them in the future, then took a break for a while to stop me getting too discouraged by it.

I'll probably start a new project again soon - possibly a simple platformer - but I would like to go back and finish Cas-Evac and Nekron at some point - if I can eventually figure out what's brought them both to a breaking-point. Nekron was just meant to be a quick project to give me a break from Cas-Evac, lol.

My logic is probably very unconventional, it's literally a rat's-nest of "If statements" with many "On Proximity" events registered to "Animated Joint Nodes", all governed by variables and a few timers. I think I probably use Coppercube in a way it wasn't really intended - having said that, I don't think I'm doing anything particularly ground-breaking or forcing it to do things it's not capable of - possibly just too many things at once - and a lack of streamlined coding efficiency.

I think the biggest problem I face (and anyone who tries to look at my projects), is that it's hard to see what's going on under-the-,hood because there's no code to see at all - but there are so many (hundreds) of events interacting with each other across different scenes. If there was a way for me to visually represent it (maybe with a flow-chart or memory-map) with all the events, it would help a lot - I tried, but it's really hard for me to translate my coppercube logic into to a flow-chart diagram - especially as I was making so many updates to my project each day - kinda like doing a long day at work and then having to sit down to do all the paperwork afterwards. lol.

Basically, there are some folders with all global combat events, randomised and carried out every few seconds.

The character nodes have all the on proximity events to trigger the various animations and particles whenever a sword hits a shield or person.

The map-screen is just a flag system to set a variable when the level is selected and it also flags whether the level was won or lost, the main scene then switches decorations and billboards to draw a new location depending on which part of the map is clicked. It's the same scene recycled over and over with different graphics, rather than try to program many different locations with the same duplicated mechanics.

Generally speaking, everything runs sequentially (with some parallel events), and most events are triggered either by timers, mouse-click, keypress or on-proximity - and I used If statements to check various variables to determine which player wins each round, depending on which strike was used by each.

The main issue I have with all my projects is that they all run perfectly - but then at some point (when I add a new feature to the game), random things start breaking - things which (to me) seem completely unrelated to the changes I just made. Once that happens, more and more bugs start appearing from no-where, and more things start breaking - to the point that the game no longer works at all and - I can't figure out a way to finish the project.


Arcanjo
Guest
Quote
2022-04-29 20:45:52

I agree with ViP.


just_in_case
Moderator
Quote
2022-04-30 05:54:46

Sometimes, coppercube goes out of memory and execution will stop or the whole game might freeze or crash. This usually happens when you are using inbuilt, time-related actions or behaviors.
these bugs are hard to reproduce hence really hard to fix them.
Try avoiding the usage of inbuilt time events.


veganpete
Registered User
Quote
2022-04-30 21:43:07

Ahhh, yes, that makes sense. Thanks just_in_case I think you're right about the timing issue - all the issues do seem to be related to multiple events running together - as you say, very difficult to explain/reproduce/find/fix. I think this could be the one single issue that eventually breaks everything for me - if so, that's very promising as I can probably find a way to work around it and start the projects again to get everything working.

By "built-in timed events" - do you specifically mean the "Every few seconds" action I commonly use - is there an alternative way I can make all my time-based events with an external clock/timer? If so, I'll definitely have to spend some time to try to learn how to code all the timed events (if that would help?).

If possible, would you be willing to make a timer plugin for me to use (similar to every few seconds) and I'll happily buy it from you if you'd be willing to make it?

Thanks - that's 2 major things you've all helped me with recently.

Nice one!


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