the code:
local function apply(src,dst)
for k,v in pairs(src) do
if(v=="setnil") then
dst[k]=nil;
else
dst[k]=v;
end
end
end
local function register(inobj)
data:extend{inobj}
end
--actual code:
if(1==1) then
local barrel=table.deepcopy(data.raw.item["empty-barrel"]);
local barrel_setting=
{
type="capsule",
capsule_action=
{
type="throw",uses_stack=false,
attack_parameters=
{
type="beam",range=5,cooldown=(60/10),
activation_type="activate",
ammo_type=
{
category="capsule",
target_type="position",
action={type="direct",action_delivery={type="instant",target_effects={
{type="script",effect_id="using_barrel"},
},},},
},
},
},
};
apply(barrel_setting,barrel);
data.raw.item["empty-barrel"]=nil;
register(barrel);
end
the log:
Error while running event ingteb::on_gui_click (ID 1)
__ingteb__/ingteb/Database.lua:31: attempt to index local 'data' (a nil value)
stack traceback:
__ingteb__/ingteb/Database.lua:31: in function 'EnsureKey'
__ingteb__/ingteb/Database.lua:359: in function 'AddRecipe'
__ingteb__/ingteb/Database.lua:493: in function 'ScanFuel'
__ingteb__/ingteb/Database.lua:513: in function 'ScanItem'
__ingteb__/ingteb/Database.lua:149: in function 'ScanBackLinks'
__ingteb__/ingteb/Database.lua:196: in function 'Ensure'
__ingteb__/ingteb/EventManager.lua:40: in function <__ingteb__/ingteb/EventManager.lua:38>
(...tail calls...)
__ingteb__/core/classclass.lua:58: in function '__index'
__ingteb__/ingteb/Selector.lua:213: in function 'GetAllItemsGui'
__ingteb__/ingteb/Selector.lua:119: in function 'GetGuiInnerVariant'
__ingteb__/ingteb/Selector.lua:101: in function 'GetGui'
__ingteb__/ingteb/Selector.lua:36: in function 'Open'
__ingteb__/ingteb/EventManager.lua:113: in function 'ToggleFloating'
__ingteb__/ingteb/Gui.lua:39: in function 'OnGuiEvent'
__ingteb__/ingteb/EventManager.lua:378: in function <__ingteb__/ingteb/EventManager.lua:370>