Sample: Player Location

From SkyCorp Global
Note - this entity is a modification for The Underworld. Visit the new Mods Portal for more mods, mods on the wiki are no longer maintained. You can put it in-game by visiting the Debug Mod Control Panel in the debug rooms and browse to this mod or copy/paste the JSON below into the program window.

Entity Details

This entity demonstrates how to access the player's position.

Author: SkyCorp

Minimum Required Version: r22.6

Entity JSON Code

{
	"type": "ENTITY",
	"name":
	{
		"literalString" : "Player Location Sample"
	},
	"description":
	{
		"programString": true
	},
	"luac": "G0x1YVEAAQQEBAgADQAAAEB0ZXN0TWFwLmx1YQAAAAAAAAAAAAAAAgIDAAAAJAAAAAcAAAAeAIAAAQAAAAQMAAAAZGVzY3JpcHRpb24AAQAAAAAAAAABAAAADgAAAAAAAAcSAAAABQAAAAZAQAAcgIAARoBAAFyAgACBwAAAxgDBAJXAAAHGQMEA3ICAAMaAwQHcgIAAAAEAAUHBAQCAAYABlYABAp4AAAEeAIAACAAAAAQHAAAAUGxheWVyAAQMAAAAZ2V0SW5zdGFuY2UABAwAAABnZXRMb2NhdGlvbgAEFgAAAFBsYXllciBpcyBpbiBSb29tIElEIAAEBwAAAHJvb21JRAAEBwAAAGdldE1hcAAECAAAAGdldE5hbWUABAoAAAAgb24gTWFwOiAAAAAAABIAAAADAAAAAwAAAAMAAAAEAAAABAAAAAYAAAAGAAAABgAAAAgAAAAIAAAACAAAAAgAAAAKAAAACgAAAAoAAAAKAAAADAAAAA4AAAAEAAAABwAAAHBsYXllcgADAAAAEQAAAA8AAABwbGF5ZXJMb2NhdGlvbgAFAAAAEQAAABAAAABkZXNjcmlwdGlvblRleHQACAAAABEAAAAIAAAAbWFwTmFtZQAMAAAAEQAAAAAAAAADAAAADgAAAAEAAAAOAAAAAAAAAAAAAAA="	
}

LUA Source Code

function description()

        local player = Player.getInstance();
        local playerLocation = player.getLocation();

        local descriptionText = "Player is in Room ID " .. playerLocation.roomID;

        local mapName = playerLocation.getMap().getName();

        descriptionText = descriptionText .. " on Map: " .. mapName;

        return descriptionText;

end