[MOD 1.0] Alien walls [0.9.5]

Topics and discussion about specific mods
vedrit
Filter Inserter
Filter Inserter
Posts: 293
Joined: Sun Aug 03, 2014 2:25 am
Contact:

Re: [WIP] Alien walls [0.1.2]

Post 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?
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5266
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [WIP] Alien walls [0.1.2]

Post 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
vedrit
Filter Inserter
Filter Inserter
Posts: 293
Joined: Sun Aug 03, 2014 2:25 am
Contact:

Re: [WIP] Alien walls [0.1.2]

Post 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.
vedrit
Filter Inserter
Filter Inserter
Posts: 293
Joined: Sun Aug 03, 2014 2:25 am
Contact:

Re: [WIP] Alien walls [0.1.2]

Post 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.
User avatar
ThaPear
Fast Inserter
Fast Inserter
Posts: 226
Joined: Fri May 30, 2014 8:05 am
Contact:

Re: [WIP] Alien walls [0.1.2]

Post 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.
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5266
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [WIP] Alien walls [0.1.2]

Post 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 :D
vedrit
Filter Inserter
Filter Inserter
Posts: 293
Joined: Sun Aug 03, 2014 2:25 am
Contact:

Re: [WIP] Alien walls [0.1.2]

Post 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
vedrit
Filter Inserter
Filter Inserter
Posts: 293
Joined: Sun Aug 03, 2014 2:25 am
Contact:

Re: [WIP] Alien walls [0.1.4]

Post by vedrit »

Thanks again for the help guys. Is there a way to read a variable stored in another lua file?
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5266
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [WIP] Alien walls [0.1.4]

Post 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)
User avatar
ThaPear
Fast Inserter
Fast Inserter
Posts: 226
Joined: Fri May 30, 2014 8:05 am
Contact:

Re: [WIP] Alien walls [0.1.4]

Post 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
vedrit
Filter Inserter
Filter Inserter
Posts: 293
Joined: Sun Aug 03, 2014 2:25 am
Contact:

Re: [WIP] Alien walls [0.1.4]

Post 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.
jorgenRe
Filter Inserter
Filter Inserter
Posts: 535
Joined: Wed Apr 09, 2014 3:32 pm
Contact:

Re: [WIP] Alien walls [0.1.4]

Post 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 :mrgreen:
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 :)!
Logo
Noticed the told change in FFF #111 so il continue to use my signature ^_^
Thanks for listening to our suggestions, devs :D!
I would jump of joy if we could specify which tiles spawned in a surfaces
vedrit
Filter Inserter
Filter Inserter
Posts: 293
Joined: Sun Aug 03, 2014 2:25 am
Contact:

Re: [WIP] Alien walls [0.1.4]

Post 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?
User avatar
ThaPear
Fast Inserter
Fast Inserter
Posts: 226
Joined: Fri May 30, 2014 8:05 am
Contact:

Re: [WIP] Alien walls [0.1.4]

Post 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.
User avatar
jockeril
Filter Inserter
Filter Inserter
Posts: 372
Joined: Sun Feb 08, 2015 11:04 am
Contact:

Re: [WIP] Alien walls [0.1.5]

Post by jockeril »

sounds interesting - I might try it soon.

Will you continue to develop it in version 0.12 ?
My mods

Formerly Hebrew translator for FARL & EvoGUI - two mods I highly recommend for anyone to check-out

join me on
- Twitter[@jockeril],
- Twitch.tv/jockeril,
- Youtube/jocker-il (or JoCKeR-iL)
- and steam !
Image
vedrit
Filter Inserter
Filter Inserter
Posts: 293
Joined: Sun Aug 03, 2014 2:25 am
Contact:

Re: [WIP] Alien walls [0.1.5]

Post 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
vedrit
Filter Inserter
Filter Inserter
Posts: 293
Joined: Sun Aug 03, 2014 2:25 am
Contact:

Re: [WIP] Alien walls [0.1.5]

Post by vedrit »

Unable to test, as parent mod is broken in 0.12
vedrit
Filter Inserter
Filter Inserter
Posts: 293
Joined: Sun Aug 03, 2014 2:25 am
Contact:

Re: [WIP] [0.12.0] Alien walls [0.2.0]

Post 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.
Koub
Global Moderator
Global Moderator
Posts: 7772
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: [WIP] [0.12.0] Alien walls [0.2.1]

Post by Koub »

Topic moved to Mods for 0.12 ‹ New Items, Entities, Extensions (0.12)
Koub - Please consider English is not my native language.
FreekillX1Alpha
Manual Inserter
Manual Inserter
Posts: 2
Joined: Fri Jul 24, 2015 12:57 am
Contact:

Re: [WIP] [0.12.0] Alien walls [0.2.1]

Post 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
Post Reply

Return to “Mods”