Page 1 of 2 12 LastLast
Results 1 to 25 of 28

Thread: StringToID - a name to ID converter for osr

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

    Default StringToID - a name to ID converter for osr

    just a simple snippet that converts strings to ids.
    I made this because you cant pickup ground items with a string, only with IDs (with the current include).

    its using itemdb.biz to get the IDs.

    usage:
    Simba Code:
    stringToIDs([]);                                          {add a array of items you want the id of}
    stringToIDs(['Rune scimitar', 'Rune platelegs']);         {make sure you have CORRECT capitals}
    stringToIDs(['Iron bar*', 'Iron ore*']);                  {if you want to add a noted item add * at the end of the name}
    Simba Code:
    {author: Hoodz}
     
    function StringToID(StringName: string): Integer;
    var
      I: Integer;
      S, Ls, Cs: string;
      SArray: TStringArray;
      Noted: Boolean;
    begin
      Noted := false;
      if (StringMatch('*', StringName) > 0) then
      begin
        Noted := true;
        StringName := Replace(StringName, '*', '', []);
      end;
      LS := Replace(StringName, ' ', '+', []);
      S := GetPage('http://itemdb.biz/index.php?search=' + LS);
      Cs := Between('<div id="content">', '</font></', S);
      Cs := Between('<font color=''', '''>', Cs);
      if (Cs = 'red') then
      begin
        Writeln(StringName + ' Could not be found');
        Result := - 1;
        Exit;
      end;
      S := Between('<td><center>', StringName + '<', S);
      SArray := Explode('<b>', S);
      S := SArray[High(SArray)];
      SArray := Explode('</b>', S);
      S := SArray[0];
      if (S = '') then
      begin
        Writeln(StringName + ' Could not be found');
        Result := - 1;
        Exit;
      end;
      I := StrToInt(S);
      if (Noted) then
      begin
        Inc(I);
        Writeln('Item loaded: ' + StringName + ' (noted)  - ' + ' (' + IntToStr(I) + ')');
      end
      else
        Writeln('Item loaded: ' + StringName + '  - ' + ' (' + S + ')');
      Result := I;
    end;
     
    function StringToIDs(StringArray: array of string): array of Integer;
    var
      I, IntReturn: Integer;
      IntArray: array of Integer;
    begin
      for I := 0 to High(StringArray) do
      begin
        IntReturn := StringToID(StringArray[I]);
        if (IntReturn = - 1) then
          continue;
        SetLength(IntArray, Length(IntArray) + 1);
        IntArray[High(IntArray)] := intReturn;
      end;
      Result := IntArray;
    end;


    note: might not work 100%, if this is the case, please say it

    EDIT: might add some exceptions like coins if wanted

  2. #2
    Join Date
    Feb 2013
    Location
    Rimmington
    Posts
    319
    Mentioned
    33 Post(s)
    Quoted
    183 Post(s)

    Default

    Nice one!

    Things you could consider adding,
    - Rev number, that way it would fit for both 07 and Eoc
    - IDToString?





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

    Default

    Quote Originally Posted by Fitta View Post
    Nice one!

    Things you could consider adding,
    - Rev number, that way it would fit for both 07 and Eoc
    - IDToString?
    thanks

    rev number: there is not a reflection include for rs3 so there wont be any use for it.
    IDToString: not possible on itemdb.biz

  4. #4
    Join Date
    Feb 2013
    Location
    Rimmington
    Posts
    319
    Mentioned
    33 Post(s)
    Quoted
    183 Post(s)

    Default

    Quote Originally Posted by hoodz View Post
    thanks

    rev number: there is not a reflection include for rs3 so there wont be any use for it.
    IDToString: not possible on itemdb.biz
    Try searching for coins(ID 995), while the function will grab the upper one and result in wrong ID.





  5. #5
    Join Date
    Oct 2006
    Posts
    6,752
    Mentioned
    95 Post(s)
    Quoted
    532 Post(s)

    Default

    Awesome job Hoodz! I always meant on doing this but never did, should be quite useful for aio scripts for user setup.
    “The long-lived and those who will die soonest lose the same thing. The present is all that they can give up, since that is all you have, and what you do not have, you cannot lose.” - Marcus Aurelius

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

    Default

    Quote Originally Posted by Fitta View Post
    Try searching for coins(ID 995), while the function will grab the upper one and result in wrong ID.
    well thats because there are two coin ids for rev 317. this will also happen at some other items like herbs and clue scrolls

  7. #7
    Join Date
    Nov 2006
    Location
    Location, Location
    Posts
    1,126
    Mentioned
    6 Post(s)
    Quoted
    41 Post(s)

    Default

    Nice work - saves time on looting lists.

  8. #8
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    Are you serious? There is this object called ItemComposition. Just load that and get the name.

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

    Default

    Quote Originally Posted by tls View Post
    Are you serious? There is this object called ItemComposition. Just load that and get the name.
    im serious. thanks for your comment, i appreciate it not.



    Quote Originally Posted by Kave View Post
    Nice work - saves time on looting lists.
    thanks!

  10. #10
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    Quote Originally Posted by hoodz View Post
    im serious. thanks for your comment, i appreciate it not.
    Here let me spoon feed you a little.
    https://github.com/tlsdude/OSR-Refle...odes.simba#L77
    Take that function and feed it the ground item ID and you will have retrieved the ItemComposite from the runescape cache. It has several member, one of which, is the item name. The cache used is the itemCompositeCache. I have confidence you can work the rest out.

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

    Default

    Quote Originally Posted by tls View Post
    Here let me spoon feed you a little.
    https://github.com/tlsdude/OSR-Refle...odes.simba#L77
    Take that function and feed it the ground item ID and you will have retrieved the ItemComposite from the runescape cache. It has several member, one of which, is the item name.
    i didnt even develop grounditems..? i made it because there was no such thing in THE include

  12. #12
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    Alright it's seriously time for me to finish this include and release it so the community has it.

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

    Default

    Quote Originally Posted by tls View Post
    Alright it's seriously time for me to finish this include and release it so the community has it.
    gl do want you want, but i wont be making scripts for it

  14. #14
    Join Date
    Oct 2006
    Posts
    6,752
    Mentioned
    95 Post(s)
    Quoted
    532 Post(s)

    Default

    The problem is, that I think tls doesn't see is that his include will be in lape, with the main osr being in pascal script. So in order to use any reflection, you will be unable to use anything from the official include. That is why I would be very surprised if there are ever any scripts that would be released with the new include and the one that I started will still be the primary one. EVERY reflection script will have to be redone and all color functions will have to be changed to reflection. I always liked scripting a color script only using reflection for walking.
    “The long-lived and those who will die soonest lose the same thing. The present is all that they can give up, since that is all you have, and what you do not have, you cannot lose.” - Marcus Aurelius

  15. #15
    Join Date
    Sep 2014
    Location
    the Netherlands
    Posts
    136
    Mentioned
    7 Post(s)
    Quoted
    61 Post(s)

    Default

    Quote Originally Posted by elfyyy View Post
    The problem is, that I think tls doesn't see is that his include will be in lape, with the main osr being in pascal script. So in order to use any reflection, you will be unable to use anything from the official include. That is why I would be very surprised if there are ever any scripts that would be released with the new include and the one that I started will still be the primary one. EVERY reflection script will have to be redone and all color functions will have to be changed to reflection. I always liked scripting a color script only using reflection for walking.
    That's exactly my way of scripting :>

    Kinda surprised about this one, as I just recently was trying to script an item looter. Maybe kinda noobish, but what would be the best way of using item ID's to pick up items? Didn't quite find anything in the includes. Or I really missed it..
    Previously known as; Annonymus.

  16. #16
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    Quote Originally Posted by elfyyy View Post
    The problem is, that I think tls doesn't see is that his include will be in lape, with the main osr being in pascal script. So in order to use any reflection, you will be unable to use anything from the official include. That is why I would be very surprised if there are ever any scripts that would be released with the new include and the one that I started will still be the primary one. EVERY reflection script will have to be redone and all color functions will have to be changed to reflection. I always liked scripting a color script only using reflection for walking.
    There is a lape version of osr -.-
    Plus, the new srl will be lape.
    Plus, this include will actually be efficient.
    I'm not personally attacking you when I say the "unofficial" include is crap. The code you used to create it was old code that I helped write, and honestly it was crap. We were in the process of re-writing it when jagex started sending out different packs to different people based on ip address and we just didn't want to deal with it. A lot of the ideas I use in the current dev include are ideas that were brainstormed a long time ago for the improvement of reflection through smart. They will make scripts faster, more flexible, and more powerful(seeing as things like item composites will actually be implemented).

  17. #17
    Join Date
    Oct 2006
    Posts
    6,752
    Mentioned
    95 Post(s)
    Quoted
    532 Post(s)

    Default

    Quote Originally Posted by tls View Post
    There is a lape version of osr -.-
    Plus, the new srl will be lape.
    Plus, this include will actually be efficient.
    I'm not personally attacking you when I say the "unofficial" include is crap. The code you used to create it was old code that I helped write, and honestly it was crap. We were in the process of re-writing it when jagex started sending out different packs to different people based on ip address and we just didn't want to deal with it. A lot of the ideas I use in the current dev include are ideas that were brainstormed a long time ago for the improvement of reflection through smart. They will make scripts faster, more flexible, and more powerful(seeing as things like item composites will actually be implemented).
    True, there is a unofficial, quite buggy, never used version of osr in lape, kinda defeats the purpose of making a "official" reflection include that is forced to use either the unofficial lape include, or flight's AL include.

    People have been saying for months that a rewrite of the official include for osr will be converted to SRL6. Everybody know's the likelyhood of that happening isn't very great.

    I'm sure that your new include will be more efficient, don't see anybody denying that, especially the fact that lape is more efficient...

    I haven't seen you call the include "crap," as I was afk for most of the summer like I always am, and of course, I wouldn't take it personal, lately Meerkat has been the head of it while I was gone. The only reason I am bringing this up is I didn't think it was necessary for you to bash what hoodz wrote. Clearly you knew that the include didn't have item names, and either used that opportunity to point that out, or just be mean to hoodz for no reason. Many people using this include will find it VERY useful...

    I think that it is cool that you are rewriting it, the point that I was trying to make, is just don't be suprised if/when nobody uses it, and people still uses the current one. Because until the official osr is rewritten, I can guarantee you that nobody will write a script SOLEY using reflection. As much as I love using it, it definitely should be used as a supplement to color, or if not, there will inevitably be a function that is needed that isn't in reflection.

    Quote Originally Posted by Annonymus View Post
    That's exactly my way of scripting :>

    Kinda surprised about this one, as I just recently was trying to script an item looter. Maybe kinda noobish, but what would be the best way of using item ID's to pick up items? Didn't quite find anything in the includes. Or I really missed it..
    Glad you have been finding use of it! Check my guide in my signature for some help with the functions. Not sure if I have put info about ground item's yet, but I will surely add to the guide now that I will be more active!
    Last edited by Kyle; 09-25-2014 at 09:55 PM.
    “The long-lived and those who will die soonest lose the same thing. The present is all that they can give up, since that is all you have, and what you do not have, you cannot lose.” - Marcus Aurelius

  18. #18
    Join Date
    Feb 2013
    Location
    Rimmington
    Posts
    319
    Mentioned
    33 Post(s)
    Quoted
    183 Post(s)

    Default

    Quote Originally Posted by hoodz View Post
    gl do want you want, but i wont be making scripts for it
    Don't worry, I will though.

    Quote Originally Posted by elfyyy View Post
    The problem is, that I think tls doesn't see is that his include will be in lape, with the main osr being in pascal script. So in order to use any reflection, you will be unable to use anything from the official include. That is why I would be very surprised if there are ever any scripts that would be released with the new include and the one that I started will still be the primary one. EVERY reflection script will have to be redone and all color functions will have to be changed to reflection. I always liked scripting a color script only using reflection for walking.
    I'm certain from "stealing" parts of tls reflection github(heh, don't password it), that it works like a charm with AeroLib.

    To be quite honest there's no point to re-write anything, just take AL, make it the official old-school include and work from there? It's not like making a third include will help anyone. If there already is a good include, lets use it. Being stubborn about it will just lead to... oh right, nowhere.
    And to really make shit interesting there's a new forum part coming for tls reflection include(?)
    The current reflection include is a kebab without sauce, tls just brings the garlic sauce.

    Also what's the point to have a include in pascalscript if the support for it is close to nothing? Lape' it up, rape it up?





  19. #19
    Join Date
    Sep 2014
    Location
    the Netherlands
    Posts
    136
    Mentioned
    7 Post(s)
    Quoted
    61 Post(s)

    Default

    Quote Originally Posted by elfyyy View Post
    Glad you have been finding use of it! Check my guide in my signature for some help with the functions. Not sure if I have put info about ground item's yet, but I will surely add to the guide now that I will be more active!
    Ooh, awesome, gonna check it out right now! Thanks
    Previously known as; Annonymus.

  20. #20
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by elfyyy View Post
    I always liked scripting a color script only using reflection for walking.

    As much as I love using it, it definitely should be used as a supplement to color, or if not, there will inevitably be a function that is needed that isn't in reflection.
    Absolutely not. Why should reflection (something better) be held back or used in a limited way in favour of colour, or be a "supplement" to it?

    It's superior in every way.. That statement's just wrong. I can never understand the logic/reasoning behind such a statement. What do you mean by there will be a function inevitably missing? As a scripter, you make your own functions if no such function exists..

    The reflection includes are there only to provide a base api.. Just like colour does. I am fairly certain there isn't anything special in the colour include that the reflection ones cannot do.


    Quote Originally Posted by Fitta View Post
    Lape' it up, rape it up?
    What? :l
    Last edited by Brandon; 09-25-2014 at 11:28 PM.
    I am Ggzz..
    Hackintosher

  21. #21
    Join Date
    Oct 2006
    Posts
    6,752
    Mentioned
    95 Post(s)
    Quoted
    532 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    Absolutely not. Why should reflection (something better) be held back or used in a limited way in favour of colour, or be a "supplement" to it?

    It's superior in every way.. That statement's just wrong. I can never understand the logic/reasoning behind such a statement. What do you mean by there will be a function inevitably missing? As a scripter, you make your own functions if no such function exists..

    The reflection includes are there only to provide a base api.. Just like colour does. I am fairly certain there isn't anything special in the colour include that the reflection ones cannot do.
    No I hear you completely and agree definitely. I should have said "in my opinion". I just have always preferred to script with color used primarily and reflection to the side. I enjoy using color as it can be more of a challenge and It seems other people do as well!

    But, having a lape reflection include and pascal script main include removes that option and forces people to choose one or the other.

    That's all I will say on this, when tls finishes up that will allow people to use his if they want to solely use reflection or keep using the current one if they prefer both!
    “The long-lived and those who will die soonest lose the same thing. The present is all that they can give up, since that is all you have, and what you do not have, you cannot lose.” - Marcus Aurelius

  22. #22
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by elfyyy View Post
    That's all I will say on this, when tls finishes up that will allow people to use his if they want to solely use reflection or keep using the current one if they prefer both!

    Even though it is your opinion, WHY do you prefer colour? If there is a more efficient way that makes your scripts more accurate and efficient, why choose the less efficient or harder way?

    As for the difference between the two includes.. Meh. I don't see much wrong. I think it's nice to have options. I don't script or play anymore but I can't see a problem with options even though scripters would have a big switch.

    Other than an API difference, I can't see much difference between PS and Lape itself.
    I am Ggzz..
    Hackintosher

  23. #23
    Join Date
    Oct 2006
    Posts
    6,752
    Mentioned
    95 Post(s)
    Quoted
    532 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    Even though it is your opinion, WHY do you prefer colour? If there is a more efficient way that makes your scripts more accurate and efficient, why choose the less efficient or harder way?

    As for the difference between the two includes.. Meh. I don't see much wrong. I think it's nice to have options. I don't script or play anymore but I can't see a problem with options even though scripters would have a big switch.

    Other than an API difference, I can't see much difference between PS and Lape itself.
    Yeah, like I was saying, it definitely will be cool to have the second include to give people the option if they want to switch.

    Again, since I script for fun, to take time away from college, I don't always need it to be the most perfectly optimized script in every single aspect. I do it for fun and find the challenge of using color to be more fun for ME. Plus, some inaccuracy's and less efficiency can also add to some anti ban and more human like scripts, since we all know that humans don't play completely perfect!
    “The long-lived and those who will die soonest lose the same thing. The present is all that they can give up, since that is all you have, and what you do not have, you cannot lose.” - Marcus Aurelius

  24. #24
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    Even though it is your opinion, WHY do you prefer colour? If there is a more efficient way that makes your scripts more accurate and efficient, why choose the less efficient or harder way?

    As for the difference between the two includes.. Meh. I don't see much wrong. I think it's nice to have options. I don't script or play anymore but I can't see a problem with options even though scripters would have a big switch.

    Other than an API difference, I can't see much difference between PS and Lape itself.
    It's fun to have to write computer-vision based algorithms to solve such things, this is something that can be applied to other stuff then java-based game like RS, so it can be "useful" if you like to tinker with other computer-vision tasks as well.
    Going by some simple API and getting it to find a NPC by doing EG "ReflectionGetNPC(NPC_ID).position()" just aint no fun AT ALL.. And for scripters it "encourages lazyness", rather then producing new cool ways to do solve the problem, by using what the screen displays.

    I really do NOT like the use of Reflection, but meh, for the people who want the simplest way out, it's nice to have.
    Last edited by slacky; 09-26-2014 at 12:57 AM.
    !No priv. messages please

  25. #25
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    It's fun to have to write computer-vision based algorithms to solve such things, this is something that can be applied to other stuff then java-based game like RS, so it can be "useful" if you like to tinker with other computer-vision tasks as well.
    Going by some simple API and getting it to find a NPC by doing EG "ReflectionGetNPC(NPC_ID).position()" just aint no fun AT ALL.. And for scripters it "encourages lazyness", rather then producing new cool ways to do solve the problem, by using what the screen displays.

    I really do NOT like the use of Reflection, but meh, for the people who want the simplest way out, it's nice to have.
    I agree with the "fun" aspect of color scripting. I've made plenty of pure color scripts. But in the "laziness" aspect of reflection I entirely disagree. Yes, more scripts are released that are incredibly simple(ie findnpc('banker').click()). This doesn't promote laziness, it changes the "problem" that a scripter is trying to solve. They can focus more on the logic of the script, and less on the logic of finding something with complex algorithms(relatively complex). While a scripter progresses in skill, reflection allows them to not be anchored down with solving the screen finding things, and focus more on making an incredibly powerful and stable script. The scope of a scripts potential is increased astronomically. Instead of endless lines of a script for on simple skill, you get endless lines of a script for an unlimited set of skills, or everything you can do with one skill. I may be exaggerating a tiny bit, but I could make a global fighter that banked everywhere, picked up valuable loot, and did other sorts of awesome things, EXPONENTIALLY simpler than in color. And maintenance of a such a script would be much more organized and easier.

    At the idea of adding inaccuracy and less efficiency, it is smarter to add it when you want it in the script than having it just randomly happening. Color or reflection, that should be controlled by the scripter, not the limits of the script's functions itself.

    Generally my view is that someone can pick up a love programming easier/more quickly if the first step isn't a massive leap. I think that is sort of the goal of srl as well. Reflection can give them that, and if they do decide they enjoy programming, doubtless they will discover that color scripting adds an extra challenge past reflection. Then after they learn even more from crossing over to color based scripts, they can create some kind of reflection/color lovechild that just has so much awesome in it...but I digress. A quality library should be available for people that want to pick up scripting real quick.

    Regarding the lack of an osr lape include: This is a HUGE failure of the community. I don't see why we are still mass-using a compiler that we are trying to phase out of simba(at least I believe we are trying to phase it out). It doesn't take much to convert from pascalscript to lape, unless you want to group everything into modules like SRL6. Claiming that the lape include is "buggy" seems ridiculous. It should act the exact same, and if it doesn't then there are bugs in lape that we have not discovered, which should be discovered.

    @elfyyy if you got offended, I totally apologize. It was brought to my attention that you might have taken my posts that way. It honestly was not something that was meant to be offensive. I have quite an abrasive personality(not an excuse, more of an explanation).

    /post(didn't proofread hope I didn't ramble)

Page 1 of 2 12 LastLast

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
  •