write events.lua