[0.16.36] map_gen_settings.height / width not saved

Bugs that are actually features.
User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2638
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

[0.16.36] map_gen_settings.height / width not saved

Post by steinio »

Hi,

according to the api-doc map_gen_settings.height and width is writable but the value is not saved and so not returned:

Code: Select all

/c game.player.surface.map_gen_settings.width=42
/c game.player.print(game.player.surface.map_gen_settings.width)
This returns 2000000, expected is 42.

Cu, steinio.
Image

Transport Belt Repair Man

View unread Posts
posila
Former Staff
Former Staff
Posts: 5448
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: [0.16.36] map_gen_settings.height / width not saved

Post by posila »

It needs to be

Code: Select all

local new_map_gen_settings = game.player.surface.map_gen_settings
new_map_gen_settings.width = 42
game.player.surface.map_gen_settings = new_map_gen_settings
game.player.print(game.player.surface.map_gen_settings.width)
In general, classes of type LuaSomething (ie LuaSurface, LuaEntity, ...) have binding to some underlying C++ class, wheras types without Lua prefix in name are plain Lua tables. So if the lua-doc says

Code: Select all

map_gen_settings :: MapGenSettings [RW]
it means result of map_gen_settings is plain table and changing it won't do anything. You need to change it and write it back.
User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2638
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: [0.16.36] map_gen_settings.height / width not saved

Post by steinio »

Ok thank you for this explaination.
Image

Transport Belt Repair Man

View unread Posts
Post Reply

Return to “Not a bug”