Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
Own Scripter in Delphi
Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Own Scripter in Delphi

  1. #1

    Own Scripter in Delphi

    Hello
    I'm going to show you how you can write own scripter (pascal interpreter).

    at first you need to get RemObject Pascal Interpreter

    You can find it here

    www.remobjects.com

    Download

    Ok now just install this package :P


    Open new project in Delphi and put at form memmo and 2x buttons



    and Pascal Scripter component



    Now you need to add some lines to uses

    Code:
    uses
    ... uPSRuntime,uPSCompiler;

    Ok so lets set event onClick for button1 named "Compile"

    this is a full code for button1 click:
    Code:
    procedure TForm1.Button1Click(Sender: TObject);
      procedure OutputMessages;
      var
        l: Longint;
        b: Boolean;
      begin
        b := False;
    
        for l := 0 to PSScript1.CompilerMessageCount - 1 do
        begin
          showmessage('Compiler: '+ PSScript1.CompilerErrorToStr(l));
          if (not b) and (PSScript1.CompilerMessages[l] is TIFPSPascalCompilerError) then
          begin
            b := True;
            Memo1.SelStart := PSScript1.CompilerMessages[l].Pos;
          end;
        end;
      end;
    begin
      PSScript1.Script.Assign(Memo1.Lines);
      if PSScript1.Compile then
      begin
        OutputMessages;
        showmessage('Compiled succesfully');
        if not PSScript1.Execute then
        begin
          Memo1.SelStart := PSScript1.ExecErrorPosition;
          showmessage(PSScript1.ExecErrorToString +' at '+Inttostr(PSScript1.ExecErrorProcNo)+'.'+Inttostr(PSScript1.ExecErrorByteCodePosition));
        end;
      end else
      begin
        OutputMessages;
        showmessage('Compiling failed');
      end;
    end;
    from now you can compile your code (F9), write in memmo

    Code:
    Begin
    end.
    and click "Compile"
    You will see a messagebox with message "Compiled succesfully"
    Great!

    Now I will show how to add your own functions and procedures to scripter

    First you need to create function or procedure that you will use in you scripter for example ShowMSG(s:String);

    Code:
    Procedure ShowMSG(s:String);
    begin
      showmessage(s);
    end;
    Double click at OnCompile event in PSScript1

    Code:
    procedure TForm1.PSScript1Compile(Sender: TPSScript);
    begin
      Sender.AddFunction(@ShowMSG,'procedure ShowMSG(s:string);');
    end;
    compile (F9) and write in memmo this code:

    Code:
    Begin
    showMSG('lol');
    end.
    You will see a message that code was sucessfull compiled and next message "lol"
    You can try to compile something more difficult like

    Code:
    var
    a:byte;
    b:byte;
    c:byte;
    begin
    a:=5;
    b:=4;
    for c:=0 to 2 do
     begin
     ShowMSG(inttostr(a+b));
     end;
    end.

    This is all in this lesson :P in next one I will show you how to import own classes into scripter

  2. #2

    Own Scripter in Delphi

    Are you ready for next lesson? ^^

    So now when we know how to compile simple scripts we could try to add a bit professional ones :P
    There is one powerfull tool in Remobject Pascal interperter package, its named Unit importer.

    How do we use it? At first we need a new unit with some functions :P

    As a example I will use my memmory reading unit.

    http://nbot.pl/norbert/memmory.pas

    Save it as a memmory.pas

    Now we need to run Unit Importer



    open

    File -> Settings

    now we need to set directory to our project

    almost done !

    Now we need to open (ctrl+O) memmory.pas and press F9.
    Great! Our file was converted into a uPSI_memmory.pas

    Close Unit importer and go back to a Delphi.

    into unit1 uses we need to add

    Code:
    uPSI_memmory
    and try to compile it, if u get error



    just delete this line or change it to a

    Code:
    //RIRegister_memmory(ri);

    in form1 onCreate event we need to import our module to a scripter

    Code:
    procedure TForm1.FormCreate(Sender: TObject);
    var
    mem:TPSplugin;
    begin
    mem:= TPSImport_memmory.Create(self);
    TPSPluginitem(PSScript1.Plugins.Add).Plugin:=mem;
    end;
    from now its possible to use unit memmory.pas in our scripter :P

    And now simple script to test our scripter, reading player pos (X Y Z) and showing it in a new window :P

    Code:
    var
    z,y,x:integer;
    Begin
    hook;
    z:=readmemint($62FAF8);
    y:=readmemint($62FAF8+4);
    x:=readmemint($62FAF8+8);
    ShowMSG(inttostr(x)+' '+inttostr(y)+' '+inttostr(z));
    end.

    So this is all :P Sorry for my english, hope that you understand me
    If u use SynEdit you can add pascal highlighters and your scripter will be more professional


  3. #3
    Programmer
    Join Date
    Mar 2007
    Posts
    770

    Own Scripter in Delphi

    Cool, i found something like that when i did delphi, but never put it to use!

  4. #4

    Own Scripter in Delphi

    Quote Originally Posted by ame
    Cool, i found something like that when i did delphi, but never put it to use!
    It's kinda usefull when u have a good API :P

  5. #5
    Senior Member
    Join Date
    Mar 2007
    Posts
    1,323

    Own Scripter in Delphi

    Next thing is to add syntax highlighting to it etc etc :P

  6. #6

    Own Scripter in Delphi

    Quote Originally Posted by OsQu
    Next thing is to add syntax highlighting to it etc etc :P
    Its simple when u are using SynEdit ^^ there is a component that whill add u syntax highlighting automaticly for pascal ^^

  7. #7

    Own Scripter in Delphi

    Its all !! Now u can create your own scripter in few simple steps :P Hope that somebody will use it xD

  8. #8

    Own Scripter in Delphi

    Gratz on doublepost ^^ and btw ;p this tutorial sucks for my... why? cuz there are lots of interpreters on internet =) much more better than remobject...

  9. #9
    Programmer
    Join Date
    Mar 2007
    Posts
    770

    Own Scripter in Delphi

    Post some examples of better interpreters then

  10. #10

    Own Scripter in Delphi

    w8 ill find one and post it here i use it and btw yaboo... you can use multi-classes in it ^^ like mychar.container[0].slot[0].movetoslot ^^ etc

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •