Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: TheNewSon on Tue 28/07/2020 15:00:22

Title: [SOLVED] Undefined token 'SetViewport'
Post by: TheNewSon on Tue 28/07/2020 15:00:22
Hello! I'm trying to use SetViewport to manually scroll a room rightwards, but in the room script, as I start typing set, I get no suggestions related to that function (same for ReleaseViewport). I've tried running it anyway, but then I get the message: Undefined token 'SetViewport'. Can someone kindly help me please? Suggestions are also welcome! Thanks in advance! :)

Wrong code:
Spoiler
Code (ags) Select

function room_AfterFadeIn()
{
  for(int i = 0; i < 240; i++)
  {
    SetViewport(i,  0);
    Wait(1);
  }
  ReleaseViewport;
}
[close]
Correct code:
Code (ags) Select

function room_AfterFadeIn()
{
  for(int i = 0; i < 240; i++)
  {
    Game.Camera.SetAt(i,  0);
    Wait(1);
  }
  Game.Camera.AutoTracking = true;
}
Title: Re: Undefined token 'SetViewport'
Post by: Crimson Wizard on Tue 28/07/2020 15:03:44
These functions are deprecated in 3.5.0. There's an article in the manual called "Upgrading to AGS 3.5" which explains the changes.

Instead of old Viewport use Game.Camera instead:
https://github.com/adventuregamestudio/ags-manual/wiki/UpgradeTo35#new-viewportcamera-system

Also, if you search for these functions (SetViewport, ReleaseViewport) in the manual, their pages will notify you of which functions to use instead.
Title: Re: Undefined token 'SetViewport'
Post by: TheNewSon on Tue 28/07/2020 15:11:29
Crimson Wizard
Thank you very much! Looks like I've been reading an old version (https://www.adventuregamestudio.co.uk/manual/) of the manual... My bad, sorry!  :-[
Title: Re: [SOLVED] Undefined token 'SetViewport'
Post by: Crimson Wizard on Tue 28/07/2020 15:17:32
Quote from: TheNewSon on Tue 28/07/2020 15:11:29
Crimson Wizard
Thank you very much! Looks like I've been reading an old version (https://www.adventuregamestudio.co.uk/manual/) of the manual... My bad, sorry!  :-[

Yes, unfortunately that one had not been updated yet.
The wiki pages I've linked above is a "source" from which the manual is now generated.

But you also have an up-to-date manual with your Editor, you can bring it up with F1, or from start up menu too.