Sample: GPS

From SkyCorp Global
Jump to: navigation, search
Note - this entity is a modification for The Underworld. You can put it in-game by visiting the Debug Monster Control Panel in the debug rooms. The debug rooms are accessed via the Debug Box, an item available to all Private Build Backers which is located in the first room you spawn in (Ex's Apartment).

Entity Details

This entity is intended for example purposes to demonstrate an object that can check its location and the player's location. It could also be useful for finding the RoomID of various in-game rooms.

Author: SkyCorp

Entity JSON Code

{
	"type": "ENTITY",
	"name":
	{
		"literalString": "GPS"
	},
	"description":
	{
		"programString": true
	},
	"isPickupable":
	{
		"literalBoolean": true
	},
	"luac": "G0x1YVEAAQQEBAgACQAAAEBHUFMubHVhAAAAAAAAAAAAAAACAgMAAAAkAAAABwAAAB4AgAABAAAABAwAAABkZXNjcmlwdGlvbgABAAAAAAAAAAEAAAAdAAAAAAAABisAAAAFQAAABoBAAByAgAAHAAAAAQABAEFAAQAVQAAAB8AAAAUAAABFgAEAF0AAABaAAoAFwAEABgBCAByAgAAGgEAAHICAAAcAAAAFwAAAQUACABVAAAAHwAAAFsAAgAXAAABBgAIAFUAAAAfAAAAFwAAAQcACAIUAAACGAEMBwUADAAUBAAAGgUMCHIGAAAbBQwIcgYAAQQEEABVAAQAHwAAABcAAAB4AAAEeAIAAEQAAAAQJAAAAbG9jYXRpb24ABAUAAAB0aGlzAAQMAAAAZ2V0TG9jYXRpb24ABBAAAABkZXNjcmlwdGlvblRleHQABDcAAABUaGUgR1BTIGJsaW5rcywgZGlzcGxheWluZyBibGFjayB0ZXh0IG9uIGEgbGltZSBncmVlbiAABA4AAABMQ0Qgc2NyZWVuOiAnAAQFAAAAbnVsbAAEBwAAAFBsYXllcgAEDAAAAGdldEluc3RhbmNlAAQZAAAASW4gcGxheWVyJ3MgaW52ZW50b3J5IEAgAAQQAAAASW4gdGhlIHdvcmxkIEAgAAQIAAAAUm9vbUlEIAAEBwAAAHJvb21JRAAEBwAAACwgTWFwIAAEBwAAAGdldE1hcAAECAAAAGdldE5hbWUABAIAAAAnAAAAAAArAAAABQAAAAUAAAAFAAAABQAAAAgAAAAJAAAACQAAAAkAAAAMAAAADAAAAAwAAAAMAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEQAAABEAAAARAAAAEQAAABEAAAATAAAAEwAAABMAAAATAAAAFwAAABcAAAAXAAAAFwAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABsAAAAbAAAAHQAAAAAAAAAAAAAAAwAAAB0AAAABAAAAHQAAAAAAAAAAAAAA"
}

LUA Source Code

function description()

   -- 'this' is a predefined keyword that refers to this entity (in this case, 
   -- the GPS)
   location = this.getLocation();

   -- All text will be added to 'descriptionText' string, and returned.
   descriptionText = "The GPS blinks, displaying black text on a lime green " ..
      "LCD screen: '";

   -- Check if GPS item is in inventory or in world
   if location == null then
      -- Item's Location is null, which means GPS is in player inventory.
      -- Because of this, this script must check player location instead of
      -- item location.
      location = Player.getInstance().getLocation();
      descriptionText = descriptionText .. "In player's inventory @ ";
   else
      descriptionText = descriptionText .. "In the world @ ";
   end

   -- Add RoomID & Map Name to description text
   descriptionText = descriptionText .. "RoomID " .. location.roomID ..
      ", Map " .. location.getMap().getName() .. "'";

   -- Return text to be displayed by game
   return descriptionText;

end