ID:178816
 
How would I make an object or an image be invisible to others but visible to one character than make it so that after a while that player can not see it anymore either.
Exadv1 wrote:
How would I make an object or an image be invisible to others but visible to one character than make it so that after a while that player can not see it anymore either.

Welcome to the world of client.images!

atom
var/image/my_images[]

proc/DisplayImage(icon, icon_state, mob/mob = usr, remove = 0)
if(!my_images) my_images = list() //initialise list only if necessary

var/image/cur_image
for(cur_image in my_images) //check to see if an image exists
//this will store the image found in the 'image' var
if(cur_image.icon == icon && cur_image.icon_state == icon_state) break

if(!cur_image) //if we haven't found an image,
cur_image = image(icon, icon_state) //make a new one,
my_images += cur_image //and add it to our list for future reference

if(mob && mob.client) //if it is a player,
mob.client.images += cur_image //display it to him/her

if(remove) //if we have a remove timer set
//remove the image after that many ticks
spawn(remove) mob.client.images -= cur_image




Thus, let's say you cast "Know Alignment" on a person. This reveals their alignment as LAWFUL_GOOD.

Now, you check it in:

var/icon_state
switch(alignment)
if(LAWFUL_GOOD) icon_state = "lawful good"

Now, you do the following:

person.DisplayImage('alignment_auras.dmi', icon_state, usr, 50)

This will display the lawful good aura around this person to the usr for 5 seconds. That goody-two-shoes.

There you go! =)
In response to Spuzzum (#1)
Nifty :)

I haven't really used image yet (because I haven't had the need) but I can definetely see using them at some point. Mind if I steal that? I don't really feel like writing my own :p
In response to English (#2)
English wrote:
Nifty :)

I haven't really used image yet (because I haven't had the need) but I can definetely see using them at some point. Mind if I steal that? I don't really feel like writing my own :p

Note that I'm not actually sure if it works or not, since it's untested.

It's going in my list of snippets anyway -- if I can ever get my freakin' website loading subpages rather than just loading the main page for all of 'em (for some odd reason, when I break out of the main proc suddenly the Section datum is nulled out, which prevents subpages from reading it, which makes them all think they're the main page).

So you can steal it, yes. =)
In response to Spuzzum (#3)
Maybe I should test it before I use it then ;)

Even if it doesn't work it looks good in principle and should work fine with a few minor tweaks (if it needs them at all).

Anyway, thanks :)
In response to English (#4)
English wrote:
Maybe I should test it before I use it then ;)

Even if it doesn't work it looks good in principle and should work fine with a few minor tweaks (if it needs them at all).

Should work now... I cleaned out the errors and reposted. =)
In response to Spuzzum (#3)
(for some odd reason, when I break out of the main proc suddenly the Section datum is nulled out, which prevents subpages from reading it, which makes them all think they're the main page)

I'm not exactly sure what the webpage code you're talking about does, but this sounds suspiciously like a problem I had when creating objects that did browse thingies. What I did was create an object, then use a proc of that object to browse some stuff. The problem was that after that, no references to the object still existed and the garbage collector ate them. I ended up creating a little proc that always runs for them, which I needed to do for my purposes anyway, which ensured that the garbage collector left them alone.

-AbyssDragon
In response to AbyssDragon (#6)
AbyssDragon wrote:
(for some odd reason, when I break out of the main proc suddenly the Section datum is nulled out, which prevents subpages from reading it, which makes them all think they're the main page)

I'm not exactly sure what the webpage code you're talking about does, but this sounds suspiciously like a problem I had when creating objects that did browse thingies. What I did was create an object, then use a proc of that object to browse some stuff. The problem was that after that, no references to the object still existed and the garbage collector ate them. I ended up creating a little proc that always runs for them, which I needed to do for my purposes anyway, which ensured that the garbage collector left them alone.

But the thing is, it would never break out of a situation where there wouldn't be a reference pointing to them. Once it tries to run a procedure, suddenly the arguments don't exist any more.

This is verified by my debug output:

Sun Mar 17 19:39:50 2002
BuildPage() - No subsection!
BuildPage() - No page!
GenerateToC() - No subsection!
GeneratePage() - No subsection!
GeneratePage() - No page!
LoadText() - No section!
LoadText() - No subsection!
LoadText() - No page!

In other words, though it all is called from the single wrapper procedure BuildPage(), suddenly LoadText() doesn't have a section argument given to it.

I put my webpage by the wayside for now, anyway. I might get back to it next week.