Jump to content




I am completely lost! Need help fixing this neat program


2 replies to this topic

#1 L0NE

  • New Members
  • 2 posts

Posted 01 April 2017 - 10:16 AM

Okay so to get started I would like to say I am very new to this forum, i just started my own server and i have been playing with my friends. I am not new to programming and thats why i am so frustrated i can't fix this, it just doesn't get in my head...and i still have to learn better syntax of Lua.

So what is program about:

The program is almost like a universal wireless control for a "base". You have 2 pieces of code, one for clients and one for lets say server, or a mainframe.
The client one is a standalone computer that is connected to redstone....could be multiple of standalone ones because the server ties them together.
The server is a computer that makes a montior screen, user makes his own buttons and the program is supposed to turn on/off on monitorclick the specific computer redstone signal

What is the problem:

1. ) I am sure there will be more problems since this is the one that showed at almost startup, but i couldn't get through it so i don't know what waits for me next.
On startup it runs, I press the "+" on cursor pos 1,1 so i can add a button, i add one, and i press on the left corner of the button which is supposed to call a function to changebox i think, so i can assign a standalone computer to that button. Then I get a attemt to call nil on :104

		repeat
  :104			  term.restore()
				local w, h = term.getSize()
		until w == 51 and h == 19

I am not familiar with Lua, but i have read that restore is a Lua function? So that can't be call nil in my opinion

2. )

even if i don't click on the left of the button to edit it...but i just create a button and reboot the program...it gives me on line :90 table expected, got nil....i have looked and looked, nothing crossed my mind

:90 for id,b in pairs(box) do
				drawBox(b,id)
		end

If there is any way you could help me i would appreciate it :D
The full codes and pastebin:

Server:
https://pastebin.com/faNYCykU
Client:
https://pastebin.com/m8MmwvX7


Here is the full code for server:

Spoiler


Full code client:

Spoiler

Edited by Bomb Bloke, 01 April 2017 - 01:26 PM.


#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 01 April 2017 - 01:35 PM

View PostL0NE, on 01 April 2017 - 10:16 AM, said:

I am not familiar with Lua, but i have read that restore is a Lua function? So that can't be call nil in my opinion

term.restore() is a ComputerCraft-specific function that only exists in versions of the mod prior to 1.6. When using later releases, you're expected to keep track of previous terminals yourself. term.redirect() actually returns the previous terminal every time you tell it to switch to a new one, which helps somewhat with this.

View PostL0NE, on 01 April 2017 - 10:16 AM, said:

it gives me on line :90 table expected, got nil....

If "box" is nil, then that implies line 26 within your load() function is setting it as such:

box = textutils.unserialize(file.readLine())

Bearing in mind that textutils.serialize() typically produces multiple lines of output (again, this is version dependant), you can probably see why.

If you want to write multiple tables to a file, then it's easiest to place them all within a single "master" table, then serialise that all in one go. You can then read it back later with a "readAll", and it'll work regardless of version.

#3 L0NE

  • New Members
  • 2 posts

Posted 01 April 2017 - 03:37 PM

Well that makes things more clear....i will try to fix it now by knowing this and get back on this post if i need some further help. Thank you for your time :D





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users