Trying to update a simple mod.

Place to get help with not working mods / modding interface.
Post Reply
TreeGnoll
Manual Inserter
Manual Inserter
Posts: 1
Joined: Wed Jun 25, 2014 11:46 pm
Contact:

Trying to update a simple mod.

Post 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.
Last edited by Koub on Fri Aug 17, 2018 5:23 am, edited 1 time in total.
Reason: Changed quote to code tag for better readability.

orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Trying to update a simple mod.

Post 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.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Trying to update a simple mod.

Post 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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Modding help”