ID:171064
 
I have this random icon picker thing and anyway, It randomly puts RGB in your icon right, but I have this arrow also that I want added over the person and have its color the same as the player. Also if this isnt hard (I have it so the arrow goes on the player on the players screen, how can I make it go A SPACE OVER the player on there screen?)


Heres what I attempted.

var/image/I
var/image/T

mob
verb
join()
if(alreadystarted == 0)
if(src.alreadyjoined == 1)
return
else
world << "[src] is playing."
src.iconpick()
playing += 1
src.alreadyjoined = 1
src.loc = locate(1,2,1)
src.density = 1
return
else
return




proc
iconpick()
var/icon/I = rand(1,26)
if(I == 1)
src.icon_state = "A"
if(I == 2)
src.icon_state = "B"
if(I == 3)
src.icon_state = "C"
if(I == 4)
src.icon_state = "D"
if(I == 5)
src.icon_state = "E"
if(I == 6)
src.icon_state = "F"
if(I == 7)
src.icon_state = "G"
if(I == 8)
src.icon_state = "H"
if(I == 9)
src.icon_state = "I"
if(I == 10)
src.icon_state = "J"
if(I == 11)
src.icon_state = "K"
if(I == 12)
src.icon_state = "L"
if(I == 13)
src.icon_state = "M"
if(I == 14)
src.icon_state = "N"
if(I == 15)
src.icon_state = "O"
if(I == 16)
src.icon_state = "P"
if(I == 17)
src.icon_state = "Q"
if(I == 18)
src.icon_state = "R"
if(I == 19)
src.icon_state = "S"
if(I == 20)
src.icon_state = "T"
if(I == 21)
src.icon_state = "U"
if(I == 22)
src.icon_state = "V"
if(I == 23)
src.icon_state = "W"
if(I == 24)
src.icon_state = "X"
if(I == 25)
src.icon_state = "Y"
if(I == 26)
src.icon_state = "Z"
var/R = rand(1,200)
var/B = rand(1,200)
var/G = rand(1,200)
src.icon +=rgb (R,G,B)//Edit after this line
T = new('arrow.dmi',src)
T += rgb(R,G,B)
src.client.images += T



Thanks all!
Try src.overlays+=?
Or src.client.screen or whatever it was.
In response to Hell Ramen (#1)
Did you understand what I meant?
In response to XxDohxX (#2)
obj
arrow
var/A
var/S
var/D
src.icon = rgb(A,S,D)
src.pixel_y = 32

:o Then set the "A", "S", and "D" variables to the RGB, and wallah, it should work. >_>
[EDIT]OOOOH, or you could do T.pixel_y = 32
I think.
In response to Hell Ramen (#3)
According to what you said, this is what I tryed, but Im getting a runtime error and it doesnt show up.


var/image/I
var/image/T
obj
arrow
icon = 'arrow.dmi'
mob
verb
join()
if(alreadystarted == 0)
if(src.alreadyjoined == 1)
return
else
world << "[src] is playing."
src.iconpick()
playing += 1
src.alreadyjoined = 1
src.loc = locate(1,2,1)
src.density = 1
return
else
return




proc
iconpick()
var/icon/I = rand(1,26)
if(I == 1)
src.icon_state = "A"
if(I == 2)
src.icon_state = "B"
if(I == 3)
src.icon_state = "C"
if(I == 4)
src.icon_state = "D"
if(I == 5)
src.icon_state = "E"
if(I == 6)
src.icon_state = "F"
if(I == 7)
src.icon_state = "G"
if(I == 8)
src.icon_state = "H"
if(I == 9)
src.icon_state = "I"
if(I == 10)
src.icon_state = "J"
if(I == 11)
src.icon_state = "K"
if(I == 12)
src.icon_state = "L"
if(I == 13)
src.icon_state = "M"
if(I == 14)
src.icon_state = "N"
if(I == 15)
src.icon_state = "O"
if(I == 16)
src.icon_state = "P"
if(I == 17)
src.icon_state = "Q"
if(I == 18)
src.icon_state = "R"
if(I == 19)
src.icon_state = "S"
if(I == 20)
src.icon_state = "T"
if(I == 21)
src.icon_state = "U"
if(I == 22)
src.icon_state = "V"
if(I == 23)
src.icon_state = "W"
if(I == 24)
src.icon_state = "X"
if(I == 25)
src.icon_state = "Y"
if(I == 26)
src.icon_state = "Z"
var/R = rand(1,200)
var/B = rand(1,200)
var/G = rand(1,200)
src.icon +=rgb (R,G,B)
T = new(/obj/arrow ,src)
T += rgb(R,G,B)
src.client.images += T
T.pixel_y = 32



Runtime error:
<font color = "Red">

runtime error: type mismatch
proc name: iconpick (/mob/proc/iconpick)
source file: Block Falling.dm,180
usr: XxDohxX (/mob/player)
src: XxDohxX (/mob/player)
call stack:
XxDohxX (/mob/player): iconpick()
XxDohxX (/mob/player): join()
</font>


Help with all this is appreciated!
Well, if I understand you correctly, the best way to have the arrow be located a space above the user would be to make a new arrow, set its pixel_y to 32, rgb the icon, and then, add it to the player as an overlay(src.overlays+=/obj/arrow). So assuming that arrows are defined as /obj/arrow,

mob
proc
iconpick()
var/icon/I = rand(1,26)
if(I == 1)
src.icon_state = "A"
if(I == 2)
src.icon_state = "B"
if(I == 3)
src.icon_state = "C"
if(I == 4)
src.icon_state = "D"
if(I == 5)
src.icon_state = "E"
if(I == 6)
src.icon_state = "F"
if(I == 7)
src.icon_state = "G"
if(I == 8)
src.icon_state = "H"
if(I == 9)
src.icon_state = "I"
if(I == 10)
src.icon_state = "J"
if(I == 11)
src.icon_state = "K"
if(I == 12)
src.icon_state = "L"
if(I == 13)
src.icon_state = "M"
if(I == 14)
src.icon_state = "N"
if(I == 15)
src.icon_state = "O"
if(I == 16)
src.icon_state = "P"
if(I == 17)
src.icon_state = "Q"
if(I == 18)
src.icon_state = "R"
if(I == 19)
src.icon_state = "S"
if(I == 20)
src.icon_state = "T"
if(I == 21)
src.icon_state = "U"
if(I == 22)
src.icon_state = "V"
if(I == 23)
src.icon_state = "W"
if(I == 24)
src.icon_state = "X"
if(I == 25)
src.icon_state = "Y"
if(I == 26)
src.icon_state = "Z"
var/R = rand(1,200)
var/B = rand(1,200)
var/G = rand(1,200)
src.icon +=rgb (R,G,B)
var/A=new/obj/Arrow()//Create an arow
A.pixel_y=32//Set its pixel offset
A.icon+=rgb(R,G,B)//RGB it
src.overlays+=A//Add it to src as an overlay


That's all you need :)
In response to Wizkidd0123 (#5)
Yeah but how you do it, it makes it so ALL people can see it, I want it only to src. Also gives me a runtime..



Updated coding:
var/image/I
var/image/T
obj
arrow
icon = 'arrow.dmi'
mob
verb
join()
if(alreadystarted == 0)
if(src.alreadyjoined == 1)
return
else
world << "[src] is playing."
src.iconpick()
playing += 1
src.alreadyjoined = 1
src.loc = locate(1,2,1)
src.density = 1
return
else
return




proc
iconpick()
var/icon/I = rand(1,26)
if(I == 1)
src.icon_state = "A"
if(I == 2)
src.icon_state = "B"
if(I == 3)
src.icon_state = "C"
if(I == 4)
src.icon_state = "D"
if(I == 5)
src.icon_state = "E"
if(I == 6)
src.icon_state = "F"
if(I == 7)
src.icon_state = "G"
if(I == 8)
src.icon_state = "H"
if(I == 9)
src.icon_state = "I"
if(I == 10)
src.icon_state = "J"
if(I == 11)
src.icon_state = "K"
if(I == 12)
src.icon_state = "L"
if(I == 13)
src.icon_state = "M"
if(I == 14)
src.icon_state = "N"
if(I == 15)
src.icon_state = "O"
if(I == 16)
src.icon_state = "P"
if(I == 17)
src.icon_state = "Q"
if(I == 18)
src.icon_state = "R"
if(I == 19)
src.icon_state = "S"
if(I == 20)
src.icon_state = "T"
if(I == 21)
src.icon_state = "U"
if(I == 22)
src.icon_state = "V"
if(I == 23)
src.icon_state = "W"
if(I == 24)
src.icon_state = "X"
if(I == 25)
src.icon_state = "Y"
if(I == 26)
src.icon_state = "Z"
var/R = rand(1,200)
var/B = rand(1,200)
var/G = rand(1,200)
src.icon +=rgb (R,G,B)
T=new/obj/arrow()
T.pixel_y=32
T.icon+=rgb(R,G,B)
src.client.images += T


Runtime Error:
<font color = "red">
runtime error: wrong type of value for list
proc name: iconpick (/mob/proc/iconpick)
source file: Block Falling.dm,182
usr: XxDohxX (/mob/player)
src: XxDohxX (/mob/player)
call stack:
XxDohxX (/mob/player): iconpick()
XxDohxX (/mob/player): join()
</font>


Thanks for trying by the way...
In response to XxDohxX (#6)
What line is the error on?

If I remember images correctly to show only to the player, you output them, not add them to a list.

T=new /obj/arrow()
T.pixel_y=32
T.icon+=rgb(R,G,B)
var/Blah=image(T.icon,src)
src<<Blah


Try that.
In response to Airjoe (#7)
Worked, yet it still appears on the same turf as the player, maybe setting its location to src.y+=1?
In response to XxDohxX (#8)
That might work, but I don't think the arrow will move with the player.
Give it a shot.
image(T.icon,locate(src.x,src.y+1,src.z))
In response to Airjoe (#9)
Doesnt move with the player...now what?
In response to XxDohxX (#10)
I'm not sure how you'd move an image. Wait...

mob/var/Blah

then in the iconpick proc, don't define Blah, just set it. Set the R,G,B vars as mob vars, not temporary proc vars. Then, in mob/Move()

mob/Move()
.=..()
Blah=null
Blah=image() //then just reset it
In response to Airjoe (#7)
That would make an image out of an icon. The problem is, pexil_y isn't connected to the icon, so it would stay on the same turf as the user.
In response to Airjoe (#11)
That solution would work, Airjoe, but since he's doing a game with so much moving around, that would cauise alot of lag; probably too much for the type of game.
In response to XxDohxX (#6)
The problem here is that /image types are purely visual procs. They can take into account location, icon and icon_state, but that's about it. Unfortunately, pixel offsets(pixel_y and pixel_x) aren't connected in any way to /image types.

Therefore, you would need to use client.screen, and you would need to create a ticker to update the arrow's screen_loc, accounting for pixel_y values using a colon(:).

Sorry, if I wasn't clear, but what youre trying to do is actually rather difficult.
I see that you have gotten some help already, so I'm just pitching in a little code optimizing thing. Instead of all those if-statements in iconpick(), use ASCII and end up with this:

var/I = rand(1,26)
src.icon_state = ascii2text(I+64)



/Gazoot
In response to XxDohxX (#6)
You shouldn't be using an image for the arrow since images can't have pixel offsets. What you need is a pixel offset.
In response to Wizkidd0123 (#16)
Wizkidd0123 wrote:
You shouldn't be using an image for the arrow since images can't have pixel offsets. What you need is a pixel offset.

He could use a .png for the arrow.
Make it 64x64, the bottom 32x32 make it invisible, the above 32x32 make it the arrow. :0
In response to Hell Ramen (#17)
Meh, thatd work sure! But uh, I dont know how to make it so only the player sees it, on his/her screen.
Sorry, I was thinking about it, and I found it extremely difficult to use with client.screen_loc(Probably impossible, actually). Then I asked for a feature request on Design Philosophy, and once I got some answers, clicked the DM Ref definition of atom/image and image(). I then noticed the words "explicitly to the target" Apparently, if you did something like the following code, it would only show it to src.
var/I=new/image
src << I


Knowing that, the problem became simple. Here's the fix:

    proc
iconpick()
var/icon/I = rand(1,26)
if(I == 1)
src.icon_state = "A"
if(I == 2)
src.icon_state = "B"
if(I == 3)
src.icon_state = "C"
if(I == 4)
src.icon_state = "D"
if(I == 5)
src.icon_state = "E"
if(I == 6)
src.icon_state = "F"
if(I == 7)
src.icon_state = "G"
if(I == 8)
src.icon_state = "H"
if(I == 9)
src.icon_state = "I"
if(I == 10)
src.icon_state = "J"
if(I == 11)
src.icon_state = "K"
if(I == 12)
src.icon_state = "L"
if(I == 13)
src.icon_state = "M"
if(I == 14)
src.icon_state = "N"
if(I == 15)
src.icon_state = "O"
if(I == 16)
src.icon_state = "P"
if(I == 17)
src.icon_state = "Q"
if(I == 18)
src.icon_state = "R"
if(I == 19)
src.icon_state = "S"
if(I == 20)
src.icon_state = "T"
if(I == 21)
src.icon_state = "U"
if(I == 22)
src.icon_state = "V"
if(I == 23)
src.icon_state = "W"
if(I == 24)
src.icon_state = "X"
if(I == 25)
src.icon_state = "Y"
if(I == 26)
src.icon_state = "Z"
var/R = rand(1,200)
var/B = rand(1,200)
var/G = rand(1,200)
src.icon +=rgb (R,G,B)
var/image/A=image('MyArrowIcon.dmi',src)
A.pixel_y=32//Set its pixel offset to 32
A.icon+=rgb(R,G,B)
src << A//Show the image to src and only to src
Page: 1 2