Page 1 of 1
[MOD 0.15.x] Stamina
Posted: Sat May 13, 2017 3:16 pm
by Ranakastrasz
Stamina
Description:
- Health drains when crafting or mining. It drains faster when in combat or running. Crafting, mining, and running speed decay with health, but recover as you regeneration.
Cannot drop you below 10% health.
Only craft small batches, automated as much as you can instead, or keep fish on hand. Don't craft in combat, since you can lose quite a bit of speed.
Not compatible with any mod that alters character-specific stats for Crafting, Mining, or Running speed.
Based on Stamina by Schmendrick
Details:
- Factorio Version: 0.15
- Released: July 28th 2015
- License: MIT License
- Tags: crafting, health, stats
Download
------[/b][/color]
Re: [MOD 0.15.x] Stamina
Posted: Thu Jul 13, 2017 4:23 pm
by abordoli
Glad you updated this!
"Not compatible with any mod that alters character-specific stats for Crafting, Mining, or Running speed."
So by this you mean mods that increase crafting speed, mining speed and running speed, but the vanilla exoskeleton and enhanced mining tools are fine, right?
Also wondering if there ought to be no penalty for exoskeleton (vanilla and MKII) usage. (if it isn't already in there)
~B
Re: [MOD 0.15.x] Stamina
Posted: Thu Jul 13, 2017 11:38 pm
by Ranakastrasz
abordoli wrote:Glad you updated this!
"Not compatible with any mod that alters character-specific stats for Crafting, Mining, or Running speed."
So by this you mean mods that increase crafting speed, mining speed and running speed, but the vanilla exoskeleton and enhanced mining tools are fine, right?
Also wondering if there ought to be no penalty for exoskeleton (vanilla and MKII) usage. (if it isn't already in there)
~B
Only things like Crafting speed upgrade mod, or whatever. Essentially it changes those values for the player based on current hitpoints, and since we don't have a cross-mod friendly interface, like Starsector, They won't play nice together, ever....
That said, I THINK (wrote this a few months ago) that if you disable a stat's modification it should work with other mods, but that kinda defeats the purpose.
Re: [MOD 0.15.x] Stamina
Posted: Fri Jul 14, 2017 12:36 am
by Nexela
Just a heads up that this is Not MP safe, Also incorrectly using on_tick to init your mod.
You are storing variables in locals and you are staring Init variables in local as well. For anything to persist between saves it needs to be stored in the "global" variable
http://lua-api.factorio.com/latest/Global.html
Re: [MOD 0.15.x] Stamina
Posted: Fri Jul 14, 2017 1:54 am
by Ranakastrasz
Odd. It worked fine in multiplayer last I tried it.
Also I don't think I have anything saves that needs to remain between saves, but ill recheck.
Looking at it again, Yea, I haven't updated it since I learned about how to intilize properly. Irritatingly, I can't find one of my mods that I did so for. I think it was just, OnInit, and OnConfigChange.
Do those "Local Variables" get set when the game loads again? Because otherwise I have no idea how to do that properly. I just copied that from another mod which used game configuration settings.
Wormmus-Config
Re: [MOD 0.15.x] Stamina
Posted: Fri Jul 14, 2017 2:36 am
by Ranakastrasz
I have no idea why this isn't working. None of my debug messages worked, and so far as I can tell neither event occurs now.
Haven't done coding in a while, and I'm tired, so I probably missed something obvious.
Re: [MOD 0.15.x] Stamina
Posted: Fri Jul 14, 2017 11:58 am
by Nexela
Ranakastrasz wrote:I have no idea why this isn't working. None of my debug messages worked, and so far as I can tell neither event occurs now.
Haven't done coding in a while, and I'm tired, so I probably missed something obvious.
You are defining onTick after you call it
Code: Select all
script.on_event(defines.events.on_tick, onTick) --< onTick is nil here,
function onTick(event)
Also it will still desync due to "timer"
Code: Select all
local timer, Char, drain -- Remove this line all together
Code: Select all
function onTick(event)
if event.tick % 3 == 0 then --every three ticks
for _,p in pairs(game.connected_players) do --Only need to loop through connected players
local Char = p.character
if Char then
local drain = 0
-- Rest of code here
end
end
end
end
Re: [MOD 0.15.x] Stamina
Posted: Fri Jul 14, 2017 4:22 pm
by Ranakastrasz
Thanks. the undefined variable should have been obvious, but I've been messing with c# recently and that doesn't apply there.
Still not 100% sure how that can cause desyncs, but I fixed it as such.
Re: [MOD 0.15.x] Stamina
Posted: Fri Jul 14, 2017 8:27 pm
by abordoli
"I love it when a plan comes together" - 80s A-Team, The White Haired Guy..
P.S. Another mod handles hunger "O-Sushi-Mod". Any thoughts bout "sleep" or will low stamina force you to look for a bed to regenerate? j/k
Re: [MOD 0.15.x] Stamina
Posted: Fri Jul 14, 2017 10:35 pm
by Nexela
Your latest version still suffers from the same problem tick will be different depending on player
I suggest removing Tick all together and use the event.tick example from above
Re: [MOD 0.15.x] Stamina
Posted: Sat Jul 15, 2017 1:48 am
by Ranakastrasz
Are you sure?
Code: Select all
script.on_event(defines.events.on_tick, onTick)
I thought that would run onTick.... OnTick....
Init runs on Init and onConfigChange, which means that On load, if this mod is added, or any mod changes version, or when a new game is created with this mod, it should run,
OnTick should run ontick, and the only global dependent part is the "Run every 3 ticks" which is set based on the current gametick, so shouldn't be possible to desync.
Re: [MOD 0.15.x] Stamina
Posted: Sat Jul 15, 2017 2:34 am
by Nexela
I am talking about your tick variable
LOCAL A = THIS
on_event -> A = THAT
player 1 joins
his A is THIS
event happens
his A is THAT
player 2 joins
his A is THIS
event happens
player 1 runs event with THAT
player 2 runs event with THIS
desync happens
Re: [MOD 0.15.x] Stamina
Posted: Sat Jul 15, 2017 4:02 am
by Ranakastrasz
What tick variable? I have no variable by that name. If you are talking about timer I don't think it should be possible to desync.
Re: [MOD 0.15.x] Stamina
Posted: Sat Jul 15, 2017 4:09 am
by Nexela
Ranakastrasz wrote:What tick variable? I have no variable by that name. If you are talking about timer I don't think it should be possible to desync.
Well I meant timer variable

Re: [MOD 0.15.x] Stamina
Posted: Sat Jul 15, 2017 4:52 am
by Nexela
But since init only runs once You run into this problem
Re: [MOD 0.15.x] Stamina
Posted: Sat Jul 15, 2017 3:43 pm
by Ranakastrasz
It was working great, and in multiplayer, Before. Now it doesn't work at all....
And I currently cant think of how to fix it aside from reverting to the old behavior, which worked fine.