Open v-rob opened 4 years ago
Interesting idea. The concept is OK for me, but there are a few points that would be great to adjust: 1) On-drive-over callbacks: Called when "cart_acceleration" is set and the callback exists. This approach allows registering any kind of new rail. Concept:
local new_vel, new_acc = nodedef.on_cart_driveover(pos, vel, acc, self.object)
local stopped = new_vel and vector.equals(new_vel, vector.new())
update.vel = update.vel or new_vel ~= nil
update.pos = update.pos or stopped
vel = new_vel or vel
acc = new_acc or false
if stopped then
pos = vector.round(pos)
end
2) Why do you check for if not mesecon then
? If there's no mesecons the wait time should also be configurable.
3) Assuming this node isn't placed way too often: Please move the formspec handling into the node definition. send_formspec
is not needed since you can embed the current value using ${cart_acceleration}
. The formspec will update automatically client-side as soon the metadata is received.
This adds a rail type that will stop the cart when it rolls over it, like the start-stop rail, but the cart will start moving again after a specified amount of time. After placing down this rail (it has white between the wood), a formspec will pop up, and here you can specify the amount of time.