I have problem with a mod i try to make , beacaue everytime when i try to run a function called add_newelementextension i´ll get this error message:"control.lua:23: attempt to index field 'taxiextension' (a nil value)"
here is my code:
Code: Select all
require "util"
require "defines"
script.on_load(function()
if global.taxiextension ==nil then
global.taxiextension={}
end
end)
function add_newelementextension(name)
local taxi
for chunk in game.get_surface(1).get_chunks() do
local entities = game.get_surface(1).find_entities_filtered{backer_name=name, area={{chunk.x*32, chunk.y*32}, {(chunk.x+1)*32, (chunk.y+1)*32}}}
for _, entity in pairs(entities) do
if entity.name == "taxi" then
taxi=entity
end
end
end
if taxi~=nil then
local a={}
for i=0, global.taxiextension.getn, 1 do
if i ~=0 then
a[i]= global.taxiextension[i]
end
end
local t =global.taxiextension.getn + 1
a[t]={key=taxi.backer_name,val ={caller=player,available=true}}
end
end