[Mod] Carts [carts]

graphics boy
Member
Posts: 19
Joined: Fri Jul 27, 2012 08:57
GitHub: Cg-boy

by graphics boy » Post

0.4
I like 3d graphics

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

by PilzAdam » Post

Wich 0.4? (please write everything that is written in the upper left corner of minetest)
Wich version of carts do you have?

graphics boy
Member
Posts: 19
Joined: Fri Jul 27, 2012 08:57
GitHub: Cg-boy

by graphics boy » Post

Minetest-c55 0.4.dev-20120606

carts 23
Last edited by graphics boy on Sun Jul 29, 2012 09:14, edited 1 time in total.
I like 3d graphics

graphics boy
Member
Posts: 19
Joined: Fri Jul 27, 2012 08:57
GitHub: Cg-boy

by graphics boy » Post

version 23 of carts
I like 3d graphics

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

by PilzAdam » Post

This is realy strange because in line 390 if init.lua the method is_player() is not used. Try redownload.

Tggtt
New member
Posts: 5
Joined: Sat Jul 28, 2012 00:30

by Tggtt » Post

PilzAdam wrote:
tee-jay wrote:I have the latest mesecons version from github (7568182) and have the exact same problem sfan5 has.
Yes it does work without mesecons.
Maybe it helps when you add "mesecons" to depends.txt
When this dont fix it I have no idea what to do. I dont have this bug.
I had that problem too and adding mesecons to depends.txt of carts fixed it.

It's working great, thank you very much.


Also, does it have a box that the cart takes its contents too? I only find one that the cart drops the content, not for taking.

If it's possible, I would be able to create closed circuit tracks that carts take contents from one side and drop on the other.
Last edited by Tggtt on Sun Jul 29, 2012 23:14, edited 1 time in total.

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

by PilzAdam » Post

Tggtt wrote: I had that problem too and adding mesecons to depends.txt of carts fixed it.

It's working great, thank you very much.
Thanks for the feedback.
Tggtt wrote: Also, does it have a box that the cart takes its contents too? I only find one that the cart drops the content, not for taking.

If it's possible, I would be able to create closed circuit tracks that carts take contents from one side and drop on the other.
Good idea.
EDIT: Added.
Last edited by PilzAdam on Mon Jul 30, 2012 10:04, edited 1 time in total.

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

by PilzAdam » Post

PilzAdam wrote:
tee-jay wrote:I have the latest mesecons version from github (7568182) and have the exact same problem sfan5 has.
Yes it does work without mesecons.
Maybe it helps when you add "mesecons" to depends.txt
When this dont fix it I have no idea what to do. I dont have this bug.
You dont have add mesecons to depends.txt with version 25.

Tggtt
New member
Posts: 5
Joined: Sat Jul 28, 2012 00:30

by Tggtt » Post

Thanks a lot. I think you forgot to add the recipe for pickup_plate in the first post.

Image
[EDIT] sorry, I saw it now.

I had to open the code to find it.
While reading the code for the pickup_plate, I came across your "fors" to search for the boxes and plates. I think you should try merging the "fors" because they are exactly the same, only the "if" changes. Merging them would improve performance for the same result.

[EDIT]
This is what I meant by merging the "fors". I believe it has the exact same result.

Code: Select all

    --search for pickup plates and take items
    -- and
    -- search for boxes and place all items (except players) in it
    for x=-1,1 do
        local pos = {x=self.object:getpos().x+x, y=self.object:getpos().y, z=self.object:getpos().z}
        local name = minetest.env:get_node(pos).name
        if name == "carts:pickup_plate" then
            pos.x = math.floor(0.5+pos.x)
            pos.y = math.floor(0.5+pos.y)
            pos.z = math.floor(0.5+pos.z)
            local items = minetest.env:get_objects_inside_radius(pos, 1)
            for i,item in ipairs(items) do
                if not item:is_player() then
                    table.insert(self.items, item)
                elseif TRANSPORT_PLAYER then
                    table.insert(self.items, item)
                end
            end
        end
        if name == "carts:chest" and self.items ~= {} then
            local items_tmp = {}
            for i,item in ipairs(self.items) do
                if not item:is_player() then
                    item:setpos({x=math.floor(0.5+pos.x), y=math.floor(0.5+pos.y)+0.2, 

z=math.floor(0.5+pos.z)})
                else
                    table.insert(items_tmp, item)
                end
            end
            self.items = items_tmp
        end
    end
    for z=-1,1 do
        local pos = {x=self.object:getpos().x, y=self.object:getpos().y, z=self.object:getpos().z+z}
        local name = minetest.env:get_node(pos).name
        if name == "carts:pickup_plate" then
            pos.x = math.floor(0.5+pos.x)
            pos.y = math.floor(0.5+pos.y)
            pos.z = math.floor(0.5+pos.z)
            local items = minetest.env:get_objects_inside_radius(pos, 1)
            for i,item in ipairs(items) do
                if not item:is_player() then
                    table.insert(self.items, item)
                elseif TRANSPORT_PLAYER then
                    table.insert(self.items, item)
                end
            end
        end
        if name == "carts:chest" and self.items ~= {} then
            local items_tmp = {}
            for i,item in ipairs(self.items) do
                if not item:is_player() then
                    item:setpos({x=math.floor(0.5+pos.x), y=math.floor(0.5+pos.y)+0.2, 

z=math.floor(0.5+pos.z)})
                else
                    table.insert(items_tmp, item)
                end
            end
            self.items = items_tmp
        end
    end
However, it could cause the cart to deliver itens to a box that is too near to the plate. You may want to invert the order of the "ifs".

When the server is laggy, the "cart missing the rail" problem happens more often. I have reduced the MAX_SPEED as a work around.
Last edited by Tggtt on Tue Jul 31, 2012 05:41, edited 1 time in total.

cornernote
Member
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Post

Mine would stop if i made a stair-like slope into my mine. I got it working really nicely (havent seen it crash) with a really small change:

Code: Select all

        -- downhill
        local vel = self.object:getvelocity()
        vel.y = -3*MAX_SPEED -- used to be -2*MAX_SPEED

edit: no it still crashes sometimes
Last edited by cornernote on Tue Jul 31, 2012 08:36, edited 1 time in total.

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

by PilzAdam » Post

Tggtt wrote:Thanks a lot. I think you forgot to add the recipe for pickup_plate in the first post.

Image
Ive added your picture.
Tggtt wrote: I had to open the code to find it.
While reading the code for the pickup_plate, I came across your "fors" to search for the boxes and plates. I think you should try merging the "fors" because they are exactly the same, only the "if" changes. Merging them would improve performance for the same result.
Ive changed it (see version 26).

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

by PilzAdam » Post

cornernote wrote:Mine would stop if i made a stair-like slope into my mine. I got it working really nicely (havent seen it crash) with a really small change:

Code: Select all

        -- downhill
        local vel = self.object:getvelocity()
        vel.y = -3*MAX_SPEED -- used to be -2*MAX_SPEED

edit: no it still crashes sometimes
My cart works with -2*MAX_SPEED.

User avatar
Ragnarok
Member
Posts: 217
Joined: Thu Mar 22, 2012 12:56
Location: Poland
Contact:

by Ragnarok » Post

I made a bit more natural sound for cart. Do you like it?:

http://speedy.sh/r4dPu/carts-cart-sound.ogg

License: WTFPL

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

by PilzAdam » Post

Ragnarok wrote:I made a bit more natural sound for cart. Do you like it?:

http://speedy.sh/r4dPu/carts-cart-sound.ogg

License: WTFPL
Ive set this to the default one but leave the old one in the sound folder so everyone can choose on his own.

User avatar
Ragnarok
Member
Posts: 217
Joined: Thu Mar 22, 2012 12:56
Location: Poland
Contact:

by Ragnarok » Post

Fantastic :) What do you think about using two different sounds for cart on straight rails and railway crossover?

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

by PilzAdam » Post

Ragnarok wrote:Fantastic :) What do you think about using two different sounds for cart on straight rails and railway crossover?
I had the idea that theres only one short sound that is played when the cart enters a new rail block.
With this method you can make many different sounds that are played randomly. You can also make different sounds for different rails.
But the sounds have to be realy short.

User avatar
Ragnarok
Member
Posts: 217
Joined: Thu Mar 22, 2012 12:56
Location: Poland
Contact:

by Ragnarok » Post

This can be problematic because of embedding the clatter of train wheels in the sound. Rails are too short. But you can use sound which has approx. 4-rails-length (with current speed of cart). You could check rails below cart, and if it meets an crossover (or bend) swap sound and simultaneously block the substitution of a different sound for a period equal to 4-rails-length (8-rails-length?).

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

by PilzAdam » Post

Ragnarok wrote:This can be problematic because of embedding the clatter of train wheels in the sound. Rails are too short. But you can use sound which has approx. 4-rails-length (with current speed of cart). You could check rails below cart, and if it meets an crossover (or bend) swap sound and simultaneously block the substitution of a different sound for a period equal to 4-rails-length (8-rails-length?).
I can do this if you provide the sounds. The coding is easy.

User avatar
Ragnarok
Member
Posts: 217
Joined: Thu Mar 22, 2012 12:56
Location: Poland
Contact:

by Ragnarok » Post

Ok, I'll make sounds. Maybe it would be better if the default sound will play all the time and swapped only when the train hovers on the crossover (and played for few moments)? You could then use the sounds of various lengths regardless of the cart speed. What do you think?

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

by PilzAdam » Post

Ragnarok wrote:Ok, I'll make sounds. Maybe it would be better if the default sound will play all the time and swapped only when the train hovers on the crossover (and played for few moments)? You could then use the sounds of various lengths regardless of the cart speed. What do you think?
I would prefer the short sounds.

User avatar
Ragnarok
Member
Posts: 217
Joined: Thu Mar 22, 2012 12:56
Location: Poland
Contact:

by Ragnarok » Post

Two sounds 2s long (10 rails) and one 1s (5 rails):

http://speedy.sh/jqz7M/carts-sounds.7z

License: WTFPL, enjoy =)

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

by PilzAdam » Post

Ragnarok wrote:Two sounds 2s long (10 rails) and one 1s (5 rails):

http://speedy.sh/jqz7M/carts-sounds.7z

License: WTFPL, enjoy =)
Thanks a lot!
Im still working on a other mod so it will take some time (1 day).

cornernote
Member
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Post

PilzAdam wrote:
cornernote wrote:Mine would stop if i made a stair-like slope into my mine. I got it working really nicely (havent seen it crash) with a really small change:

Code: Select all

        -- downhill
        local vel = self.object:getvelocity()
        vel.y = -3*MAX_SPEED -- used to be -2*MAX_SPEED

edit: no it still crashes sometimes
My cart works with -2*MAX_SPEED.

does it ever stop on a descent slope? (not just 1 step down, then flat, i mean lots of steps like this)...

|_
|_
|_
|_

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

by PilzAdam » Post

cornernote wrote:
PilzAdam wrote:
cornernote wrote:Mine would stop if i made a stair-like slope into my mine. I got it working really nicely (havent seen it crash) with a really small change:

Code: Select all

        -- downhill
        local vel = self.object:getvelocity()
        vel.y = -3*MAX_SPEED -- used to be -2*MAX_SPEED

edit: no it still crashes sometimes
My cart works with -2*MAX_SPEED.

does it ever stop on a descent slope? (not just 1 step down, then flat, i mean lots of steps like this)...

|_
|_
|_
|_
Image
This works for me.

cornernote
Member
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Post

still too small. mine goes down about 50-70. It USUALLY works, but it sometimes stops.

Post Reply

Who is online

Users browsing this forum: No registered users and 42 guests