Jump to content




Need a real pro - Tables Error


14 replies to this topic

#1 LuaEclipser

  • Banned
  • 220 posts
  • LocationCleveland, Ohio

Posted 20 February 2013 - 03:48 PM

Well I Had This Code and when i try to print the Merchant it gives me Table:RANDOM #s

npc = {
" -------- ",
"|		   |",
"|		   |",
" --------",
"Merchant"
}
function printM()
	 print(npc)
end
printM()

i no this is nooby but i need help! (you will be in credits of my game :)

#2 LuaEclipser

  • Banned
  • 220 posts
  • LocationCleveland, Ohio

Posted 20 February 2013 - 03:57 PM


Thanks All1!

#3 BigSHinyToys

  • Members
  • 1,001 posts

Posted 20 February 2013 - 04:02 PM

npc = {
" -------- ",
"|				 |",
"|				 |",
" --------",
"Merchant"
}
function printM()
for i,v in pairs(npc) do
		 print(v)
end
end
printM()
untested but it should work

#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 20 February 2013 - 04:03 PM

for i=1, #npc do
print(npc[i])
end

You have to print the string at each index of the table.

#5 LuaEclipser

  • Banned
  • 220 posts
  • LocationCleveland, Ohio

Posted 20 February 2013 - 04:08 PM

Thank You Guys! Creds to both you

one more question


what if i want to print the guy in certain places on the map (or even randomly move!)

sorry if i am wasting your time

#6 tesla1889

  • Members
  • 351 posts
  • LocationSt. Petersburg

Posted 20 February 2013 - 04:12 PM

that gets a little complicated

basically you have two options:
  • add spaces to the beginning of each line to get the horizontal position and print nothing to get the vertical position
  • or you could set the position of the cursor for each line to where the next line should be


#7 LuaEclipser

  • Banned
  • 220 posts
  • LocationCleveland, Ohio

Posted 20 February 2013 - 04:14 PM

or could write it all to a function ,"

#8 LuaEclipser

  • Banned
  • 220 posts
  • LocationCleveland, Ohio

Posted 20 February 2013 - 04:18 PM

any ideas how to make them all move around and print maps?

#9 BigSHinyToys

  • Members
  • 1,001 posts

Posted 20 February 2013 - 04:26 PM

This program does what you want.
http://pastebin.com/ggTZXsyh

#10 LuaEclipser

  • Banned
  • 220 posts
  • LocationCleveland, Ohio

Posted 20 February 2013 - 04:44 PM

Thank You ^^

#11 R167

  • Members
  • 24 posts

Posted 20 February 2013 - 08:18 PM

 Lyqyd, on 20 February 2013 - 04:03 PM, said:

for i=1, #npc do
print(npc[i])
end

You have to print the string at each index of the table.
This is my personal favorite way to do stuff. Always works for this purpose. :)

#12 LuaEclipser

  • Banned
  • 220 posts
  • LocationCleveland, Ohio

Posted 26 February 2013 - 03:14 PM

 BigSHinyToys, on 20 February 2013 - 04:26 PM, said:

This program does what you want.
http://pastebin.com/ggTZXsyh

umm ya i got this error message while running this

i copyed it PERFECTYLE ----
( expected to close )

#13 LuaEclipser

  • Banned
  • 220 posts
  • LocationCleveland, Ohio

Posted 26 February 2013 - 03:15 PM

 LuaEclipser, on 26 February 2013 - 03:14 PM, said:

 BigSHinyToys, on 20 February 2013 - 04:26 PM, said:

This program does what you want.
http://pastebin.com/ggTZXsyh

umm ya i got this error message while running this

i copyed it PERFECTYLE ----
( at line 31 expected t oclose ) at line 30

my code ----

http://pastebin.com/ggTeYTAx


#14 BigSHinyToys

  • Members
  • 1,001 posts

Posted 26 February 2013 - 08:22 PM

http://pastebin.com/H0bSVFZA
Found a few problems with your code fixed.

#15 LuaEclipser

  • Banned
  • 220 posts
  • LocationCleveland, Ohio

Posted 01 March 2013 - 12:43 PM

thank you alot! you have helped me soooo much





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users