ID:1611943
 
Keywords: basic, button, click, show, window
(See the best response by Lugia319.)
So I made an interface (pretty snazzy too!) with three buttons that I'm eventually going to work out what they do, specifically making a new character, loading one, etc. What I really need is a very simple bit of code that allows me to tell when this button is clicked and do something with it. At the moment I want it to do two things:

Output to the user "you have just clicked New!" (not hard obviously, I know that line of text but with the button scripts ive found this oddly is very hard to do...)

and change the windows visibility to false, at the same time changing another windows visibility to true, thus "switching windows" in a way.

I've tried a couple of different codes I've found, but they are either ridiculously overcomplicated (Something about generating random hashes???) or will work with one of these functions, but oddly not the other. I understand the idea of winset and winshow abit, its just a matter of how do I specify the buttons use as executing these commands? Is there a way to set up a custom proc that I can then use in the buttons actual command thing in the interface editor? I thought of that, but wasn't sure. If someone could please tell me or give me a bit of example code I would really appreciate this! Please and thankyou :)

PS I can also provide screenshots if that helps
Best response
I advise against having a dedicated "New" button on the interface unless you want to make several windows for the process. I'd recommend using screen objects.

But the code you're looking for is this:

mob
verb
NewChar()
set hidden = 1 // So players can't see verb in tabs
src << "You have clicked New!"
winshow(src, "current windowname", 0) // Closes a window
winshow(src, "new windowname", 1) // Opens a window
In the interface is where you can set commands that are executed when a button is pressed. Click a button and press enter (or double-click a button) and go to the farthest right tab. There you'll see an input labeled "Command." This input is where you will put your verb to be called upon pressing the button, using (-) in place of underscores. So putting "someverb" in a button's Command input calls verb/someverb.
What I mean when I say new is that the button is actually called "new" for "New character" in a game. So does putting

New()

automatically know I'm talking about a button called "new" in the window?
Ohhhhh okay so the Command input in the buttons options is for a verb then?
In response to Darklady5
Darklady5 wrote:
Ohhhhh okay so the Command input in the buttons options is for a verb then?

Not only that, it HAS to be a verb.
Alright ill try it out right now..
I tried putting that code in and I just got slammed with a bunch of errors saying "inconsistent indentation"
To add more detail, the buttons ID is "New", and I haven't done any code to refer to the window or anything yet, not sure if something like that is needed?
Woops, I forgot that New() is a built in proc. Change the name, and make sure it's indented properly. I use 2 space indentations, your default settings are 4 space, so you'll need to match them up.

EDIT: Also note that the window names are case sensitive, make sure the windows exist, and match up.
I tried changing it to Newchar, and it still slammed me with errors
How do I "match up"? Do you mean change where you put current windowname, etc?Cause I checked those already.
This is literally the ONLY code I have in the thing atm

mob
Login()
world << "[usr] has just joined the world~"
verb
createnewcharacter()
set hidden = 1 // So players can't see verb in tabs
src << "You have clicked New!"
winshow(src, "loginwindow", 0)
winshow(src, "charactercreate", 1)
errrr...that didn't tab right when I copied and pasted
No, you need to put it into <dm> and </dm> tags

If it's tabbed properly you shouldn't have any errors.
Oh right

mob
Login()
world << "[usr] has just joined the world~"
verb
createnewcharacter()
set hidden = 1 // So players can't see verb in tabs
src << "You have clicked New!"
winshow(src, "loginwindow", 0)
winshow(src, "charactercreate", 1)
But thats literally the ONLY code thats being used atm
And what are the compiler errors? Or are the errors coming up when you click the button? If you click the button and it says "no such verb" or something, then the button's command is incorrectly input, you need to edit that in the skin interface.
loading The After Zone.dme
TAZlogin.dm:7:error: inconsistent indentation
TAZlogin.dm:8:error: inconsistent indentation
TAZlogin.dm:9:error: inconsistent indentation
TAZlogin.dm:10:error: inconsistent indentation
TAZlogin.dm:11:error: inconsistent indentation
The After Zone.dmb - 5 errors, 0 warnings
Try manually tabbing each of the lines over to their proper spots.

I can promise you the code is error free because I've now tested it in my test environment and in an entirely new environment with no issues.
Page: 1 2