[Mod] Mesecons (= redstone) [GitHub] [minetest-mod-mesecons]

User avatar
Jeija
Member
 
Posts: 686
Joined: Fri Dec 23, 2011 21:46

by Jeija » Sat Mar 09, 2013 14:30

There already exists a battery extension, here: https://github.com/Jeija/mesecons-extension-battery
Unfortunately it is not compatible with the latest mesecons API, needs some minor porting which has not been done yet because apparently noone used that extension. Would you give porting a try? See mesecons.net/developers.php for information, if you can't code I will do it for you but expect it to take some time.
Redstone for minetest: Mesecons (mesecons.net)
 

User avatar
RealBadAngel
Member
 
Posts: 556
Joined: Wed Jul 18, 2012 16:30

by RealBadAngel » Sat Mar 09, 2013 15:45

Batteries, energy storage is what Technic is doing. Mesecons are TTL (logic) signals. IMHO if something was about to store mesecons signals it shouldnt be called a battery, but RAM.
 

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

by Temperest » Sat Mar 09, 2013 16:52

I'll have a crack at porting the battery extension, since I hate seeing mods get outdated :)

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
for i = 1, 5 do
    minetest.register_node("mesecons_battery:battery_charging_"..i, {
        drawtype = "nodebox",
        tiles = {"jeija_battery_charging.png"},
        paramtype = "light",
        is_ground_content = true,
        walkable = true,
        node_box = {
            type = "fixed",
            fixed = {
                {-0.499, -0.499, -0.499, -0.4,   0.499,       0.499},
                { 0.4, -0.499, -0.499,  0.499,   0.499,       0.499},
                {-0.499, -0.499, -0.499,  0.499, 0.499,      -0.4  },
                {-0.499, -0.499,  0.4,  0.499, 0.499,       0.499  },
                {-0.4  , -0.5  , -0.4  ,  0.4  , 1*(i/5)-0.5, 0.4}}
        },
        selection_box = {
            type = "fixed",
            fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
        },
        groups = {dig_immediate=2, mesecon = 2},
            description="Battery",
        on_construct = function(pos)
            meta = minetest.env:get_meta(pos)
            meta:set_int("batterystate", i*20-19)
            meta:set_int("charging", 0)
        end,
        on_punch = function(pos, node, puncher)
            local meta = minetest.env:get_meta(pos);
            local batterystate = meta:get_int("batterystate")
            local charging = meta:get_int("charging")
            mesecon:swap_node(pos, "mesecons_battery:battery_discharging_" .. i)
            meta:set_int("batterystate", batterystate)
            meta:set_int("charging", charging)
        end,
        mesecons = {effector = {
            action_on = function(pos, node)
                minetest.env:get_meta(pos):set_int("charging", 1)
            end,
            action_off = function(pos, node)
                minetest.env:get_meta(pos):set_int("charging", 0)
            end,
        }}
    })
end

for i = 1, 5 do
    minetest.register_node("mesecons_battery:battery_discharging_"..i, {
        drawtype = "nodebox",
        tiles = {"jeija_battery_discharging.png"},
        paramtype = "light",
        is_ground_content = true,
        walkable = true,
        node_box = {
            type = "fixed",
            fixed = {
                {-0.499, -0.499, -0.499, -0.4,   0.499,       0.499},
                { 0.4, -0.499, -0.499,  0.499,   0.499,       0.499},
                {-0.499, -0.499, -0.499,  0.499, 0.499,      -0.4  },
                {-0.499, -0.499,  0.4,  0.499, 0.499,       0.499  },
                {-0.4  , -0.5  , -0.4  ,  0.4  , 1*(i/5)-0.5, 0.4}}
        },
        selection_box = {
            type = "fixed",
            fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
        },
        groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon = 2},
            description="Battery",
        on_construct = function(pos)
            meta = minetest.env:get_meta(pos)
            meta:set_int("batterystate", i*20-19)
            meta:set_int("charging", 0)
        end,
        on_punch = function(pos, node, puncher)
            local meta = minetest.env:get_meta(pos);
            local batterystate = meta:get_int("batterystate")
            local charging = meta:get_int("charging")
            mesecon:swap_node(pos, "mesecons_battery:battery_charging_" .. i)
            meta:set_int("batterystate", batterystate)
            meta:set_int("charging", charging)
        end,
        mesecons = {
            effector = {
                action_on = function(pos, node)
                    minetest.env:get_meta(pos):set_int("charging", 1)
                end,
                action_off = function(pos, node)
                    minetest.env:get_meta(pos):set_int("charging", 0)
                end,
            },
            receptor = {
                state = mesecon.state.on
            },
        }
    })
end

minetest.register_abm({
    nodenames = {"mesecons_battery:battery_charging_1", "mesecons_battery:battery_charging_2", "mesecons_battery:battery_charging_3", "mesecons_battery:battery_charging_4", "mesecons_battery:battery_charging_5"},
    interval = 1,
    chance = 1,
    action = function(pos, node, active_object_count, active_object_count_wider)
        local meta = minetest.env:get_meta(pos);
        if meta:get_int("charging") == 1 then
            local batterystate = meta:get_int("batterystate")
            local charging = meta:get_int("charging")
            local name = node.name;
            if batterystate < 100 then --change battery charging state
                batterystate = batterystate + 1
            else
                mesecon:swap_node(pos, string.gsub(node.name, "charging", "discharging"))
            end

            if string.find(node.name, tostring(math.ceil(batterystate/20))) == nil then
                node.name = string.gsub(node.name, tostring(math.ceil(batterystate/20)-1), tostring(math.ceil(batterystate/20))) --change node for new nodebox model
            end
            minetest.env:add_node(pos, node)
            meta:set_int("batterystate", batterystate)
            meta:set_int("charging", charging)
        end
    end,
})

minetest.register_abm({
    nodenames = {"mesecons_battery:battery_discharging_1", "mesecons_battery:battery_discharging_2", "mesecons_battery:battery_discharging_3", "mesecons_battery:battery_discharging_4", "mesecons_battery:battery_discharging_5"},
    interval = 1,
    chance = 1,
    action = function(pos, node, active_object_count, active_object_count_wider)
        local meta = minetest.env:get_meta(pos);
        local batterystate = meta:get_int("batterystate")
        local charging = meta:get_int("charging")
        local name = node.name;
        if batterystate > 1 then --change battery charging state
            batterystate = batterystate - 1
        else
            mesecon:swap_node(pos, string.gsub(node.name, "discharging", "charging"))
        end

        if string.find(node.name, tostring(math.ceil(batterystate/20))) == nil then
            node.name = string.gsub(node.name, tostring(math.ceil(batterystate/20)+1), tostring(math.ceil(batterystate/20))) --change node for new nodebox model
        end
        minetest.env:add_node(pos, node)
        meta:set_int("batterystate", batterystate)
        meta:set_int("charging", charging)
    end,
})


Completely untested.
WorldEdit 1.0 released

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

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

by VanessaE » Sat Mar 09, 2013 17:21

Well technically all TTL signals in the real world do have a tiny amount of possible current (a few micro amps), and it is common to use things such as capacitors to store small amounts of it for later use. Indeed, RAM chips do something like this. I use a transistor-resistor-capacitor circuit in one of my real projects to store charge from a high-is-inactive TTL signal in order to light an LED when the signal drops (goes active).

So if you call it anything, call it a capacitor. It isn't a RAM until you have switching and sensing circuitry around it to interpret the charge stored therein.
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

User avatar
Jeija
Member
 
Posts: 686
Joined: Fri Dec 23, 2011 21:46

by Jeija » Sun Mar 10, 2013 07:26

RealBadAngel wrote:Batteries, energy storage is what Technic is doing. Mesecons are TTL (logic) signals. IMHO if something was about to store mesecons signals it shouldnt be called a battery, but RAM.

I totally agree, it doesn't make sense to have something like a battery. That's why it's not in mesecons core and why I didn't update it.
However, sometimes people request a "battery", not a "capacitor" or "Bistable multivibrator circuit", so I made a battery for those that want it.
Redstone for minetest: Mesecons (mesecons.net)
 

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

by VanessaE » Sun Mar 10, 2013 21:17

Here's a weird one I've never seen happen before:

17:14:15: ACTION[ServerThread]: xxxxxxxxxxxxx digs mesecons:wire_10010000_on at (-341,15,-365)
17:16:29: ERROR[main]: ERROR: An unhandled exception occurred: ServerError: LuaError: error: ...ame/mods/minetest-mod-mesecons/mesecons/internal.lua:232: stack overflow
17:16:29: ERROR[main]: stack traceback:

In thread 7f85e5875740:
/home/vanessa/Minetest-Textures-and-mods/minetest/src/main.cpp:1914: int main(int, char**): Assertion '0' failed.
Debug stacks:
DEBUG STACK FOR THREAD 7f85e5875740:
#0 int main(int, char**)
(Leftover data: #1 Dedicated server branch)
(Leftover data: #2 virtual void ServerMap::save(ModifiedState))
(Leftover data: #3 virtual void ServerMap::saveBlock(MapBlock*))
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

by VanessaE » Sun Mar 10, 2013 21:35

Also, please add "overheat" protection to mesecon torches. Someone on my server figured out a simple lag machine using one of these.
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

User avatar
Jeija
Member
 
Posts: 686
Joined: Fri Dec 23, 2011 21:46

by Jeija » Mon Mar 11, 2013 15:44

Mesecon torches actually shouldn't overheat, they use ABMs... What does that lag machine look like?
Unfortunately your error message could mean anyhting... Is it reproducable, when does it occur?
Redstone for minetest: Mesecons (mesecons.net)
 

User avatar
jojoa1997
Member
 
Posts: 2890
Joined: Thu Dec 13, 2012 05:11

by jojoa1997 » Mon Mar 11, 2013 16:05

Jeija wrote:Mesecon torches actually shouldn't overheat, they use ABMs... What does that lag machine look like?
Unfortunately your error message could mean anyhting... Is it reproducable, when does it occur?
yes it is and i will send a pm so others cant use it
Coding;
1X coding
3X debugging
12X tweaking to be just right
 

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

by Temperest » Mon Mar 11, 2013 16:27

Does the "lag machine" use gates or sockets? These are both capable of causing a stack overflow as you described.

As Jeija said, torches are unable to cause infinite recursion as they use the MineTest engine as a trampoline.
WorldEdit 1.0 released

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

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Mon Mar 11, 2013 16:43

Temperest wrote:MineTest

It is Minetest, not MineTest.
 

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

by Temperest » Mon Mar 11, 2013 16:52

Thanks, autocorrect seems to change it. In any case, it's perfectly clear what was meant.
WorldEdit 1.0 released

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

User avatar
Jeija
Member
 
Posts: 686
Joined: Fri Dec 23, 2011 21:46

by Jeija » Mon Mar 11, 2013 16:53

I read your PM, but that circuit doesn't lag at all...
Instead it causes a "glitch" in pistons that prevents lagging.

If there is no danger of someone using that to cause lags on servers, I'd like to publish the PM here, or is there something I missed?
Redstone for minetest: Mesecons (mesecons.net)
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Mon Mar 11, 2013 17:28

Since we have lavacooling in the latest dev version of minetest_game, here is an infinte stone generator:
Image
Note: The piston above the stone is sticky.
Note2: There are 3 delayers between the and-gate and the sticky piston. All of them have max delay.
Last edited by PilzAdam on Mon Mar 11, 2013 17:29, edited 1 time in total.
 

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

by VanessaE » Mon Mar 11, 2013 17:37

Well in my case, I watched jojoa built the circuit on my server. When the last piece is put into place, it causes the server to instantly lock at 100% CPU, stay there for a while (about two minutes), and then the server crashes and exits, which I presume is that stack overflow.

I have sent you a private message with construction info and a screenshot of the offending circuit, which I tested in singleplayer mode with mesecons pulled about an hour before writing this post.

I noticed that it doesn't always lag the server. Sometimes, it just works without issue.
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

User avatar
jojoa1997
Member
 
Posts: 2890
Joined: Thu Dec 13, 2012 05:11

by jojoa1997 » Mon Mar 11, 2013 18:45

VanessaE wrote:Well in my case, I watched jojoa built the circuit on my server. When the last piece is put into place, it causes the server to instantly lock at 100% CPU, stay there for a while (about two minutes), and then the server crashes and exits, which I presume is that stack overflow.

I have sent you a private message with construction info and a screenshot of the offending circuit, which I tested in singleplayer mode with mesecons pulled about an hour before writing this post.

I noticed that it doesn't always lag the server. Sometimes, it just works without issue.
thats what i noticed on my singleplayer worlds. it never ever locks up. i just have to reset it by turning the construction on and off manually
Coding;
1X coding
3X debugging
12X tweaking to be just right
 

User avatar
qwrwed
Member
 
Posts: 323
Joined: Sun Jul 22, 2012 20:56
In-game: qwrwed or Nitro

by qwrwed » Tue Mar 12, 2013 15:57

I get this error when trying to start the game:
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
15:50:36: ERROR[main]: ServerError: LuaError: error: ...orlds\Frantic Mine Ride\worldmods\carts/mesecons.lua:3: attempt to call method 'register_on_signal_on' (a nil value)
15:50:36: ERROR[main]: stack traceback:
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Tue Mar 12, 2013 16:27

qwrwed wrote:I get this error when trying to start the game:
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
15:50:36: ERROR[main]: ServerError: LuaError: error: ...orlds\Frantic Mine Ride\worldmods\carts/mesecons.lua:3: attempt to call method 'register_on_signal_on' (a nil value)
15:50:36: ERROR[main]: stack traceback:

You probably use a (very) old version of carts. Downloading the latest version of carts should fix it.
 

User avatar
qwrwed
Member
 
Posts: 323
Joined: Sun Jul 22, 2012 20:56
In-game: qwrwed or Nitro

by qwrwed » Tue Mar 12, 2013 17:00

Ah, I see - it was in the worldmods folder. (I only noticed the "mesecons" part)
Last edited by qwrwed on Tue Mar 12, 2013 17:01, edited 1 time in total.
 

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

by Temperest » Fri Mar 15, 2013 20:18

I finally got around to setting up the Mesecons Laboratory!

See the forum topic for more details:

http://forum.minetest.net/viewtopic.php?pid=75996

Image
WorldEdit 1.0 released

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

User avatar
Tedypig
Member
 
Posts: 284
Joined: Tue Mar 05, 2013 12:33
IRC: Piggybear87
In-game: Piggybear

by Tedypig » Sun Mar 17, 2013 17:42

Which one is the newest?
Image



EDIT: 100th POST BAAAAYYYYBBBBBEEEEEE!!!!!!
Image
Last edited by Tedypig on Sun Mar 17, 2013 17:44, edited 1 time in total.
01010100 01100101 01100100 01111001 01110000 01101001 01100111
 

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

by Temperest » Sun Mar 17, 2013 17:58

Neither. Both are several days old. There have been quite a few changes to movestones and luacontrollers in that time.

Try downloading it again, the link is in the first post.
WorldEdit 1.0 released

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

rarkenin
Member
 
Posts: 668
Joined: Tue Nov 20, 2012 20:48

by rarkenin » Sat Mar 23, 2013 16:05

Can you implement a movestone that removes the node ahead of it, instead of pushing it?

A turntable to turn nodes such as movestones for complex electromechanical systems?
Admin pro tempore on 0gb.us:30000. Ask me if you have a problem, or just want help.
This is a signature virus. Add me to your signature so that I can multiply.
Now working on my own clone, Mosstest.
I guess I'm back for some time.
 

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

by Temperest » Sat Mar 23, 2013 16:19

A device that removes the node in front of it? Try Technic's node breakers. They respond to mesecon signals, too.

Movestones always move along a conductive rail. Turning the movestone has no effect - it will still move along the rail it is attached to. You can make more complex stuff with pistons working together with movestones - I made a movestone loop the other day for an in-game 3D scanner:

Image
WorldEdit 1.0 released

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

Nore
Member
 
Posts: 468
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs

by Nore » Sat Mar 23, 2013 16:46

How does it work? I don't understand how it detects the presence of a node.
 

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

by Temperest » Sat Mar 23, 2013 17:00

Well, at the moment there is a button in the center there that I press to make it move once around the loop. However, you can easily put a node detector there using a solar panel and a lamp with a space between them. The solar panel turns off whenever there is a node blocking the light from the lamp. I reduced the solar panel threshold value a while back specifically so this could be done.
WorldEdit 1.0 released

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

Nore
Member
 
Posts: 468
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs

by Nore » Sat Mar 23, 2013 17:04

And how will it detect all the blocks? The pistons will have a problem too if there are holes in the structure.
 

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

by Temperest » Sat Mar 23, 2013 17:29

That's right, there are limitations as to what the scanner is capable of. For one, the scanner disassembles the structure into a long line of nodes using a bunch of pistons (this part is a work in progress). They are then sent off to a node detector, which is capable of detecting three types of nodes: solid, transparent, and falling (not shown in picture). The node detector is hooked up to a luacontroller that records all the scan results into a 3D array.

Since I already built the 3D printer with 3 different "inks", it is possible to duplicate structures!

Everything is tied together with mesecons and digilines. I planned for the printer to be the next Laboratory article, but I think I'd better introduce the node detector first.
WorldEdit 1.0 released

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

Nore
Member
 
Posts: 468
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs

by Nore » Sat Mar 23, 2013 17:39

A suggestion: rules for top/bottom conduction for down/up pistons.
 

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

by Temperest » Sat Mar 23, 2013 18:22

I like that idea. The only thing that it would be able to connect to, though is the MESE block, since that would be the only other node with an exposed upwards/downwards pointing rule.

Maybe a poll is in order.
WorldEdit 1.0 released

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

PreviousNext

Return to Mod Releases

Who is online

Users browsing this forum: No registered users and 89 guests

cron