Page 1 of 1

Trying to update a simple mod.

Posted: Thu Aug 16, 2018 11:29 pm
by TreeGnoll
Hi guy,
I am trying to update my favorite mod from Factorio Ver. 0.10 but I have hit a bit of a snag.
I think the code is right but I keep getting an error when I try to run it.
The game says that I have:

Failed to load mods: __Ztech__/data.lua:48: <eof> expected near 'end'

I am guess that this is an syntax error of some kind. I have 6 ifs for 6 ends so I am wondering if there is something I have missed?

Code: Select all

function modIngredients(ingredients)
    local multipliers = { 1, 2, 4, 8, 16 }
    local total = #ingredients
    for i = 1, total do
        local pack = ingredients[i][1]
	local count = ingredients[i][2]
	if (pack == "science-pack-1")
	then
	    ingredients[i][2] = count*multipliers[total]
	elseif (pack == "science-pack-2")
	then
	    if ((total-1) < 1) then
			--ingredients[i][2] = 1000
	    else
			ingredients[i][2] = count*multipliers[total-1]
	    end
	elseif (pack == "science-pack-3")
	then
	    if ((total-2) < 1) then
			--ingredients[i][2] = 1000
	    else
			ingredients[i][2] = count*multipliers[total-2]
	    end
	elseif (pack == "production-science-pack")
	then
	    if ((total-3) < 1) then
			--ingredients[i][2] = 1000
	    else
			ingredients[i][2] = count*multipliers[total-3]
	    end
	elseif (pack == "high-tech-science-pack")
	then
	    if ((total-4)<1) then
			--ingredients[i][2] = 1000
	    else
			ingredients[i][2] = count*multipliers[total-4]
	    end
	elseif (pack == "space-science-pack")
	then
	    if ((toatl-5)<1) then
			--ingredients [i][2] = 1000
	    else
			ingredients[i][2] = count*multipliers[total-5]
 	    end
	end
	end
   end
end

for k,v in pairs(data.raw.technology) do
	modIngredients(v.unit.ingredients)
end
Thanks guys.

Re: Trying to update a simple mod.

Posted: Fri Aug 17, 2018 7:21 am
by orzelek
There are to many end statements near end of file.
It looks like this section with 5 in a row has to many of them. Like code was removed there or to many end's copied in.

Re: Trying to update a simple mod.

Posted: Fri Aug 17, 2018 9:24 am
by eradicator

Code: Select all

       end --ifthen
       end --for i total
       end --(remove this)
    end --function
My text editor (Notepad++) sees one superflous end. Also i'm not sure if that is acutally the indentation you use or if the forum broke it...but the whole ifthenelse block is *inside* the for i,total loop. Not sure if that's intended, but the indentation is definetly messed up in the post.