ID:1442782
 
(See the best response by GhostAnime.)
ok so I wanted to make like 5 hotkeys for techs but i wanted to make like each a 1 box grid for each one so im wondering if it's possible to like drag a tech from a grid list into the 1 box grid and use the tech in that grid as a hotkey? and how would i do this

Best response
Why not set it such that when the tech is dropped in to the grid, it sets the hotkey entry according to that grid position?

For example (in pseudocode):
user/hotkey = list(null, null, null, null, null)  //  For example use
Tech
Drag_and_Drop(Grid_position) // Yes, I know this does not exist. It is a pseudocode and this is an example...
var/get_position = "1" // If you are unable to get the column/row number, it defaults to 1
if(Grid_position) // If the position is defined in a "row:column" type of result, you want to extract the correct value
get_position = copy(Grid_position, start_pos, end_pos) // I do not recall the appropriate function - but, hey, this is an example

get_position = text2num(get_position) // Convert string to numeric

user.hotkey[get_position] = src // Set the hotkey list to this object

proc/Use()
user << "Default usage procedure"

Decimate_Everyone // a /Tech object
Use()
for(var/mob/M in world)
Kill(M)
world << "[user.name] killed everyone!"


User/verb/Hotkey_Function(key_pressed) // assigned to the interface to be called
set hidden = 1
var/Tech/T = usr.hotkey[key_pressed] // get technique set in the hotkey
if(T != null) // Make sure you have something there. For robustness, you may consider just if(T) to evaluate that the entry is TRUE if you have the tendancy to set things to 0 rather than null to account for mixtures of the two.

T.Use() // Call the function


Now, that is just one way to go about this. In the end, it all depends on what you want to do and how your system is set up. If all the techniques have different procedure names for its functions, obviously this method will not work.
uhh what do you mean by procedural names?
In response to Mastergamerxxx
Mastergamerxxx wrote:
uhh what do you mean by procedural names?

He means that every technique will have to be called by Use(), in which case using a single proc like he did would cause every technique to do the same thing. So in order for it to work each /Tech/ would have to be called by a Use() proc of its own. For example, if you made /Tech/Fireball, you'd have to make the fireball do its thing in /Tech/Fireball/proc/Use(). If you tried /Tech/Fireball/proc/Fireball() it wouldn't work with this system.

It COULD work with a single Use() proc, but it would just cause the proc to be huge if you have a lot of techniques.
so im guessing the easiest way is just to use a hotkey system via on screen drag and drag and drop or is there a different way of doing a hotkey/drag and drop for interface
In response to Mastergamerxxx
Mastergamerxxx wrote:
so im guessing the easiest way is just to use a hotkey system via on screen drag and drag and drop or is there a different way of doing a hotkey/drag and drop for interface

The way I do it is with screen objects and MouseDrop(). There isn't really an "easiest" way with programming, it's more about efficiency and what makes sense to the programmer.
I just thought of something is it possible to add a 2nd map element below the main map and use that as a hotkey bar screen object? would that affect anything gameplay wise like lag or possible map or button or something jumping between the 2 maps
In response to Mastergamerxxx
Mastergamerxxx wrote:
I just thought of something is it possible to add a 2nd map element below the main map and use that as a hotkey bar screen object? would that affect anything gameplay wise like lag or possible map or button or something jumping between the 2 maps

This has been possible for quite some time. And no, it won't cause "lag". The map element will only update when you add/remove objects from it.
ok so how would i go about doing that i never really messed with using a 2nd map do i make a blank map file or just a map interface window do i unset it form default i dunno how to really do anything with a 2nd map
You put a second map on the interface, and name it.

Then you add objects to the client's screen list using a screen loc in this format:

"mapname:[x]:[px],[y]:[py]"
what is the px and py for or mean?
pixel_x and pixel_y.

I'm going to post a short guide on screen objects because there are huge misconceptions in how they work. Bear with me a bit.
one question im wondering is if i say replaced my 32x32 grid boxes with 32x32 sized maps would the icons added to those maps but super small or would they be normal sized icons?
I'd advise not using a large number of map elements. Use as few as you need. They tend to be a bit... Well, flickery when you have more than a half dozen or so.

If you did this, though, you would be able to specify the icon-size property on the maps, which will allow you to specify how icons appear on them.