ID:1948366
 
(See the best response by Lummox JR.)
Hey.

I never once knew how to make an obj, turf, or mob appear on only the user's screen; without it showing up on other peoples screens. I never got into all that..

Is there a way to make a Chest in a BYOND game, that the user can open and take the contents of, and then the treasure chest won't open again for that user, BUT other players will see the chest in its Closed form still, and can open the treasure chest for the first time and take one of whatever the chest's contents are?
MartialArtistAbu wrote:
Is there a way to make a Chest in a BYOND game, that the user can open and take the contents of, and then the treasure chest won't open again for that user, BUT other players will see the chest in its Closed form still, and can open the treasure chest for the first time and take one of whatever the chest's contents are?

Some people would delve into this, but it can actually be done very simply. These two variables, invisibility and see_invisible, alone can perform what you're describing.

I don't want to go quoting the reference for you, so just click on those links and it'll direct you to where you can read up on it :)
In response to Konlet
I just re-read your question, and I believe I gave you advice for a different process. To perform what you want, I would possibly just create a list for the chest and when a player loots it, add that player to the list. When the player attempts to loot the chest, just perform nothing if they are in the list.

obj/chest
var/list/looted = new
Click()
..()
if(!looted[usr])
looted += usr
usr << "You have looted this chest!"
//Loot function here.
Thank you. Is there a way for the icon of the chest to look closed to players that haven't opened it yet, but it has the opened up graphic to players that have already opened it before?
In response to MartialArtistAbu
I don't want to give bad advice, but technically this could be done with the invisibility variables. I guess you could use client.images, but you'd have to add the chest to the user's screen which wouldn't really be optimal. I'm gonna leave that part for someone else to answer.
Best response
Invisibility is the wrong tool for the job. I suggest that image() is the better option instead. However, it does require more setup.

What you'll probably need is some kind of area trigger that lets objects know when a player has entered the area, or some way to tell when a player gets within near viewing distance of an "observing" object. Once any player who's opened a chest gets within near viewing distance of it, you'll want to create and apply an image with the override var set, and show that image to that player. When all such players leave the view area, the image can and should be nixed.

obj/chest/oneshot
icon = 'chest.dmi'
density = 1

// unique identifier for this chest
// maybe tag would be better, but screw it
var/chest_id

var/tmp/image/open
var/tmp/list/shownto

// The following procs are assumed to be inherited from obj

// this is called by some kind of global check
PlayerEnteredRange(mob/M)
if(!chest_id) return
if(chest_id in M.found_treasures) ShowOpen(M)

PlayerExitedRange(mob/M)
if(M in shownto) HideOpen(M)

ShowOpen(mob/M)
if(!open)
open = new(src)
open.appearance = appearance
open.icon_state = "open"
open.override = 1
if(!shownto) shownto = list(M)
else shownto[M] = null // add M to shownto list
M << open

HideOpen(mob/M)
if(M.client) M.client.images -= open
if(shownto)
shownto -= M
if(!shownto.len)
shownto = null
open = null

// mob acts on this object--open the chest
Action(mob/M)
if(!chest_id) return
if(chest_id in M.found_treasures) return
if(!M.found_treasures) M.found_treasures = list()
M.found_treasures += chest_id
M.gold += gold // gold var inherited from obj/chest
M << "You find $[gold] inside!"
ShowOpen(M)

That's a fairly limited example and it could stand to be generalized a lot more, but that's the gist of what you'll want to set up.