Schall Primary Battery


Adds non-rechargeable battery equipment, which can be crafted in the early game, and much cheaper than portable solar panel in short-term. Options on enable grid to early armours. Designed for “Schall Recharging Weapon” mod or as backup power to equipment grid. (Locale: English, Deutsch, 正體中文, 简体中文, Português Brasileiro, Русский)

Content
3 years ago
0.17 - 1.1
2.34K
Armor

i on_player_removed_equipment

2 years ago

on_player_removed_equipment returns a value for the equipment being removed, bit it IS the value:
In control.lua:
local function remove_used_battery_equipment(e)
local player = game.players[e.player_index]
-- local eqp = e.equipment -- Always return nil, so not useful
-- local count = e.count
-- if eqp.name:match("^primary%-battery%-equipment") then
player.remove_item{name = "primary-battery-equipment-used", count = 100}
-- end
end

you note here that e.equipment returns nil. The equipment name is actually just the value of e in this function
an easy fix (so you can give us back either the dry battery or the acid battery used) would be something like:
local function remove_used_battery_equipment(e)
local player = game.players[e.player_index]
local eqp = e
local count = e.count
if eqp:match("^primary%-battery%-equipment") then
player.remove_item{name = "primary-battery-equipment-used", count = 100}
-- end
end

Just something I wanted to help with as a big fan of your mods :)

New response