 
                
                49 posts
                
             
            
                Posted 26 October 2014 - 05:01 AM
                [SOLVED]
Hello everyone, my problem is:
after using the "for k, in pairs …"
its returns to me
10
1
15
MEANING i have:  10 Itens on Slot1, 1 Iten on Slot 2, 15 Itens on Slot 3.
Now i need to PLUS these numbers and Print the result! (10+ 1+ 15 = 26)
IMPORTANT PART OF THE CODE:
for k, detalhes in pairs(Details) do
	if detalhes.Name == "Block of Iron" then
	local b = detalhes.Size
	print(B)/>/>
	end
end
Edited on 26 October 2014 - 04:38 AM
                
             
         
        
        
            
            
                
                     
                
                1080 posts
                
                    
                        Location
                        In the Matrix
                    
                
             
            
                Posted 26 October 2014 - 05:09 AM
                What is the table Details?
local c = 0
for k,detalhes in pairs(Details) do
  if detalhes.Name == "Block of Iron" then
    local b = detalhes.Size
    c = c + b --#Adding the number to a number beforehand.
  end
end
print(c)
 
         
        
        
            
            
                
                     
                
                49 posts
                
             
            
                Posted 26 October 2014 - 05:13 AM
                What is the table Details?
local c = 0
for k,detalhes in pairs(Details) do
  if detalhes.Name == "Block of Iron" then
	local b = detalhes.Size
	c = c + b --#Adding the number to a number beforehand.
  end
end
print(c)
It returns how many slots is used in a chest. But i think its not useful here.
Your code, does not work :/
Edited on 26 October 2014 - 04:14 AM
                
             
         
        
        
            
            
                
                     
                
                1080 posts
                
                    
                        Location
                        In the Matrix
                    
                
             
            
                Posted 26 October 2014 - 05:21 AM
                It should as i copied your code exactly. try replacing 
local b = detalhes.Size
--#With
local b = tonumber(detalhe.Size)
 
         
        
        
            
            
                
                     
                
                49 posts
                
             
            
                Posted 26 October 2014 - 05:25 AM
                It should as i copied your code exactly. try replacing 
local b = detalhes.Size
--#With
local b = tonumber(detalhe.Size)
No changes :/
———————————–
Now i Have 1 Item on Slot 1, And 2 Itens on Slots 2 (to be exactly: BLock of Iron)
My Entire Code with Peripheral (working normally)
local targets = prox.getTargets()
for name, basicDetails in pairs(targets) do
local moreDetails = prox.getTargetDetails(name)
  if moreDetails.RawName == "net.chest" then
   local Details = moreDetails.Slots
   print("----")
   for k, detalhes in pairs(Details) do
   --local a = textutils.serialize(Details)
   --print(a)
   if detalhes.Name == "Block of Iron" then
	local b = (detalhes.Size)
	print(B)/>/>
   end
(dont care about the "end" to close the "ifs")
Its Returning in the Screen:
1
2
Edited on 26 October 2014 - 04:26 AM
                
             
         
        
        
            
            
                
                     
                
                7083 posts
                
                    
                        Location
                        Tasmania (AU)
                    
                
             
            
                Posted 26 October 2014 - 05:27 AM
                Best I can make out, Dragon's original code should function correctly.
Your code, does not work :/
That statement is not helpful. What 
does it do? How is that different from what you want it to do?
 
         
        
        
            
            
                
                     
                
                49 posts
                
             
            
                Posted 26 October 2014 - 05:37 AM
                What is the table Details?
local c = 0
for k,detalhes in pairs(Details) do
  if detalhes.Name == "Block of Iron" then
	local b = detalhes.Size
	c = c + b --#Adding the number to a number beforehand.
  end
end
print(c)
ITS WORKS!SORRY , because i dont look at the print ( c )  at the final of the "END" closing the for loop  :P/>
Thank you GUYS!
Edited on 26 October 2014 - 04:38 AM