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 - Khris

#261
This will get moved to the proper forum so I'll reply here:
The error I got is
Code: ags
Could not save file as : /var/www/adventuregamestudio.co.uk/public_html/images/games/684_2.png.

I tried both a 1MB and a 100KB png. Neither would upload.
#262
You can use this:
Code: ags
  // inside the button's OnClick function
  int ti = invWindow.TopItem;
  invWindow.ScrollDown();
  if (ti == invWindow.TopItem) aInvStuck.Play();
  else aScrollInv.Play();

edit: fixed code
#263
Important functions won't be missing but rather they've been replaced with oo style functions I assume.

Anyway, the basic idea is to create a GUI with a text input box on it. Give both a suitable name, like gCommand and tbCommand.

Next, you'll want to show the GUI when the user starts to type. Open the global script and find the on_key_press function. In there, add this:
Code: ags
  if (!gCommand.Visible) {
    if (keycode >= eKeyA && keycode <= eKeyZ) {
      tbCommand.Text = String.Format("%c", keycode);
      gCommand.Visible = true;
      return;
    }
  }
What this does is if the player presses a letter key while the command GUI isn't visible, it shows the GUI and puts the letter into the text box. Which should have focus now, so the player can simply continue typing their command.

Next you'll want to implement the F3 feature, which repeats the last command. We need to store the command for this, so put this directly above function on_key_press(...):
Code: ags
String last_command;

Again inside the function, add
Code: ags
  if (keycode == eKeyF3 && !String.IsNullOrEmpty(last_command)) {
    tbCommand.Text = last_command;
    gCommand.Visible = true;
  }

Finally, we need to actually run the typed command. Double click the text box in the GUI editor or use the events pane to add the OnActivate function to the global script. It will run when the player presses enter while the textbox has focus.
Inside, put this:
Code: ags
  String command = tbCommand.Text;
  tbCommand.Text = ""; // clear text box
  gCommand.Visible = false; // hide GUI
  if (command.Length == 0) { gCommand.Visible = false; return; } // hide GUI, do nothing
  last_command = command; // store command for F3 key

  Parser.ParseText(command); // pass typed text to AGS parser

  // handle commands
  if (Parser.Said("look")) CallRoomScript(1); // run on_call(1) in the current room's script
  if (Parser.Said("inv") || Parser.Said("i")) show_inventory();
  // etc
#264
You can add a hotkey to on_key_press:

Code: ags
  if (keycode == eKeyBackspace) DeleteSaveSlot(1);

This way you don't have to manually delete the save slot. You can of course also simply overwrite it instead.
#265
This program: http://www.vgmpf.com/Wiki/index.php?title=Audio_Overload can convert ROL to WAV, which can then be turned into mp3 or ogg to be used in AGS.
#266
Use the commands I mentioned in my first reply.

To put saving and restoring on button keyboard keys, add code in the Global Script's on_key_press:

Code: ags
  if (keycode == eKeyF5) SaveGameSlot(1, "main save");

Edit: fixed wording
#267
To be clear: do not put a SaveGameSlot() call directly inside repeatedly_execute :P
I'd be afraid to even just test this.

Depending on how your game works, suitable events for auto-saving are:
- each time the player enters a new room
- each time the player picks up new inventory
- each time the game's plot moves forward (i.e. the global game state changes)

The first two can be trivially solved using on_event, the third requires a manual call.
#268
Use this to save:
Code: ags
  SaveGameSlot(1, "Autosave");
(the description doesn't matter)

To restore, use:
Code: ags
  if (Game.GetSaveSlotDescription(1) != null) RestoreGameSlot(1);
#269
Meh...

Wordle 592 4/6

🟩⬜⬜⬜⬜
🟩⬜🟩⬜⬜
🟩⬜🟩🟨⬜
🟩🟩🟩🟩🟩

Spoiler
SPARE
STOUT
SHOCK
SCOLD
[close]
#270
That's exactly how it works:
https://adventuregamestudio.github.io/ags-manual/Globalfunctions_Room.html#setwalkbehindbase

You can also use a non-clickable Object instead and turn it off.
#271
Wordle 591 4/6

🟨⬜⬜🟨⬜
⬜🟨🟨🟩⬜
⬜🟩🟩🟩⬜
🟩🟩🟩🟩🟩

Spoiler
SPARE
HORSE
FROST
CROSS
[close]
#272
Quote from: TheEyess on Mon 30/01/2023 14:20:50I also enabled "Override built-in inventory window click handling" in general settings
Just for reference, turning on this option means you need to write code to be able to select an item (specifically, a block in on_mouse_click that deals with button == eMouseLeftInv).

Without custom inv click handling, interacting with an item should be enough to select it.
#273
1. turn on numbering:

Code: ags
// in game_start
  CustomDialogGui.DialogGuiOptions[eDialogGui_text_numbering] = true;

2. open CustomDialogGui.asc (Scripts/CustomDialogGui/Edit Script)
   add the following function to the script (doesn't really matter where, I put it in line 790)

Code: ags
function dialog_options_key_press(DialogOptionsRenderingInfo *info, eKeyCode keycode, int mod)
{
  if (!CDG_options.text_numbering) return;
  int typed = keycode - eKey0;
  Dialog *d = info.DialogToRender;
  int option = 0;
  for (int i = 1; i <= d.OptionCount; i++) {
    if (d.GetOptionState(i) == eOptionOn) option++;
    if (option == typed) {
      info.ActiveOptionID = i;
      break;
    }
  }
  info.RunActiveOption();
}
#274
Right, fixed my code.
#275
The propagandaPlay function will call .Play() two times if the channel pointer is null.
Also, if the 2nd play command fails and the pointer ends up being null, you're calling SetRoomLocation on null, again causing a null pointer error.

I'd do this:

Code: ags
function propagandaPlay() {
  acPropaganda = aSpeech_close.Play();
  if (acPropaganda != null) acPropaganda.SetRoomLocation(866, 252);
  SetTimer(1, 1200);
}

Edit: fixed code
#276
Some More News has compiled a great two-parter about the moronic fifteen year old divorced dad that is running twitter:

https://www.youtube.com/watch?v=RlL4xvn6xWE
https://www.youtube.com/watch?v=r-Y7U4LOTYY

Pretty long but as always funny and very informative.
#277
Indeed... :P

Wordle 585 6/6

⬜⬜🟨⬜🟩
🟩🟩⬜⬜🟩
🟩🟩⬜⬜🟩
🟩🟩⬜⬜🟩
🟩🟩⬜⬜🟩
🟩🟩🟩🟩🟩

Spoiler
SPARE
MANGE
MATTE
MAYBE
MAUVE
MAIZE
[close]
#278
Chaining non-blocking stuff is one of the hardest things to get to work correctly, especially as an AGS beginner.
One way of implementing them is a FSM where the character switches between different (animation/idle) states based on timers or other events.

The good thing is that AGS is pretty flexible; many available functions are convenience functions that can be completely replaced by custom code. You can for instance count frames instead of using timers, or simply set a character's view/loop/frame directly instead of relying on .Animate().
#279
I haven't read everything, just want to point out that this:
Code: ags
  cLeblanc.Animate(0, 4, eOnce, eNoBlock);
  cLeblanc.UnlockView();
won't work as expected; a non-blocking animation will not pause the execution while it runs, so UnlockView is called immediately after the Animate command, before the character starts animating.
#280
Ok, try
Code: ags
  player.ActiveInventory = inventory[game.inv_activated];

instead. Also, why is the GUI closing at all? I don't see anything that would cause this in your code.
SMF spam blocked by CleanTalk