scripts/scrGetRoomX.gml
From spelunky.gmk, Spelunky Classic 1.1's source, © 2008, 2009 Derek Yu and Mossmouth, LLC, shown whole under the Spelunky User License v1.1b. Extracted by spelunky.ai's tools, an unofficial fan project, one file per script or event; the // ==== lines are the extractor's, naming each action of the event. Some scripts are others' work that Derek Yu credits in the source's readme.txt: Martin Piecyk's platform engine, ChevyRay's view scaling scripts and tsg1zzn's Super Sound System.
The script scrGetRoomX, 31 lines of GML.
//// scrGetRoomX(x)//// Returns the horizontal room number of a room given the x-coord.///********************************************************************************** Copyright (c) 2008, 2009 Derek Yu and Mossmouth, LLC This file is part of Spelunky. You can redistribute and/or modify Spelunky, including its source code, under the terms of the Spelunky User License. Spelunky is distributed in the hope that it will be entertaining and useful, but WITHOUT WARRANTY. Please see the Spelunky User License for more details. The Spelunky User License should be available in "Game Information", which can be found in the Resource Explorer, or as an external file called COPYING. If not, please obtain a new copy of Spelunky from <http://spelunkyworld.com/> ***********************************************************************************/tx = argument0;if (tx < 160+16) return 0;else if (tx >= 160+16 and tx < 320+16) return 1;else if (tx >= 320+16 and tx < 480+16) return 2;else if (tx >= 480+16) return 3;return -1;