Using item to change maps - need help

As indicated by the title, I'm trying to do a thing where a character puts on a ring, and then the coding has that action move them to a new map. Unfortunately, well, I'm very, very new at this, so I haven't the foggiest idea how I would go about setting that up. Any help would be greatly appreciated.

I'm using the online editor, for clarification.


I don't know about the on-line editor, other than there are several things you can't do that the off-line editor does,
but....
On the ring object, on the inventory tab...
Under TAKE,
Check Object can be taken,
After taking the object,
You can run a script:
Move object player to object [target room]
This will move the player to that room when they take the ring.
You could use "wear" but that will clash with a built in command...
BUT BE WARNED...
If you are using the displayed map, and the player has not been to that room before,
you will get an error message, or rather several...

Take can also be told directly to Run a script... (same as above)

(By "map" I assume you are saying a "room" …)


Objects -> Verbs -> Add -> Verb Name: equip

'ring' Object -> 'Verbs' Tab -> Add -> 'equip'

'ring' Object -> 'Attributes' Tab -> Attributes -> look on the right side (scroll down) to see if the 'equip' Script Attribute is there or not

// if the 'equip' Script Attribute is NOT already there:

'ring' Object -> 'Attributes' Tab -> Attributes -> Add -> (see below)

[Object Name: ring]
Attribute Name: equip
Attribute Type: script
Attribute Value: (see below)

add new script -> 'variables' category/section -> 'set a variable or attribute' Script -> (see below)

set variable ring.parent = [EXPRESSION] player // moves/sets the 'ring' Object to the 'player' Player Object (the "inventory")

add new script -> 'variables' category/section -> 'set a variable or attribute' Script -> (see below)

set variable player.parent = [EXPRESSION] NAME_OF_YOUR_DESIRED_DESTINATION_ROOM

// if the 'equip' Script Attribute is already there:

'ring' Object -> 'Attributes' Tab -> Attributes -> 'equip' Script Attribute -> (see below, changing/setting its Attribute Value)

add new script -> 'variables' category/section -> 'set a variable or attribute' Script -> (see below)

set variable ring.parent = [EXPRESSION] player // moves/sets the 'ring' Object to the 'player' Player Object (the "inventory")

add new script -> 'variables' category/section -> 'set a variable or attribute' Script -> (see below)

set variable player.parent = [EXPRESSION] NAME_OF_YOUR_DESIRED_DESTINATION_ROOM


note that there's an issue with the map/grid when NOT using exits to change locations:

https://docs.textadventures.co.uk/quest/showing_a_map.html (scroll down to the teleporting section)


I'm not seeing any "attributes" tab, is there something I'm missing?


There's no attributes tab on the online version.

If you're using the built-in wearables system then I'd suggest the best way to run a script when putting on the ring is to create a script attribute named changedworn. This will be run every time the player puts on or takes off the item.

You'd create a script attribute something like this:

if (this.worn) {
  MoveObject (player, name of room)
}

In the online version it's not so easy to create attributes. You need to set a script that runs at the start of the game, that creates the attribute for you. So you'd tick "Run an initialisation script" on the object's 'features' tab, and then in the initialisation script put:

this.changedworn => {
  if (this.worn) {
    MoveObject (player, name of room)
  }
}

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums