Jump to content




This doesn't wok on startup, but it work..


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

#1 Asdramelesh

  • Members
  • 9 posts

Posted 28 February 2014 - 11:06 AM

Hi everyone, I need help because I really don't understand what is happening :

I'm writing a program with a list of players on the server, so I use table.
This program is called startup, when I launch it typing "startup" on a computer it work (return Asdramelesh 0), but if I reboot the computer he say that I attempt to index nil.

Can you help me please?

startup :
players = {asdra,yakoo,lous,leios,unike,minefuch,zeykoz,lazik,spekinoz,boson,lucky}
asdra = {["name"]="asdramelesh",["presence"]=0}
yakoo = {["name"]="yakoo29",["presence"]=0}
a = players[1]["name"]
b = players[1]["presence"]
print(a.." " .. B)/>

Edited by Asdramelesh, 28 February 2014 - 11:08 AM.


#2 nolongerexistant

  • Validating
  • 201 posts
  • LocationNetherlands

Posted 28 February 2014 - 11:56 AM

This is because when the Computer boots, it doesn't know what any of the variables in the players table are, you'll have to define them before you try to use them in the table. The reason it does know what they are when you manually run the program is because you're setting global variables, you should use local variables unless you need them externally.

local asdra = {["name"]="asdramelesh",["presence"]=0}
local yakoo = {["name"]="yakoo29",["presence"]=0}

local players = {asdra,yakoo} -- The others are still undefined

local a = players[1]["name"]
local b = players[1]["presence"]

print(a.." " .. B)/>/>

Edited by Snakybo, 28 February 2014 - 11:56 AM.


#3 Asdramelesh

  • Members
  • 9 posts

Posted 28 February 2014 - 12:03 PM

Okay I understand now, thanks a lot!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users