Page 2 of 6
Re: [WIP] Alien walls [0.1.2]
Posted: Thu Jun 11, 2015 12:33 am
by vedrit
Rather than stating expressly in the control what the max health is, can't we get that from the entity? Basically do something like if HP < Max_Health then
Would that be able to handle entities with different max health?
Re: [WIP] Alien walls [0.1.2]
Posted: Thu Jun 11, 2015 12:38 am
by Klonan
vedrit wrote:Rather than stating expressly in the control what the max health is, can't we get that from the entity? Basically do something like if HP < Max_Health then
Would that be able to handle entities with different max health?
I dont think so, only
health seems to be in the prototype
Re: [WIP] Alien walls [0.1.2]
Posted: Thu Jun 11, 2015 12:42 am
by vedrit
Hmm...that seems rather silly... But I tested my theory in-game and got an error, so you're probably right.
Is there a way to put in descriptions for tech? I see we can get away with not having any effects for the tech, but other than being able to create our own effect to be listed (I don't see any mention of that being possible) I can't find a way to describe what the tech does.
Re: [WIP] Alien walls [0.1.2]
Posted: Thu Jun 11, 2015 5:30 am
by vedrit
Klonan, the script you posted for having research increase regen rate doesn't seem to work. It's like the research event isn't triggering or changing anything.
Re: [WIP] Alien walls [0.1.2]
Posted: Thu Jun 11, 2015 9:34 am
by ThaPear
vedrit wrote:Klonan, the script you posted for having research increase regen rate doesn't seem to work. It's like the research event isn't triggering or changing anything.
Quite possibly due to this:
Code: Select all
if HP < 1750 then
-- Should be: HP = HP + glob.monsterregen
HP = HP + glob.regenrate --Hp per second determined by global value
monsterwall.health = HP
end
This is the only place where glob.regenrate is referenced. The rest is glob.monsterregen.
Another issue, I added the second line:
Code: Select all
game.onevent(defines.events.onresearchfinished, function(event) --when research is finished
local research = event.research -- Added this line.
if research == "monster-wall-upgrade" then
As for the max health, you can use:
Code: Select all
game.entityprototypes["monsterwall"].maxhealth
As seen
here, on the wiki.
Re: [WIP] Alien walls [0.1.2]
Posted: Thu Jun 11, 2015 10:45 am
by Klonan
This is the only place where glob.regenrate is referenced. The rest is glob.monsterregen.
Haha my bad, thats what i get for changing the entity code as i was posting it. Thanks for fixing it up

Re: [WIP] Alien walls [0.1.2]
Posted: Thu Jun 11, 2015 5:14 pm
by vedrit
ThaPear wrote:This is the only place where glob.regenrate is referenced. The rest is glob.monsterregen.
I had fixed within my script, but I think it's because research wasn't pulling the research name from the event. I have a feeling that the script you put up, Pear, will fix it.
I saw that maxhealth property before, I just wasn't using it correctly apparently. Too bad it's a read only value
Re: [WIP] Alien walls [0.1.4]
Posted: Sat Jun 13, 2015 5:06 pm
by vedrit
Thanks again for the help guys. Is there a way to read a variable stored in another lua file?
Re: [WIP] Alien walls [0.1.4]
Posted: Sat Jun 13, 2015 6:42 pm
by Klonan
vedrit wrote:Thanks again for the help guys. Is there a way to read a variable stored in another lua file?
I think if you require in a lua file you can call values from it.
Also i notices in the control.lua for 0.1.4 you have 2 different values for the regen for robot built and player built
Code: Select all
game.onevent(defines.events.onrobotbuiltentity , function(event)
if event.createdentity.name == "hybrid-wall" then
if glob.alienwall == nil then
glob.alienwall = {}
end
local alienwall = event.createdentity
table.insert(glob.alienwall, alienwall)
elseif event.createdentity.name == "hybrid-gate" then
if glob.alienwall == nil then
glob.alienwall = {}
end
local alienwall = event.createdentity
table.insert(glob.alienwall, alienwall)
end
if glob.alienregen == nil then
if glob.alienregen == 0 then
glob.alienregen = 5
end
end
end)
game.onevent(defines.events.onbuiltentity, function(event)
if event.createdentity.name == "hybrid-wall" then
if glob.alienwall == nil then
glob.alienwall = {}
end
local alienwall = event.createdentity
table.insert(glob.alienwall, alienwall)
elseif event.createdentity.name == "hybrid-gate" then
if glob.alienwall == nil then
glob.alienwall = {}
end
local alienwall = event.createdentity
table.insert(glob.alienwall, alienwall)
end
if glob.alienregen == nil then
if glob.alienregen == 0 then
glob.alienregen = 1
end
end
end)
Re: [WIP] Alien walls [0.1.4]
Posted: Sun Jun 14, 2015 11:16 am
by ThaPear
I just browsed through the current version and it'd be a lot neater if instead of checking for the existence of certain variables on each event you simply ensure they're there in your oninit() function.
Code: Select all
function init() --Initialises the global value
if glob.alienwall == nil then
glob.alienwall = {}
end
if glob.alienregen == nil or glob.alienregen == 0 then
glob.alienregen = 1
end
end
This allows you to simplify the onbuiltentity to:
Code: Select all
game.onevent(defines.events.onbuiltentity, function(event)
if event.createdentity.name == "hybrid-wall" or event.createdentity.name == "hybrid-gate" then
local alienwall = event.createdentity
table.insert(glob.alienwall, alienwall)
end
end)
Instead of the 19 lines it is currently.
It would even allow you to do away with a lot of duplicate code, by using the same function for player and robot placement:
Code: Select all
game.onevent(defines.events.onrobotbuiltentity, function(event) onbuilt(event.createdentity) end)
game.onevent(defines.events.onbuiltentity, function(event) onbuilt(event.createdentity) end)
function onbuilt(entity)
if entity.name == "hybrid-wall" or entity.name == "hybrid-gate" then
local alienwall = event.createdentity
table.insert(glob.alienwall, alienwall)
end
end
Re: [WIP] Alien walls [0.1.4]
Posted: Sun Jun 14, 2015 7:07 pm
by vedrit
There is a fair bit of redundant code, mostly because I was having issues getting certain parts of the code working. I had included checking for the variables in the createdetevent because sometimes I'd get a nil value in arithmetic when the wall or gate gets damaged. Just wanted to make sure the game had a variable when starting regen.
Re: [WIP] Alien walls [0.1.4]
Posted: Sun Jun 14, 2015 7:12 pm
by jorgenRe
vedrit wrote:There is a fair bit of redundant code, mostly because I was having issues getting certain parts of the code working. I had included checking for the variables in the createdetevent because sometimes I'd get a nil value in arithmetic when the wall or gate gets damaged. Just wanted to make sure the game had a variable when starting regen.
Indeed you are right with the checking code
I do to some degree have the same problem with my Pneumatic Transporter mod, though i've as of writing this, finished all of the functions(except power usage) and the code is totalling at 466 lines! :O!
But i'm sure il get that number down soon, and so i'm sure you can too

!
Re: [WIP] Alien walls [0.1.4]
Posted: Sun Jun 14, 2015 7:40 pm
by vedrit
I've cut out some of the redundant coding, and I can get my entities max HP to read from my variable file, but I can't seem to get my control file to write to variable file to change the max HP. Or is the game unable to change max hp after the entity file has been loaded?
Re: [WIP] Alien walls [0.1.4]
Posted: Mon Jun 29, 2015 8:24 am
by ThaPear
vedrit wrote:I've cut out some of the redundant coding, and I can get my entities max HP to read from my variable file, but I can't seem to get my control file to write to variable file to change the max HP. Or is the game unable to change max hp after the entity file has been loaded?
You cannot alter entity prototypes after the game's startup. You'd have to replace all wall/gate sections with a new entity.
Re: [WIP] Alien walls [0.1.5]
Posted: Mon Jun 29, 2015 9:57 am
by jockeril
sounds interesting - I might try it soon.
Will you continue to develop it in version 0.12 ?
Re: [WIP] Alien walls [0.1.5]
Posted: Tue Jun 30, 2015 8:01 am
by vedrit
jockeril wrote:sounds interesting - I might try it soon.
Will you continue to develop it in version 0.12 ?
I will, though as it is it is currently an add-on to another mod, as mentioned. If something in the new release causes the mod to break and the author doesn't fix it, then I might look into making this a stand-alone.
Also, to note, the Alien Walls folder is still named 0.1.4, though the version is 0.1.5. I'm out of town and not feeling like correcting it :p
Re: [WIP] Alien walls [0.1.5]
Posted: Sat Jul 18, 2015 10:29 pm
by vedrit
Unable to test, as parent mod is broken in 0.12
Re: [WIP] [0.12.0] Alien walls [0.2.0]
Posted: Thu Jul 23, 2015 2:57 am
by vedrit
After creating an unofficial patch to the parent mod, I was able to test Alien Walls in Factorio 0.12.0. I fixed a few issues, and it now works.
Re: [WIP] [0.12.0] Alien walls [0.2.1]
Posted: Thu Jul 23, 2015 5:27 am
by Koub
Topic moved to Mods for 0.12 ‹ New Items, Entities, Extensions (0.12)
Re: [WIP] [0.12.0] Alien walls [0.2.1]
Posted: Fri Jul 31, 2015 11:25 pm
by FreekillX1Alpha
Bringin this over from the shadow pack thread
Error while running the event handler: __AlienWall__/control.lua:19: attempt to index field 'create_dentity' (a nil valUe)
Appears when getting construction robots to place a blueprint (blueprint is a pair of assembler mk 2s, a passive provider chest, a requester chest, a medium electric pole, and 4 smart inserters), as soon as the first assembler is placed it gives me that error and crashes to desktop
Line 19 should read:
Code: Select all
if event.created_entity.name == "hybrid-wall" or event.created_entity.name == "hybrid-gate" then
instead of:
Code: Select all
if event.created_entity.name == "hybrid-wall" or event.create_dentity.name == "hybrid-gate" then
had to move the d around