source: abuse/branches/win32/Abuse32/LISP/Persist.lsp @ 100

Last change on this file since 100 was 100, checked in by Sam Hocevar, 15 years ago
  • Importing an old Win32 port by Jeremy "Marauder" Scott.
File size: 1.7 KB
Line 
1(setq PersistVars '(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0))
2
3(defun persist_ufun (value)
4        (if (atom value)
5                (progn
6                        (setq (car (nth Persist.PersistIndex PersistVars)) value)
7                        (print value Persist.PersistIndex)
8                )
9                (car (nth Persist.PersistIndex PersistVars))
10        )
11)
12
13
14(defun persist_ai ()
15        T
16)
17
18(def_char PERSIST_VAR
19        (vars
20                Persist.PersistIndex
21        )
22       
23        (funs
24                (draw_fun dev_draw)
25                (ai_fun persist_ai)
26                (user_fun persist_ufun)
27        )
28        (fields
29                ("Persist.PersistIndex" "Variable Index")
30        )
31        (range 0 0)
32        (states "art/misc.spe"
33                (stopped '("switch_off1" "switch_off2"))
34        )
35)
36
37(defun persist_switch_ai ()
38        (next_picture)
39        (select (aistate)
40                (0      ; waiting for player to press, then turn to on
41                        (if (and (< (distx) 20) (< (disty) 30) (with_object (bg) (pressing_action_key)))
42                                (progn
43                                        (play_sound SWITCH_SND 127 (x) (y))
44                                        (set_state running)             
45                                        (set_aistate 1)
46                                        (with_obj0 (persist_ufun 1))
47                                )
48                        )
49                )
50                (1     ; wait for player to let go of button     
51                        (if (not (with_object (bg) (pressing_action_key)))
52                                (set_aistate 2)
53                        )
54                )
55                (2     ; wait for player to press, then turn to off
56                        (if (and (< (distx) 20) (< (disty) 30) (with_object (bg) (pressing_action_key)))
57                                (progn
58                                        (play_sound SWITCH_SND 127 (x) (y))
59                                        (set_state stopped)
60                                        (set_aistate 4)
61                                )
62                        )
63                )
64                (4     ; wait for player to let go of button
65                        (if (not (with_object (bg) (pressing_action_key)))
66                                (set_aistate 0)
67                        )
68                )
69        )
70        T
71)
72
73(def_char PERSIST_SWITCH
74        (funs
75                (ai_fun persist_switch_ai)
76                (reload_fun lower_reload)
77        )
78        (range 0 0) 
79        (states "art/misc.spe"
80                (stopped '("switch_off1" "switch_off2"))
81                (running '("switch_on1"  "switch_on2"))
82        )
83)
Note: See TracBrowser for help on using the repository browser.