Hello Cemetech Users. I was wondering what you can do with an appvar in ICE, which things you can store in one and how many. For example, in Geometry Dash a whole level was stored in an appvar. Until now I have only stored lists in an appvar, but I would be interested in what you can use an appvar for.
Anything you want. Appvars can be up to 64KiB in size each.
Wait, wait, wait. Does this mean that you can even store whole programs in an appvar? 😕
It's literally like any other file. Keep whatever raw data you want in there in whatever format you want, even in your own formats.
Wow, okay. Can I also store a list and a string in the same appvar?
Sure. You can store any arbitrary data in whatever format you want.
Like I said, any binary data. There is no distinction between lists and strings with appvars, it just depends on how you read and write.
MateoConLechuga wrote:
Sure. You can store any arbitrary data in whatever format you want.
And how would I do that. Sorry for all the asking, I just think it's cool. I now have a lot of ideas about games that I might still be able to program.
The big problem is that I'm German and I don't understand most of the documentation and don't find what I'm looking for. For example, I don't understand what Offset and Origin are for sum(10,OFFSET,ORIGIN,SLOT) and unfortunately this is not explained in the documentation.
The File I/O API in ICE is very similar to that in C.
Link Here to fseek (C) documentation
In general, the term “origin” in this context typically means a starting position, while “offset” is a distance forward or backward from that starting position at which to perform an operation.
I have one more question. How can I store a list and a string in the same appvar and how can I retrieve them? If that's even possible? Because I imagine Appvars to be like a normal variable, it can only store one thing. In my case I want to store a list and a string in the appvar LEVEL. Is that possible?
Yan-Nick wrote:
I have one more question. How can I store a list and a string in the same appvar and how can I retrieve them? If that's even possible? Because I imagine Appvars to be like a normal variable, it can only store one thing. In my case I want to store a list and a string in the appvar LEVEL. Is that possible?
Yes, an Appvar is literally a sequence of bytes and can represent anything smaller than 65516 bytes.
beckadamtheinventor wrote:
Yan-Nick wrote:
I have one more question. How can I store a list and a string in the same appvar and how can I retrieve them? If that's even possible? Because I imagine Appvars to be like a normal variable, it can only store one thing. In my case I want to store a list and a string in the appvar LEVEL. Is that possible?
Yes, an Appvar is literally a sequence of bytes and can represent anything smaller than 65516 bytes.
How would I have to do that?
Yan-Nick wrote:
beckadamtheinventor wrote:
Yan-Nick wrote:
I have one more question. How can I store a list and a string in the same appvar and how can I retrieve them? If that's even possible? Because I imagine Appvars to be like a normal variable, it can only store one thing. In my case I want to store a list and a string in the appvar LEVEL. Is that possible?
Yes, an Appvar is literally a sequence of bytes and can represent anything smaller than 65516 bytes.
How would I have to do that?
It's like a file on a PC.
ICE code to overwrite to the appvar "File" with "Hello World!", including the (automatic) 0 at the end of the string.
Code:
sum(1,"File","w"->D
sum(4,"Hello World!",13,1,D
sum(3,D
Ok, but if I then store a list in the appvar, isn't the string "Hello World!" gone?
Yan-Nick wrote:
Ok, but if I then store a list in the appvar, isn't the string "Hello World!" gone?
If you want to append (add to the end)
Code:
sum(2,'L₁',"r",2→D
sum(18,D→PTR
sum(16,D→LEN
sum(3,D
sum(1,"File","a+"→D
sum(4,PTR,LEN,1,D
sum(3,D
Just like any file on a PC.
NOTE: there has to be single quotes around the token L₁, otherwise it will not work correctly.
Ah, now I know what a+ is. Thanks for your help, if there are any more problems, I'll call you back. 😁