Posted 31 May 2014 - 12:04 AM
So this is my first post on this forum, so we will see how it goes.
Hi all,
-Project Background (Thaumcraft)-
So recently I have been playing around with Thaumcraft's (and Thaumic Tinkerer's) interactions with ComputerCraft, and am now attempting to make an Infusion Altar with automatic refilling of an array(51) of surrounding aspect jars through the use of mana beans. Instead of using logistics pipes and requesting mana beans through them, I have decided, for the sake of difficulty, to use TT's Aspectualizer. The Aspectualizer will read what aspects are on an inputted item and how many of that aspect there are. A brief, simple overview of the process: I have a gold chest (Iron Chests) filled with mana beans in its first 51 slots. Each slot contains a full stack of one type of mana bean, and the chest itself only has 1 stack of each type of bean (hence 51 stacks), while the other slots are blocked/filled with cobblestone. A turtle next to the chest will scan each stack of the chest in an Aspectualizer and create a table that displays which aspect is in which slot. The main computer will then know which stack to pull from, when needed, by using said table. The chest refills itself through the use of an ME export bus attached to an ME system, which, hypothetically, would be gathering mana beans from a farm.This project involves designing a program to not only read the jars and to know when to refill them, but also to display the amount of aspects I have of each kind in the surrounding jars on a monitor nearby. This will include having the amount of each aspect color-coded by how full the jar is. And yes, I am aware that a man by the name of Direwolf20 has done something similar (I use the DW20 pack).
-Current Issue/Question-
At the moment, progress is going great, and I seem to be able to get done what I want with a bit of fiddling with the code. The issue I ran into today involves the displaying of the aspects on a monitor portion. Let me first explain how exactly I am going about reading the jars, in the situation that someone may be unfamiliar with it. I am connecting the jars to my computer through wired modems and networking cable, although the modems themselves won't attach directly onto the jars themselves, as they are not full blocks. Instead, I attach a Peripheral Proxy(OpenPeripheralAddons) to the jar and then a modem to the proxy. Through this process, I am now able to connect the jars as peripherals and read them using peripheral.getAspects(). This function, from TT, returns: {[1.0]={name=aspect, quantity=amount}}, a table with one entry. We can extract that inner table using peripheral.getAspects()[1.0], which returns: {name=Aspect, quantity=amount}. From here we can directly extract the name (peripheral.getAspects()[1.0]["name"]) and quantity (peripheral.getAspects()[1.0]["quantity"] fairly easily. So, using that info, I can write the data onto my monitor and do, well, whatever I want with it from there. However, I ran into a problem, which I couldn't find an easy answer to, although I may just be blind. The problem I referred to earlier was that the output for the quantity of aspect in each jar displayed a whole number with a tenth's place (i.e. 30.0). Since I didn't want this on my monitor, I attempted to somehow remove the decimal part of the number, and was eventually able to, kinda.
tl;dr When I extract the 'quantity' from the aspect jars, it displays with a tenth's place (i.e. 30.0), which I want to remove for displaying (i.e. 30).
The way I got rid of the tenth's place was an accidental discovery through my random testing of different methods. I used string.format(quantity), which, surprisingly, gave me what I wanted. I am led to believe, however, that somehow that function turned the number into a string while also eliminating the decimal.
So (finally), my question to you all is first: How does string.format() work in general, and then in specific how I managed to use it. Second: Instead of using this to delete the decimal, what would you all use? I would rather do it a different way as if I want to compare the quantity to other numbers, I am unable to do so directly.
(In case you were curious, here is the test program in which I stumbled upon this)
http://pastebin.com/PxUnyf4A
[Edit] Added to background info, as some might find it useful.
Thanks for the help,
Whitecatblack
Hi all,
-Project Background (Thaumcraft)-
So recently I have been playing around with Thaumcraft's (and Thaumic Tinkerer's) interactions with ComputerCraft, and am now attempting to make an Infusion Altar with automatic refilling of an array(51) of surrounding aspect jars through the use of mana beans. Instead of using logistics pipes and requesting mana beans through them, I have decided, for the sake of difficulty, to use TT's Aspectualizer. The Aspectualizer will read what aspects are on an inputted item and how many of that aspect there are. A brief, simple overview of the process: I have a gold chest (Iron Chests) filled with mana beans in its first 51 slots. Each slot contains a full stack of one type of mana bean, and the chest itself only has 1 stack of each type of bean (hence 51 stacks), while the other slots are blocked/filled with cobblestone. A turtle next to the chest will scan each stack of the chest in an Aspectualizer and create a table that displays which aspect is in which slot. The main computer will then know which stack to pull from, when needed, by using said table. The chest refills itself through the use of an ME export bus attached to an ME system, which, hypothetically, would be gathering mana beans from a farm.This project involves designing a program to not only read the jars and to know when to refill them, but also to display the amount of aspects I have of each kind in the surrounding jars on a monitor nearby. This will include having the amount of each aspect color-coded by how full the jar is. And yes, I am aware that a man by the name of Direwolf20 has done something similar (I use the DW20 pack).
-Current Issue/Question-
At the moment, progress is going great, and I seem to be able to get done what I want with a bit of fiddling with the code. The issue I ran into today involves the displaying of the aspects on a monitor portion. Let me first explain how exactly I am going about reading the jars, in the situation that someone may be unfamiliar with it. I am connecting the jars to my computer through wired modems and networking cable, although the modems themselves won't attach directly onto the jars themselves, as they are not full blocks. Instead, I attach a Peripheral Proxy(OpenPeripheralAddons) to the jar and then a modem to the proxy. Through this process, I am now able to connect the jars as peripherals and read them using peripheral.getAspects(). This function, from TT, returns: {[1.0]={name=aspect, quantity=amount}}, a table with one entry. We can extract that inner table using peripheral.getAspects()[1.0], which returns: {name=Aspect, quantity=amount}. From here we can directly extract the name (peripheral.getAspects()[1.0]["name"]) and quantity (peripheral.getAspects()[1.0]["quantity"] fairly easily. So, using that info, I can write the data onto my monitor and do, well, whatever I want with it from there. However, I ran into a problem, which I couldn't find an easy answer to, although I may just be blind. The problem I referred to earlier was that the output for the quantity of aspect in each jar displayed a whole number with a tenth's place (i.e. 30.0). Since I didn't want this on my monitor, I attempted to somehow remove the decimal part of the number, and was eventually able to, kinda.
tl;dr When I extract the 'quantity' from the aspect jars, it displays with a tenth's place (i.e. 30.0), which I want to remove for displaying (i.e. 30).
The way I got rid of the tenth's place was an accidental discovery through my random testing of different methods. I used string.format(quantity), which, surprisingly, gave me what I wanted. I am led to believe, however, that somehow that function turned the number into a string while also eliminating the decimal.
So (finally), my question to you all is first: How does string.format() work in general, and then in specific how I managed to use it. Second: Instead of using this to delete the decimal, what would you all use? I would rather do it a different way as if I want to compare the quantity to other numbers, I am unable to do so directly.
(In case you were curious, here is the test program in which I stumbled upon this)
http://pastebin.com/PxUnyf4A
[Edit] Added to background info, as some might find it useful.
Thanks for the help,
Whitecatblack
Edited on 02 June 2014 - 07:20 PM