New function help needed (random key press)

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
Lembke
Posts: 13
Joined: Sun Aug 02, 2009 8:20 pm

New function help needed (random key press)

#1 Post by Lembke » Tue Jan 19, 2010 2:28 pm

Hello i want to make a function that press random keys from a-z about 1-6 times, (if it only press a random key 1 time u can always loop it in the waypoint or profile file) and where do i put the new function?

this is my script i made sofar (noob at codeing)

Code: Select all

function random_keypress()
  local keypress_chars = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
    local index = math.random(1, #keypress_chars);
	keyboardPress( key.VK_keypress_chars[index];
  end
 
  return true
end
this function will be usefull for makeing new characters whit a random name i guess the most ppl know why i need this function

and question nr 2
when adding this to a "waypointfile" or "profile" will i just type "random_keypress()"

if i get this function to work i will be rly happy and im sure there is lots of other ppls that need this also. when i get a similar script or some help whit this one i will be running the bot 24/7

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

Re: New function help needed (random key press)

#2 Post by Administrator » Tue Jan 19, 2010 2:36 pm

Why are you trying to map the character to the key? Why not just use VK_A to VK_Z for the array to begin with?

Lembke
Posts: 13
Joined: Sun Aug 02, 2009 8:20 pm

Re: New function help needed (random key press)

#3 Post by Lembke » Tue Jan 19, 2010 2:53 pm

well i did find some other function and i did copy the most of it and im not an advanced scripter but you are right i should use VK_A - VK_Z

well lets move on to next question do i put that script in the Functions.lua file?

edit:
so i made some update on it i hope this is what you did mean

Code: Select all

function random_keypress()
  local keypress_chars = {"VK_a", "VK_b", "VK_c", "VK_d", "VK_e", "VK_f", "VK_g", "VK_h", "VK_i", "VK_j", "VK_k", "VK_l", "VK_m", "VK_n", "VK_o", "VK_p", "VK_q", "VK_r", "VK_s", "VK_t",
                "VK_u", "VK_v", "VK_w", "VK_x", "VK_y", "VK_z"};
    local index = math.random(1, #keypress_chars);
	keyboardPress( key.keypress_chars[index];
  end
 
  return true
end

I should even make

Code: Select all

local index = math.random(1, #keypress_chars);
to something like this

Code: Select all

    local index = math.random(1, 4);

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

Re: New function help needed (random key press)

#4 Post by Administrator » Tue Jan 19, 2010 8:53 pm

Again, you're using strings. You don't want "VK_A", you want VK_A. There is a difference. And, you're using a lowercase letter for some reason. Fix that.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests