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

#162
There's two ways you can fix this:

a) band-aid: after each interaction, make sure each of the 11 pieces exists either as placed object, loose object or active inventory item

b) get rid of all the duplicate code by using loops and the IDs/arrays of the hotspots, objects and inv items.
#163
Can you upload the source files so we can take a look?
#164
You can also use System.OperatingSystem == eOSAndroid to let your game handle input differently based on the OS it's running on.

I still think Seven Days a Sceptic had one of the most elegant interfaces, and it lends itself perfectly to one touch operation. Clicking an active area brings up the inventory, but the first few items are look / interact / talk icons.
#165
GUIs don't have an "on activate" event, just an "on click" event.
Simply assign the text to the label right before setting gGui24.Visible to true.
#166
I'm too tired to really think this through but from a technical standpoint this should be possible:

Code: ags
function Room_RepExec() {
  ...
}

function on_call(int param) {
  if (param == 1) Room_RepExec();
}

  // elsewhere
  CallRoomScript(1);

No idea whether this will solve the problem though.

Another way to tackle this is to change the template's code so that the interface isn't enabled/disabled immediately but after a short timer has expired.
#167
General Discussion / Re: Trumpmageddon
Fri 08/11/2024 10:23:52
Somebody on tiktok made a women only map:



(it's from October though, the data is not based on the actual votes but on polls etc.)
#168
Ok, it all sounds like you're simply running the wrong exe file (or you have discovered an extremely esoteric bug, which I don't think is likely).

If you press F7 in the editor, all the game files should be built into the Compiled/Windows folder. If you rename the game in the editor, AGS will build an exe with the same name but it won't delete the old exe.

You can also delete the entire Compiled folder before building to make sure all old files are gone.
And you can change the Explorer window's view to Details and check the exe's creation date / time.
Also make sure you're not using any special characters in folders or file names.
#169
When you open the game in the editor and press F5, does it run the correct game?

Also, which room is loaded at the start of the game depends on a) which character is set as the player character and b) what their starting room is. Check that the player character has the correct starting room set.
#170
To find out when a sound has ended, store its channel when playing the sound, the repeatedly check if the channel is still playing.
Or you can simply set a timer to a number corresponding to the sound effect's length and use IsTimerExpired()
#171
In my snippet, the relevant lines are 7, 11 and 12.
Over active areas, the cursor should change to a pointer for both characters. Outside active areas, it should use the default one of the player is the man and the custom one when they're a woman.

What exactly fails?

I can't tell what "the mouse for the female player is not working at all" means exactly.
#172
Here's a better way to do this:

Code: ags
bool wasOverActiveArea;
void HandleCursor() {
  if (Mouse.Mode == eModeUseinv) return; // do nothing
  bool isOverActiveArea = GetLocationType(mouse.x, mouse.y) != eLocationNothing; // compare to enum!
  if (isOverActiveArea && !wasOverActiveArea) {
    // mouse just moved over active area
    Mouse.UseModeGraphic(eModePointer); // pointer for both
  }
  else if (!isOverActiveArea && wasOverActiveArea) {
    // mouse just left active area
    if (player == cWoman) Mouse.UseModeGraphic(eModeDapHandU);
    else Mouse.UseDefaultGraphic();
  }
}

function repeatedly_execute() {
  HandleCursor();
  // other stuff
}
#173
Not sure what you mean by "putting this in every room", the mouse is a global thing. It doesn't reset on a room change.

Anyway, the proper way is to (permanently) change the graphic of the mode when you switch the player character. Like:
Code: ags
function SwitchToWoman() {
  Mouse.ChangeModeGraphic(eModeInteract, 123); // sprite slot 123 is woman's interact cursor
  Mouse.ChangeModeGraphic(eModeTalkto, 124)); // sprite slot 124 is woman's interact cursor
  cWoman.SetAsPlayer();
}

#174
You can change some settings like language and fullscreen/windowed while the game is running. So the question is, what do you want to achieve?

My point is, even if there was a way to open winsetup from inside the game, I don't think it's the solution to your problem. Winsetup changes acsetup.cfg, which is only read when the game is started.
#175
I'm 99% sure OP is talking about the thing from the spoiler, however there's a slightly easier version of this where you don't need the triangle diagram, just a basic table.

        |  Color  |  Name  |  Country  |  buys
----------------------------------------------------
House 1  | yellow  |  John  |  USA      |
----------------------------------------------------
House 2  |        |        |  Spain    | newspaper
----------------------------------------------------
House 3  |        |        |          |



So we're talking about a bunch of interactive areas where a click loops through a bunch of possible String values.

To display text on screen, we can use
a) a label or a button on a transparent GUI
b) a textual Overlay
c) the DrawString function to directly draw to the room background or a dynamic sprite

Since we also need to be able to click the text, a button is a straightforward solution. The downside is we need to create 16 or 20 buttons manually.

I'd use a single hotspot covering the clickable area to detect the click and option c) to display the text.

We also need a way to store the table's state. This can be done using an array of ints the size of which is the number of interactive cells.

Let's start with a bunch of variables:

Code: ags
#define ROWS 4 // four houses
#define COLS 4 // color, name, country, article
#define CELLCOUNT 16 // ROWS * COLS

int cellValue[CELLCOUNT]; // one integer for each cell: -1 is empty, 0 = first option, 1 = second option, etc.
String options[CELLCOUNT]; // # of total options == # of cells

// table's room coordinates
int offsetX = 40, offsetY = 60; // coordinates of the top left corner of the first clickable cell
int cellWidth = 70, cellHeight = 20; // cell size

// sprite to store room background
DynamicSprite* backup;

Next, we need to set the possible options and all cells to empty (don't forget to create this function via the room's event table!):

Code: ags
function room_Load() {
  options[0] = "yellow";
  options[1] = "red";
  options[2] = "green";
  options[3] = "blue";
  options[4] = "John";
  // ...
  options[8] = "USA";
  options[9] = "Spain";
  // ...
  options[12] = "magazines";
  options[13] = "newspapers";

  for (int i = 0; i < CELLCOUNT; i++) cellValue[i] = -1;
  backup = DynamicSprite.CreateFromBackground();
}

Handling a hotspot click works like this:
Code: ags
function hTable_AnyClick(Hotspot* theHotspot, MouseButton button) {
  // calculate clicked row and column from mouse coordinates
  int col = (mouse.x + Screen.Viewport.X - offsetX) / cellWidth;
  int row = (mouse.y + Screen.Viewport.Y - offsetY) / cellHeight;
  // change cell value
  int i = row * COLS + col; // array index
  cellValue[i]++; // move to next option
  if (cellValue[i] == ROWS) cellValue[i] = -1; // if cell contained last option, set to empty
  UpdateCells();
}

This requires a function further up in the script:
Code: ags
void UpdateCells() {
  DrawingSurface* ds = Room.GetDrawingSurfaceForBackground();
  ds.DrawImage(0, 0, backup.Graphic); // restore room bg (i.e. empty table)

  // cell contents
  ds.DrawingColor = Game.GetColorFromRGB(123, 45, 74); // font color
  for (int row = 0; row < ROWS; row++) {
    for (int col = 0; col < COLS; col++) {
      int i = row * COLS + col; // array index
      if (cellValue[i] > -1) {
        String text = options[col * ROWS + cellValue[i]];
        int x = col * cellWidth + offsetX + 2; // some padding
        int y = row * cellHeight + offsetY + (cellHeight - GetFontHeight(eFontFont0)) / 2;
        ds.DrawStringWrapped(x, y, cellWidth, eFontFont1, eAlignCenter, text);
      }
    }
  }
  ds.Release();
}

NOT TESTED!

Edit:
Solution check to follow, if this works.
@Salamdandersad please edit your first post and change the title to something descriptive like "Creating a table with clickable cells"

Edit 2: fixed a few small errors
#176
You neglected to mention you're using the Tumbleweed template, which uses a custom dialog GUI... ;)

Open Scripts -> Tumbleweed -> TemplateSettings -> Edit Script
Scroll down to lines 169 & 170
#177
You can do this in game_start to change the highlight color:
Code: ags
  game.dialog_options_highlight_color = Game.GetColorFromRGB(255, 255, 0); // bright yellow

To change the text color, simply change the player character's SpeechColor (in the editor).

(You can also use custom dialog rendering.)
#178
A fixed version is now online under the same link.

Thanks @Crimson Wizard  :)
#179
It's this one: https://drive.google.com/file/d/19uyh4VBjeMkhg-oNX2RC-STsw7IGG9Bl/view?usp=drive_link

I only publish modules in their own threads after extensive testing (i.e. never). This one was thrown together in an afternoon.
#180
The Rumpus Room / Re: What grinds my gears!
Wed 16/10/2024 17:45:36
There's a node module called 'unique-string' with over 16 million weekly downloads.

This is the main script:
Spoiler
Code: javascript
import cryptoRandomString from 'crypto-random-string';

export default function uniqueString() {
	return cryptoRandomString({length: 32});
}
[close]
SMF spam blocked by CleanTalk