Saturday, 4 July 2015

Moving Items Into Your World With TMVT

A short tutorial on how to move new agents into your world by checking their location first with TMVT.

To find a good position for something to appear in the world, use the key command Ctrl-Shift-X. (Docking Station or Docked worlds only, but it will still be valid with C3 standalone.) This will give you two numbers that appear next to your hand in the world. Hover the fingertip over the place you want your agent to appear, and write down the two numbers. These are your coordinates.

mvto will make the top left point of a target agent appear exactly at the coordinates you chose.

mvsf will try to make an item appear in the general vicinity of the coordinates, at a slightly different spot that it considers 'safe'.

So what if you want to use mvto, but you want to make sure that the game won't crash if the spot isn't suitable?

You use a doif block with tmvt.

tmvt is a command that tests if the target can move to the given location and still lie validly within the room system. tmvt returns 1 if it can, 0 if it can't.

*If the test move works
doif tmvt X Y eq 1
*actually move the object to where I want to
mvto X Y
*If the test move doesn't work
*move the item safely to the same location
mvsf X Y
*End the doif block

You can see that you can extend this code to try to place your object in multiple locations, if need be.

I like to first try to move my objects into a C3 location, and then if that isn't valid, move it to a valid DS position - thus incorporating a rough C3/DS check into the positioning of the agent. 'If the player isn't running C3, or a C3-docked world, then they must be running Docking Station!'

There are many, many other ways of running that C3/DS check and positioning the agent appropriately, but this is the one I use.

This can also be used in the push script for vendors to make sure that the vended item is made in a valid place in the world.

No comments:

Post a Comment