mob
proc
Update_screen_ammo(mob/m)
var/Ammo=list()
var/aymo=num2text(src.ammo)
var/CX=-(lentext(aymo)*3)
for(var/a=1, a<lentext(aymo)+1, a++)
Ammo+=copytext(aymo,a,a+1)
for(var/X in Ammo)
world<<X
var/obj/onscreenammo/O=new/obj/onscreenammo()
O.screen_loc="23,23"
O.icon_state=X
O.pixel_x=CX
O.pixel_y=-20
CX+=10
m.client.screen+=O
obj
onscreenammo
icon='onscreenammo.dmi'
mob
verb
testit()
Update_screen_ammo(src)
Problem description:
Okay, I just copied and edited this code, because I'm so completely lost when it comes to editing icons with coding. I attempted to change it in to a lovely system where it checks how much ammo you have, then plops in on the client's screen in the top right corner. However I can't seem to figure out how to space the numbers out. Obviously I have no idea what I'm doing, and if there was a guide out there that went in to great definition of how to do this, I'd be happy to read it. Thanks!
I got it working with a work-around.
mob
proc
Update_screen_ammo(mob/m)
for(var/obj/onscreenammo/o in world)
if(o.owner==src)
del o
var/Ammo=list()
var/aymo=num2text(src.ammo)
var/CX=-(lentext(aymo)*3)
var/doublestop
for(var/a=1, a<lentext(aymo)+1, a++)
Ammo+=copytext(aymo,a,a+1)
for(var/X in Ammo)
if(lentext(Ammo)>1&&!doublestop) //got it working with this:
doublestop=1
continue
var/obj/onscreenammo/O=new/obj/onscreenammo()
O.icon_state=X
O.owner=m
O.screen_loc="23:[CX],23"
CX+=10
m.client.screen+=O
obj
onscreenammo
var/owner
icon='onscreenammo.dmi'
To apply a pixel offset to a screen object, you do this in the screen_loc. The format is like this
So, just put this in your code, like so.
Personally, I would make it change the X coordinate of the screen_loc as well, since pixel offsets do have an upper bound (I think it's 192 pixels). Though, that might not be necessary in your case; I don't think you're going to have all of the bullets necessary to make use of all of the digits.