The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
proper use of 'remove'
Author Message
Rattlehead
Master
**

Posts: 290
Likes Given: 3
Likes Received: 8 in 6 posts
Joined: Jun 2012
Reputation: 8



Post: #1
proper use of 'remove'
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
remove
return 1

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

[function remove_me]
ref1=<argv[0]>
remove <ref1>

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

[function remove_me]
ref1=<argv[0]>
ref1.remove

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]
id=i_gold
type=t_script
name=Remove the region

on=@step
region.remove // ????

so u can see, the damned remove function is haunting me, as many examples as i can get would be uber helpful

[Image: matts_siggy.gif]
(This post was last modified: 07-24-2013 04:11 AM by Rattlehead.)
07-24-2013 04:10 AM
Find all posts by this user Like Post Quote this message in a reply
Shaklaban
Master
**

Posts: 378
Likes Given: 0
Likes Received: 1 in 1 posts
Joined: Mar 2012
Reputation: 8

DOT

Post: #2
RE: proper use of 'remove'
PHP Code:
[function remove_me]
ref1=<argv[0]>
if <
ref1//if ref1 exist, useful in some situations
    
ref1.remove
endif


[
itemdef i_remove_me]
id=i_gold
type
=t_script
name
=Remove the region

on
=@step
ref1
=<src.region.uid>
if <
ref1//maybe not needed, i can't check it because my desktop pc is dead
    
if <ref1.type> = t_multi 
        ref1
.remove
    
endif
endif 
(This post was last modified: 07-24-2013 04:27 AM by Shaklaban.)
07-24-2013 04:26 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Rattlehead
Master
**

Posts: 290
Likes Given: 3
Likes Received: 8 in 6 posts
Joined: Jun 2012
Reputation: 8



Post: #3
RE: proper use of 'remove'
ok, so no arguments after the remove, remove should be left side, not right. thx man

[Image: matts_siggy.gif]
07-24-2013 04:55 AM
Find all posts by this user Like Post Quote this message in a reply
amonvangrell
Banned

Posts: 337
Likes Given: 17
Likes Received: 32 in 20 posts
Joined: Aug 2012

britannia shard

Post: #4
RE: proper use of 'remove'
interesting. ;]
07-24-2013 08:18 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
RanXerox
Master
**

Posts: 550
Likes Given: 1
Likes Received: 12 in 9 posts
Joined: Dec 2010
Reputation: 19



Post: #5
RE: proper use of 'remove'
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).

An object oriented program may be viewed as a collection of interacting objects, as opposed to the conventional model, in which a program is seen as a list of tasks (subroutines) to perform. In OOP, each object is capable of receiving messages, processing data, and sending messages to other objects. Each object can be viewed as an independent "machine" with a distinct role or responsibility. Actions (or "methods") on these objects are closely associated with the object. For example, OOP data structures tend to "carry their own operators around with them" (or at least "inherit" them from a similar object or class)...

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.
(This post was last modified: 07-24-2013 11:19 AM by RanXerox.)
07-24-2013 11:15 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)