helps to create function
- Lamkefyned
- Posts: 348
- Joined: Thu May 23, 2013 11:38 am
- Location: Spain
helps to create function
How to make a function that look if connected characters and invite the connected... ??
If you think something is right just because everyone else believes,you're not thinking.
Re: helps to create function
This will invite a char until the char accepts
Code: Select all
if(RoMScript("GetNumPartyMembers()") == 0)then
repeat
RoMScript("InviteByName('Yourchar');");
until RoMScript("GetNumPartyMembers()") ~= 0
end
Jack-of-all-trades, but master-of-only of a few
My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226
- Lamkefyned
- Posts: 348
- Joined: Thu May 23, 2013 11:38 am
- Location: Spain
Re: helps to create function
Hi, thanks
But if I have multiple characters? 12 for example
But if I have multiple characters? 12 for example
If you think something is right just because everyone else believes,you're not thinking.
Re: helps to create function
If you try to invite the characters that are offline it wouldn't hurt, you would just get a message saying that character is offline. I don't see why you can't just use a table of names and invite them all.
Remember no matter you do in life to always have a little fun while you are at it 
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
- Lamkefyned
- Posts: 348
- Joined: Thu May 23, 2013 11:38 am
- Location: Spain
Re: helps to create function
Is there any tutorial by hai how to make tables?
If you think something is right just because everyone else believes,you're not thinking.
Re: helps to create function
There is some light reading here http://www.lua.org/manual/5.1/manual.ht ... ble.concat but that is to do with the actual table functions, like table.insert.
Simple ways to use tables if you already know what you want in the table goes like this.
sometablename = { "string1","string2", number1, number2, "string3"}
Note strings have " " and numbers don't, those are just examples and you can have anything you want in the table.
and to use the table information you do
the k and v are like arguments in a function and can be what ever you want to call them.
Simple ways to use tables if you already know what you want in the table goes like this.
sometablename = { "string1","string2", number1, number2, "string3"}
Note strings have " " and numbers don't, those are just examples and you can have anything you want in the table.
and to use the table information you do
Code: Select all
for k,v in pairs(sometablename) do
-- in this case k is a number value and starts at 1 and goes up.
-- v would be the values you have in the table, "string1" and so on
-- so if you did a simple print here
print(v)
-- it would print all the values of the table
end
Code: Select all
for slot,names in pairs(sometablename) do
print(names)
end
Remember no matter you do in life to always have a little fun while you are at it 
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: helps to create function
I might add that all tables are made up of keys and values. In this exampleThe numbers in the square brackets are the keys, and the strings and numbers are the values.
In Lisas example
BTW, this is what I call an indexed table. In such a table I would call the keys indexes. An indexed table is a table where all the keys are numerical starting from 1 and having no breaks. Also the keys have no meaning to the program being run. They are just placeholders for the values. Functions such as table.insert and table.remove should only be used with indexed tables.
You can also use the keys to mean something by giving them a name. EgThe reason why you need to use square brackets with numbers is because lua wont let you use numbers like named keys without them.
To further confuse you, there are different ways you can refer to individual elements in a table.
With numbers you can't use
is equivalent tolisa wrote:sometablename = { "string1","string2", number1, number2, "string3"}
Code: Select all
sometablename = { [1]="string1",[2]="string2", [3]=number1, [4]=number2, [5]="string3"}
In Lisas example
the k is the key and the v is the value.lisa wrote:for k,v in pairs(sometablename) do
BTW, this is what I call an indexed table. In such a table I would call the keys indexes. An indexed table is a table where all the keys are numerical starting from 1 and having no breaks. Also the keys have no meaning to the program being run. They are just placeholders for the values. Functions such as table.insert and table.remove should only be used with indexed tables.
You can also use the keys to mean something by giving them a name. Eg
Code: Select all
customer={name="someone", address="123 solarstrike boulevard, net",phone="1234 5678"}
To further confuse you, there are different ways you can refer to individual elements in a table.
- customer.name
customer["name"]
tmp="name"; customer[tmp]
With numbers you can't use
- sometablename.1
- sometablename[1]
tmp = 1; sometablename[tmp]
- 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
- Lamkefyned
- Posts: 348
- Joined: Thu May 23, 2013 11:38 am
- Location: Spain
Re: helps to create function
for example this officer?
Code: Select all
nameTable =
{
'larinja','example'
};
function LTU_group()
if(RoMScript("GetNumPartyMembers()") == 0)then
repeat
RoMScript("InviteByName(nameTable);");
until RoMScript("GetNumPartyMembers()") ~= 0
end
end
If you think something is right just because everyone else believes,you're not thinking.
Re: helps to create function
Code: Select all
nameTable =
{
'larinja','example'
};
function LTU_group()
if(RoMScript("GetNumPartyMembers()") == 0)then
for k,v in pairs(nameTable) do
RoMScript("InviteByName('"..v.."');");
end
end
end
Remember no matter you do in life to always have a little fun while you are at it 
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: helps to create function
Let me try to explain. RoMScript sends code/commands to the game to be executed. "InviteByName(nameTable);" is literally just a string that it sends to the game which the ingamefunctions addon (igf) converts to code and runs. igf literally receives "InviteByName(nameTable);", makes it executable and runs it. nameTable has no value in the game, that variable only exists in the bot. If you want to send variable values to the bot you have to append them to the string you are sending to the bot.Lamkefyned wrote: RoMScript("InviteByName(nameTable);");
So for example
Code: Select all
var="somename"
RoMScript("InviteByName('"..var..'");")
And of course, because RoMScript only accepts strings, you can't send the contents of a table, you have to iterate through the table and use each string name separately. Although you can theoretically recreate a small bot table in game by converting it to a string first.
Hm... you know I could probably make a function for moving tables into the game. Could be useful. So for example if you need to execute an in game function on a long list of names you could move the long list into the game first then use 1 RoMScript to iterate though the ingame table to executes those commands. Instead of iterating though the table in the bot and executing a RoMScript for every name. The code for converting tables to strings already exist. All I would have to do is modify it for this purpose and find some way to move the table strings longer than 255 into the game. Sounds like a worthwhile project.
- 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
Re: helps to create function
Cool. I just modified RoMScript to take any length command. That's going to be so useful. In this case, when I create a tableToString function you'll be able to do something like this.
And that should work with any length list. Cool, huh?
I can think of 2 places I can use this new feature to simplify the bot. The autosell sells blocks of items at a time and is limited to the 255 character length. With this, I'll be able to just create 1 big sell command and execute it instead of the complex code to break it up into blocks. The other is the itemtypes table creation. It does blocks of TEXT commands. Hm... Why don't we use memory reads with getTEXT for that? I'll have to look into that.
By the way Lamkefyned, sorry for hijacking your topic. Don't let me stop you from asking any more questions about lisas solution if you have any.
Code: Select all
namestoinvite={"name1","name2","name3"}
RoMCode("t="..tableToString(namestoinvite).." for k,v in pairs(t) do InviteByName(v) end")
I can think of 2 places I can use this new feature to simplify the bot. The autosell sells blocks of items at a time and is limited to the 255 character length. With this, I'll be able to just create 1 big sell command and execute it instead of the complex code to break it up into blocks. The other is the itemtypes table creation. It does blocks of TEXT commands. Hm... Why don't we use memory reads with getTEXT for that? I'll have to look into that.
By the way Lamkefyned, sorry for hijacking your topic. Don't let me stop you from asking any more questions about lisas solution if you have any.
- 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
- Lamkefyned
- Posts: 348
- Joined: Thu May 23, 2013 11:38 am
- Location: Spain
Re: helps to create function
don't worry rock5 in awhile I will put to the bargain. If I update all my scripts with userfunction_lamkefyned-tools and find new functions and if this works.
If you think something is right just because everyone else believes,you're not thinking.
- Lamkefyned
- Posts: 348
- Joined: Thu May 23, 2013 11:38 am
- Location: Spain
Re: helps to create function
Code: Select all
function LTU_Hoss_group()
if(RoMScript("GetNumPartyMembers()") == 0)then
for k,v in pairs(invite) do
RoMScript("InviteByName('"..v.."');");
end
end
end
If you think something is right just because everyone else believes,you're not thinking.
Re: helps to create function
The loop looks fine you must have called the function somewhere again.
You might at some yrest between the calls because else it would get laggy and maybe you have need for this function if you don't want to invite somebody which is already in the group http://runesofmagic.gamepedia.com/API:InPartyByName
You might at some yrest between the calls because else it would get laggy and maybe you have need for this function if you don't want to invite somebody which is already in the group http://runesofmagic.gamepedia.com/API:InPartyByName
Jack-of-all-trades, but master-of-only of a few
My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226
- Lamkefyned
- Posts: 348
- Joined: Thu May 23, 2013 11:38 am
- Location: Spain
Re: helps to create function
I can create another function that look if hai someone in Group and if there is it that back... I feel well sleep XDDD
If you think something is right just because everyone else believes,you're not thinking.
- Lamkefyned
- Posts: 348
- Joined: Thu May 23, 2013 11:38 am
- Location: Spain
Re: helps to create function
Code: Select all
function LTU_Hoss_group()
if(RoMScript("GetNumPartyMembers()") == 0)then
repeat
for k,v in pairs(invite) do
RoMScript("InviteByName('"..v.."');");
end
until RoMScript("GetNumPartyMembers()") ~= 0
end
end
How I can do to wait five seconds between recurrence and repetition without affecting the first invitation.
If you think something is right just because everyone else believes,you're not thinking.
Re: helps to create function
Code: Select all
function LTU_Hoss_group()
if(RoMScript("GetNumPartyMembers()") == 0)then
repeat
for k,v in pairs(invite) do
RoMScript("InviteByName('"..v.."');");
end
yrest(5000);
until RoMScript("GetNumPartyMembers()") ~= 0
end
end
Re: helps to create function
That I think too, but I would make sure you don't bother doing think you don't need.
Code: Select all
function LTU_Hoss_group()
if(RoMScript("GetNumPartyMembers()") == 0)then
repeat
for k,v in pairs(invite) do
if(not RoMScript("InPartyByName ( "..v.." );")then
RoMScript("InviteByName('"..v.."');");
yrest(5000)
end
end
until RoMScript("GetNumPartyMembers()") ~= 0
end
end
Jack-of-all-trades, but master-of-only of a few
My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226
- Lamkefyned
- Posts: 348
- Joined: Thu May 23, 2013 11:38 am
- Location: Spain
Re: helps to create function
Thank you BlubBlab and all
If you think something is right just because everyone else believes,you're not thinking.
- Lamkefyned
- Posts: 348
- Joined: Thu May 23, 2013 11:38 am
- Location: Spain
Re: helps to create function
only one thing...
Gives this error code.
Gives this error code.
If you think something is right just because everyone else believes,you're not thinking.
Who is online
Users browsing this forum: No registered users and 1 guest