Crossfire Server, Trunk
QuestApplyIf.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 # QuestApplyIf.py - A script to let an item be applied only if a quest
3 # reached a certain step
4 # Arguments are:
5 # - quest name
6 # - a list of steps, either single value (x) or range (x-y)
7 # If any matches, then the item can be applied, else it is not applied
8 
9 import Crossfire
10 
11 player = Crossfire.WhoIsActivator()
12 params = Crossfire.ScriptParameters()
13 args = params.split()
14 
15 def can_apply(player):
16  if type(player) == Crossfire.Player:
17  questname = args[0]
18  currentstep = player.QuestGetState(questname)
19 
20  for rule in args[1:]:
21  if rule.find("-") == -1:
22  startstep = int(rule)
23  endstep = startstep
24  else:
25  startstep = int(rule.split("-")[0])
26  endstep = int(rule.split("-")[1])
27  if currentstep >= startstep and currentstep <= endstep:
28  return True
29  return False
30 
31 if can_apply(player):
32  Crossfire.SetReturnValue(0)
33 else:
34  # forbid applying
35  Crossfire.SetReturnValue(1)
36  msg = Crossfire.WhoAmI().Message
37  if type(player) == Crossfire.Player:
38  if msg is not None:
39  player.Message(msg.strip())
40  else:
41  player.Message("You cannot apply the %s now." % Crossfire.WhoAmI().Name)
QuestApplyIf.can_apply
def can_apply(player)
Definition: QuestApplyIf.py:15
make_face_from_files.int
int
Definition: make_face_from_files.py:32
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25