Jump to content




attempt to call string >.<


  • You cannot reply to this topic
2 replies to this topic

#1 Cozzimoto

  • Members
  • 221 posts
  • LocationDallas, Tx

Posted 19 June 2013 - 09:38 AM

ok i have tried several things in order to get this small program to work. basically this program is connected to other computers with gates on MFSUs and each line is a main and a back up battery, im trying to track the battery and display a certain status up on an advanced monitor. ive tried converting the booleans to strings, and doing a compare that way, ive also tried changing the color around. this is starting to give me a headache and i cannot see what i am doing wrong

the error it is throwing is on line 37 (alot of * to mark the line) and the computer is saying attempt to call string

this is the table the program receives to do the compares
ive hardcoded to convert to string and do compares, but i converted back to booleans to have the program do the compares that way, still having issues
package = {mvOneMain = {isEmpty = true, isFull = true, spaceForEnergy = true},
		   mvOneBack = {isEmpty = true, isFull = true, spaceForEnergy = true}}

this is the program
MODEM = peripheral.wrap("back")
M = peripheral.wrap("top")
MODEM.open(2424)
x,y = M.getSize()
tri = x/3
package = {}

function draw()
  M.clear()

  for i=1,3 do
	M.setCursorPos((tri*i)-9,1)
	  if i == 1 then
		M.write("- MV 1 -")
	  elseif i == 2 then
		M.write("- MV 2 -")
	  else
		M.write("- LV 1 -")
	  end
  
	M.setCursorPos((tri*i)-9,4)
	M.write("Main")
	M.setCursorPos((tri*i)-9,7)
	M.write("Backup")
  end
end

function e(X,Y,COLOR,TEXT)
  M.setCursorPos(X,Y)
  M.setBackgroundColor(COLOR)
  M.write(" "..TEXT.." ")
  M.setBackgroundColor(colors.black)
end

function checkStatus()
  if package.mvOneMain.isEmpty == true then
	e(4,5,colors.red,"Empty") **************************************************************************************
  elseif package.mvOneMain.spaceForEnergy == true then
	e(4,5,colors.orange,"Dischargin")
  elseif package.mvOneMain.isFull == true then
	e(4,5,colors.lime,"Full")
  else
	e(4,5,colors.grey,"NA")
  end
end

while true do  
  e,side,iC,rC,msg,dist = os.pullEvent("modem_message")
  package = textutils.unserialize(msg)
  print(type(package.mvOneMain.isEmpty))
  draw()
  checkStatus()
end


#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 19 June 2013 - 09:44 AM

it is because in your while loop you override the `e` function with the event string. hence it telling you that you're attempting to call a string.

either rename the variable or localise the variable and pass the data around where appropriate.

future reference, any time it states "attempt to call <value>" then check and make sure you're not overriding functions with variables of the type the error states.

#3 Cozzimoto

  • Members
  • 221 posts
  • LocationDallas, Tx

Posted 19 June 2013 - 06:46 PM

oh wow i see it now, im dumb, talk about no seeing anything when i named a variable and a function the same name. thanks man. its working now





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users