CyrusJazzberry Posted March 1, 2016 Share Posted March 1, 2016 I've come up with a cool character idea after playing as Woodlegs and his constant sanity loss on land, and I was wondering how to reverse the code to where a character takes sanity loss while sailing. local function sanityfn(inst) local x, y, z = inst.Transform:GetWorldPosition() local ground = GetWorld() local tile = GROUND.GRASS if ground and ground.Map then tile = ground.Map:GetTileAtPoint(x, y, z) end local onWater = ground.Map:IsWater(tile) local delta = 0 if not onWater then delta = TUNING.WOODLEGS_WATER_SANITY end return delta end Any help would be greatly appreciated. Link to comment https://forums.kleientertainment.com/forums/topic/65015-reversing-woodlegs-land-sanity/ Share on other sites More sharing options...
Mobbstar Posted March 2, 2016 Share Posted March 2, 2016 if not onWater then just remove the "not" and you're good to go. (Of course you need to hook the function up in the main fn/postinit) Link to comment https://forums.kleientertainment.com/forums/topic/65015-reversing-woodlegs-land-sanity/#findComment-729160 Share on other sites More sharing options...
CyrusJazzberry Posted March 4, 2016 Author Share Posted March 4, 2016 Thanks for the help! Link to comment https://forums.kleientertainment.com/forums/topic/65015-reversing-woodlegs-land-sanity/#findComment-729599 Share on other sites More sharing options...
CyrusJazzberry Posted March 4, 2016 Author Share Posted March 4, 2016 (edited) Sorry if I sound noobish, but whenever I put the function that corresponds to the water sanity in the main fn (inst.components.sanity.custom_rate_fn = sanityfn) which is where it's located in Woodleg's prefab, it keeps crashing the game when I load the character up with the error message "variable 'sanityfn' is not declared" in the log. I dunno what to do. Edited March 4, 2016 by SecretCereal Link to comment https://forums.kleientertainment.com/forums/topic/65015-reversing-woodlegs-land-sanity/#findComment-729632 Share on other sites More sharing options...
Mobbstar Posted March 4, 2016 Share Posted March 4, 2016 Make sure you place the "sanityfn" function somewhere above the line of code you want to use it at. If you still need help, upload the Lua file. Link to comment https://forums.kleientertainment.com/forums/topic/65015-reversing-woodlegs-land-sanity/#findComment-729762 Share on other sites More sharing options...
CyrusJazzberry Posted March 5, 2016 Author Share Posted March 5, 2016 Your solution worked. Thank you! Link to comment https://forums.kleientertainment.com/forums/topic/65015-reversing-woodlegs-land-sanity/#findComment-729953 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