KucheKlizma Posted January 19, 2018 Share Posted January 19, 2018 (edited) Hi, I'm trying to make a simple mod to easily change the seed for world generation. I found that this could be possible if I can override the savedata.meta.seed value. It's declared in the following function from worldgen_main.lua and I think I have to override it in order to do so, but I'm not sure where to begin: Spoiler function GenerateNew(debug, world_gen_data) .... savedata.meta = { build_version = APP_VERSION, build_date = APP_BUILD_DATE, build_time = APP_BUILD_TIME, seed = SEED, level_id = level.id, session_identifier = WorldSim:GenerateSessionIdentifier(), saveversion = savefileupgrades.VERSION, } ... end I've done similar stuff in a different API, but there I only had to create a lua file with the same filename in the mod and override as I please. I tried supplying a value for savedata.meta.seed in various forms, but that didn't achieve anything: Spoiler Global.savedata.meta.seed = 3 savedata.meta.seed = 3 global.savedata.meta["seed"] = 3 savedata.meta["seed"] = 3 local require = GLOBAL.require gen = require("worldgen_main") gen.savedata.meta.seed= 3 gen.savedata.meta["seed"] = 3 I'm using this console command to check after generating a world: print(TheWorld.meta.seed) I'm currently trying something like this in modworldgenmain.lua - it's probably very wrong: Spoiler local require = GLOBAL.require gen = require("worldgen_main") function gen.GenerateNew = function (debug, world_gen_data) .... modified seed. ... end I'm getting this error: Spoiler [string "../mods/World_Seed_DST/modworldgenmain.lua"]:31: '<name>' expected near '?' This is line 31 - it's part of the GenerateNew function: Spoiler print("level_type", tostring(world_gen_data.level_type)) Tbh I'm not certain if it would even work with correct synthax, as I don't know if mods get loaded in time for world generation, but I thought it's worth a try. If I manage to at least get the basic functionality working, I'll probably have to work out how to read seeds from a .txt file, as the UI doesn't support direct number/string input. Trying the aforementioned input from file caused the game to crash, but I'll troubleshoot that one out later once it's meaningful. If it's possible to mod the API/UI so it supports direct numberic input that would be much more elegant than reading from a file, but idk if that's a realistic goal. Any tips would be appreciated! Thanks! Edited January 19, 2018 by KucheKlizma Link to comment https://forums.kleientertainment.com/forums/topic/86595-override-generatenew-from-worldgen_mainlua/ Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now