ID:264853
 

I am currently displaying the players inventory as 8 slots on their interface using 8 labels. I use the code :

            winset(src,"MainWindow.1","text=[Slot1]")
winset(src,"MainWindow.1A","text=[Slot1A]")
winset(src,"MainWindow.2","text=[Slot2]")
winset(src,"MainWindow.2A","text=[Slot2A]")
winset(src,"MainWindow.3","text=[Slot3]")
winset(src,"MainWindow.3A","text=[Slot3A]")
winset(src,"MainWindow.4","text=[Slot4]")
winset(src,"MainWindow.4A","text=[Slot4A]")
winset(src,"MainWindow.5","text=[Slot5]")
winset(src,"MainWindow.5A","text=[Slot5A]")
winset(src,"MainWindow.6","text=[Slot6]")
winset(src,"MainWindow.6A","text=[Slot6A]")
winset(src,"MainWindow.7","text=[Slot7]")
winset(src,"MainWindow.7A","text=[Slot7A]")
winset(src,"MainWindow.8","text=[Slot8]")
winset(src,"MainWindow.8A","text=[Slot8A]")


This code fills all 8 slots with the required text and another 8 with how many of that object there are.


The problem is that I want to add an extension " " to this text. I do so using this :

    verb
Slot1()
usr.Slot1 += " <Selected>"
Update_Stats()


However.. Due to the space at the start of this extra string, nothing happens. When the space is removed or replaced with an underscore, the text is displayed but only then. I need that space to keep the item name and the add on separate, like :

"BroadSword "

What am I doing wrong? Thanks.
I believe the issue is being caused because you aren't quoting the value you're setting text to. winset() is really wonky and finicky about this sort of thing. You'll need to do something along the lines of:
winset(src, "MainWindow.1", {"text="[Slot1]""})
//or
winset(src, "MainWindow.1", "text=\"[Slot1]\"")

To make sure you're setting text to the entire value of the string you're sending at it (including internal spaces of said string).

Besides that heres a little something for you to examine:
var/winsetText
for(var/x = 1, x <= 8, x++)
winsetText += {"MainWindow.[x].text="[vars["Slot[x]"]]";"}
winsetText += {"MainWindow.[x]A.text="[vars["Slot[x]A"]]";"}
winset(src, null, winsetText)
In response to Vermolius
Yea, that's working fine now. Cheers.


About the second part to your post, that's a very interesting way of doing it but here's why I'm taking the straight forward approach :

mob
proc
Update_Stats()
winset(src,"MainWindow.Name","text=[Name]")
winset(src,"MainWindow.Level","text=[Level]")
winset(src,"MainWindow.Exp","text=[Exp]")
winset(src,"MainWindow.Next","text=[Next]")
winset(src,"MainWindow.Race","text=[Race]")
winset(src,"MainWindow.Class","text=[Class]")

winset(src,"MainWindow.Health","text=[Health]")
winset(src,"MainWindow.MaxHealth","text=[MaxHealth]")
winset(src,"MainWindow.Mana","text=[MaxMana]")
winset(src,"MainWindow.MaxMana","text=[MaxMana]")
winset(src,"MainWindow.Attack","text=[Attack]")
winset(src,"MainWindow.Defense","text=[Defense]")

winset(src,"MainWindow.Space","text=[Space]")

winset(src,"MainWindow.1","text=[Slot1]")
winset(src,"MainWindow.1A","text=[Slot1A]")
winset(src,"MainWindow.2","text=[Slot2]")
winset(src,"MainWindow.2A","text=[Slot2A]")
winset(src,"MainWindow.3","text=[Slot3]")
winset(src,"MainWindow.3A","text=[Slot3A]")
winset(src,"MainWindow.4","text=[Slot4]")
winset(src,"MainWindow.4A","text=[Slot4A]")
winset(src,"MainWindow.5","text=[Slot5]")
winset(src,"MainWindow.5A","text=[Slot5A]")
winset(src,"MainWindow.6","text=[Slot6]")
winset(src,"MainWindow.6A","text=[Slot6A]")
winset(src,"MainWindow.7","text=[Slot7]")
winset(src,"MainWindow.7A","text=[Slot7A]")
winset(src,"MainWindow.8","text=[Slot8]")
winset(src,"MainWindow.8A","text=[Slot8A]")

winset(src,"MainWindow.Head","text=[Head]")
winset(src,"MainWindow.Body","text=[Body]")
winset(src,"MainWindow.Legs","text=[Legs]")
winset(src,"MainWindow.LeftHand","text=[LeftHand]")
winset(src,"MainWindow.RightHand","text=[RightHand]")


If they were the only values I was trying to do then I would use your way but for now this is good. O and this is the old style, using your new way thanks.