Thursday, August 23, 2012

Ruby helps in gaming

Recently I found the game Clockwords: prelude (http://www.kongregate.com/games/gabob/clockwords-prelude) in which you have to write words to shoot letters and kill spiders.

Well after some levels the game become boring so I decided to find another solution... thanks to the xsendkeycode command and a simple ruby script...

first of all install xsendkeycode by typing
sudo apt-get install lineakd
then copy and paste this code into a file, make it executable and run it.
#!/usr/bin/env ruby
words = [
'congregationalists',
'chlorofluorocarbon',
'chlorofluorocarbons',
'compartmentalizing',
'conceptualizations',
'contradistinctions',
'conversationalists',
'counterintelligence',
'counterrevolutionaries',
'uncharacteristically']
keycodes = {
'q' => 24,
'w' => 25,
'e' => 26,
'r' => 27,
't' => 28,
'y' => 29,
'u' => 30,
'i' => 31,
'o' => 32,
'p' => 33,
'a' => 38,
's' => 39,
'd' => 40,
'f' => 41,
'g' => 42,
'h' => 43,
'j' => 44,
'k' => 45,
'l' => 46,
'z' => 52,
'x' => 53,
'c' => 54,
'v' => 55,
'b' => 56,
'n' => 57,
'm' => 58
}
sleep 2
words.each do |word|
  word.each_char do |letter|
    `xsendkeycode #{keycodes[letter]} 1`
     sleep 0.2
     `xsendkeycode #{keycodes[letter]} 0`
  end
  `xsendkeycode 36 1`
  sleep 0.2
  `xsendkeycode 36 0`
end

note that you need to quickly switch to the game windows and focus the game area with a click.
You also need to interrupt the script (ctrl+c) when the match is finished..

Long words are not the best.. I lost at level 9.. maybe short words with lots of letters contained in the boiler are the best.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.