Skip to content

Commit

Permalink
Script API: implement Room.Number and Room.Name
Browse files Browse the repository at this point in the history
Room.Name corresponds to the room's Description field in the Editor.
  • Loading branch information
ivan-mogilko committed Dec 20, 2024
1 parent a9825ff commit 1b9e0db
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Editor/AGS.Editor/Resources/agsdefns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,10 @@ builtin struct Room {
import static bool Exists(int room); // $AUTOCOMPLETESTATICONLY$
#endif // SCRIPT_API_v360
#ifdef SCRIPT_API_v400
/// Gets the current Room's number
import static readonly attribute int Number; // $AUTOCOMPLETESTATICONLY$
/// Gets the current Room's name (description)
import static readonly attribute String Name; // $AUTOCOMPLETESTATICONLY$
/// Accesses the Hotspots in the current room.
import static readonly attribute Hotspot *Hotspots[]; // $AUTOCOMPLETESTATICONLY$
/// Accesses the Objects in the current room.
Expand All @@ -855,7 +859,7 @@ builtin struct Room {
import static readonly attribute WalkableArea *WalkableAreas[]; // $AUTOCOMPLETESTATICONLY$
/// Accesses the Walk-behinds in the current room.
import static readonly attribute Walkbehind *Walkbehinds[]; // $AUTOCOMPLETESTATICONLY$
/// Gets this Room's Pathfinder object that lets find route around walkable areas.
/// Gets the current Room's Pathfinder object that lets find route around walkable areas.
import static readonly attribute Pathfinder *PathFinder; // $AUTOCOMPLETESTATICONLY$
/// Gets/sets the optional y/x ratio of character's facing directions, determining directional loop selection for each Character in the current room.
import static attribute float FaceDirectionRatio;
Expand Down
22 changes: 22 additions & 0 deletions Engine/ac/room.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,16 @@ void Room_SetFaceDirectionRatio(float ratio)
croom->face_dir_ratio = ratio;
}

const char *Room_GetName()
{
return CreateNewScriptString(thisroom.GetName());
}

int Room_GetNumber()
{
return displayed_room;
}

bool Room_Exists(int room)
{
String room_filename;
Expand Down Expand Up @@ -1087,6 +1097,16 @@ RuntimeScriptValue Sc_Room_SetFaceDirectionRatio(const RuntimeScriptValue *param
API_SCALL_VOID_PFLOAT(Room_SetFaceDirectionRatio);
}

RuntimeScriptValue Sc_Room_GetName(const RuntimeScriptValue *params, int32_t param_count)
{
API_SCALL_OBJ(const char *, myScriptStringImpl, Room_GetName);
}

RuntimeScriptValue Sc_Room_GetNumber(const RuntimeScriptValue *params, int32_t param_count)
{
API_SCALL_INT(Room_GetNumber);
}

// void (int xx,int yy,int mood)
RuntimeScriptValue Sc_RoomProcessClick(const RuntimeScriptValue *params, int32_t param_count)
{
Expand Down Expand Up @@ -1149,6 +1169,8 @@ void RegisterRoomAPI()
{ "Room::get_Width", API_FN_PAIR(Room_GetWidth) },
{ "Room::get_FaceDirectionRatio", API_FN_PAIR(Room_GetFaceDirectionRatio) },
{ "Room::set_FaceDirectionRatio", API_FN_PAIR(Room_SetFaceDirectionRatio) },
{ "Room::get_Name", API_FN_PAIR(Room_GetName) },
{ "Room::get_Number", API_FN_PAIR(Room_GetNumber) },
{ "Room::geti_Hotspots", API_FN_PAIR(Room_GetiHotspots) },
{ "Room::geti_Objects", API_FN_PAIR(Room_GetiObjects) },
{ "Room::geti_Regions", API_FN_PAIR(Room_GetiRegions) },
Expand Down

0 comments on commit 1b9e0db

Please sign in to comment.