jkjkrules Posted December 29, 2018 Share Posted December 29, 2018 i'm trying to make a char mod that you can pick some of your attributes at the beginning It looks like it works for the hunger health and sanity but not combat damage.... This is part of the code i'm trying to use. in modinfo.lua there's configuration_options = { { name = "health", label = "Max Health", options = { {description = "100", data = 1}, {description = "150", data = 2}, {description = "175", data = 3}, {description = "200", data = 4}, }, default = true, }, { name = "hunger", label = "Max Hunger", options = { {description = "100", data = 1}, {description = "150", data = 2}, {description = "175", data = 3}, {description = "200", data = 4}, }, default = true, }, { name = "sanity", label = "Max Sanity", options = { {description = "100", data = 1}, {description = "150", data = 2}, {description = "175", data = 3}, {description = "200", data = 4}, }, default = true, }, { name = "attack", label = "Damage multiplier", options = { {description = "100%", data = 1}, {description = "150%", data = 2}, {description = "175%", data = 3}, {description = "200%", data = 4}, }, default = true, } } in modmain.lua there's if attack == 1 then --Tiny AddPlayerPostInit(function(player) inst.components.combat.damagemultiplier = 1 end) elseif attack ==2 then --Poor AddPlayerPostInit(function(player) inst.components.combat.damagemultiplier = 1.5 end) elseif attack == 3 then --Large AddPlayerPostInit(function(player) inst.components.combat.damagemultiplier = 1.75 end) elseif attack == 4 then --Lots AddPlayerPostInit(function(player) inst.components.combat.damagemultiplier = 2 end) end Link to comment Share on other sites More sharing options...
jkjkrules Posted December 29, 2018 Author Share Posted December 29, 2018 So I forgot to add local attack = GetModConfigData("attack") but it crashes with that [string "../mods/workshop-b/modmain.lua"]:110: attempt to index global 'inst' (a nil value) LUA ERROR stack trceback: ../mods/workshop-b/main.lua(110,1) in function 'fn' scripts/modutil.lua(426,1) =(tail xall) ? =[C] in function 'xpcall' scripts/mods.lua(158,1) in funtcion 'prefabpostinitany' scripts/mainfunctions.lua(280,1) =[C] in funtion 'SendResumeRequestToServer' script/prefabs/world_network.lua(30,1) in function 'fn Link to comment Share on other sites More sharing options...
Ultroman Posted December 30, 2018 Share Posted December 30, 2018 That's an easy one: you named your parameter "player" instead of "inst" You should really combine the things into one big AddPlayerPostInit, instead of creating a bunch of them. Just move all the if-statements into one big AddPlayerPostInit. Then it won't have to add 4 per player. Link to comment Share on other sites More sharing options...
jkjkrules Posted December 30, 2018 Author Share Posted December 30, 2018 54 minutes ago, Ultroman said: That's an easy one: you named your parameter "player" instead of "inst" You should really combine the things into one big AddPlayerPostInit, instead of creating a bunch of them. Just move all the if-statements into one big AddPlayerPostInit. Then it won't have to add 4 per player. Thanks looks like that's working. The codes probably a big mess I really don't know what i'm doing i'm just messing around and pulling parts from other mods and trying to learn. "Just move all the if-statements into one big AddPlayerPostInit." Not sure exactly what that means AddPlayerPostInit(function(inst) if damagemultiplier == 1 then --Tiny inst.components.combat.damagemultiplier = 1 elseif damagemultiplier == 2 then --Poor inst.components.combat.damagemultiplier = 1.5 elseif damagemultiplier == 3 then --Large inst.components.combat.damagemultiplier = 1.75 elseif damagemultiplier == 4 then --Lots inst.components.combat.damagemultiplier = 2 end end) Like this? Link to comment Share on other sites More sharing options...
Ultroman Posted December 30, 2018 Share Posted December 30, 2018 (edited) Yep You could also merge all the health, sanity and hunger stuff into the same AddPlayerPostInit. This mod, though...it kind of has to be a server mod, which means the settings will be applied to every single player, no matter which character they've picked. Most character mods have balanced their character's stats to fit their special abilities, so you might end up really messing up the balance of these characters. For playing singleplayer, it's a nice mod, though, since you'll know which character you're going to pick, and can choose settings accordingly. Edited December 30, 2018 by Ultroman Link to comment Share on other sites More sharing options...
jkjkrules Posted December 31, 2018 Author Share Posted December 31, 2018 Well heck it does mess everyone up. is there a way to fix it?https://steamcommunity.com/sharedfiles/filedetails/?id=1555145441 Link to comment Share on other sites More sharing options...
jkjkrules Posted December 31, 2018 Author Share Posted December 31, 2018 If I move the if statements into the maxwell.lua would that work? If So how would I call that variables? Link to comment Share on other sites More sharing options...
Ultroman Posted January 1, 2019 Share Posted January 1, 2019 (edited) What exactly are you trying to do? Do you want the ability to change the stats for the Maxwell character only, by setting the stats in the settings for your mod? I don't think you can make a mod, where clients can set their own stats before joining. I'm not sure it's impossible either, though. Edited January 1, 2019 by Ultroman Link to comment Share on other sites More sharing options...
jkjkrules Posted January 2, 2019 Author Share Posted January 2, 2019 Just trying to make it so the server side can pick the stats for just maxwell and I wanted it to be changeable so people can play how they like one day they want to play and make it harder or easier. Link to comment Share on other sites More sharing options...
Ultroman Posted January 2, 2019 Share Posted January 2, 2019 Then you can just do AddPlayerPostInit(function(inst) if inst.prefab == "waxwell" then return end -- do all your stat changes end) Or even better AddPrefabPostInit("waxwell", function(inst) -- do all your stat changes end) Not sure if AddPrefabPostInit also works for player characters, but it's worth a try. Link to comment Share on other sites More sharing options...
jkjkrules Posted January 3, 2019 Author Share Posted January 3, 2019 Dude your awesome looks like that did it 3 hours ago, Ultroman said: AddPrefabPostInit("waxwell", function(inst) -- do all your stat changes end) 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