Data Realms Fan Forums http://45.55.195.193/ |
|
"ERROR: No such operator defined" http://45.55.195.193/viewtopic.php?f=73&t=19657 |
Page 1 of 1 |
Author: | CaveCricket48 [ Wed Sep 01, 2010 11:24 pm ] |
Post subject: | "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. |
Author: | Areku [ Thu Sep 02, 2010 12:32 am ] |
Post subject: | 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 |
Author: | Geti [ Thu Sep 02, 2010 7:27 am ] |
Post subject: | 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. |
Author: | CrazyMLC [ Thu Sep 02, 2010 8:41 am ] |
Post subject: | 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. |
Author: | Geti [ Thu Sep 02, 2010 9:54 am ] |
Post subject: | Re: "ERROR: No such operator defined" |
Oh, I missed that. Concatenate the PresetName, not the object? |
Author: | CaveCricket48 [ Thu Sep 02, 2010 8:37 pm ] |
Post subject: | Re: "ERROR: No such operator defined" |
But, self.weaponammolist stores numerical information. I'm pretty sure you can concedklfhbavka, er, dot dot those. |
Author: | Areku [ Thu Sep 02, 2010 11:38 pm ] |
Post subject: | 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. |
Author: | CaveCricket48 [ Fri Sep 03, 2010 12:35 am ] |
Post subject: | Re: "ERROR: No such operator defined" |
Bleh, didn't work. |
Author: | Grif [ Fri Sep 03, 2010 12:42 am ] |
Post subject: | 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? |
Author: | CaveCricket48 [ Fri Sep 03, 2010 12:51 am ] |
Post subject: | 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. |
Author: | Geti [ Fri Sep 03, 2010 4:41 am ] |
Post subject: | 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.. |
Author: | CaveCricket48 [ Fri Sep 03, 2010 11:02 am ] |
Post subject: | 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]". |
Author: | Kyred [ Fri Sep 03, 2010 7:12 pm ] |
Post subject: | 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. |
Author: | Geti [ Sat Sep 04, 2010 1:01 am ] |
Post subject: | 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. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |