Page 1 of 3
[Mod] Gates [1.8] [gates]

Posted:
Thu Jan 26, 2012 08:45
by Splizard
This mod adds 3d gates to minetest.
Toggle a gate by clicking on it. Iron gates can be toggled only by mesecon signals.
You can stack the gates to create doors that open with a single click.
They can also be used as windows that open.
DownloadCrafting:



3D gates:

If you have xFences mod the fences connect to the short gates:
Video: http://www.youtube.com/watch?v=uZHrin-7lqg (version 1.3)
Minimum Minetest version: 0.4.9
Depends: default,
mesecons (optional),
xFences (recommended)
License: GPLv2/laterTextures: Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)Github: https://github.com/Splizard/minetest-mod-gatesWebsite: http://minetest.splizard.com/mods/gates/ (May not always be online)
Changelog:Version 1.0Version 1.1- Added Temperest's code
- Added Mesecon version
- Added Readme file
Version 1.2Version 1.3Version 1.4- Added iron gates in mesecons version
- Updated textures
Version 1.5- Complete rewrite of code
- Added API for making new gates
- Fixed iron gate bugs
NOTICE: Version 1.5 is not backwards compatible with the previous versions of this mod!
Version 1.6Version 1.8- Make iron gates only usable by the placer.
- Remove mesecon support.
- Update gates API.
- Open with right click.
Specific Version links: (Only download these if you need a previous version)
http://minetest.splizard.com/mods/gates/gates-1.8.zip (Version 1.8)
http://minetest.splizard.com/mods/gates/gates-1.6.zip (Version 1.6)
http://minetest.splizard.com/mods/gates/gates-1.5.zip (Version 1.5)
http://minetest.splizard.com/mods/gates/gates-1.4.zip (Version 1.4)
http://minetest.splizard.com/mods/gates/gates-1.3.zip (Version 1.3)
http://minetest.splizard.com/mods/gates/gates-1.2.zip (Version 1.2)
http://minetest.splizard.com/mods/gates/gates-1.1.zip (Version 1.1)
http://minetest.splizard.com/mods/gates/gates-1.0.zip (Version 1.0)

Posted:
Thu Jan 26, 2012 09:33
by Calinou
Do want in official game. Like it... and it looks fine. :)

Posted:
Thu Jan 26, 2012 09:37
by rinoux
Thank you for this great mod, my castle will look better.

Posted:
Thu Jan 26, 2012 15:35
by sfan5
+2

Posted:
Thu Jan 26, 2012 20:58
by Splizard
Forgot to show the crafting recipe! Fixed now.
I will be keeping the textures as they are now.
Although I would like to be able to open both gates if connected with one click,
any idea how I would go about this?
Somthing similar to how in mesecons, sending power to one item will activate all items attached to the first.

Posted:
Sun Jan 29, 2012 18:10
by Temperest
Splizard wrote:Although I would like to be able to open both gates if connected with one click,
any idea how I would go about this?
Somthing similar to how in mesecons, sending power to one item will activate all items attached to the first.
I've done it:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
-- Local constants
-- This _has_ to be set to 1
local GATE_OPENED = 2
-- This has to be != from GATE_OPENED and is coded on 4 bits
local GATE_CLOSED = 1
-- Local Functions
local on_gate_punched = function(pos, node, puncher)
if (node.name ~= 'gates:gate_closed')
and (node.name ~= 'gates:gate_opened') then
return
end
local state = node.param2
local toggle_gate = function(pos, state)
local nodename = ""
local param2 = ""
-- Switch the gate state when hit
if state == GATE_OPENED then
nodename = 'gates:gate_closed'
param2 = GATE_CLOSED
elseif state == GATE_CLOSED then
nodename = 'gates:gate_opened'
param2 = GATE_OPENED
else
print('Uninitialized node: ' .. state)
return
end
minetest.env:add_node(pos, {
name = nodename,
param2 = param2,
})
end
toggle_gate(pos, state)
--handle gates above this one
local lpos = {x=pos.x, y=pos.y, z=pos.z}
while true do
lpos.y = lpos.y+1
local lnode = minetest.env:get_node(lpos)
if (lnode.name ~= "gates:gate_closed" and lnode.name ~= "gates:gate_opened") then
break
end
toggle_gate(lpos, state)
end
--handle gates below this one
local lpos = {x=pos.x, y=pos.y, z=pos.z}
while true do
lpos.y = lpos.y-1
local lnode = minetest.env:get_node(lpos)
if (lnode.name ~= "gates:gate_closed" and lnode.name ~= "gates:gate_opened") then
break
end
toggle_gate(lpos,state)
end
end
local on_gate_placed = function(pos, node, placer)
if node.name ~= 'gates:gate_closed' then
return
end
minetest.env:add_node(pos, {
name = node.name,
param2 = GATE_OPENED,
})
end
-- Nodes
-- As long as param2 is set to 1 for open gates, it doesn't matter to
-- use drawtype = 'signlike'
minetest.register_node('gates:gate_opened', {
drawtype = 'plantlike',
visual_scale = 1.5,
tile_images = {'gate_open.png'},
sunlight_propagates = true,
paramtype = 'light',
walkable = false,
material = minetest.digprop_constanttime(1.0),
drop = "gates:gate_closed",
})
minetest.register_node('gates:gate_closed', {
tile_images = {'gate_top.png','gate_top.png','gate.png'},
sunlight_propagates = true,
paramtype = 'light',
walkable = true,
material = minetest.digprop_constanttime(1.0),
})
-- Crafts
minetest.register_craft({
output = '"gates:gate_closed" 2',
recipe = {
{"default:stick", "default:wood", "default:stick"},
{"default:stick", "default:wood", "default:stick"},
},
})
-- Change the gate state
minetest.register_on_punchnode(on_gate_punched)
-- Reset param2 for open gates
minetest.register_on_placenode(on_gate_placed)
-- Mesecon Stuff:
--mesecon:register_on_signal_on(on_gate_punched)
--mesecon:register_on_signal_off(on_gate_punched)
print("[Gates] Loaded!")
Punching a gate node now opens or closes all nodes above or below it. Also fixed a bug with the on_placenode routine.
Just place two or more gates an top of each other and punching any of them will toggle the gate state.
Speaking of mesecons, I've tried to add mesecon actuation (commented out at the bottom), but it fails because the name "mesecons" is nil. It's unusual since the hatches mod had worked just fine.

Posted:
Sun Jan 29, 2012 22:07
by Splizard
Thank you Temperest
the mod is now updated with your code :)
The reason that mesecons returns nil is because jeija needs to be added to depends.txt
I have included the mesecon version in the mod.

Posted:
Sun Jan 29, 2012 22:21
by neko259
This mod is great! I use it for doors, but it's more universal.

Posted:
Mon Jan 30, 2012 02:08
by Splizard
Version 1.2
Fixed a bug: While creating a gate another gate would appear on top of the original gate.

Posted:
Mon Jan 30, 2012 02:47
by Temperest
I noticed that the mesecon registration at the bottom is commented out in the mesecon version. Was this intentional?

Posted:
Mon Jan 30, 2012 02:51
by kahrl
Do you think optional dependencies would be useful here? So this mod (hatches too) could have an optional dependency on mesecons, which would mean: make sure mesecons is loaded first, but only if it is loaded at all. Then check if mesecon ~= nil and only in that case register with it.

Posted:
Mon Jan 30, 2012 03:16
by Temperest
That sounds like a great idea - I'm in favor of it.

Posted:
Mon Jan 30, 2012 03:16
by Splizard
Temperest wrote:I noticed that the mesecon registration at the bottom is commented out in the mesecon version. Was this intentional?
Whoops :D
Fixed now, please download gates 1.2 again.
kahrl wrote:Do you think optional dependencies would be useful here? So this mod (hatches too) could have an optional dependency on mesecons, which would mean: make sure mesecons is loaded first, but only if it is loaded at all. Then check if mesecon ~= nil and only in that case register with it.
Yes, it would be more efficient. It is anoying to create two different versions or for the user to manually edit the mod just for a few lines of code eg. gates or hatches + mesecons

Posted:
Tue Jan 31, 2012 04:00
by Temperest
Adding the following to line 88 gives proper tooltips in inventory views:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
I hope you'll consider including it.

Posted:
Wed Feb 01, 2012 20:27
by Splizard
Updated to 1.3
Added inventory tooltips

Posted:
Thu Feb 02, 2012 17:54
by sfan5

Posted:
Mon Feb 13, 2012 16:34
by MirceaKitsune
+1. I wouldn't quite agree with doors opening in all directions for a default mod, but other than that I like this :)

Posted:
Wed Feb 15, 2012 08:45
by Gatharoth
Okay, so how exactly does the open gate look the way it does? Is it cause of plantlike drawtype? Or is it because of the visual scale? Or the combination of both? Or is it something else?? O.O

Posted:
Wed Feb 15, 2012 11:21
by Jordach
When ounched the node def does change to plantlike, all he has done is remove part of the middle to appear like the gate is open. Nothing too hard here. Just a really clever trick.

Posted:
Thu Feb 16, 2012 00:38
by lalorobot
It looks so great! but I cant craft it! maybe it is the way or where I put it? I made this: I went to the data folder and then made a folder in there called mods and in the mods folder I made another folder (XD) with the name gates-1.3 and tried crafting nothing....I left the init.lua script in the folder only and it did not worked! what I did wrong? help I am new with mods
I taked where and how to put mods from here:
http://minetest.com/category/mods/

Posted:
Thu Feb 16, 2012 01:04
by bob
nice your now my #1 mod make eveyone it is a very good mod with smart tricks in it

Posted:
Thu Feb 16, 2012 01:07
by Splizard
It looks so great! but I cant craft it! maybe it is the way or where I put it? I made this: I went to the data folder and then made a folder in there called mods and in the mods folder I made another folder (XD) with the name gates-1.3 and tried crafting nothing....I left the init.lua script in the folder only and it did not worked! what I did wrong? help I am new with mods
I taked where and how to put mods from here:
http://minetest.com/category/mods/
To install it copy the gates folder inside gates1.3 to your mods folder.
If you have the mesecons mod installed, copy the gates folder inside gates1.3/mesecons instead.

Posted:
Fri Feb 17, 2012 20:15
by lalorobot
Splizard wrote:It looks so great! but I cant craft it! maybe it is the way or where I put it? I made this: I went to the data folder and then made a folder in there called mods and in the mods folder I made another folder (XD) with the name gates-1.3 and tried crafting nothing....I left the init.lua script in the folder only and it did not worked! what I did wrong? help I am new with mods
I taked where and how to put mods from here:
http://minetest.com/category/mods/
To install it copy the gates folder inside gates1.3 to your mods folder.
If you have the mesecons mod installed, copy the gates folder inside gates1.3/mesecons instead.
Thanks! :D

Posted:
Fri Feb 17, 2012 22:45
by IPushButton2653
Best doors I've seen.

Posted:
Tue Feb 28, 2012 23:09
by Temperest
Here's an update with iron doors, which only open with mesecon signals!
http://goo.gl/DiOfVUseful in conjunction with the node ownership mod, which can prevent the placement of mesecons near the door to force it to open.
Also updated all the textures, so the gates should be more visible now.

Posted:
Thu Mar 01, 2012 01:17
by Splizard
Temperest wrote:Here's an update with iron doors, which only open with mesecon signals!
http://goo.gl/DiOfVUseful in conjunction with the node ownership mod, which can prevent the placement of mesecons near the door to force it to open.
Also updated all the textures, so the gates should be more visible now.
Thanks Temperest!
I have updated the mod to include iron gates :)

Posted:
Tue Mar 20, 2012 23:20
by Splizard
Version 1.5 is out now!
I have done a rewrite of the code and this is no longer based on hatches mod.
There is also an API now to create new types of gates easily.
This version IS NOT backwards compatible with any previous versions.

Posted:
Tue Mar 20, 2012 23:31
by RAPHAEL
"Could not locate object" when trying to download latest

Posted:
Wed Mar 21, 2012 02:08
by Splizard
RAPHAEL wrote:"Could not locate object" when trying to download latest
oops, the download link works now.

Posted:
Wed Jun 27, 2012 00:41
by Splizard
3D gates now included!
You need the latest nightly build for this.