Page 1 of 3
[Mod] Vehicles: Cart
Posted: Sat Dec 17, 2011 16:16
by xyz
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:
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
Posted: Sat Dec 17, 2011 16:43
by MrThebuilder3
the recipe isnt working
:edit nevermind i fixed it
Posted: Sat Dec 17, 2011 16:58
by RAPHAEL
Can't wait till it can go both directions and do more than just look perty lol
Posted: Sat Dec 17, 2011 19:19
by elemashine
doesn't work in water and torches:
_ == rail
o == block
/ == torch
Posted: Sat Dec 17, 2011 21:52
by sdzen
your link isn't working for me
Posted: Sun Dec 18, 2011 07:54
by elemashine
sdzen wrote:your link isn't working for me
Try this:
http://minakov.dyndns.org/vehicles.tar.gz
Posted: Sun Dec 18, 2011 07:59
by xyz
elemashine wrote:doesn't work in water and torches:
_ == 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
Posted: Sun Dec 18, 2011 08:23
by kahrl
Perhaps you could check if the "walkable" property of the node is false.
Posted: Sun Dec 18, 2011 09:52
by xyz
Updated!
now cart's initial movement vector based on player position
carts move better, especially for Y-axis
Posted: Wed Dec 21, 2011 09:28
by Weird Carrot Monster
In single player mode cart stops after disconnecting, sometimes between blocks. Should it be so?
Posted: Wed Dec 21, 2011 22:01
by randomproof
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
Posted: Mon Jan 02, 2012 07:15
by IPushButton2653
Are the codes in the download, or do I have to insert them manually?
Posted: Mon Jan 02, 2012 08:05
by xyz
IPushButton2653 wrote:Are the codes in the download, or do I have to insert them manually?
You should modify my mod and minetest source.
Posted: Mon Jan 02, 2012 22:38
by marzin
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.
Posted: Wed Jan 25, 2012 22:23
by elemashine
This mod will increase number of players and developers, and I view it very important now. Please don't stop development.
Posted: Wed Jan 25, 2012 22:31
by sdzen
look at rideable blocks mod it seems more current
Posted: Wed Jan 25, 2012 23:14
by elemashine
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
Posted: Thu Feb 09, 2012 06:23
by sifrax
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.
Posted: Thu Feb 09, 2012 06:30
by sfan5
The Mod is not updated yet, that can cause Problems
Posted: Sat Feb 18, 2012 07:44
by RAPHAEL
So.... any news on carts or updating this mod?
Posted: Wed Feb 22, 2012 12:41
by DevilXkid1
I have tested the mod but the cart can`t drive!
Posted: Wed Feb 29, 2012 11:40
by poiuztr99
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
Posted: Wed Feb 29, 2012 13:24
by Nemo08
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'
Posted: Wed Feb 29, 2012 17:16
by poiuztr99
when i go to the rails and press q the minetest process is killed.
Posted: Thu Mar 01, 2012 01:57
by Utilisatrice
poiuztr99 wrote:when i go to the rails and press q the minetest process is killed.
Me too.
Tested on latest version of minetest.