Skrzelik Posted July 8, 2018 Share Posted July 8, 2018 (edited) So here's the thing I'm trying to do: In the prefabs/evergreens.lua we have table "local builds", in which I'd like to change a few values. I've tried doing AddPrefabPostInit("evergreens", function(inst) builds.twiggy.rebirth_loot = {loot="twigs", max=4} end) and while it doesn't break the game it doesn't really do anything Another thing I've been trying to figure out is in components/lootdropper there is a "local function SplashOceanLoot(loot, cb)" which I'm also having troubles with accessing it. I know that if I'd like to modify "function LootDropper:FlingItem(loot, pt, bouncedcb)" I could do: local Lootdropper = require "components/lootdropper" and then simpy override it with "function Lootdropper:FlingItem(loot, pt, bouncedcb)", but since SplashOceanLoot is local function I'm not sure how to refrence it. I know i could replace whole file with my own and it would work, but that way it wouldn't be really compatible and would easily break, so I'd like to do it from modmain.lua Any tips appresiated Edited July 8, 2018 by Skrzelik being more specific Link to comment Share on other sites More sharing options...
Joachim Posted July 9, 2018 Share Posted July 9, 2018 You can't modify local functions or variables from outside their scope, unless they are somehow passed on or indirectly accessible, in which case they are not true local functions and variables. Link to comment Share on other sites More sharing options...
Skrzelik Posted July 9, 2018 Author Share Posted July 9, 2018 4 minutes ago, Joachim said: You can't modify local functions or variables from outside their scope, unless they are somehow passed on or indirectly accessible, in which case they are not true local functions and variables. Yeah, it's hat I was affraid of. Do you happen to know if you can change your environment to get access to the file where it's been declared? Or alternativly how would you attempt to change previously mentioned "local function SplashOceanLoot" so that I could use GetModConfigData inside of it? If I replace entire file I cant call that function, and from modmain you cant modyfiy SplashOceanLoot, so it's a deadlock for me :/ Link to comment Share on other sites More sharing options...
Saiph Posted July 10, 2018 Share Posted July 10, 2018 Normally you shouldn't be able to do this in standard Lua but there are hacky ways to edit at least local variables. Take a look at Rezecib's Upvalue Hacker. Link to comment 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