Skip to content

Commit 30f57f3

Browse files
committed
Fix warnings
1 parent 9e65c9d commit 30f57f3

9 files changed

Lines changed: 41 additions & 33 deletions

File tree

ScriptHawk.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2267,7 +2267,7 @@ function ScriptHawk.drawHitboxes()
22672267
end
22682268
end
22692269

2270-
local renderedText = nil;
2270+
local renderedText;
22712271
local isStaticText = false;
22722272
if mouseIsOnScreen and (mouse.X >= x1 and mouse.X <= x2) and (mouse.Y >= y1 and mouse.Y <= y2) then
22732273
if hitbox.draggable and startDrag then

Tetris Attack Bot.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ local function pickRandomMove(player)
334334
rightMoveable = isMoveable(x + 1, y, player);
335335

336336
timeout = timeout + 1;
337-
until (currentColumnHeight == maxColumnHeight or math.random(1,2) == 1) and (leftMoveable and rightMoveable and (left ~= 0x00 or right ~= 0x00) and left ~= right) or timeout > 100;
337+
until (currentColumnHeight == maxColumnHeight or math.random(1, 2) == 1) and (leftMoveable and rightMoveable and (left ~= 0x00 or right ~= 0x00) and left ~= right) or timeout > 100;
338338

339339
if timeout <= 100 then
340340
moveQueue[player] = {};

games/bk.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,14 +2479,14 @@ local vileMap = {
24792479
{ 20, 19, 17, 13, 12 },
24802480
{ 9, 18, 11, 4 },
24812481
{ 10, 7, 8, 2, 1 },
2482-
{ 6, 5, 3, 0 }
2482+
{ 6, 5, 3, 0 },
24832483
};
24842484

24852485
local heart = {
24862486
{2, 2}, {2, 3},
24872487
{3, 2}, {3, 3}, {3, 4},
24882488
{4, 2}, {4, 3},
2489-
{5, 3}
2489+
{5, 3},
24902490
};
24912491

24922492
local waveFrames = {
@@ -2498,7 +2498,7 @@ local waveFrames = {
24982498
{ {2, 3}, {4, 3}, {6, 3} },
24992499
{ {1, 3}, {3, 4}, {5, 4} },
25002500
{ {2, 4}, {4, 4}, {6, 4} },
2501-
{ {3, 5}, {5, 5} }
2501+
{ {3, 5}, {5, 5} },
25022502
};
25032503

25042504
function getSlotIndex(row, col)

games/dk64.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8406,7 +8406,7 @@ function Game.setKrushaColors()
84068406
texturePointer = getNextTextureRenderer(texturePointer); -- Skip Eyes
84078407

84088408
-- 2 Body
8409-
mainmemory.write_u16_be(texturePointer + obj_model1.texture_renderer.texture_index, TinyBodyColors[math.random(1, #TinyBodyColors)][2]);
8409+
mainmemory.write_u16_be(texturePointer + obj_model1.texture_renderer.texture_index, KrushaColors[math.random(1, #KrushaColors)][2]);
84108410
end
84118411
end
84128412
end
@@ -9996,7 +9996,7 @@ function buildIdentifyMemoryCache()
99969996
addHeapMetadata(collisionLinkedListPointer, "addressType", 4);
99979997
for i = 0, collisionListObjectSize - 4, 4 do
99989998
local object = dereferencePointer(collisionLinkedListPointer + i);
9999-
local safety = nil;
9999+
local safety;
1000010000
while isRDRAM(object) do
1000110001
local kong = mainmemory.read_u16_be(object + 0x04);
1000210002
local collisionType = mainmemory.read_u16_be(object + 0x02);

games/dkr.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ function adjustVelMax(value, bananas)
743743
velocity_max[bananas] = math.min(velocity_max[bananas], velocity_med[bananas]); -- Clamp to velocity_med
744744
end
745745

746-
function dumpVelocityValues()
746+
function dumpVelocityValues(bananas)
747747
return "min: "..round(velocity_min[bananas], 3).." med: "..round(velocity_med[bananas], 3).." max: "..round(velocity_max[bananas], 3);
748748
end
749749

@@ -1093,7 +1093,7 @@ function Game.eachFrame()
10931093
if zPos >= -3800 then
10941094
local character = Game.getCharacter();
10951095
local bananas = math.max(math.min(Game.getBananas(), 10), 0);
1096-
print("frame "..emu.framecount().." pos "..round(zPos, 3).." vel "..round(velocity, 3).." || "..dumpVelocityValues());
1096+
print("frame "..emu.framecount().." pos "..round(zPos, 3).." vel "..round(velocity, 3).." || "..dumpVelocityValues(bananas));
10971097
adjustVelMin(testSpace.min, bananas);
10981098
adjustVelMed(testSpace.med, bananas);
10991099
adjustVelMax(testSpace.max, bananas);

games/ej3d.lua

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,10 @@ function checkFlagArray()
10971097
if flag_Array[1] ~= nil then -- flag array populated
10981098
for i = 1, flag_block_size do
10991099
local currentFlagState = mainmemory.readbyte(flag_start + i);
1100-
local flag_name = flagBlock[i].name or "Unknown ("..toHexString(i)..")";
1100+
local flag_name = "Unknown ("..toHexString(i)..")";
1101+
if flagBlock[i] ~= nil then
1102+
flag_name = flagBlock[i].name;
1103+
end
11011104
if flag_Array[i] ~= currentFlagState then -- Flag has changed states
11021105
if currentFlagState == 1 then
11031106
print("'"..flag_name.."' has been SET on frame "..currentFrame);
@@ -1126,7 +1129,10 @@ function setFlag(offset)
11261129
local flag_start = dereferencePointer(Game.Memory.flag_pointer);
11271130
if isRDRAM(flag_start) then
11281131
mainmemory.writebyte(flag_start + offset, 1);
1129-
local flag_name = flagBlock[offset].name or "Unknown ("..toHexString(offset)..")";
1132+
local flag_name = "Unknown ("..toHexString(offset)..")";
1133+
if flagBlock[offset] ~= nil then
1134+
flag_name = flagBlock[offset].name;
1135+
end
11301136
print("Set flag '"..flag_name.."'");
11311137
end
11321138
end
@@ -1135,7 +1141,10 @@ function clearFlag(offset)
11351141
local flag_start = dereferencePointer(Game.Memory.flag_pointer);
11361142
if isRDRAM(flag_start) then
11371143
mainmemory.writebyte(flag_start + offset, 0);
1138-
local flag_name = flagBlock[offset].name or "Unknown ("..toHexString(offset)..")";
1144+
local flag_name = "Unknown ("..toHexString(offset)..")";
1145+
if flagBlock[offset] ~= nil then
1146+
flag_name = flagBlock[offset].name;
1147+
end
11391148
print("Cleared flag '"..flag_name.."'");
11401149
end
11411150
end

games/sm64.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ function Game.drawUI()
271271
end
272272
end
273273

274-
function incrementObjectIndex()
274+
local function incrementObjectIndex()
275275
if ScriptHawk.UI.ischecked("Enable Object Analyzer") then
276276
objectIndex = objectIndex + 1;
277277
if objectIndex >= numObjects then
@@ -280,7 +280,7 @@ function incrementObjectIndex()
280280
end
281281
end
282282

283-
function decrementObjectIndex()
283+
local function decrementObjectIndex()
284284
if ScriptHawk.UI.ischecked("Enable Object Analyzer") then
285285
objectIndex = objectIndex - 1;
286286
if objectIndex < 0 then

games/smash64.lua

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ local player_fields = {
200200
InvinvibilityState = 0x5AC, -- u16_be
201201
hurtbox_lower_Stomach = 0x5BC,
202202
hurtbox_head = 0x5E8,
203-
hurtbox_upper_right_arm = 0x614,
204-
hurtbox_upper_right_arm = 0x640,
203+
hurtbox_upper_right_arm = 0x614, -- TODO: Which one is correct?
204+
hurtbox_upper_right_arm = 0x640, -- TODO: Which one is correct?
205205
hurtbox_upper_left_arm = 0x66C,
206206
hurtbox_lower_right_arm = 0x698,
207207
hurtbox_lower_left_arm = 0x6C4,
@@ -263,7 +263,7 @@ local player_fields = {
263263
ShowHitbox = 0xB4C, -- u32_be
264264
};
265265

266-
movement_states = {
266+
local movement_states = {
267267
[0x00] = "Dying (Down)", [0x01] = "Dying (Side)", [0x02] = "Dying (Up far)", [0x03] = "Dying (Up near)", [0x05] = "Appearing",
268268
[0x07] = "Reviving", [0x08] = "Spawning", [0x09] = "Standing on Spawning Platform",
269269
[0x0A] = "Standing", [0x0B] = "Walking slowly", [0x0C] = "Walking", [0x0D] = "Walking quickly",
@@ -335,7 +335,7 @@ movement_states = {
335335
[0xDA] = "Miss Landing hardly", [0xDB] = "Miss Landing softly",
336336
};
337337

338-
character_states = {
338+
local character_states = {
339339
[0x00] = { -- Mario
340340
[0xDC] = "Jab 3",
341341
[0xDE] = "Appearing",
@@ -765,8 +765,7 @@ function Game.getBoomerang(player)
765765
end
766766

767767
function Game.getBoomerangOSD(player)
768-
local projectileObject = nil;
769-
local projectileObject2 = nil;
768+
local projectileObject, projectileObject2;
770769
local positionObject = nil;
771770
local timer1 = 0;
772771
local timer2 = 0;
@@ -786,7 +785,7 @@ function Game.getBoomerangOSD(player)
786785
return toHexString(positionObject).." ("..timer1..", "..timer2..")";
787786
end
788787

789-
boomerangState = {
788+
local boomerangState = {
790789
{ prev_position = {x = 0, y = 0}, d = {x = 0, y = 0} },
791790
{ prev_position = {x = 0, y = 0}, d = {x = 0, y = 0} },
792791
{ prev_position = {x = 0, y = 0}, d = {x = 0, y = 0} },

lib/Stats.lua

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function stats.mean(t)
1414
local sum = 0;
1515
local count = 0;
1616

17-
for k,v in pairs(t) do
17+
for k, v in pairs(t) do
1818
if type(v) == 'number' then
1919
sum = sum + v;
2020
count = count + 1;
@@ -27,7 +27,7 @@ end
2727
-- Get the mode of a table. Returns a table of values.
2828
-- Works on anything (not just numbers).
2929
function stats.mode(t)
30-
local counts={};
30+
local counts = {};
3131

3232
for k, v in pairs(t) do
3333
if counts[v] == nil then
@@ -45,9 +45,9 @@ function stats.mode(t)
4545
end
4646
end
4747

48-
local temp={};
48+
local temp = {};
4949

50-
for k,v in pairs(counts) do
50+
for k, v in pairs(counts) do
5151
if v == biggestCount then
5252
table.insert(temp, k);
5353
end
@@ -58,11 +58,11 @@ end
5858

5959
-- Get the median of a table.
6060
function stats.median(t)
61-
local temp={};
61+
local temp = {};
6262

6363
-- deep copy table so that when we sort it, the original is unchanged
6464
-- also weed out any non numbers
65-
for k,v in pairs(t) do
65+
for k, v in pairs(t) do
6666
if type(v) == 'number' then
6767
table.insert(temp, v);
6868
end
@@ -73,10 +73,10 @@ function stats.median(t)
7373
-- If we have an even number of table elements or odd.
7474
if math.fmod(#temp,2) == 0 then
7575
-- return mean value of middle two elements
76-
return (temp[#temp/2] + temp[(#temp/2)+1]) / 2;
76+
return (temp[#temp / 2] + temp[(#temp / 2) + 1]) / 2;
7777
else
7878
-- return middle element
79-
return temp[math.ceil(#temp/2)];
79+
return temp[math.ceil(#temp / 2)];
8080
end
8181
end
8282

@@ -98,7 +98,7 @@ function stats.standardDeviation(t)
9898
end
9999
end
100100

101-
result = math.sqrt(sum / (count-1));
101+
result = math.sqrt(sum / (count - 1));
102102

103103
return result;
104104
end
@@ -108,10 +108,10 @@ function stats.maxmin(t)
108108
local max = -math.huge;
109109
local min = math.huge;
110110

111-
for k,v in pairs( t ) do
111+
for k, v in pairs(t) do
112112
if type(v) == 'number' then
113-
max = math.max(max, v)
114-
min = math.min(min, v)
113+
max = math.max(max, v);
114+
min = math.min(min, v);
115115
end
116116
end
117117

0 commit comments

Comments
 (0)