DEADSOFTWARE

Convert codepage to utf8
[cavecraft.git] / src / console.pas
1 unit console;
3 interface
4 const
5 version='BETA 8 FIX';
6 var
7 osadki:boolean;
8 bl_upd:integer;
9 s_get_drp:boolean;
10 particle_upd:boolean;
11 drw_back:boolean;
12 drw_sm:boolean;
13 s_max_fps:integer;
14 s_jpeg_quality:integer;
15 drawgui:boolean;
16 light_type:integer;
18 ifosad:boolean;
19 //s_particles:boolean; - module
21 load_sm:integer;
22 load_sky_siz:integer;
23 load_back_tex:boolean;
24 load_weather_tex:boolean;
25 load_particles_tex:boolean;
26 load_light_tex:boolean;
27 load_gui_tex:boolean;
29 menu_background:integer;
31 load_minimap_tex:boolean;
33 //load_key_tex:integer;
35 drw_stars:boolean;
37 cheats:boolean;
39 sd:string;
41 //max_particles:integer; - module
43 procedure save_settings;
44 procedure load_settings;
45 procedure call_console;
46 procedure exec(s, search:string; acces:boolean);
47 procedure addToLog(str:string);
49 implementation
50 uses keyboard,particles_store,vars,maps,items,canvas,mob,worldgen,jsr75i,particles,func, player,sensor, drop, inv, furnace, items_store, video;
51 const
52 CON_LOG_SIZE=9;
53 PARSER_MAX_STR=15;
54 MAX_IMGREG=2;
55 var
56 logSTR: array [0..CON_LOG_SIZE] of string;
57 lastCommand:string;
59 parseStr:string;
60 EOFstr, ENDstr:boolean;
62 stack: array [0..0] of integer;
63 stack_pointer:integer;
65 autoexec_acces:boolean;
66 regimg:image;
68 procedure resetStack(size:integer);
69 begin
70 stack_pointer:=0;
71 size:=size+1;
72 bytecode
73 iload 0;
74 newarray 10;
75 putstatic field 'console', 'stack', '[I';
76 end;
77 end;
79 procedure pushStack(i:integer;);
80 begin
81 stack[stack_pointer]:=i;
82 stack_pointer:=stack_pointer+1;
83 end;
85 function popStack:integer;
86 begin
87 stack_pointer:=stack_pointer-1;
88 popStack:=stack[stack_pointer];
89 end;
91 procedure swapStack;
92 var
93 tmp:integer;
94 begin
95 tmp:=stack[stack_pointer-2];
96 stack[stack_pointer-2]:=stack[stack_pointer-1];
97 stack[stack_pointer-1]:=tmp;
98 end;
100 procedure dupStack;
101 begin
102 stack[stack_pointer]:=stack[stack_pointer-1];
103 stack_pointer:=stack_pointer+1;
104 end;
106 procedure resetTmpImg;
107 var
108 nullimg:image;
109 begin
110 regimg:=nullimg;
111 end;
113 procedure addToLog(str:string);
114 var
115 i:integer;
116 begin
117 debug('::'+str);
118 for i:=CON_LOG_SIZE-1 downto 0 do
119 logSTR[i+1]:=logSTR[i];
120 logSTR[0]:=str;
121 end;
123 procedure setTexture(img:image; name:string; i:integer);
124 begin
125 name:=UpCase(name);
126 if name='BLOCK' then
127 begin
128 tex[i]:=img;
129 tex8[i]:=resize_image(img, 8, 8);
130 end;
131 else
132 if name='ITEM' then
133 begin
134 item[i]:=img;
135 item8[i]:=resize_image(img, 8, 8);
136 end;
137 else
138 if name='VKEY' then
139 setVkeyImg(img, i);
140 else
141 addToLog('Error: unknown texture type "'+name+'"');
142 end;
144 procedure save_settings;
145 var
146 rs:recordstore;
147 t:integer;
148 begin
149 deleteRecordStore('S');
150 rs:=openRecordStore('S');
151 t:=addRecordStoreEntry(rs,version);
152 t:=addRecordStoreEntry(rs,''+light_type);
153 t:=addRecordStoreEntry(rs,''+ifosad);
154 t:=addRecordStoreEntry(rs,''+s_particles);
155 t:=addRecordStoreEntry(rs,''+drawgui);
156 t:=addRecordStoreEntry(rs,''+s_jpeg_quality);
157 t:=addRecordStoreEntry(rs,''+load_key_tex);
158 closeRecordStore(rs);
159 end;
161 function sett_ld_bool(s:string):boolean;
162 begin
163 if s='true' then sett_ld_bool:=true;
164 end;
166 procedure load_settings;
167 var
168 rs:recordstore;
169 begin
170 rs:=openRecordStore('S');
171 if readRecordStoreEntry(rs,1)<>version then
172 begin
173 debug(readRecordStoreEntry(rs,1));
174 closeRecordStore(rs);
175 exit;
176 end;
177 light_type:=stringtointeger(readRecordStoreEntry(rs,2));
178 ifosad:=sett_ld_bool(readRecordStoreEntry(rs,3));
179 s_particles:=sett_ld_bool(readRecordStoreEntry(rs,4));
180 drawgui:=sett_ld_bool(readRecordStoreEntry(rs,5));
181 s_jpeg_quality:=stringtointeger(readRecordStoreEntry(rs,6));
182 load_key_tex:=stringtointeger(readRecordStoreEntry(rs,7));
183 closeRecordStore(rs);
184 end;
186 function isEOS(c:integer):boolean;
187 var
188 ch:char;
189 begin
190 ch:=chr(c);
191 if (ch=#$0A) or (ch=#$0D) then
192 isEOS:=true;
193 end;
195 function isSpace(c:integer;):boolean;
196 var
197 ch:char;
198 begin
199 ch:=chr(c);
200 if ((ch=' ') or (ch=#$09) or (ch=#$0B) or isEOS(c)) then
201 isSpace:=true;
202 end;
204 function nextByte(res:resource):integer;
205 var
206 i:integer;
207 begin
208 i:=ReadByte(res);
209 if i=EOF then
210 EOFstr:=true;
211 if isEOS(i) then
212 ENDstr:=true;
214 nextByte:=i and $FF;
215 end;
217 function ReadString(res:resource):string;
218 var
219 b:integer;
220 tmpstr:string;
221 begin
222 ENDstr:=false;
223 repeat
224 b:=nextByte(res);
225 if EOFstr or ENDstr then
226 break;
228 tmpstr:=tmpstr+chr(b);
229 forever;
230 ReadString:=tmpstr;
231 end;
233 function nextChar:integer;
234 var
235 i:integer;
236 begin
237 ENDstr:=false;
238 if length(parseStr)>0 then
239 begin
240 i:=ord(getChar(parseStr, 0));
241 parseStr:=copy(parseStr, 1, length(parseStr));
242 if isEOS(i) then
243 ENDstr:=true;
244 end;
245 else
246 begin
247 parseStr:='';
248 ENDstr:=true;
249 end;
251 nextChar:=i;
252 end;
254 procedure clearSpaces;
255 var
256 i:integer;
257 begin
258 repeat
259 i:=nextChar;
260 if ENDstr then
261 exit;
263 {Symbol ';' is one line commentary}
264 if i=$3B then
265 begin
266 repeat
267 i:=nextChar;
268 if ENDstr then
269 exit;
270 forever;
271 end;
273 if isSpace(i)=false then
274 begin
275 //Go back
276 parseStr:=chr(i)+parseStr;
277 exit;
278 end;
279 forever;
280 end;
282 function nextWord:string;
283 var
284 str:string;
285 i:integer;
286 begin
287 ENDstr:=false;
288 clearSpaces;
289 repeat
290 i:=nextChar;
292 if ENDstr then
293 begin
294 nextWord:=str;
295 exit;
296 end;
298 if isSpace(i) then
299 begin
300 //Go back
301 parseStr:=chr(i)+parseStr;
302 nextWord:=str;
303 exit;
304 end;
305 else
306 str:=str+chr(i);
307 forever;
308 end;
310 function strToBool(str:string):boolean;
311 begin
312 str:=UpCase(str);
313 if str='TRUE' then
314 strToBool:=true;
315 else
316 if str='FALSE' then
317 strToBool:=true;
318 else
319 if StringToInteger(str)<>0 then
320 strToBool:=true;
321 else
322 strToBool:=false;
323 end;
325 //Перевод строки в целое число. base - система счисления
326 function Str2Dec(str:string; base:integer;):integer;
327 var
328 i, tmp, res:integer;
329 ch:char;
330 neg:boolean;
331 begin
332 str:=UpCase(str);
333 if GetChar(str, 0)='-' then
334 begin
335 neg:=true;
336 i:=i+1;
337 end;
339 for i:=i to length(str)-1 do
340 begin
341 ch:=GetChar(str, i);
342 if ((ch>='0') and (ch<='9')) then
343 tmp:=ord(ch)-$30;
344 else
345 if ((ch>='A') and (ch<=chr($36+base))) then
346 tmp:=ord(ch)-$37;
347 else
348 begin
349 addToLog('Error! I cant decode "'+str+'" -> "'+ch+'"');
350 Str2Dec:=0;
351 exit;
352 end;
354 res:=res*base+tmp;
355 end;
357 if neg then
358 Str2Dec:=-res;
359 else
360 Str2Dec:=res;
361 end;
363 function getVar(name:string):integer;
364 begin
365 name:=UpCase(name);
367 if name='SCREEN_W' then
368 getVar:=getWidth;
369 else
370 if name='SCREEN_H' then
371 getVar:=getHeight;
372 else
373 addToLog('Unknown variable "'+name+'"');
374 end;
376 procedure setVar(name:string; value:integer);
377 begin
378 name:=UpCase(name);
380 addToLog('I cant set variable "'+name+'"');
381 end;
383 function DecodeInt(str:string):integer;
384 var
385 head:char;
386 num:string;
387 begin
388 if str='' then
389 begin
390 addToLog('DecodeInt getted null string!');
391 DecodeInt:=0;
392 exit;
393 end;
395 str:=UpCase(str);
396 head:=getchar(str, 0);
397 num:=copy(str, 1, length(str));
399 if str='TRUE' then
400 DecodeInt:=1;
401 else
402 if str='FALSE' then
403 DecodeInt:=0;
404 else
405 if str='POP' then
406 DecodeInt:=popStack;
407 else
408 if head='$' then
409 DecodeInt:=getVar(num);
410 else
411 if (head='0') and (getchar(str, 1)='X') then
412 begin
413 DecodeInt:=Str2Dec(copy(str, 2, length(str)), 16);
414 end;
415 else
416 if (head='0') and (length(str)>1) then
417 begin
418 DecodeInt:=Str2Dec(num, 8);
419 end;
420 else
421 if head='B' then
422 begin
423 DecodeInt:=Str2Dec(num, 2);
424 end;
425 else
426 if ((head>='0') and (head<='9')) or (head='-') then
427 begin
428 DecodeInt:=Str2Dec(str, 10);
430 end;
431 else
432 addToLog('Error! I cant decode "'+str+'"');
433 end;
435 procedure exeCommand(str:string);
436 var
437 com, tmp, tmp2:string;
438 i:integer;
439 begin
440 parseStr:=str;
441 clearSpaces;
442 if parseStr='' then
443 exit;
445 com:=UpCase(nextWord);
447 if (cheats) or (autoexec_acces) or (gamemode=1) then
448 begin
449 if com='TIME' then
450 game_time:=decodeInt(nextWord);
451 else
452 if com='FLY' then
453 fly:=strToBool(nextWord);
454 else
455 if com='PL_HP' then
456 hp:=decodeInt(nextWord);
457 else
458 if com='PL_EP' then
459 hunger:=decodeInt(nextWord);
460 else
461 if com='GIVE' then
462 player.dropItem(decodeInt(nextWord), decodeInt(nextWord));
463 else
464 if com='PL_TP' then
465 begin
466 player.setX(decodeInt(nextWord));
467 player.setY(decodeInt(nextWord));
468 end;
469 else
470 if com='GAMEMODE' then
471 begin
472 gamemode:=decodeInt(nextWord);
473 fly:=false;
474 end;
475 else
476 {if com='KILL_MOBS' then
477 for i:=0 to 31 do
478 begin
479 mob[i].m_type:=0;
480 mob[i].m_hp:=0;
481 end;
482 else}
483 if com='SPAWN' then
484 begin
485 player.setX(get_spawn_x*16+4);
486 player.setY(get_spawn_y*16);
487 end;
488 else
489 {if com='SPAWN_MOBS' then
490 s_spawn_mob:=strToBool(nextWord);
491 else}
492 {if com='SURVIVAL' then
493 begin
494 fly:=false;
495 gamemode:=0;
496 hp:=20;
497 hunger:=20;
498 for i:=0 to 35 do
499 begin
500 inv[i].item_i:=0;
501 inv[i].sum_i:=0;
502 end;
503 end;
504 else}
505 if com='CLEAR_INVENTORY' then
506 begin
507 inv.resetData;
508 end;
509 else
511 end;
513 if com='I_AM_CHEATER' then
514 begin
515 if nextWord=#$36+#$36+#$36 then
516 cheats:=not cheats;
517 else
518 cheats:=false;
519 end;
520 else
521 if com='HALT' then
522 halt;
523 else
524 if com='WEATHER' then
525 osadki:=strToBool(nextWord);
526 else
527 {if com='MEGASPAWN' then
528 megaspawn;
529 else}
530 if com='REF_DRP' then
531 ref_drp:=strToBool(nextWord);
532 else
533 if com='BL_UPD' then
534 bl_upd:=decodeInt(nextWord);
535 else
536 if com='GET_DRP' then
537 s_get_drp:=strToBool(nextWord);
538 else
539 {if com='AI_UPD' then
540 ai_upd:=strToBool(nextWord);
541 else}
542 if com='PRT_UPD' then
543 particle_upd:=strToBool(nextWord);
544 else
545 if com='MAX_FPS' then
546 s_max_fps:=decodeInt(nextWord); else
547 if com='DRW_BACK' then
548 drw_back:=strToBool(nextWord);
549 else
550 {if com='DRW_MOBS' then
551 drw_mobs:=strToBool(nextWord);
552 else}
553 if com='DRP_PHY' then
554 drp_phy:=strToBool(nextWord);
555 else
556 if com='DRW_SM' then
557 drw_sm:=strToBool(nextWord);
558 else
559 if com='JPEG_Q' then
560 begin
561 s_jpeg_quality:=decodeInt(nextWord);
562 if s_jpeg_quality>100 then
563 s_jpeg_quality:=100;
564 else if s_jpeg_quality<0 then
565 s_jpeg_quality:=0;
566 end;
567 else
568 if com='LOAD_SM' then
569 load_sm:=decodeInt(nextWord);
570 else
571 if com='S_WEATHER' then
572 ifosad:=strToBool(nextWord);
573 else
574 if com='S_HIDE_GUI' then
575 drawgui:=strToBool(nextWord);
576 else
577 if com='S_LIGHT' then
578 light_type:=decodeInt(nextWord);
579 else
580 if com='S_PARTICLES' then
581 s_particles:=strToBool(nextWord);
582 else
583 if com='LOAD_SKY' then
584 load_sky_siz:=decodeInt(nextWord);
585 else
586 {if com='LOAD_MOB_TEX' then
587 load_mob_tex:=strToBool(nextWord);
588 else}
589 if com='LOAD_BACK_TEX' then
590 load_back_tex:=strToBool(nextWord);
591 else
592 if com='LOAD_WEATHER_TEX' then
593 load_weather_tex:=strToBool(nextWord);
594 else
595 if com='LOAD_PARTICLES_TEX' then
596 load_particles_tex:=strToBool(nextWord);
597 else
598 if com='LOAD_LIGHT_TEX' then
599 load_light_tex:=strToBool(nextWord);
600 else
601 if com='LOAD_GUI_TEX' then
602 load_gui_tex:=strToBool(nextWord);
603 else
604 if com='MENU_BACKGROUND' then
605 menu_background:=decodeInt(nextWord);
606 else
607 if com='DRW_DRP' then
608 drw_drp:=strToBool(nextWord);
609 else
610 if com='DRW_STARS' then
611 drw_stars:=strToBool(nextWord);
612 else
613 if com='SV_SETT' then
614 save_settings;
615 else
616 if com='LD_SETT' then
617 load_settings;
618 else
619 if com='LOAD_MINIMAP_TEX' then
620 load_minimap_tex:=strToBool(nextWord);
621 else
622 if com='MAX_PARTICLES' then
623 begin
624 max_particles:=decodeInt(nextWord);
625 reset_particles(max_particles+1);
626 end;
627 else
628 if com='EXEC' then
629 begin
630 tmp:=nextWord;
631 exec(nextWord, tmp, autoexec_acces);
632 end;
633 else
634 if com='RESET_ITEMS' then
635 begin
636 resetItems(decodeInt(nextWord)+1);
637 //addToLog('Max items: '+decodeInt(parsed_str[1]));
638 end;
639 else
640 if com='SET_ITEM' then
641 begin
642 setItemData(decodeInt(nextWord),
643 decodeInt(nextWord),
644 decodeInt(nextWord),
645 decodeInt(nextWord),
646 decodeInt(nextWord),
647 decodeInt(nextWord));
648 end;
649 else
650 if com='RESET_BLOCKS' then
651 begin
652 resetBlocks(decodeInt(nextWord)+1);
653 //addToLog('Max blocks: '+decodeInt(parsed_str[1]));
654 end;
655 else
656 if com='SET_BLOCK' then
657 begin
658 setBlockData(decodeInt(nextWord),
659 decodeInt(nextWord),
660 decodeInt(nextWord),
661 decodeInt(nextWord),
662 decodeInt(nextWord),
663 decodeInt(nextWord),
664 decodeInt(nextWord),
665 decodeInt(nextWord),
666 decodeInt(nextWord));
667 end;
668 else
669 if com='RESET_TOOLS' then
670 begin
671 resetTools(decodeInt(nextWord)+1);
672 //addToLog('Max tools: '+decodeInt(parsed_str[1]));
673 end;
674 else
675 if com='SET_TOOL' then
676 begin
677 setToolData(decodeInt(nextWord),
678 decodeInt(nextWord),
679 decodeInt(nextWord),
680 decodeInt(nextWord),
681 decodeInt(nextWord));
682 end;
683 else
684 if com='RESET_FUELS' then
685 begin
686 furnace.setMaxFuel(decodeInt(nextWord));
687 //addToLog('Max fuel: '+decodeInt(parsed_str[1]));
688 end;
689 else
690 if com='SET_FUEL' then
691 begin
692 furnace.initFuel(decodeInt(nextWord),
693 decodeInt(nextWord),
694 decodeInt(nextWord));
695 end;
696 else
697 if com='RESET_RECIPES' then
698 begin
699 furnace.setMaxRecipes(decodeInt(nextWord));
700 //addToLog('Max recipes: '+decodeInt(parsed_str[1]));
701 end;
702 else
703 if com='SET_RECIPE' then
704 begin
705 furnace.initRecipe(decodeInt(nextWord),
706 decodeInt(nextWord),
707 decodeInt(nextWord));
708 end;
709 else
710 if com='RESET_CRAFTS' then
711 begin
712 resetCrafts(decodeInt(nextWord));
713 //addToLog('Max crafts: '+decodeInt(parsed_str[1]));
714 end;
715 else
716 if com='SET_CRAFT_IN' then
717 begin
718 setCraftIn(decodeInt(nextWord),
719 decodeInt(nextWord),
720 decodeInt(nextWord),
721 decodeInt(nextWord));
722 end;
723 else
724 if com='SET_CRAFT_OUT' then
725 begin
726 setCraftOUT(decodeInt(nextWord),
727 decodeInt(nextWord),
728 decodeInt(nextWord),
729 decodeInt(nextWord));
730 end;
731 else
732 if com='RESET_BLOCKS_TEX' then
733 begin
734 initBlockTex(decodeInt(nextWord));
735 end;
736 else
737 if com='RESET_ITEMS_TEX' then
738 begin
739 initItemTex(decodeInt(nextWord));
740 end;
741 else
742 if com='LOAD_TEX' then
743 regimg:=ld_tex(nextWord, '/'+sd+'/cavecraft/', '');
744 else
745 if com='RESET_TEX' then
746 resetTmpImg;
747 else
748 if com='SET_TEX' then
749 setTexture(regimg,
750 nextWord,
751 decodeInt(nextWord));
752 if com='SET_CANV_TEX' then
753 begin
754 tmp:=nextWord;
755 tmp2:=nextWord;
756 setTexture(rotate_image_from_image(regimg,
757 decodeInt(nextWord),
758 decodeInt(nextWord),
759 decodeInt(nextWord),
760 decodeInt(nextWord),
761 0),
762 tmp,
763 decodeInt(tmp2));
764 end;
765 else
766 if com='SET_MAX_ITEM_LIST' then
767 setMaxItemList(decodeInt(nextWord));
768 else
769 if com='SET_ITEM_LIST' then
770 setItemList(decodeInt(nextWord),
771 decodeInt(nextWord));
772 else
773 if com='BIND_KEY' then
774 begin
775 tmp:=nextWord;
776 for i:=0 to MAX_KEY_BIND do
777 keyboard.bindKey(decodeInt(tmp), i, decodeInt(nextWord));
778 end;
779 else
780 if com='STACK' then
781 resetStack(decodeInt(nextWord));
782 else
783 if com='PUSH' then
784 pushStack(decodeInt(nextWord));
785 else
786 if com='POP' then
787 i:=popStack;
788 else
789 if com='SWAP' then
790 swapStack;
791 else
792 if com='DUP' then
793 dupStack;
794 else
795 if com='ADD' then
796 pushStack(popStack+popStack);
797 else
798 if com='SUB' then
799 begin
800 i:=popStack;
801 pushStack(popStack-i);
802 end;
803 else
804 if com='MUL' then
805 pushStack(popStack*popStack);
806 else
807 if com='DIV' then
808 begin
809 i:=popStack;
810 pushStack(popStack/i);
811 end;
812 else
813 if com='MOD' then
814 begin
815 i:=popStack;
816 pushStack(popStack mod i);
817 end;
818 else
819 if com='SET' then
820 setVar(nextWord, decodeInt(nextWord));
821 else
822 if com='POPSET' then
823 setVar(nextWord, popStack);
824 else
825 if com='MAX_VKEYS' then
826 resetVirtualKeyboard(decodeInt(nextWord));
827 else
828 if com='SET_VKEY' then
829 bindVKey(decodeInt(nextWord),
830 decodeInt(nextWord),
831 decodeInt(nextWord),
832 decodeInt(nextWord));
833 else
834 if com='SET_RESOLUTION' then
835 initVideo(decodeInt(nextWord), decodeInt(nextWord), strToBool(nextWord));
836 else
837 //addToLog('Unknown command "'+com+'"');
838 end;
840 procedure call_console;
841 var
842 commandTxt:integer;
843 i, tmpid:integer;
844 exitCmd, exeCmd, Clicked:command;
845 str:string;
846 begin
848 setFont(FONT_FACE_SYSTEM,FONT_STYLE_PLAIN,FONT_SIZE_SMALL);
850 repeat
851 ClearForm;
853 exitCmd:=createCommand('Exit', CM_EXIT, 1);
854 exeCmd:=createCommand('Execute', CM_OK, 1);
855 addCommand(exitCmd);
856 addCommand(exeCmd);
858 commandTxt:=formAddTextField('Enter command:', ''+lastCommand, 32, TF_ANY);
860 for i:=0 to CON_LOG_SIZE do
861 tmpid:=formAddString(logSTR[i]+chr(10));
863 ShowForm;
864 Repaint;
866 repeat
867 Clicked:=getClickedCommand;
868 if Clicked=exitCmd then
869 begin
870 lastCommand:=formGetText(commandTxt);
871 showCanvas;
872 exit;
873 end;
874 else
875 if Clicked=exeCmd then
876 begin
877 str:=formGetText(commandTxt);
878 addToLog(str);
879 exeCommand(str);
880 lastCommand:='';
881 break;
882 end;
883 forever;
884 forever;
885 end;
887 procedure exec(s, search:string; acces:boolean);
888 var
889 res:resource;
890 str:string;
891 tmp_acces, tmpEOF:boolean;
892 begin
893 tmp_acces:=autoexec_acces;
894 autoexec_acces:=acces;
896 search:=UpCase(search);
898 if search='LOCAL' then
899 begin
900 addToLog('Load file "'+s+'" at LOCAL!');
901 res:=OpenResource('/'+s);
902 end;
903 else
904 if search='SD' then
905 begin
906 if open_file('/'+sd+'/cavecraft/'+s)=1 then
907 begin
908 addToLog('Load file "'+s+'" at SD!');
909 res:=get_stream;
910 end;
911 end;
912 else
913 if search='AUTO' then
914 begin
915 addToLog('path "/'+sd+'/cavecraft/'+s+'"');
916 if file_exists('/'+sd+'/cavecraft/'+s)=1 then
917 begin
918 if open_file('/'+sd+'/cavecraft/'+s)=1 then
919 begin
920 addToLog('Load file "'+s+'" at SD(AUTO)!');
921 res:=get_stream;
922 end;
923 end;
924 else
925 begin
926 addToLog('Load file "'+s+'" at LOCAL(AUTO)!');
927 res:=OpenResource('/'+s);
928 end;
929 end;
930 else
931 begin
932 addToLog('Unknown load type "'+search+'", file "'+s+'" not executed!');
933 autoexec_acces:=tmp_acces;
934 exit;
935 end;
937 if ResourceAvailable(res) then
938 repeat
939 str:=ReadString(res);
940 tmpEOF:=EOFstr;
941 //addToLog('Exec: "'+str+'"');
942 exeCommand(str);
943 EOFstr:=tmpEOF;
944 until EOFstr;
945 else
946 addToLog('Execute file "'+s+'" not found!');
948 CloseResource(res);
949 autoexec_acces:=tmp_acces;
950 end;
952 initialization
954 end.