ID:2061991
 
Code:
mob
var/list/screenlist=list()
var/list
HotKeys=list("F1","F2","F3","F4","F5","F6","F7","F8")

verb/UseKey(key as text)
set hidden=1
if(HotKeys[key])

var/obj/Skill/O=HotKeys[key]

O.Initiate(src)


proc/SetKey(key,object) HotKeys[key]=object

obj
icon='TechList.dmi'
Skill
proc
Initiate(mob/Owner)

MouseDrag()
mouse_drag_pointer=icon(icon,icon_state)

MouseDrop(over_location)
mouse_drag_pointer=null
if(istype(over_location,/obj/Hud/HotKeys))
var/obj/O=over_location
O.overlays=list(icon(icon,icon_state))
usr.SetKey(O.name,src)

Punch
icon_state="Punch"
Initiate(mob/Owner)
Owner.Punch()
Kick
icon_state="Kick"
Initiate(mob/Owner)

Owner.Punch()
Hud
HotKeys
mouse_drop_zone=1
icon='Hotkeys.dmi'
New() icon_state=name
Click()
overlays=null
usr.HotKeys[name]=null


F1/screen_loc="12,2:-16"
F2/screen_loc="13:16,2:-16"
F3/screen_loc="15,2:-16"
F4/screen_loc="16:16,2:-16"
F5/screen_loc="18,2:-16"
F6/screen_loc="19:16,2:-16"
F7/screen_loc="21,2:-16"
F8/screen_loc="22:16,2:-16"
mob
proc
StartHotkeys()
for(var/obj/Hud/HotKeys/m in src.screenlist)
if(m)
src.client.screen+=m


Problem description:

I know I need to add tehniques into list and than save/read from the list. But how can I save/read the number where tehniques was on.

For example 3 tehniques: "kick", "block", "punch" on 1 2 3. If I save the number-position in list and reread it it would work. But if I remove 2 the 3 will be pushed into number 2 in list.

Sorry for my bad English


Having a type for each button (F1, F2, etc.) is really a bad way to go. Don't do this:

F1/screen_loc="12,2:-16"
F2/screen_loc="13:16,2:-16"
F3/screen_loc="15,2:-16"
F4/screen_loc="16:16,2:-16"
F5/screen_loc="18,2:-16"
F6/screen_loc="19:16,2:-16"
F7/screen_loc="21,2:-16"
F8/screen_loc="22:16,2:-16"

Do this:

New(newloc, n)   // n is 1 through 8
name = "F[n]"
icon_state = n
var/X = 10.5 + n*1.5
var/px = (X - round(X)) * 32
screen_loc = "[round(X)]:[px],2:-16"

An uncluttered type tree is your friend.
Nice thanks for this. I can avoid few lines of code and I`ll keep this in my mind.