ID:270998
 
How do I make it where, you click a button in-game and it does a verb?
King of Slimes wrote:
How do I make it where, you click a button in-game and it does a verb?

Set the button as an object or turf, and in the object use the Click() or DblClick() command. It would be a good idea to make the verb instead into a proc, so you could just call that proc instead. This way you could make it so players could use the button and/or the command verb.
In response to FriesOfDoom
FriesOfDoom wrote:
King of Slimes wrote:
How do I make it where, you click a button in-game and it does a verb?

Set the button as an object or turf, and in the object use the Click() or DblClick() command. It would be a good idea to make the verb instead into a proc, so you could just call that proc instead. This way you could make it so players could use the button and/or the command verb.

Thanks.

One last HUD question.

How do I put the button on the map thats 100x100 but its always on 1,4,1?
In response to King of Slimes
Actual HUDs are NOT meant to be placed on maps.
HUD
parent_type=/atom/movable // so it has the screen_loc variable
icon='HUD.dmi'
worldSay //Say HUD
icon_state="WS"
screen_loc="SOUTH,WEST+3" //Placement of the HUD in the client's screen\
1,4 in dynamic settings [like if person has an option to change screen size]. If the size always stays the same, you can make it 1,4 if you want

Click() Say() //calls the say verb Say()

var/HUDList[0] //an array list
world/New()
..()
for(var/HUD/A in typesof(/HUD)-/HUD) //Loops through the /HUD datum
HUDList+=new A //creates a new instance of the object in the list

mob/Login()
.=..()
if(.&&client) //if it's continues successfully and src is has a client [safety check]
for(var/HUD/H in HUDList) //Searches through the HUDList
client.screen+=H //Adds the object to the client screen


- GhostAnime
In response to GhostAnime
GhostAnime wrote:
Actual HUDs are NOT meant to be placed on maps.
HUD
> parent_type=/atom/movable // so it has the screen_loc variable
> icon='HUD.dmi'
> worldSay //Say HUD
> icon_state="WS"
> screen_loc="SOUTH,WEST+3" //Placement of the HUD in the client's screen\
> 1,4 in dynamic settings [like if person has an option to change screen size]. If the size always stays the same, you can make it 1,4 if you want

> Click() Say() //calls the say verb Say()
>
> var/HUDList[0] //an array list
> world/New()
> ..()
> for(var/HUD/A in typesof(/HUD)-/HUD) //Loops through the /HUD datum
> HUDList+=new A //creates a new instance of the object in the list
>
> mob/Login()
> .=..()
> if(.&&client) //if it's continues successfully and src is has a client [safety check]
> for(var/HUD/H in HUDList) //Searches through the HUDList
> client.screen+=H //Adds the object to the client screen

- GhostAnime

<Newbie alert> How do I define a proc?
In response to King of Slimes
Er, what type of proc?:
mob/proc  //a mob procedure
atom/proc
area/proc
turf
atom/movable/proc //this falls for /mob and /obj
obj/proc
proc //think this as a global proc
global/proc
static/proc
proc/proc // :P just kidding


- GhostAnime
In response to GhostAnime
GhostAnime wrote:
Er, what type of proc?:
mob/proc  //a mob procedure
> atom/proc
> area/proc
> turf
> atom/movable/proc //this falls for /mob and /obj
> obj/proc
> proc //think this as a global proc
> global/proc
> static/proc
> proc/proc // :P just kidding

- GhostAnime

Your code thing says Say is a undefined proc.
In response to King of Slimes
My code is an EXAMPLE, meaning it was not suppose to be copied nearly the exact same way... but I'll shed some light as why it did not use the mob/verb/Say() which you have:

It's datum is HUD not mob

Say() is referring to src.Say()... however, if I made it usr.Say(), which usr is safe in Click()...

- GhostAnime
In response to GhostAnime
GhostAnime wrote:
My code is an EXAMPLE, meaning it was not suppose to be copied nearly the exact same way... but I'll shed some light as why it did not use the mob/verb/Say() which you have:

It's datum is HUD not mob

Say() is referring to src.Say()... however, if I made it usr.Say(), which usr is safe in Click()...

- GhostAnime

Erm, it isnt putting the icon on the screen so I can click it >_>
In response to King of Slimes
usr.client.screen += new /atom/movable/HUD


thats how I add it to the screen

but usr might not be safe to use, but I can never figure out exactly how to not use usr
In response to KirbyAllStar
http://bwicki.byond.com/ByondBwicki.dmb?WhatIsUsr

As you can see, usr is the last client who did something.. meaning it's safe to use in verb, Click() and DblClick() as it is prosecuted exactly when it was clicked, thus making usr = the appropriate client.

However, if something is to be called indirectly/delayed or can be called by anything that is NOT a client (such as Bump()), it can lead to unwanted results.

- GhostAnime
In response to GhostAnime
Ah so if I have proc called Join() and it is called in login, so the player can pick a character it is safe to use usr?
In response to KirbyAllStar
just make a say() proc.
mob
proc
say()
var/msg = input("?")as null|text
if(msg)world<<msg
In response to Xx Dark Wizard xX
Just wondering what that has to do with my question?
In response to KirbyAllStar
KirbyAllStar wrote:
Ah so if I have proc called Join() and it is called in login, so the player can pick a character it is safe to use usr?

Login() is one of those "neutral procs". In theory it's always safe to use usr in it, but it's best to use src: Login() may still be called by another part in the code and it would mean usr could be invalid or null. As a rule of thumb I'd advise to use src whenever possible, and thus extend this to use it in Login() as well.

Your Join() proc is as you just said a proc. It would be best to use src or an argument whenever possible.
In response to Xx Dark Wizard xX
That wouldn't work, as Say() is referring to the source's Say() verb/proc, not a mob's...

and as I said before, the source is NOT a mob, it's /HUD (and it's parent type if /atom/movable since I forced it to move to that family :( )

- GhostAnime
In response to GhostAnime
GhostAnime wrote:
Actual HUDs are NOT meant to be placed on maps.
HUD
> parent_type=/atom/movable // so it has the screen_loc variable
> icon='HUD.dmi'
> worldSay //Say HUD
> icon_state="WS"
> screen_loc="SOUTH,WEST+3" //Placement of the HUD in the client's screen\
> 1,4 in dynamic settings [like if person has an option to change screen size]. If the size always stays the same, you can make it 1,4 if you want

> Click() Say() //calls the say verb Say()
>
> var/HUDList[0] //an array list
> world/New()
> ..()
> for(var/HUD/A in typesof(/HUD)-/HUD) //Loops through the /HUD datum
> HUDList+=new A //creates a new instance of the object in the list
>
> mob/Login()
> .=..()
> if(.&&client) //if it's continues successfully and src is has a client [safety check]
> for(var/HUD/H in HUDList) //Searches through the HUDList
> client.screen+=H //Adds the object to the client screen

- GhostAnime

I have a guestion about the...
  worldSay  //Say HUD

...part.
Does this make it so that if the player types in "HUD" in the bar below it will activate the proc instead of having to click?
In response to FriesOfDoom
That's an object... AN OBJECT!! >_>

Here's a basic translation of what I just said:
atom/movable/HUD  //Not quite, it's more like /HUD being an alias for atom/movable.. but meh

icon='HUD.dmi'

worldSay
icon_state="WS"
screen_loc="SOUTH,WEST+3"
Click() Say()


And to answer your question, No... unless they typed in ".click worldSay"

- GhostAnime