1 /* SpinWheel requires a key */
2 
3 #appendto SpinWheel
4 
ControlUp(object clonk,...)5 public func ControlUp(object clonk, ...)
6 {
7 	if (!CheckLock(clonk)) return false;
8 	return inherited(clonk, ...);
9 }
10 
ControlDown(object clonk)11 public func ControlDown(object clonk)
12 {
13 	if (!CheckLock(clonk)) return false;
14 	return inherited(clonk, ...);
15 }
16 
CheckLock(object clonk)17 func CheckLock(object clonk)
18 {
19 	// already unlocked?
20 	if (this.unlocked) return true;
21 	// otherwise, find key
22 	var key = clonk->FindContents(Key);
23 	if (!key)
24 	{
25 		Dialogue->MessageBox("$DoorNoKey$", clonk, clonk);
26 		clonk->Sound("Animals::Wipf::Whine");
27 		return false;
28 	}
29 	// too far away? (may happen when callback is from key)
30 	if (ObjectDistance(clonk, this) > 30)
31 	{
32 		Dialogue->MessageBox("$DoorTooFar$", clonk, clonk, nil, true);
33 		return false;
34 	}
35 	// unlock
36 	Dialogue->MessageBox("$DoorUnlocked$", clonk, clonk, nil, true);
37 	this.unlocked = true;
38 	key->RemoveObject();
39 	Sound("UI::Click");
40 	return true;
41 }