Hello everyone.
I am a amateur autolisp programmer, not really a good one
. Hope one the guru here can help me with my grread problem.
I have downloaded the Troy AutoLisp grread game (written by Terry Miller), copied part of the code from the Troy game to my program. The weird thing is the grread won't move until I move the mouse, unlike the Troy program worked with streaming output, even without touching the mouse. I added a princ after the grread, Amazingly the Troy program printed out coordinates even without moving the mouse (The Troy game can be downloaded here -
http://web2.airmail.net/terrycad/LISP/Troy-I.lsp)
I would appreciated any help. (Hope one of the Guru will tell me what my program is missing)
Thank you very much.
Sorry for the lousy grammar
Below is my short program -
;;--------------------------------------------------------------------------------------------------------------------
;; trying to make grread streaming output.
(defun c:tg ()
(setq loop t)
(setq Previous@ (grread t 4))
(setq cr_pt (getpoint "\npick pt for circle-red")
cw_pt (getpoint "\npick pt for circle-white")
)
(command "circle" cr_pt 3)
(command "chprop" "l" "" "c" "1" "")
(setq cr_name (entlast))
(command "circle" cw_pt 3)
(command "chprop" "l" "" "c" "7" "")
(setq cw_name (entlast))
(while Loop
(if (not (setq Read@ (grread t 4))) ;; problem here is, grread is not streaming, it pause when mouse not moving
(setq Read@ Previous@)
)
(if (and (/= Previous@ nil) (not (equal (cadr Previous@) (cadr Read@) 0.001))) (move_white)) ;; mouse moved then move white circle
;; red circle supposed to move even user not moving the mouse.
;; like the Troy.lsp - Troy moves around even when mouse not moving
(move_red)
(princ Read@)
(setq Code# (nth 0 Read@))
(if (= Code# 2) ;; key pressed then
(setq loop nil) ;; exit loop
)
(setq Previous@ Read@)
)
(princ)
)
(princ "\ntest grread movement.LSP loaded...type tg to test")
;; --------------------
;; move square
;; --------------------
(defun move_red ()
(command "move" cr_name "" "0,0" "@1<0.5")
)
;; --------------------
;; move circle
;; --------------------
(defun move_white ()
(command "move" cw_name "" "0,0" "@1<0.5")
)
;; ---------------------------------------------------------------------------------------- end of lisp