[Mod] Gates [1.8] [gates]

User avatar
Splizard
Member
Posts: 227
Joined: Wed Jan 25, 2012 07:20
GitHub: Splizard
IRC: Splizard
In-game: Splizard
Location: New Zealand
Contact:

[Mod] Gates [1.8] [gates]

by Splizard » Post

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.

Image

Download

Crafting:

Image Image

Image Image

Image Image

3D gates:
Image

If you have xFences mod the fences connect to the short gates:
Image

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/later
Textures: Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)

Github: https://github.com/Splizard/minetest-mod-gates
Website: http://minetest.splizard.com/mods/gates/ (May not always be online)

Changelog:

Version 1.0
  • Initial release
Version 1.1
  • Added Temperest's code
  • Added Mesecon version
  • Added Readme file
Version 1.2
  • Bugfixes
Version 1.3
  • Added inventory tooltip
Version 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.6
  • Added 3D gates
Version 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://splizard.com/mods/gates/gates-1.8.zip (Version 1.8)
http://splizard.com/mods/gates/gates-1.6.zip (Version 1.6)
http://splizard.com/mods/gates/gates-1.5.zip (Version 1.5)
http://splizard.com/mods/gates/gates-1.4.zip (Version 1.4)
http://splizard.com/mods/gates/gates-1.3.zip (Version 1.3)
http://splizard.com/mods/gates/gates-1.2.zip (Version 1.2)
http://splizard.com/mods/gates/gates-1.1.zip (Version 1.1)
http://splizard.com/mods/gates/gates-1.0.zip (Version 1.0)
Attachments
gates.jpg
gates.jpg (310.62 KiB) Viewed 2008 times
Last edited by Splizard on Mon Apr 23, 2018 12:03, edited 4 times in total.
Games: Builda City, The Hungry Games Mods: Lifters, Snow Biomes and Gates. Also checkout my texture pack Gridtoon!

User avatar
Calinou
Moderator
Posts: 3169
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou
Location: Troyes, France
Contact:

by Calinou » Post

Do want in official game. Like it... and it looks fine. :)

User avatar
rinoux
Member
Posts: 184
Joined: Tue Dec 27, 2011 12:15

by rinoux » Post

Thank you for this great mod, my castle will look better.

sfan5
Moderator
Posts: 4094
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

+2
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

User avatar
Splizard
Member
Posts: 227
Joined: Wed Jan 25, 2012 07:20
GitHub: Splizard
IRC: Splizard
In-game: Splizard
Location: New Zealand
Contact:

by Splizard » Post

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.
Last edited by Splizard on Thu Jan 26, 2012 20:59, edited 1 time in total.
Games: Builda City, The Hungry Games Mods: Lifters, Snow Biomes and Gates. Also checkout my texture pack Gridtoon!

Temperest
Member
Posts: 651
Joined: Tue Nov 15, 2011 23:13
GitHub: Uberi

by Temperest » Post

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:

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.
Last edited by Temperest on Sun Jan 29, 2012 18:11, edited 1 time in total.
WorldEdit 1.0 released

The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.

User avatar
Splizard
Member
Posts: 227
Joined: Wed Jan 25, 2012 07:20
GitHub: Splizard
IRC: Splizard
In-game: Splizard
Location: New Zealand
Contact:

by Splizard » Post

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.
Games: Builda City, The Hungry Games Mods: Lifters, Snow Biomes and Gates. Also checkout my texture pack Gridtoon!

User avatar
neko259
Member
Posts: 805
Joined: Sun Jun 19, 2011 06:51

by neko259 » Post

This mod is great! I use it for doors, but it's more universal.
s3tuPDfUv2IyvXHzPmE31MQvnWULv1zj

User avatar
Splizard
Member
Posts: 227
Joined: Wed Jan 25, 2012 07:20
GitHub: Splizard
IRC: Splizard
In-game: Splizard
Location: New Zealand
Contact:

by Splizard » Post

Version 1.2
Fixed a bug: While creating a gate another gate would appear on top of the original gate.
Games: Builda City, The Hungry Games Mods: Lifters, Snow Biomes and Gates. Also checkout my texture pack Gridtoon!

Temperest
Member
Posts: 651
Joined: Tue Nov 15, 2011 23:13
GitHub: Uberi

by Temperest » Post

I noticed that the mesecon registration at the bottom is commented out in the mesecon version. Was this intentional?
WorldEdit 1.0 released

The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.

kahrl
Member
Posts: 236
Joined: Fri Sep 02, 2011 07:51
Location: Rös̓̇chenhof

by kahrl » Post

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.

Temperest
Member
Posts: 651
Joined: Tue Nov 15, 2011 23:13
GitHub: Uberi

by Temperest » Post

That sounds like a great idea - I'm in favor of it.
WorldEdit 1.0 released

The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.

User avatar
Splizard
Member
Posts: 227
Joined: Wed Jan 25, 2012 07:20
GitHub: Splizard
IRC: Splizard
In-game: Splizard
Location: New Zealand
Contact:

by Splizard » Post

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
Games: Builda City, The Hungry Games Mods: Lifters, Snow Biomes and Gates. Also checkout my texture pack Gridtoon!

Temperest
Member
Posts: 651
Joined: Tue Nov 15, 2011 23:13
GitHub: Uberi

by Temperest » Post

Adding the following to line 88 gives proper tooltips in inventory views:

Code: Select all

description = "Gate",
I hope you'll consider including it.
WorldEdit 1.0 released

The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.

User avatar
Splizard
Member
Posts: 227
Joined: Wed Jan 25, 2012 07:20
GitHub: Splizard
IRC: Splizard
In-game: Splizard
Location: New Zealand
Contact:

by Splizard » Post

Updated to 1.3
Added inventory tooltips
Games: Builda City, The Hungry Games Mods: Lifters, Snow Biomes and Gates. Also checkout my texture pack Gridtoon!

sfan5
Moderator
Posts: 4094
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

Minetest Mod Spotlight - Gates 1.3
http://www.youtube.com/watch?v=uZHrin-7lqg
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

User avatar
MirceaKitsune
Member
Posts: 924
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune
Location: Romania, Bucharest

by MirceaKitsune » Post

+1. I wouldn't quite agree with doors opening in all directions for a default mod, but other than that I like this :)

Gatharoth
Member
Posts: 196
Joined: Thu Dec 22, 2011 02:54

by Gatharoth » Post

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

Jordach
Member
Posts: 4534
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach
Location: Blender Scene

by Jordach » Post

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.

User avatar
lalorobot
Member
Posts: 32
Joined: Wed Feb 15, 2012 17:37
Location: Canada

by lalorobot » Post

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/
Last edited by lalorobot on Thu Feb 16, 2012 00:38, edited 1 time in total.
Mods make minetest even better and maybe getting better than minecraft with some time
my maps: http://c55.me/minetest/forum/viewtopic.php?id=1359

bob
Member
Posts: 66
Joined: Thu Feb 16, 2012 00:59

by bob » Post

nice your now my #1 mod make eveyone it is a very good mod with smart tricks in it

User avatar
Splizard
Member
Posts: 227
Joined: Wed Jan 25, 2012 07:20
GitHub: Splizard
IRC: Splizard
In-game: Splizard
Location: New Zealand
Contact:

by Splizard » Post

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.
Games: Builda City, The Hungry Games Mods: Lifters, Snow Biomes and Gates. Also checkout my texture pack Gridtoon!

User avatar
lalorobot
Member
Posts: 32
Joined: Wed Feb 15, 2012 17:37
Location: Canada

by lalorobot » Post

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
Mods make minetest even better and maybe getting better than minecraft with some time
my maps: http://c55.me/minetest/forum/viewtopic.php?id=1359

User avatar
IPushButton2653
Member
Posts: 666
Joined: Wed Nov 16, 2011 22:47
Location: Mississippi
Contact:

by IPushButton2653 » Post

Best doors I've seen.

Temperest
Member
Posts: 651
Joined: Tue Nov 15, 2011 23:13
GitHub: Uberi

by Temperest » Post

Here's an update with iron doors, which only open with mesecon signals!

http://goo.gl/DiOfV

Useful 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.
Last edited by Temperest on Tue Feb 28, 2012 23:10, edited 1 time in total.
WorldEdit 1.0 released

The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.

Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests