ID:2307170
 
Code:
mob
var/list
HotKeys=list(,"Key1","Key2","Key3","Key4","Key5","Key6","Key7","Key8","Key9","Key0","Key10","Key11","Key12")
proc/SetKey(key,object) HotKeys[key]=object
obj
var
screenlocation
SlotLoc = 0
Skillcards
layer = 12
New()
..()
src.mouse_drag_pointer = icon(src.icon,src.icon_state)
MouseDrop(obj/Slot)
if(Slot)
src.name = Slot.name
usr.client.screen += src
src.screen_loc=Slot.screen_loc
src.screenlocation = src.screen_loc
usr.SetKey(Slot.name,src)


Problem description:

Hi, I tried to save client screen but it dont work. How I can generate skillcards into client screen? Because each skillcard gets the key name, like key 1, key 2,... I have no idea what to do.
I tried to load this way but no works
mob
proc/LoadSkillCards()
var/obj/Skillcards/O=HotKeys[key]
var/obj/Keys/Z
O.MouseDrop(Z.locc)
Preface: Am probably on toward blackout drunk, so anything I say should be taken with a grain of salt.

Don't. Don't save the client's screen. Associate a string to a skillcard and a skillcard type to a string.

Rebuild the screen based on the contents of the mob/hotbar string list when the mob is logged into.

Check out stdlib for the proc index_typesof(). PM me in the morning. I'll write some code or something so you can copy/paste and then yell at me about compiler errors.
Alright, so we're going to have a couple stated goals here with a skillcard system.

1) Separation of concern. Screen objects are just buttons that interact with the mouse. They don't actually hold any real skill information.

2) The mob doesn't care about what's on the screen. Just what the objects on the screen actually do.

3) The client doesn't need to save any objects, just a list of ids that we can use to reference the objects from memory between sessions.

Abilities will be global singletons. That means that only one per type will be implemented. We reference them on attempted use by their id and then grab a reference to the object.

var/list/abilities = singleton_init(/ability) //this function from Ter13.StdLib allows you to initialize one of each subtype that has an id variable set to a value.

ability
parent_type = /obj
var
id
proc
Use(mob/user,mob/target)

MouseDrop(atom/over_object,atom/src_location,atom/over_location,src_control,over_control,params)
if(istype(over_object,/screen_obj/hotslot))
var/screen_obj/hotslot/slot = over_object
slot.Update(src)


screen_obj/hotslot objects themselves will handle displaying skillcards for ability objects. You can drag them around to swap them, or drag them off the bar to remove them. Clicking on them will tell the mob to use that hotkey by position.

screen_obj
parent_type = /obj

hotslot
var
position
stored_appearance
Click()
if(position)
usr.Hotkey(position)

MouseDrop(atom/over_object,atom/src_location,atom/over_location,src_control,over_control,params)
if(istype(over_object,/screen_obj/hotslot))
var/screen_obj/hotslot/slot = over_object
usr.hotslots.Swap(position,slot.position)
else
usr.hotslots[position] = null

Update(ability/ability)
if(stored_appearance) overlays -= stored_appearance
if(ability)
overlays += (stored_appearance = ability.appearance)
usr.hotslots[position] = ability.id

New(screen_loc,position)
src.position = position
src.screen_loc = screen_loc
..()


Next, we set up /mob to have a hotslots list. This list will store the id names of /ability objects that are stored in the hotbar.

mob
var
list/hotslots = new/list(10)
proc
Hotkey(position)
var/id = hotslots[position]
if(id)
var/ability/ability = global.abilities[id]
if(ability)
ability.Use()


Last, we need to modify the client to build the hotbars:

client
var
list/hotbar
New()
. = ..()
if(.)
BuildHotbar()

proc
BuildHotbar()
var/screen_obj/hotslot/slot, list/bar = mob.hotslots, id
hotbar = list()
for(var/pos in 1 to 10)
slot = new/screen_obj/hotslot("CENTER+0:[(count - 5) * TILE_WIDTH],SOUTH",pos)
id = bar[pos]
if(id)
ability = abilities[id]
if(ability)
slot.Update(ability)
hotbar += slot
screen += hotbar



You follow?
In response to Ter13
hi, im a bit confused on where I should start, like the obj dont saves on screen but the key list still saves
mob
var/list
HotKeys=list(,"Key1","Key2","Key3","Key4","Key5","Key6","Key7","Key8","Key9","Key0","Key10","Key11","Key12")

verb/UseKey(key as text)
set hidden=1, instant = 1
if(HotKeys[key])
var/obj/Skillcards/O=HotKeys[key]
O.Initiate(src)


I tried to build Keys obj with

    proc
BuildHotbar()
var/screen_obj/hotslot/slot, list/bar = mob.hotslots, id
hotbar = list()
for(var/pos in 1 to 10)


instead of

client/proc/StartHotkeys()
new/obj/Numbers/Key0(src)
new/obj/Numbers/Key1(src)
...
new/obj/Keys/Key1(src)
...


But I didn't get it :/