ID:2048234
 
(See the best response by Nadrew.)
Hey guys, Its been along time since I've been on BYOND, and Im trying to remember how to do a few things.


At the moment I'm attempting to create an action button (like many Gameboy/DS games have, for interacting with just about everyone and everything, but I can't quite seem to get it right.

I'm not looking for any code snippets, I'm just looking for someone to point me to a post or library that can help. Searching , "ACTION, button,macros" or things like that hasn't really returned the results I was hoping for.
The easiest way at this point is by modifying the macro sets in your game's interface file, doing this you can make keys and combinations of keys trigger verbs, which can in turn be used to do whatever you need.
When I said button I should've clarified.

I mean, say I want the Z key on the keyboard to be the "Use button" for everything, like talking to an npc, or opening a chest....whatever. I've thought about calling a proc, but then i'd have to do that for every single entity in the game.

As for making a master-like macro in the interface, im not sure how to do that. Infact that didn't even occur to me at all, to what I was attempting to do.

Would you, or anyone be able to point me in the right direction?
Best response
mob
verb/ActionButton()
var/atom/movable/M = locate() in get_step(usr,usr.dir)
if(M)
M.Action(usr)

atom/movable/proc/Action(mob/caller)
// Topmost stuff here, if needed

obj
some_random_obj
Action(mob/caller)
caller << "I'm random!"

some_other_obj
Action(mob/caller)
caller << "I'm something else..."


Or something along those lines, them simply set a macro up on the interface that calls "ActionButton" and go from there, totally written off the top of my head to give you an idea of where to go, good luck :)
Thank you for your reply, this makes more sense to me, and is along the lines of what im looking for. However, so i can adapt it, could you possibly explain more of the "why" rather than the "How" .

I wasn't really looking for a snippet.

I figured the code snippet was simple enough to explain that, it's a simple matter of using the most generic method possible if you want it accessible for everything, overriding the proc will allow you to have unique actions for anything that need actions.
Well Im going to have to look up some interface tutorials because i cant seem to call the proc from the interface correctly.