Jump to content




How can I make the Chat Box print out variables?


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

#1 austinv11

  • Members
  • 107 posts

Posted 26 June 2013 - 06: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()


#2 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 27 June 2013 - 10:19 AM

Split to new topic.

#3 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 27 June 2013 - 11:36 AM

Try out tostring() to makes out of numbers.
Example:
tostring(8749)

#4 austinv11

  • Members
  • 107 posts

Posted 27 June 2013 - 11:56 AM

View PostFreack100, on 27 June 2013 - 11:36 AM, said:

Try out tostring() to makes out of numbers.
Example:
tostring(8749)
thank you





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users