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

#121
@Crimson Wizard Right, I didn't realize this is about String variables created inside the Global Variables pane.

Anyway, calling a function is still better than using just a player.Say command because if you ever want to change the behavior in the future, you can do it in a single place instead of having to edit potentially dozens or even hundreds of interaction functions.
#122
You can redirect interactions to unhandled_event to do this.
Open the global script's header and add
Code: ags
import function unhandled_event(int what, int type);

Now you can do
Code: ags
  else unhandled_event(2, 3); // 2 = on object, 3 = use inventory

This way the global unhandled_event functions gets called even if an event handler exists, and in there you can now have the player say appropriate messages, which thus end up in the translation file.

In general you shouldn't use global messages any longer, they've been obsolete for years.
#123
Please never post code as image.

Just copy paste it in between [code] tags
#124
Hey, I made a small demo game that shows how to connect a GUI, a module and a room.

Places of note:
GUIs -> 9: gBattleMain (the used GUI and its buttons and label, check the GUI elements' names and on click event functions)
Scripts -> BattleGUI (the header and script for the module I used to keep things tidy)
- the header shows enums, a basic struct to store boss info and one to group functions for outside access
- the main script shows handling buttons, updating the GUI, providing module info to the room script, setting up bosses
Scripts -> GlobalScript -> Edit Script, scroll to the very end (since GUI buttons clicks are handled by the global script, we forward them to the module)
Rooms -> 1 -> Room Script (function call that starts a battle)
Rooms -> 2 -> Room Script (script for room used for battles)

When you run the game, simply click the glowing orb to start the "battle" :)

Source Download for AGS 3.6.0: https://drive.google.com/file/d/1QkXihSpB-AMSYBNzGKKtHiPU6jPsDq_i/view?usp=sharing
#125
Hey, in case you're following a tutorial, can you tell us which one? Because it should be updated or marked as outdated.
#126
It should work if you don't indent the dialog script commands. Like

Code: ags
  if (wasTalkedWith_Josh) {
Ego: Hi again!
goto-dialog 3
  } else {
Ego: Hi, how are you?
    wasTalkedWith_Josh = true;
  }
#127
Sure, reordering them via int array is feasible.

But if you have to mostly edit the dialog script, you can do a search and replace for the number. Turning option 5 into option 7 should be relatively painless if you simply replace all occurrences of 5 with a 7.
It just requires a small bit of planning, and moving existing options into new numbers first, then putting additional options into the now free slots.

Also, if you have dozens of options in a single dialog, you might want to consider splitting it up anyway.
#128
Yeah, but reordering them via custom dialog rendering is going to be much more cumbersome :)

One thing you can do is just add a bunch of blank options when you start creating a dialog so you can insert more options in the middle later. Just uncheck the "Show" options for these until you need them.
#129
Can you post what you did to solve this? In case somebody finds this thread in the future.
#130
You can in theory use custom dialog rendering to change the order, yes.

But just to make sure this isn't an XY problem: if this is about adding a new dialog option above the one at the bottom (i.e. the goodbye one), simply put it above from the start. Since this solution is very obvious, your question is probably about something else though, so can you elaborate a bit? How and why exactly do you want to re-order the options?
#131
All three cases sound like they might be xy problems; the bigger question is whether .Think() is a suitable solution in the first place.
#132
The original code is fine, so it sounds like you had a special space character in your code that irritated the compiler and deleted it while fixing the indentation.
#134
It's a separate function (returning a bool, so it says "bool" instead of "function" at the start). Just put it at the top of the global script, outside of other functions.

You can also put it directly above your btnSaveGame_OnClick function.
#135
You can use this:

Code: ags
bool ItemExists(this ListBox*, String item) {
  for (int i = 0; i < this.ItemCount; i++) {
    if (item == this.Items[i]) return true;
  }
  return false;
}

Now you can use this:
Code: ags
  else if (lstSaveGamesList.ItemExists(txtNewSaveName.Text)) ...

edit: fixed code
#136
The original code should've thrown a bunch of compiler errors.

{ opens a block, } closes it again (a block is a bunch of statements / commands).

This is true for functions and for the commands that run conditionally based on if conditions or else cases.
When you put if blocks inside functions, you're going to open a 2nd block using a 2nd { inside the outer one, then as you approach the end of the function you close them again, in order. It basically works exactly like the nested parens in mathematical expressions.

You can keep track of the "level" by indenting each block (AGS even does this for you whenever you press enter to end a line). Nested example using 4 spaces to make it more prominent:

Code: ags
function CommentOnWeather()
{
    if (itsRaining)
    {
        player.Say("I'm going to need an umbrella.");
        if (player.HasInventory(iUmbrella))
        {
            player.Say("Luckily I found one earlier.");
        }
        else
        {
            player.Say("But where am I going to get one?");
        }
    }
    else // not raining
    {
        player.Say("I love the sun.");
    }
}


Once you can do this in your sleep, you can try different styles. Many people for instance do not put the opening brace in the next line, and if there's only one command inside an inner block, you can omit the braces. I'd write the above code like this:
Spoiler
Code: ags
function CommentOnWeather() {
    if (itsRaining) {
        player.Say("I'm going to need an umbrella.");
        if (player.HasInventory(iUmbrella)) player.Say("Luckily I found one earlier.");
        else player.Say("But where am I going to get one?");
    }
    // not raining
    else player.Say("I love the sun.");
}
[close]
#137
This seems to be a bug, yes. It works fine in AGS 3.2.1 :)
#138
Ok, I gave this a shot.

Here's the download for the edited VerbGui module:
https://drive.google.com/file/d/1zZj0VC1VwE947E_gZXS8cJgTpM_x8fD1/view?usp=sharing

Usage example:

This goes into the click handling for the object
Code: ags
    // PICKUP
    else if(Verbs.UsedAction(eGA_PickUp)) {
      Verbs.UseObject(oBlueCup); // new function, tell game to "use" the object "with"
    }

This goes into the click handling for the target hotspot / object / character
Code: ags
    else if (Verbs.UsedAction(eGA_UseObj)) {
      if (Verbs.UsedObject(oBlueCup)) {
        Display("You use the cup on the screen.");
        // Verbs.UseObject(null); // call this to deselect the object
      }
    }

Consider this an alpha test! :-D
#139
Actually, I don't understand :-D

Can you give an example? Let's say I have a knife in my inventory. I click on "pick up", then a balloon object in the room. Instead of picking up the balloon, the game is supposed to switch to "Use knife with"? Or "Use knife with balloon" and immediately run that interaction?

Or do you want to be able to use room object A on room object B without picking one up first?
#140
Try replacing
Code: ags
  if (dist<10)
with
Code: ags
  if (dist < 10 && !oStalagmiteTip.Moving)

Also, basic debugging. You have already done this yourself:
Code: ags
 // Display(String.Format("%d", dist));
Just keep doing that to check values and whether lines run at all, etc.

You might also want to fix the indentation, it's all over the place currently which makes debugging much harder.
SMF spam blocked by CleanTalk