ID:1230386
 
(See the best response by Kaiochao.)
Code:
mob
var
Title
AlertInfo
Accept

mob
proc
ShowAlert()
winset(usr,"Alert.Title","text = [Title]")
winset(usr,"Alert.AlertInfo","text = [AlertInfo]")
winset(usr,"Alert.Accept","text = Ok")
winshow(usr,"Alert",1)


mob/verb
Close()
set hidden = 1
winshow(usr,"Alert",0)

mob/verb
Test()
ShowAlert()
Title = "Testing "
AlertInfo ="HMMMMMMM"


Problem description:

Hello guys, I am testing out Interface for the first time and I'm encountering some issues. The first as you might all have noticed by now , is that I didn't necessarily took the best approach while doing this, I did this very messily and just tried to get the overall to work, I know that this will cause me many issues on the road ahead. So first of all, can any of you show me a better approach of handling this? Also, another problem I have yet to figure out how to solve is that, once I click the verb "Test" my results won't show up the first time, instead, I have to re-click the verb, that'll cause it to actually show what it's supposed to show. Anyway, any help will be appreciated, thanks :P
Interface elements are only updated when you tell them to update. This does not change when you assign a variable to them. I advise making a proc that updates all of your elements and call that when you update those variables, like so:
mob
proc
update_interface() // put all the winset() updates here

ShowAlert()
update_interface()
winshow(src, "Alert", 1)


Make sure you aren't using usr in procs, except where usr is what is needed (Like Click()).
Hello Albro1, thanks for the quick response, however, I'm still facing the same difficulties, I updated my code to:
mob/verb
Test()
src.ShowAlert()
Title = "Testing "
AlertInfo ="HMMMMMMM"

// update interface

mob/proc
UpdateInterface()
winset(src,"Alert.Title","text = [Title]")
winset(src,"Alert.AlertInfo","text = [AlertInfo]")
ShowAlert()
UpdateInterface()
winshow(src,"Alert",1)
In response to SillyChild123
Get rid of the spaces in the winsets' text, they don't play nice.
Alright
Thanks for the help but my friend, Galactic Soldier helped me figure out the problem, feeling very stupid right now xD, got fixed with
mob/verb
Test()
Title = "Testing "
AlertInfo ="HMMMMMMM"
src.ShowAlert()

I had the ShowAlert() before I even gave it what to output xD
In response to SillyChild123
Your problem is that you are calling the update before you update the variables.

EDIT: Yeah, there you go.
Anyway, now I'm experiencing a whole new problem, I have just added a child to the map in order to glue the interface to it, it works fine and all but now my alert only displays 1 word :( can you help me out ?
mob/verb
Close()
set hidden = 1
winshow(src,"AlertSpace","is-visibible=false")

mob/verb
Test()
Title = "Welcome~"
AlertInfo ="Why won't you output more than one word :("
src.ShowAlert()

// update interface

mob/proc
UpdateInterface()
winset(src,"Alert.Title","text=[Title]")
winset(src,"Alert.AlertInfo","text=[AlertInfo]")
ShowAlert()
UpdateInterface()
winset(src,"AlertSpace","is-visible=true")


EDIT: Nvm, Galactic Soldier has saved the day once again
The child isn't the problem here. Surround [Title] and [AlertInfo] with apostrophes.
I got it fixed with list2params

winset(src,"Alert.AlertInfo","text[list2params(list(AlertInfo))]")

Did you do what I told you to do?

winset(src,"Alert.AlertInfo", "text='[AlertInfo]'")

There's no sense in calling a proc if you don't have to. Frankly I don't understand how that doesn't give you an error.
When I do it the way you say it still only outputs a section of what I tell it it, it doesn't finish it completely
mob/verb
CreateCharacter()
Title = "Welcome~"
AlertInfo ="Hope you have a great time! Don't forget to help me hunt down bugs :D"
src.ShowAlert()

// update interface

mob/proc
UpdateInterface()
winset(src,"Alert.Title","text='[Title]'")
winset(src,"Alert.AlertInfo","text='[AlertInfo]'")
ShowAlert()
UpdateInterface()
winset(src,"AlertSpace","is-visible=true")


This only shows it all the way till "Don" think the apostrophe might be the reason behind this.

EDIT: just tested, Yup, it works when I remove the apostrophe from "don't":D
In response to SillyChild123
Best response
Instead of using apostrophes, you can replace them with \". It's an escaped quote. It's all explained in the reference entry for winset().
*Ahem*

Kaiochao wrote:
Instead of using apostrophes, you can replace them with \". It's an escaped quote. It's all explained in the reference entry for winset().

If I disagreed with him I would've said so.
Why not something like this:
mob/verb
CreateCharacter()
src.ShowAlert("Welcome~","Hope you have a great time! Don't forget to help me hunt down bugs :D") // Welcome is the title, and the rest after the coma, is the info

// update interface

mob/proc
ShowAlert(var/T,var/I) // T is going to be the title, and I is the info inside the alert.
winset(src,"AlertSpace","is-visible=true")
winset(src,"Alert.Title","text='[T]'")
winset(src,"Alert.AlertInfo","text='[I]'")


This is a lot better because you won't need to create a new proc every time.Using the same proc, you can change the text like this:
src.ShowAlert("Changed Text","I just created the exact same proc with different text, in 1 line of code.")

Hmm, that works too KidPaddle xD, Frankly, I have like 3 methods of doing this now xD, thanks for all the help and support guys :P
In response to Kidpaddle45
That would still cause issues because of the apostrophe in "Don't". You need to use escaped quotes like Kaiochao suggested.
Oh yeah I'm sorry i didn't read what you guys said above.
Yeah use the escaped quotes.
Funny, because when I tried your snippet that supposedly 'hacked' the interface with escaped quotes, this is what happened:

var/a = "Hey';background-color=#FFFFFF"
winset(src, "window1.label1", "text=\"[a]\"")


Here's a screenshot of this 'hack'.
I never said yours was wrong, because it indeed works. It is also a valuable piece of information for future reference.

However in the case of his application here, I have no clue as to why he would use an escaped quote inside of the message. He isn't using player input here, he's putting his own message in. As such, either of our ways would suffice.
Page: 1 2