For loop refusing to run through a table?

Hi, I am having a bit of a problem, this is not garrysmod lua but a library that shares the same concepts.
Basically I am trying to check if an item is not in a global table, and if it is not, reward a player. However all my for loops (pairs, ipairs, clasical) seem not to work.

GlobalObjects1 = {}
oldobj = Mode.onObjectAdded
     function Mode:onObjectAdded(obj)
          table.insert(self, GlobalObjects1)
          return oldobj(self, obj)

oldob = Mode.onObjectRemoved
     function Mode:onObjectRemoved(obj)
          for i, v in pairs(GlobalObjects1) do
               if i == self then
               GlobalObjects1* = nil
          return oldob(self, obj)

function PlayerHasGottenLoot(lootstring)
          for i = 1, #GlobalObjects1 do
               if GlobalObjects1*.type == lootstring then
                    return false
                    return true

The odd local function replacing is so I do not overwrite the functions when appending code to them, but anyway, the for loops will never run, the debug text never prints, any ideas?

How can code be so ugly?
It reminds me of Warcraft III World Editor’s JASS files.
Rename your variables.
Indent your code properly.

Tell us which loop doesn’t work.

Sorry, I have never indented lua, it’s a bad habit, I started coding when I was 9 and just learned to count the blue things that aren’t locals, and that’s how many ends there should be.

None of the loops work, as in whenever one of them is ran though the table, it just wont do anything, as if the table just doesn’t exist.

The variable name was because I had a table named GlobalObjects, that is the name of a global that was already used though, thus re-declaring it was a bad idea. I made the new table then.

You also may notice I didn’t use table.remove, that was also because I figured it may have been causing the problem, looking back I forgot the reasoning for that.

Edit: Cleaned it up a little.

The fuck? Indenting code is a bad habit? No fucking way. Just no. No!
I hope you mean the bad habit is that you don’t indent.

And yes that was the bad habit.

But even if it did run once, would it still not print?

Use Sublime Text 2. (You can even use it unlicensed. It will bug you every 20 or so saves, but you just hit Cancel and continue.)

Your arguments are in the wrong order. You’re inserting the GlobalObjects1 table reference into self.

Facepalm of the century.

Thankyou very much.

You’re welcome!
And remember to indent your code (even if your editor doesn’t). It will save you a lot of headaches in the future. (I’ve had the same habit when I started coding - at 11)