Results 1 to 7 of 7

Thread: [Reflection] Item,Npc, and Object Id getter

  1. #1
    Join Date
    Feb 2016
    Posts
    13
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default [Reflection] Item,Npc, and Object Id getter

    Ok so I wrote my first script, it fetches the IDs of the npcs, objects, and items on your screen and labels them.
    I wrote this since I was finding it a pain to get the ids manually and a lot of the time the id's and the names didn't match up. I know the code isn't super elegant. I'd love to hear feedback!

    Note that if there are too many objects around you can just comment out the functions that labels them.

    Code:
    // 2016 Bran_corn @villavu.com
    //use this script to get ids ect
    
    
    
    program new;
    {$DEFINE SMART}
    {$i aerolib\aerolib.simba }
    {$i reflection/reflection.Simba}
    {$I SRL-OSR\SRL\utilities\drawing.simba}
    
    procedure PrintNpcIdToScreen();
    var
      Npcs :TReflectNPCArray ;
      i: integer;
      ScreenCoord : TPoint;
    begin
    
        WriteLn('----------------------------------------------------------');
        WriteLn('labelling npcs...');
        Npcs.GetAll;
        for i:= 0 to high(Npcs) do begin
            ScreenCoord :=   Npcs[i].GetMsPoint;//TReflectionTiles.TileToMS(Npcs[i].GetTile);
    
            if (((ScreenCoord.X > 50) and (ScreenCoord.X < 550)) and ((ScreenCoord.Y > 50) and (ScreenCoord.Y < 350)))   then begin
              WriteLn('');
              WriteLn(Npcs[i].GetName);
              WriteLn(Npcs[i].Getid );
              OS_SMART.graphics().drawCircle(ScreenCoord,3,clred, True);
              OS_SMART.graphics().DrawClippedText(Npcs[i].GetName+'     ' +InttoStr(Npcs[i].Getid) ,statChars,ScreenCoord);
            end;
        end;
    end;
    
    
    procedure PrintItemIdToScreen();
    var
      Items :TReflectGroundItemArray ;
      Item :TReflectGroundItem;
      i: integer;
      ScreenCoord : TPoint;
    begin
        WriteLn('----------------------------------------------------------');
        WriteLn('labelling items...');
        Items.GetAll;
        for i:= 0 to high(Items) do begin
            Item:= Items[i];
            ScreenCoord :=   Item.GetMsPoint;//TReflectionTiles.TileToMS(Npcs[i].GetTile);
            //WriteLn(ScreenCoord);
            if (((ScreenCoord.X > 50) and (ScreenCoord.X < 550)) and ((ScreenCoord.Y > 50) and (ScreenCoord.Y < 350)))   then begin
              WriteLn('');
              WriteLn(Item.GetName);
              WriteLn(Item.Getid );
              OS_SMART.graphics().drawCircle(ScreenCoord,3,clblue, True);
              OS_SMART.graphics().DrawClippedText(Item.GetName +'     ' +InttoStr(Item.Getid) ,statChars,ScreenCoord,clblue);
            end;
        end;
    end;
    
    procedure PrintObjectIdToScreen();
    var
      myObjects :TReflectObjectArray ;
      myObject :TReflectObject;
      i: integer;
      ScreenCoord : TPoint;
    begin
        WriteLn('----------------------------------------------------------');
        WriteLn('labelling objects...');
        myObjects.GetAll(ObjGame,30) ;
        for i:= 0 to high(myObjects) do begin
            myObject:= myObjects[i];
            ScreenCoord :=   myObject.GetMsPoint;//TReflectionTiles.TileToMS(Npcs[i].GetTile);
            if (((ScreenCoord.X > 50) and (ScreenCoord.X < 550)) and ((ScreenCoord.Y > 50) and (ScreenCoord.Y < 350)))   then begin
              WriteLn('');
              WriteLn(myObject.GetName);
              WriteLn(myObject.GetId );
              OS_SMART.graphics().drawCircle(ScreenCoord,3,clpurple, True);
              OS_SMART.graphics().DrawClippedText(myObject.GetName +'      ' + inttostr(myObject.Getid ),statChars,ScreenCoord,clpurple);
            end;
        end;
    end;
    
    procedure setup();
    begin
       setDefaultZoom;
    end;
    
    begin
      initAL();
      Reflect.Setup;
      setup;
      While True do begin
        OS_SMART.graphics().Clear;
        ClearDebug;
        PrintNpcIdToScreen;
        PrintItemIdToScreen  ;
        PrintObjectIdToScreen  ;
        Wait(10000);
      end;
    end.

  2. #2
    Join Date
    Dec 2013
    Location
    Pitcairn Island
    Posts
    288
    Mentioned
    20 Post(s)
    Quoted
    166 Post(s)

    Default

    This is definitely something that is missing from the reflection include and should have been added a long time ago.

    Something like:

    Simba Code:
    Reflect.Smart.Graphics.DebugModels();
    //or preferably
    Reflect.Smart.Graphics.Debug(Models); //Items, Objects etc..

    would be really useful as this is a time consuming part of writing a script. @mudda_fudda; @Kyle; you down?

  3. #3
    Join Date
    Feb 2014
    Location
    UDFj-39546284
    Posts
    76
    Mentioned
    1 Post(s)
    Quoted
    43 Post(s)

    Default

    Very useful. thank you

  4. #4
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    I dont this will work correctly when there are multiple objects/npcs/grounditems on one tile

  5. #5
    Join Date
    Feb 2016
    Posts
    13
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Went on a trip for the last few days, back around now.

    Quote Originally Posted by Bulbasaur View Post
    Very useful. thank you
    Did you run it? Did it work find on your computer? (curious to make sure it works fine on other peoples' systems!)

    Quote Originally Posted by hoodz View Post
    I dont this will work correctly when there are multiple objects/npcs/grounditems on one tile
    Good point, I'll have to investigate what it does in those cases. When I wrote it the other night I was getting all round items as id=1 and name ="toolkit" due to reflection being out of date so I'll poke around and try and find a good way to display everything!

  6. #6
    Join Date
    Apr 2014
    Posts
    323
    Mentioned
    0 Post(s)
    Quoted
    131 Post(s)

    Default

    I'm grabbing this error

    Error: File "SRL-OSR\SRL\utilities\drawing.simba" not found at line 10
    If all pork-chops were perfect, we wouldn't have hot-dogs.

  7. #7
    Join Date
    Jul 2015
    Posts
    80
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    Awsome, i will be getting info reflection soon, this will be useful to me, thanks a bunch,

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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