src/examples/jumpbot.clj @ 1e03d5cc372b
Refactor the loop stuff.
author |
Steve Losh <steve@stevelosh.com> |
date |
Fri, 26 Aug 2011 18:02:11 -0400 |
parents |
(none) |
children |
7aa6da5b1d8b |
(ns examples.jumpbot
(:require [clojurecraft.core :as core])
(:require [clojurecraft.events :as events])
(:require [clojurecraft.actions :as actions]))
(defn jump [bot]
[(actions/jump bot)])
(defn handle-dead [bot]
[(actions/chat bot "WHY DO YOU NOT WANT ME TO JUMP?!")
(actions/respawn bot)])
(defn make-jumpbot [server username]
(let [bot (core/connect server username)]
(events/add-handler bot :dead #'handle-dead)
(events/add-loop bot #'jump 3000 :jump-loop)
bot))