Jump to content


Zamithal's Content

There have been 28 items by Zamithal (Search limited from 10-February 22)


By content type

See this member's


Sort by                Order  

#139426 [Open Peripherals] function only works once

Posted by Zamithal on 11 August 2013 - 09:40 AM in Ask a Pro

Oh,I see what you mean, instead of deleting it in my function I could use setHeight, I thought you meant instead of the function all together. OK, well if get rid of the deleting that should fix it, thank you you have been a big help.



#139423 [Open Peripherals] function only works once

Posted by Zamithal on 11 August 2013 - 09:29 AM in Ask a Pro

Im doing it incrementally, so it gets a nice expanding/shrinking affect whenever I want it to change sizes instead of sudden changes. I didn't try setheight though, does it do an effect or is it sudden? Also, pertaining to my question, can I not just return 'object' itself?



#139399 [Open Peripherals] function only works once

Posted by Zamithal on 11 August 2013 - 07:26 AM in Ask a Pro

Title[Open Peripherals] function only works once

function changeBoxHeight(desiredHeightChange, object, speed, direction)
   local boxWidth = object.getWidth();
   local boxHeight = object.getHeight();
   local boxX = object.getX();
   local boxY = object.getY();
   print(object.getHeight());
   for i = 1, desiredHeightChange/5 do
      object.delete();
   if direction == "up" then
      object = net.addBox(boxX, boxY, boxWidth, boxHeight - 5*i, 0xFFFFFF, 0.5);
   end
   if direction == "down" then
      object = net.addBox(boxX, boxY, boxWidth, boxHeight + 5*i, 0xFFFFFF, 0.5);
   end
      sleep(speed);
   end
end

This function works perfectly..once, after it fires once whatever I put in for object will return nil if
variable.getHeight();
is asked of it. Any idea what I did wrong?



#65851 Error: concatenate nil and string.

Posted by Zamithal on 29 December 2012 - 03:37 PM in Ask a Pro

Ok, thank you I got it fixed now, but, just out of curiosity, why is that way better for setting values in a table? It seems less organized IMO.



#65816 Error: concatenate nil and string.

Posted by Zamithal on 29 December 2012 - 01:47 PM in Ask a Pro

I have had some help with this code before but it needs a little more love :D
rednet.open("back")
invalid = "ERROR: Not a valid floor."
f = {}
f[1] = "Automation"
f[2] = "Storage"
f[3] = "Agriculture"
f[4] = "Reactor control"
f[5] = "Matter generation"
f[6] = "Matter generation 2"
f[7] = "Living space"
f[8] = "Library"
f[9] = "Danger room"
f[10] = "Roof"
f[11] = invalid
f[12] = invalid
f[13] = invalid
f[14] = invalid
f[15] = invalid
f[16] = invalid
g = {}
g[1] = "white"
g[2] = "Lightblue"
g[3] = "yellow"
g[4] = "magenta"
g[5] = "purple"
g[6] = "lime"
g[7] = "orange"
g[8] = "red"
g[9] = "pink"
g[10] = "green"
g[11] = "brown"
g[12] = "cyan"
g[13] = "blue"
g[14] = "black"
g[15] = "gray"
g[16] = "lightGray"
while true do
		e, p1, p2 = os.pullEvent()
		if e == "rednet_message" then
	rednet.send(p1, "Floor " .. p2 .. ", " .. f[p2] .. " accepted.")
				if colors[g[p2]] then rs.setBundledOutput("right", colors[g[p2]]) end
  
		elseif e == "redstone" then
				rs.setBundledOutput("right", rs.getBundledInput("left") == 0 and rs.getBundledOutput("right") or rs.getBundledInput("left"))
		end
end

the error is line 44 " rednet.send(p1, "Floor " .. p2 .. ", " .. f[p2] .. " accepted.")" concatenate nil and string



#65017 Running parallel?

Posted by Zamithal on 27 December 2012 - 07:46 PM in Ask a Pro

Ok. thank you, this achieves my desired goal, however i haven't seen ors and ands used outside of conitional statements before, so im not quite sure of what to make of that. :D



#65013 Running parallel?

Posted by Zamithal on 27 December 2012 - 07:22 PM in Ask a Pro

Ok thank you, I was originally trying to use
redstone.setBundledOutput("right", "colors."color)
but that didn't work so i moved to elseifs....

So, replacing the elseif functions i'm still left with parallel:4:Coroutine limit of 50 reached, and Lyqyds code works, but i would like the latest input to stay on, and i don't understand enough of it to change it myself.

What I THINK i have gathered:

e is the event?
p1 is the sender ID?
p2 is the message recieved?
colors[variable] is the proper form of "colors."color correct?

edit: ok coroutine fixed
edit 2: I lied, it isn't fixed by putting the while true's inside the function :(



#65007 Running parallel?

Posted by Zamithal on 27 December 2012 - 07:07 PM in Ask a Pro

I know, i'm rather new at this, Id love to hear your suggestions for improving upon my code. in addition to this, i'm now greeted with a parallel:4:Coroutine limit of 50 reached.



#65004 Running parallel?

Posted by Zamithal on 27 December 2012 - 06:49 PM in Ask a Pro

rednet.open("top")
function getColor()
  if redstone.testBundledInput("left", colors.white) == true then
	color = "white"
  elseif redstone.testBundledInput("left", colors.lightBlue) == true then
	color = "lightBlue"
  elseif redstone.testBundledInput("left", colors.yellow) == true then
	color = "yellow"
  elseif redstone.testBundledInput("left", colors.magenta) == true then
	color = "magenta"
  elseif redstone.testBundledInput("left", colors.purple) == true then
	color = "purple"
  elseif redstone.testBundledInput("left", colors.lime) == true then
	color = "lime"
  elseif redstone.testBundledInput("left", colors.orange) == true then
	color = "orange"
  elseif redstone.testBundledInput("left", colors.red) == true then
	color = "red"
  elseif redstone.testBundledInput("left", colors.pink) == true then
	color = "pink"
  end
end
function getReading()
   local senderId, message, distance = rednet.receive()
   color = message
end

function getTrueColor()
   if color == "white" then
	 trueColor = 1
   elseif color == "lightBlue" then
	 trueColor = 8
   elseif color == "yellow" then
	 trueColor = 16
   elseif color == "magenta" then
	 trueColor = 4
   elseif color == "purple" then
	 trueColor = 1024
   elseif color == "lime" then
	 trueColor = 32
   elseif color == "orange" then
	 trueColor = 2
   elseif color == "red" then
	 trueColor = 16384
   elseif color == "pink" then
	 trueColor = 64
   end
  redstone.setBundledOutput("right", trueColor)
end

while true do
parallel.waitForAny(getColor(), getReading(), getTrueColor)
end

Can someone explain to me what is wrong with this code? it never turns on any output (I have not tried brodcasting it a message yet, just the wire inputs.)



#64914 Does ccSensors actually work on tekkit?

Posted by Zamithal on 27 December 2012 - 02:11 PM in Ask a Pro

os.unloadAPI("/rom/apis/sensorsAPI")
os.unloadAPI("/rom/apis/sensorsData")
os.unloadAPI("/rom/apis/sensorsUI")
os.loadAPI("/rom/apis/sensorsAPI")
os.loadAPI("/rom/apis/sensorsData")
os.loadAPI("/rom/apis/sensorsUI")

function printDict(data)
for i,v in pairs(data) do
  print(tostring(i).." - "..tostring(v))
end
end

ctrl = sensors.getController()
data = sensors.getSensors(ctrl)
printDict(data)
This code should return a list of all connected sensors from the adjacent Sensor Controller...problem is, it just returns 1 sensor named "Sensor" ( I have 6 named sensors)
I tested this in single player, works fine, not on SMP though, so is ccSensors-B017pr2 broken?



#64455 Simple bundled command?

Posted by Zamithal on 26 December 2012 - 12:43 PM in Ask a Pro

That works, thank you, I don't know why the other one doesn't return true though :/



#64451 Simple bundled command?

Posted by Zamithal on 26 December 2012 - 12:37 PM in Ask a Pro

if redstone.getBundledInput ("bottom", colors.red) == true then
  print("YES!")
else
  print("NO!")
end

This always returns no and I cannot figure out why, the red wire is on and I have a jacketed bundled cable running up to the bottom of my turtle...any ideas?

No error is returned, only "NO!"



#64236 Can turtles give a redstone output?

Posted by Zamithal on 25 December 2012 - 08:47 PM in Ask a Pro

Simple question, can turtles send out a redstone signal? Or will I need to set something up with rednet?



#64216 Whats wrong with my function?

Posted by Zamithal on 25 December 2012 - 06:16 PM in Ask a Pro

Wow, that's the second time I've done something silly like that. thank you for the help.



#64204 Whats wrong with my function?

Posted by Zamithal on 25 December 2012 - 05:14 PM in Ask a Pro

Got another function that i cant find the issue with, though posting it here again would be better than starting a new thread:

function farmLine() -- farm 1 collum
    repeat
   loc:forward
    until turtle.detect() == true
repeat
   turtle.select(14)
   if turtle.compareDown() == true then
	 loc:right()
  loc:right()
  loc:forward()
  loc:left()
  loc:left()
  turtle.dig()
  turtle.select(1)
  turtle.place()
   else
	 loc:right()
  loc:right()
  loc:forward()
  loc:left()
  loc:left()
until loc.x == 0
repeat
   loc:left()
until loc.h == 2
end

the loc: comands are from Lyqud's location API and there isn't a problem with those.
Error is: line 7 function arguments expected.



#64194 Whats wrong with my function?

Posted by Zamithal on 25 December 2012 - 04:15 PM in Ask a Pro

thank you, that worked.



#64190 Whats wrong with my function?

Posted by Zamithal on 25 December 2012 - 03:54 PM in Ask a Pro

function fillSlot(slot) -- finish the stack
  until turtle.getItemSpace(slot) == 0 -- repeat until stack is complete
	turtle.select(slot) -- select slot
	turtle.suck() -- try to fill slot
	if turtle.getItemSpace(slot) == 0 then -- if slot was filled
	  turtle.suckDown() -- pick up all non matching items
	  for i = 1, 16 do --empty all items except for kept slots
		if i == 1 or i == 4 or i == 13 or i == 15 or i == 16 then -- kept slots
	   -- Do nothing
	 else
	   turtle.select(i) -- select non-kept slot
	   turtle.drop()	--place in chest
	 end
	  end
	else -- if slot was not filled
	  for i = 1, 16 do  --empty all items into "temporary holding area" except for kept slots
		if i == 1 or i == 4 or i == 13 or i == 15 or i == 16 then -- kept slots
	   -- Do nothing
	 else
	   turtle.select(i) -- select non-kept slots
	   turtle.dropDown() -- drop on floor (under turtle)
	 end
   end
	end
  end
end
fillSlot(1)


The error is Line 2 'end' expected to close function, but i believe I have all the ends



#64184 turtle.transferTo work around

Posted by Zamithal on 25 December 2012 - 02:52 PM in Ask a Pro

Thank you, This is helpful, the 1 square can be arranged.. things can always be solved with a little creativity :D
I am on 1.41 so this should work



#64164 turtle.transferTo work around

Posted by Zamithal on 25 December 2012 - 12:29 PM in Ask a Pro

I'm running a 1.2.5 minecraft because of tekkit... however I need access to this command to continue my project. The Turtle API wiki thing says this is a 1.4.5 command only (newer than my version). Is there any possible way to use this command even though its newer? (or a work around (API?))



#63896 Keeping track of turtle location

Posted by Zamithal on 24 December 2012 - 07:06 PM in Ask a Pro

Ok, it works now :D, but for the sake of learning, why does it work? I never declare the variable "loc", yet I am able to print it.. shouldn't it just return nil?

Oh, nevermind, I just noticed that you mentioned loc:forward() changes the value of loc



#63886 Keeping track of turtle location

Posted by Zamithal on 24 December 2012 - 06:25 PM in Ask a Pro

View PostLyqyd, on 24 December 2012 - 04:41 PM, said:

You may wish to look into my location API. You'll need to save location data to a file, however you do that. With my location API it's easy:

local loc = location.new()
handle = io.open("/.loc", "w")
if handle then
  handle:write(tostring(loc))
  handle:close()
end

local loc
handle = io.open("/.loc", "r")
if handle then
  local x, y, z, h = string.match(handle:read(), "(%-?%d+),(%d+),(%-?%d+),(%d)")
  loc = location.new(tonumber(x), tonumber(y), tonumber(z), tonumber(h))
  handle:close()
end
Can you explain this bit of code a bit further? I could be wrong but the first one opens the data stored, then you do the action, then use the second one to save correct? I'm not really sure I understand the local variable part though.
function readLocation(loc)
  local loc = location.new()
  handle = io.open("/.loc", "r")
  if handle then
	local x, y, z, h = string.match(handle:read(), "(%-?%d+),(%d+),(%-?%d+),(%d)")
	loc = location.new(tonumber(x), tonumber(y), tonumber(z), tonumber(h))
	handle:close()
  end
end
-----------------------------------------------------
function saveLocation(loc)
  handle = io.open("/.loc", "w")
  if handle then
	handle:write(tostring(loc))
	handle:close()
  end
end
readLocation()
loc:back()
saveLocation()
print(loc)
This is my code, it prints properly, however if I look at the .loc file... it tells me the value is nil. However, this code works, but id much rather it be a function
local loc = location.new()
handle = io.open("/.loc", "r")
if handle then
  local x, y, z, h = string.match(handle:read(), "(%-?%d+),(%d+),(%-?%d+),(%d)")
  loc = location.new(tonumber(x), tonumber(y), tonumber(z), tonumber(h))
  handle:close()
end
print (loc)
loc:forward()
handle = io.open("/.loc", "w")
if handle then
  handle:write(tostring(loc))
  handle:close()
end
print (loc)



#63867 Keeping track of turtle location

Posted by Zamithal on 24 December 2012 - 04:04 PM in Ask a Pro

Since there is no call to get ahold of turtles locations, my idea was to store it to a variable for x coods and z coords. ex:
direction = 1
turtleOneXCoord = 0
turtleOneZCoord = 0

while true do

direction = 1
turtleOneXCoord = 0
turtleOneXCoord = 0

while true do
-- some sort of input to go forward 1 square
if direction == 1 then
turtle.forward()
turtleOneXCoord = turtleOneXCoord + 1
elseif direction == 2 then
turtle.forward()
turtleOneZCoord = turtleOneZCoord + 1
elseif direction == 3 then
turtle.forward()
turtleOneXCoord = turtleOneXCoord - 1
elseif direction == 4 then
turtle.forward()
turtleOneZCoord = turtleOneZCoord - 1
end
--some sort of input to turn right
direction = direction + 1
--some sort of input to turn left
direction = direction - 1
end

with this, I can note down coordinates important to the turtle (like a restock chest)

However, the problem with this is if the program is terminated, and the turtle is not at (0,0), (0,0) is then moved and all reference coordinates would be thrown off... so a few questions...

1. Is this the best way to keep track of the turtle?
2. Can i save information without storing it to a file with the vault API?
3. If no, can someone explain how to use the vault API a little bit more thoroughly to me?



#62275 CCSensors D:

Posted by Zamithal on 20 December 2012 - 09:54 PM in Ask a Pro

Copy pasting that into my game, it prints fine, the only thing different in mine is I create the printDict function first, you sure its not printing anything?
function printDict(data)
for i,v in pairs(data) do
  print(tostring(i).." - "..tostring(v))
end
end

ctrl = sensors.getController() -- set the Sensor Controler's data
data = sensors.getSensors(ctrl)
SENSOR = data[1]
data = sensors.getProbes(ctrl,SENSOR)
SENSProbe = data[2]
data = sensors.getAvailableTargetsforProbe(ctrl,SENSOR,SENSProbe)
SENSPos = data[1]
data = sensors.getSensorReadingAsDict(ctrl,SENSOR,SENSPos,SENSProbe)
print(data.TotalItems)
Thats my code that I just tested, prints 0 items for an empty chest.



#61826 CCSensors D:

Posted by Zamithal on 19 December 2012 - 06:13 PM in Ask a Pro

If your using tekkit/technic, there is a EE Sensor Module (I assume its there if you don't use tekkit too) That can get you the current EMC Here is my code for it
----------------------getEMCInformation-----------------------------------
ctrl = sensors.getController() -- set the Sensor Controler's data
data = sensors.getSensors(ctrl) -- Find and access the Sensor Controler, bring up all avaiable sensors.
EMC = data[3] -- The EE Sensor Module is thrid on the list, pick it, make note of it.
data = sensors.getProbes(ctrl,EMC) -- Bring up a list of avalable options (TargetInfo, Collector, Furnace ect.)
EMCProbe = data[2] -- Pick #5 Because we are using a condesor
data = sensors.getAvailableTargetsforProbe(ctrl,EMC,EMCProbe) -- Get available blocks
EMCPos = data[1] -- Select the first condensor seen
data = sensors.getSensorReadingAsDict(ctrl,EMC,EMCPos,EMCProbe) -- GET THE DATA!!
---------------------printEMC--------------------------
print(data.displayEnergy) -- Print the current reading to the screen
Im fairly new at this so this is probably not the correct way to do it, but it works...

As for the checking items thing, do the same process and use a Inventory Sensor Module instead..

PS. Put this at the top of your code
function printDict(data)
for i,v in pairs(data) do
  print(tostring(i).." - "..tostring(v))
end
end
and then use printDict(data) whenever your not sure what data[x] your supposed to pick, its helped me lots!



#61812 [Question] Damage Values?

Posted by Zamithal on 19 December 2012 - 05:52 PM in Ask a Pro

View Postanonimo182, on 19 December 2012 - 04:32 PM, said:

or you can use a for loop
Example:
for i = 1, #nameOfTheTable do
  print(nameOfTheTable[i])
end
I was trying this earlier, but it leaves me with a string, it contains all the info (item name, tile or item, and damage). However, I don't know how to get the numbers out of the string, and even if I did, wouldnt it still be a string? math cant be performed on strings and would need to be converted to an int, correct?