New File: Binary Supervars
Rabid wolves roam the desolate network plains, doing maths and stuffs.
Behold! The Rabid Wolf Number 9 has released a dev file: Binary Supervars. It's a method to store up to 28 true/false values in a single variable. Try to understand how it all works in less than 5 minutes.
Behold! The Rabid Wolf Number 9 has released a dev file: Binary Supervars. It's a method to store up to 28 true/false values in a single variable. Try to understand how it all works in less than 5 minutes.
Isn't this the same concept as SlipDink's Checkbit?
Could be. I didn't know that existed and I made this for funsies. I'll have to look into it.
Funny, I've thought to do similar things before. I believe you could even use the binary values to store multiple (smaller) variables instead of just binary flags, although it becomes more complicated to extract the data again then.
I actually used Someone's functions from FIFO tutorial as a base for the script to seperate the digit into 10 individual places. Then used a bit of logic to seperate each digit into 3 bools (the final being 1)
It's fully capable of storing non-bool values just using the storage and extract functions. You could even make a variable that uses multiple ranges of values and bools. The functions make it relatively easy to read and modify the variables.
The tricky part is proper documentation for keeping track of your subvars because you can easily muck something up.
This might be a more simple minded and less optimized approach than checkbit, but as someone who is not a programmer or good at math I can actually wrap my head around it
It's fully capable of storing non-bool values just using the storage and extract functions. You could even make a variable that uses multiple ranges of values and bools. The functions make it relatively easy to read and modify the variables.
The tricky part is proper documentation for keeping track of your subvars because you can easily muck something up.
This might be a more simple minded and less optimized approach than checkbit, but as someone who is not a programmer or good at math I can actually wrap my head around it
I noticed you'd used three per decimal. I haven't looked into the specifics, but wouldn't it be possible to split things into actual binary? (That is 0 is 00000000, 1 is 00000001, 2 is 00000010, 3 is 00000011, etc...)
Also, I don't know how big variables are allowed to be, but I suspect some versions can use larger variables than others, because the test DMod is crashing when I open the higher-valued chests.
Also, I don't know how big variables are allowed to be, but I suspect some versions can use larger variables than others, because the test DMod is crashing when I open the higher-valued chests.
It shouldn't crash unless there's some sort of oversight in the implementation somewhere. Global vars are 32-bit integers, and have been since the very beginning meaning that it's technically possible to shove up to 32 bools into a global var, rather than 28.
This Cornell page goes into it all, explaining how to store them, and then retrieve using shifting and then the AND operator.
Unfortunately, instead of bitwise operators, reDink and 1.08 received some fairly useless trigonometric functions instead which makes it a slog to implement outside of DinkLua.
This Cornell page goes into it all, explaining how to store them, and then retrieve using shifting and then the AND operator.
Unfortunately, instead of bitwise operators, reDink and 1.08 received some fairly useless trigonometric functions instead which makes it a slog to implement outside of DinkLua.
I don't know why it's crashing. I've tried new installs of both FreeDink and DinkHD and it works flawlessly, but when I tried the browser it crashed immediately on opening a chest. Weird. The variable limit is 2,147,483,647. That's why I've limited the last digit to be one bool. The way I store them is as follows:
1: Bool1=True
3: Bool2=True
4: Bool1,Bool2=True
5: Bool3=True
6: Bool1,Bool3=True
8: Bool2,Bool3=True
9: Bool1,Bool2,Bool3=True
When all the bools are true that makes the final result 1,999,999,999.
My implementation in the demo uses the chests editor number 1-28 as a reference to the bool. The first 3 chests are the the fist 3 bools and change the first digit etc.. So if someone mucks around in the editor that could potentially mess up the demo.
1: Bool1=True
3: Bool2=True
4: Bool1,Bool2=True
5: Bool3=True
6: Bool1,Bool3=True
8: Bool2,Bool3=True
9: Bool1,Bool2,Bool3=True
When all the bools are true that makes the final result 1,999,999,999.
My implementation in the demo uses the chests editor number 1-28 as a reference to the bool. The first 3 chests are the the fist 3 bools and change the first digit etc.. So if someone mucks around in the editor that could potentially mess up the demo.
@megadogv2
Out of curiosity, what version of Dink are you using?
@rabidwolf9
I'm reporting that with YeOldeDink 0.95 on Linux Mint 22.3, I did not manage to crash the test D-Mod.
I attempted to open the chests in a weird order, and even used fast-forward.
I don't know anything about programming, and I hate math, so I can't exactly tell if any number is wrong. Or even what this could be used for.
But it's nice to finally test something that I had no major problems with.
Out of curiosity, what version of Dink are you using?
@rabidwolf9
I'm reporting that with YeOldeDink 0.95 on Linux Mint 22.3, I did not manage to crash the test D-Mod.
I attempted to open the chests in a weird order, and even used fast-forward.
I don't know anything about programming, and I hate math, so I can't exactly tell if any number is wrong. Or even what this could be used for.
But it's nice to finally test something that I had no major problems with.
Thanks for the report RangerLord. I did attempt to deliberately make it crash by adding more treasure, but those additional boxes instead flipped it into a negative number, rather than setting it to 9 million like one might expect.
>what this could be used for.
Save files only allow for 250 variables to be saved within them. Quite often, these are used merely as flags to determine if the user did something or not. By splitting one of those variables up, it allows for one variable to have 28 (in this implementation) or more flags within it, thereby saving the use of the other 249 for more substantial purposes.
>what this could be used for.
Save files only allow for 250 variables to be saved within them. Quite often, these are used merely as flags to determine if the user did something or not. By splitting one of those variables up, it allows for one variable to have 28 (in this implementation) or more flags within it, thereby saving the use of the other 249 for more substantial purposes.
Looks like it's FreeDink 1.08.
Also, does DinkC not have modulo? It's inefficient, but can be used to extract bit-wise stuff in a pinch.
EDIT: For added crash-catching, it's crashing at the first millions place. That is, I can safely store 999999, but nothing higher.
Also, does DinkC not have modulo? It's inefficient, but can be used to extract bit-wise stuff in a pinch.
EDIT: For added crash-catching, it's crashing at the first millions place. That is, I can safely store 999999, but nothing higher.
The supervar functions in the FIFO tutorial were indeed useful, I used them extensively in my Dmod. Although calling the store/extract functions directly with base 2 and specifying the place yields more than 28 bools.
Funny, I've thought to do similar things before. I believe you could even use the binary values to store multiple (smaller) variables instead of just binary flags, although it becomes more complicated to extract the data again then.
Yup. Been there. Created a small proc to store and extract values between x, y bits. Ran like crap though, often leading into other bugs.
Yup. Been there. Created a small proc to store and extract values between x, y bits. Ran like crap though, often leading into other bugs.















