Seems the item grid is missing an equipment grid hope it helps This seems to happen when cursed tries implementing its own armor then dystopia tries and forces an armor slot into it. And gets the upper hand. Then your mod returns this error. Mod works without either of these mods Might be wrong tho! dont judge :# i suck at lua lol I am only good at throwing stuff at it and make it work on some magical reason
function hasgasmask(player)
if player.getinventory(defines.inventory.playerarmor)[1] == nil then return false end
local grid = player.getinventory(defines.inventory.playerarmor)[1].grid
if grid == nil then return false end
for _,equip in pairs(grid.equipment) do
if equip.name == "gas-mask" then return true end
end
return false
end
I've added a check with the ItemStack.hasgrid() method, it should work now
Hmm...whenever i fix small errors and I'm sure that it must be correct, there is a new error
Nevertheless thanks, I'll now try to test the mod always
Re: [0.11.X] Oxygen
Posted: Mon Apr 20, 2015 5:42 pm
by orzelek
Natha wrote:
Nevertheless thanks, I'll now try to test the mod always
Famous last words of developer
Re: [0.11.X] Oxygen
Posted: Mon Apr 20, 2015 6:08 pm
by Natha
orzelek wrote:
Natha wrote:
Nevertheless thanks, I'll now try to test the mod always
Famous last words of developer
the thing was, that I not have tested each small change of the mod
its annoying that almost always the small changes cause the biggest errors
Re: [0.11.X] Oxygen
Posted: Tue Apr 21, 2015 10:31 am
by Cheata
I seem to have found a minor issue with the oxygen bottle detection
I tried out this mod for the first time today and as expected ran out of oxygen before i managed to get a working oxygen facility up and running, However i had expected this and planned ahead. while the last of the research was completing and the first oxygen bottle got filled i ran around picking up and eating fish to keep my health up.
16min after running out of oxygen i finally managed to get a full bottle back into my inventory but to my disappointment i still died from lack of oxygen
It appears you use the code below to check if the player has run out of oxygen and deal damage accordingly however you only check for oxygen bottles if the players remaining oxygen is greater than 0.
This means that once the player has started suffocating it cannot be stopped even if a fresh oxygen bottle is added to the inventory after suffocation has begun
if v[2] > 0 and (game.tick % 800 == 0 or (not hasgasmask(v[1]) and game.tick % 400 == 0)) then
v[2] = v[2] - 1
updategui(v)
elseif v[2] <= 0 and game.tick % 300 == 0 and v[1].character ~= nil then
v[1].character.damage(10, v[1].force, "oxygen")
end
checkinventory(v)
or something similar, possibly with a separate tick check around the 200 or 300 mark
alternatively you could setup the checkinventory function to return true if an oxygen bottle was found as shown below (i have done this on my local machine and confirmed it works)
function checkinventory(oxygenplayer)
local inv = oxygenplayer[1].getinventory(defines.inventory.playermain)
for i=1,2 do
if inv.getitemcount("oxygen-bottle") >= 1 and oxygenplayer[2] <= 50 then
inv.remove{name="oxygen-bottle", count=1}
inv.insert{name="empty-oxygen-bottle", count=1}
oxygenplayer[2] = oxygenplayer[2] + 50
return true -- small bottle found so leave the function and tell caller about it
elseif inv.getitemcount("big-oxygen-bottle") >= 1 and oxygenplayer[2] == 0 then
inv.remove{name="big-oxygen-bottle", count=1}
inv.insert{name="big-empty-oxygen-bottle", count=1}
oxygenplayer[2] = oxygenplayer[2] + 100
return true -- large bottle found so leave the function and tell the caller about it
end
inv = oxygenplayer[1].getinventory(defines.inventory.playerquickbar)
end
return false --no bottles found so send caller default value
end
function handleplayers()
for _,v in ipairs(glob.oxygen) do
if v[1].controllertype == defines.controllers.character then
-- Sauerstoffverbrauch und Schaden bei geringem Sauerstoff
if v[2] > 0 and (game.tick % 800 == 0 or (not hasgasmask(v[1]) and game.tick % 400 == 0)) then
v[2] = v[2] - 1
checkinventory(v) -- left this here to make use of the 50% bottles sooner but not necessarily needed
updategui(v)
elseif v[2] <= 0 and game.tick % 300 == 0 and v[1].character ~= nil then
if checkinventory(v) then --check for the bottles and restore oxygen
updategui(v)
else
v[1].character.damage(10, v[1].force, "oxygen") --cause damage if none found
end
end
-- Auffüllung durch Verteiler
local pos = v[1].position
if game.tick % 75 == 0 then
entities = game.findentitiesfiltered{area={{pos.x - 10, pos.y - 10}, {pos.x + 10, pos.y + 10}}, name="oxygen-dispenser"}
if #entities > 0 then
if v[2] < 100 then
v[2] = v[2] + 1
updategui(v)
end
if game.tick % 225 == 0 then
local inv = v[1].getinventory(defines.inventory.playermain)
for i=1,2 do
if inv.getitemcount("empty-oxygen-bottle") > 0 then
inv.remove({name="empty-oxygen-bottle", count=1})
inv.insert({name="oxygen-bottle", count=1})
elseif inv.getitemcount("big-empty-oxygen-bottle") > 0 then
inv.remove({name="big-empty-oxygen-bottle", count=1})
inv.insert({name="big-oxygen-bottle", count=1})
end
inv = v[1].getinventory(defines.inventory.playerquickbar)
end
end
end
end
end
end
end
Let me know your thoughts
Re: [0.11.X] Oxygen
Posted: Tue Apr 21, 2015 2:18 pm
by Natha
Quote
[quote="Cheata"]I seem to have found a minor issue with the oxygen bottle detection
I tried out this mod for the first time today and as expected ran out of oxygen before i managed to get a working oxygen facility up and running, However i had expected this and planned ahead. while the last of the research was completing and the first oxygen bottle got filled i ran around picking up and eating fish to keep my health up.
16min after running out of oxygen i finally managed to get a full bottle back into my inventory but to my disappointment i still died from lack of oxygen
It appears you use the code below to check if the player has run out of oxygen and deal damage accordingly however you only check for oxygen bottles if the players remaining oxygen is greater than 0.
This means that once the player has started suffocating it cannot be stopped even if a fresh oxygen bottle is added to the inventory after suffocation has begun
if v[2] > 0 and (game.tick % 800 == 0 or (not hasgasmask(v[1]) and game.tick % 400 == 0)) then
v[2] = v[2] - 1
updategui(v)
elseif v[2] <= 0 and game.tick % 300 == 0 and v[1].character ~= nil then
v[1].character.damage(10, v[1].force, "oxygen")
end
checkinventory(v)
or something similar, possibly with a separate tick check around the 200 or 300 mark
alternatively you could setup the checkinventory function to return true if an oxygen bottle was found as shown below (i have done this on my local machine and confirmed it works)
function checkinventory(oxygenplayer)
local inv = oxygenplayer[1].getinventory(defines.inventory.playermain)
for i=1,2 do
if inv.getitemcount("oxygen-bottle") >= 1 and oxygenplayer[2] <= 50 then
inv.remove{name="oxygen-bottle", count=1}
inv.insert{name="empty-oxygen-bottle", count=1}
oxygenplayer[2] = oxygenplayer[2] + 50
return true -- small bottle found so leave the function and tell caller about it
elseif inv.getitemcount("big-oxygen-bottle") >= 1 and oxygenplayer[2] == 0 then
inv.remove{name="big-oxygen-bottle", count=1}
inv.insert{name="big-empty-oxygen-bottle", count=1}
oxygenplayer[2] = oxygenplayer[2] + 100
return true -- large bottle found so leave the function and tell the caller about it
end
inv = oxygenplayer[1].getinventory(defines.inventory.playerquickbar)
end
return false --no bottles found so send caller default value
end
function handleplayers()
for _,v in ipairs(glob.oxygen) do
if v[1].controllertype == defines.controllers.character then
-- Sauerstoffverbrauch und Schaden bei geringem Sauerstoff
if v[2] > 0 and (game.tick % 800 == 0 or (not hasgasmask(v[1]) and game.tick % 400 == 0)) then
v[2] = v[2] - 1
checkinventory(v) -- left this here to make use of the 50% bottles sooner but not necessarily needed
updategui(v)
elseif v[2] <= 0 and game.tick % 300 == 0 and v[1].character ~= nil then
if checkinventory(v) then --check for the bottles and restore oxygen
updategui(v)
else
v[1].character.damage(10, v[1].force, "oxygen") --cause damage if none found
end
end
-- Auffüllung durch Verteiler
local pos = v[1].position
if game.tick % 75 == 0 then
entities = game.findentitiesfiltered{area={{pos.x - 10, pos.y - 10}, {pos.x + 10, pos.y + 10}}, name="oxygen-dispenser"}
if #entities > 0 then
if v[2] < 100 then
v[2] = v[2] + 1
updategui(v)
end
if game.tick % 225 == 0 then
local inv = v[1].getinventory(defines.inventory.playermain)
for i=1,2 do
if inv.getitemcount("empty-oxygen-bottle") > 0 then
inv.remove({name="empty-oxygen-bottle", count=1})
inv.insert({name="oxygen-bottle", count=1})
elseif inv.getitemcount("big-empty-oxygen-bottle") > 0 then
inv.remove({name="big-empty-oxygen-bottle", count=1})
inv.insert({name="big-oxygen-bottle", count=1})
end
inv = v[1].getinventory(defines.inventory.playerquickbar)
end
end
end
end
end
end
end
Let me know your thoughts [/quote]
thanks for your report, i've changed the condition checks
Re: [0.11.X] Oxygen
Posted: Wed Apr 29, 2015 5:25 pm
by darkshadow1809
Seems my modpack has a major issue. Once i threw oxygen mod out. It seems something still damages people from polution... Wut? xD
I pm'd you.
Re: [0.11.X] Oxygen
Posted: Sat May 02, 2015 11:30 pm
by Virlomi
Since you're making oxygen a thing to worry about, it would be really neat to have an atmosphere dispenser that builds a dome of safe space that you don't need a mask in. Think kind of force field type thing on space carriers and the like.
Re: [0.11.X] Oxygen
Posted: Sun May 03, 2015 4:52 am
by Natha
Virlomi wrote:Since you're making oxygen a thing to worry about, it would be really neat to have an atmosphere dispenser that builds a dome of safe space that you don't need a mask in. Think kind of force field type thing on space carriers and the like.
You dont need any gas masks while you are in the dispensing area of the dispenser
Maybe I can implement a higher tier of dispenser with an area about 20 blocks
Re: [0.11.X] Oxygen
Posted: Sat May 09, 2015 6:44 am
by Peter34
Hi
You say you've set this mod to start the game with 10 Oxygen Bottles, but that you personally feel that you'd be able to research up to the Chemical Plant tech before using more than half of that.
Well, I'm the opposite, I'm rather less hardcore, so might it be a good idea to make several versions of this mod, differing only in terms of the amount of starting Oxygen Bottles, as a way for the player to toggle the difficulty level? I propose versions with 3, 5, 7, 10, 15, 22 and 35 bottles, each figure being approxiatemly 50% greater than the previous, thereby catering to players of all levels of hardcoreness from ultra to none.
Re: [0.11.X] Oxygen
Posted: Sun May 10, 2015 6:36 am
by Natha
Peter34 wrote:Hi
You say you've set this mod to start the game with 10 Oxygen Bottles, but that you personally feel that you'd be able to research up to the Chemical Plant tech before using more than half of that.
Well, I'm the opposite, I'm rather less hardcore, so might it be a good idea to make several versions of this mod, differing only in terms of the amount of starting Oxygen Bottles, as a way for the player to toggle the difficulty level? I propose versions with 3, 5, 7, 10, 15, 22 and 35 bottles, each figure being approxiatemly 50% greater than the previous, thereby catering to players of all levels of hardcoreness from ultra to none.
Hmm...I think the best way is to set up a config file where you can change the oxygen bottle amount.
Re: [0.11.X] Oxygen
Posted: Sun May 10, 2015 3:01 pm
by Peter34
Natha wrote:
Hmm...I think the best way is to set up a config file where you can change the oxygen bottle amount.
That may be easier. Just make sure to explain how people can find the file and edit it.
Re: [0.11.X] Oxygen
Posted: Sun May 31, 2015 2:18 am
by OvermindDL1
As per prior recent posts, 10 is *not* enough when playing heavily modded, I adjusted mine to 15 and that was sufficient, though I could see most people needing more when not making a dead beeline for it like I was in my mod-set.
However, I am here to report a 'bug'?
Specifically when calling:
And that seems to have resolved the issue. Is the Player object not comparable? If so then those lines were doomed to fail. if they are comparable then somehow it is not returning the same object.
</edit>
Re: [0.11.X] Oxygen
Posted: Mon Jun 01, 2015 12:07 am
by Wyrm
I think it may be an aliasing issue. == is testing whether the two compare equal in some implementation-dependent way. I suspect that it's probably a bit-wise comparison. If v is a copy of game.player, it is not necessarily (and probably isn't) bit-equal with game.player. Instead it's a whole different structure with every element copied to v from game.player to a new patch of memory. This means that (given that probably game.player is represented by a C++ vector) the pointers will not compare equal, and so, the two structures will not compare equal.
I would consider this to be a bug in the underlying program. == should have special handling code for lists, and should compare equal all lists whose corresponding elements compare equal.
Re: [0.11.X] Oxygen
Posted: Mon Jun 01, 2015 5:10 am
by OvermindDL1
Wyrm wrote:I think it may be an aliasing issue. == is testing whether the two compare equal in some implementation-dependent way. I suspect that it's probably a bit-wise comparison. If v is a copy of game.player, it is not necessarily (and probably isn't) bit-equal with game.player. Instead it's a whole different structure with every element copied to v from game.player to a new patch of memory. This means that (given that probably game.player is represented by a C++ vector) the pointers will not compare equal, and so, the two structures will not compare equal.
I would consider this to be a bug in the underlying program. == should have special handling code for lists, and should compare equal all lists whose corresponding elements compare equal.
As someone who has implement LUA as a scripting language in multiple different games, hell no. Deep comparisons are costly as hell.
What you would 'think' it would do is return the same object, those would compare true, it probably returns different objects from underlying C++ code, thus yeah, they test false, and the usernames (or really GUID if Factorio had those) should be checked instead.
Re: [0.11.X] Oxygen
Posted: Wed Jun 03, 2015 1:19 pm
by Wyrm
OvermindDL1 wrote:As someone who has implement LUA as a scripting language in multiple different games, hell no. Deep comparisons are costly as hell.
And as a general programmer, I can tell you that such things are sometimes necessary to ensure consistent behavior. They aren't too bad as long as you don't do them too often on structures that are too large. You're right that there should be a separate function for them, though (like Scheme's equal? vs eq? predicates).
Re: [0.11.X] Oxygen
Posted: Thu Jun 11, 2015 8:08 am
by OvermindDL1
Wyrm wrote:
OvermindDL1 wrote:As someone who has implement LUA as a scripting language in multiple different games, hell no. Deep comparisons are costly as hell.
And as a general programmer, I can tell you that such things are sometimes necessary to ensure consistent behavior. They aren't too bad as long as you don't do them too often on structures that are too large. You're right that there should be a separate function for them, though (like Scheme's equal? vs eq? predicates).
Precisely, a separate function, and yes I tested, Factorio does not always return the same structure, name checking should be checked, not the structure.
Re: [0.11.X] Oxygen
Posted: Sun Aug 09, 2015 9:36 pm
by Neomore
will this mod ever be getting updated to .12? I love this mod, and have been looking forward to it getting new stuff. I'm not very good at coding, myself. Otherwise I'd update it myself.
Re: [0.11.X] Oxygen
Posted: Mon Aug 10, 2015 4:40 am
by Neomore
For anyone better at coding than me, i was able to actually get the mod to load on .12 after having to add over 50 lines of code, and lots of underscores. However, currently only placing the oxygen dispenser down works. Picking it up breaks the mod. Haven't figured out how to fix that, yet.
Also, the smoke effect and the dispenser's shadow effects are also broken, as well as oxygen being added to the main menu (i believe). It at least doesn't in test mode.
But, hey. At least Factorio is able to turn on when the mod is installed. That's at least a bit of progress.
Here's the file. I will keep trying to work on it, but would appreciate someone more qualified to do this. Hopefully the mod author him/her self, but anyone will do.