isaacscript 2.6.2 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -21,11 +21,11 @@ font:Load("font/pftempestasevencondensed.fnt") -- A vanilla font good for this k
|
|
|
21
21
|
local connected = false
|
|
22
22
|
local sprite = nil
|
|
23
23
|
|
|
24
|
-
local
|
|
24
|
+
local mod = RegisterMod("IsaacScript Watcher", 1)
|
|
25
25
|
|
|
26
26
|
-- On mod initialization, nuke the "save#.dat" folder to get rid of old messages that might be left
|
|
27
27
|
-- there from IsaacScript.
|
|
28
|
-
|
|
28
|
+
mod:SaveData("")
|
|
29
29
|
|
|
30
30
|
local function pushMessageArray(msg)
|
|
31
31
|
frameOfLastMsg = Isaac.GetFrameCount()
|
|
@@ -45,20 +45,20 @@ local function getScreenBottomRightPos()
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
-- ModCallbacks.MC_POST_RENDER (2)
|
|
48
|
-
function
|
|
48
|
+
function mod:PostRender()
|
|
49
49
|
-- Don't do anything while fading in to a new run to prevent crashes.
|
|
50
50
|
if game:GetFrameCount() < 1 then
|
|
51
51
|
return
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
mod:RenderSprite()
|
|
55
|
+
mod:RenderText()
|
|
56
|
+
mod:LoadSaveDat()
|
|
57
|
+
mod:CheckInput()
|
|
58
|
+
mod:CheckRestart()
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
function
|
|
61
|
+
function mod:RenderSprite()
|
|
62
62
|
-- Determine if IsaacScript is connected or not.
|
|
63
63
|
local frameCount = Isaac.GetFrameCount()
|
|
64
64
|
connected = frameCount - frameOfLastSuccessfulLoad <= FRAMES_BEFORE_DISCONNECTED
|
|
@@ -68,7 +68,14 @@ function IsaacScriptWatcher:RenderSprite()
|
|
|
68
68
|
if sprite == nil then
|
|
69
69
|
sprite = Sprite()
|
|
70
70
|
sprite:Load("gfx/logo.anm2", true)
|
|
71
|
-
|
|
71
|
+
|
|
72
|
+
local lastMsg = messageArray[#messageArray]
|
|
73
|
+
local compiling = string.match(lastMsg, "Compiling the mod for the first time...")
|
|
74
|
+
local animation = "Default"
|
|
75
|
+
if compiling ~= nil then
|
|
76
|
+
animation = "Green"
|
|
77
|
+
end
|
|
78
|
+
sprite:Play(animation)
|
|
72
79
|
end
|
|
73
80
|
else
|
|
74
81
|
if sprite ~= nil then
|
|
@@ -80,11 +87,11 @@ function IsaacScriptWatcher:RenderSprite()
|
|
|
80
87
|
if sprite ~= nil then
|
|
81
88
|
local bottomRightPos = getScreenBottomRightPos()
|
|
82
89
|
local position = bottomRightPos + SPRITE_BOTTOM_RIGHT_OFFSET
|
|
83
|
-
sprite:
|
|
90
|
+
sprite:Render(position)
|
|
84
91
|
end
|
|
85
92
|
end
|
|
86
93
|
|
|
87
|
-
function
|
|
94
|
+
function mod:RenderText()
|
|
88
95
|
-- Don't draw IsaacScript text when custom consoles are open.
|
|
89
96
|
if AwaitingTextInput then
|
|
90
97
|
return
|
|
@@ -124,24 +131,9 @@ function IsaacScriptWatcher:RenderText()
|
|
|
124
131
|
return
|
|
125
132
|
end
|
|
126
133
|
|
|
127
|
-
local white = KColor(1, 1, 1, alpha)
|
|
128
|
-
local red = KColor(1, 0, 0, alpha)
|
|
129
|
-
local green = KColor(0, 1, 0, alpha)
|
|
130
|
-
|
|
131
134
|
-- Go through each message.
|
|
132
135
|
for i, msg in ipairs(messageArray) do
|
|
133
|
-
local color =
|
|
134
|
-
|
|
135
|
-
local hasSuccess = string.match(msg, "Compilation successful.")
|
|
136
|
-
if hasSuccess ~= nil then
|
|
137
|
-
color = green
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
local hasErrors = string.match(msg, "Found [0-9]+ errors.")
|
|
141
|
-
if hasErrors ~= nil then
|
|
142
|
-
color = red
|
|
143
|
-
end
|
|
144
|
-
|
|
136
|
+
local color = mod:GetColorForMsg(msg, alpha)
|
|
145
137
|
font:DrawStringScaledUTF8(
|
|
146
138
|
msg,
|
|
147
139
|
x,
|
|
@@ -155,7 +147,25 @@ function IsaacScriptWatcher:RenderText()
|
|
|
155
147
|
end
|
|
156
148
|
end
|
|
157
149
|
|
|
158
|
-
function
|
|
150
|
+
function mod:GetColorForMsg(msg, alpha)
|
|
151
|
+
local white = KColor(1, 1, 1, alpha)
|
|
152
|
+
local red = KColor(1, 0, 0, alpha)
|
|
153
|
+
local green = KColor(0, 1, 0, alpha)
|
|
154
|
+
|
|
155
|
+
local hasSuccess = string.match(msg, "Compilation successful.")
|
|
156
|
+
if hasSuccess ~= nil then
|
|
157
|
+
return green
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
local hasErrors = string.match(msg, "Found [0-9]+ errors.")
|
|
161
|
+
if hasErrors ~= nil then
|
|
162
|
+
return red
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
return white
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
function mod:LoadSaveDat()
|
|
159
169
|
-- Local variables
|
|
160
170
|
local isaacFrameCount = Isaac.GetFrameCount()
|
|
161
171
|
|
|
@@ -165,13 +175,13 @@ function IsaacScriptWatcher:LoadSaveDat()
|
|
|
165
175
|
end
|
|
166
176
|
|
|
167
177
|
-- Check to see if there a "save.dat" file for this save slot.
|
|
168
|
-
if not Isaac.HasModData(
|
|
169
|
-
|
|
178
|
+
if not Isaac.HasModData(mod) then
|
|
179
|
+
mod:ClearSaveDat()
|
|
170
180
|
return
|
|
171
181
|
end
|
|
172
182
|
|
|
173
183
|
-- The server will write JSON data for us to the "save#.dat" file in the mod subdirectory.
|
|
174
|
-
if not pcall(
|
|
184
|
+
if not pcall(mod.Load) then
|
|
175
185
|
-- Sometimes loading can fail if the file is currently being being written to, so give up for
|
|
176
186
|
-- now and try again on the next interval.
|
|
177
187
|
Isaac.DebugString(
|
|
@@ -184,12 +194,12 @@ function IsaacScriptWatcher:LoadSaveDat()
|
|
|
184
194
|
|
|
185
195
|
if #saveData > 0 then
|
|
186
196
|
local saveDatContents = saveData
|
|
187
|
-
|
|
188
|
-
|
|
197
|
+
mod:ClearSaveDat()
|
|
198
|
+
mod:LoadSuccessful(saveDatContents)
|
|
189
199
|
end
|
|
190
200
|
end
|
|
191
201
|
|
|
192
|
-
function
|
|
202
|
+
function mod:LoadSuccessful(saveDatContents)
|
|
193
203
|
frameOfLastSuccessfulLoad = Isaac.GetFrameCount()
|
|
194
204
|
|
|
195
205
|
for _, entry in ipairs(saveDatContents) do
|
|
@@ -205,23 +215,35 @@ function IsaacScriptWatcher:LoadSuccessful(saveDatContents)
|
|
|
205
215
|
elseif entry.type == "msg" then
|
|
206
216
|
Isaac.DebugString(MOD_NAME .. " - " .. entry.data)
|
|
207
217
|
pushMessageArray(entry.data)
|
|
218
|
+
|
|
219
|
+
if sprite ~= nil then
|
|
220
|
+
local starting1 = string.match(entry.data, "TypeScript change detected.")
|
|
221
|
+
local starting2 = string.match(entry.data, "Compiling the mod for the first time...")
|
|
222
|
+
local finished1 = string.match(entry.data, "Compilation successful.")
|
|
223
|
+
local finished2 = string.match(entry.data, "Found [0-9]+ errors.")
|
|
224
|
+
if starting1 ~= nil or starting2 ~= nil then
|
|
225
|
+
sprite:Play("Green")
|
|
226
|
+
elseif finished1 ~= nil or finished2 ~= nil then
|
|
227
|
+
sprite:Play("Default")
|
|
228
|
+
end
|
|
229
|
+
end
|
|
208
230
|
end
|
|
209
231
|
end
|
|
210
232
|
end
|
|
211
233
|
|
|
212
|
-
function
|
|
234
|
+
function mod:ClearSaveDat()
|
|
213
235
|
saveData = {}
|
|
214
|
-
|
|
236
|
+
mod:Save()
|
|
215
237
|
end
|
|
216
238
|
|
|
217
|
-
function
|
|
239
|
+
function mod:Save()
|
|
218
240
|
local saveDataJSON = json.encode(saveData)
|
|
219
|
-
|
|
241
|
+
mod:SaveData(saveDataJSON)
|
|
220
242
|
end
|
|
221
243
|
|
|
222
|
-
function
|
|
244
|
+
function mod:Load()
|
|
223
245
|
-- Read the "save#.dat" file into a string.
|
|
224
|
-
local saveDataJSON = Isaac.LoadModData(
|
|
246
|
+
local saveDataJSON = Isaac.LoadModData(mod)
|
|
225
247
|
|
|
226
248
|
-- Handle the case of a 0 byte file.
|
|
227
249
|
if saveDataJSON == "" then
|
|
@@ -232,7 +254,7 @@ function IsaacScriptWatcher:Load()
|
|
|
232
254
|
saveData = json.decode(saveDataJSON)
|
|
233
255
|
end
|
|
234
256
|
|
|
235
|
-
function
|
|
257
|
+
function mod:CheckInput()
|
|
236
258
|
if game:IsPaused() then
|
|
237
259
|
return
|
|
238
260
|
end
|
|
@@ -249,7 +271,7 @@ function IsaacScriptWatcher:CheckInput()
|
|
|
249
271
|
end
|
|
250
272
|
end
|
|
251
273
|
|
|
252
|
-
function
|
|
274
|
+
function mod:CheckRestart()
|
|
253
275
|
if not RESTART_GAME_ON_RECOMPILATION then
|
|
254
276
|
return
|
|
255
277
|
end
|
|
@@ -263,7 +285,7 @@ function IsaacScriptWatcher:CheckRestart()
|
|
|
263
285
|
Isaac.ExecuteCommand("restart")
|
|
264
286
|
end
|
|
265
287
|
|
|
266
|
-
|
|
288
|
+
mod:AddCallback(ModCallbacks.MC_POST_RENDER, mod.PostRender)
|
|
267
289
|
|
|
268
290
|
local initMessage = "IsaacScript Watcher initialized."
|
|
269
291
|
Isaac.DebugString(initMessage)
|
|
Binary file
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
<AnimatedActor>
|
|
2
|
-
<Info CreatedBy="Unknown" CreatedOn="
|
|
2
|
+
<Info CreatedBy="Unknown" CreatedOn="6/26/2022 2:14:32 PM" Version="3" Fps="30"/>
|
|
3
3
|
<Content>
|
|
4
4
|
<Spritesheets>
|
|
5
5
|
<Spritesheet Path="logo.png" Id="0"/>
|
|
6
|
+
<Spritesheet Path="logo-green.png" Id="1"/>
|
|
6
7
|
</Spritesheets>
|
|
7
8
|
<Layers>
|
|
8
9
|
<Layer Name="Layer 0" Id="0" SpritesheetId="0"/>
|
|
10
|
+
<Layer Name="Layer 1" Id="1" SpritesheetId="1"/>
|
|
9
11
|
</Layers>
|
|
10
12
|
<Nulls/>
|
|
11
13
|
<Events/>
|
|
@@ -19,6 +21,20 @@
|
|
|
19
21
|
<LayerAnimation LayerId="0" Visible="true">
|
|
20
22
|
<Frame XPosition="0" YPosition="0" XPivot="0" YPivot="0" XCrop="0" YCrop="0" Width="44" Height="28" XScale="66" YScale="66" Delay="1" Visible="true" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="false"/>
|
|
21
23
|
</LayerAnimation>
|
|
24
|
+
<LayerAnimation LayerId="1" Visible="false"/>
|
|
25
|
+
</LayerAnimations>
|
|
26
|
+
<NullAnimations/>
|
|
27
|
+
<Triggers/>
|
|
28
|
+
</Animation>
|
|
29
|
+
<Animation Name="Green" FrameNum="1" Loop="true">
|
|
30
|
+
<RootAnimation>
|
|
31
|
+
<Frame XPosition="0" YPosition="0" XScale="100" YScale="100" Delay="1" Visible="true" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="false"/>
|
|
32
|
+
</RootAnimation>
|
|
33
|
+
<LayerAnimations>
|
|
34
|
+
<LayerAnimation LayerId="0" Visible="false"/>
|
|
35
|
+
<LayerAnimation LayerId="1" Visible="true">
|
|
36
|
+
<Frame XPosition="0" YPosition="0" XPivot="0" YPivot="0" XCrop="0" YCrop="0" Width="44" Height="28" XScale="66" YScale="66" Delay="1" Visible="true" RedTint="255" GreenTint="255" BlueTint="255" AlphaTint="255" RedOffset="0" GreenOffset="0" BlueOffset="0" Rotation="0" Interpolated="false"/>
|
|
37
|
+
</LayerAnimation>
|
|
22
38
|
</LayerAnimations>
|
|
23
39
|
<NullAnimations/>
|
|
24
40
|
<Triggers/>
|