Map Problems With Creating Room Objects [SOLVED]
1234676543224
15 Feb 2022, 20:13Hello,
I am trying to clone rooms using this code
obj = GetObject("new"+game.newroom)
obj.alias = name
obj.parent = fromRoom.parent
CreateBiExits ("north", fromRoom, obj)
game.newroom = game.newroom+1
game.exits = game.exits+1
and while it does clone the rooms, the map does nothing at all. The player yellow dot does not move.
Any suggestions?
Thank you
mrangel
15 Feb 2022, 23:33I assume you're actually cloning the room at the start?
Do you mean that the dot on the map doesn't move when the player goes into the new room? There's two possible issues here, so I'll address them one at a time.
Firstly, when the player enters a room, it calculates the map coordinates of all the room's exits and the rooms they lead to. That means that if you create an exit from the room the player is in, its coordinates won't be generated unless the player goes back and reenters the current room; which can mess up your map in weird and counterintuitive ways.
If you are creating an exit from the current room, you should probably do:
Grid_CalculateMapCoordinates (game.pov.parent, game.pov)
Grid_Redraw()
Secondly, CreateBiExits
for some reason creates nondirectional exits, which the map doesn't recognise.
So instead of:
CreateBiExits ("north", fromRoom, obj)
you should do:
create exit ("north", fromRoom, obj, "northdirection")
create exit ("south", obj, fromRoom, "southdirection")
The first parameter to create exit ("north") is the name that is displayed to the player; the last ("northdirection") is the name of a type, and is used by the map to decide where to draw the new room relative to the old one.
If this is a pain, you could modify the function like this:
<function name="CreateBiExits" parameters="dir, from, to">
if (ListContains (Split("north;south;east;west;northeast;northwest;southeast;southwest;up;down;in;out"), dir)) {
create exit (dir, from, to, LCase (dir) + "direction")
create exit (ReverseDirection (dir), to, from, LCase (reverse) + "direction")
}
else {
create exit (dir, from, to)
create exit (ReverseDirection (dir), to, from)
}
</function>
(off the top of my head; I can't test it, because you can only modify core functions in the desktop version)
1234676543224
16 Feb 2022, 00:18Thank you for helping me once again @mrangel! My problem is solved.