forked from leberechtreinhold/dba3_tts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ttslua
175 lines (152 loc) · 5.85 KB
/
main.ttslua
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
-- In the global file of your game, simply add this line
-- #include main
-- Then, in Atom package settings, go to the TTS package and define the path
-- to this folder. Since this main file already includes the others no further
-- operation is required for scripts. The XML needs to be copied manually
-- however.
#include scripts/utilities_lua
-- shallow_copy and deep_copy are needed by data_cheat_sheet
#include scripts/data/data_cheat_sheet
#include scripts/data/data_settings
#include scripts/data/data_tables
#include scripts/data/data_terrain
#include scripts/data/data_troops
#include scripts/data/data_troops_greek_successors
#include scripts/data/data_armies_book_I
#include scripts/data/data_armies_book_II
#include scripts/data/data_armies_book_III
#include scripts/data/data_armies_book_IV
#include scripts/base_cache
#include scripts/log
#include scripts/utilities
#include scripts/logic_terrain
#include scripts/logic_gizmos
#include scripts/logic_spawn_army
#include scripts/logic_dead
#include scripts/logic_dice
#include scripts/logic_history_stack
#include scripts/logic_tool_tips
#include scripts/logic
#include scripts/uievents
function onload()
print_info('----------------------------------------------')
print_info(' DBA 3.0 v1.26 ')
print_info('----------------------------------------------\n\nCheck the Notebook for instructions.')
Wait.time(main_loop, g_seconds_main_loop, -1)
make_scenery_non_interactable()
reset_state()
spawn_proxy_bases()
spawn_all_dice()
spawn_dead_zones()
print_tool_tip_status()
end
function make_scenery_non_interactable()
-- Main table
getObjectFromGUID('558717').interactable = false
-- Chairs
getObjectFromGUID('e149a5').interactable = false
getObjectFromGUID('daff99').interactable = false
-- Floor
getObjectFromGUID('83a7b8').interactable = false
-- Walls
getObjectFromGUID('77e020').interactable = false
getObjectFromGUID('6880f1').interactable = false
getObjectFromGUID('a2475b').interactable = false
getObjectFromGUID('0d0857').interactable = false
-- Main point light
getObjectFromGUID('c0f8eb').interactable = false
-- Key light
getObjectFromGUID('4a9adf').interactable = false
-- Back lights
getObjectFromGUID('3b5c97').interactable = false
getObjectFromGUID('018fac').interactable = false
-- Top light for shadows
getObjectFromGUID('bc09bc').interactable = false
end
function update()
check_picked_base()
end
function print_help()
print_info('Write commands in the chat by writting !command.')
print_info('A extended description can be found on the Notebook.')
print_info('Available commands:')
print_info('!dba_help: Print this help')
print_info('!dba_print_state: Prints the current global vars of bases and table')
print_info('!dba_reset: Recalculates the bases and tables using heuristics on the existing objects')
end
function onChat(message, player)
if message == '!dba_help' then
print_info(player.get_steam_name() .. ': ' .. message)
print_help()
return false
end
if message == '!dba_reset' then
print_info(player.get_steam_name() .. ': ' .. message)
print_important('Resetting the state of the board, check the chat')
reset_state()
return false
end
if message == '!dba_print_state' then
print_info(player.get_steam_name() .. ': ' .. message)
print_state()
return false
end
if message == '!dba_debug' then
print_info(player.get_steam_name() .. ': ' .. message)
if g_debug_mode then
print_info('Disabling debug mode')
g_debug_mode = false
else
print_info('Enabling debug mode, will take effect in three seconds. Note, this will cause decreased performance.')
Wait.time(function()
g_debug_mode = true
print_info('Debug mode ON')
end, 3)
end
return false
end
if message == '!dba_3dterrain' then
print_info(player.get_steam_name() .. ': ' .. message)
g_use_3d_terrain = true
print_info('3D Terrain enabled, when doing a fix&lock on the table 3D objects will load.')
return false
end
if message == '!dba_regen_dice' then
print_info(player.get_steam_name() .. ': ' .. message)
spawn_all_dice()
return false
end
if message == '!dba_random_army' then
print_info(player.get_steam_name() .. ': ' .. message)
local _,book = random_kv(armies)
local army_name, army = random_kv(book)
print_important('Army selected: ' .. army_name .. '')
print_info('List: ' .. army['data']['list'])
print_info('Agressiveness: ' .. army['data']['aggresiveness']
.. ' Terrain: ' .. army['data']['terrain'])
return false
end
if message == '!dba_count_army_models' then
print_info(player.get_steam_name() .. ': ' .. message)
local total_counter = 0
for book_name,book_armies in pairs(armies) do
local counter = 0
local counter_total_armies = 0
for army_name,_ in pairs(book_armies) do
if not str_has_substr(army_name, '(Plain)') then
counter = counter + 1
end
counter_total_armies = counter_total_armies + 1
end
print_info(book_name .. ' has ' .. counter .. ' armies with models (of ' .. counter_total_armies .. ')')
total_counter = total_counter + counter
end
print_info('There is a total of ' .. total_counter .. ' armies with models')
return false
end
if str_starts_with(message, '!dba') then
print_info(player.get_steam_name() .. ': ' .. message)
print_error('Command not recognized. Please, use !dba_help')
end
return true
end