Jump to content




Table acting weird


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

#1 XoX

  • New Members
  • 53 posts

Posted 30 October 2012 - 08:54 PM

Spoiler

EDIT:
I fixed the problem, for some reason as soon as I copy menu2 to menu5 it for some reason messes up menu2,
I don't know what the reason is for this and if this is still a problem in the current version of Computercraft but it should definitely be fixed.

Edited by XoX, 30 October 2012 - 09:26 PM.


#2 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 31 October 2012 - 02:59 AM

Of course it is still an issue in the latest version of ComputerCraft - because it is your code which is a problem. Because you're altering the functions in the sub tables of menu2 after referencing them from menu5, the functions in menu2 instead do the actions in menu5.

#3 XoX

  • New Members
  • 53 posts

Posted 31 October 2012 - 09:20 AM

for k, v in ipairs(menu5) do
I am editing in the table menu5, not menu2.

And I am not doing menu5 = menu2 as before which apparenly is supposed to reference to the old table.
I wrote a table.copy function which SHOULD create a copy of the table, not a reference.

EDIT: WAIT, don't tell me that because the contents of the table are tables I'm not copying the table but referencing the sub-tables in the old table instead of creating them in the new table??


EDIT2: Should this work then?
ttable.copy = ""
ttable.copy = function(t1)
	local t2 = {}
	for k,v in pairs(t1) do
		if type(v) == "table" then
			t2[k] = ttable.copy(v)
		else
			t2[k] = v
		end
	end
	return t2
end


#4 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 31 October 2012 - 07:18 PM

That's exactly what I was dating saying :P/>

Yep the new code should do what is expected.

#5 XoX

  • New Members
  • 53 posts

Posted 31 October 2012 - 09:38 PM

View PostCloudy, on 31 October 2012 - 07:18 PM, said:

That's exactly what I was dating saying :P/>

Yep the new code should do what is expected.

Sweet, alright.
I had no idea that if you try to assign a variable the value of a defined table it would just refer to it.


I was wondering, what do you have to do to get the Lua Coder Pro whatever tag?

#6 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 31 October 2012 - 10:55 PM

There's no set rule on getting marked as a Pro. Setting out to try to get it just because it's shiny isn't the way to earn it, though.

#7 ChunLing

  • Members
  • 2,027 posts

Posted 31 October 2012 - 11:09 PM

I was marked as a pro for a while. Now I'm on the road to back-alley Lua serial offender. Which is kinda the wrong direction, from a certain point of view.

#8 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 31 October 2012 - 11:12 PM

View PostChunLing, on 31 October 2012 - 11:09 PM, said:

I was marked as a pro for a while. Now I'm on the road to back-alley Lua serial offender. Which is kinda the wrong direction, from a certain point of view.

The "Lua Pros" group is separate from the post count rank names. :P/>

#9 ChunLing

  • Members
  • 2,027 posts

Posted 31 October 2012 - 11:46 PM

True. But if you check, "Lua Coder Pro" is probably talking about the Coder Pro tag, or at least failing to distinguish it from Lua Pro. Just saying that as one on the path to becoming a Dark Lord of Aul.

#10 XoX

  • New Members
  • 53 posts

Posted 01 November 2012 - 12:05 AM

I meant the Lua Pro tag, I just couldn't recall what it was called exactly.
I was just wondering.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users