Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - TDBFW1

#1
Thanks, I accidentally typed in 0, instead of 1
#2
This doesn't really work for me, either in room_Load or room_AfterFadeIn. Either way, it brings up the same error message: Character.InventoryQuantity: invalid inventory index 0.
#3
Thanks. It's funny, I just assumed there would be a simple function to reset the inventory.
#4
I don't know if I'm missing something, but is there an easy way to remove all inventory items at once, without checking for it first?
#5
I think I understand. I'm using a key press rather than a button but I assume it will still work.
#6
Sorry, I'm new to programming. Could you explain that a little simpler? :P
#7
Thanks a lot for the suggestions. However, in one of my rooms (Not the test room with the code given), it needs to run during room_Rep_exec. This stems from a workaround. As SetRestartPoint() only restarts the game after a non-blocking loop, and my room immediately starts with a blocking script (I.e, a cutscene), I've set up a timer for one loop (To restart the game) and put the rest in room_Rep_exec, something like this:

Code: ags

function room_FirstLoad()
{
SetRestartPoint();
SetTimer(1, 1);
}

function room_RepExec()
{
if (IsTimerExpired(1))
{
int ran=Random(3);
if (ran == 0)
{
  HallRan=true;
  aGrandfather_Clock.Play(eAudioPriorityLow, eRepeat);
  Wait(20);
  cMaid.Say("Looks like I don't have to wind up the grandfather clock.");
  ClockPlaying=true;
  Wait(20);
  blink();
  cMaid.Say("Now which cup did the chef ask for?");
  cMaid.Walk(140, 190, eBlock);
  cMaid.FaceDirection(eDirectionRight, eBlock);
  Wait(40);
  oPinkCup.Visible=false;
  cMaid.Say("That's the one!");
  Wait(20);
  cMaid.Say("Now isn't there another thing the chef asked for?");
  blink();
  oVase.Visible=false;
  Wait(20);
  cMaid.Walk(257, 195, eBlock);
  cMaid.Say("Now I'm ready to go to the chef.");
  if (DifficultyEasy)
  {
    mouse.Mode=eModePointer;
    gNotebook.Visible=true;
  }
}
etc.
Now I don't know where to put the code in my script. Is it better to put it in Globalscript? Is there a better way to restart a room? Or should I just put the code for when the notebook is closed at the end of my room_Rep_exec function?

Sorry for the long post, it's become a bit of a mess.

BTW, you can see where the notebook closed code is meant to slot in, in the DifficultyEasy section.
#8
Sorry, I do want the player to move once the GUI has closed. Is there a way I can do this?
#9
Sorry, but a related question: Why doesn't this work?
Code: ags

function room_AfterFadeIn()
{
mouse.Mode=eModePointer;
gNotebook.Visible=true;
if (!gNotebook.Visible) player.Walk(180, 170, eBlock, eAnywhere);
}
#10
Thanks so much! I had no idea why it wasn't working. Sorry for being a bit slow to realise what you were getting at, I'm a little late to coding.:-D
#11
This works:
Code: ags

function on_key_press(eKeyCode keycode)
{
    if (gNotebook.Visible)
    {
  if ((keycode == eKeyN) &&
  (DifficultyEasy))
  {
    gNotebook.Visible=false;
  }
  else
    {
  if ((keycode == eKeyEscape) && gRestartYN.Visible) {
    //Use ESC to cancel restart.
    gRestartYN.Visible = false; 
    gIconbar.Visible = true;
    // If the panel's not ON, then the player must have gotten here by tapping F9,
    // therefore his cursor needs restoring. If the panel IS on, then it doesn't,
    // because it's already a pointer. Get used to thinking like this!!
    if (!gPanel.Visible) mouse.UseDefaultGraphic(); 
    return;
  }
  if ((keycode == eKeyEscape) && gPanel.Visible) {
    // Use ESC to turn the panel off.
    gPanel.Visible = false; 
    mouse.UseDefaultGraphic();
    gIconbar.Visible = true;
    return;
  }
  if ((keycode == eKeyEscape) && (gSaveGame.Visible))
  {
    // Use ESC to close the save game dialog
    close_save_game_dialog();
    return;
  }
  if ((keycode == eKeyEscape) && (gRestoreGame.Visible))
  {
    // Use ESC to close the restore game dialog
    close_restore_game_dialog();
    return;
  }
  
  if (keycode == eKeyReturn) { 
    // ENTER, in this case merely confirms restart
    if (gRestartYN.Visible) RestartGame();
  }

  // FUNCTION KEYS AND SYSTEM SHORTCUTS
  if (keycode == eKeyEscape) {
    // ESC
    gPanel.Visible = true; 
    gIconbar.Visible = false;
    mouse.UseModeGraphic(eModePointer);
  }
  if (keycode == eKeyCtrlQ)  QuitGame(1);   // Ctrl-Q
  if (keycode == eKeyF5) show_save_game_dialog();   // F5
  if (keycode == eKeyF7) show_restore_game_dialog();  // F7
  if (keycode == eKeyF9) {
    // F9, asks the player to confirm restarting (so much better to always confirm first)
    gRestartYN.Visible = true;  
    gIconbar.Visible = false;
    mouse.UseModeGraphic(eModePointer);
  }
  if (keycode == eKeyF12) SaveScreenShot("scrnshot.bmp");  // F12
  if (keycode == eKeyTab)   show_inventory_window();  // Tab, show inventory
    }
  // GAME COMMAND SHORTCUTS
  if (keycode == 'W') mouse.Mode=eModeWalkto; //Notice this alternate way to indicate keycodes.
  if (keycode == 'L') mouse.Mode=eModeLookat; //Note that all we do here is set modes.
  if (keycode == 'U') mouse.Mode=eModeInteract; //If you want something else to happen, such as GUI buttons highlighting,
  if (keycode == 'T') mouse.Mode=eModeTalkto; //you'll need some more scripting done.
  if (keycode == 'I') mouse.Mode=eModeUseinv; //But this will, as-is, give you some standard keyboard shortcuts your players will very much appreciate.

  // For extra cursor modes, such as pick up, feel free to add as you will.
  // Uncomment the line below if you use the "Pick Up" mode.
  //if (keycode == 'P' || keycode == 'G') mouse.Mode=eModePickup; 

  // DEBUG FUNCTIONS
  if (keycode == eKeyCtrlS)  Debug(0,0);  // Ctrl-S, give all inventory
  if (keycode == eKeyCtrlV)  Debug(1,0);  // Ctrl-V, version
  if (keycode == eKeyCtrlA)  Debug(2,0);  // Ctrl-A, show walkable areas
  if (keycode == eKeyCtrlX)  Debug(3,0);  // Ctrl-X, teleport to room
  if (keycode == eKeyCtrlW && game.debug_mode) 
    player.PlaceOnWalkableArea(); //Ctrl-W, move to walkable area 

}
}

But if I add this:
Code: ags

if ((keycode == eKeyN) &&
(DifficultyEasy))
{
gNotebook.Visible=!gNotebook.Visible;
}

at the end of the initial "else" statement (I.e. where all the other keycodes live), it doesn't work.
#12
Code: ags

function on_key_press(eKeyCode keycode) {
  // The following is called before "if game is paused keycode=0", so
  // it'll happen even when the game is paused.
  
  if ((keycode == eKeyEscape) && gRestartYN.Visible) {
    //Use ESC to cancel restart.
    gRestartYN.Visible = false; 
    gIconbar.Visible = true;
    // If the panel's not ON, then the player must have gotten here by tapping F9,
    // therefore his cursor needs restoring. If the panel IS on, then it doesn't,
    // because it's already a pointer. Get used to thinking like this!!
    if (!gPanel.Visible) mouse.UseDefaultGraphic(); 
    return;
  }
  if ((keycode == eKeyEscape) && gPanel.Visible) {
    // Use ESC to turn the panel off.
    gPanel.Visible = false; 
    mouse.UseDefaultGraphic();
    gIconbar.Visible = true;
    return;
  }
  if ((keycode == eKeyEscape) && (gSaveGame.Visible))
  {
    // Use ESC to close the save game dialog
    close_save_game_dialog();
    return;
  }
  if ((keycode == eKeyEscape) && (gRestoreGame.Visible))
  {
    // Use ESC to close the restore game dialog
    close_restore_game_dialog();
    return;
  }
  
  if (keycode == eKeyReturn) { 
    // ENTER, in this case merely confirms restart
    if (gRestartYN.Visible) RestartGame();
  }

  if (IsGamePaused() || (IsInterfaceEnabled() == 0))
  {
    // If the game is paused with a modal GUI on the
    // screen, or the player interface is disabled in
    // a cut scene, ignore any keypresses.
    return;
  }

  // FUNCTION KEYS AND SYSTEM SHORTCUTS
  if (keycode == eKeyEscape) {
    // ESC
    gPanel.Visible = true; 
    gIconbar.Visible = false;
    mouse.UseModeGraphic(eModePointer);
  }
  if (keycode == eKeyCtrlQ)  QuitGame(1);   // Ctrl-Q
  if (keycode == eKeyF5) show_save_game_dialog();   // F5
  if (keycode == eKeyF7) show_restore_game_dialog();  // F7
  if (keycode == eKeyF9) {
    // F9, asks the player to confirm restarting (so much better to always confirm first)
    gRestartYN.Visible = true;  
    gIconbar.Visible = false;
    mouse.UseModeGraphic(eModePointer);
  }
  if (keycode == eKeyF12) SaveScreenShot("scrnshot.bmp");  // F12
  if (keycode == eKeyTab)   show_inventory_window();  // Tab, show inventory

  if ((keycode == eKeyN) &&
(DifficultyEasy))
{
  if ((gNotebook.Visible) &&
  (IsGamePaused()))
  {
    gNotebook.Visible=false;
  }
  else if (!gNotebook.Visible) gNotebook.Visible=true;
  else
  {
    gNotebook.Visible=false;
  }
}

  // GAME COMMAND SHORTCUTS
  if (keycode == 'W') mouse.Mode=eModeWalkto; //Notice this alternate way to indicate keycodes.
  if (keycode == 'L') mouse.Mode=eModeLookat; //Note that all we do here is set modes.
  if (keycode == 'U') mouse.Mode=eModeInteract; //If you want something else to happen, such as GUI buttons highlighting,
  if (keycode == 'T') mouse.Mode=eModeTalkto; //you'll need some more scripting done.
  if (keycode == 'I') mouse.Mode=eModeUseinv; //But this will, as-is, give you some standard keyboard shortcuts your players will very much appreciate.

  // For extra cursor modes, such as pick up, feel free to add as you will.
  // Uncomment the line below if you use the "Pick Up" mode.
  //if (keycode == 'P' || keycode == 'G') mouse.Mode=eModePickup; 

  // DEBUG FUNCTIONS
  if (keycode == eKeyCtrlS)  Debug(0,0);  // Ctrl-S, give all inventory
  if (keycode == eKeyCtrlV)  Debug(1,0);  // Ctrl-V, version
  if (keycode == eKeyCtrlA)  Debug(2,0);  // Ctrl-A, show walkable areas
  if (keycode == eKeyCtrlX)  Debug(3,0);  // Ctrl-X, teleport to room
  if (keycode == eKeyCtrlW && game.debug_mode) 
    player.PlaceOnWalkableArea(); //Ctrl-W, move to walkable area 

}


The code for the room is just this:
Code: ags

function room_AfterFadeIn()
{
gNotebook.Visible=true;
}

function room_Load()
{
DifficultyEasy=true;
}
#13
Difficulty Easy is just a variable that should be active in the new blank room.
#14
I tried something like this, in my original game with a GUI called gNotebook:

Code: ags

  if ((keycode == eKeyN) &&
(DifficultyEasy))
{
  if ((gNotebook.Visible) &&
  (IsGamePaused()))
  {
    gNotebook.Visible=false;
  }
  else if (!gNotebook.Visible) gNotebook.Visible=true;
  else
  {
    gNotebook.Visible=false;
  }
}

It still doesn't work and I don't know why.
#15
Yes I do, actually:
Code: ags

  if (IsGamePaused() || (IsInterfaceEnabled() == 0))
  {
    // If the game is paused with a modal GUI on the
    // screen, or the player interface is disabled in
    // a cut scene, ignore any keypresses.
    return;
  }

What should I do about it (It's in the default game)?
#16
I'm doing this in a new game in a default game for testing:

Code: ags

function room_AfterFadeIn()
{
gTest.Visible=true;
mouse.Mode=eModePointer;
}


In the Globalscript:

Code: ags

   if (keycode == eKeyN) gTest.Visible = !gTest.Visible;


However, the GUI doesn't close when I push "N". BTW, the GUI visibility is on pause game when shown. Any help?
#17
I have a GUI which pauses the game when shown. For some reason, the mouse doesn't show when hovering over the GUI. Any help?
#18
So If I change the GUI to normal, initially off it works. No idea why it doesn't work when paused. Thanks anyway
#19
No textboxes or modules. I don't know what's wrong...
#20
It still doesn't work. When the GUI is open, the key doesn't seem to register.
SMF spam blocked by CleanTalk