def process_events
while e = get_event
begin
obj = Engine.instance.db.get(e.to)
obj2 = Engine.instance.db.get(e.from)
sid = obj.get_trigger("pre_"+e.kind.to_s)
if sid
script = Engine.instance.db.get(sid)
if script
if script.execute(e)
if obj2.class == Character
s,o = obj.msgsucc.split("|")
obj2.sendto(s) if s && !s.empty?
if o && !o.empty?
Engine.instance.db.get(obj2.location).characters(obj2.id).each do |p|
add_event(obj2.id,p.id,:show,"#{obj2.name} #{o}")
end
end
end
else
if obj2.class == Character
s,o = obj.msgfail.split("|")
obj2.sendto(s) if s && !s.empty?
if o && !o.empty?
Engine.instance.db.get(obj2.location).characters(obj2.id).each do |p|
add_event(obj2.id,p.id,:show,"#{obj2.name} #{o}")
end
end
end
next
end
else
log.error "Script not found: #{sid} for Event: #{e}"
next
end
end
obj.send(e.kind,e)
sid = obj.get_trigger(e.kind)
if sid
script = Engine.instance.db.get(sid)
if script
if script.execute(e)
if obj2.class == Character
s,o = obj.msgsucc.split("|")
obj2.sendto(s) if s && !s.empty?
if o && !o.empty?
Engine.instance.db.get(obj2.location).characters(obj2.id).each do |p|
add_event(obj2.id,p.id,:show,"#{obj2.name} #{o}")
end
end
end
else
if obj2.class == Character
s,o = obj.msgfail.split("|")
obj2.sendto(s) if s && !s.empty?
if o && !o.empty?
Engine.instance.db.get(obj2.location).characters(obj2.id).each do |p|
add_event(obj2.id,p.id,:show,"#{obj2.name} #{o}")
end
end
end
end
else
log.error "Script not found: #{sid} for Event: #{e.inspect}"
end
end
rescue
log.error "Event failed: #{e.inspect}"
log.error $!
end
end
end