Modding:Map: Difference between revisions

From SkyCorp Global
Jump to navigation Jump to search
(Created page with "A location is a combination of a roomID (int), and a particular Map. == Public Methods == luaMap.addItem = facade.addItem; luaMap.deleteItem = facade.deleteItem; luaMa...")
 
(Bunch of new map functions!)
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
A location is a combination of a roomID (int), and a particular Map.
== Public Static Methods ==
 
=== static Map getMap(string mapName) ===
Gets map object from map name (string).  Returns null if map with that name can not be found.  


== Public Methods ==
== Public Methods ==


luaMap.addItem = facade.addItem;
=== boolean addItem([[Entity]] entity, int roomID) ===
luaMap.deleteItem = facade.deleteItem;
Attempt adding entity to roomID.
luaMap.getRoomName = facade.getRoomName;
 
luaMap.getNamedEntityInRoom = facade.getNamedEntityInRoom;
More performant to use entity's
//luaMap.getEntityInRoomByType = facade.getEntityInRoomByType;
 
luaMap.setTagBoolean = facade.setTagBoolean;
Called during drop item, could also be used to drop new items/loot/etc
luaMap.getTagBoolean = facade.getTagBoolean;
 
luaMap.getRoomIDOfEntity = facade.getRoomIDOfEntity;
=== boolean deleteItem([[Entity]] entity) ===
luaMap.getName = facade.getName;
Attempt removing an item from anywhere in the map
 
Called from pickup.  Could also be used to destroy an item in a room.
 
=== string getRoomName(int roomID) ===
Gets name of room. If no such room, returns "INVALID ROOM"
 
=== [[Entity]] getNamedEntityInRoom(string entityName, int roomID) ===
If the map has the named entity in the given roomID, return it.  Else null.
 
=== [[Entity]] getEntityInRoomByType(class entityClass, int roomID) ===
TODO - not yet hooked up, need to figure out how to best pass class information between AS3/LUA.
 
=== void setTagBoolean(int roomID, string tag, boolean enabled) ===
Sets a tag for a room which can be useful for classifying rooms or applying special properties.
 
This version will set the tag to be either True or False (this system could be expanded in future to allow for string or other object storage inside tags)
 
Tags are used in a number of game locations to keep track of types of places.  For instance, in the strip club, it is used to tag rooms where the patrons can see the player.
 
Parameters:
* roomID: room to change
* tag: tag name to change
* enabled: what to set tag state to (true/false)  (false is same as unset)
 
=== boolean getTagBoolean(int roomID, string tag) ===
Gets a boolean tag for a certain room.  False if room or tag does not exist, or is set to false.  True if it exists and is set to true.
 
=== int getRoomIDOfEntity([[Entity]] entity) ===
Which room is a particular entity in?  If not found, then 0
 
=== string getName() ===
Name of the map
 
=== [[Location]] createLocation(int roomID) ===
Returns the Location for a particular roomID on this map.  Does not check the room ID actually exists.
 
(Introduced in r26)
 
=== void setupRoomIfNeeded(int roomID) ===
For better performance, the contents of a room is not typically loaded into memory until the player has visited it.  This means the entities there are not accessible by code.  This function can be called to load the contents of the room into memory without the player having to visit it.
 
Calling this function will have no effect on non-existent rooms or already loaded rooms.
 
(Introduced in r56.1)
 
=== bool isRoomSetup(int roomID) ===
Checks to see if the target room ID is loaded.  
 
(Introduced in r56.1)
 
=== [[Modding:Entity|Entity]][] getAllEntitiesInRoom(int roomID) ===
Returns a list of all the entities in a given room.  Returns empty list if nothing inside the room.  Returns null if room is not yet loaded (see setupRoomIfNeeded)
 
Example code:  [https://skycorp.global/skyscript/mods/v/93/sample-list-entities-in-room List all entities in room]
 
(Introduced in r56.1)
 
=== [[Modding:Entity|Entity]][] findEntitiesByNameSlow(string name, bool caseSensitive = true, [[Modding:NameType|NameType]] nameType = NameType.Unspecified) ===
Attempts to find all entities with a particular name.  It's usually safer to find an entity based on type (though as of r56.1 this hasn't been exposed yet) as names are subject to change.
 
Returns all the entities with that name on the map.
 
(Introduced in r56.1)
 
=== [[Modding:Entity|Entity]] findEntityByNameSlow(string name, bool caseSensitive = true, [[Modding:NameType|NameType]] nameType = NameType.Unspecified) ===
Attempts to find an entity based on name.  It's usually safer to find an entity based on type (though as of r56.1 this hasn't been exposed yet) as names are subject to change.
 
Returns the first entity with that name on the map.


(Introduced in r56.1)


=== table<character, [[Modding:Location|Location]]> getExits(int roomID) ===
Gets a table containing the exits for a particular room.  If no such room, returns null.  Otherwise, the character will be a cardinal direction abbreviation such as 'n', 'w', 'e', 's'.  The location will be the linked location -- it may be on another map.


=== int roomID ===
Example code:  [https://skycorp.global/skyscript/mods/v/94/sample-list-room-exits List room exits]


=== [[Map (Class)|Map]] getMap() ===
(Introduced in r56.1)
[[Category:LUA Class Reference]]
[[Category:LUA Class Reference]]

Latest revision as of 02:56, 29 January 2026

Public Static Methods

static Map getMap(string mapName)

Gets map object from map name (string).  Returns null if map with that name can not be found.

Public Methods

boolean addItem(Entity entity, int roomID)

Attempt adding entity to roomID.

More performant to use entity's

Called during drop item, could also be used to drop new items/loot/etc

boolean deleteItem(Entity entity)

Attempt removing an item from anywhere in the map

Called from pickup.  Could also be used to destroy an item in a room.

string getRoomName(int roomID)

Gets name of room. If no such room, returns "INVALID ROOM"

Entity getNamedEntityInRoom(string entityName, int roomID)

If the map has the named entity in the given roomID, return it.  Else null.

Entity getEntityInRoomByType(class entityClass, int roomID)

TODO - not yet hooked up, need to figure out how to best pass class information between AS3/LUA.

void setTagBoolean(int roomID, string tag, boolean enabled)

Sets a tag for a room which can be useful for classifying rooms or applying special properties.

This version will set the tag to be either True or False (this system could be expanded in future to allow for string or other object storage inside tags)

Tags are used in a number of game locations to keep track of types of places. For instance, in the strip club, it is used to tag rooms where the patrons can see the player.

Parameters:

  • roomID: room to change
  • tag: tag name to change
  • enabled: what to set tag state to (true/false)  (false is same as unset)

boolean getTagBoolean(int roomID, string tag)

Gets a boolean tag for a certain room.  False if room or tag does not exist, or is set to false. True if it exists and is set to true.

int getRoomIDOfEntity(Entity entity)

Which room is a particular entity in?  If not found, then 0

string getName()

Name of the map

Location createLocation(int roomID)

Returns the Location for a particular roomID on this map. Does not check the room ID actually exists.

(Introduced in r26)

void setupRoomIfNeeded(int roomID)

For better performance, the contents of a room is not typically loaded into memory until the player has visited it. This means the entities there are not accessible by code. This function can be called to load the contents of the room into memory without the player having to visit it.

Calling this function will have no effect on non-existent rooms or already loaded rooms.

(Introduced in r56.1)

bool isRoomSetup(int roomID)

Checks to see if the target room ID is loaded.

(Introduced in r56.1)

Entity[] getAllEntitiesInRoom(int roomID)

Returns a list of all the entities in a given room. Returns empty list if nothing inside the room. Returns null if room is not yet loaded (see setupRoomIfNeeded)

Example code: List all entities in room

(Introduced in r56.1)

Entity[] findEntitiesByNameSlow(string name, bool caseSensitive = true, NameType nameType = NameType.Unspecified)

Attempts to find all entities with a particular name. It's usually safer to find an entity based on type (though as of r56.1 this hasn't been exposed yet) as names are subject to change.

Returns all the entities with that name on the map.

(Introduced in r56.1)

Entity findEntityByNameSlow(string name, bool caseSensitive = true, NameType nameType = NameType.Unspecified)

Attempts to find an entity based on name. It's usually safer to find an entity based on type (though as of r56.1 this hasn't been exposed yet) as names are subject to change.

Returns the first entity with that name on the map.

(Introduced in r56.1)

table<character, Location> getExits(int roomID)

Gets a table containing the exits for a particular room. If no such room, returns null. Otherwise, the character will be a cardinal direction abbreviation such as 'n', 'w', 'e', 's'. The location will be the linked location -- it may be on another map.

Example code: List room exits

(Introduced in r56.1)