Skip to content

Commit

Permalink
/datum/Read() (#19)
Browse files Browse the repository at this point in the history
Just learning how this works with a simple example
  • Loading branch information
amylizzle authored Aug 6, 2024
1 parent de34056 commit b4c9c3e
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion content/objects/datum/proc/read.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,28 @@ name = "F"
type = "/savefile"
+++

When the thing's been read.
This is called when a [/datum](@/objects/datum/_index.md) is read from a [/savefile](@/objects/savefile/_index.md). The [/savefile](@/objects/savefile/_index.md) being read from is passed as the first argument. The return value is ignored.

Example:
```dm
//create a demonstrator datum type
/datum/test
var/test_var = 1
//define our demonstrator Read() proc
Read(savefile/F)
src.test_var = 2
//create an instance of /savefile and our /datum/test
var/savefile/my_savefile = new()
var/datum/test/T = new()
//store the test datum in the savefile
my_savefile["test"] = T
//read the test datum from the savefile. This calls /datum/test/Read()
var/datum/test/T2 = my_savefile["test"]
//test_var is now 2, because Read() was called
ASSERT(T2.test_var == 2)
```

0 comments on commit b4c9c3e

Please sign in to comment.