Ostatnio aktywny 2 hours ago

An example of objects.

june's Avatar june zrewidował ten Gist 2 hours ago. Przejdź do rewizji

1 file changed, 88 insertions

objects.nv(stworzono plik)

@@ -0,0 +1,88 @@
1 + ||'@include' (https://gist.casuallyblue.dev/wryl/d3c64c1df98e48cbaff3b3dcdc189e3f/raw/HEAD/map.nv lib/rpn.nv)
2 +
3 + |::(/* */)|
4 + |::(/* $x)| :: /*
5 + ||::(
6 + /* Now we can add comments to what we are doing. */
7 + /*
8 + .. but maybe not too many?
9 + */
10 + )
11 +
12 + ||:fresh ID: 0
13 + |:: next ID :@rpn data: $id|
14 + :fresh ID: $id
15 + |:: next ID? :fresh ID: $id|
16 + :@rpn: ($id 1 +)
17 +
18 + |:: {}| :: ({ })
19 + |:: { :fresh ID: $id?|
20 + :self: $id
21 + :: next ID
22 + |:: } :self: $ :parent: $parent :field: $field|
23 + :@map: set
24 + :@map.key: $parent $field
25 + :@map.value: $
26 + |:: } :self: $ :field: $field|
27 + :@map: set
28 + :@map.key: $field
29 + :@map.value: $
30 + |:: } :self: $|
31 + :data: $
32 +
33 + |:: ($x = {})| :: ($x = { })
34 + |:: ($x = {) :self: $?|
35 + :: { :parent: $ :field: $x
36 + |:: ($x = {)|
37 + :: { :field: $x
38 + |:: ($x = $y) :self: $?|
39 + :@map: set
40 + :@map.key: $ $x
41 + :@map.value: $y
42 + |:: $x :self: $?|
43 + :@map: set
44 + :@map.key: $ $x
45 + :@map.value:
46 +
47 + ||::(
48 + world = {
49 + kitchen = {
50 + table
51 + chairs = {
52 + /* Should probably add some way to do lists.. */
53 + [chair 1] [chair 2] [chair 3] [chair 4]
54 + }
55 + players = {
56 + 0 = {
57 + name = [Wryl Gardner]
58 + position = {
59 + x = 10
60 + y = 20
61 + }
62 + inventory = {
63 + sword shield gold = { amount = 300 }
64 + }
65 + }
66 + 1 = {
67 + name = [A Brave Adventurer]
68 + position = {
69 + x = 100
70 + y = 200
71 + }
72 + inventory = {
73 + [a stick] [some weird bag of herbs]
74 + }
75 + }
76 + }
77 + }
78 + }
79 + [to-do list] = {
80 + [somehow, build some cool string support using this system.]
81 + [write an accessor library, so we can actually traverse these objects.]
82 + [demonstrate their usage/interplay with math expressions, rules, etc.]
83 + }
84 + )
85 +
86 + |: comment section :| ##"
87 + (wryl) This was really, really fun to work on. Took very little brain power.
88 + "
Nowsze Starsze