Difference between revisions of "Sample: GPS"

From SkyCorp Global
(Created page with "{{EntityModHeader}} == Entity Details == ''This entity is intended for example purposes to demonstrate an object that can check its location and the player's location. It co...")
 
(Tags: Removed redirect, Visual edit: Switched)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
{{EntityModHeader}}
 
{{EntityModHeader}}
  
== Entity Details ==
+
Moved to: https://skycorp.global/skyscript/mods/v/11/sample-gps
''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 ==
 
 
 
<syntaxhighlight lang="json">
 
{
 
"type": "ENTITY",
 
"name":
 
{
 
"literalString": "GPS"
 
},
 
"description":
 
{
 
"programString": true
 
},
 
"isPickupable":
 
{
 
"literalBoolean": true
 
},
 
"luac": "G0x1YVEAAQQEBAgACQAAAEBHUFMubHVhAAAAAAAAAAAAAAACAgMAAAAkAAAABwAAAB4AgAABAAAABAwAAABkZXNjcmlwdGlvbgABAAAAAAAAAAEAAAAdAAAAAAAABisAAAAFQAAABoBAAByAgAAHAAAAAQABAEFAAQAVQAAAB8AAAAUAAABFgAEAF0AAABaAAoAFwAEABgBCAByAgAAGgEAAHICAAAcAAAAFwAAAQUACABVAAAAHwAAAFsAAgAXAAABBgAIAFUAAAAfAAAAFwAAAQcACAIUAAACGAEMBwUADAAUBAAAGgUMCHIGAAAbBQwIcgYAAQQEEABVAAQAHwAAABcAAAB4AAAEeAIAAEQAAAAQJAAAAbG9jYXRpb24ABAUAAAB0aGlzAAQMAAAAZ2V0TG9jYXRpb24ABBAAAABkZXNjcmlwdGlvblRleHQABDcAAABUaGUgR1BTIGJsaW5rcywgZGlzcGxheWluZyBibGFjayB0ZXh0IG9uIGEgbGltZSBncmVlbiAABA4AAABMQ0Qgc2NyZWVuOiAnAAQFAAAAbnVsbAAEBwAAAFBsYXllcgAEDAAAAGdldEluc3RhbmNlAAQZAAAASW4gcGxheWVyJ3MgaW52ZW50b3J5IEAgAAQQAAAASW4gdGhlIHdvcmxkIEAgAAQIAAAAUm9vbUlEIAAEBwAAAHJvb21JRAAEBwAAACwgTWFwIAAEBwAAAGdldE1hcAAECAAAAGdldE5hbWUABAIAAAAnAAAAAAArAAAABQAAAAUAAAAFAAAABQAAAAgAAAAJAAAACQAAAAkAAAAMAAAADAAAAAwAAAAMAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEQAAABEAAAARAAAAEQAAABEAAAATAAAAEwAAABMAAAATAAAAFwAAABcAAAAXAAAAFwAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABsAAAAbAAAAHQAAAAAAAAAAAAAAAwAAAB0AAAABAAAAHQAAAAAAAAAAAAAA"
 
}
 
</syntaxhighlight>
 
 
 
== LUA Source Code ==
 
 
 
<syntaxhighlight lang="lua">
 
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
 
</syntaxhighlight>
 
 
 
[[Category:Mods]]
 
[[Category:Entity Mods]]
 

Latest revision as of 02:06, 14 July 2023

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.

Moved to: https://skycorp.global/skyscript/mods/v/11/sample-gps