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

Topics - hocuspocus2

#1
I have a custom Say function that's like this:
Code: ags

void Saying(this Character*, String msg) {  
  gSpchWindow.Visible = true;
  lSpeechText.Text = msg;
  lSpeakerName.Text = this.Name;
  
  while (WaitMouseKey(40) == 0 && !Game.SkippingCutscene) { // wait until key or mouse click
  
    /*...Irrelevant animation code...*/
    
  }
  
  gSpchWindow.Visible = false;
}


This function works fine. The problem is with WaitMouseKey, in that during a cutscene with lots of dialogue, I'd like the player to be able to pause the game during the cutscene (by pressing P, for example). Pressing P during a cutscene while the speech GUI is visible doesn't do anything, it just treats it like any key press. So I was wondering how I could have the WaitMouseKey in this code ignore certain keys?

In truth, I was originally trying to have the function only respond to mouse clicks and the Enter key, instead of responding to any mouse clicks/key presses. I tried to do it by modifying the loop to something like:
Code: ags

while (!Mouse.IsButtonDown(eMouseLeft) && !IsKeyPressed(eKeyReturn) && !Game.SkippingCutscene) {
  while (WaitMouseKey(40) == 0) {
   /*....*/
  }
}

Which I suppose worked with the speech aspect, but would also cause some bugs in other areas, and not "queue" speech lines.
#2
The player will have a limited number of inventory (10 items), and so they would need to store extra items in drawers and such and then take them out if needed. They essentially work like backpacks in some video games. This will probably be achieved using multiple inventory GUIs, the problem is I'm not sure how I would go on about it. I'm thinking that I would need to create dummy characters for each drawer, but that's about it.
I should mention that this is a 1st-person perspective (so the player character is hidden).
#3
Hello, I have a room where there would be a complicated chemistry puzzle that the player uses to create items, like Black Ink or Glue. I started coding it myself, but I felt stumped on how to do this properly. I also feel like it's just spaghetti code and possibly needs a complete do-over. So, I need someone to help me code the puzzle and get it working, it's not a long-term role really but just for this room.

I've written the notes in a Doc, with screenshots: https://docs.google.com/document/d/140oAEoX2QuQRPyNveGJUfuvQU_DnU0K_vQgvTJVF33k/edit?usp=sharing
Here's a Doc of the current code, I tried my best to format it nicely: https://docs.google.com/document/d/18HxjUeciVUCoa7UVTIjqfzNOglsUbvrs3ji8OlJKYU8/edit?usp=sharing

You can reply to this thread or PM me, but I think I prefer replies.

If you need any more details, let me know and I will add it to this post.
#4
I'm trying to have a global function that resets an int array's elements, like so:
Code: ags
void resetIntArray(int array[], int n, int indexNum) {
  for (int i = 0; i < n; i++) 
    array[i] = 0;  
  indexNum = 0;
}


then imported it in the header:
Code: ags
 import void resetIntArray(int array[], int n, int indexNum = 0);

but when I try to use it locally it gives me the error:
Code: ags
Error (line 43): Type mismatch: cannot convert 'int*' to 'int[]'

I would use it like this:
Code: ags
resetIntArray(playerInput, 9, indexNum);

where playerInput is an int array of 9 elements.

I think playerInput is the problem. Am I supposed to pass it a different way in the argument?
#5
I have "Use selected inventory graphic for cursor" to true. What I want to happen is that the item's cursor graphic would be scaled down so it looks smaller than its graphic in the inventory bar, but they're still essentially the same sprite/image. In my case, each item's sprite is 100 x 100, and I want its cursor graphic to be scaled by half, so 50 x 50 (might change my mind and make that bigger though, like 70 x 70).
I know I can probably redraw each item as smaller, then set that as its cursor graphic in the editor's inventory item menu. But I feel like that would take too much space and time when I can just globally script the scaling. I tried using DynamicSprite* and Overlay*, but I think they're too complicated for me. I just kept getting errors, and I kinda didn't know what I was doing.

#6
My game is in 1st person view and with no character, so you move around by clicking. As for the inventory system, I don't want multiple modes like Look At, Talk To, etc. I just want it so the player clicks on an item to uses it on other stuff or combine it with other inventories, like those 2000s-2010's point-and-click Flash games (Daymare Town, Cube Escape (though that series is still ongoing), Bars of Black and White, Submachine, etc.)

Here is a video I recorded of what happens:


Both 'Override built-in inventory window click handling' and 'Use selected inventory graphic for cursor' are set to True. I should mention that I'm also using the Bass template. Here's what I have for the Global Script:
Code: ags

// called when the game starts, before the first room is loaded
function game_start() {
  Mouse.Mode = eModeInteract;
  
  // register a GUI to use for the inventory bar
  //TwoClickHandler.InventoryGUI = gInventoryBar;

  // register a Label to use for action text
  //TwoClickHandler.ActionLabel = lblAction;

  // optionally set the popup distance for the inventory bar
  //TwoClickHandler.PopupProportional = 0.5;
  //TwoClickHandler.PopupDistance = 50;

  // optionally reverse the left and right mouse buttons
  //TwoClickHandler.ReversedClicks = true;
}

// called on every game cycle, except when the game is blocked
function repeatedly_execute() {
  if ((mouse.x < 100) && (Room.GetProperty("LeftAble"))) {
    mouse.SaveCursorUntilItLeaves();
    mouse.Mode = eModeLeft;
  } else if ((mouse.x > 1180) && (Room.GetProperty("RightAble"))) {
    mouse.SaveCursorUntilItLeaves();
    mouse.Mode = eModeRight;
  } else if ((mouse.y > 620) && (Room.GetProperty("DownAble")) && (GetLocationType(mouse.x, mouse.y) != eLocationHotspot)) {
    mouse.SaveCursorUntilItLeaves();
    mouse.Mode = eModeDown;
  } else {mouse.Mode = eModePointer;}
}

// called when a mouse button is clicked
function on_mouse_click(MouseButton button) {
  //clicking on edges code
  if (button != eMouseLeft) return; // do nothing
  
  if ((mouse.x < 100) && (Room.GetProperty("LeftAble"))) {
    player.ChangeRoom(Room.GetProperty("GoLeft")); // leftmost 100 pixels
  } else if ((mouse.x > 1180) && (Room.GetProperty("RightAble"))) {
    player.ChangeRoom(Room.GetProperty("GoRight"));  // 1280 - 100
  } else if ((mouse.y > 620) && (Room.GetProperty("DownAble")) && (GetLocationType(mouse.x, mouse.y) != eLocationHotspot)) {
    player.ChangeRoom(Room.GetProperty("GoDown"));  // 720 - 100
  }
}


The rest of the functions are either empty, have default lines from the template, or are irrelevant (ie character code or GUI code for specific rooms). The GUI for the inventory is called gInventoryBar.

When I try to use inventory functions like:

Code: ags
function iNeedle1_OtherClick()
{
  Display("aaaa please");
}


Nothing happens, either.

I tried switching mouse modes and removing all that room edges code to see if it's the cause but nothing changes. And uncommenting the TwoClickHandler line that registers the inventory GUI does nothing, either.
SMF spam blocked by CleanTalk