Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
Fail variables

Thomas
Guest
Quote
2022-06-03 09:21:41

hi I have a very absurd problem. the variables stopped working, I used the java functions to load and save values in .dat file but when they load the value and in turn they have to do an action (like for example value 1 = make the sphere visible) I don't does! moreover, it loads the value without making the object visible !. the scene weighs like 1.7GB memory but the game is super smooth I don't think that's the problem. can you give me some advice. a thousand thanks


sven
Registered User
Quote
2022-06-03 17:00:15

Thomas wrote:
hi I have a very absurd problem. the variables stopped working, I used the java functions to load and save values in .dat file but when they load the value and in turn they have to do an action (like for example value 1 = make the sphere visible) I don't does! moreover, it loads the value without making the object visible !. the scene weighs like 1.7GB memory but the game is super smooth I don't think that's the problem. can you give me some advice. a thousand thanks


Always make backups so you can go back to last working version.(then you can trace error and you know exactly what problems there can be)

instead of 1 or 0 you may need to use true or false when making visible or invisible. (depends of course how your loader works)


Thomas
Guest
Quote
2022-06-03 17:40:04

I also tried with version 6.5 instead of cc 6.5.1. but nothing the script does not work it does not load the values and if it does the values and as if they were not there.


sven
Registered User
Quote
2022-06-03 20:22:44

First make sure your script works 100%
[even simple typo can mess up whole game-sometimes doesnt even show error message]

then create new project (small project) then test script there.

Also make sure your dat file is saved as it should be and script reads that file as it should be readed.

Cant help you more with this problem because i have no idea how you load how you save and how you use that data.


Thomas
Guest
Quote
2022-06-04 07:54:16

I use this to upload

var varContent = 0;
var readline;
var varContent = ccbReadFileContent('value.dat');
readline = varContent.substring(16,varContent.length-1)
ccbSetCopperCubeVariable('IntegerValue',readline);


and this to save
and de all in the same folder

var varContent = ccbGetCopperCubeVariable('IntegerValue');
var iniFileContent = 'Integer Value = ';
iniFileContent += varContent;
iniFileContent += '\n';
ccbWriteFileContent('value.dat', iniFileContent);


I also made an empty project to test them by pressing a button to activate the loading and one to save it but nothing! I also downloaded the example on the forum and that works .. I tried to do it the same in every single thing and it doesn't work .. absurd!


nigec
Registered User
Quote
2022-06-04 08:32:53

Have you a link to the forum example?


Thomas
Guest
Quote
2022-06-04 08:48:34

no I have no examples. also because if I give an example and it works for you and for me it doesn't change? it's not that there is a script limit that cc can support or even actions I don't know .. I'm thinking about them all ..


nigec
Guest
Quote
2022-06-04 10:14:34

you said you download an example from the forum, I wanted to compare because all people can do is guess

I had issues reading arrays from file because I ended up with blank spaces

I was just reading from file, don't you need to close a file after writing to it?

Does it load restarting the exe?


Thomas
Guest
Quote
2022-06-04 11:30:29

I found it doing a search on the name "save"


Thomas
Guest
Quote
2022-06-04 12:13:22

now it works .. and I don't know why! and calculate badly too! the value inside the .dat file is 10 and I only see 1 .. absurd! does it just happen to me?


sven
Registered User
Quote
2022-06-04 15:14:12

If i use your script to read:

var varContent = 0;
var readline;
var varContent = ccbReadFileContent('value.dat');
readline = varContent.substring(16,varContent.length-1)
ccbSetCopperCubeVariable('IntegerValue',readline);

print(readline);
print(ccbGetCopperCubeVariable('IntegerValue') );

And dat file with input:
Integer Value = 1447

Then it prints 1447 and sets CC variable to 1447
(i am using windows publish settings so it may be different with webGL version -as i know there is difference with them sometimes.)


just_in_case
Moderator
Quote
2022-06-04 16:30:40

Thomas wrote:
now it works .. and I don't know why! and calculate badly too! the value inside the .dat file is 10 and I only see 1 .. absurd! does it just happen to me?


this is because you are having -1 from the length of your string.
in the line
  readline = varContent.substring(16,varContent.length-1)


so if you use '10' then it will print '1' only if you replace the above line of your code with this line
readline = varContent.substring(16,varContent.length)
then it will print the correct value for you.
it will print '10' for you.

I don't know why it is printing `1447` for @sven as it should print `144` if he is subtracting the length by 1.

I am on an AMD chipset that can be the reason maybe but I am not sure if this has to do with the chipset.


sven
Registered User
Quote
2022-06-04 19:38:56

There is a /n at the end of my line in dat file thats why i can 1447

as he saves it so:
var varContent = ccbGetCopperCubeVariable('IntegerValue');
var iniFileContent = 'Integer Value = ';
iniFileContent += varContent;
iniFileContent += '\n';
ccbWriteFileContent('value.dat', iniFileContent);



code:
var varContent = 0;
var readline;
var varContent = ccbReadFileContent('value.dat');
readline = varContent.substring(16,varContent.length-1)
ccbSetCopperCubeVariable('IntegerValue',readline);
print("----------");
print("----------");
print("----------");
print(readline);
print(ccbGetCopperCubeVariable('IntegerValue') );


var varContent = 1447;
var iniFileContent = 'Integer Value = ';
iniFileContent += varContent;
iniFileContent += '\n';
ccbWriteFileContent('value.dat', iniFileContent);



Create reply:


Posted by: (you are not logged in)


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