blob: ab19e4286721766f0c102593ed44041117c5db87 [file] [log] [blame]
Zesstra5481d492021-04-08 20:07:06 +02001SYNOPSIS
2 lwobject new_lwobject(string name, ...)
3
4DESCRIPTION
5 Creates a new lightweight object from the program <name> and
6 returns it. The program will be loaded as a regular object,
7 called a blueprint, first, and then a lightweight object will
8 be created therefrom.
9
10 Note that the pathname must be complete, which means there are no
11 relative paths allowed. Any further arguments will be passed to
12 the H_CREATE_LWOBJECT hook to initialize the lightweight object.
13
14 If strict euids are enforced, the calling object must have a
15 non-zero euid.
16
17 Variable initialization is done similar to cloned objects with a call
18 to the internal lfun __INIT(). However, if #pragma share_variables is
19 in effect, the values for a lightweight object's variables are taken
20 from the current variables of the blueprint.
21
22 In the absence of share_variables, variables without explicit
23 initializers are initialized to 0.
24
25
26EXAMPLES
27 --- /lwo/stack.c ---
28 mixed* stack = ({});
29
30 int empty()
31 {
32 return sizeof(stack) == 0;
33 }
34
35 void push(mixed val)
36 {
37 stack += ({ val });
38 }
39
40 mixed pop()
41 {
42 mixed result;
43
44 if (empty())
45 raise_error("stack is empty.\n");
46
47 result = stack[<1];
48 stack = stack[..<2];
49 return result;
50 }
51
52 --- usage: ---
53 lwobject stack = new_lwobject("/lwo/stack");
54
55 stack.push("A");
56 return stack.pop();
57
58
59HISTORY
60 LDMud 3.6.5 introduced lightweight objects.
61
62SEE ALSO
63 blueprint(E), lwobjectp(E), load_name(E), uids(C), pragma(LPC)