New trick for advanced users

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

New trick for advanced users

#1 Post by rock5 » Thu May 22, 2014 6:46 am

Some of you will be aware that doing 1 RoMScript is a lot faster than doing multiple RoMScripts. So it's better to do loops in the game than in the bot. Here's an example, say you want to see if you have a particular title. A really slow way would be like this

Code: Select all

for i = 0, RoMScript("GetTitleCount()") do
    local name, titleid, geted = RoMScript("GetTitleInfoByIndex("..i..")
    if titleid == 530897 then 
        -- have title
        break
    end
end
On my character with 568 titles this takes nearly 2m.

People with the programming skills know this can be done with an in game loop that will be much faster, example

Code: Select all

RoMCode("for i = 0, GetTitleCount() do n,t,g=GetTitleInfoByIndex(i) if t==530897 then a = {g} end end")
Until recently the length of this command was limited to 255 characters and it didn't matter if you used the whole 255 characters it still took about the same amount of time.

Now RoMScripts can be any length. This is useful because now you can create long complex code and execute it in 1 RoMScript. A side affect of this is if the command is longer than 255 characters it will take twice as long. If it's more than 510 characters it will take 3 times as long, etc. So the usefulness of using really long code will be limited by how long it will take.

The trick I want to introduce is creating an in game function instead. When you want to use some really long code it might be beneficial to do something like this.

In the onload of your waypoint file create the in game function.

Code: Select all

RoMCode([[
    function myfunction(arg)
    
        ...    
    
        ...    

        -- some really long code
    
        ...    

    
        ...    

    end
]])
Then when you need to run the code just use this which should run fast as any short RoMScript would.

Code: Select all

RoMScript("myfunction("..argument..")")
Well, that's it. There might not be much call for it but it's worth keeping in mind.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 0 guests