Hey can someone help me with a script for a moveable minecart when you purchase you will be riding from A to B ? Like in the map Minecraft v1.2 with the boat. Thanks for helping
Hey can someone help me with a script for a moveable minecart when you purchase you will be riding from A to B ? Like in the map Minecraft v1.2 with the boat. Thanks for helping
Setup a trigger multiple and target the cart model. Then target a struct where the cart will end up. Then target a script_brushmodel from the cart. Then cut that brushmodel and wrap your cart with it. Place the trigger multiple in the base of the cart, just above the script_brushmodel.
/* ##################### by: M.A.K.E C E N T S ##################### Script:
Add to main in mapname.gsc cart::init( );
Add to top of mapname.gsc #using scripts\zm\cart;
Add to zone file scriptparsetree,scripts/zm/cart.gsc
//below > stands for autotargets trigger_multiple at bottome of cart> cartmodel at starting position> brush_models wrapping the cart struct, just one, where you want it to end ############################################################################### */
#namespace cart;
function init() { level.carttime = 10;//adjust time it takes to get to other station level.cartloop = true; carts = GetEntArray("carts","targetname");//triggers array::thread_all(carts, &CartSetup); } function CartSetup() { cart = GetEnt(self.target,"targetname"); self EnableLinkTo(); self linkto(cart); cart LinkPeices(); self thread CartMove(cart); } function CartMove(cart) { cart.a = cart.origin; cart.b = struct::get(cart.target, "targetname").origin; while(1) { self waittill("trigger"); self MoveToNext(cart); wait(.05); } } function MoveToNext(cart) { if(Distance(cart.origin,cart.a)<10) { cart MoveTo(cart.b,level.carttime); } else { cart MoveTo(cart.a,level.carttime); } wait(level.carttime); wait(2);//waits so the cart doesn't go back right away } function LinkPeices() { peices = GetEntArray(self.target,"targetname"); foreach(p in peices) { p LinkTo(self); } }
Setup a trigger multiple and target the cart model. Then target a struct where the cart will end up. Then target a script_brushmodel from the cart. Then cut that brushmodel and wrap your cart with it. Place the trigger multiple in the base of the cart, just above the script_brushmodel.
/* ##################### by: M.A.K.E C E N T S ##################### Script:
Add to main in mapname.gsc cart::init( );
Add to top of mapname.gsc #using scripts\zm\cart;
Add to zone file scriptparsetree,scripts/zm/cart.gsc
//below > stands for autotargets trigger_multiple at bottome of cart> cartmodel at starting position> brush_models wrapping the cart struct, just one, where you want it to end ############################################################################### */
#namespace cart;
function init() { level.carttime = 10;//adjust time it takes to get to other station level.cartloop = true; carts = GetEntArray("carts","targetname");//triggers array::thread_all(carts, &CartSetup); } function CartSetup() { cart = GetEnt(self.target,"targetname"); self EnableLinkTo(); self linkto(cart); cart LinkPeices(); self thread CartMove(cart); } function CartMove(cart) { cart.a = cart.origin; cart.b = struct::get(cart.target, "targetname").origin; while(1) { self waittill("trigger"); self MoveToNext(cart); wait(.05); } } function MoveToNext(cart) { if(Distance(cart.origin,cart.a)<10) { cart MoveTo(cart.b,level.carttime); } else { cart MoveTo(cart.a,level.carttime); } wait(level.carttime); wait(2);//waits so the cart doesn't go back right away } function LinkPeices() { peices = GetEntArray(self.target,"targetname"); foreach(p in peices) { p LinkTo(self); } }
Awesome Question though. Is there a way to make this go say in a circle. For example, go half around a city block, stop then when used again going back to the beginning?
It's a very simple script and is only setup currently to go from one point to the next, then back, in a straight line.
If your going to make turns I'd recommend learning more about vehicle nodes. I've used structs before, and it is possible. If it is the better solution for you to use structs, I would set them up as the target of each, turning them as it goes around the track. Then in script turn the cart to the next structs angle over the time it takes the cart to get there, continuing this until you have defined a kvp that says to stop. In the end you would have a loop of structs as each the target of the previous, with two of them having kvps to stop it. MoveToNext function would be edited to make this happen. I would suggest a while loop, that checks for that kvp. When defined and equal to stop, it would stop. In the while loop I would get the distance to the next struct, which would be the target of the current struct, and the angle of the next struct. Rotate to that angle and move to that struct, track the last struct, and wait the time it takes.
Setup a trigger multiple and target the cart model. Then target a struct where the cart will end up. Then target a script_brushmodel from the cart. Then cut that brushmodel and wrap your cart with it. Place the trigger multiple in the base of the cart, just above the script_brushmodel.
/* ##################### by: M.A.K.E C E N T S ##################### Script:
Add to main in mapname.gsc cart::init( );
Add to top of mapname.gsc #using scripts\zm\cart;
Add to zone file scriptparsetree,scripts/zm/cart.gsc
//below > stands for autotargets trigger_multiple at bottome of cart> cartmodel at starting position> brush_models wrapping the cart struct, just one, where you want it to end ############################################################################### */
#namespace cart;
function init() { level.carttime = 10;//adjust time it takes to get to other station level.cartloop = true; carts = GetEntArray("carts","targetname");//triggers array::thread_all(carts, &CartSetup); } function CartSetup() { cart = GetEnt(self.target,"targetname"); self EnableLinkTo(); self linkto(cart); cart LinkPeices(); self thread CartMove(cart); } function CartMove(cart) { cart.a = cart.origin; cart.b = struct::get(cart.target, "targetname").origin; while(1) { self waittill("trigger"); self MoveToNext(cart); wait(.05); } } function MoveToNext(cart) { if(Distance(cart.origin,cart.a)<10) { cart MoveTo(cart.b,level.carttime); } else { cart MoveTo(cart.a,level.carttime); } wait(level.carttime); wait(2);//waits so the cart doesn't go back right away } function LinkPeices() { peices = GetEntArray(self.target,"targetname"); foreach(p in peices) { p LinkTo(self); } }
Also, I cant get this to work. I know I've set it up just like you said. I dont know if you forgot but I gave the script_multiple a targetname of carts like it says in the script and still didnt work. Any ideas why?
Also, I cant get this to work. I know I've set it up just like you said. I dont know if you forgot but I gave the script_multiple a targetname of carts like it says in the script and still didnt work. Any ideas why?