Better-Q

by Skorpa

Better-Q is a simple Mod that layers additional functionality over the in-game Pipette ('Q') function.

Tweaks
3 years ago
0.17 - 0.18
10

b Crash when q-ing on an entity that doesn't have a recipe

3 years ago

Hey Skorpa,

First of all, thank you so much for this mod! I wouldn't know how to play my messily-modded game without it.

I'm using LTN, and the ltn train stop consists of three entities: The actual train stop, a constant combinator and a lamp. The combinator and lamp provide the circuit interface to LTN, and they are automatically placed when putting down the stop. Q-ing on the stop does everything right, but when I q on the combinator or the lamp, I get the following error:

The mod Better-Q (0.1.2) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event Better-Q::on_player_pipette (ID 93)
Better-Q/control.lua:29: attempt to index local 'recipe' (a nil value)
stack traceback:
Better-Q/control.lua:29: in function <Better-Q/control.lua:10>

I fixed it by adding this before the "if target ~= nil" block:

if recipe == nil then
player.print("Better-Q failed: The target has no recipe")
return
end

Programmer nerdery: I prefer these blocks that do early returns to nesting if expressions, but you're obviously free to implement this however you think is best <3

New response