Create NPC follower in GUI version of quest

NecroDeath
12 Jan 2017, 15:56Hi,
This has been asked before but only in terms of using code, is there as straightforward way of getting a NPC to follow the player?
Thanks.
hegemonkhan
12 Jan 2017, 17:36'player' Player Object -> 'Attributes' Tab -> Attributes -> Add -> (see below)
(Object Name: player)
Attribute Name: changedparent
Attribute Type: script
Attribute Value: (scriping/add new scripts, see below)
(quest has a special 'changedXXX' Script Attribute: upon the specified Attribute changing its Values, it'll run/do/activate/execute these/your added scripts to/for/within the special 'changedXXX' Script Attribute)
add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> (see below, repeat as needed)
set variable NAME_OF_FOLLOWING_OBJECT_1.parent = [EXPRESSION] player.parent
set variable NAME_OF_FOLLOWING_OBJECT_2.parent = [EXPRESSION] player.parent
etc etc etc more or less
replace 'player' if you've changed the name of your default 'player' Player Object (or you can also use: game.pov)
replace my use of 'NAME_OF_FOLLOWING_OBJECT_1...N' with the name of your Objects that you want to follow your Player Object
in code it'll look like this, an example:
<object name="player">
<attr name="changedparent" type="script">
npc_1.parent = player.parent
npc_2.parent = player.parent
npc_3.parent = player.parent
</attr>
</object>
<object name="npc_1">
</object>
<object name="npc_2">
</object>
<object name="npc_3">
</object>
if you're going to move a lot of Objects... then you'd need to use Object List Attributes, but this is more advanced stuff:
<object name="player">
<attr name="following_npc_list" type="objectlist">npc_1;npc_2;npc_3;npc_4;npc_5;etc etc etc</attr>
<attr name="changedparent" type="script">
foreach (team_member_placeholder_object_variable, player.following_npc_list) {
team_member_placeholder_object_variable.parent = player.parent
}
</attr>
</object>
<object name="npc_1">
</object>
<object name="npc_2">
</object>
<object name="npc_3">
</object>
<object name="npc_4">
</object>
<object name="npc_5">
</object>
etc etc etc more or less Objects
you can also take a look at this Attribute and 'if' Script usage guide too if interested:
http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk
http://textadventures.co.uk/forum/quest/topic/5387/i-really-need-help (a demo game step by step guide on basic attribute usage)

Father
12 Jan 2017, 19:59Perhaps you might try
Go to 'Game'
scripts tab.
Script when entering a room. Move required player object to current room.
You may need to set an ' if ' on the start of the script to require a flag. Then set flag to operate or be removed when the follower starts ( or stops ) following.

NecroDeath
12 Jan 2017, 22:04Thanks both, I'll try your approach Father, seems simplest solution if it works.

NecroDeath
12 Jan 2017, 22:18Father - it works, but the npc doesn't appear in the room description upon entering new location, but the NPC is there and is listed if I then 'look', is there a way to fix this?
hegemonkhan
13 Jan 2017, 00:56the 'onenterroom' Script (which has your following/move code/action) is probably running AFTER the 'NAME_OF_ROOM.description' String/Script Attribute
you can turn off the room description script ('game' Game Settings Object -> 'features' Tab -> the option to do so --- or: 'whatever' Object -> 'room descriptions' Tab -> the option to do so), and within your 'ononenterroom' Script, you can add in this (after/below your move and/or other scripts --- have it be your last / most-bottom script):
add new script -> ?output? section/category -> 'call function' Script -> (see below)
Function name text box: ShowRoomDescription
Add Parameters: (don't add in anything / leave blank)
http://docs.textadventures.co.uk/quest/functions/corelibrary/showroomdescription.html

Father
13 Jan 2017, 19:13That works. I just tried it. I didn't realise you could do that. I was going to suggest putting in a script message " Bob follows you as you move on." Or something similar, but that is far better.

NecroDeath
13 Jan 2017, 20:09Cheers! Works a treat.