[Mod] Carts [carts]

User avatar
glomie
Member
Posts: 141
Joined: Sun Aug 07, 2011 19:41

by glomie » Post

You can make switch with mesecon piston, as it was done in my server.
Sorry for my bad english...

User avatar
VanessaE
Moderator
Posts: 4572
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaE
Location: Western NC
Contact:

by VanessaE » Post

The only problem with using pistons for switches (which we do on my server also) is that a piston only has two states (basically stop/go or turn/don't-turn if your tracks are simple, or turn-left/turn-right with a somewhat convoluted track layout around the piston), but one of those carts switches has *three*, allowing for left and right turns or stopping entirely.
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)

User avatar
glomie
Member
Posts: 141
Joined: Sun Aug 07, 2011 19:41

by glomie » Post

So, using two piston ?
Sorry for my bad english...

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

by jojoa1997 » Post

glomie wrote:So, using two piston ?
i have 3 pistons on here server and it is COMPLICATED
Coding;
1X coding
3X debugging
12X tweaking to be just right

User avatar
J-Block
Member
Posts: 39
Joined: Sun Dec 23, 2012 20:04

by J-Block » Post

Hi, I'm really new to this site so sorry if I do something wrong.

I downloaded this mod and for some reason it fails to load. It displays the message (NOT copying and pasting):

Failed to load and run C:\Users\..\Documents\minetest-0.4.4-win32\minetest-0.4.4-win32\bin\..\mods\minetest\PilzAdam-carts-01b4bc5\init.lua

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

by jojoa1997 » Post

J-Block wrote:Hi, I'm really new to this site so sorry if I do something wrong.

I downloaded this mod and for some reason it fails to load. It displays the message (NOT copying and pasting):

Failed to load and run C:\Users\..\Documents\minetest-0.4.4-win32\minetest-0.4.4-win32\bin\..\mods\minetest\PilzAdam-carts-01b4bc5\init.lua
Rename the mod to carts. Its okay this happens to everyone. I had the same problem. If you look in the topic name [Mod] Carts [carts] the words in the [] are usually what you name it.
Coding;
1X coding
3X debugging
12X tweaking to be just right

User avatar
J-Block
Member
Posts: 39
Joined: Sun Dec 23, 2012 20:04

by J-Block » Post

jojoa1997 wrote:
J-Block wrote:Hi, I'm really new to this site so sorry if I do something wrong.

I downloaded this mod and for some reason it fails to load. It displays the message (NOT copying and pasting):

Failed to load and run C:\Users\..\Documents\minetest-0.4.4-win32\minetest-0.4.4-win32\bin\..\mods\minetest\PilzAdam-carts-01b4bc5\init.lua
Rename the mod to carts. Its okay this happens to everyone. I had the same problem. If you look in the topic name [Mod] Carts [carts] the words in the [] are usually what you name it.
Oh, ok, thanks, I'll remember that! It's working well now!

EDIT: I saw in the first post you can power it with the mesecons mod, but I don't have that. Is there an alternative power source or is that the only one?
Last edited by J-Block on Sun Dec 23, 2012 21:50, edited 1 time in total.

User avatar
VanessaE
Moderator
Posts: 4572
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaE
Location: Western NC
Contact:

by VanessaE » Post

Glomie: Using two pistons requires a bare minimum of EIGHT nodes' worth of space (two pistons, two switches, two pieces of track that can move, and one space each for the track to move into/out of when the piston moves), where two (one track, one switch) was sufficient before. Add several more nodes if you need extra wiring to position the switches conveniently.

And if you want left-right behavior out of a piston, you need roughly 12 nodes worth of space for just one such turnout because of the way the track has to be routed to allow for such a thing.

There are examples of these arrangements on my server.
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)

User avatar
jordan4ibanez
Member
Posts: 1895
Joined: Tue Sep 27, 2011 18:44
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez
Location: Rhode Island, USA

by jordan4ibanez » Post

Pilzadam I was beginning to develop trains with your mod, while I'm on break I hope to see you develop the ability for minecarts to essentially be "attached" to eachother.
I was starting with a very simple code:
Replace this:

Code: Select all

    local dir = cart_func:velocity_to_dir(self.velocity)
Which is in the on_step function of your carts with:

Code: Select all

    for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 10)) do
        if object:is_player() then
            local objdir = object:getpos()
            self.velocity.x = objdir.x - pos.x
            self.velocity.z = objdir.z - pos.z
        end
    end
    local dir = cart_func:velocity_to_dir(self.velocity)
This essentially makes the minecarts pathfind to a player through rails, this can be further heavily developed into attaching carts to eachother by right clicking with a special chain tool or something. You'd have to add another another self variable, which would be self.follow. But I did not get to that point yet. Let me explain further:
1.) A player right clicks the cart that should be the "lead" for the other cart with the tool.
2.) When the player clicks that cart, the luaentity should be stored in a table for that player's name.
3.) When the player clicks the "following" cart, it would be given the self variable (self.follow) of the luaentity it is supposed to follow.
4.) On step, if the luaentity it is supposed to follow is in it's radius (Maybe a radius of 5 or so) It would try to go towards that other cart.
5.) If it gets stopped, or disconnected (Someone breaks the rail in between them and the "lead" cart gets away) then the radius function should set the self.follow variable to nil or "" so that it will not try to follow the cart as if the connection between the "lead" and the "follow" broke.


Also, i have made a train out of your cart, it is very simple but it looks nice-ish. This train should get if the player is pushing the move forward key (w) and backwards key (s), and move forward, and stop/move backwards accordingly.

Here is a mesh that kaeza made: http://pastebin.com/raw.php?i=5Wz8BqA5
It is very simple and needs to be moved forward a bit so it appears that you are actually sitting in the train. I hope you can work with this information, as it will greatly help minetest achieve another awesome mod. Best of wishes. and merry Christmas.
I've been gone for a long time

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

by PilzAdam » Post

J-Block wrote:EDIT: I saw in the first post you can power it with the mesecons mod, but I don't have that. Is there an alternative power source or is that the only one?
You can punch the cart to accelerate it. Or simply drive downhill.

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

by PilzAdam » Post

jordan4ibanez wrote:Pilzadam I was beginning to develop trains with your mod, while I'm on break I hope to see you develop the ability for minecarts to essentially be "attached" to eachother.
I was starting with a very simple code:
Replace this:

Code: Select all

    local dir = cart_func:velocity_to_dir(self.velocity)
Which is in the on_step function of your carts with:

Code: Select all

    for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 10)) do
        if object:is_player() then
            local objdir = object:getpos()
            self.velocity.x = objdir.x - pos.x
            self.velocity.z = objdir.z - pos.z
        end
    end
    local dir = cart_func:velocity_to_dir(self.velocity)
This essentially makes the minecarts pathfind to a player through rails, this can be further heavily developed into attaching carts to eachother by right clicking with a special chain tool or something. You'd have to add another another self variable, which would be self.follow. But I did not get to that point yet. Let me explain further:
1.) A player right clicks the cart that should be the "lead" for the other cart with the tool.
2.) When the player clicks that cart, the luaentity should be stored in a table for that player's name.
3.) When the player clicks the "following" cart, it would be given the self variable (self.follow) of the luaentity it is supposed to follow.
4.) On step, if the luaentity it is supposed to follow is in it's radius (Maybe a radius of 5 or so) It would try to go towards that other cart.
5.) If it gets stopped, or disconnected (Someone breaks the rail in between them and the "lead" cart gets away) then the radius function should set the self.follow variable to nil or "" so that it will not try to follow the cart as if the connection between the "lead" and the "follow" broke.


Also, i have made a train out of your cart, it is very simple but it looks nice-ish. This train should get if the player is pushing the move forward key (w) and backwards key (s), and move forward, and stop/move backwards accordingly.

Here is a mesh that kaeza made: http://pastebin.com/raw.php?i=5Wz8BqA5
It is very simple and needs to be moved forward a bit so it appears that you are actually sitting in the train. I hope you can work with this information, as it will greatly help minetest achieve another awesome mod. Best of wishes. and merry Christmas.
Thanks for this bunch of information. Now I have something to do. But I dont know if I can start right away, I have some other things to do. But I will try my best.

User avatar
BrandonReese
Member
Posts: 839
Joined: Wed Sep 12, 2012 00:44
GitHub: bremaweb
IRC: BrandonReese
In-game: BrandonReese
Location: USA

by BrandonReese » Post

I had the idea to make a jousting arena... make two oval tracks one block apart from each other, have the competitors put a cart on the track and have them go in opposite directions and as they pass by each other attack until one of the competitors is dead. I was sorely disappointed when I was testing this that when I tried to attack the other player it just accelerated their cart, which makes sense once I thought about it.

This is my question... if I modify the code so it doesn't accelerate the cart if you are wielding a sword, will I be able to hurt the person attached to the cart?

User avatar
aximx51v
Member
Posts: 60
Joined: Fri Dec 07, 2012 03:47

by aximx51v » Post

Is there a way to limit cart speed? I have a track that runs down hill. If i put mesecons alongside it to push my cart up the hill, when i go down the hill i end up going so fast that, well... let's just say glitch city.
what if mesecons could act as brakes for the cart? like, mesecons on the right side speed the cart up, and mesecons on the left slow it down. or maybe a mesecon block that slows down/speeds up the cart to a specific speed, regardless of direction?
all in all, great mod so far!

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

by rarkenin » Post

aximx51v wrote:Is there a way to limit cart speed? I have a track that runs down hill. If i put mesecons alongside it to push my cart up the hill, when i go down the hill i end up going so fast that, well... let's just say glitch city.
what if mesecons could act as brakes for the cart? like, mesecons on the right side speed the cart up, and mesecons on the left slow it down. or maybe a mesecon block that slows down/speeds up the cart to a specific speed, regardless of direction?
all in all, great mod so far!
No, you can't, since Mesecons triggers a per-node on or off. I'll make a manual powered rail and manual brake rail, and I'll submit a pull request for that.
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.

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

by PilzAdam » Post

rarkenin wrote:
aximx51v wrote:Is there a way to limit cart speed? I have a track that runs down hill. If i put mesecons alongside it to push my cart up the hill, when i go down the hill i end up going so fast that, well... let's just say glitch city.
what if mesecons could act as brakes for the cart? like, mesecons on the right side speed the cart up, and mesecons on the left slow it down. or maybe a mesecon block that slows down/speeds up the cart to a specific speed, regardless of direction?
all in all, great mod so far!
No, you can't, since Mesecons triggers a per-node on or off. I'll make a manual powered rail and manual brake rail, and I'll submit a pull request for that.
Would be nice.

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

by jojoa1997 » Post

Will carts be able to pick up dropped items
Coding;
1X coding
3X debugging
12X tweaking to be just right

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

by PilzAdam » Post

jojoa1997 wrote:Will carts be able to pick up dropped items
No. Carts are only for player transport now.

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

by jojoa1997 » Post

I kniw this is from minecraft but chest carts seem like a good idea. Is that possible in minetest.
Coding;
1X coding
3X debugging
12X tweaking to be just right

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

by PilzAdam » Post

jojoa1997 wrote:I kniw this is from minecraft but chest carts seem like a good idea. Is that possible in minetest.
Since we have minetest.show_formspec(playername, formspec) in the API now it is possible. I will add it in the near future.

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

by rarkenin » Post

PilzAdam wrote:
rarkenin wrote:
aximx51v wrote:Is there a way to limit cart speed? I have a track that runs down hill. If i put mesecons alongside it to push my cart up the hill, when i go down the hill i end up going so fast that, well... let's just say glitch city.
what if mesecons could act as brakes for the cart? like, mesecons on the right side speed the cart up, and mesecons on the left slow it down. or maybe a mesecon block that slows down/speeds up the cart to a specific speed, regardless of direction?
all in all, great mod so far!
No, you can't, since Mesecons triggers a per-node on or off. I'll make a manual powered rail and manual brake rail, and I'll submit a pull request for that.
Would be nice.
Pull request submitted, awaiting feedback and response! This is my first experience doing much in Lua, so sorry if I made something not follow convention.

Edit: Oh, and I plan to submit another pull request with a handbrake(brake rail that can be punched to bring to full power)
Last edited by rarkenin on Wed Jan 09, 2013 21:27, edited 1 time in total.
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.

User avatar
aximx51v
Member
Posts: 60
Joined: Fri Dec 07, 2012 03:47

by aximx51v » Post

rarkenin wrote:
PilzAdam wrote:
rarkenin wrote: No, you can't, since Mesecons triggers a per-node on or off. I'll make a manual powered rail and manual brake rail, and I'll submit a pull request for that.
Would be nice.
Pull request submitted, awaiting feedback and response! This is my first experience doing much in Lua, so sorry if I made something not follow convention.

Edit: Oh, and I plan to submit another pull request with a handbrake(brake rail that can be punched to bring to full power)
What about a rail that slows you down when you travel over it one way, and speeds you up when you're going the other way?

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

by rarkenin » Post

aximx51v wrote:
rarkenin wrote:
PilzAdam wrote: Would be nice.
Pull request submitted, awaiting feedback and response! This is my first experience doing much in Lua, so sorry if I made something not follow convention.

Edit: Oh, and I plan to submit another pull request with a handbrake(brake rail that can be punched to bring to full power)
What about a rail that slows you down when you travel over it one way, and speeds you up when you're going the other way?
I don't know how to do that, since I'm setting cart_acceleration in node metadata, I think. The cart would need to pay attention to node orientation, in that case. If PilzAdam changed the carts' core code, that would be awesome, though.
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.

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

by PilzAdam » Post

rarkenin wrote:
aximx51v wrote:
rarkenin wrote: Pull request submitted, awaiting feedback and response! This is my first experience doing much in Lua, so sorry if I made something not follow convention.

Edit: Oh, and I plan to submit another pull request with a handbrake(brake rail that can be punched to bring to full power)
What about a rail that slows you down when you travel over it one way, and speeds you up when you're going the other way?
I don't know how to do that, since I'm setting cart_acceleration in node metadata, I think. The cart would need to pay attention to node orientation, in that case. If PilzAdam changed the carts' core code, that would be awesome, though.
Sure, it is possible. Save a serialized unit vector in the node meta as "cart_acceleration_direction". If the carts detect the "cart_acceleration" field (or however I called it) it first checks the direction. The deceleration could be done via "cart_deceleration" or something similar.

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

by rarkenin » Post

Oh, I didn't know about that. What form is the vector in? Lua doesn't have a built-in vector format IIRC. If it does, pardon my ignorance.
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.

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

by PilzAdam » Post

rarkenin wrote:Oh, I didn't know about that. What form is the vector in? Lua doesn't have a built-in vector format IIRC. If it does, pardon my ignorance.
With "It is possible" I meant, "It is possible to implement some day". So its not in my code currently.
And for the vectors its same as position, local vec = {x=0, y=0, z=0}. To serialize it call minetest.serialize(vec). This returns a string that can be stored in meta. Ill maybe implement this tomorow or so.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests