help needed with making a folower...
eeveerocks1000
07 Jul 2016, 16:39i am trying to make my own game, and i want to make a wolf follow the player, she is going to be a healer.... but i dont know how to make her follow the player around. code is very new to me, so can i get some help/advice please?
bergedorfcacher
07 Jul 2016, 17:14I'm a newbie myself, but I would guess you can put a script under Objects->game: Script when entering a room
wolf.parent = player.parent
(Assuming your wolf is represented by an object called 'wolf'. :-) )
bergedorfcacher
07 Jul 2016, 17:20Or instead of the line I gave above try this one:
MoveObjectHere (Wolf)
I actually tested this one, works fine.
eeveerocks1000
07 Jul 2016, 17:59yes well i want her to only follow the player when ask to.... not when the game starts....
Father
07 Jul 2016, 18:22Make the wolf invisible until needed
eeveerocks1000
07 Jul 2016, 19:03oh... well heres the thing she is in a forest and the player has to ask her if she wants to go on a grand adventuer.... but i will try figure this out... this is confusing to at the very least.....
bergedorfcacher
07 Jul 2016, 19:56Make a boolean attribute on the Wolf object, say Wolf.hasAgreed, default False. Once the Wolf agrees set that o True. Expand the script I mentioned above to:
if (Wolf.hasAgreed){
MoveObjectHere (Wolf)
}
If you haven't done so so far, you should work through the tutorial, beginners and intermediate parts. WIthout that it might be hard to understand anything anyone says to help you. :-)
Proudly Humble
07 Jul 2016, 21:10From one newbie to another, there is a page on the subject. In that example, it has a on object called "boss" that follows the player. I'd suggest that you use the example, and adapt it for your wolf.
http://docs.textadventures.co.uk/quest/guides/following.html
I would assign two verbs to the wolf, one to tell it to follow, and one to tell it to stay. If you tell it to follow, the wolf will be flagged and then follow you with each turn. When you tell it to stay, it will then be unflagged and then stay in whatever room it is currently in. And if you need it to magically appear when you suddenly need it, but it's in another room, I would set up a command that would move the wolf to my current location.
eeveerocks1000
07 Jul 2016, 22:57how do i make the command only work after you talk to her?
edit- nevermind i think i got this
Proudly Humble
08 Jul 2016, 00:56What I would do is set up the first verb
- Create an object called wolf
- Click the object in the editor to bring up the object setup
- Click on the "verb" tab
- Click on +Add and enter "Lead" in the space given
- Click on "Print a message" and change it to "Run a script"
- Click "Add new script"
- Scroll down the menu until you get to the Variables section and select "Set object flag"
- Pick "wolf" from the options and then enter "following" in the blank space
Now, it's time to set up the second verb.
- Click on +Add again and enter "Stop"
- Repeat the same process as before, except you'll pick "Unset object flag." You'll still put "wolf" and "following" in those last two places.
Now, you need a script to run each turn.
- Click on "game" in the left pane to bring up the game setup tabs.
- Select the Script tab.
- Go down to the turn script section, and click +Add
- Give the script a name, such as "helper wolf" and then click the option to enable the script when the game begins.
- Click on the option to bring up code view.
- Paste this into the space:
if (GetBoolean(wolf, "following")) {
wolf.parent = player.parent
}
At that point, you are ready to run the game, with the wolf to follow you whenever you say "lead wolf" while playing the game. If you say "stop wolf," the wolf will remain at its current location.
hegemonkhan
08 Jul 2016, 03:34just a quick explanation of the concept of the 'parent' Object Attribute:
the default new game is this:
the 'player' Object is contained within the 'room' Object:
<object name="room">
<object name="player">
</object>
</object>
well, this is the exact same thing:
<object name="room">
</object>
<object name="player">
<attr name="parent" type="object">room</attr>
</object>
and this too is the exact same thing:
<game name="xxx">
<attr name="start" type="script">
player.parent = room
</attr>
</game>
<object name="room">
</object>
<object name="player">
</object>
so, the concept:
player.parent = room
wolf.parent = room
'player' and 'wolf' are both inside (contained within) 'room'
player.parent = room
wolf.parent = room2
'player' and 'wolf' are inside different rooms: 'room' vs 'room2'
so, by doing this:
wolf.parent = player.parent
we're setting the 'wolf' to be inside of the same room as the 'player'
conceptually:
wolf.parent = (player.parent = room) -> wolf.parent = room
or
wolf.parent = (player.parent = room2) -> wolf.parent = room2
or
wolf.parent = (player.parent = room99) -> wolf.parent = room99
and if we want the 'player' to be following the 'wolf' (the reverse):
player.parent = wolf.parent
conceptually:
player.parent = (wolf.parent = room) -> player.parent = room