I'm pretty new to Byond coding, and trying to learn... Can't find anything that I can seem to use to get this working...
I want my obj to be displayed by two separate icons. Basically displayed in the world with Icon A, and displayed in the player's inventory with Icon B.
If anybody has any code examples, and can describe what it all means (so that I actually learn what's going on and how to do this type of thing without feeling like I'm just copying other people's chunks of code) I'd be very appreciative.
ID:161550
Apr 22 2008, 8:13 pm
|
|
In response to Garthor
|
|
obj |
In response to RanEsu
|
|
RanEsu wrote:
> obj |
In response to RanEsu
|
|
This code is horribly written and I can't see any relation between it and the question posed.
|
In response to Garthor
|
|
Good code, good explanation. But-
Garthor wrote: .=..()</DM> You don't need to override Move() all the time; you've got the cleaner, more object oriented Entered() and Exited() for these kind of things. So you could do this by overriding a pair of them in many combinations, I'd go for /mob/Exited() and /mob/Entered() (you could do atom/movable instead of mob, but it shouldn't be needed). when creating the object, we need to set its icon properly. So, we'll put essentially the same thing we had in Move() into New(): Essentially, he will be using the 'ground icon' for the compile-time setting, so you only need half of the code block in New(); only check if the item is in a mob, and if so change the icon. |
In response to Garthor
|
|
Thanks Garthor. I was able to simply change the icon and icon_state within the grab() and drop() commands I'm using, as I had previously though, but the vars are what I was missing. Thanks for the ideas and the detailed explanation! It really helped!
|
In response to Spartan206
|
|
It will do to put it in the verb itself, but putting it in a movement proc like I/Garthor said is preferable.
|
Simple enough. Now, we will have this change icon and icon_state in Move(), so that when it moves to a turf, it sets its icon to groundicon and icon_state to groundstate. When it moves to anything else, it will become invicon and invstate:
However, what you need to keep in mind is that items now need to call Move() in order to move around. If their loc is altered directly, their icons won't change. So, for example, get() and drop() will have to look like this:
No more difficult than adjusting loc directly. Now, there's one last thing: when creating the object, we need to set its icon properly. So, we'll put essentially the same thing we had in Move() into New():
And that should be it. You probably want to also set the icon and icon_state of the items, as well, so that they show up properly in the map editor.