Skip to content

Commit 8f87c74

Browse files
authored
Add files via upload
1 parent 26260c2 commit 8f87c74

File tree

13 files changed

+240
-27
lines changed

13 files changed

+240
-27
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
Quite possibly the jankest Factorio mod ever made
44

55
but at least the memes are good
6+
7+
8+
Features include Thrower Inserters that YEET items through the air, and Bounce Pads that can make those items fly further through chained bounces. The Player Launcher lets you do the same with your character.

changelog.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
---------------------------------------------------------------------------------------------------
2+
Version: 0.8.1
3+
Date: 5/29/2021
4+
Bugfixes:
5+
- Fixed crash from saves that had the old overflow prevention transitioning to the new one
6+
---------------------------------------------------------------------------------------------------
7+
Version: 0.8.0
8+
Date: 5/29/2021
9+
Changes:
10+
- Updated overflow prevention code. Throwers will now freeze if it detects that the item won't fit in to the destination inventory taking into account items in the air and items bouncing through bounce pads. Of note, throwing onto a curved belt is still a bit off, but throwing onto straight belts work quite well.
11+
---------------------------------------------------------------------------------------------------
212
Version: 0.7.7
313
Date: 5/3/2021
414
Bugfixes:

control.lua

Lines changed: 96 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
if script.active_mods["gvv"] then require("__gvv__.gvv")() end
12
-- Setup tables and stuff for new/existing saves ----
23
script.on_init(
34
require("script.event.init")
@@ -112,13 +113,59 @@ function(event)
112113

113114
if (catapult.valid and catapult.held_stack.valid_for_read) then
114115
if (settings.global["RTOverflowComp"].value == true) then
115-
if (properties.target and properties.target.valid and properties.target ~= "nothing" and properties.target.type == "transport-belt" and (properties.target.get_transport_line(1).can_insert_at_back() == false and properties.target.get_transport_line(2).can_insert_at_back() == false)) then
116-
catapult.active = false
117-
elseif (properties.target and properties.target.valid and properties.target ~= "nothing" and properties.target.can_insert(catapult.held_stack) == false) then
118-
catapult.active = false
119-
else
116+
if (properties.target ~= "nothing" and properties.target.valid and global.ThrowerTargets[properties.target.unit_number]) then
117+
if (properties.target.type ~= "transport-belt") then
118+
local InAir = {}
119+
for name, count in pairs(global.ThrowerTargets[properties.target.unit_number].OnTheWay) do
120+
local total = count
121+
if (name == catapult.held_stack.name) then
122+
total = count + catapult.held_stack.count
123+
end
124+
local inserted = nil
125+
if (total > 0) then
126+
inserted = properties.target.insert({name=name, count=total})
127+
InAir[name] = inserted
128+
end
129+
if (total > 0 and inserted < total) then
130+
for namee, countt in pairs(InAir) do
131+
if (countt > 0) then
132+
properties.target.remove_item({name=namee, count=countt})
133+
end
134+
end
135+
catapult.active = false
136+
InAir = {}
137+
break
138+
elseif (InAir == {}) then
139+
catapult.active = true
140+
else
141+
catapult.active = true
142+
end
143+
end
144+
for namee, countt in pairs(InAir) do
145+
properties.target.remove_item({name=namee, count=countt})
146+
end
147+
148+
elseif (properties.target.type == "transport-belt"
149+
and (properties.target.get_transport_line(1).can_insert_at_back() == true
150+
or properties.target.get_transport_line(2).can_insert_at_back() == true)
151+
) then
152+
local InAir = 0
153+
for name, count in pairs(global.ThrowerTargets[properties.target.unit_number].OnTheWay) do
154+
InAir = InAir + count
155+
end
156+
local total = InAir + properties.target.get_transport_line(1).get_item_count() + properties.target.get_transport_line(2).get_item_count()
157+
if (total <= 6) then
158+
catapult.active = true
159+
else
160+
catapult.active = false
161+
end
162+
end
163+
164+
elseif (properties.target == "nothing") then
120165
catapult.active = true
121166
end
167+
else
168+
catapult.active = true
122169
end
123170

124171
if (catapult.active == true) then
@@ -135,12 +182,31 @@ function(event)
135182
source_position = catapult.held_stack_position, --launch from
136183
target_position = catapult.drop_position --launch to
137184
})
138-
end) --end of pcall function
185+
end)
139186
) then
140187
catapult.active = false
141188
for ii, player in pairs(game.players) do
142189
player.print("Invalid throwable item "..catapult.held_stack.name.." at "..catapult.held_stack_position.x..","..catapult.held_stack_position.x..". Thrower halted. Please report the item to the mod portal form.")
143190
end
191+
192+
elseif (settings.global["RTOverflowComp"].value == true and properties.target ~= "nothing" and properties.target.valid) then
193+
local unused = 1
194+
while (global.ThrownItems[unused] ~= nil) do
195+
unused = unused + 1
196+
end
197+
198+
global.ThrownItems[unused] = {
199+
from = catapult.held_stack_position,
200+
to = catapult.drop_position,
201+
destination = properties.target.unit_number,
202+
item = catapult.held_stack.name}
203+
204+
if (global.ThrowerTargets[properties.target.unit_number].OnTheWay[catapult.held_stack.name] == nil) then
205+
global.ThrowerTargets[properties.target.unit_number].OnTheWay[catapult.held_stack.name] = 1
206+
else
207+
global.ThrowerTargets[properties.target.unit_number].OnTheWay[catapult.held_stack.name] = global.ThrowerTargets[properties.target.unit_number].OnTheWay[catapult.held_stack.name] + 1
208+
end
209+
144210
end
145211
end
146212
catapult.held_stack.clear()
@@ -149,6 +215,7 @@ function(event)
149215

150216
elseif (catapult.valid == false) then
151217
global.CatapultList[catapultID] = nil
218+
152219
end
153220
end
154221
end
@@ -158,13 +225,16 @@ script.on_nth_tick(120,
158225
function(event)
159226
if (settings.global["RTOverflowComp"].value == true) then
160227
for catapultID, properties in pairs(global.CatapultList) do
161-
properties.entity.surface.create_entity
162-
({
163-
name = "MaybeIllBeTracer-projectileFromRenaiTransportation",
164-
position = properties.entity.position, --required setting for rendering, doesn't affect spawn
165-
source = properties.entity, --launch from
166-
target_position = properties.entity.drop_position --launch to
167-
})
228+
if (properties.ImAlreadyTracer == nil or properties.ImAlreadyTracer == "traced") then
229+
properties.ImAlreadyTracer = "tracing"
230+
properties.entity.surface.create_entity
231+
({
232+
name = "MaybeIllBeTracer-projectileFromRenaiTransportation",
233+
position = properties.entity.position, --required setting for rendering, doesn't affect spawn
234+
source = properties.entity, --launch from
235+
target_position = properties.entity.drop_position --launch to
236+
})
237+
end
168238
end
169239
else
170240
--dont
@@ -213,9 +283,18 @@ script.on_event(defines.events.on_player_changed_surface,
213283
-- .surface_index :: uint: The surface index the player was on
214284
function(event)
215285
local player = game.players[event.player_index]
216-
if (global.AllPlayers[event.player_index] and global.AllPlayers[event.player_index].sliding and global.AllPlayers[event.player_index].sliding == true and player.surface.name ~= global.AllPlayers[event.player_index].StartingSurface.name) then
217-
player.teleport(player.position, game.get_surface(event.surface_index))
218-
219-
end
286+
if (global.AllPlayers[event.player_index] and global.AllPlayers[event.player_index].sliding and global.AllPlayers[event.player_index].sliding == true and player.surface.name ~= global.AllPlayers[event.player_index].StartingSurface.name) then
287+
player.teleport(player.position, game.get_surface(event.surface_index))
288+
end
289+
end)
220290

291+
script.on_event(defines.events.on_runtime_mod_setting_changed,
292+
-- player_index :: uint (optional): The player who changed the setting or nil if changed by script.
293+
-- setting :: string: The setting name that changed.
294+
-- setting_type :: string: The setting type: "runtime-per-user", or "runtime-global".
295+
function(event)
296+
if (event.setting == "RTOverflowComp" and settings.global["RTOverflowComp"].value == false) then
297+
global.ThrowerTargets = {}
298+
global.ThrownItems = {}
299+
end
221300
end)

info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "RenaiTransportation",
3-
"version": "0.7.7",
3+
"version": "0.8.1",
44
"title": "Renai Transportation",
55
"author": "Kiplacon",
66
"factorio_version": "1.1",

locale/en/config.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ RTTrainBounceSetting=Enable Train Bounce Pads (Requires Train Ramps)
115115
RTZiplineSetting=Enable Electric Ziplines
116116
RTZiplineSmoothSetting=Zipline Motion
117117
RTModdedThrowers=Enable modded thrower varients (Requires base throwers to be enabled)
118-
RTOverflowComp=Thrower Overflow Prevention [Experimental]
118+
RTOverflowComp=Thrower Overflow Prevention v2 [WIP]
119119

120120

121121
[mod-setting-description]
122122
RTBounceSetting=Circuit Bounce Pad and Primer Bounce Pad
123123
RTZiplineSmoothSetting=At faster speeds with poles closer together, the bobbing camera motion might be dizzying for some people.
124124
RTModdedThrowers=Enables thrower varients of modded inserters, otherwise only vanilla inserter throwers are made.
125-
RTOverflowComp=Toggles on or off the logic that helps minimize overflow from throwers spilling items all over the place. Disabling probably saves UPS
125+
RTOverflowComp=Toggles on or off the logic that helps minimize overflow from throwers spilling items all over the place. Disabling probably saves a bit of UPS
126126
RTThrowersSetting=Enables the base features of thrower inserters, bounce pads, player launchers, and hatches. Required to be on for modded throwers to be created.

prototypes/TrainGoBrrrr/PropHunt.lua

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,45 @@ MLG.track_particle_triggers = nil
3333
data:extend({
3434

3535
MLG,
36+
{
37+
type = "car",
38+
name = "RTPropCart",
39+
collision_mask = {},
40+
selectable_in_game = false,
41+
corpse = nil,
42+
weight = 1,
43+
braking_power = "1J",
44+
energy_per_hit_point = 99999,
45+
effectivity = 69,
46+
inventory_size = 0,
47+
consumption = "1J",
48+
rotation_speed = 0,
49+
has_belt_immunity = true,
50+
energy_source ={type = "void"},
51+
working_sound =
52+
{
53+
sound =
54+
{
55+
filename = "__base__/sound/train-engine.ogg",
56+
volume = 0.35
57+
},
58+
match_volume_to_activity = true
59+
},
60+
friction = 1e-98,
3661

62+
animation =
63+
{
64+
filename = "__RenaiTransportation__/graphics/nothing.png",
65+
size = 32,
66+
direction_count = 1
67+
}
68+
},
3769
{ --------- prop item -------------
3870
type = "item",
3971
name = "RTPropCarItem",
4072
icon = "__RenaiTransportation__/graphics/Untitled.png",
4173
icon_size = 32,
74+
flags = {"hidden"},
4275
subgroup = "RT",
4376
order = "c",
4477
place_result = "RTPropCar",

script/event/config_changed.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ local function config_changed()
5858
if (global.About2Jump == nil) then
5959
global.About2Jump = {}
6060
end
61+
62+
if (global.ThrowerTargets == nil) then
63+
global.ThrowerTargets = {}
64+
end
65+
if (global.ThrownItems == nil) then
66+
global.ThrownItems = {}
67+
end
6168
end
6269

6370
return config_changed

script/event/effect_triggered.lua

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,33 @@
1-
local function effect_triggered(event) --has .effect_id, .surface_index, and .source_position, .source_entity, .target_position, and .target_entity depending on how the effect was triggered
1+
local function TrackProjectile(event)
2+
if (settings.global["RTOverflowComp"].value == true) then
3+
for id, stuff in pairs(global.ThrownItems) do
4+
--game.print(string.gsub(event.effect_id, "-LandedRT", ""))
5+
if (math.abs(event.target_position.x - stuff.to.x) < 0.1
6+
and math.abs(event.target_position.y - stuff.to.y) < 0.1
7+
and math.abs(event.source_position.x - stuff.from.x) < 0.1
8+
and math.abs(event.source_position.y - stuff.from.y) < 0.1
9+
and string.gsub(event.effect_id, "-LandedRT", "") == stuff.item) then
10+
if (global.ThrowerTargets[stuff.destination] ~= nil) then
11+
global.ThrowerTargets[stuff.destination].OnTheWay[stuff.item] = global.ThrowerTargets[stuff.destination].OnTheWay[stuff.item] - 1
12+
end
13+
global.ThrownItems[id] = nil
14+
break
15+
end
16+
end
17+
end
18+
end
19+
20+
-- effect_id :: string: The effect_id specified in the trigger effect.
21+
-- surface_index :: uint: The surface the effect happened on.
22+
-- source_position :: Position (optional)
23+
-- source_entity :: LuaEntity (optional)
24+
-- target_position :: Position (optional)
25+
-- target_entity :: LuaEntity (optional)
26+
27+
28+
29+
30+
local function effect_triggered(event)
231

332
---- If it's from this mod ----
433
if (string.find(event.effect_id, "-LandedRT")) then
@@ -82,6 +111,8 @@ local function effect_triggered(event) --has .effect_id, .surface_index, and .so
82111
target_position = {ThingLandedOn.position.x +unitx*(range+RangeBonus) +unity*(SidewaysShift), ThingLandedOn.position.y +unity*(range+RangeBonus) +unitx*(SidewaysShift)},
83112
force = ThingLandedOn.force
84113
})
114+
-- game.print(cheesewheel.unit_number) -- projectiles dont have unit_numbers i guess
115+
85116
if (event.effect_id ~= "MaybeIllBeTracer-LandedRT") then
86117
ThingLandedOn.surface.create_particle
87118
({
@@ -98,6 +129,23 @@ local function effect_triggered(event) --has .effect_id, .surface_index, and .so
98129
position = ThingLandedOn.position,
99130
volume = 0.7
100131
}
132+
if (settings.global["RTOverflowComp"].value == true and event.effect_id ~= "test-LandedRT") then
133+
for id, stuff in pairs(global.ThrownItems) do
134+
if (math.abs(event.target_position.x - stuff.to.x) < 0.1
135+
and math.abs(event.target_position.y - stuff.to.y) < 0.1
136+
and math.abs(event.source_position.x - stuff.from.x) < 0.1
137+
and math.abs(event.source_position.y - stuff.from.y) < 0.1
138+
and string.gsub(event.effect_id, "-LandedRT", "") == stuff.item) then
139+
stuff.from.x = ThingLandedOn.position.x
140+
stuff.from.y = ThingLandedOn.position.y
141+
stuff.to.x = ThingLandedOn.position.x +unitx*(range+RangeBonus) +unity*(SidewaysShift)
142+
stuff.to.y = ThingLandedOn.position.y +unity*(range+RangeBonus) +unitx*(SidewaysShift)
143+
break
144+
end
145+
end
146+
end
147+
else
148+
--global.CatapultList[event.source_entity.unit_number].bounces = global.CatapultList[event.source_entity.unit_number].bounces + 1
101149
end
102150
---- Handling players ----
103151
if (event.effect_id == "test-LandedRT") then
@@ -145,22 +193,37 @@ local function effect_triggered(event) --has .effect_id, .surface_index, and .so
145193
{name=string.gsub(event.effect_id, "-LandedRT", ""), count=1}
146194
)
147195
end
196+
197+
TrackProjectile(event)
148198

149199
elseif (event.effect_id == "MaybeIllBeTracer-LandedRT") then
150-
global.CatapultList[event.source_entity.unit_number].target = ThingLandedOn
200+
if (global.CatapultList[event.source_entity.unit_number]) then
201+
global.CatapultList[event.source_entity.unit_number].target = ThingLandedOn
202+
global.CatapultList[event.source_entity.unit_number].ImAlreadyTracer = "traced"
203+
if (global.ThrowerTargets[ThingLandedOn.unit_number] == nil) then
204+
global.ThrowerTargets[ThingLandedOn.unit_number] = {}
205+
global.ThrowerTargets[ThingLandedOn.unit_number].entity = ThingLandedOn
206+
global.ThrowerTargets[ThingLandedOn.unit_number].OnTheWay = {}
207+
script.register_on_entity_destroyed(ThingLandedOn)
208+
end
209+
end
151210
end
152211

153212
---- If it didnt land on anything but theres a cargo wagon there
154213
elseif (LandedOnCargoWagon ~= nil and LandedOnCargoWagon.can_insert({name=string.gsub(event.effect_id, "-LandedRT", "")})) then
155214
LandedOnCargoWagon.insert({name=string.gsub(event.effect_id, "-LandedRT", ""), count=1})
156-
215+
TrackProjectile(event)
216+
157217
---- if the item/character lands in the water, it's gone ----
158218
elseif (event.effect_id ~= "MaybeIllBeTracer-LandedRT" and game.get_surface(event.surface_index).find_tiles_filtered{position = event.target_position, radius = 1, limit = 1, collision_mask = "player-layer"}[1] ~= nil) then -- in theory, tiles the player cant walk on are some sort of fluid or other non-survivable ground
159219

160220
---- drown the character ----
161221
if (event.effect_id == "test-LandedRT") then
162222
game.get_player(event.source_entity.player.index).character.destructible = true
163223
game.get_player(event.source_entity.player.index).character.die()
224+
else
225+
---- dont drop an item ----
226+
TrackProjectile(event)
164227
end
165228

166229
---- splash ----
@@ -170,7 +233,7 @@ local function effect_triggered(event) --has .effect_id, .surface_index, and .so
170233
position = event.target_position
171234
})
172235

173-
---- dont drop an item ----
236+
174237

175238
---- if thrown thing didn't land on anything and not in water, i don't want characters to do anything upon landing. it would cause an error if it got to the item drop code ----
176239
elseif (event.effect_id == "test-LandedRT") then
@@ -180,8 +243,10 @@ local function effect_triggered(event) --has .effect_id, .surface_index, and .so
180243
else --if it fell on nothing just drop it
181244
if (event.effect_id ~= "MaybeIllBeTracer-LandedRT") then
182245
game.get_surface(event.surface_index).spill_item_stack({event.target_position.x, event.target_position.y}, {name=string.gsub(event.effect_id, "-LandedRT", ""), count=1})
246+
TrackProjectile(event)
183247
else
184248
global.CatapultList[event.source_entity.unit_number].target = "nothing"
249+
global.CatapultList[event.source_entity.unit_number].ImAlreadyTracer = "traced"
185250
end
186251
--[[ random item landing offset
187252
local xoffset = 0.1*math.random(-1,6)

0 commit comments

Comments
 (0)