Integrates existing soaring instruments with the soaring sdk
[fg:toms-fgdata.git] / Aircraft / bocian / Nasal / winch.nas
1 # Place winch model in correct location 
2
3 var placeWinch = func {
4
5         setprop("/controls/winch/place",1);
6         settimer(placeWinchModel,0.1);
7
8 } #End Function
9
10 var placeWinchModel = func {
11
12         var posX = getprop("sim/hitches/winch/winch/global-pos-x");
13         var posY = getprop("sim/hitches/winch/winch/global-pos-y");
14         var posZ = getprop("sim/hitches/winch/winch/global-pos-z");
15
16         var g = geo.Coord.new().set_xyz(posX, posY, posZ);
17         geo.put_model("Models/Airport/supacat_winch.ac", g.lat(), g.lon());
18
19         setprop("/controls/winch/place",0);
20
21 } #End Function
22
23
24
25 #Init model counter
26 var winchModel = nil;
27
28 var placeWinchByMouse = func {
29
30
31         setprop("/controls/winch/open",1);
32         setprop("/sim/hitches/winch/winch/rel-speed",0);
33         var w = geo.click_position();
34         var ac = geo.aircraft_position();
35
36         if (winchModel != nil)
37                 winchModel.getParent().removeChild(winchModel.getName(), winchModel.getIndex());
38
39         winchModel = geo.put_model("Models/Airport/supacat_winch.xml", w.lat(), w.lon(), (w.alt()+0.81), (w.course_to(ac) ));
40
41         setprop("/sim/hitches/winch/winch/global-pos-x", w.x());
42         setprop("/sim/hitches/winch/winch/global-pos-y", w.y());
43         setprop("/sim/hitches/winch/winch/global-pos-z", w.z());
44         
45         settimer(placeWinchByMousePart2,0.1);
46
47 } #End Function
48
49 setlistener("/sim/signals/click",placeWinchByMouse);
50
51 var placeWinchByMousePart2 = func {
52
53         setprop("/sim/hitches/winch/winch/max-tow-length-m", getprop("/sim/hitches/winch/tow/dist") + 1);
54         setprop("/sim/hitches/winch/tow/length", getprop("/sim/hitches/winch/tow/dist") + 0.1);
55
56         setprop("/sim/hitches/winch/open",0);
57
58 } #End Function
59
60 controls.applyBrakes = func(v) {
61
62         setprop("sim/model/bocian/winch-hook-pos",v);
63         setprop("sim/hitches/winch/open",1);
64
65 } # End Function