General > News

Quick fix for the "commands break over time" problem

<< < (2/3) > >>

spbogie:
Actually, the problem is not lying when we use it in a for loop, but in the way it is repeatedly used in place of nil in many function calls.

Megiddo,
Although this method works, it will break whichever script(s) is/are setting _ to a value. Although this/these script(s) shouldn't be using _ I think it would better fit our goal to find less intrusive method. I believe simply defining _ as a local variable set to nil at the top of each script should do. This would also be less hacky (not setting the global table as a metatable for itself).

Megiddo:
I'm fairly sure that whoever is assigning a value to _ is doing it on accident, for example, if you do _, var = string.find() it will assign a value to _ instead of leaving it nil. Doing it this way ensures that other scripts remain working as well.

Mank:

--- Quote from: JamminR on February 25, 2007, 11:53:33 AM ---A little deeper, without getting overly technical;
We're 99% sure that another script not controlled by Ulysses Team, we're still not sure which, was setting _ as a global variable.

That would be fine and dandy, but, many programmers, including us, use _ as a local variable, usually in a for loop or function.

Whichever script was setting _ as a global was then causing havok on ULX.

This tiny bit of code, in simplest terms, sets the global _ as nil permanently.

It will still be able to be used as a local if needed.

--- End quote ---

Since when were variables inside of for loops local?

(If I'm wrong it's because I only use C++ =P)

spbogie:

--- Code: ---for _, ply in pairs(player.GetAll()) do
--- End code ---
In this case Lua makes _ and ply local variables.

As I stated before however this is not where our problem is steming. It comes when we assume _ is nil without it having been defined localy. This workaround ensures that global _ always remains nil.

Mank:

--- Quote from: spbogie on February 27, 2007, 01:50:06 PM ---
--- Code: ---for _, ply in pairs(player.GetAll()) do
--- End code ---
In this case Lua makes _ and ply local variables.

As I stated before however this is not where our problem is steming. It comes when we assume _ is nil without it having been defined localy. This workaround ensures that global _ always remains nil.

--- End quote ---
Ah, I see =)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version