Page 1 of 2
About the script
Posted: Fri Apr 17, 2009 8:22 pm
by ransuer
I put the script on the micromacro-->script and name it Nostale.lua
after that i open the Micromacro then i put Nostale.lua then it said theres no file in that name..
i put the scipt in file document...like notepad..
Theres something wrong?
Re: About the script
Posted: Fri Apr 17, 2009 11:32 pm
by Administrator
When you saved the file, you probably left the file type as "Text file", so it saved it as Nostale.lua.txt. Enable the showing of file extensions and check that. I have no idea what was going through the heads of the people at Microsoft when they thought not showing file extensions was a good idea.
Re: About the script
Posted: Sat Apr 18, 2009 1:03 am
by zer0
Administrator wrote:When you saved the file, you probably left the file type as "Text file", so it saved it as Nostale.lua.txt. Enable the showing of file extensions and check that. I have no idea what was going through the heads of the people at Microsoft when they thought not showing file extensions was a good idea.
U and I both, I think it made a generation of Computers users not understand what a file extension is. :O
Re: About the script
Posted: Sat Apr 18, 2009 7:29 am
by ransuer
What i'm gonna do now?
I save my file Nostale.lua.txt.
but its error..it cannot find..
Re: About the script
Posted: Sat Apr 18, 2009 7:59 am
by Administrator
No. You misunderstood. You are supposed to save it as Nostale.lua, but you DID save it as Nostale.lua.txt. When you go to save it (I'm assuming you're using Notepad), change the "Save as type:" to "All files", and put "Nostale.lua" into the File Name field.
Re: About the script
Posted: Sat Apr 18, 2009 10:13 am
by ransuer
Sir i do the All files and Nostale.lua then save then if i type Nostale.lua in micromacro theres no file in that name..
I don't have a Notepad i only have Text Document..
Re: About the script
Posted: Sat Apr 18, 2009 10:36 am
by Administrator
And Nostale.lua is inside "scripts" inside the "micromacro" folder?
Re: About the script
Posted: Sat Apr 18, 2009 11:00 am
by ransuer
Yes sir..
Re: About the script
Posted: Sat Apr 18, 2009 11:05 am
by Administrator
Sounds pretty strange to me. Attach the Nostale.lua file and your log.txt for inspection.
Re: About the script
Posted: Sat Apr 18, 2009 11:23 am
by ransuer
Nostale.lua
Code: Select all
---------------------------------------------------------------------------------------------------
--SETTINGS
---------------------------------------------------------------------------------------------------
HP_potion = 500;
MP_potion = 50;
HP_restatm = 1000;
MP_restatm = 300;
key_attack = key.VK_SPACE;
key_pickup = key.VK_TILDE;
key_skill1 = key.VK_1;
keyskill2 = key.VK_2;
keyskill3 = key.VK_3;
key_hppotion = key.VK_4;
key_mppotion = key.VK_5;
-----------------------------------------------------------------------------------------------------
--ADDRESSES
-----------------------------------------------------------------------------------------------------
proc = 0;
win = 0;
char_Ptr = 0x00784D70;
HP_Ptr_offset = 0xAC;
curHP_offset = 0x4C;
maxHP_offset = 0x48;
MP_Ptr_offset = 0xB0;
curMP_offset = 0x4C;
maxMP_offset = 0x48;
char_target = 0x00784D70;
target_Ptr_offset = 0xBC;
target_offset = 0x18;
HP_Ptr = 0;
MP_Ptr = 0;
target_Ptr = 0;
HP = 0;
HPmax = 0;
MP = 0;
MPmax = 0;
target = 0;
-------------------------------------------------------------------------------------------------------
--FUNCTIONS
-------------------------------------------------------------------------------------------------------
--pickup items
function pickup()
keyboardPress(key.VK_TILDE);
end
--select nearby monster
function target_monster()
keyboardPress(key.VK_SPACE);
end
--fight timer
function fight_timer()
-- keyboardPress(key.VK_SPACE);
end
--check if you have a target
function have_target()
if( target == 1 ) then
return true;
else
return false;
end
end
--updates variables from client
function update_var()
HP_Ptr = memoryReadIntPtr(proc, char_Ptr, HP_Ptr_offset);
HP = memoryReadInt( proc , HP_Ptr + curHP_offset);
HPmax = memoryReadInt(proc, HP_Ptr + maxHP_offset);
MP_Ptr = memoryReadIntPtr(proc, char_Ptr, MP_Ptr_offset);
MP = memoryReadInt(proc, MP_Ptr + curMP_offset);
MPmax = memoryReadInt(proc, MP_Ptr + maxMP_offset);
target_Ptr = memoryReadIntPtr(proc, char_target, target_Ptr_offset);
target = memoryReadInt(proc, target_Ptr + target_offset);
end
-- toggle can_heal to true, disable timer
function can_rest_timer()
unregisterTimer("can_rest_timer");
can_rest = true;
end
--rest until healed
function rest_heal()
if( can_rest == false ) then return; end
printf("Entering rest state\t%s\n", os.date("%X"));
keyboardPress(key.VK_T);
need_heal = true;
last_hp= HP;
while( need_heal ) do
yrest(100);
if( HP == HPmax and MP == MPmax ) then
buff();
need_heal = false;
end
if( HP < last_hp ) then
print("Under attack! Exiting rest.");
can_rest = false;
registerTimer("can_rest_timer", 3000, can_rest_timer);
break;
else
last_hp = HP;
end
end
end
--use hp potion
function hp_potion()
keyboardPress(key.VK_6);
yrest(1000);
end
--use mp potion
function mp_potion()
keyboardPress(key.VK_7)
yrest(1000);
end
--bot fight
function bot_fight()
registerTimer("fight_timer", 3000, fight_timer);
if( HP < HP_potion) then hp_potion(); end
if( MP < MP_potion) then mp_potion(); end
if( target == 1 ) then
keyboardPress(key.VK_2);
yrest(200);
keyboardPress(key.VK_3);
yrest(200);
keyboardPress(key.VK_SPACE);
end
if( math.random(100) > 60 ) then
keyboardPress(key.VK_4);
yrest(1000);end
end
unregisterTimer("fight_timer");
for i=0, 8 do
pickup();
yrest(50);
can_rest = false;
-- registerTimer("can_rest_timer", 3000, can_rest_timer);
end
--can_rest_timer
function can_rest_timer()
unregisterTimer("can_rest_timer");
can_rest = true;
end
-- buff
function buff()
keyboardPress(key.VK_0);
yrest(1000);
keyboardPress(key.VK_9);
yrest(1000);
end
-----------------------------------------------------------------------------------------------------------------
--MAIN BOT FUNCTIONS
-----------------------------------------------------------------------------------------------------------------
function main()
win = findWindow("Nomad of Silver Spirit - Nostale");
local wx,wy,ww,wh = windowRect(win);
if( win == 0 ) then printf("Error! Could not locate Nostale window!\n"); return; end;
hdc = openDC(win);
proc = openProcess( findProcessByExe("NostaleX.dat") );
attach(win);
setPriority(PRIORITY_HIGH);
registerTimer("update_var", 100, update_var);
while( true ) do
if( HP < HP_potion ) then hp_potion(); end
if( MP < MP_potion ) then mp_potion(); end
if( HP < HP_restatm and can_rest == true ) then rest_heal(); end
if( MP < MP_restatm and can_rest == true ) then rest_heal(); end
if( HP > HP_restatm and can_rest == true ) then buff();end
yrest(100);
target_monster();
yrest(200);
if( target == 1 ) then
can_rest = fasle;
if( target == 1 ) then bot_fight();
while( target == 1 ) do
if( HP < HP_potion) then hp_potion(); end
if( MP < MP_potion) then mp_potion(); end
if( math.random(100) > 0 ) then
keyboardPress(key.VK_2);
yrest(200);
keyboardPress(key.VK_3);
yrest(200);
keyboardPress(key.VK_SPACE);
end
if( math.random(100) > 60 ) then
keyboardPress(key.VK_4);
yrest(1000);end
end
for i=0, 8 do
pickup();
yrest(50);
end
can_rest = false;
end
can_rest = true;
end
pickup();
end
detach();
closeProcess(proc);
end
startMacro(main);
Log.txt
Sun Apr 19 01:11:42 2009 : MicroMacro v0.99
Sun Apr 19 01:11:42 2009 : Processor Type: 586, OS: Windows XP Service Pack 2
Sun Apr 19 01:11:42 2009 : Lua initialized successfully.
Sun Apr 19 01:11:42 2009 : Lua libs opened successfully.
Sun Apr 19 01:11:42 2009 : LuaCoco is available.
Sun Apr 19 01:11:42 2009 : Lua glues exported.
Sun Apr 19 01:11:42 2009 : Keyboard layout: US English
Sun Apr 19 01:11:42 2009 : Configurations run.
Sun Apr 19 01:11:48 2009 : Executing script "Nostale.lua".
==================================================
Sun Apr 19 01:11:48 2009 : ...d Settings\MUEGA LINK\Desktop\micromacro\lib\lib.lua:335: Timer not found: 'fight_timer'
Sun Apr 19 01:11:48 2009 : Execution of Nostale.lua complete.
Sun Apr 19 01:11:48 2009 : Execution error: Runtime error
Sun Apr 19 01:11:48 2009 : Collecting garbage...
Sun Apr 19 01:11:48 2009 : 47KB freed.
Re: About the script
Posted: Sat Apr 18, 2009 12:49 pm
by Administrator
You're not properly closing one of your functions.
Code: Select all
for i=0, 8 do
pickup();
yrest(50);
Actually, you're not closing that for loop, so the 'end' you have after it was intended to close the function, but is closing the for loop. Add an 'end' after that, and it should work.
Re: About the script
Posted: Sat Apr 18, 2009 1:27 pm
by ransuer
Sir what im gonna do now?
im newbie in this script..
Re: About the script
Posted: Sat Apr 18, 2009 2:00 pm
by Administrator
I just told you exactly what to do. Add "end" after the code segment in my last reply.
Re: About the script
Posted: Sat Apr 18, 2009 3:14 pm
by 3cmSailorfuku
Administrator wrote:I just told you exactly what to do. Add "end" after the code segment in my last reply.
Saw the first bit of it where you comment the spacebar action out, probably because you thought it's the same as targetting nearby monsters?
Anyway, he gotta remove the -- infront of it, or it won't attack.
Or replace everything with this:
Code: Select all
while (true) do
keyboardPress(key.VK_SPACE);
keyboardPress(key.VK_TILDE);
end

... It's quite not correct though lmao.
Re: About the script
Posted: Sat Apr 18, 2009 4:38 pm
by ransuer
@Sir Admin..
every function it have the end ..then im gonna put end again?
@3cmSailorfuku
What do you mean by that?I can't understand..
Re: About the script
Posted: Sat Apr 18, 2009 4:50 pm
by Administrator
Look at this function:
Code: Select all
--bot fight
function bot_fight()
registerTimer("fight_timer", 3000, fight_timer);
if( HP < HP_potion) then hp_potion(); end
if( MP < MP_potion) then mp_potion(); end
if( target == 1 ) then
keyboardPress(key.VK_2);
yrest(200);
keyboardPress(key.VK_3);
yrest(200);
keyboardPress(key.VK_SPACE);
end
if( math.random(100) > 60 ) then
keyboardPress(key.VK_4);
yrest(1000);end
end
unregisterTimer("fight_timer");
for i=0, 8 do
pickup();
yrest(50);
can_rest = false;
-- registerTimer("can_rest_timer", 3000, can_rest_timer);
end
See how you open the 'for' near the end, but do not have an 'end' after it? It's messing up the code. Change
Code: Select all
for i=0, 8 do
pickup();
yrest(50);
To
Code: Select all
for i=0, 8 do
pickup();
yrest(50);
end
Re: About the script
Posted: Sat Apr 18, 2009 9:05 pm
by ransuer
i do that but it cannot find the file name..
Re: About the script
Posted: Sun Apr 19, 2009 1:26 am
by Administrator
It's not a file name. It's a timer name. It can't find it because many of your if statements are left open, which is placing functions inside if statements inside other functions, which means they cannot be found at global scope.
That whole script is a mess. Just start from scratch.
Re: About the script
Posted: Sun Apr 19, 2009 5:06 am
by ransuer
What program can bot in nostale global?
Re: About the script
Posted: Sun Apr 19, 2009 9:21 am
by 3cmSailorfuku
ransuer wrote:What program can bot in nostale global?
Just go with something like this:
Code: Select all
function main()
attach(findWindow("NosTale"));
while(true) do
keyboardPress(key.VK_SPACE);
keyboardPress(key.VK_2);
rest(300);
end
end
startMacro(main, true);
Put pickup on shortcut 2. Seriously, there isn't any better bot out there for NosTale anyway.
They all just bash on two buttons. Healing is unecessary anyway.
Because the script you've posted is probably lacking updated adresses anyway, which you won't understand, keeps you from doing more work.
@Elverion: Spacebar in NosTale does automatically select a monster that has been alive for the longest time and automatically attacks it.
So spacebar bashing is the way to go, lol.