[Mod] Vehicles: Cart

User avatar
xyz
Member
Posts: 450
Joined: Thu Nov 10, 2011 14:25

[Mod] Vehicles: Cart

by xyz » Post

Image
This is not a release version, it may be buggy and eat all your cpu, please don't install this on public servers. Thanks.

Now this mod adds only carts, but I plan to add boats (when it'll be possible with modding api)
Current KNOWN bugs:
1) Player is not attached to cart, this is because modding api doesnt allow to move player (okay, actually, moveto and setpos both don't work when using with player's objectref)
2) Initial moving vector should be determined using player position, but now it is hardcoded

Crafting:

Code: Select all

...
#.#
###
where # is steel ingot and . is nothing

How-to use:
Craft cart, place it on the rails (by using right mouse button), then right-click it and it will go!

Download

If the first link doesn't work

Test & enjoy
Last edited by celeron55 on Sat Mar 17, 2012 11:34, edited 1 time in total.

User avatar
MrThebuilder3
Member
Posts: 104
Joined: Sat Nov 19, 2011 18:26

by MrThebuilder3 » Post

the recipe isnt working
:edit nevermind i fixed it
Last edited by MrThebuilder3 on Sat Dec 17, 2011 16:45, edited 1 time in total.

User avatar
RAPHAEL
Member
Posts: 627
Joined: Tue Nov 01, 2011 09:09
Location: Earth

by RAPHAEL » Post

Can't wait till it can go both directions and do more than just look perty lol
"Before you speak, ask yourself: Is it kind, is it true, is it necessary, does it improve upon the silence?"
My mods: http://goo.gl/n4kpn
(Currently Various, Industrial, Fakeblocks, Jail, MoarCraft, Christmas, Replicator, minetest dev installer for linux, bash mod installer, windows mod installer)

User avatar
elemashine
Member
Posts: 12
Joined: Fri Dec 16, 2011 07:47

by elemashine » Post

doesn't work in water and torches:

Code: Select all

_
o_/
oo_
ooo
_ == rail
o == block
/ == torch

User avatar
sdzen
Member
Posts: 1170
Joined: Fri Aug 05, 2011 22:33
Location: Paradise (your not allowed)

by sdzen » Post

your link isn't working for me

Zen S.D.

The next generation of tranquility!
malheureusement mon français n'est pas bon :<
Owner of the Zelo's
In game name: MuadTralk, spdtainted, sdzen, sd zen, sdzeno

User avatar
elemashine
Member
Posts: 12
Joined: Fri Dec 16, 2011 07:47

by elemashine » Post

sdzen wrote:your link isn't working for me
Try this: http://minakov.dyndns.org/vehicles.tar.gz

User avatar
xyz
Member
Posts: 450
Joined: Thu Nov 10, 2011 14:25

by xyz » Post

elemashine wrote:doesn't work in water and torches:

Code: Select all

_
o_/
oo_
ooo
_ == rail
o == block
/ == torch
That's because torch is node, and when going down or up you cannot pass through a node
Same for water

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

by kahrl » Post

Perhaps you could check if the "walkable" property of the node is false.

User avatar
xyz
Member
Posts: 450
Joined: Thu Nov 10, 2011 14:25

by xyz » Post

Updated!
now cart's initial movement vector based on player position
carts move better, especially for Y-axis

User avatar
Weird Carrot Monster
New member
Posts: 3
Joined: Tue Sep 20, 2011 23:14

by Weird Carrot Monster » Post

In single player mode cart stops after disconnecting, sometimes between blocks. Should it be so?

User avatar
randomproof
Member
Posts: 214
Joined: Thu Nov 17, 2011 06:31
Location: California, USA

by randomproof » Post

I've played with the code a little and here is a start to the change needed to move the player with the cart.

in scriptapi.cpp around line 1869

Code: Select all

    static int l_setpos(lua_State *L)
    {
        ObjectRef *ref = checkobject(L, 1);
        //LuaEntitySAO *co = getluaobject(ref);
        v3f pos = readFloatPos(L, 2);
        ServerRemotePlayer *player = getplayer(ref);
        if(player != NULL)
        {
            player->setPos(pos);

            std::ostringstream os(std::ios::binary);
            // command (3 = force update position)
            writeU8(os, 3);
            // pos
            writeV3F1000(os, pos);
            // yaw
            writeF1000(os, player->getYaw());
            // create message and add to list
            ActiveObjectMessage aom(player->getId(), false, os.str());
            player->m_messages_out.push_back(aom);

            return 0;
        }
        ServerActiveObject *co = getobject(ref);

        if(co != NULL)
        {
            // Do it
            co->setPos(pos);
            return 0;
        }
        return 0;
    }
and in content_cao.cpp around line 2248

Code: Select all

    void processMessage(const std::string &data)
    {
        //infostream<<"PlayerCAO: Got message"<<std::endl;
        std::istringstream is(data, std::ios::binary);
        // command
        u8 cmd = readU8(is);
        if(cmd == 0) // update position
        {
            // pos
            m_position = readV3F1000(is);
            // yaw
            m_yaw = readF1000(is);

            pos_translator.update(m_position, false);

            updateNodePos();
        }
        else if(cmd == 1) // punched
        {
            // damage
            s16 damage = readS16(is);

            if(m_is_local_player)
                m_env->damageLocalPlayer(damage, false);

            m_damage_visual_timer = 0.5;
            updateTextures("^[brighten");
        }
        else if(cmd == 3) // force update position
        {
            // pos
            m_position = readV3F1000(is);
            // yaw
            m_yaw = readF1000(is);

            if(m_is_local_player)
            {
                m_local_player->setPosition(m_position);
            }

            pos_translator.update(m_position, false);

            updateNodePos();
        }
    }
I also moved the code that moves the player in the mod script and made it so you and get attached if you are standing in the cart when you activate it:

Code: Select all

    -- first state: cart is moving
    if self.moving ~= false and self.time == 0 then
        local pos_f = self.object:getpos()
        if self.moving ~= false then
            if eq(pos_f.x, self.moving.x) and eq(pos_f.y, self.moving.y) and eq(pos_f.z, self.moving.z) then
                self.moving = false
                self.object:setacceleration({x = 0, y = -10, z = 0})
                if self.stopnow then
                    self.stopnow = false
                    self.attached_to = false
                end
            else
                local needed = {x = self.moving.x - pos_f.x,
                                y = self.moving.y - pos_f.y,
                                z = self.moving.z - pos_f.z}
                needed = resize(needed, math.min(length(needed), speed))
                self.object:setpos(move(pos_f, needed))

                -- move player that attached to this cart; FIXME
                local player = minetest.env:get_player_by_name(self.attached_to)
                if player ~= nil then
                    --print (self.attached_to .. " moved to " .. self.object:getpos().x .. ", " .. self.object:getpos().y .. ", " .. self.object:getpos().z)
                    p_pos = self.object:getpos()
                    p_pos.y = p_pos.y - 0.5
                    player:setpos(p_pos)
                end
            end

            return
        end
    end

    -- second state: cart just need to check whether to move next self.time==0

...

...

function cart:on_rightclick(clicker)
    if self.attached_to == false then
        local playerpos = clicker:getpos()
        local selfpos = self.object:getpos()

        if ((playerpos.x-1) < selfpos.x and (playerpos.x+1) > selfpos.x and
            (playerpos.y-2) < (selfpos.y) and (playerpos.y+1) > (selfpos.y) and
            (playerpos.z-1) < selfpos.z and (playerpos.z+1) > selfpos.z) then
            self.attached_to = clicker:get_player_name()
        else
            self.attached_to = ""
        end
        local best = 1e15
        -- find initial moving direction by searching through 4 nearby possibly positions
        self.vec = {x = 1, z = 0}
        for dx = -1,1 do
            for dz = -1,1 do
                if (dx * dz == 0) and (dx ~= 0 or dz ~= 0) then
                    local dst = dist(playerpos, {x = selfpos.x + dx, z = selfpos.z + dz})
                    if dst < best
                        and (is_rail({x = selfpos.x - dx, y = selfpos.y, z = selfpos.z - dz})
                        or is_rail({x = selfpos.x - dx, y = selfpos.y + 1, z = selfpos.z - dz})
                        or is_rail({x = selfpos.x - dx, y = selfpos.y - 1, z = selfpos.z - dz})) then
                            best = dst
                            self.vec = {x = -dx, z = -dz}
                    end
                end
            end
        end
    else
        self.stopnow = true
    end
end
Last edited by randomproof on Wed Dec 21, 2011 23:29, edited 1 time in total.

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

by IPushButton2653 » Post

Are the codes in the download, or do I have to insert them manually?

User avatar
xyz
Member
Posts: 450
Joined: Thu Nov 10, 2011 14:25

by xyz » Post

IPushButton2653 wrote:Are the codes in the download, or do I have to insert them manually?
You should modify my mod and minetest source.

User avatar
marzin
Member
Posts: 34
Joined: Sun Jun 26, 2011 12:07

by marzin » Post

Great mod.

But I suggesting 2 things:

1. Should be also "mese cart" - very fast, faster that fast_move. From mese instead steel.

2.Ships should be also in "normal" and "mese" version - second much faster, but slower than mese cart.

3.deltaplane(http://en.wikipedia.org/wiki/Hang_glider). - also with "slow" and "mese" version(mese version will be like a today "fast_move"). Simple with it player with it can move like in free_move but without noclip(eg walls are solid).

With that mod servers can put off free_move.

User avatar
elemashine
Member
Posts: 12
Joined: Fri Dec 16, 2011 07:47

by elemashine » Post

This mod will increase number of players and developers, and I view it very important now. Please don't stop development.

User avatar
sdzen
Member
Posts: 1170
Joined: Fri Aug 05, 2011 22:33
Location: Paradise (your not allowed)

by sdzen » Post

look at rideable blocks mod it seems more current

Zen S.D.

The next generation of tranquility!
malheureusement mon français n'est pas bon :<
Owner of the Zelo's
In game name: MuadTralk, spdtainted, sdzen, sd zen, sdzeno

User avatar
elemashine
Member
Posts: 12
Joined: Fri Dec 16, 2011 07:47

by elemashine » Post

sdzen wrote:look at rideable blocks mod it seems more current
Those blocks looks better just because can provide player's movements on it, but with rideable blocks we have two useless items - rails and this blocks. We need worked railroads with carts, which can move minerals and player to the ground

User avatar
sifrax
Member
Posts: 16
Joined: Thu Feb 09, 2012 06:17

by sifrax » Post

Hello, can someone post me a little help? I'm using a git version of Minetest and some plugins, I like to use carts, but the veihcle is not moving at all (on the rails of course). If I hit it with right-click nothing happen, left-click collect it.
Last edited by sifrax on Thu Feb 09, 2012 07:47, edited 1 time in total.

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

by sfan5 » Post

The Mod is not updated yet, that can cause Problems
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

User avatar
RAPHAEL
Member
Posts: 627
Joined: Tue Nov 01, 2011 09:09
Location: Earth

by RAPHAEL » Post

So.... any news on carts or updating this mod?
"Before you speak, ask yourself: Is it kind, is it true, is it necessary, does it improve upon the silence?"
My mods: http://goo.gl/n4kpn
(Currently Various, Industrial, Fakeblocks, Jail, MoarCraft, Christmas, Replicator, minetest dev installer for linux, bash mod installer, windows mod installer)

User avatar
DevilXkid1
Member
Posts: 16
Joined: Mon Feb 20, 2012 10:56
Location: Heilbronn,Germany

by DevilXkid1 » Post

I have tested the mod but the cart can`t drive!
I Play MINETEST , You Play MINECRAFT
(Minetest is better than Minecraft :P )

User avatar
poiuztr99
Member
Posts: 10
Joined: Tue Feb 14, 2012 17:06
Location: Germany

by poiuztr99 » Post

Hi!
I want ot test it but it dosnt work.
I can craft it but when i place it on the rails it look like this:
[img=Vehicle]http://s9.postimage.org/a7wet95b3/vehicle.png[/img]

i hope you can help me

poiuztr99
My house was at squark.servegame.com
Now it the server is down. :-(

User avatar
Nemo08
Member
Posts: 132
Joined: Mon Dec 26, 2011 04:59

by Nemo08 » Post

poiuztr99 wrote:Hi!
I want ot test it but it dosnt work.
I can craft it but when i place it on the rails it look like this:
[img=Vehicle]http://s9.postimage.org/a7wet95b3/vehicle.png[/img]

i hope you can help me

poiuztr99
Stay on rails and press 'q'

User avatar
poiuztr99
Member
Posts: 10
Joined: Tue Feb 14, 2012 17:06
Location: Germany

by poiuztr99 » Post

when i go to the rails and press q the minetest process is killed.
My house was at squark.servegame.com
Now it the server is down. :-(

User avatar
Utilisatrice
Member
Posts: 103
Joined: Thu Feb 16, 2012 18:04

by Utilisatrice » Post

poiuztr99 wrote:when i go to the rails and press q the minetest process is killed.
Me too.

Tested on latest version of minetest.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest