ID:2961655
 
(See the best response by Kozuma3.)
Code:
mob
var/tmp/selected_emote // Stores the selected emote icon

verb
Emote()
set name = "Emote"
set category = "Communication"

// Display the emote selection window
var/html = "<html><body>"
html += "Select an emote:<br>"

// Define available emote states from the emotes.dmi file
var/list/emotes = list("Alert", "Shocked", "Upset", "Awkward")

// Create buttons for each emote
for (var/emote_name in emotes)
html += "<button onclick='.?set_emote=[emote_name]'>[emote_name]</button><br>"

html += "</body></html>"

// Show the HTML to the player
src << browse(html, "window=emote_selection")

proc
HandleTopic(href)
if (!href) return // Ensure href is valid
if (findtext(href, "set_emote=")) // Check for the set_emote key
var/emote_name = copytext(href, findtext(href, "set_emote=") + 10)

// Validate the emote selection
var/list/emotes = list("Alert", "Shocked", "Upset", "Awkward")
if (emote_name in emotes)
selected_emote = icon('Icons/emotes.dmi', emote_name) // Select the icon state
src.overlays += selected_emote // Add the selected emote icon as an overlay
src << "You selected the [emote_name] emote."
else
src << "Invalid emote selection."

world
Topic(href, href_list[])
..() // Call the built-in Topic for other handling

// Debug: Print the received href to ensure the button click is working
if (href)
world << "Topic href: [href]"

// Forward the Topic call to the appropriate player mob
for (var/mob/m in world)
if (istype(m) && m.client)
m.HandleTopic(href)


Problem description:
At the moment the verb works as follows
Click emote
a window opens displaying buttons for each emote
Clicking the button does nothing at the moment.



Preview:
https://i.imgur.com/BJS60qn.png

What I'd like it to do
I'd like to be able to input the command /emote "state name"
and the state within the icon file display above the players head.
I'd like players to be able to input this command in Say and OOC as well and get the same functions.

I'd like /emote by itself to display a tutorial for the command in the chat.

I'm pretty sure this code would be remade to display the emote said in the chat or command window but I wouldnt know how to go about it.

Can anyone help me achieve this?
Best response
mob/verb/Emote()
var list/emotes = list("Alert","Shocked","Upset","Awkward")
var html = "Select an emote:<br>"
for(var/emote in emotes)
html += "<a href=?set_emote=[emote]>[emote]</a><br>"
src << browse(html, "window=emote_selection")

client/Topic(_,list/l)
if(l.Find("set_emote"))
world << "You clicked [l["set_emote"]]"
In response to Kozuma3
I replaced my code with yours and got this

https://i.imgur.com/1UHTasj.png

My goal was the bar at the very bottom that you can write in. Making the command capable to be input there with or without say", ooc".

The command is /emote
like /emote Alert

I'd like /emote when input alone to open the window with a tutorial on the command use.

Just a window with
Use "/emote" with these words to display emotes
"Alert"
"Shocked"
etc

Login to reply.