Entity Mod JSON Format: Difference between revisions
(Created page with ".") |
(Add NameType parameter to name(...)) |
||
| (17 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
. | 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) | |||
An optional "'''customPublicFunctions'''" parameter is an array of custom lua functions that should be publicly available to other lua scripts. The [[Sample: Radio|radio sample]] shows an example of this. You can pass and return values, however, it's recommened to stick with primitive values when possible. Initial testing shows complex values like Tables and Entities are also okay to pass, but this is not well tested yet. (Introduced in r35) | |||
== Dynamic fields == | |||
JSON definitions can specify each as programmable (LUA) or literal values. | |||
{| class="wikitable" | |||
!Return Type | |||
!Parameter | |||
|- | |||
|string | |||
| | |||
=== name([[Modding:NameType|NameType]] nameType = NameType.Unspecified) === | |||
Title of the item. | |||
A nametype may be parsed to differentiate which type of name is being requested (ex: a button name or dialogue name) | |||
See also: [[Modding:Defining Names|Defining Names]] | |||
|- | |||
|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 | |||
(In r51, the internal way playerAttemptLeaveRoom() works changed to use Locations, however, the modding system has not yet been updated. If you need to use currentRoom or get map information, ask Skye to update this mod API for this function to use Locations also.) | |||
|- | |||
|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 | |||
|- | |||
|string | |||
| | |||
===personalName()=== | |||
A name of them as a person (eg: 'Micky') as opposed to the general name above. This name would be used as the character refers to themselves. Ie, 'I am Micky' as opposed to 'I am Cowgirl Micky'. If you set this, normally the name field would be something more generic, like their species. | |||
Normally when you first encounter an enemy, it just shows their generic type (ex: "AlphaSlug") as their button (UI Name), which is what the main name field is. Their dialogue might use their name (the "GameText" name, which pulls from this personalName field), and if they become your owner, their UI name likely becomes something like "<Honorific> <Personal Name>" | |||
Note, if you set this (or usesRandomizedName() below), it is recommended to not set the overall name function. To set species/initial UI name, you can set the 'name' field in 'initialValues' instead of the 'name' function override. | |||
See also: [[Modding:Defining Names|Defining Names]] | |||
Introduced in r56.1 | |||
|- | |||
|bool | |||
| | |||
===usesRandomizedName()=== | |||
If true, a randomized name will be assigned to this entity. The name will be a common one related to the assigned pronouns of the entity. (Mostly makes sense for NPCs) | |||
Introduced in r56.1 | |||
|- | |||
|string | |||
| | |||
===desiredPlayerSubmissiveType()=== | |||
Can define this if the npc is a dom to tell game text what sorts of sub types to use for its variables. Basically, what sort of dom/sub relationship will the npc form with the player, if the player accepts them as their owner? | |||
Currently, the following sub types are supported: | |||
*Sub (Default) | |||
*Breeder | |||
*Pet | |||
*Slave | |||
Any other string other than the above is currently not supported. | |||
Introduced in r56.1 | |||
|- | |||
|string | |||
| | |||
===pronoun()=== | |||
If an NPC, can set this to the character's pronouns so gametext variables can refer to them properly. | |||
Currently, the following pronoun types are supported: | |||
*Unspecified (default) | |||
*He | |||
*She | |||
*Shi | |||
*It | |||
*They | |||
Any other string other than the above is currently not supported. | |||
Introduced in r56.1 | |||
|} | |||
Latest revision as of 01:47, 9 January 2026
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)
An optional "customPublicFunctions" parameter is an array of custom lua functions that should be publicly available to other lua scripts. The radio sample shows an example of this. You can pass and return values, however, it's recommened to stick with primitive values when possible. Initial testing shows complex values like Tables and Entities are also okay to pass, but this is not well tested yet. (Introduced in r35)
Dynamic fields
JSON definitions can specify each as programmable (LUA) or literal values.
| Return Type | Parameter |
|---|---|
| string |
name(NameType nameType = NameType.Unspecified)Title of the item. A nametype may be parsed to differentiate which type of name is being requested (ex: a button name or dialogue name) See also: Defining Names |
| string |
descriptionDescription of the item when looked at. |
| boolean |
playerOnEnterRoomCan 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 |
playerAttemptLeaveRoomCan 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 (In r51, the internal way playerAttemptLeaveRoom() works changed to use Locations, however, the modding system has not yet been updated. If you need to use currentRoom or get map information, ask Skye to update this mod API for this function to use Locations also.) |
| boolean |
isExaminableAllow player to examine object? (This is the page description is displayed on. Otherwise will be invisible to player). |
| boolean |
isUseableDisplay the 'use' button on the examine item page? |
| boolean |
doUseAction 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 |
isPickupableShould a pick-up item be displayed on item page if item is in the world? |
| boolean |
playerAttemptPickupCheckPlayer has opted to pick up the item (may output descriptive message to screen) Returns if successful in pickup attempt. |
| boolean |
isDropableShould a drop item be displayed on item page if item is in inventory? |
| boolean |
playerAttemptDropCheckPlayer has opted to drop the item. Return if successful in drop attempt. |
| void |
inInventoryTickCalled each turn the item exists in the player's inventory. |
| void |
inWorldTickCalled each turn the item exists on the map somewhere (may not be called if player is on a different map). |
| void |
notifyPlayerEnterRoomNotify 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 |
notifyPlayerEnterRoomPreSceneNotify 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 |
notifyPlayerLeftRoomNotify 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 |
| string |
personalName()A name of them as a person (eg: 'Micky') as opposed to the general name above. This name would be used as the character refers to themselves. Ie, 'I am Micky' as opposed to 'I am Cowgirl Micky'. If you set this, normally the name field would be something more generic, like their species. Normally when you first encounter an enemy, it just shows their generic type (ex: "AlphaSlug") as their button (UI Name), which is what the main name field is. Their dialogue might use their name (the "GameText" name, which pulls from this personalName field), and if they become your owner, their UI name likely becomes something like "<Honorific> <Personal Name>" Note, if you set this (or usesRandomizedName() below), it is recommended to not set the overall name function. To set species/initial UI name, you can set the 'name' field in 'initialValues' instead of the 'name' function override. See also: Defining Names Introduced in r56.1 |
| bool |
usesRandomizedName()If true, a randomized name will be assigned to this entity. The name will be a common one related to the assigned pronouns of the entity. (Mostly makes sense for NPCs) Introduced in r56.1 |
| string |
desiredPlayerSubmissiveType()Can define this if the npc is a dom to tell game text what sorts of sub types to use for its variables. Basically, what sort of dom/sub relationship will the npc form with the player, if the player accepts them as their owner? Currently, the following sub types are supported:
Any other string other than the above is currently not supported. Introduced in r56.1 |
| string |
pronoun()If an NPC, can set this to the character's pronouns so gametext variables can refer to them properly. Currently, the following pronoun types are supported:
Any other string other than the above is currently not supported. Introduced in r56.1 |