ID:1209841
 
Keywords: background, map
(See the best response by Ter13.)
So I have a map that I want completely covered with a background and the player can click on any tile on the map and spawn an object. This is supposed to basically be an editor for a spaceship, where a player can build the walls of the ship with the background being a high definition spacey image.

I've tried doing it a few ways, but they're all rough and pretty stupid to be honest. If anyone could explain a way to implement this or give any tips in dealing with backgrounds on a map it'd be much appreciated.


Also, for some reason when I use the below method clicking a Space object does nothing when it should spawn a Chasis. If I use this method with Space being a turf it works though, so I'd appreciate help with this as well.

obj
Space
icon = 'Icon1.dmi'
icon_state = "space"
Click()
new /obj/Chasis(src)
Chasis
icon = 'Icon1.dmi'
icon_state = "chasis"
step_size = 8

turf
Background
icon = 'Background.png'
It is not working because you have passed src as an argument, where you really meant to pass src.loc, or simply loc.

Not sure what you really want to get to with this, but I think this would be fine:

client
var
atom/selection as mob|obj|turf
Click(atom/A)
if(!A.is_buildable) return ..()
else if(selection) new selection.type(isturf(A) ? A : A.loc)
proc/SetSelection(atom/atom)if(atom && istype(atom))selection = atom

atom/var
is_buildable = FALSE
is_selectable = FALSE

obj/Space
icon = 'Icon1.dmi'
icon_state = "space"
is_buildable = TRUE
obj/Chasis
icon = 'Icon1.dmi'
icon_state = "chasis"
is_selectable = TRUE


Do not copy paste this in, just wanted to provide some functionality examples. Without further explanation about how things are meant to work, this is what I can offer you, feel free to reply back if you need anything else.
I'll try what you suggested and get back to you. Could you give any help on the background thing though? I want to basically have a background behind my map that's always there and doesn't affect anything. I've tried doing it with HUDs, but I'm not too familiar with them.

I learn best by studying an example, and don't worry I don't copy paste scripts.

If it wouldn't be too much trouble, could you put some comments explaining what's going on here step by step? I understand most of it, but some things go over my head. Pardon my ignore, I'm returning to this language after a while away.
Fushimi wrote:
    Click(atom/A)
> if(!A.is_buildable) return ..()
> else if(selection) new selection.type(isturf(A) ? A : A.loc)
> proc/SetSelection(atom/atom)if(atom && istype(atom))selection = atom
client
var
atom/selection as mob|obj|turf
Click(atom/A)
if(!A.is_buildable) return ..(A) // If the clicked turf, obj or mob is not a buildable atom, we return the default Click() behavior passing A again.

else if(selection) new selection.type(isturf(A) ? A : A.loc)
//Otherwise we check if we have a buildable object selected, if true, we create a new fresh copy of said selection, calling new selection.type (If A is a turf we return the turf as an argument, otherwise we pass the atom's loc)
proc/SetSelection(atom/atom)if(atom && istype(atom))selection = atom
//We woulc typically use this, like this:

obj/randomobject/verb/PlaceonMap()
set src in oview(0)
usr.client.SetSelection(src) //Sets our current object to randomobject.
//Then, we click on a turf that has a is_buildable variable set to 1 or true, we place the selected object over clicked turf/obj/mob.
Anything for backgrounds? I honestly can't get it to work for the life of me. I've been trying to create an object with an icon of my background and then add it to client.screen, but nothing actually happens. Is there some kind of demo on HUDs that you could link me to?
You don't need to use a screen object to do this. Look up Client.Click(). That will allow you to grab client clicks any time the player clicks on anything anywhere.
I apologize as I should've made this clear from the beginning and is probably causing confusion, but I actually have two problems I'm trying to fix.

The second problem I had was with getting the player's clicks and spawning objects. This has been solved and I appreciate all the help with it.

The first problem and the one I'm still having trouble with is putting a background behind my map, which has nothing to do with player clicks. I'm basically trying to get a battle back that you'd see in a take turn game like final fantasy or something, where there's a detailed non-tiled background and the mobs/objects move around on top of it.

I've tried using client.screen, but I cannot get it to work. Below is someone's short script example of client.screen, but when I run it and use the test_background verb nothing happens.

obj
background
icon = 'Icon1.dmi' //this image file can be large enough to cover the entire map

mob
verb
test_background()
var/obj/Background/b = new
client.screen += b //add the object to src's screen
Best response
You need to supply a screen_loc to any object you add to the screen. Look it up in the reference.