[Mod] Vehicles: Cart

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

[Mod] Vehicles: Cart

by xyz » Sat Dec 17, 2011 16:16

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:
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
...
#.#
###

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 » Sat Dec 17, 2011 16:43

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

by RAPHAEL » Sat Dec 17, 2011 16:58

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)
 

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

by elemashine » Sat Dec 17, 2011 19:19

doesn't work in water and torches:
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
_
o_/
oo_
ooo


_ == rail
o == block
/ == torch
 

User avatar
sdzen
Member
 
Posts: 1170
Joined: Fri Aug 05, 2011 22:33

by sdzen » Sat Dec 17, 2011 21:52

your link isn't working for me
[h]Zen S.D.[/h] 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
 

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

by elemashine » Sun Dec 18, 2011 07:54

sdzen wrote:your link isn't working for me

Try this: http://minakov.dyndns.org/vehicles.tar.gz
 

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

by xyz » Sun Dec 18, 2011 07:59

elemashine wrote:doesn't work in water and torches:
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
_
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

by kahrl » Sun Dec 18, 2011 08:23

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

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

by xyz » Sun Dec 18, 2011 09:52

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

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

by Weird Carrot Monster » Wed Dec 21, 2011 09:28

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

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31

by randomproof » Wed Dec 21, 2011 22:01

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
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
    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
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
    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:

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
    -- 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

by IPushButton2653 » Mon Jan 02, 2012 07:15

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

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

by xyz » Mon Jan 02, 2012 08:05

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

You should modify my mod and minetest source.
 

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

by marzin » Mon Jan 02, 2012 22:38

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.
 

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

by elemashine » Wed Jan 25, 2012 22:23

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

by sdzen » Wed Jan 25, 2012 22:31

look at rideable blocks mod it seems more current
[h]Zen S.D.[/h] 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
 

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

by elemashine » Wed Jan 25, 2012 23:14

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
 

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

by sifrax » Thu Feb 09, 2012 06:23

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
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Thu Feb 09, 2012 06:30

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

by RAPHAEL » Sat Feb 18, 2012 07:44

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)
 

DevilXkid1
Member
 
Posts: 16
Joined: Mon Feb 20, 2012 10:56

by DevilXkid1 » Wed Feb 22, 2012 12:41

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

poiuztr99
Member
 
Posts: 10
Joined: Tue Feb 14, 2012 17:06

by poiuztr99 » Wed Feb 29, 2012 11:40

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. :-(
 

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

by Nemo08 » Wed Feb 29, 2012 13:24

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'
 

poiuztr99
Member
 
Posts: 10
Joined: Tue Feb 14, 2012 17:06

by poiuztr99 » Wed Feb 29, 2012 17:16

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. :-(
 

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

by Utilisatrice » Thu Mar 01, 2012 01:57

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


Me too.

Tested on latest version of minetest.
 

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

by Nemo08 » Thu Mar 01, 2012 07:41

i think cart mod dont updated to last MT build
 

User avatar
RabbiBob
Member
 
Posts: 335
Joined: Sat Jan 28, 2012 22:40

by RabbiBob » Fri Mar 02, 2012 01:47

For the pickup/crash bug, change the line

add_item("craft vehicles:cart 1") to add_item("main" ,"vehicles:cart")

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
function cart:on_punch(hitter)
    self.health = self.health - 1
    if self.health <= 0 then
        self.object:remove()
        --hitter:get_inventory():add_item("craft vehicles:cart 1")
        hitter:get_inventory():add_item("main" ,"vehicles:cart")
    end
end


Edit:

The 'q' drop issue looks like it was due to the on_drop call, corrected by changing to drop. Though right now I seem to be dropping all in my inventory (2) rather than 1 as depicted in the line.

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
minetest.register_craftitem("vehicles:cart", {
    tile_images = {"vehicles_cart_top.png","vehicles_cart_top.png",
        "vehicles_cart_side.png","vehicles_cart_side.png","vehicles_cart_side.png","vehicles_cart_side.png"},
   
    inventory_image = "vehicles_cart_inventory.png",
    walkable = true,
    climbable = true,
    description = "Cart",
    --on_drop = function(item, dropper, pos)
    drop = '"vehicles:cart" 1',
        --minetest.env:add_entity({x = round(pos.x), y = round(pos.y), z = round(pos.z)}, "vehicles:cart")
        --return true
    --end
})



The facing issue only occurs with newly placed carts in 20120122. If you bring a world up from 20120106 with carts already in place, they look and function fine. I haven't been able to determine what isn't right anymore with the cart definition that is causing the placement issue. I've tried changing the _image definitions above with little success.

Off to bed...
Last edited by RabbiBob on Fri Mar 02, 2012 02:18, edited 1 time in total.
 

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

by xyz » Fri Mar 02, 2012 11:53

Also you may try using this mod from my repo (it got updated someday). Will update it again when have free time.
 

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

by RAPHAEL » Fri Mar 02, 2012 13:28

xyz wrote:Also you may try using this mod from my repo (it got updated someday). Will update it again when have free time.

Well the mod from there seems to work to a degree. I crafted a cart but cant place it on the track.
"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
RabbiBob
Member
 
Posts: 335
Joined: Sat Jan 28, 2012 22:40

by RabbiBob » Sat Mar 03, 2012 12:59

xyz wrote:Also you may try using this mod from my repo (it got updated someday). Will update it again when have free time.


Thanks! I updated and it works under 20120122 when placed on a track, plus the Player movement works.

In testing (see video):
If I right click to place the object, it comes out as a single pane.
Using 'q' to drop places it properly, however inventory doesn't decrement by 1.

http://www.youtube.com/watch?v=eAzWJ8XKFh8

There's a reason I've been looking at this one so much, however I think I'm trying to run before I learn to walk with Lua. If you're interested, I'll toss my idea your way as I think you'll be able to pull it off.
 

Next

Return to Old Mods

Who is online

Users browsing this forum: No registered users and 4 guests

cron