Jump to content

Hotkey for functions in a script?


Recommended Posts

How can i set an hotkey for activating functions inside a script? 
Here an example, what's wrong?

Spoiler

import player
import net
import app

class Test():

	def __init__(self):
		self.__BuildKeyDict()

	def __BuildKeyDict(self):
		onPressKeyDict = {}
		onPressKeyDict[app.DIK_SPACE] = lambda : self.StartHot()
		self.onPressKeyDict = onPressKeyDict

	def StartHot(self):
		net.SendChatPacket("/unmount")
		player.ClickSkillSlot(3)
		for i in xrange(player.INVENTORY_PAGE_SIZE*3):
			ItemValue = player.GetItemIndex(i)
			if ItemValue == 666:
				net.SendItemUsePacket(i)

 

 

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

  • Forum Moderator
	def OnKeyDown(self, key):
		try:
			self.onPressKeyDict[key]()
		except KeyError:
			pass
		except:
			raise

		return True

 

  • Love 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.