 (defn updategamestate! [gamestate]
   (let [oldrenderstate @displayed-renderstate
         renderstate (assoc oldrenderstate :gamestate gamestate)
+        selectedcharacterid (:selectedcharacterid renderstate)
+        gamestate (:gamestate renderstate)
+        overlaydata (if selectedcharacterid
+                      (getclickablesfor gamestate (world/get-character gamestate selectedcharacterid) nil)
+                      nil)
         newrenderstate (-> renderstate
             (rebuildmapdisplaylist oldrenderstate)
             (rebuildcharacterdisplaylist)
             (rebuildteamdisplaylist :team1)
             (rebuildteamdisplaylist :team2)
-            (rebuildoverlay nil)
+            (rebuildoverlay overlaydata)
             (updatemessagelog))]
     (if (compare-and-set! displayed-renderstate oldrenderstate newrenderstate)
       nil ; updated renderstate

      (rendermovelocations overlay movelocations))
    (when (not-nil? attacktargets)
      (renderattacktargets overlay attacktargets))
    (assoc renderstate :overlayclickables (buildclickcallbacks renderstate actiondata))))

;;
;; text log window

         findspriteforcharacter
         rebuildoverlay)

(defn setcanvascaption [renderstate caption]
  (let [stage (:stage renderstate)
        canvas (.-canvas stage)]
    (aset canvas "title" caption)))

(defn- highlightcharacter
  "Highlights current character. Doesn't modify the clojure-side renderstate"
  [character]
