Echo Hollow

Gender-Bending Interactive Stories! :D

User Tools

Site Tools


libtf:documentation:api:persistentobject

This is an old revision of the document!


<-- Back

LibTF.PersistentObject

Blurb.

(PersistentObject).id

  • Getter: Returns the persistence id of this object.
  • Setter: None.

(PersistentObject).parentId

  • Getter: Returns the persistence id of this object's parent, or null if it doesn't have a parent.
  • Setter: None.

(PersistentObject).parent

  • Getter: Returns fully instantiated parent of this object.
  • Setter: None.

(PersistentObject).hasPersistent( subid )

  • subid is a persistence id fragment referring to some child data record for this object.
  • Returns: True if there is a record for the child data, or False if there is not.
  • Throws: Error if: Something goes wrong.

Method blurb.

Example code.
    
	this.= function( subid )
	{
		if( subid == null )
			throw "Null id!";
		return Persistence.has( id+"."+subid );
	}
	
	this.getPersistent = function( subid )
	{
		if( subid == null )
			throw "Null id!";
		if( this.hasPersistent(subid) )
			return Persistence.get( id+"."+subid );
		return null;
	}
	
	this.setPersistent = function( subid, value )
	{
		if( subid == null )
			throw "Null id!";
		return Persistence.set( id+"."+subid, value );
	}
	
	this.resetPersistent = function( subid )
	{
		if( subid == null )
			throw "Null id!";
		return Persistence.reset( id+"."+subid );
	}
    
    this.getName = function()
    {
    	if( this.hasPersistent("name") )
    		return this.getPersistent("name");
    	return null;
    }
    
	this.getAName = function()
	{
		var name = this.getName();
		if( this.getPersistent("nameIsProper") || name.charAt(0) == name.charAt(0).toUpperCase() )
			return name;
		if( this.hasPersistent("nameIrregularArticle") )
			return this.getPersistent("nameIrregularArticle")+" "+name;
		switch( name.charAt(0) )
		{
			case 'a':
			case 'e':
			case 'i':
			case 'o':
			case 'u':
				return "an " + name;
			default:
				return "a " + name;
		}
	}

<-- Back

libtf/documentation/api/persistentobject.1519524244.txt.gz ยท Last modified: 2018/02/24 18:04 by lee