Skip to content

Commit 067e175

Browse files
committed
Add spawner option: spawn only on screen
1 parent 247878e commit 067e175

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

enemytool.lua

+8-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ function enemytool:init(x, y, r, e)
88
self.r = r
99
self.customenemy = true
1010
self.animation = false
11+
self.spawnonlyonscreen = false
1112
if e:find("|") then
12-
local v = convertr(e, {"string", "num", "num", "bool", "string"}, true)
13+
local v = convertr(e, {"string", "num", "num", "bool", "string", "bool"}, true)
1314
self.enemy = v[1]
1415
self.xvel = v[2]
1516
self.yvel = v[3]
@@ -26,6 +27,9 @@ function enemytool:init(x, y, r, e)
2627
if v[5] and v[5] ~= "none" then
2728
self.animation = v[5]
2829
end
30+
if v[6] ~= nil then
31+
self.spawnonlyonscreen = v[6]
32+
end
2933
else
3034
self.enemy = e or "goomba"
3135
self.legacy = true
@@ -144,6 +148,9 @@ function enemytool:spawn()
144148
if i == nil then
145149
return false
146150
end
151+
if self.spawnonlyonscreen and not onscreen(self.x-2, self.y-2, 4, 4) then
152+
return false
153+
end
147154

148155
--backwards compatibility fuck
149156
if (not self.customenemy) and self.legacy then

entity.lua

+3-2
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ rightclicktype["tiletool"] = {
11101110
}
11111111
rightclicktype["enemytool"] = {
11121112
name = "spawner",
1113-
default = "goomba|0|0|false|none",
1113+
default = "goomba|0|0|false|none|false",
11141114
ignoredefault = {false,false,false,"missing",false},
11151115
varfunc = function(v, i)
11161116
if i == 1 then
@@ -1174,7 +1174,8 @@ rightclicktype["enemytool"] = {
11741174
{"slider", 3, range = {-50, 50, round = 1}},
11751175
"animation",
11761176
{"dropdown", 5, 14, nil, {"none", "block", "cannon", "pipeup", "pipedown", "pipeleft", "piperight", "poof"}, ignorerctt=true},
1177-
{"button", 2, {"link trigger ", startrclink}, {"x", resetrclink, textcolor = {255, 0, 0}}}
1177+
{"checkbox", 6, "only on screen"},
1178+
{"button", 2, {"link trigger ", startrclink}, {"x", resetrclink, textcolor = {255, 0, 0}}},
11781179
},
11791180
t = {"goomba"},
11801181
entitylistlength = 1,

0 commit comments

Comments
 (0)