Help with defining method for items

I am trying to make a system where each item has its own weight, and when the characters cannot carry all their stuff, they cannot move and have to throw away their stuff.

The main focus for help:
Here is the code in the scripts:
Spoiler: Code in the scripts
class RPG::Item
def weight
if @weight.nil?
weight_checker
return @weight
else
return @weight
end
end

def weight_checker
@weight = self.note =~ /<Weight: (.*)>/i ? $1 : 0
end
end

Code in common events:
Spoiler: Code in common events
hepl.PNG

The thing is, it breaks on the 1st line after "else" in the common event with a " "weight" not found for nil:nilClass "

how do I define "weight" properly?
Moved to: Learning Ruby and RGSDx
All the database globals ($data_*) start at index 1, not 0. So init variable 63 to 1.
Thanks! (I kinda feel like an idiot but thanks anyways) 🙂
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/help-with-defining-method-for-items.108123/