Making a object move to a specific direction using command
sasha2cool
28 Mar 2018, 17:58In making a game with horse riding,
You know how on the side of the text box like Once: or B (Bold)
Is there a way I can use that to make a object move to a direction? With a command like:
Ride horse west
Like where west is it kind of be like [direction]
The Pixie
28 Mar 2018, 20:29It will be very much like this:
https://textadventures.co.uk/forum/quest/topic/guvemyyxheio3tiogk6m9q/push-object-direction
And the sequel:
http://textadventures.co.uk/forum/quest/topic/2pwcb_0rikapdrldyr2yva/push-object-direction

K.V.
28 Mar 2018, 23:25Pixie's suggestion is the best solution.
If you want to actually ride the horse around, you could try this (it might work):
http://textadventures.co.uk/forum/samples/topic/chdetokj-0gyxr-abcmktg/horselib
This is new code, and there may be bugs!
Be sure to test this on a copy of your game, not the game itself!!!

K.V.
29 Mar 2018, 18:10A simple solution which does not include actually riding the horse around (which I am stealing from NecroDeath) would be this:
Create a command: ride_horse_cmd
The pattern:
ride #object# #exit#
The script:
if (not object = horse) {
msg ("You can't ride " + object.article + ".")
}
else {
if (exit.visible) {
if (exit.locked) {
msg (exit.lockmessage)
}
else if (exit.runscript) {
if (HasScript(exit, "script")) {
// Move the horse first, so it shows up in the next room's description.
MoveObject (object, exit.to)
do (exit, "script")
}
}
else if (exit.lookonly) {
msg ("You can't go there.")
}
else {
if (HasString(exit, "message")) {
if (not exit.message = "") {
if (game.clearscreenonroomenter) {
game.currentexitmessage = exit.message
}
else {
msg (exit.message)
}
}
}
// Move the horse first, so it shows up in the next room's description.
MoveObject (object, exit.to)
game.pov.parent = exit.to
}
}
else {
msg ("You can't go there.")
}
}
mrangel
29 Mar 2018, 19:56This part of the code looks odd:
if (HasScript(exit, "script")) {
// Move the horse first, so it shows up in the next room's description.
MoveObject (object, exit.to)
do (exit, "script")
}
}
In a lot of cases, an exit with a script might prevent you from travelling. In this case, you would likely want:
if (HasScript(exit, "script")) {
// Move the horse first, so it shows up in the next room's description.
MoveObject (object, exit.to)
do (exit, "script")
// Move the horse back if the player hasn't moved
if (game.pov.parent = exit.parent) {
object.parent = exit.parent
}
}
}
It might also make sense for an exitscript to get a parameter identifying the horse in this case.

K.V.
29 Mar 2018, 20:31Thanks, mrangel!
I was supposed to make a note about the exits having scripts which might do something other than move the player to the target room, but I completely forgot. I'm glad I did, too, because your solution to that is much better than what I was thinking about doing!