forked from Johnson336/LotJPlugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLotJVisualSpace.xml
More file actions
2086 lines (1915 loc) · 77.7 KB
/
LotJVisualSpace.xml
File metadata and controls
2086 lines (1915 loc) · 77.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE muclient>
<!-- Saved on Thursday, February 21, 2013, 8:52 PM -->
<!-- MuClient version 4.73 -->
<muclient>
<plugin name="LotJVisualSpace" author="@Johnson" id="a920ac5df84885eac6be8d61" language="Lua" purpose="Display character and ship information visually" save_state="y" requires="4.73" version="0.97">
<description trim="y">
Type 'vsconfig' to display Visual Space Config window where you can check and uncheck which windows you want to display.
</description>
</plugin>
<!-- Get our standard constants -->
<include name="constants.lua" />
<!-- Triggers -->
<triggers>
<!-- autopilot triggers -->
<trigger name="autopilotActivated" match="^Autopilot ON\.$" script="toggleAutopilotOn" group="LotJVisualSpace" enabled="y" regexp="y" sequence="100" />
<trigger name="autopilotDeactivated" match="^Autopilot OFF\.$" script="toggleAutopilotOff" group="LotJVisualSpace" enabled="y" regexp="y" sequence="100" />
<trigger name="autopilotActivate" match="^Autopilot Status\: ACTIVE(.*)$" script="toggleAutopilotOn" group="LotJVisualSpace" enabled="y" regexp="y" sequence="100" />
<trigger name="autopilotAlreadyActivate" match="^Autopilot is already on\.$" script="toggleAutopilotOn" group="LotJVisualSpace" enabled="y" regexp="y" sequence="100" />
<trigger name="autopilotAlreadyDeactive" match="^Autopilot is already off\.$" script="toggleAutopilotOff" group="LotJVisualSpace" enabled="y" regexp="y" sequence="100" />
<trigger name="autopilotDeactive" match="^Autopilot Status\: Offline(.*)$" script="toggleAutopilotOff" group="LotJVisualSpace" enabled="y" regexp="y" sequence="100" />
<!-- shield triggers -->
<trigger name="shieldsActivated" match="^Shields ON\. Autorecharge ON(.*)?$" script="toggleShieldsOn" group="LotJVisualSpace" enabled="y" regexp="y" sequence="100" />
<trigger name="shieldsDeactivated" match="^Shields OFF\. Shield strength set to 0\. Autorecharge OFF\.$" script="toggleShieldsOff" group="LotJVisualSpace" enabled="y" regexp="y" sequence="100" />
<trigger name="landingShieldOff" match="^You begin to land on (.*)\.$" script="toggleShieldsOff" group="LotJVisualSpace" enabled="y" regexp="y" sequence="100" />
<trigger name="shieldsIdle" match="^Autorecharge OFF\. Shields IDLING\.$" script="toggleShieldsOff" group="LotJVisualSpace" enabled="y" regexp="y" sequence="100" />
<!-- Lightspeed triggers -->
<trigger name="partialJump" match="^Remaining jump distance\: (.*)$" script="storePartialJump" group="LotJVisualSpace" enabled="y" regexp="y" sequence="100" />
<trigger name="jumpComplete" match="^Hyperjump complete\.$" script="clearJump" group="LotJVisualSpace" enabled="y" regexp="y" sequence="100" />
<!-- triggers relating to space capturing -->
<trigger name="StoreSpaceCoordinate" match="^(.*) (\-?\d+) (\-?\d+) (\-?\d+)(.*)?$" script="spaceCapStore" omit_from_output="n" keep_evaluating="y" group="SpaceCap" enabled="n" regexp="y" sequence="100" />
<trigger name="CapStop" match="^Your Coordinates\: (.*)$" script="spaceCapStop" group="SpaceCap" enabled="n" omit_from_output="n" regexp="y" sequence="100" />
<!-- Level capture triggers -->
<trigger name="LevelScoreGrab" match="^(.*) Level\: (\S+)\s*?\/(\S+)\s+(.*) Level\: (\S+)\s*?\/(.*)$" script="storeLevel" regexp="y" enabled="y" group="VariableStorage" sequence="100" />
<trigger name="LevelGrab" match="^(.*) Level\: (\d+)\s+Max\: (.*)\s+Exp\:(.*)$" script="storeLevel2" regexp="y" enabled="y" group="VariableStorage" sequence="100" />
</triggers>
<!-- Aliases -->
<aliases>
<alias name="clearWindows" script="destroyWindows" match="^vsclear$" enabled="y" ignore_case="y" regexp="y" group="LotJVisualSpace" sequence="100" />
<alias name="toggleConfigCommand" script="toggleVisualSpaceConfig" match="^vsconfig$" enabled="y" ignore_case="y" regexp="y" group="LotJVisualSpace" sequence="100" />
<alias name="toggleSpeedCommand" script="toggleVisualSpaceSpeed" match="^vsspeed$" enabled="y" ignore_case="y" regexp="y" group="LotJVisualSpace" sequence="100" />
<alias name="manualReset" script="reset" match="vsreset" enabled="y" ignore_case="y" group="LotJVisualSpace" sequence="100" />
<alias name="CoordCapStart" match="rad" script="spaceCapStart" enabled="y" group="LotJVisualSpace" ignore_case="y" sequence="100" />
<!--alias name="manualwindowskew" script="setval" match="vsset * * * *" enabled="y" regexp="n" ignore_case="y" group="LotJVisualSpace" sequence="100" -->
</aliases>
<timers>
<timer name="hyperJumpTicker" script="hyperJumpTick" enabled="n" second="2" group="LotJVisualSpace" />
<timer name="radarPulse" script="spaceCapStart" enabled="n" second="5" group="LotJVisualSpace" />
</timers>
<!-- Script -->
<script>
<![CDATA[
require "tprint"
require "movewindow"
require "serialize"
require "pairsbykeys"
dofile(GetPluginInfo(GetPluginID(), 20) .. "LotJMSDPHelper.lua")
local win = "visual_space_" .. GetPluginID() -- unique window name
local configwin = "config_win_" .. GetPluginID() -- unique config window name
local speedwin = "speed_win_" .. GetPluginID() -- unique speed window name
local jumpwin = "jump_win_" .. GetPluginID() -- unique jump window name
local statwin = "stat_win_" .. GetPluginID() -- unique stat window name
local shipwin = "ship_win_" .. GetPluginID() -- unique ship stat window name
local font = "font"..GetPluginID()
local digiFont = "digiFont"..GetPluginID()
local statFont = "statFont"..GetPluginID()
local shipFont = "shipFont"..GetPluginID()
local displayJumpPercent = tonumber(GetVariable("show_jump_percent") or 1)
local visualSpaceVisible = tonumber(GetVariable("show_space") or 0)
local visualSpaceConfigVisible = tonumber(GetVariable("show_config") or 1)
local visualSpaceSpeedVisible = tonumber(GetVariable("show_speed") or 0)
local visualSpaceJumpVisible = tonumber(GetVariable("show_jump") or 0)
local visualSpaceStatVisible = tonumber(GetVariable("show_stat") or 0)
local visualSpaceShipVisible = tonumber(GetVariable("show_ship") or 0)
local levels = {}
windows = {}
window_info = {}
loadstring(GetVariable("windows") or "")()
local autopilot = false
local recharge = false
local totalJump = 0
local partialJump = 0
background_colour = 0x000000
border_color = 0xcccccc
default_width = 400
default_height = 40
default_x = 0
default_y = 552
width = tonumber(GetVariable("width")) or 800
height = tonumber(GetVariable("height")) or 600
local RESIZE_TAG_SIZE = 10
local MIN_WIDTH = 50
local MIN_HEIGHT = 40
local LEFT_MARGIN = 10
local TOP_MARGIN = 5
-- Variables not saved.
startx = 0
starty = 0
posx = 0
posy = 0
hotspot_id = ""
page_built = false
line_height= 0
redraw_scheduled = false
-- space position variables
local zoom = tonumber(GetVariable("zoom")) or .75
local xcenter = 0
local ycenter = 0
local zcenter = 0
local xrotation = -30
local yrotation = -120
local zrotation = -30
systemobjs = {}
function drawWindows()
if redraw_scheduled == false then
return
else
redraw_scheduled = false
end
for k, v in pairs(windows) do
if (v.visible == 1) then
makeWindow(v)
end
end
if (visualSpaceVisible == 1) then
drawWindow()
end
if (visualSpaceConfigVisible == 1) then
drawConfigWindow()
end
if (visualSpaceSpeedVisible == 1) then
drawSpeedWindow()
end
if (visualSpaceJumpVisible == 1) then
drawJumpWindow()
end
if (visualSpaceStatVisible == 1) then
drawStatWindow()
end
if (visualSpaceShipVisible == 1) then
drawShipWindow()
end
--BroadcastPlugin (999, "repaint")
end
function drawConfigWindow()
left = 0
top = 0
right = 220
bottom = 155+(#windows*25)
WindowRectOp (configwin, miniwin.rect_fill, 0, 0, right, bottom, ColourNameToRGB("black"))
WindowRectOp (configwin, 5, 0, 0, 0, 0, 5, 15 + 0x1000)
movewindow.add_drag_handler (configwin, 0, 0, 0, WindowFontInfo (configwin, font, 1))
-- config window X
WindowLine (configwin, right-15, 5, right-5, 15, ColourNameToRGB ("white"), miniwin.pen_solid, 1)
WindowLine (configwin, right-15, 15, right-5, 5, ColourNameToRGB ("white"), miniwin.pen_solid, 1)
WindowAddHotspot(configwin, "configWindowX",
right-15, 5, right-5, 15,
"",
"",
"destroyConfigWindow",
"",
"",
"Close config window",
1, 0)
-- config window header
WindowText (configwin, font, "Visual Space Config v"..GetPluginInfo(GetPluginID(), 19), 5, 5, 0, 0, ColourNameToRGB("white"))
local oX = 10
local oY = 30
-- config option for main space window
drawConfigEntry(configwin, oX, oY, "Display Ship Position",
ColourNameToRGB("white"),
visualSpaceVisible,
"configWindowSpaceToggle",
"toggleVisualSpace")
-- move down 25 pixels
oY = oY + 25
-- config option for speed window
drawConfigEntry(configwin, oX, oY, "Display Speedometer",
ColourNameToRGB("white"),
visualSpaceSpeedVisible,
"configWindowSpeedToggle",
"toggleVisualSpaceSpeed")
-- move down 25 pixels
oY = oY + 25
-- config option for jump window
drawConfigEntry(configwin, oX, oY, "Display Hyperjump Window",
ColourNameToRGB("white"),
visualSpaceJumpVisible,
"configWindowJumpToggle",
"toggleVisualSpaceJump")
-- move down 25 pixels
oY = oY + 25
--config option for stat window
drawConfigEntry(configwin, oX, oY, "Display Char Stat Window",
ColourNameToRGB("white"),
visualSpaceStatVisible,
"configWindowStatToggle",
"toggleVisualSpaceStat")
-- move down 25 pixels
oY = oY + 25
--config option for stat window
drawConfigEntry(configwin, oX, oY, "Display Ship Stat Window",
ColourNameToRGB("white"),
visualSpaceShipVisible,
"configWindowShipToggle",
"toggleVisualSpaceShip")
for k, v in pairs(windows) do
-- move down 25 pixels
oY = oY + 25
drawConfigEntry(configwin, oX, oY, "Display " .. v.name .. " Window",
ColourNameToRGB("white"),
v.visible,
v.id.."configWindowToggle",
"windowToggle")
end
WindowSetZOrder (configwin, 1) -- config window is always on top
WindowShow (configwin, true)
end
function drawConfigEntry(w, x, y, tx, cr, cbb, hsn, hscn)
-- window, x, y, displayText, color, checkBoxBoolean, hotSpotName, hotSpotClickName
WindowRectOp (w, 5, x, y, x+20, y+20, 5, 15 + 0x1000) -- draw empty check box
WindowText (w, font, tx, x+28, y+2, 0, 0, cr) -- draw option text
if (cbb == 1) then -- draw checkbox if window is visible
drawcheckbox(w, x+2, y+2)
end
WindowAddHotspot(w, hsn, x, y, x+20, y+20, -- window, hotspotname, left, top, right, bottom
"", -- mousehover
"", -- mouseoffhover
hscn,-- mousedown
"", -- mouseoffdown
"", -- mouseup
tx, -- alt text
1, 0)
end
function drawcheckbox(window, left, top)
WindowLine (window, left+3, top+7, left+7, top+13, ColourNameToRGB("white"), miniwin.pen_solid, 2)
WindowLine (window, left+7, top+13, left+15, top+1, ColourNameToRGB("white"), miniwin.pen_solid, 2)
Redraw()
end
function windowToggle(flags, hotspot_id)
clickedWin = findwinbyid(string.sub(hotspot_id, 0, string.find(hotspot_id, "configWindowToggle")-1))
if not clickedWin then
return
end
if (clickedWin.visible == 1) then
clickedWin.visible = 0
WindowShow (clickedWin.id, false)
else
clickedWin.visible = 1
makeWindow(clickedWin)
end
if (visualSpaceConfigVisible == 1) then
drawConfigWindow()
end
end
function windowSwap(flags, hotspot_id)
clickedWin = findwinbyid(string.sub(hotspot_id, 0, string.find(hotspot_id, "Swap")-1))
if not clickedWin then
return
end
if (clickedWin.style == "horizontal") then
clickedWin.style = "vertical"
temp = clickedWin.width
clickedWin.width = clickedWin.height
clickedWin.height = temp
else
clickedWin.style = "horizontal"
temp = clickedWin.width
clickedWin.width = clickedWin.height
clickedWin.height = temp
end
SetUpHotspotsAndDraw(false)
end
function togglePercent(flags, hotspot_id)
clickedWin = findwinbyid(string.sub(hotspot_id, 0, string.find(hotspot_id, "TogglePercent")-1))
if not clickedWin then
return
end
if (clickedWin.percent == 1) then
clickedWin.percent = 0
else
clickedWin.percent = 1
end
makeWindow(clickedWin)
end
function unmakeWindow(flags, hotspot_id)
clickedWin = findwinbyid(string.sub(hotspot_id, 0, string.find(hotspot_id, "Close")-1))
if not clickedWin then
return
end
clickedWin.visible = 0
WindowShow (clickedWin.id, false)
if (visualSpaceConfigVisible == 1) then
drawConfigWindow()
end
end
function makeWindow(ww)
-- clear window
WindowRectOp (ww.id, miniwin.rect_fill, 0, 0, ww.width, ww.height, ColourNameToRGB("black"))
-- draw border
WindowRectOp (ww.id, 5, 0, 0, 0, 0, 5, 15 + 0x1000)
--drag handler
movewindow.add_drag_handler (ww.id, 0, 0, 0, WindowFontInfo(ww.id, font, 1)+5)
-- msdp assignment
local stat = tonumber(getmsdp(ww.stat1)) or 0
local maxStat = tonumber(getmsdp(ww.stat2)) or 0
--local stat = tonumber(msdpval(ww.stat1)) or 0
--local maxStat = tonumber(msdpval(ww.stat2)) or 0
local filledPixels = 0
local filledPercent = 0
if (maxStat > 0) then
filledPercent = stat / maxStat
else
filledPercent = 0
end
if (ww.style == "horizontal") then -- style horizontal
filledPixels = filledPercent * (ww.width - MIN_WIDTH)
local textWidth = WindowTextWidth(ww.id, font, ww.name)
WindowText (ww.id, font, ww.name, (25-(textWidth/2)), ww.height/2, 0, 0, ColourNameToRGB("white"))
local displayText = ""
if (ww.percent == 1) then
displayText = round(filledPercent*100) .. "%"
else
displayText = stat
end
textWidth = WindowTextWidth(ww.id, font, displayText)
WindowText (ww.id, font, displayText, (25-(textWidth/2)), ww.height/2-line_height, 0, 0, ColourNameToRGB("white"))
WindowAddHotspot(ww.id, ww.id.."TogglePercent",
(25-(textWidth/2)), ww.height/2-line_height, (25+(textWidth/2)), ww.height/2+line_height,
"",
"",
"togglePercent",
"",
"",
"Toggle percentage display",
1, 0)
WindowRectOp (ww.id, 5, MIN_WIDTH-2, 2, ww.width-2, ww.height-2, 10, 15 + 0x1000) -- surround dial with inverted border
local fillcolor = ColourNameToRGB(ww.color100)
if (filledPercent*100 <= 50) then
fillcolor = ColourNameToRGB(ww.color50)
if (filledPercent*100 <= 25) then
fillcolor = ColourNameToRGB(ww.color25)
end
end
-- redraw the bars
WindowGradient (ww.id, 50, 3, 46+filledPixels, ww.height/2, ColourNameToRGB("black"), fillcolor, 2)
WindowGradient (ww.id, 50, ww.height/2, 46+filledPixels, ww.height-3, fillcolor, ColourNameToRGB("black"), 2)
else -- style vertical
-- calculate the filled part
filledPixels = filledPercent * (ww.height - MIN_HEIGHT - 20)
local textWidth = WindowTextWidth (ww.id, font, ww.name)
WindowText (ww.id, font, ww.name, ((ww.width/2)-(textWidth/2)), ww.height-8-line_height,0,0, ColourNameToRGB("white"))
if (ww.percent == 1) then
displayText = round(filledPercent*100) .. "%"
else
displayText = stat
end
textWidth = WindowTextWidth (ww.id, font, displayText)
WindowText (ww.id, font, displayText, ((ww.width/2)-(textWidth/2)), ww.height-8-(line_height*2),0,0, ColourNameToRGB("white"))
WindowAddHotspot(ww.id, ww.id.."TogglePercent",
((ww.width/2)-(textWidth/2)), ww.height-45, ((ww.width/2)+(textWidth/2)), ww.height-5,
"", --mousehover
"", --mouseoffhover
"togglePercent", --mousedown
"", --mouseoffdown
"", --mouseup
"Toggle percentage display",
1, 0)
WindowRectOp (ww.id, 5, 2, 18, ww.width-2, ww.height-(MIN_HEIGHT-2), 10, 15 + 0x1000) -- surround dial with inverted border
fillcolor = ColourNameToRGB(ww.color100)
if (filledPercent*100 <= 50) then
fillcolor = ColourNameToRGB(ww.color50)
if (filledPercent*100 <= 25) then
fillcolor = ColourNameToRGB(ww.color25)
end
end
-- redraw the bars
WindowGradient (ww.id, 4, ww.height-filledPixels-MIN_HEIGHT, ww.width/2, ww.height-MIN_HEIGHT, ColourNameToRGB("black"), fillcolor, 1)
WindowGradient (ww.id, ww.width/2, ww.height-filledPixels-MIN_HEIGHT, ww.width-4, ww.height-MIN_HEIGHT, fillcolor, ColourNameToRGB("black"), 1)
end -- style
-- draw widget to vert swap
drawSwapper(ww.id, ww.width-30, 5, ColourNameToRGB("white"), ww.id.."Swap", "windowSwap", "Swap window style")
--draw X to close
drawX(ww.id, ww.width-15, 5, ColourNameToRGB("white"), ww.id.."Close", "unmakeWindow", "Close "..ww.name.." window")
drawResizer(ww.id, ww.width, ww.height)
WindowShow (ww.id, true)
end
require "commas"
function drawStatWindow()
statwidth = 400
statheight = 300
-- clear window
WindowRectOp (statwin, miniwin.rect_fill, 0, 0, statwidth, statheight, ColourNameToRGB("black"))
--border
WindowRectOp (statwin, 5, 0, 0, 0, 0, 5, 15 + 0x1000)
--drag handler
movewindow.add_drag_handler (statwin, 0, 0, 0, WindowFontInfo(statwin, font, 1))
--draw X to close
drawX(statwin, statwidth-15, 5, ColourNameToRGB("white"), "statWindowX", "destroyStatWindow", "Close stat window")
local charname = getmsdp("CHARACTERNAME") or ""
local toplevel = getmsdp("TOPLEVEL") or ""
local class = getmsdp("CLASS") or ""
local race = getmsdp("RACE") or ""
local align = tonumber(getmsdp("ALIGNMENT")) or 0
local charstats = {
"Strength", getmsdp("STR") or 0, getmsdp("STRPERM") or 0,
"Dexterity", getmsdp("DEX") or 0, getmsdp("DEXPERM") or 0,
"Constitution", getmsdp("CON") or 0, getmsdp("CONPERM") or 0,
"Intelligence", getmsdp("INT") or 0, getmsdp("INTPERM") or 0,
"Wisdom", getmsdp("WIS") or 0, getmsdp("WISPERM") or 0,
"Charisma", getmsdp("CHA") or 0, getmsdp("CHAPERM") or 0
}
local charattribs = {
"Armor", getmsdp("AC") or 0,
"Hitroll", getmsdp("HITROLL") or 0,
"Damroll", getmsdp("DAMROLL") or 0,
"MoneyTotal", getmsdp("MONEYTOTAL") or 0,
"Money Bank", getmsdp("MONEYBANK") or 0,
"Money Held", getmsdp("MONEYINV") or 0
}
local oY = 10
local textWidth = WindowTextWidth(statwin, font, charname)
if (align < 0) then
aligncolor = "red"
elseif (align > 0) then
aligncolor = "deepskyblue"
else
aligncolor = "white"
end
WindowText(statwin, font, charname, statwidth/2-(textWidth/2), oY, 0, 0, ColourNameToRGB("silver"))
oY = oY + (line_height*1.5)
textWidth = WindowTextWidth(statwin, font, "Level "..toplevel.." "..race.." "..class.." main")
WindowText(statwin, font, "Level "..toplevel.." "..race.." "..class.." main", statwidth/2-(textWidth/2), oY, 0, 0, ColourNameToRGB("silver"))
oY = oY + line_height
for i=0, 15, 3 do
oY = oY + line_height
WindowText(statwin, statFont, charstats[i+1], 10, oY, 0, 0, ColourNameToRGB("gray"))
WindowText(statwin, statFont, ":[", 110, oY, 0, 0, ColourNameToRGB("cyan"))
WindowText(statwin, statFont, charstats[i+2], 130, oY, 0, 0, ColourNameToRGB("silver"))
textWidth = WindowTextWidth(statwin, statFont, charstats[i+2])
WindowText(statwin, statFont, "/", 130+textWidth, oY, 0, 0, ColourNameToRGB("cyan"))
textWidth = textWidth + WindowTextWidth(statwin, statFont, "/")
WindowText(statwin, statFont, charstats[i+3], 130+textWidth, oY, 0, 0, ColourNameToRGB("silver"))
textWidth = textWidth + WindowTextWidth(statwin, statFont, charstats[i+3])
WindowText(statwin, statFont, "]", 133+textWidth, oY, 0, 0, ColourNameToRGB("cyan"))
end
oY = 10 + (line_height*2.5)
for i=0, 10, 2 do
oY = oY + line_height
WindowText(statwin, statFont, charattribs[i+1], 200, oY, 0, 0, ColourNameToRGB("gray"))
WindowText(statwin, statFont, ":[", 280, oY, 0, 0, ColourNameToRGB("cyan"))
if (i>4) then
text = commas(charattribs[i+2])
else
text = charattribs[i+2]
end
WindowText(statwin, statFont, text, 300, oY, 0, 0, ColourNameToRGB("silver"))
textWidth = WindowTextWidth(statwin, statFont, text)
WindowText(statwin, statFont, "]", 303+textWidth, oY, 0, 0, ColourNameToRGB("cyan"))
end
oY = oY + 20
oX = statwidth / 2
local skip = false
for k, v in pairsByKeys(levels) do
if (k == "bounty hunting") then
levels[k].class_level = getmsdp("LEVELHUNTING") or 1
elseif (k == "combat") then
levels[k].class_level = getmsdp("LEVELCOMBAT") or 1
elseif (k == "diplomacy") then
levels[k].class_level = getmsdp("LEVELDIPLOMACY") or 1
elseif (k == "engineering") then
levels[k].class_level = getmsdp("LEVELENGINEERING") or 1
elseif (k == "espionage") then
levels[k].class_level = getmsdp("LEVELESPIONAGE") or 1
elseif (k == "force") then
levels[k].class_level = getmsdp("LEVELFORCE") or 1
elseif (k == "leadership") then
levels[k].class_level = getmsdp("LEVELLEADERSHIP") or 1
elseif (k == "medical") then
levels[k].class_level = getmsdp("LEVELMEDIC") or 1
elseif (k == "piloting") then
levels[k].class_level = getmsdp("LEVELPILOTING") or 1
elseif (k == "science") then
levels[k].class_level = getmsdp("LEVELSCIENCE") or 1
elseif (k == "slicer") then
levels[k].class_level = getmsdp("LEVELSLICER") or 1
elseif (k == "smuggling") then
levels[k].class_level = getmsdp("LEVELSMUGGLING") or 1
end
if (skip == true) then
skip = false
WindowText(statwin, statFont, v.class_name,oX+10, oY, 0, 0, ColourNameToRGB("gray"))
WindowText(statwin, statFont, ":",oX+103,oY,0,0,ColourNameToRGB("cyan"))
WindowText(statwin, statFont, v.class_level, oX+110, oY, 0, 0, ColourNameToRGB("silver"))
WindowText(statwin, statFont, "/", oX+134, oY, 0, 0, ColourNameToRGB("cyan"))
WindowText(statwin, statFont, v.class_max, oX+141, oY, 0, 0, ColourNameToRGB("silver"))
else
skip = true
oY = oY + line_height
WindowText(statwin, statFont, v.class_name,10, oY, 0, 0, ColourNameToRGB("gray"))
WindowText(statwin, statFont, ":",123,oY,0,0,ColourNameToRGB("cyan"))
WindowText(statwin, statFont, v.class_level, 130, oY, 0, 0, ColourNameToRGB("silver"))
WindowText(statwin, statFont, "/", 154, oY, 0, 0, ColourNameToRGB("cyan"))
WindowText(statwin, statFont, v.class_max, 161, oY, 0, 0, ColourNameToRGB("silver"))
end
end
--drawResizer(statwin, width, height)
WindowShow (statwin, true)
end
dofile(GetPluginInfo(GetPluginID(), 20) .. "lotj_colors.lua")
-- window to display ship information
function drawShipWindow()
shipwidth = 400
shipheight = 150
-- clear window
WindowRectOp (shipwin, miniwin.rect_fill, 0, 0, shipwidth, shipheight, ColourNameToRGB("black"))
--border
WindowRectOp (shipwin, 5, 0, 0, 0, 0, 5, 15 + 0x1000)
--drag handler
movewindow.add_drag_handler (shipwin, 0, 0, 0, WindowFontInfo(shipwin, font, 1))
--draw X to close
drawX(shipwin, shipwidth-15, 5, ColourNameToRGB("white"), "shipWindowX", "destroyShipWindow", "Close ship window")
local ship = {}
local piloting = tonumber(getmsdp("PILOTING") or "")
ship.name = "(Not piloting a ship)"
if piloting == 1 then -- we're in a cockpit, assume the room name is close enough to being the ship's name (not always true)
ship.name = strip_colours(getmsdp("ROOMNAME") or "")
end
local sysname = getmsdp("SHIPSYSNAME")
if sysname == "" then sysname = "(Not in a known system)" end
local shipx = getmsdp("SHIPSYSX")
local shipy = getmsdp("SHIPSYSY")
local shipz = getmsdp("SHIPSYSZ")
local shipheadx = getmsdp("SHIPHEADX")
local shipheady = getmsdp("SHIPHEADY")
local shipheadz = getmsdp("SHIPHEADZ")
local oY = 10
local textWidth = WindowTextWidth(shipwin, shipFont, ship.name)
WindowText(shipwin, shipFont, ship.name, shipwidth/2-(textWidth/2), oY, 0, 0, ColourNameToRGB("silver"))
oY = oY + (line_height*1.5)
textWidth = WindowTextWidth(shipwin, shipFont, "Current System: "..sysname)
WindowText(shipwin, shipFont, "Current System: "..sysname, shipwidth/2-(textWidth/2), oY, 0, 0, ColourNameToRGB("silver"))
oY = oY + line_height*2
textWidth = WindowTextWidth(shipwin, shipFont, "Coords [ X: "..shipx.." Y: "..shipy.." Z: "..shipz.." ]")
WindowText(shipwin, shipFont, "Coords [ X: "..shipx.." Y: "..shipy.." Z: "..shipz.." ]", shipwidth/2-(textWidth/2), oY, 0, 0, ColourNameToRGB("silver"))
oY = oY + line_height*2
textWidth = WindowTextWidth(shipwin, shipFont, "Heading [ X: "..shipheadx.." Y: "..shipheady.." Z: "..shipheadz.." ]")
WindowText(shipwin, shipFont, "Heading [ X: "..shipheadx.." Y: "..shipheady.." Z: "..shipheadz.." ]", shipwidth/2-(textWidth/2), oY, 0, 0, ColourNameToRGB("silver"))
--drawResizer(shipwin, shipwidth, shipheight)
WindowShow (shipwin, true)
end
function storeLevel(name, list, args)
local storage = {
class_name = "",
class_level = 1,
class_max = 1
}
storage.class_name = Trim(args[1])
storage.class_level = Trim(args[2])
storage.class_max = Trim(args[3])
levels[storage.class_name] = storage
--table.insert(levels, storage)
--Note("class: '" .. storage.class_name .. "' (" .. storage.class_level .. "/" .. storage.class_max .. ")")
local storage = {
class_name = "",
class_level = 0,
class_max = 0
}
storage.class_name = Trim(args[4])
storage.class_level = Trim(args[5])
storage.class_max = Trim(args[6])
levels[storage.class_name] = storage
--table.insert(levels, storage)
--Note("class: '" .. storage.class_name .. "' (" .. storage.class_level .. "/" .. storage.class_max .. ")")
--for i=1, #args, 1 do
-- Note(i .. " : '" .. args[i] .. "'")
--end
if (visualSpaceStatVisible == 1) then
drawStatWindow()
end
end
function storeLevel2(name, list, args)
local storage = {
class_name = "",
class_level = 1,
class_max = 1
}
storage.class_name = Trim(args[1])
storage.class_level = Trim(args[2])
storage.class_max = Trim(args[3])
levels[storage.class_name] = storage
if (visualSpaceStatVisible == 1) then
drawStatWindow()
end
end
function abbrev_class(classname)
if (classname == "combat") then
return "Com"
elseif (classname == "piloting") then
return "Pil"
elseif (classname == "engineering") then
return "Eng"
elseif (classname == "bounty hunting") then
return "Bht"
elseif (classname == "smuggling") then
return "Smu"
elseif (classname == "diplomacy") then
return "Dip"
elseif (classname == "leadership") then
return "Lea"
elseif (classname == "espionage") then
return "Esp"
elseif (classname == "slicer") then
return "Sli"
elseif (classname == "medical") then
return "Med"
elseif (classname == "science") then
return "Sci"
elseif (classname == "force") then
return "Frc"
end
end
function drawJumpWindow()
left = 0
top = 0
right = 400
bottom = 60
-- clear window
WindowRectOp (jumpwin, miniwin.rect_fill, 0, 0, right, bottom, ColourNameToRGB("black"))
--border
WindowRectOp (jumpwin, 5, 0, 0, 0, 0, 5, 15 + 0x1000)
--drag handler
movewindow.add_drag_handler (jumpwin, 0, 0, 0, WindowFontInfo(jumpwin, font, 1))
--draw X to close
drawX(jumpwin, right-15, 5, ColourNameToRGB("white"), "jumpWindowX", "destroyJumpWindow", "Close hyperjump window")
local percent = 0
local pixels = 0
local systemname = getmsdp("SHIPSYSNAME") or ""
--Note("System: " .. systemname)
-- calculate amount of jump we've completed
if (totalJump > 0 and partialJump > 0) then
percent = (totalJump - partialJump) / totalJump
else
percent = 0
end
pixels = percent * (right - 70)
local textWidth = WindowTextWidth(jumpwin, font, "Jump")
WindowText (jumpwin, font, "Jump", left+(25-(textWidth/2)), bottom-25, left+(25+(textWidth/2)), bottom-5, ColourNameToRGB("white"))
local displayJumpText = ""
if (displayJumpPercent == 1) then
displayJumpText = round(percent*100) .. "%"
else
displayJumpText = partialJump
end
-- jump window header - remaining jump time
if (partialJump > 0) then
local jumpTime = displayTime(math.ceil(partialJump/50) * 2)
textWidth = WindowTextWidth(jumpwin, font, "~" .. jumpTime .. " remaining")
WindowText (jumpwin, font, "~" .. jumpTime .. " remaining", left+(200-(textWidth/2)) , 5, left+(200+(textWidth/2)), 20, ColourNameToRGB("white"))
end
textWidth = WindowTextWidth (jumpwin, font, displayJumpText)
WindowText (jumpwin, font, displayJumpText, left+(25-(textWidth/2)), bottom-45, left+(25+(textWidth/2)), bottom-15, ColourNameToRGB("white"))
WindowAddHotspot (jumpwin, "toggleJumpPercentHotspot",
left+(25-(textWidth/2)), bottom-45, left+(25+(textWidth/2)), bottom-25,
"",
"",
"toggleJumpPercent",
"",
"",
"Toggle percentage display",
1, 0)
-- draw systems and traveling bar
WindowLine (jumpwin, left+60, bottom/2, right-10, bottom/2, ColourNameToRGB("white"), miniwin.pen_solid, 4)
WindowCircleOp(jumpwin, 1, left+55, (bottom/2)-5, left+65, (bottom/2)+5, ColourNameToRGB("olivedrab"), 0, 2, ColourNameToRGB("olivedrab"), 0)
WindowCircleOp(jumpwin, 1, right-15, (bottom/2)-5, right-5, (bottom/2)+5, ColourNameToRGB("olivedrab"), 0, 2, ColourNameToRGB("olivedrab"), 0)
-- draw player ship on traveling bar
WindowCircleOp(jumpwin, 1, left+55+pixels, (bottom/2)-5, left+65+pixels, (bottom/2)+5, ColourNameToRGB("dodgerblue"), 0, 2, ColourNameToRGB("dodgerblue"), 0)
WindowShow (jumpwin, true)
end
local speedSlide = 0
local prevSpeed = 0
local tempSpeed = 0
local tempPercent = 0
local tempPixels = 0
local speed = 0
local maxSpeed = 0
local speedlist = {}
function drawSpeedWindow()
left = 0
top = 0
right = 300
bottom = 200
prevSpeed = speed
--msdp assignment
if (speedSlide == 0) then -- we're sliding so we don't need to update speed
speed = tonumber(getmsdp("SHIPSPEED")) or 0
maxSpeed = tonumber(getmsdp("SHIPMAXSPEED")) or 0
end
-- clear window
WindowRectOp (speedwin, miniwin.rect_fill, 0, 0, right, bottom, ColourNameToRGB("black"))
-- border
WindowRectOp (speedwin, 5, 0, 0, 0, 0, 5, 15 + 0x1000)
-- drag handler
movewindow.add_drag_handler (speedwin, 0, 0, 0, WindowFontInfo (speedwin, font, 1))
-- draw X to close
drawX(speedwin, right-15, 5, ColourNameToRGB("white"), "speedWindowX", "destroySpeedWindow", "Close speed window")
-- here is my attempt to slide the indicator nicely between speed changes
if (speed > prevSpeed) then -- you went up in speed
speedSlide = 1
for i=0, 10, 1 do -- figure the incremental changes
speedlist[i] = prevSpeed + ((speed - prevSpeed)*(i/10))
end
end
if (speed < prevSpeed) then -- you went down in speed
speedSlide = -1
for i=0, 10, 1 do -- figure the incremental changes
speedlist[i] = prevSpeed - ((prevSpeed - speed)*(i/10))
end
end
local filledPixels = 0
local filledPercent = 0
if (maxSpeed > 0) then -- if you're in a ship
filledPercent = speed / 200 -- percent is your speed / max speed of gauge
else
filledPercent = 0 -- not in a ship
end
filledPixels = filledPercent * 280 -- number of pixels to draw is percent * width of gauge
-- draw Speed text
local textWidth = WindowTextWidth (speedwin, font, "Speed")
WindowText (speedwin, font, "Speed", left+(150-(textWidth/2)), bottom-25, left+(150+(textWidth/2)), bottom-5, ColourNameToRGB("white"))
--Note("speed: " .. speed .. " max: " .. maxSpeed .. " filled: " .. filledPercent .. " (" .. filledPixels .. ")")
-- draw speed readout text
if (#speedlist > 0 and speedlist[math.abs(speedSlide)] > 0) then -- if we're in the middle of a slide, show the incremental speed change
textWidth = WindowTextWidth(speedwin, digiFont, round(speedlist[math.abs(speedSlide)]))
WindowText (speedwin, digiFont, round(speedlist[math.abs(speedSlide)]), left+(150-(textWidth/2)), bottom-55, left+(150+(textWidth/2)), bottom-15, ColourNameToRGB("white"))
else
textWidth = WindowTextWidth (speedwin, digiFont, speed) -- otherwise show the real speed
WindowText (speedwin, digiFont, speed, left+(150-(textWidth/2)), bottom-55, left+(150+(textWidth/2)), bottom-15, ColourNameToRGB("white"))
end
-- surround dial with inverted border
WindowRectOp (speedwin, 5, left+8, top+38, right-8, bottom-68, 10, 15 + 0x1000)
-- draw speed tick marks at 10% intervals from 20 to 200
for i=0, 10, 1 do
WindowLine (speedwin, left+(i*28)+10, top+40, left+(i*28)+10, bottom-110, ColourNameToRGB("white"),0, 4)
textWidth = WindowTextWidth(speedwin, font, (i*20))
-- draw text above the tick marks centered on each mark
WindowText (speedwin, font, (i*20), left+(i*28)+(10-(textWidth/2)), top+20, left+(i*28)+(10+(textWidth/2)), top+41, ColourNameToRGB("white"))
end
-- draw the ship's max speed (red line)
WindowLine (speedwin, left+((maxSpeed/200)*280)+10, top+40, left+((maxSpeed/200)*280)+10, bottom-110, ColourNameToRGB("darkred"), 0, 4)
-- draw current speed indicator
if (#speedlist > 0 and speedlist[math.abs(speedSlide)] > 0) then -- if we're sliding, show the incremental change
tempPercent = speedlist[math.abs(speedSlide)] / 200
tempPixels = tempPercent * 280
WindowLine (speedwin, left+tempPixels+10, bottom-120, left+tempPixels+10, bottom-70, ColourNameToRGB("red"), 0, 4)
else -- show the real speed
WindowLine (speedwin, left+filledPixels+10, bottom-120, left+filledPixels+10, bottom-70, ColourNameToRGB("red"), 0, 4)
end
-- poor way of incrementing the shift from one speed to another.. FIXME
if (speedSlide > 0) then
speedSlide = speedSlide + 1
if (speedSlide > 10) then
speedSlide = 0
speedlist = {}
else
-- this seems to work alright, but varies quite a bit in number of frames shown and isn't always smooth
-- needs a smooother animation method to slide needle between speeds
DoAfterSpecial (.1, 'drawSpeedWindow()', sendto.script)
end
end
if (speedSlide < 0) then
speedSlide = speedSlide - 1
if (speedSlide < -10) then
speedSlide = 0
speedlist = {}
else
DoAfterSpecial (.1, 'drawSpeedWindow()', sendto.script)
end
end
-- draw autopilot indicator
local drawcolor = ColourNameToRGB("gray")
if (autopilot) then
drawcolor = ColourNameToRGB("red")
end
WindowText (speedwin, font, "AUTOPILOT", left+5, bottom-25, left+WindowTextWidth(speedwin, font, "AUTOPILOT")+5, bottom-5, drawcolor)
-- draw shield indicator
drawcolor = ColourNameToRGB("gray")
if (recharge) then
drawcolor = ColourNameToRGB("yellow")
end
WindowText (speedwin, font, "SHIELDS", right-WindowTextWidth(speedwin, font, "SHIELDS")-5, bottom-25, right-5, bottom-5, drawcolor)
WindowShow (speedwin, true)
end
-- method to draw a colored X in window at left, top with hotspotname and does hotspotclick when you click it
function drawX(window, left, top, color, hotSpotName, hotSpotClick, hotSpotText)
WindowLine (window, left, top, left+10, top+10, color, miniwin.pen_solid, 1)
WindowLine (window, left, top+10, left+10, top, color, miniwin.pen_solid, 1)
WindowAddHotspot(window, hotSpotName, left, top, left+10, top+10, "", "", hotSpotClick, "", "", hotSpotText, 1, 0)
Redraw()
end
function drawSwapper(window, left, top, color, hotSpotName, hotSpotClick, hotSpotText)
WindowLine(window, left, top, left+4, top, color, miniwin.pen_solid, 1)
WindowLine(window, left, top, left, top+4, color, miniwin.pen_solid, 1)
WindowLine(window, left, top, left+11, top+11, color, miniwin.pen_solid, 1)
WindowLine(window, left+7, top+10, left+10, top+10, color, miniwin.pen_solid, 1)
WindowLine(window, left+10, top+7, left+10, top+10, color, miniwin.pen_solid, 1)
WindowAddHotspot(window, hotSpotName, left, top, left+10, top+10, "", "", hotSpotClick, "", "", hotSpotText, 1, 0)
Redraw()
end
function drawResizer(window, width, height)
-- draw the resize widget bottom right corner.
WindowLine(window, width-3, height-2, width-2, height-3, 0xffffff, 0, 2)
WindowLine(window, width-4, height-2, width-2, height-4, 0x696969, 0, 1)
WindowLine(window, width-6, height-2, width-2, height-6, 0xffffff, 0, 2)
WindowLine(window, width-7, height-2, width-2, height-7, 0x696969, 0, 1)
WindowLine(window, width-9, height-2, width-2, height-9, 0xffffff, 0, 2)
WindowLine(window, width-10, height-2, width-2, height-10, 0x696969, 0, 1)
WindowLine(window, width-12, height-2, width-2, height-12, 0xffffff, 0, 2)
WindowLine(window, width-13, height-2, width-2, height-13, 0x696969, 0, 1)
end
function round (x)
if x >= 0 then
return math.floor (x + 0.5)
--return math.floor (x)
end -- if positive
return math.ceil (x - 0.5)
--return math.ceil (x)
end -- function round
function spaceCapStart()
if (visualSpaceVisible ~= 1) then
return
end
EnableTriggerGroup("SpaceCap", true)
for _,v in pairs(systemobjs) do
WindowDeleteHotspot(win, "systemobjhover"..v.name)
end
systemobjs = {}
SendNoEcho("radar")
end
function spaceCapStop()
EnableTriggerGroup("SpaceCap", false)
scheduleRedraw()
end
function spaceCapStore(name, line, args, styles)
local body = {
name=Trim(args[1]),
x=tonumber(args[2]),
y=tonumber(args[3]),
z=tonumber(args[4])
}
if (body.name ~= "Your Coordinates:" and body.name ~= "New course set, approaching" and not string.find(body.name, "Speed:", 0, true)) then
systemobjs[#systemobjs + 1] = body
--ColourTell("silver", "black", #spaceCoords..") ")
--for k, v in pairs(styles) do
--Hyperlink("lcalc "..#spaceCoords, v.text, "Jump to "..spaceCoords[#spaceCoords].name, RGBColourToName(v.textcolour), RGBColourToName(v.backcolour), false)
--end
--else
--for k, v in pairs(styles) do
--ColourTell (RGBColourToName(v.textcolour), RGBColourToName(v.backcolour), v.text)
--end
end
--Note("")
end
----- 3D transform variables
--a{x,y,z} - the 3D position of a point A that is to be projected
--c{x,y,z} - the 3D position of a point C representing the camera
--t{x,y,z} - the orientation of the camera (represented, for instance, by tait-bryan angles)
--e{x,y,z} - the viewer's position relative to the display surface
-- which results in:
-- b{x,y} - the 2D projection of A
-- to compute b{x,y} we first define a vector d{x,y,z} as the position of point A with respect to a coordinate system
-- defined by the camera, with origin in C and rotated by T with respect to the initial coordinate system. This is
-- achieved by subtracting C from A and then applying a rotation by -T to the result. This transformation is often
-- called a camera transform, and can be expressed as follows, expressing the rotation in terms of rotations about
-- the x, y, and z axes (these calculations assume that the axes are ordered as a left-handed system of axes)
-- d{x} = cos(t{y}) * (sin(t{z}) * (a{y} - c{y}) + cos(t{z}) * (a{x} - c{x})) - sin(t{y}) * (a{z} - c{z})
-- d{y} = sin(t{x}) * (cos(t{y}) * (a{z} - c{z}) + sin(t{y}) * (sin(t{z}) * (a{y} - c{y}) + cos(t{z}) * (a{x} - c{x}))) + cos(t{x}) * (cos(t{z}) * (a{y} - c{y}) - sin(t{z}) * (a{x} - c{x}))
-- d{z} = cos(t{x}) * (cos(t{y}) * (a{z} - c{z}) + sin(t{y}) * (sin(t{z}) * (a{y} - c{y}) + cos(t{z}) * (a{x} - c{x}))) - sin(t{x}) * (cos(t{z}) * (a{y} - c{y}) - sin(t{z}) * (a{x} - c{x}))
--
-- b{x} = (d{x} - e{x})*(e{z}/d{z})
-- b{y} = (d{y} - e{y})*(e{z}/d{z})
--local a = {x=0,y=0,z=0} -- position of point A to be projected
--local c = {x=2000,y=2000,z=2000} -- position of point C representing the camera
--local t = {x=30,y=30,z=30} -- orientation of the camera
--local e = {x=2000,y=2000,z=2000} -- viewer's position relative to the display surface
--local d = {x=0,y=0,z=0} -- position of point A with respect to coordinate system defined by the camera, with origin C and rotated by T
--local b = {x=0,y=0} -- our final point to be mapped in an 2D XY surface
--function setval(name, line, args)
-- if (args[1]~="" and args[2]~="" and args[3]~="" and args[4]~="") then
-- if (args[1] == "t") then
-- t = {x=tonumber(args[2]),y=tonumber(args[3]),z=tonumber(args[4])}
-- Note("t".."("..t.x..","..t.y..","..t.z..")")
-- elseif (args[1] == "c") then
-- c = {x=tonumber(args[2]),y=tonumber(args[3]),z=tonumber(args[4])}
-- Note("c".."("..c.x..","..c.y..","..c.z..")")
-- elseif (args[1] == "e") then
-- e = {x=tonumber(args[2]),y=tonumber(args[3]),z=tonumber(args[4])}
-- Note("e".."("..e.x..","..e.y..","..e.z..")")
-- end
--args[1] = {x=tonumber(args[2]),y=tonumber(args[3]),z=tonumber(args[4])}
--Note(args[1].."("..args[1].x..","..args[1].y..","..args[1].z..")")
-- drawWindow()
-- end
--end
--local matrix = require 'matrix'
local ball = { pos = {x = width/2, y = height/2}, speed = {x = 10, y = 10}, radius = 10 }
function drawWindow() -- getting closer
-- clear window