proper use of 'remove' - Printable Version +- SphereCommunity (https://forum.spherecommunity.net) +-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d) +--- Forum: Script Help (/Forum-Script-Help) +--- Thread: proper use of 'remove' (/Thread-proper-use-of-remove) |
proper use of 'remove' - Rattlehead - 07-24-2013 04:10 AM this has actually kicked my ass for a really long time, i saw something about it on the old forums, i think vjaka or furio explained it, but as we dont have any access to that anymore i cant remember the proper use, ill give some examples, once i get the proper useage i plane to update the damn wiki so its always there incase i forget again or incase someone else needs to know of course ok, so to remove the obj that the script is running on i know already, its obvious really: Code: on=@timer but what if i need to remove some other item? Code: // lets assume for the moment that i am passing multiple UID's to this function the above example doesnt seem correct at all to me, so: Code: // lets assume for the moment that i am passing multiple UID's to this function so is this proper? and if so, how would i work that in a @step trigger for example, on an item to remove a multi: // lets assume for the moment that i am passing multiple UID's to this function Code: [itemdef i_remove_me] so u can see, the damned remove function is haunting me, as many examples as i can get would be uber helpful RE: proper use of 'remove' - Shaklaban - 07-24-2013 04:26 AM PHP Code: [function remove_me] RE: proper use of 'remove' - Rattlehead - 07-24-2013 04:55 AM ok, so no arguments after the remove, remove should be left side, not right. thx man RE: proper use of 'remove' - amonvangrell - 07-24-2013 08:18 AM interesting. ;] RE: proper use of 'remove' - RanXerox - 07-24-2013 11:15 AM Here is an excerpt from the wikipedia article on Object Oriented Programming: Quote:In programming languages an object is the composition of nouns (like data such as numbers, strings, or variables) and verbs (like actions, such as functions). The REMOVE "function" (or "command", or "method" if you prefer), is inherited from the most primitive of objects... as such, it can be applied to nearly anything (certainly any ITEM, CHAR (both NPC and Player), and possibly even more esoteric stuff like REGIONS (although I've never tried that sort of thing...) Using "dot notation" you can can cause the REMOVE to act on the referenced object... for example: SRC.REMOVE ACT.REMOVE SRC.FINDLAYER.layer_hand1.UID.REMOVE etc... or you can pass arguments to it and cause it to affect something else entirely... as in: REMOVE SRC REMOVE ACT REMOVE <SRC.FINDLAYER.layer_hand.UID> The wiki article goes on to say this: Quote:...Objects can be thought of as encapsulating their data within a set of functions designed to ensure that the data are used appropriately, and to assist in that use. The object's methods typically include checks and safeguards specific to the data types the object contains... An example of a safeguard that sphere has implemented in the REMOVE method is the protection of player CHAR objects... to remove a Player CHAR, the last argument of REMOVE must be a 1, as in: SRC.REMOVE 1 or REMOVE <SRC> 1 Quote:ok, so no arguments after the remove, remove should be left side, not right. thx man There isn't really any difference, from a style perspective using SRC.REMOVE is a more "object oriented" way of writing your code... but there is also something to say for code readability, so in some cases it might be easier to "read" your code if you use the other style of passing an argument to the function/method. |