-
Lamkefyned
- Posts: 348
- Joined: Thu May 23, 2013 11:38 am
- Location: Spain
#1
Post
by Lamkefyned » Thu Nov 06, 2014 10:44 am
Hi, I am making a user function and I want to make a function that is running another inside.
Example:
Code: Select all
function LKCore()
-- COUNT ROUND
Rcount = 0
local function countround()
Rcount = Rcount+1;
end
end
if anyone knows and can help me ... Thank you
If you think something is right just because everyone else believes,you're not thinking.
-
rock5
- Posts: 12173
- Joined: Tue Jan 05, 2010 3:30 am
- Location: Australia
#2
Post
by rock5 » Thu Nov 06, 2014 10:57 am
When you use "function" you are creating a function, not running it. What does is create a local function and then not use it.
I can't make a suggestion because I don't know what you are trying to do.
- 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.”
-
Lamkefyned
- Posts: 348
- Joined: Thu May 23, 2013 11:38 am
- Location: Spain
#3
Post
by Lamkefyned » Thu Nov 06, 2014 5:37 pm
I mean calling a function that is inside another ....
for a single function ....
If you think something is right just because everyone else believes,you're not thinking.
-
rock5
- Posts: 12173
- Joined: Tue Jan 05, 2010 3:30 am
- Location: Australia
#4
Post
by rock5 » Thu Nov 06, 2014 9:55 pm
Do you mean you want to pass an argument to a function telling it which function to use?
Well the bot does something like this when using eval functions eg.
Code: Select all
player:findEnemy(true,nil evalTargetDefault)
player:findNearestNameOrId(""",nil,evalTargetLootable)
In this case it just passes the whole function as the argument.
Is it a requirement for you to use local functions inside the main function? In that case it would be a bit more tricky. You could use a local table to hold the local functions eg.
Code: Select all
function mainFunc(funcname)
local funcs = {}
function funcs.f1()
-- do something
end
function funcs.f2()
-- do something
end
funcs[funcname]()
end
Then you could call them with
- 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.”
-
Lamkefyned
- Posts: 348
- Joined: Thu May 23, 2013 11:38 am
- Location: Spain
#5
Post
by Lamkefyned » Fri Nov 07, 2014 9:31 am
this is just what I want
but can pass parameters to the function inside ....?
Code: Select all
mainFunc("f1(3)")
mainFunc("f1("33")") -->>> this would mistake?
If you think something is right just because everyone else believes,you're not thinking.
-
rock5
- Posts: 12173
- Joined: Tue Jan 05, 2010 3:30 am
- Location: Australia
#6
Post
by rock5 » Fri Nov 07, 2014 9:54 am
Maybe as extra arguments.
Code: Select all
function mainFunc(funcname, ...)
local funcs = {}
function funcs.f1(a)
-- do something
end
function funcs.f2(a, b, c)
-- do something
end
funcs[funcname](...)
end
Code: Select all
mainFunc("f1",1)
mainFunc("f2",1,2,3)
- 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.”
-
Lamkefyned
- Posts: 348
- Joined: Thu May 23, 2013 11:38 am
- Location: Spain
#7
Post
by Lamkefyned » Sat Nov 08, 2014 10:18 am
Thank R5
If you think something is right just because everyone else believes,you're not thinking.
Who is online
Users browsing this forum: Ahrefs [Bot] and 55 guests