Error doing userfunction

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
Lamkefyned
Posts: 348
Joined: Thu May 23, 2013 11:38 am
Location: Spain

Error doing userfunction

#1 Post by Lamkefyned » Sun May 04, 2014 12:56 pm

Hi, I'm doing a userfunction for all my scripts but when I run a command for example

Code: Select all

LTU()
Run me all the userfunction.

Code: Select all

------------------------------------------------------------------
--  Lamkefyned Tools Userfunction
--                Version 1.0.000
------------------------------------------------------------------

-- Settings

function LTU_version()
	cprintf(cli.red,"Version: 1.0.000\n")
end

function LTU_versioninfo()
	cprintf(cli.red,"Version Beta\n")
end

function LTU_clear()
   local _, _, x, y = getConsoleAttributes();
   for j = 1, y do
      printf(string.rep(' ', x));
   end
   clearScreen();
end

-- General

function LTU()
	cprintf(cli.red,"Lamkefyned Tools Userfunction\n")
end

function LTU(loading)
    LTU_clear()
	cprintf(cli.red,"\n \n \n \n \n \n \n \n \n \n \n \n")
	cprintf(cli.red,"Loading Script By Lamkefyned...")
	cprintf(cli.red,"\n \n \n \n \n \n \n \n \n \n \n \n")
	yrest(2000) 
	LTU_clear()
end

function LTU(info)
	cprintf(cli.red,"Developer: Lamkefyned\n")
	cprintf(cli.red,"Userfunction: Lamkefyned Tools Userfunction\n")
	LTU_version()
	LTU_versioninfo()
end

-- Hoss

function LTU_Hoss(menu)
                     print("Here are the options:")
                     print("   1. Main character")
                     print("   2. Character to level up")
                     printf("Enter a number > ")
                     local selected = io.stdin:read()
                     if selected == "1" then
                     __WPL:setWaypointIndex(__WPL:findWaypointTag("MC"))
                     elseif selected == "2" then
                     __WPL:setWaypointIndex(__WPL:findWaypointTag("CTL"))
                     yrest(5000)
                     loadPaths(__WPL.FileName);
	end
end

function LTU_Hoss(start)
   eventParty()
   repeat
      yrest(100)
   until checkEventParty() == "start" 
   eventParty("stop")
end

function LTU_Hoss(next)
   eventParty()
   repeat
      yrest(100)
   until checkEventParty() == "next" 
   eventParty("stop")
end

function LTU_Hoss(finish)
   eventParty()
   repeat
      yrest(100)
   until checkEventParty() == "finish"
   eventParty("stop") 
end
What I'm doing wrong?
If you think something is right just because everyone else believes,you're not thinking.

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Error doing userfunction

#2 Post by lisa » Sun May 04, 2014 6:56 pm

you have 3 functions with the exact same name, so the last to be loaded will be the one that over rides the others.

Code: Select all

function LTU()
   cprintf(cli.red,"Lamkefyned Tools Userfunction\n")
end

function LTU(loading)
    LTU_clear()
   cprintf(cli.red,"\n \n \n \n \n \n \n \n \n \n \n \n")
   cprintf(cli.red,"Loading Script By Lamkefyned...")
   cprintf(cli.red,"\n \n \n \n \n \n \n \n \n \n \n \n")
   yrest(2000) 
   LTU_clear()
end

function LTU(info)
   cprintf(cli.red,"Developer: Lamkefyned\n")
   cprintf(cli.red,"Userfunction: Lamkefyned Tools Userfunction\n")
   LTU_version()
   LTU_versioninfo()
end
so when you do
LTU() it will do.

Code: Select all

function LTU(info)
   cprintf(cli.red,"Developer: Lamkefyned\n")
   cprintf(cli.red,"Userfunction: Lamkefyned Tools Userfunction\n")
   LTU_version()
   LTU_versioninfo()
end
So basically just rename the functions to be individual names or if you want them all to be done with just 1 call then make them into 1 function.

It's a bit like

flag = "australia"
flag = "france"
flag = "england"

print(flag)
it will of course print the last value it was changed to, "england"
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

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Error doing userfunction

#3 Post by lisa » Sun May 04, 2014 7:01 pm

This might help you a little better, I see you do the same thing for LTU_HOSS()

Code: Select all

function LTU_Hoss(arg1)
   eventParty()
   repeat
      yrest(100)
   until checkEventParty() == arg1
   eventParty("stop") 
end
Now to have the 3 different things you want you change what you put in as the argument when calling the function.

Code: Select all

LTU_Hoss("start")

LTU_Hoss("next")

LTU_Hoss("finish")
So you can do it in 1 single function.
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

User avatar
Lamkefyned
Posts: 348
Joined: Thu May 23, 2013 11:38 am
Location: Spain

Re: Error doing userfunction

#4 Post by Lamkefyned » Mon May 05, 2014 1:03 pm

Thank you Lisa
If you think something is right just because everyone else believes,you're not thinking.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest