mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2025-12-28 03:01:37 +00:00
Admins can toy around with converting a character to text, and placing them back elsewhere, independent of the round. It's got a kink, though: The text given to you directly needs to be printed once to remove all the escapes - otherwise the thing will choke. I'd like advice on resolving that
39 lines
1.2 KiB
Plaintext
39 lines
1.2 KiB
Plaintext
/*
|
|
* Returns a byond list that can be passed to the "deserialize" proc
|
|
* to bring a new instance of this atom to its original state
|
|
*
|
|
* If we want to store this info, we can pass it to `json_encode` or some other
|
|
* interface that suits our fancy, to make it into an easily-handled string
|
|
*/
|
|
/atom/movable/proc/serialize()
|
|
return list("type" = "[type]")
|
|
|
|
/*
|
|
* This is given the byond list from above, to bring this atom to the state
|
|
* described in the list.
|
|
* This will be called after `New` but before `initialize`, so linking and stuff
|
|
* would probably be handled in `initialize`
|
|
*
|
|
* Also, this should only be called by `json_to_object` in persistence.dm - at least
|
|
* with current plans - that way it can actually initialize the type from the list
|
|
*/
|
|
/atom/movable/proc/deserialize(var/data)
|
|
return
|
|
|
|
/proc/json_to_object(var/json_data, var/loc)
|
|
var/data = json_decode(json_data)
|
|
return list_to_object(data, loc)
|
|
|
|
/proc/list_to_object(var/list/data, var/loc)
|
|
if(!islist(data))
|
|
throw EXCEPTION("You didn't give me a list, bucko")
|
|
if(!("type" in data))
|
|
throw EXCEPTION("No 'type' field in the data")
|
|
var/path = text2path(data["type"])
|
|
if(!path)
|
|
throw EXCEPTION("Path not found: [path]")
|
|
|
|
var/atom/movable/thing = new path(loc)
|
|
thing.deserialize(data)
|
|
return thing
|