[MOD 0.15.x] Stamina

Topics and discussion about specific mods
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2173
Joined: Thu Jun 12, 2014 3:05 am
Contact:

[MOD 0.15.x] Stamina

Post 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
---
Stamina_15.1.2.zip
(16.72 KiB) Downloaded 89 times
---[/b][/color]



LONG DESCRIPTION
TODO
CHANGLOG
Attachments
Stamina_15.1.0.zip
(2.83 KiB) Downloaded 92 times
Last edited by Ranakastrasz on Fri Jul 14, 2017 4:21 pm, edited 1 time in total.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
abordoli
Fast Inserter
Fast Inserter
Posts: 131
Joined: Thu May 25, 2017 1:19 am
Contact:

Re: [MOD 0.15.x] Stamina

Post 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
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2173
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: [MOD 0.15.x] Stamina

Post 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.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: [MOD 0.15.x] Stamina

Post 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
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2173
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: [MOD 0.15.x] Stamina

Post 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
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2173
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: [MOD 0.15.x] Stamina

Post 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.
Attachments
Stamina_15.1.1.zip
(16.71 KiB) Downloaded 76 times
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: [MOD 0.15.x] Stamina

Post 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
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2173
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: [MOD 0.15.x] Stamina

Post 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.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
abordoli
Fast Inserter
Fast Inserter
Posts: 131
Joined: Thu May 25, 2017 1:19 am
Contact:

Re: [MOD 0.15.x] Stamina

Post by abordoli »

"I love it when a plan comes together" - 80s A-Team, The White Haired Guy.. :P

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
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: [MOD 0.15.x] Stamina

Post 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
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2173
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: [MOD 0.15.x] Stamina

Post 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.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: [MOD 0.15.x] Stamina

Post 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
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2173
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: [MOD 0.15.x] Stamina

Post 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.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: [MOD 0.15.x] Stamina

Post 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 :)
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: [MOD 0.15.x] Stamina

Post by Nexela »

But since init only runs once You run into this problem
Attachments
Factorio 07.15.2017 - 00.50.39.02.png
Factorio 07.15.2017 - 00.50.39.02.png (10.6 KiB) Viewed 4687 times
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2173
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: [MOD 0.15.x] Stamina

Post 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.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Post Reply

Return to “Mods”