Hi Guys and Gals,
I am trying to work out how to use RegionGetAtRoomXY properly.
currently I have made a test function like this (as it is written in the help file) within the rooms script.
function SeaRegionCheck()
{
if (Region.GetAtRoomXY(cBoat.x, cBoat.y) == region[0])
{
Display("The player is not currently standing on a region.");
}
}
And within the rooms script under repeatedly execute I have a simple
function room_repeatedly_execute()
{
SeaRegionCheck();
}
When I test my "game", I move cBoat outside of region 1 no display is created.
Question, can I use this within the room script or does it need to be specified within the Global Script.
*Note.. I have tried to change the cBoat.x and y to player.x and y and this does nothing also.
*Further Note.. The function is created prior to the Repeatedly execute section.
Any help would my greatly appreciated.
:)
Is your function "room_repeatedly_execute" actually connected to room event? AGS does not have a standard function of such name.
Always first thing to test is to put Display unconditionally in a function to see if it runs at all.
function room_repeatedly_execute()
{
Display("It runs");
SeaRegionCheck();
}
Yeah, the function that AGS creates for the room event is called room_RepExec.
Only repeatedly_execute_always and a few others can be used without event linking.
To be honest I dont think there is a linked event as I didn't click and on the event handlers prior to inputing the code.. Im not sat in front of my PC at the minute so couldn't say 100%. I'll check in the morning cheers guys.
I did test the function I created in global script and it worked a charm but I'd rather have it handled in the room if I can.
Its nice to be back after so long away, good to know some of the same faces are still about. :)
Quote from: Khris on Wed 03/03/2021 20:52:18
Yeah, the function that AGS creates for the room event is called room_RepExec.
Only to clarify, to prevent occasional misunderstanding, "room_RepExec" is simply default name generated by the editor, but it's not ags script standard, as in, it may be called anything you like so long as it's connected to room event.
Quote from: Crimson Wizard on Wed 03/03/2021 21:49:16
Quote from: Khris on Wed 03/03/2021 20:52:18
Yeah, the function that AGS creates for the room event is called room_RepExec.
Only to clarify, to prevent occasional misunderstanding, "room_RepExec" is simply default name generated by the editor, but it's not ags script standard, as in, it may be called anything you like so long as it's connected to room event.
Understood. ;)
So It's exactly as you guys say, I had simply missed the room event
After correcting my mistake I built a new function to Check the region and now call it from room_RepExec()
function GetRoomRegion()
{
Region* r = Region.GetAtRoomXY(cBoat.x, cBoat.y);
if (r != region[0])
{
SeaRegionCheck.Text = String.Format ("%d",r.ID);
}
else if (r == region[0])
{
}
}
function room_RepExec()
{
GetRoomRegion();
CheckForBattle();
}
In time I will move my GetRoomRegion code into the GlobalScript and write the proper import as I will need to use this room region checker in 3 or 4 other rooms.
Thanks again for your help. ;-D