Author |
Message |
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
"ERROR: No such operator defined"
This is really getting on my nerves. I usually get this error when I've typed something incorrectly, but I can't find anything wrong with this script: Code: function Create(self) self.isammothing = false;
if MovableMan:IsParticle(limittedammopar) then self.ToDelete = true; else limittedammo = self; defaultammoamount = 5; self.isammothing = true; self.weaponlist = {}; self.weaponammolist = {}; print("Limited Ammo Feature ON"); end
end
function Update(self)
if self.isammothing == true then self.ToDelete = false; self.ToSettle = false; self.PinStrength = 1000; self.Pos = Vector(0,0); end
for i = 1,MovableMan:GetMOIDCount()-1 do self.gun = MovableMan:GetMOFromID(i); if self.gun.ClassName == "HDFirearm" then self.gotgun = false;
for b = 1, #self.weaponlist do if self.weaponlist[b] ~= nil then if self.weaponlist[b].ID ~= nil then if self.weaponlist[b].ID == 255 then self.weaponlist[b] = nil; end end end if self.weaponlist[b] ~= nil then if self.weaponlist[b] == self.gun then self.gotgun = true;
if ToHDFirearm(self.weaponlist[b]):DoneReloading() == true then self.weaponammolist[b] = self.weaponammolist[b] - 1; end
if self.weaponammolist[b] <= 0 then self.weaponammolist[b] = 0; self.weaponlist[b]:Deactivate(); end
if self.weaponlist[b].RootID ~= self.weaponlist[b].ID then self.actor = MovableMan:GetMOFromID(self.weaponlist[b].RootID); if MovableMan:IsActor(self.actor) == true and ToActor(self.actor):IsPlayerControlled() == true then
self.textsetter = "Magazine(s) = "..self.weaponammolist[b]; FrameMan:ClearScreenText(ToActor(self.actor):GetController().Player); FrameMan:SetScreenText(self.textsetter,ToActor(self.actor):GetController().Player,0,1,false);
end end
break; end end end
if self.gotgun == false then self.listnum = #self.weaponlist + 1; self.weaponlist[self.listnum] = ToHDFirearm(self.gun); self.weaponammolist[self.listnum] = defaultammoamount; print("Added Weapon"); end end end
end
It seems to happen between "for b = 1, #self.weaponlist do" and that for loop's "end". ANd pretty close to the begining of that area.
|
Wed Sep 01, 2010 11:24 pm |
|
|
Areku
Joined: Fri Oct 17, 2008 9:46 pm Posts: 5212 Location: The Grills Locker.
|
Re: "ERROR: No such operator defined"
Hmm. I've encountered that problem a few times before. It usually happens when you try to make function operations into Userdata variables (SetMagnitude on self.Vel, for instance, or diving self.Vel by a vector).
However, I can find nothing of the sort in your script.
Maybe the game is not recognizing the objects in the table as proper MOs with ID's. In the case, a ToParticle might solve it.
I might be probably am wrong, of course, since tables are a bit too hardcore for me.
|
Thu Sep 02, 2010 12:32 am |
|
|
Geti
Joined: Sun Jul 13, 2008 9:57 am Posts: 4886 Location: some compy
|
Re: "ERROR: No such operator defined"
Does it happen right away? A line number would help. Also, why are you checking if self.weaponlist[b] ~= nil all the time? could be solved with an if self.weaponlist[b] == nil then break; end at the start. A more effective trace would be helpful.
|
Thu Sep 02, 2010 7:27 am |
|
|
CrazyMLC
Joined: Fri Dec 22, 2006 4:20 am Posts: 4772 Location: Good news everyone!
|
Re: "ERROR: No such operator defined"
Code: self.textsetter = "Magazine(s) = "..self.weaponammolist[b]; I'm pretty sure only strings can be ..'d onto other strings.
|
Thu Sep 02, 2010 8:41 am |
|
|
Geti
Joined: Sun Jul 13, 2008 9:57 am Posts: 4886 Location: some compy
|
Re: "ERROR: No such operator defined"
Oh, I missed that. Concatenate the PresetName, not the object?
|
Thu Sep 02, 2010 9:54 am |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: "ERROR: No such operator defined"
But, self.weaponammolist stores numerical information. I'm pretty sure you can concedklfhbavka, er, dot dot those.
|
Thu Sep 02, 2010 8:37 pm |
|
|
Areku
Joined: Fri Oct 17, 2008 9:46 pm Posts: 5212 Location: The Grills Locker.
|
Re: "ERROR: No such operator defined"
Oooh oooh, I know how to fix that!
Always put stuff that is directly next to a .. between (). It helps solve a lot of variable print crashes, so it should help there.
|
Thu Sep 02, 2010 11:38 pm |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: "ERROR: No such operator defined"
Bleh, didn't work.
|
Fri Sep 03, 2010 12:35 am |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: "ERROR: No such operator defined"
CaveCricket48 wrote: But, self.weaponammolist stores numerical information. I'm pretty sure you can concedklfhbavka, er, dot dot those. Tostring it to be sure?
|
Fri Sep 03, 2010 12:42 am |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: "ERROR: No such operator defined"
Still no luck.
This sucks, I don't even know the exact location of the error. I have a feeling that it's not the string that's causing it.
|
Fri Sep 03, 2010 12:51 am |
|
|
Geti
Joined: Sun Jul 13, 2008 9:57 am Posts: 4886 Location: some compy
|
Re: "ERROR: No such operator defined"
chuck prints and the start of each line with the line number? O_o Getting a line trace isn't the hard part..
|
Fri Sep 03, 2010 4:41 am |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: "ERROR: No such operator defined"
It's somewhere in this for loop: Code: for b = 1, #self.weaponlist do if self.weaponlist[b] ~= nil then if self.weaponlist[b].ID ~= nil then if self.weaponlist[b].ID == 255 then self.weaponlist[b] = nil; end end end
Aswell as anything after that uses "self.weaponlist[b]".
|
Fri Sep 03, 2010 11:02 am |
|
|
Kyred
Joined: Sun May 31, 2009 1:04 am Posts: 308
|
Re: "ERROR: No such operator defined"
Maybe it's an error with the array reference? Try doing the loop this way and see what happens. Code: for index, weapon in ipairs( self.weaponlist ) do if weapon ~= nil then if weapon.ID ~= nil then if weapon.ID == 255 then self.weaponlist[index] = nil; end end end end
Is this part of the script trying to check if weapon in the list still exists? If so, you can skip the ID check and use MovableMan:ValidMO() instead. That way, you can avoid using logic operators, thereby circumventing the error. I hope this helps. EDIT: Quote: Aswell as anything after that uses "self.weaponlist[b]". I just noticed that statement. Hmm...maybe it could be because operations are trying to be carried out on a possible nil value? If the above code does not work, you might also try setting a local variable in the loop to ToMovableObject(self.weaponlist[b]) to ensure the object retrieved from the array actually has the properties of a movable object.
|
Fri Sep 03, 2010 7:12 pm |
|
|
Geti
Joined: Sun Jul 13, 2008 9:57 am Posts: 4886 Location: some compy
|
Re: "ERROR: No such operator defined"
Why don't you use table.remove as well as an ipairs iteration like kyred suggested? It'd mean you can call a break upon removing the item, so you won't ever be trying to work with a nil reference.
|
Sat Sep 04, 2010 1:01 am |
|
|
|