sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #08842
Re: [Question #188360]: Cant use def!?!?
Question #188360 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/188360
Status: Open => Answered
RaiMan proposed the following answer:
a def on its own does nothing. It is only a piece of prepared code to be run by calling it.
Normally it is used to run the same workflow with different parameters and/or at different places in main workflow.
To run a def you have to call it like:
letsmine()
--- optimized version 1
assuming, that levelup() might change mineiron and/or more than one iron might exist in parallel
def letsmine():
if mineiron and gamezone.exists(iron, 0):
click(gamezone.getLastMatch())
wait(waittime)
levelup()
if mineiron and gamezone.exists(iron2, 0):
click(gamezone.getLastMatch())
wait(waittime)
levelup()
if mineiron and gamezone.exists(iron3, 0):
click(gamezone.getLastMatch())
wait(waittime)
levelup()
--- optimized version 2
assuming, that mine iron is not changed and only one iron exists in game zone at one time
def letsmine():
if mineiron and
(gamezone.exists(iron, 0) or
gamezone.exists(iron2, 0) or
gamezone.exists(iron3, 0) ):
click(gamezone.getLastMatch())
wait(waittime)
levelup()
the variables mineiron, iron, iron2, iron3 and waittime must be defined
before calling lets mine
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.