Difference between revisions of "Entity Mod JSON Format"

From SkyCorp Global
(r35 notifications)
Line 22: Line 22:
 
|boolean
 
|boolean
 
|'''playerOnEnterRoom'''
 
|'''playerOnEnterRoom'''
Can be used to present some special text when player enters a room when this object is inside it.   
+
Can be used to present some special text when player enters a room when this object is inside it or prevent the player from entering.  But if it's not necessary to prevent player from entering, you may want to use the notify version of this function below.   
  
 
Normally true.  If false, will prevent mapscene from doing further room processing (be sure to use a continue scene)
 
Normally true.  If false, will prevent mapscene from doing further room processing (be sure to use a continue scene)
  
As of r35, Lua function will receive these variables as parameters: currentRoom:String, destinationRoom:String (however, currentRoom is placeholder.  It can be queried for manually if needed based on entity current position)
+
As of r35, Lua function will receive these variables as parameters:  
 +
 
 +
- currentRoom:String (however, currentRoom is placeholder.  It can be queried for manually if needed based on entity current position)
 +
 
 +
- destinationRoom:String
 
|-
 
|-
 
|boolean
 
|boolean
Line 35: Line 39:
 
Normally true.  If false, will prevent mapscene from doing further room processing (be sure to use a continue scene)  
 
Normally true.  If false, will prevent mapscene from doing further room processing (be sure to use a continue scene)  
  
As of r35, Lua function will receive these variables as parameters: currentRoom:String, destinationRoom:String, destinationRoomID:int (however, currentRoom is placeholder.  It can be queried for manually if needed based on entity current position)  
+
As of r35, Lua function will receive these variables as parameters:
 +
 
 +
- currentRoom:String (however, currentRoom is placeholder.  It can be queried for manually if needed based on entity current position)  
 +
 
 +
- destinationRoom:String
 +
 
 +
- destinationRoomID:int 
 
|-
 
|-
 
|boolean
 
|boolean

Revision as of 06:56, 27 December 2018

Entity JSON supports a variety of parameters to create custom objects.

Fixed fields

A "type" of "ENTITY" should be used when creating an entity mod.

An optional "id" parameter can be used to refer to this type of entity (for instance in Entity.generate() to programmatically create additional entities). Be careful not to use the same id as another mod -- if you use the same mod name as your mod wiki page, you can be assured of no conflicts. (Introduced in r25)

Dynamic fields

JSON definitions can specify each as programmable (LUA) or literal values.

Return Type Parameter
string name

Title of the item.

string description

Description of the item when looked at.

boolean playerOnEnterRoom

Can be used to present some special text when player enters a room when this object is inside it or prevent the player from entering. But if it's not necessary to prevent player from entering, you may want to use the notify version of this function below.

Normally true. If false, will prevent mapscene from doing further room processing (be sure to use a continue scene)

As of r35, Lua function will receive these variables as parameters:

- currentRoom:String (however, currentRoom is placeholder. It can be queried for manually if needed based on entity current position)

- destinationRoom:String

boolean playerAttemptLeaveRoom

Can be used to prevent player from leaving room when in same room as entity.

Normally true. If false, will prevent mapscene from doing further room processing (be sure to use a continue scene)

As of r35, Lua function will receive these variables as parameters:

- currentRoom:String (however, currentRoom is placeholder. It can be queried for manually if needed based on entity current position)

- destinationRoom:String

- destinationRoomID:int

boolean isExaminable

Allow player to examine object?  (This is the page description is displayed on. Otherwise will be invisible to player).

boolean isUseable

Display the 'use' button on the examine item page?

boolean doUse

Action to do on using entity.

Usually should return true -- this will cause a continue scene after the text.

For a manual continue or a different scene change, return false.

boolean isPickupable

Should a pick-up item be displayed on item page if item is in the world?

boolean playerAttemptPickupCheck

Player has opted to pick up the item (may output descriptive message to screen)

Returns if successful in pickup attempt.

boolean isDropable

Should a drop item be displayed on item page if item is in inventory?

boolean playerAttemptDropCheck

Player has opted to drop the item. Return if successful in drop attempt.

void inInventoryTick

Called each turn the item exists in the player's inventory.

void inWorldTick

Called each turn the item exists on the map somewhere (may not be called if player is on a different map).

void notifyPlayerEnterRoom

Notify object that player has just entered the same room as us.

Okay to output to screen - this is called after showScene() of the room.

As of r35, Lua function will receive these variables as parameters:

- arrivingFromRoom    String name of room that was arrived from (before this room)

- arrivingFromRoomID    ID of room arriving from (before this room)

void notifyPlayerEnterRoomPreScene

Notify object that player has just entered the same room as us

This variant happens BEFORE showScene() is called, so is best for when entities are moving in/out based on player actions.

Don't output to screen using this call - it will be eaten by showScene()

As of r35, Lua function will receive these variables as parameters:

- arrivingFromRoom    String name of room that was arrived from (before this room)

- arrivingFromRoomID    ID of room arriving from (before this room)

void notifyPlayerLeftRoom

Notify entity of the room the player is leaving that the player left successfully.  Entities should not write to the screen since showScene() will immediately overwrite it.

The player's position has already been updated with the correct location by this point.

As of r35, Lua function will receive these variables as parameters:

- originalRoomName    

- originalRoomID