Sample: Pants Enthusiast

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 use the new clothing functions in r25.

Author: SkyCorp

Entity JSON Code

{
	"type": "ENTITY",
	"name":
	{
		"literalString": "Pants Enthusiast"
	},
	"description":
	{
		"programString": true
	},
	"doUse":
	{
		"programBoolean": true
	},
	"isUseable":
	{
		"literalBoolean": true
	},
	"luac": "G0x1YVEAAQQEBAgAEwAAAEBjbG90aGluZ0NoZWNrLmx1YQAAAAAAAAAAAAAAAgIFAAAAJAAAAAcAAAAkQAAAB0AAAB4AgAACAAAABAwAAABkZXNjcmlwdGlvbgAEBgAAAGRvVXNlAAIAAAAAAAAAAQAAABkAAAAAAAAENQAAAAVAAAAGgEAAHICAAAcAAAABAAEAQUABABVAAAAHwAAABQAAAAaAQQBBwAEAHIAAARoAAAAWwAaABQAAAAZAQgBBwAEAHIAAAQcAAgAFAAIABoBCAByAgAAaQAAAFgACgAXAAABBwAIAhQACAIYAQwGcgIAAwUADABXAAAAHwAAAFgADgAXAAABBgAMAhQACAIYAQwGcgIAAwcADABXAAAAHwAAAFsAAgAXAAABBAAQAFUAAAAfAAAAFwAAAQUAEABVAAAAHwAAABcAAAB4AAAEeAIAAEgAAAAQHAAAAcGxheWVyAAQHAAAAUGxheWVyAAQMAAAAZ2V0SW5zdGFuY2UABBAAAABkZXNjcmlwdGlvblRleHQABDgAAABUaGUgbWFuIGdyZWV0cyB5b3UgYXMgeW91IGFwcHJvYWNoLiAgIkkgbGlrZSByZXZlYWxpbmcgAAQXAAAAY2xvdGhpbmcsIiBoZSBzYXlzLiAgIgAEDAAAAGhhc0Nsb3RoaW5nAAQFAAAAbGVncwAEBgAAAHBhbnRzAAQMAAAAZ2V0Q2xvdGhpbmcABBYAAABpc0NvbmNlYWxhYmxlQ2xvdGhpbmcABAYA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EAgAAACEABC8AAABJZiB5b3UgZmluZCBhbnkgcGFudHMsIHBsZWFzZSBnaXZlIHRoZW0gdG8gbWUhAAQZAAAALCIgdGhlIHN0cmFuZ2UgbWFuIHNheXMuAAAAAAAtAAAAHAAAABwAAAAcAAAAHAAAAB4AAAAeAAAAHgAAAB4AAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAjAAAAIwAAACMAAAAjAAAAIwAAACQAAAAkAAAAJAAAACQAAAAlAAAAJQAAACUAAAAnAAAAJwAAACcAAAAnAAAAJwAAACcAAAAnAAAAJwAAACoAAAAqAAAAKgAAACoAAAAtAAAALQAAAC0AAAAtAAAALwAAAC8AAAAwAAAAAAAAAAAAAAAFAAAAGQAAAAEAAAAwAAAAGwAAADAAAAAAAAAAAAAAAA=="
}

LUA Source Code

function description()
	player = Player.getInstance();
	descriptionText = 'The man greets you as you approach.  "I like revealing ' ..
		'clothing," he says.  "';

	if player.hasClothing("legs") then
		-- Player is wearing pants
		pants = player.getClothing("legs");

		if not pants.isConcealableClothing() then
			-- Player is wearing pants that does not conceal a TF
			descriptionText = descriptionText .. "Nice " .. pants.getName() .. "!";
		else
			-- Player is wearing pants the conceal TF
			descriptionText = descriptionText .. "Oh, you're wearing " .. pants.getName() ..
				"?  That's okay I guess...";
		end
	else
		-- Player is not wearing any pants
		descriptionText = descriptionText .. "But wearing no pants is *too* revealing!";
	end
		
	descriptionText = descriptionText .. '"\n\n"Hey, want to give me some pants?," he asks.';
	return descriptionText;
end

function doUse()
	player = Player.getInstance();

	MainScreen.addGameText('"');

	if player.hasClothing("legs") then
		-- Player is wearing pants, 'give' them to NPC.  (Here, they are just
		-- deleted for simplicity since they are never referred to again later)
		pants = player.getClothing("legs");
		pantsName = pants.getName();
		pants.deleteEntity();

		MainScreen.addGameText("Thanks for the " .. pantsName .. "!");
	else
		-- Player not wearing pants.
		MainScreen.addGameText("If you find any pants, please give them to me!");
	end

	MainScreen.addGameText('," the strange man says.');

	return true; -- Automatic continue scene
end