Page 2 of 2
Re: [MOD 0.10.x+] Straight world (1.0.2)
Posted: Thu May 28, 2015 5:31 pm
by orzelek
Xecutor wrote:Hm. I can't see any difference in map generator debug info with and without Straight world mod.
In both cases map gen seems to be doing something all the time. I've started new game without mod and left it for half an hour. Map gen is still doing something.
Code of Straight world is quite simple. I looked thru it again and it seems find to me

Someone more experienced in oddities of game.findentities and game.createentity should look into it probably.
Yeah I rechecked and it also happens without Straight World. It looks like game behavior.
Only thing that Straight World can do (as a bug) is to eat resources
I hope you don't mind it being part of RSO but thats only way I can find to make them agree on order of calling map modifying functions.
Re: [MOD 0.10.x+] Straight world (1.0.2)
Posted: Fri May 29, 2015 5:31 am
by Xecutor
orzelek wrote:
Only thing that Straight World can do (as a bug) is to eat resources
Hm?
orzelek wrote:
I hope you don't mind it being part of RSO but thats only way I can find to make them agree on order of calling map modifying functions.
Sure, I don't mind

Re: [MOD 0.10.x+] Straight world (1.0.2)
Posted: Fri May 29, 2015 6:46 am
by orzelek
Due to way in which Straight World detects resources whole 8x8 tile is generated using last resource bit found in the square. This applies both to resource type and amount. For some resources (like gems or cobalt) it means you will get lots more or potentially none if there was other resource detected on same square after them.
Re: [MOD 0.10.x+] Straight world (1.0.2)
Posted: Mon Aug 17, 2015 7:31 am
by St3f4n2006
Mod updated for Factorio 0.12.X
- only one problem.. when the user is put near water it ends the game.
Code: Select all
require "defines"
local blocksize=8
local blocksizem1=blocksize-1
local blocksized2=math.floor(blocksize/2)
local ti=table.insert
local function fill(x0,y0,name,amount,step,shift)
step=step or 1
shift=shift or 0
for y=y0+shift,y0+blocksize-1,step do
for x=x0+shift,x0+blocksize-1,step do
game.get_surface(1).create_entity{name=name,position={x,y},amount=amount}
end
end
end
script.on_event(defines.events, function(event)
if event.name == defines.events.on_chunk_generated then
local lt = event.area.left_top
local rb = event.area.right_bottom
for y0=lt.y,rb.y-1,blocksize do
for x0=lt.x,rb.x-1,blocksize do
local tile=game.get_surface(1).get_tile(x0,y0).name
local tiles={}
for y=y0,y0+blocksizem1 do
for x=x0,x0+blocksizem1 do
ti(tiles,{name=tile,position={x,y}})
end
end
game.get_surface(1).set_tiles(tiles)
local ent=game.get_surface(1).find_entities{{x0,y0},{x0+blocksize,y0+blocksize}}
local haveTree=false
local amount=0
local haveResource=false
local haveDecor=false
for _,e in ipairs(ent) do
if e.position.x>=x0 and e.position.y>=y0 then
if e.type=="resource" then
haveResource=e.name
amount=e.amount
e.destroy()
elseif e.type=="tree" then
haveTree=e.name
e.destroy()
elseif e.type=="decorative" then
haveDecor=e.name
e.destroy()
elseif e.type=="simple-entity" then
e.destroy()
end
end
end
if haveResource then
if haveResource=="crude-oil" or string.sub(haveResource,1,4) == "lava" then
game.get_surface(1).create_entity{name=haveResource,amount=amount,position={x0+blocksized2,y0+blocksized2}}
else
fill(x0,y0,haveResource,amount)
end
end
if not haveResource and haveTree then
fill(x0,y0,haveTree,nil,4)
end
if haveDecor then
fill(x0,y0,haveDecor,nil,2,1)
end
end
end
end
end)
Re: [MOD 0.10.x+] Straight world (1.0.2)
Posted: Sun Mar 13, 2016 4:10 pm
by generilisk
Using the 1.02 update (I'm assuming this is the 0.12.x update mentioned; it was the latest listed) I get the following error:
Code: Select all
Notice:
__straight_world__/control.lua:19: attempt to index global 'game' (a nil value)
I'm using 0.12.26 (Build 17762, win64)
Re: [MOD 0.10.x+] Straight world (1.0.2)
Posted: Sat May 28, 2016 10:50 am
by St3f4n2006
generilisk wrote:Using the 1.02 update (I'm assuming this is the 0.12.x update mentioned; it was the latest listed) I get the following error:
Code: Select all
Notice:
__straight_world__/control.lua:19: attempt to index global 'game' (a nil value)
I'm using 0.12.26 (Build 17762, win64)
Just replace game.on_event(defines.events, function(event)
with script.on_event(defines.events, function(event)
PS: i edited the post with the code

Re: [MOD 0.10.x+] Straight world (1.0.2)
Posted: Sat May 28, 2016 12:52 pm
by steinio
Sorry but it's not as easy as it looks.
Since 0.12.11 the game.onevent command is called script.on_event -> easy fix
The onchunkgenerated event is now called on_chunk_generated -> easy fix.
According to
http://lua-api.factorio.com/0.12.34/LuaGameScript.html in 0.12 are no events called:
game.createntity
game.gettile
game.settile
game.findentities
Maybe any experienced programer has a new way to achieve the look of this mod.
Greetings steinio
Re: [MOD 0.10.x+] Straight world (1.0.2)
Posted: Sat May 28, 2016 3:28 pm
by St3f4n2006
EDIT:
steinio wrote:Sorry but it's not as easy as it looks.
Since 0.12.11 the game.onevent command is called script.on_event -> easy fix
The onchunkgenerated event is now called on_chunk_generated -> easy fix.
This are already in the code posted by me.
Thanks for the warning
I am using the steam version( 0.12.33 ) and it works.
I have not tried on 0.12.34 and i am aware that things are changed and will change as the game is improved.
I have no experience with mods for Factorio, i just "tweaked" the code , but i can look into it. It might take some time to understand how all things work.
This are now here:
http://lua-api.factorio.com/0.12.34/LuaSurface.html
I will look into converting the code to use this for the 0.12.34 , and will post here if i manage to do it 
EDIT: i testest in 0.12.34 and it works.
Re: [MOD 0.10.x+] Straight world (1.0.2)
Posted: Sat May 28, 2016 10:27 pm
by steinio
St3f4n2006 wrote:
steinio wrote:Sorry but it's not as easy as it looks.
Since 0.12.11 the game.onevent command is called script.on_event -> easy fix
The onchunkgenerated event is now called on_chunk_generated -> easy fix.
This are already in the code posted by me.
Thanks for the warning
Yes just for completeness. Had to quote you..
Thanks for putting your work in this.
Re: [MOD 0.10.x+] Straight world (1.0.1)
Posted: Sun May 29, 2016 1:13 am
by Qon
Xecutor wrote:It is quite easy to change blocksize in control.lua
I don't think it is possible to have gui that blocks world generation...
Take a look at flatland mod. It does that for floor type and tree and stone generation.
Re: [MOD 0.10.x+] Straight world (1.0.2)
Posted: Wed Nov 23, 2016 7:50 pm
by SlikeyTre
Can someone update this for .14?
Re: [MOD 0.10.x+] Straight world (1.0.2)
Posted: Wed Nov 23, 2016 8:25 pm
by steinio
You can enable it in the RSO mod config if you play with it.
Greetings steinio