In vanilla there is so much you can do the the circuit network thanks to the introduction of combinators, but not really any easy way to directly interface with it. So I've created a simple entity called the pressure plate. Connect it to the circuit network, and when the player stands in it, it sends out a custom pressure signal. I got the idea for it when I saw a player make racetrack in Factorio and thought it would be neat to use combinators to time your laps, except there was no good way to start and stop the timer. Until now.
It's easy to set up. Just research the technology, place a pressure plate, wire it to anything you like, and stand on it! It's that simple. It can tell if the player is standing on it even if they are in a car.
Included is a recipe and technology for building the pressure plate and a virtual signal output by the pressure plate. The pressure plate depresses and lights up when the player stands on it. Currently, by allowing this, there is a consequence/bug where the pressure plate does not show up while held until it is actually placed by the player. If this annoys you, there is a config file included in the mod where you can disable this. It makes the pressure plate visible when it is in your hand, at the consequence of the plates no longer being animated and slight render layer problems.
People are racing to play this mod
Check out my custom racetrack map that uses pressure plates to time your laps.
Future Plans
This is my first mod and I'm surprised I got it working without too much hassle. I've got a few things I'd like to improve and I always listen to suggestions.
Make the pressure plate send a custom virtual signal rather than an item
Always draw the pressure plate under the player, rather than only when the player is in front of the entity
Show different sprites when the pressure plate is active and inactive
Play a noise when the player gets on and gets off the pressure plate
Draw better graphics for the technology and item icons
Introduce a more advanced pressure plate that can tell the difference between the player/vehicles/biters
Test out the mod in multiplayer
Fix up and optimize/understand my control.lua code
Allow the player to see the pressure plate as they are placing it
Fix the pressure plate mask being deleted when concrete is built on the same tile
Have adjacent pressure plates automatically connect to each other to form one large plate
I have to give a big thanks to Schorty who made the Pollution Detector mod and from whom I copied large amounts of code in order to get my pressure plate working for the first time, plus a fairly large thanks to all the guys in the mod help board who helped me out with my code. If anyone would like to help out with anything on the future plans list or offer suggestions for other future plans I would be very appreciative, and any comments/constructive criticisms/love letters are always welcome.
Changelog
version 0.0.1 (1/6/2016)
First release version
version 0.1.0 (1/16/2016)
Added animated pressure plates
Pressure plates now outputs a virtual signal
Pressure plate now always renders under objects and players
Completely rewrote variable names and handling in control.lua
If you are upgrading to 0.1.0 after playing with the 0.0.1 mod, your old pressure plates will not work, and will be invisible if you have animated_graphics set equal to true. You will need to set animated_graphics to false, and then mine and replace all of your old pressure plates. Sorry.
version 0.1.1 (3/20/2016)
Increased technology cost
Added a slightly better looking technology icon
Fixed a crash caused by interacting with a plate that didn't have a mask. Thanks binbinhfr
version 0.1.2 (4/26/2016)
Fixed pressure plate turning invisible when a floor covering is placed on top of it
version 0.1.3 (4/28/2016)
I left out the image for the signal icon in v0.1.2 like an idiot. Thanks Cyber_Garret
Re: [Mod 12.20] Player sensitive pressure plates 0.0.1
Posted: Mon Jan 11, 2016 2:48 pm
by StanFear
this is interesting, and definetly more interesting than some other mod that used concreete to just check presence ... (I think it's advenced logistics or something)
(what follows is only from reading the code, not 100% certains about what I will say)
it's just kinda sad it only works on player, would be interesting to know if an enemy is on it (do they attack it ?)
does it works in multiplayer ?
in your control.lua file, (function removeBPP)
you go through the whole table to know if the entity is a presure plate, (I know you want the id to remove it from the table but ...)
you could just create a pair table with the key being X,Y and then remove it much more easily
and to know if this is a presure plate : entity.name == "basic-pressure-plate"
Re: [Mod 12.20] Player sensitive pressure plates 0.0.1
Posted: Mon Jan 11, 2016 11:52 pm
by Airat9000
but you can make the underground pillars? that is, as the cables underground
Re: [Mod 12.20] Player sensitive pressure plates 0.0.1
Posted: Tue Jan 12, 2016 11:42 am
by StanFear
Airat9000 wrote:but you can make the underground pillars? that is, as the cables underground
do you mean having the cable not showing ? sadly, I havn't found a way to do that, maybe someone have but I doubt that ... (I actually have an idea, but it would be a pain in the *** to do and maintain)
and if it was possible, there would be the problem of knowing to which power pole the presure plate is connected
Re: [Mod 12.20] Player sensitive pressure plates 0.0.1
Posted: Wed Jan 13, 2016 9:31 am
by Dr. Walrus
StanFear wrote:this is interesting, and definetly more interesting than some other mod that used concreete to just check presence ... (I think it's advenced logistics or something)
(what follows is only from reading the code, not 100% certains about what I will say)
it's just kinda sad it only works on player, would be interesting to know if an enemy is on it (do they attack it ?)
does it works in multiplayer ?
in your control.lua file, (function removeBPP)
you go through the whole table to know if the entity is a presure plate, (I know you want the id to remove it from the table but ...)
you could just create a pair table with the key being X,Y and then remove it much more easily
and to know if this is a pressure plate : entity.name == "basic-pressure-plate"
Thanks for the help dude. I redid the entire control.lua file from scratch and I now use the x and y position to point to another table that contains some info about the pressure plate. The game now no longer has to search the table when removing a pressure plate and my code overall has gotten a lot simpler.
global.basic_pp_list[entity.position.x .. "," .. entity.position.y] = {basic_pp_entity = entity, mask_entity = pp_mask, x = entity.position.x, y = entity.position.y, active = false}
I got some help from some modders on another thread with my entity sprites render layer so that's one thing to check off my to do list. I should have a new version up in a day or so. It will be completely incompatible with the previous version so heads up. And TBH I'm not really sure I'm going to make a migration script if only nine people have downloaded my mod.
Re: [Mod 12.20] Player sensitive pressure plates 0.0.1
Posted: Wed Jan 13, 2016 5:27 pm
by StanFear
Dr. Walrus wrote:And TBH I'm not really sure I'm going to make a migration script if only nine people have downloaded my mod.
yeah, they probably won't be mad at you (and actually, ..., I have downloaded it but have not yet made a play with it because I'm currently creating my own mod so I don't have anything to play with yet, so.... it's really only 8 people who've downloaded it and play with it.)
plus, if the changes you made are just to make the mod more cpu friendly, they won't need to update !
Re: [Mod 12.20] Player sensitive pressure plates 0.1.0
Posted: Sun Jan 17, 2016 12:12 am
by Dr. Walrus
Updated to 0.1.0! Check out the changelog for what's new. I am going to ask the mods move this mod to the new items, entities, and extensions mods subforum.
Re: [Mod 12.20] Player sensitive pressure plates 0.1.0
Posted: Sun Jan 17, 2016 12:47 am
by Klonan
Dr. Walrus wrote:Updated to 0.1.0! Check out the changelog for what's new. I am going to ask the mods move this mod to the new items, entities, and extensions mods subforum.
Congrats on the release, this mod looks really nice.
I moved it to new items forum for you.
PS your wire shadow offset is a little off
Re: [Mod 12.20+] Player sensitive pressure plates 0.1.0
Posted: Sun Jan 17, 2016 1:20 am
by Dr. Walrus
Klonan wrote:Congrats on the release, this mod looks really nice.
I moved it to new items forum for you.
PS your wire shadow offset is a little off
Thank you Klonan! And congrats on the new job!
And you are right about the wire shadow offset, but you must forgive me because I my entity sprites are edits of the sprite for the small lamp and I took the wire offset from the small lamp entity data. So I looked into it and the wire shadow offset is off on the small lamp too
Re: [Mod 12.20+] Player sensitive pressure plates 0.1.0
Posted: Sat Jan 23, 2016 4:35 am
by malcmiller
This mod is really neat! Are you going to add other types of pressure plates in the future? You should make it so the signal it sends out is customizable like with a constant combinator.
Re: [Mod 12.20+] Player sensitive pressure plates 0.1.0
Posted: Thu Mar 10, 2016 6:33 pm
by binbinhfr
Very nice mod, thanks !
I wish there was also a larger plate (2x2, 3x3 ?) because when you have a lot a exoskelets and move quick , it's not easy to position yourself on the little plate.
By the way, I have a map that makes a problem :
"Error while running the event handler: __Pressure Plate__/control.lua:84: LuaEntity API call when LuaEntity was invalid."
I tried to put 4 plates as a 2x2 pattern to have a better detection surface, but only 2 of them are visible and the invisible ones seems to produce the crash...
It crashs even with no other mod than yours.
I can send you the map if you want (5 mb size).
Re: [Mod 12.20+] Player sensitive pressure plates 0.1.0
Posted: Fri Mar 11, 2016 6:03 am
by Dr. Walrus
binbinhfr wrote:Very nice mod, thanks !
I wish there was also a larger plate (2x2, 3x3 ?) because when you have a lot a exoskelets and move quick , it's not easy to position yourself on the little plate.
By the way, I have a map that makes a problem :
"Error while running the event handler: __Pressure Plate__/control.lua:84: LuaEntity API call when LuaEntity was invalid."
I tried to put 4 plates as a 2x2 pattern to have a better detection surface, but only 2 of them are visible and the invisible ones seems to produce the crash...
It crashs even with no other mod than yours.
I can send you the map if you want (5 mb size).
In response to having larger pressure plates, I think keeping them at 1x1 size makes more sense as a basic structure, and if you want a larger area you can just place them in a 2x2 grid as you did in your map. My goal for the future if I get back to developing more features is to have to plates link together if 2 are placed down next to each other, so that if you build a 2x2 grid of pressure plates they will visually link together and act as a single plate.
First off, did you use the 0.0.1 version and then switch to the 0.1.0 version by any chance? I should take the 0.0.1 version down from here because it is incompatible with the 0.1.0 version and updating from the old version can cause the old plates to crash the game.
If you did not update the mod from the old version, then I know exactly what caused the crash but I don't know how it arose in normal gameplay. The pressure plate that senses the player is actually invisible (which is why nothing shows up when you are trying to place one on the ground). The visual for the pressure plate you see is 2 separate decorative entities. When you place a pressure plate, the mod automatically creates a decoration in the same place. When you step on the plate, the mod deletes the old decoration and places a new one. Somehow when you built the pressure plates the decoration never got built by the mod (which is why they were invisible), and when you step on the plate there's no decoration to be deleted therefore the game crashes.
It would be very helpful if you sent me the map and tell me what version of Factorio you are playing on. I will try to have a fix in a few days. As for a solution right now, try mining and rebuilding the 2 invisible pressure plates to see if they become visible when you rebuild them. If they are visible it means that you can safely walk on them without crashing the game.
Thanks for using my mod.
Re: [Mod 12.20+] Player sensitive pressure plates 0.1.0
Posted: Fri Mar 11, 2016 8:52 am
by binbinhfr
Hi and thanks for answer.
OK for enlarging the zone with several plates, it's ok for me and that's what I did here with a 2x2 pattern. It would be even better if you connect them automatically together as you want to do
I did not use your old version, just the new one.
I am in last factorio 0.12.26
Please find the map as an attachement, with no other mods.
You'll see the plates just at the right of the player. There are 4 of them in a 2x2 pattern, but only the two on the right side of the square are visible. You go on them or try to mine them, it crashes. So I cannot fix them the way you said. Thanks for your help, and let me know if you have a fix.
Re: [Mod 12.20+] Player sensitive pressure plates 0.1.1
Posted: Mon Mar 21, 2016 1:38 am
by Dr. Walrus
Updated to 0.1.1
Sorry for the delay. I've fixed the issue with the crash caused by stepping on invisible plates. If by some chance you manage to build an invisible pressure plate, you can now mine them and if you step on them then turn to normal.
Also I updated the technology icon from something I made in Microsoft paint to something I made in Microsoft word, and I increased the technology cost to 100 red and green for 60 seconds. I only had the technology cost very low for testing purposes at first and this new number seems like an appropriate amount for when you get pressure plates in game.
*EDIT* And now just after I posted the update, I found what caused your pressure plates to go invisible in the first place. If you place concrete or brick over the pressure plate, it automatically erases the pressure plate mask because it is a decorative object. I'll fix that in a bit, but at least it's not game breaking anymore, it just makes the pressure plates go invisible until you step on them again.
Re: [Mod 12.20+] Player sensitive pressure plates 0.1.1
Posted: Sun Mar 27, 2016 5:14 pm
by vanatteveldt
I'm an old DF player, so I have one comment and one question:
- Cool mod! We now have a turing complete system with goblins/biters, mine carts/trains, and pressure plates, so the only things missing in factorio except for ASCII graphics is magma!
- How do we militarize this? If it can detect biters, we need to be able to control something to defeat the biters as well. I'm thinking of controlling gates (to create a live biter trap - although contrary to goblins biters are smart enough to destroy walls), turrets, especially flame thrower turrets, mines, and trains. Wouldn't it be cool to use pressure plates to trap biters into a "kill zone" which is 'patrolled' by trains?
Re: [Mod 12.29+] Player sensitive pressure plates 0.1.2
Posted: Tue Apr 26, 2016 7:05 am
by Dr. Walrus
Updated to 0.1.2! Now pressure plates don't turn invisible if you build concrete or any other floor covering over top of them.
Also a purple pressure plate that can detect biters is in the works. I'm not sure how useful it is because so far the biters just attack it. You win this time nature!
Re: [Mod 12.29+] Player sensitive pressure plates 0.1.2
Posted: Thu Apr 28, 2016 7:27 pm
by Cyber_Garret
Some bug of missing icon, on loading game.
Re: [Mod 12.29+] Player sensitive pressure plates 0.1.2
Posted: Thu Apr 28, 2016 11:53 pm
by Dr. Walrus
Cyber_Garret wrote:Some bug of missing icon, on loading game.
Oops. That was dumb of me. I accidentally deleted it when I was zipping up the mod. Fixed it and updated to v0.1.3
Re: [Mod 12.29+] Player sensitive pressure plates 0.1.3
Posted: Mon May 30, 2016 2:33 pm
by sumdawgy
can you make a train signal compatible version?
If you step on plate, it sets signal red for ....what..10 sec?
Re: [Mod 12.29+] Player sensitive pressure plates 0.1.3
Posted: Wed Jun 01, 2016 8:46 pm
by Dr. Walrus
sumdawgy wrote: can you make a train signal compatible version?
If you step on plate, it sets signal red for ....what..10 sec?
Right now that's actually not possible to make with a mod because train signals can't interact with the circuit network. Fortunately in the 0.13 update train signals will be able to be controlled by the circuit network so you can make a contraption that does that with just a regular pressure plate and a few combinators. If it can't be built in vanilla then I'll add in a pressure plate train signal after the 0.13 update comes out.