ID:142751
 
Code:
                if(usr.Ships.len)
var/i
for(i=1,i<=usr.Ships.len,i++)
var/mob/Ships/S = usr.Ships[i]
var/list/params = new
params["parent"] = "Merch"
params["type"] = "button"
params["command"] = "say \"This is a new button.\""
params["pos"] = "140+([i*36]),15"
params["size"] = "32x32"
params["anchor1"] = "0,0"
params["image"] = "[S.icon]"
winset(usr, "newbutton[i]", list2params(params))


Problem description:

I have three ships, so it should make three buttons each with [S.icon] as their image. Instead it makes only one button, and the image on it is kinda a cut between two of the directions within S's icon file... any idea why this is happening?

No idea why, but you can make your params list wayyy smaller?

                        var/list/params = list("parent"="Merch","type"="button")//etc
In response to Tubutas (#1)
I gotta admit, I just kinda copy and pasted it from the Skin Reference, but (obviously) bringing it all down to one line won't effect much. (Though I will do it, to clean up the code)

~Ease~
I think I can answer your questions.

As to why you've got the icon directions kind of jumbled together, there's a simple explanation: Remember, your icon is basically a big PNG file. At the interface end, BYOND has no way of knowing that you want only one of the still frames inside of that icon, so it's showing the entire thing, either cropped or compressed (probably cropped) to fit the button. Solution: Use a dedicated single-frame icon without directions and such.

I can spot the other problem, but it might not be as clear to you if you're not aware of the limitations of the skin parser:

params["pos"] = "140+([i*36]),15"


That's going to look like "140+(0),15", "140+(36),15", etc. The parser has no idea how to handle that, because it doesn't do calculations. As soon as it hits the + it assumes the X coordinate is done, so it's thinking you mean "140,15" each time. Solution: Do the whole calculation, not just the multiplication part, inside the brackets. Then DM can do it for you, and create strings like "140,15", "176,15", etc. that the parser understands.

Lummox JR
In response to Lummox JR (#3)
Thanks LJR. I've got the positioning working perfectly, but for the life of me I can't get the icon to work. I have a dedicated single dir icon ('HUD.dmi',"1") and no matter what I try it doesn't work. I've tried images, icons, even making it an object. The nearest I've come is to having some random crop of an icon I can't identify (not "1", and doesn't even look like its from 'HUD.dmi') on the buttons.

~Ease~
In response to Ease (#4)
Ease wrote:
Thanks LJR. I've got the positioning working perfectly, but for the life of me I can't get the icon to work. I have a dedicated single dir icon ('HUD.dmi',"1") and no matter what I try it doesn't work.

Are you sure that's just a single dir? That looks like you've narrowed it down to a single icon_state but not a single dir, single animation.

Lummox JR
In response to Lummox JR (#5)
Well "1" is just a single icon_state. No directions or animations or anything.

~Ease~
In response to Ease (#6)
I've been manipulating it further, and I still can't quite get it to work.

<Solved>Had to put the image in with ' instead of " into the params for some queer reason.</Solved>

~Ease~