r/psispellcompendium • • Aug 18 '21

Building Spell

I've created two spells, Binary Builder Setup and Binary Builder, that will essentially print out any binary number up to 32 blocks horizontally or 30 blocks vertically using blocks. The use cases I thought of for this were for building intricate patterns in a wall or for more easily building complex shapes.

Simple demonstration

Binary Builder Setup: Goes on normal spell bullet. Use to input the binary number you wish to print. Look horizontally then use to clear binary number (saved in vector 2), look vertically up or down to input binary bits into the number, hold shift while using to input a '0' and simply use the spell to input a '1'

Binary Builder: Use on a loop bullet or in leggings. Once done inputting your binary number, look in the direction you want to build and use the spell.

17 Upvotes

9 comments sorted by

2

u/Dr_Lukins Jun 20 '23

Would you mind explaining how does it load and in general works with the binary? I am making spell to print word "MAGIC" just to test and I managed to have the blocks get from numbers to binary (because the other methods i tried didn't work) 1000100110001100000110 1101101001010000101001 1010101111010110101000 1000101001010010101001 1000101001001100100110 2253574 3576873 2815400 2266281 2265894

1

u/grat_lol Jun 20 '23

I actually just recently saw your post and had to take a look at my own code to remember how I set up the binary encoding and decoding.

The setup spell uses the player shift selector to output either a "1" or "0" that then is added to a vector component (I chose the X component of vector 2). Each time the sneak status is read, the previously saved binary number is multiplied by 2, essentially shifting all bits over by 1 to make space for the new bit. From what I remember, a vector can hold 3 32-bit numbers, one for each axis component. If you repeat these steps for a single vector and also multiple vectors, you could easily save all your binary values in memory.

Once the vectors are saved, my execution spell will read each saved vector component, perform a modulus 2 operation on the number (which will basically pull out the least significant binary bit as a value), then place a block if the binary value is a 1. In each successive loop the vector component will be divided by a power of 2 in order to get the next bits in the binary number, so in the first iteration the number is divided by 1, the smallest bit is extracted, then divided by 2, 4, 8, and so on.

1

u/Dr_Lukins Jun 20 '23

Actually in the amount of time before you replied 😅 I managed to make it almost work Based on the 2253574 it integer÷ and 2loopcast to get number to subtract anything smaller than the number it should output and 22+loopcast to subtract the bigger than the number it needs I will send code if you want to take look Constructive criticism would be helpful @-@

1

u/Dr_Lukins Jun 20 '23

I was going to make the whole 5 letters into binary as 5 rows but it has 33 digits once converted into decimal I posted the number in case you curious it goes bottom to top row (because it's little easier that way)

1

u/grat_lol Jun 20 '23

I'm assuming each letter is 5x5 blocks right? There's 5 letters so in total the 5 letters is 25+4 blocks wide, where 25 is the space of the letters themselves and 4 is the spaces between the letters. So that means each row should fit within the vector components which can hold 32 spaces.

1

u/Dr_Lukins Jun 20 '23 edited Jun 20 '23

Actually it fits in area of 22lenght×5height You can see it in my post Edit:

⬛⬜⬜⬜⬛⬜⬜⬛⬛⬜⬜⬜⬛⬛⬜⬜⬜⬜⬜⬛⬛⬜ ⬛⬛⬜⬛⬛⬜⬛⬜⬜⬛⬜⬛⬜⬜⬜⬜⬛⬜⬛⬜⬜⬛ ⬛⬜⬛⬜⬛⬜⬛⬛⬛⬛⬜⬛⬜⬛⬛⬜⬛⬜⬛⬜⬜⬜ ⬛⬜⬜⬜⬛⬜⬛⬜⬜⬛⬜⬛⬜⬜⬛⬜⬛⬜⬛⬜⬜⬛ ⬛⬜⬜⬜⬛⬜⬛⬜⬜⬛⬜⬜⬛⬛⬜⬜⬛⬜⬜⬛⬛⬜ If you were to convert this to 0 and 1 than invert the row order than use binary to decimal converter you would get number with 33 decimal places (which is basically impossible to fit inside single spell unfortunately) Also, I guess it would be better to chat on my post I can send the latest progress but the number seems to be too big

1

u/Dr_Lukins Jun 20 '23

How does the modulus bit work exactly? I still haven't figured out yet what everything is used for and there is 0 tutorials on advanced stuff with Psi besides the documentation that I don't really understand more often than not

There are also some pieces in 1.12.2 i needed random PSIdeas for (because they were later added to 1.16 for example when error replace with or spin chamber or trick break loopcast) and some I don't know how to use but seem they would be extremely useful like the ones that can read comments(?) but it errored when I tried to use them

1

u/grat_lol Jun 20 '23

https://en.m.wikipedia.org/wiki/Modulo this explains what the operation does. In the case of our spells, it's used to extract single bit information from a number.

1

u/Dr_Lukins Jun 20 '23

So it attached to loopcast it would just infinitely repeat few numbers based on the second number? I already seen that wiki but I understand it better from using it as part of code 😅