Sat, 27 Mar 2010 17:43:08 +0000
Initial commit (importing from old SVN repo which got lost)
0
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 | -- Here we process special commands, for example, those with more than one object specified |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 | |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 | commands = {}; |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 | |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 | function commands:_parse(person, command) |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 | if person.group.perm_edit and command:match("^@.*$") then |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 | local verb, param = command:match("^@(%a+)%s?(.*)$"); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 | local verb, object = command:match("^(%a+%s%a+)%s(.+)$"); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 | if verb and object and #verb > 0 and #object > 0 and person.room:_findobject(object) then |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 | return verb, object; |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 | verb, object = command:match("^(%a+)%s?(.*)$"); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 | if verb and object and #verb > 0 and #object > 0 then |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 | return verb, object; |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 | if verb and ((not object) or (object == "")) then return verb, nil; end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 | |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 | function commands:_handle(person, action, object) |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 | -- if not (person and action) then print("Invalid parameters!"); return; end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 | function callobjectmethod(object) |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 | local o = person.room._objects:findobject(object) or person._contents["in"]:findobject(object); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 | if o and o[action] then o[action](o, {room = person.room, person = person, nick = person.nick }); return true; end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 | return false; |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 | |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 | if commands[action] then commands[action](person, action, object); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 | elseif object and object ~= "" and callobjectmethod(object) then return true; |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 | elseif occupant[action] then occupant[action](person, { room = person.room, person = person }); return true; |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 | elseif action and type(person.room[action]) == "function" then person.room[action](person.room, { room = person.room, person = person, jid = person.jid, nick = person.nick, param = object }); return true; |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 | else return false; -- Unable to understand command |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 | |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 | function commands.get(person, action, param) |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 | -- Decide if we are taking it from a container |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 | obj1, obj2 = param:match("^([%a%s]+)%sfrom%s([%a%s]+)$"); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
39 | if obj1 and obj2 then -- We are taking from a container |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 | local container = person:_findobject(obj2) or person.room:_findobject(obj2); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 | if not container then person:_tell(string.format("I don't see any '%s' here.", obj2 or "")); return; end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 | if not (container._contents and container._contents["in"]) then person:_tell(string.format("The %s is not a container.", obj2 or "")); return; end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
43 | object = container:_findobject(obj1); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
44 | if not object then |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 | if object == false then person:_tell(string.format("Sorry, the %s is locked.", obj2)); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
46 | else person:_tell(string.format("I can't find any %s in there.", obj1)); end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
47 | return; |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
48 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
49 | if person:_get({ object = object, container = container, name = obj1 }) then |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
50 | person:_say(string.format("/me gets %s from %s", object._properties.longname or object._properties.name or "something", container._properties.longname or container._properties.name or "something")); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
51 | else |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
52 | person:_tell("You can't get that"); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
53 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
54 | return; |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
55 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
56 | obj1 = param:match("^([%a%s]+)$"); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
57 | if not obj1 then person:_tell("uh?"); return; end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
58 | -- So we are getting an object just in the room |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
59 | local container = person.room; |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
60 | local object = container:_findobject(obj1); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
61 | if not object then person:_tell(string.format("I can't find any %s in here.", obj1)); return; end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
62 | if person:_get({ object = object, container = container, name = obj1}) then |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
63 | person:_say(string.format("/me picks up %s", object._properties.longname or object._properties.name or "something")); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
64 | else |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
65 | person:_tell("You can't get that"); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
66 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
67 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
68 | |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
69 | function commands.put(person, action, param) |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
70 | obj1, obj2 = param:match("^([%a%s]+)%sin%s([%a%s]+)$"); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
71 | if not (obj1 and obj2) then return end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
72 | local oldcontainer = person; -- Where the object currently is |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
73 | local object = person:_findobject(obj1); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
74 | if not object then object = person.room:_findobject(obj1); oldcontainer = person.room; end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
75 | if not object then person:_tell(string.format("Sorry, I can't find the '%s'.", obj1)); return; end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
76 | local newcontainer = person.room:_findobject(obj2); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
77 | if not newcontainer then person:_tell(string.format("I don't see any '%s' here.", obj2 or "")); return; end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
78 | if not (newcontainer._contents and newcontainer._contents["in"]) then person:_tell(string.format("The %s is not a container.", obj2 or "")); return; end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
79 | |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
80 | if newcontainer:_get({ object = object, container = oldcontainer }) then |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
81 | person:_say(string.format("/me puts %s in %s", object._properties.longname or object._properties.name or "something", newcontainer._properties.longname or newcontainer._properties.name or "something")); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
82 | else |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
83 | person:_tell("You can't put that in there"); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
84 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
85 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
86 | |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
87 | function commands.drop(person, action, param) |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
88 | local o = person:_findobject(param); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
89 | if not o then person:_tell("You don't seem to have any "..param); return false; end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
90 | if person.room:_get({ object = o, container = person }) then |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
91 | person:_say("/me drops "..(o._properties.longname or o._properties.name)); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
92 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
93 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
94 | |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
95 | function commands.give(person, action, param) |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
96 | if not param then person:_tell("Give what to whom?"); return; end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
97 | local objname, tonick = param:match("([%a%s]-)%s* to (.*)"); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
98 | if not objname or not tonick then person:_tell("Give what to whom?"); return; end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
99 | local o = person:_findobject(objname); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
100 | if not o then person:_tell("You don't seem to have any "..objname); return false; end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
101 | if not person.room.people[tonick] then person:_tell("Sorry, I can't find "..(tonick or "that person").."in this room..."); return; end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
102 | if person.room.people[tonick]:_get({object = o, container = person}) then |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
103 | person:_action("gives "..(o._properties.longname or ((o._properties.prepend or "the").." "..o._properties.name)).." to "..param); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
104 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
105 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
106 | |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
107 | function commands.help(person, action, param) |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
108 | |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
109 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
110 | |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
111 | function commands.loadclass(person, action, param) |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
112 | local subenv = { classes = { } } |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
113 | local classdefinition = loadfile("objects/"..param..".lua"); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
114 | setfenv(classdefinition, subenv); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
115 | local success, message = pcall(classdefinition); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
116 | if not success then person:_tell(string.format("Error loading %s: %s", param, message)); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
117 | else |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
118 | for k, v in pairs(classes[param]) do classes[param][k] = nil; end -- Clear current class |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
119 | for k, v in pairs(subenv.classes[param]) do classes[param][k] = v; end -- Fill with data from new definition |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
120 | person:_tell("Loaded"); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
121 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
122 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
123 | |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
124 | function commands.dump(person, action, param) |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
125 | table.print(param, person.room:_findobject(param) or person:_findobject(param) or classes.default or {}); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
126 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
127 | |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
128 | function commands.dumproom(person, action, param) |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
129 | table.print(person.room.name or "room", person.room); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
130 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
131 | |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
132 | function commands.loadroom(person, action, param) |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
133 | if not rooms[param] then person:_tell("You should go into the room, it has not even been created yet."); end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
134 | local oldpeople = rooms[param].people; |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
135 | rooms[param]:_create{ room = param, server = GetJIDParts(person.occjid).server} |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
136 | rooms[param].people = oldpeople; |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
137 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
138 | |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
139 | commands["@create"] = function (person, action, param) |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
140 | local chunk = loadstring(param); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
141 | if not chunk then person:_tell("There was an error in your syntax. Please read the manual"); return; end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
142 | setfenv(chunk, 1); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
143 | local success, message = pcall(chunk); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
144 | if not success then person:_tell(message.."\nThere was an error processing the command"); return; end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
145 | local t = message; |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
146 | local newobj = classes[t.class]:_create(t); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
147 | if newobj then |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
148 | person._contents["in"]:add(newobj); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
149 | person:_action("waves his hands, and conjures something from thin air!"); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
150 | else |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
151 | person:_tell("For some reason, the object was not created"); |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
152 | end |
cc66ad6b0d75
Initial commit (importing from old SVN repo which got lost)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
153 | end |