[Guide] Modding and Scripting changes in 0.3.0

Place to post guides, observations, things related to modding that are not mods themselves.
kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [Guide] Modding and Scripting changes in 0.3.0

Post by kovarex »

ficolas wrote: same error, line 8...
why...
On line 8, you are missing the closing bracket and comma for another recipe

Code: Select all

},

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: [Guide] Modding and Scripting changes in 0.3.0

Post by ficolas »

fail, sorry, im a bit asleep.

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: [Guide] Modding and Scripting changes in 0.3.0

Post by ficolas »

why do entities have two icons?
you need to put an icon in the entity definition, and another icon in the item definition, why?

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: [Guide] Modding and Scripting changes in 0.3.0

Post by ficolas »

How can I do to use the texture from the base of the game?

Also, my lua code is beeing ignored D:?

Code: Select all

require "util"
require "defines"

game.oninit = function()
end

game.onevent = function(event)
   --[[------------------Underground mining drill stuff------------------]]--
    local randomResources={"coal", "coal", "coal","iron-ore","iron-ore","copper-ore","copper-ore","stone","stone","stone","stone","coal", "coal", "coal","iron-ore","iron-ore","copper-ore","copper-ore","stone","stone","stone","stone","stone","stone","stone","stone","gold-ore","silver-ore"}
   
   if event.name == "onplayermineditem" and event.itemstack.name=="underground-mining-drill" then 
   glob.undergroundMinerPos[#glob.undergroundMinerPos].active=false
   end
   
   if event.name == "onbuiltentity" and event.createdentity.name=="underground-mining-drill" then

        local bModified
        for _,fieldValue in pairs(glob.undergroundMinerPos) do
                
                if event.createdentity.position.x==fieldValue.x and event.createdentity.position.y==fieldValue.y then
                        fieldValue.active="true"
                        bModified=true
                        break
                end
        end
        if not bModified then

                local fieldName=#glob.undergroundMinerPos+1
                glob.undergroundMinerPos[fieldName]={}


                glob.undergroundMinerPos[fieldName].entity = event.createdentity


                glob.undergroundMinerPos[fieldName].active="true"
		if glob.undergroundMinerPos[fieldName].resource~="iron-ore" or glob.undergroundMinerPos[fieldName].resource~="coal" or glob.undergroundMinerPos[fieldName].resource~="stone" or glob.undergroundMinerPos[fieldName].resource~="copper-ore" or glob.undergroundMinerPos[fieldName].resource~="silver-ore" or glob.undergroundMinerPos[fieldName].resource~="gold-ore" then
                	glob.undergroundMinerPos[fieldName].resource=randomResources[math.random(1,#randomResources)]
                	glob.undergroundMinerPos[fieldName].resourcevalue=math.random(1,5)
		end
                glob.undergroundMinerPos[fieldName].position={}
                glob.undergroundMinerPos[fieldName].position.x=event.createdentity.position.x
                glob.undergroundMinerPos[fieldName].position.y=event.createdentity.position.y
            glob.undergroundMinerPos[fieldName].name="underground-mining-drill"
        end


  end 

   
   if event.name == "ontick" then


      for fieldName, _ in pairs(glob.undergroundMinerPos) do

            if glob.undergroundMinerPos[fieldName].entity.isvalid() then
			uminingdrill=glob.undergroundMinerPos[fieldName].entity.getinventory(defines.inventory.chest)

         
         if math.random(130)==80 then
            
            randomnumber2=math.random(1,glob.undergroundMinerPos[fieldName].resourcevalue)
            if uminingdrill.isvalid() and uminingdrill.caninsert({name=(glob.undergroundMinerPos[fieldName].resource), count=(randomnumber2)}) then
               uminingdrill.insert({name=(glob.undergroundMinerPos[fieldName].resource), count=(randomnumber2)})
            end
         end
         end
      end
   end

   
    	if event.name == "onbuiltentity" and event.createdentity.name=="underground-scanner" then
		for fieldName, v in ipairs(glob.undergroundMinerPos) do
		local canbescanned={}
            if event.createdentity.position.x==v.position.x and event.createdentity.position.y==v.position.y then
			game.getplayer().print("The scanner has found "..glob.undergroundMinerPos[fieldName].resource.." in this zone, and the richness is "..glob.undergroundMinerPos[fieldName].resourcevalue)
			canbescanned={fieldName=true}
			break
			end
		if canbescanned[fieldname]==nil then
			game.getplayer().print("The zone has not been drilled, the scanner will not work")
		end
	end
	end
   --[[-------------------------------End :)------------------------------]]--




function cheat(n,a)
	if a == nil then
		game.getplayer().insert{name=n,count=5}
	else
		game.getplayer().insert{name=n,count=a}
	end
end

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: [Guide] Modding and Scripting changes in 0.3.0

Post by drs9999 »

No offence, but I think that this isnt the correct thread to dicuss your modding problems...
But anyway, the "syntax" of the game-event stuff changed, maybe this is the reason why it wont work.

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: [Guide] Modding and Scripting changes in 0.3.0

Post by ficolas »

drs9999 wrote:No offence, but I think that this isnt the correct thread to dicuss your modding problems...
But anyway, the "syntax" of the game-event stuff changed, maybe this is the reason why it wont work.
Well since the problems are because the modding changes, I thought that this was a good place. I will put it elsewere

Post Reply

Return to “Modding discussion”