About the script

Discuss, ask for help, share ideas, give suggestions, read tutorials, and tell us about bugs you have found with MicroMacro in here.

Do not post RoM-Bot stuff here. There is a subforum for that.
Forum rules
This is a sub-forum for things specific to MicroMacro.

This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
Message
Author
ransuer
Posts: 10
Joined: Fri Apr 17, 2009 7:58 pm

About the script

#1 Post by ransuer » Fri Apr 17, 2009 8:22 pm

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?

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: About the script

#2 Post by Administrator » Fri Apr 17, 2009 11:32 pm

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.

zer0
Posts: 213
Joined: Sat Feb 16, 2008 11:55 pm

Re: About the script

#3 Post by zer0 » Sat Apr 18, 2009 1:03 am

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

ransuer
Posts: 10
Joined: Fri Apr 17, 2009 7:58 pm

Re: About the script

#4 Post by ransuer » Sat Apr 18, 2009 7:29 am

What i'm gonna do now?

I save my file Nostale.lua.txt.

but its error..it cannot find..

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: About the script

#5 Post by Administrator » Sat Apr 18, 2009 7:59 am

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.

ransuer
Posts: 10
Joined: Fri Apr 17, 2009 7:58 pm

Re: About the script

#6 Post by ransuer » Sat Apr 18, 2009 10:13 am

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..

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: About the script

#7 Post by Administrator » Sat Apr 18, 2009 10:36 am

And Nostale.lua is inside "scripts" inside the "micromacro" folder?

ransuer
Posts: 10
Joined: Fri Apr 17, 2009 7:58 pm

Re: About the script

#8 Post by ransuer » Sat Apr 18, 2009 11:00 am

Yes sir..

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: About the script

#9 Post by Administrator » Sat Apr 18, 2009 11:05 am

Sounds pretty strange to me. Attach the Nostale.lua file and your log.txt for inspection.

ransuer
Posts: 10
Joined: Fri Apr 17, 2009 7:58 pm

Re: About the script

#10 Post by ransuer » Sat Apr 18, 2009 11:23 am

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.

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: About the script

#11 Post by Administrator » Sat Apr 18, 2009 12:49 pm

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.

ransuer
Posts: 10
Joined: Fri Apr 17, 2009 7:58 pm

Re: About the script

#12 Post by ransuer » Sat Apr 18, 2009 1:27 pm

Sir what im gonna do now?

im newbie in this script..

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: About the script

#13 Post by Administrator » Sat Apr 18, 2009 2:00 pm

I just told you exactly what to do. Add "end" after the code segment in my last reply.

User avatar
3cmSailorfuku
Posts: 354
Joined: Mon Jan 21, 2008 6:25 pm

Re: About the script

#14 Post by 3cmSailorfuku » Sat Apr 18, 2009 3:14 pm

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
Image
... It's quite not correct though lmao.

ransuer
Posts: 10
Joined: Fri Apr 17, 2009 7:58 pm

Re: About the script

#15 Post by ransuer » Sat Apr 18, 2009 4:38 pm

@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..

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: About the script

#16 Post by Administrator » Sat Apr 18, 2009 4:50 pm

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

ransuer
Posts: 10
Joined: Fri Apr 17, 2009 7:58 pm

Re: About the script

#17 Post by ransuer » Sat Apr 18, 2009 9:05 pm

i do that but it cannot find the file name..

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: About the script

#18 Post by Administrator » Sun Apr 19, 2009 1:26 am

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.

ransuer
Posts: 10
Joined: Fri Apr 17, 2009 7:58 pm

Re: About the script

#19 Post by ransuer » Sun Apr 19, 2009 5:06 am

What program can bot in nostale global?

User avatar
3cmSailorfuku
Posts: 354
Joined: Mon Jan 21, 2008 6:25 pm

Re: About the script

#20 Post by 3cmSailorfuku » Sun Apr 19, 2009 9:21 am

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests