Gigimoi wrote:
> you give a man a fish, you feed him for a day > > you teach a man how to fish, you feed him for a lifetime. > > no offence but please remember that.
That is exactly what Schnitzelnagler was attempting to do, and he told you exactly what to look at, and that you should still use Move(). You took his attempt to teach you to fish, and you started trapping squirrels instead.
> also my > > src.loc = (usr) > > works
Alright, I'll try to drag you back over to fishing if you're going to say that, and when you get me on a "teaching to fish" spree, you better be ready for a lecture, because that's what all my replies of that nature turn into.
Obviously, Byond works by having a 2-dimensional visible grid of squares for you to move on. Every movable object is generally (we won't go into the odd cases) contained in one of these squares.
Again obviously, all objects have a bunch of "variables" that keep track of various data relating to the object.
Movable objects have a variable called "loc" which tells the object which object (usually a "square" a.k.a. a "turf") it is within. So, generally, "loc" equals the square you are in. So, if you change loc to equal a different square, then you will be in that square obviously since you just told it that that's where it is!
Although I'm not going into the odd situations, I will go into the fact that movable objects (mobs and objs) can be located (via "loc" variable) inside of other mobs and objs as well as inside of turfs, which you apparently realize hence your post concerning this. Again, since you want the one mob object to be inside the other mob object, well, loc is what decides where you are, so obviously setting it will make you happen to be "in" whatever you set it to, including another mob, which is what you just attempted.
Now, there is a function, called Move(), that moves an object to another location. Move() does this the "proper" way, as it takes certain checks and balances into account that just setting "loc = whatever" obviously cannot.
Remember, if you just set "loc = usr" then the src is now going to be inside of usr, no questions asked, and without any side effects, because there's no reason for anything else to happen.
Move(), on the other hand, will set loc for you. Being a function, it also has other code inside of it that does other stuff. Here's what Move() does...
Move() first checks to make sure you are actually able to leave the location you are currently at. Second, it will check to make sure you are able to enter into the new location you want. Now, two different scenarios can play out for whether or not you are able to enter the new location. 1) You cannot enter the new location (maybe something is already there and blocking the way), so Move() makes a call to Bump() so that you bump into whatever is in the way. 2) You can enter the new location, so Move() now sets loc equal to the new location for you, it also sets your direction you are facing, and it calls the old location's Exited() and new location's Entered() functions.
If some of that seems overwhelming to you, just remember that three quarters of that amounts to "now do nothing" because certain functions don't do anything unless you override them and tell them to do something.
Entered() does nothing, Exited() does nothing, Bump() does nothing, Exit() does nothing (I didn't specifically mention Exit(), but it's what determines whether you are able to exit your current location). All these things do nothing and you don't have to worry about them unless you decide to use them later on.
For now though, you just need to remember "Move() is a function that checks to see if you can move out of your current location and into the new one. If you can, it relocates you to the new location and sets your direction appropriately."
For future expansion, remember "If Move() succeeds in moving you, it causes special actions to happen if you have programmed any special actions to happen, which would be determined by Entered() and Exited(). On the other hand, if it fails to move you, it bumps whatever was in the way (if something was in the way), if you have overridden Bump() to make special bumpy things happen.
So, if you say "loc = newLocation" it will move an object to newLocation, because you're telling it "this is what your location is." If you say "Move(newLocation)" then Move() will check on things for you and properly handle all movement, which includes "loc = newLocation" and other stuff.
As for what Schnitzelnagler told you to do, he said to check on the arguments of Move() so that you could see what to use between the () parenthesis. As the reference says, Move(newLoc, Dir) takes an object (the new location) as the newLoc argument.
If having looked it up and seeing that you need to pass the new location to Move() did not clear it up for you, then the following might help as well.
Every function has built in variables that are local to it. This includes "src" and "usr" The variable "src" is a variable that always actually equals the object that the function is acting on behalf of. This much you seem to realise, as you are using src to mean "the mob I want to move into my inventory." usr is equal to the object that initiated the sequence of actions that led to this function being called. Since you, the player, initiated the action, your mob is the usr. usr = your mob.
A "list" is another type of object (of type /list), one that is not like the other atomic-based objects (area,turf,mob,obj). A list is an object that keeps track of groups of data. All atomic-based objects have a variable called "contents" which is a list object of everything that, according to the map's point of view, is inside that object.
So, in your case, usr is one object, and it's an object of type /mob, and it's the object you want to move src into. usr.contents is another object, an object of type /list, and a list doesn't contain anything in a mappable sense, only from an abstract sense that it is keeping track of a group of things behind the scenes. From a mappable point of view, a /list doesn't contain anything, the objects on the map do (albeit via the /list type object that it has for one of its variables).
Hope that helps. And it might even increase your fish-catching rate. |
|