This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
austinv11's profile picture

How can I make the Chat Box print out variables?

Started by austinv11, 26 June 2013 - 05:48 PM
austinv11 #1
Posted 26 June 2013 - 07:48 PM
Title: [MiscPeripherals] How can I make the Chat Box print out variables?

I was writing a program for a minigame map I'm making, but I can't get the chat box to say a variable (in this case for points), instead of saying the variable, it says "string expected" on that line of code at around line 100


function rec()
  id, msg=rednet.receive(60)
  end
p = peripheral.wrap("left")
local coal="n"
local wind="n"
local weapons="n"
local solar="s"
local lava="s"
local bombs="s"
local north=0
local south=0
function score()
  p.say("Northern Forttress is in control of:",2048)
  if coal=="n" then
	sleep(1)
	p.say("Coal Powerplant",2048)
	north=north+1
	end

  if wind=="n" then
	sleep(1)
	p.say("Wind Powerplant",2048)
	north=north+1
	end
  
  if weapons=="n" then
	sleep(1)
	p.say("Weapon Factory",2048)
	north=north+1
	end

  if solar=="n" then
	sleep(1)
	p.say("Solar Powerplant",2048)
	north=north+1
	end

  if lava=="n" then
	sleep(1)
	p.say("Lava Powerplant",2048)
	north=north+1
	end

  if bombs=="n" then
	sleep(1)
	p.say("Bomb Factory",2048)
	north=north+1
	end
  
  sleep(5)
  p.say("Southern Fortress is in control of:",2048)

  if coal=="s" then
	sleep(1)
	p.say("Coal Powerplant",2048)
	south=south+1
	end
  
  if wind=="s" then
	sleep(1)
	p.say("Wind Powerplant",2048)
	south=south+1
	end
  
  if weapons=="s" then
	sleep(1)
	p.say("Weapon Factory",2048)
	south=south+1
	end
  
  if solar=="s" then
	sleep(1)
	p.say("Solar Powerplant",2048)
	south=south+1
	end
  
  if lava=="s" then
	sleep(1)
	p.say("Lava Powerplant",2048)
	south=south+1
	end
  
  if bombs=="s" then
	sleep(1)
	p.say("Bomb Factory",2048)
	south=south+1
	end

  sleep(5)
  p.say("Northern Fortress has:",2048)
  sleep(0.5)
  p.say(north,2048)

  sleep(5)
  p.say("Southern Fortress has:",2048)
  sleep(0.5)
  p.say(south,2048)
  check()
  end

function check()
  rec()
  if msg=="lava(n)" then
	lava="n"
	rec()
  
  elseif msg=="lava(s)" then
	lava="s"
	rec()
  
  elseif msg=="wind(n)" then
	wind="n"
	rec()
  
  elseif msg=="wind(s)" then
	wind="s"
	rec()

  elseif msg=="weapons(n)" then
	weapons="n"
	rec()
  
  elseif msg=="weapons(s)" then
	weapons="s"
	rec()
  
  elseif msg=="bombs(n)" then
	bombs="n"
	rec()
  
  elseif msg=="bombs(s)" then
	bombs="s"
	rec()
  
  elseif msg=="coal(n)" then
	coal="n"
	rec()
  
  elseif msg=="coal(s)" then
	coal="s"
	rec()
  
  elseif msg=="solar(n)" then
	solar="n"
	rec()
  
  elseif msg=="solar(s)" then
	solar="s"
	rec()
  
  else
	score()
	end
  end

check()
Cranium #2
Posted 27 June 2013 - 11:19 AM
Split to new topic.
H4X0RZ #3
Posted 27 June 2013 - 12:36 PM
Try out tostring() to makes out of numbers.
Example:
tostring(8749)
austinv11 #4
Posted 27 June 2013 - 12:56 PM
Try out tostring() to makes out of numbers.
Example:
tostring(8749)
thank you