seeking prehistoric mismatch ;-)

Started by newdep, July 13, 2009, 08:10:54 AM

Previous topic - Next topic

newdep

Who sees the error?



I can't see (wrong glasses i guess)

why this isnt working any more.. It was build in the

pre-history pre version 10.0.0 ages of newlisp and I cant get it

working on the 10.1.0 ..Any help very welcome! ;-)



The error im getting is:


newLISP-GS v.1.29 on Linux
 double buffering supported.
 listening on 47011
 accepted connection from 0.0.0.0
 connecting to 0.0.0.0:47012
 retrying to connect

ERR: illegal parameter type in function string : $idx
called from user defined function gs:button




#!/usr/bin/newlisp
;; -----------------------------------------------------
;; - LaZu - v2.0
;;
;; Fix the game by rotating the colored squares.
;; (Horizontal and vertical numbers may only occeur once)
;;
;; Enjoy! game and idea by nodep 2006 (c) -
;; -----------------------------------------------------

(if (= ostype "Win32")
 (load (string (env "PROGRAMFILES") "/newlisp/guiserver.lsp"))
 (load "/usr/share/newlisp/guiserver.lsp"))

;; -----------------------------------------------------
;; Generate game
;; -----------------------------------------------------
(seed (nth 6 (now)) )
(push (randomize (sequence 1 9)) b)
(while (< (length b) 9) (push (rotate (b -1)) b -1))
(dotimes (x 3) (setq b (randomize b true)))
(dotimes (x 9) (dolist (y b) (push (y x) c)))
(setq c (explode c 9))
(dotimes (x 3) (setq c (randomize c true)))
(set 'c (flat c))
(set 'solution c)
;; -----------------------------------------------------

(set 'clickers '(B10 B13 B16 B37 B40 B43 B64 B67 B70))
(dotimes (T 81) (push (sym (append "B" (string T))) buttons -1))
(define (update-buttons) (dolist (x c) (gs:set-text (buttons $idx) (string x))))
(define (roler p q, r) (dotimes (r p) (set 'c (eval (coaster q)))))

;; -----------------------------------------------------

(set 'coaster '(
(and (swap  0  1 c) (swap  1  2 c) (swap  2 11 c) (swap 11 20 c) (swap 20 19 c) (swap 19 18 c) (swap 18  9 c))
(and (swap  3  4 c) (swap  4  5 c) (swap  5 14 c) (swap 14 23 c) (swap 23 22 c) (swap 22 21 c) (swap 21 12 c))
(and (swap  6  7 c) (swap  7  8 c) (swap  8 17 c) (swap 17 26 c) (swap 26 25 c) (swap 25 24 c) (swap 24 15 c))
(and (swap 27 28 c) (swap 28 29 c) (swap 29 38 c) (swap 38 47 c) (swap 47 46 c) (swap 46 45 c) (swap 45 36 c))
(and (swap 30 31 c) (swap 31 32 c) (swap 32 41 c) (swap 41 50 c) (swap 50 49 c) (swap 49 48 c) (swap 48 39 c))
(and (swap 33 34 c) (swap 34 35 c) (swap 35 44 c) (swap 44 53 c) (swap 53 52 c) (swap 52 51 c) (swap 51 42 c))
(and (swap 54 55 c) (swap 55 56 c) (swap 56 65 c) (swap 65 74 c) (swap 74 73 c) (swap 73 72 c) (swap 72 63 c))
(and (swap 57 58 c) (swap 58 59 c) (swap 59 68 c) (swap 68 77 c) (swap 77 76 c) (swap 76 75 c) (swap 75 66 c))
(and (swap 60 61 c) (swap 61 62 c) (swap 62 71 c) (swap 71 80 c) (swap 80 79 c) (swap 79 78 c) (swap 78 69 c))))


;; -----------------------------------------------------
;; Rotate only x squares random 1-8 times left
;; Make R higher will make game even more difficult
;; -----------------------------------------------------
(dotimes (R 3)
 (roler ((randomize (sequence 1 8)) 0) ((randomize (sequence 0 8)) 0)))

;; -----------------------------------------------------
;; GUI
;; -----------------------------------------------------
(gs:init)
;(gs:set-look-and-feel "com.sun.java.swing.plaf.motif.MotifLookAndFeel")
;(gs:set-look-and-feel "com.sun.java.swing.plaf.gtk.GTKLookAndFeel")
;(gs:set-look-and-feel "com.sun.java.swing.plaf.windows.WindowsLookAndFeel")
;(gs:set-look-and-feel "javax.swing.plaf.mac.MacLookAndFeel")
(gs:set-look-and-feel "javax.swing.plaf.metal.MetalLookAndFeel")

(gs:frame 'F1 0 0 420 470 "LaZu")
(gs:set-resizable 'F1 nil)
(gs:set-grid-layout 'F1 1 1 1 1 )

(gs:panel 'BP)
(dolist (b buttons)
 (gs:button b B-handler (string (c $idx)) 50 50)
 (gs:set-size b 50 50)
 (gs:set-foreground b 0 0 0 )
 (gs:set-background b 0.9 1 0.7)
 (gs:set-font b "Sans Serif" 18 "bold")
 (if (find b clickers)
  (and (gs:set-foreground b 1 0 0 )
   (gs:set-background b 0.9 1 0.4)))
 (gs:add-to 'BP b))

(gs:label 'L1 "horizontal and vertical the numbers 1-9 can only appear once" "center")
(gs:label 'L2 "click the highlighted buttons to rotate left" "center")
(gs:set-foreground 'L1 0.2 0.4 0.8 0.8 )
(gs:set-foreground 'L2 0.2 0.4 0.8 0.8 )

(gs:add-to 'BP 'L1 'L2)

(gs:add-to 'F1 'BP)
(gs:set-visible 'F1 true)


;; -----------------------------------------------------  
;; Go!
;; -----------------------------------------------------  
(define (B-handler id text)
 (cond
  ((= "MAIN:B10" id) (roler 1 0))
  ((= "MAIN:B13" id) (roler 1 1))
  ((= "MAIN:B16" id) (roler 1 2))
  ((= "MAIN:B37" id) (roler 1 3))
  ((= "MAIN:B40" id) (roler 1 4))
  ((= "MAIN:B43" id) (roler 1 5))
  ((= "MAIN:B64" id) (roler 1 6))
  ((= "MAIN:B67" id) (roler 1 7))
  ((= "MAIN:B70" id) (roler 1 8)))
  (update-buttons)
   (if (= solution c)
    (and (dolist (x clickers)
     (gs:set-text x ( "WELLDONE!" $idx )))
     (dolist (x buttons) (gs:disable x)))))

(gs:listen)
-- (define? (Cornflakes))

Lutz

#1
The syntax of 'swap' has changed:



http://www.newlisp.org/downloads/newlisp_manual.html#swap">http://www.newlisp.org/downloads/newlis ... .html#swap">http://www.newlisp.org/downloads/newlisp_manual.html#swap





instead of:


(swap 3 4 c)

do:


(swap (c 3) (c 4))

'c' must be a list.



You also still can swap the contents of two variables/symbols:


(swap x y) ; exchange contents of x and y

newdep

#2
Aaaaa realy is it the swap function?...



Pffff i seeked and seeked I though it was releated to the $idx value

all the time..



Thanks I try that right away!



PS: I wanted to change that part of the game anyway so this is a good start to do it right now ;-)
-- (define? (Cornflakes))