DEADSOFTWARE

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