Show Posts

You can view here all posts made by this member. Note that you can only see posts made in areas to which you currently have access.

Messages - Mr Games

Pages: [1]
OK, thanks :) I'm familiar with the room saving the state but I wasn't sure if it would "re-read" code outside of the functions and thus return the variable to its original value.

Sorry this is a super-beginner question,

Every time I've created a new variable I've made it a Global Variable, because I was thinking that if I created an int or bool at the top a room script, it would return to that value every time that room is entered.

For example, if I stated at the top of a room:
Code: Adventure Game Studio
  1. PineapplePizzaIsTasty = true;
and an event in that same room caused that value to become false, but I left the room and came back, would it not read the original statement and make it true again?

I'm just trying to get my head around how this works.

Ah, a rudimentary error! Thank you both, "else if" fixed it.

Hi everyone

I've started a mini "boss fight" where clicking on the Succubus causes her to "teleport" (with object.SetPosition) but for every instance there is a timer. If any of these timers expire the player is sent to room 38 (game over.)

I'm stumped because the first timer is working, but after the initial click (which I intended to stop the first timer and start the second) nothing happens. Here is my code:

Code: Adventure Game Studio
  1. // room script file
  4. Timer *succubTimer0;
  5. Timer *succubTimer1;
  6. Timer *succubTimer2;
  9. int showdown = 0;
  12. function room_AfterFadeIn()
  13. {
  14.   succubTimer0 = Timer.StartRT(3.0);
  15. }
  18. function room_RepExec()
  19. {
  20.   if (Timer.IsExpired(succubTimer0)) {
  21.   cSmileyface.ChangeRoom(38);}
  22.   if (Timer.IsExpired(succubTimer1)) {
  23.   cSmileyface.ChangeRoom(38);}
  24. }
  27. function oSuccubus_AnyClick()
  28. {
  29.   if (showdown == 0) {
  30.   Timer.Stop(succubTimer0);
  31.   oSuccubus.SetPosition(1528, 407);
  32.   showdown += 1;
  33.   succubTimer1 = Timer.StartRT(2.0);}
  34.   if (showdown == 1) {
  35.   Timer.Stop(succubTimer1);}
  36. }

Apologies in advance for being a total noob. I'm learning all the time!

Another mystery solved! Thank you, now I understand how it works.

Hi guys :grin:

I initially couldn't get the timer to work and found a thread where another user had the same issue.
Here I discovered Crimson Wizard's Timer Module and imported the script. But my timer still isn't working.

Code: Adventure Game Studio
  1. Timer *chickenTimer;
  3. function room_AfterFadeIn()
  4. {
  5.   chickenTimer = Timer.StartRT(5.0);
  6.   if (Timer.IsExpired(chickenTimer)) {
  7.   cSmileyface.ChangeRoom(15);
  8.   }
  9. }

I want to change room when the timer expires, but as far as I can tell there's nothing wrong with my code. Am I missing something?

You were right and it wasn't fixed. I must have produced some text I hadn't seen the first time.
I'm starting to get the hang of things now. Please consider this solved.

Thank you so much, Khris.

I put function room_beforeFadeIn; at the top of the room script and that fixed it.

Hi all,

I'm already aware that text overlays are removed when the player changes room:
...except that with this command the text stays on the screen until either you remove it with the Remove command, or the player goes to a different room, in which case it is automatically removed.

When I first read this I mistakenly assumed it just meant remove from sight. Now I see that returning to a room I cannot get that text to reappear.

Just to clarify, is it possible to recreate the overlay (via whatever triggers it) every time that room is revisited? Or is this counter-intuitive?

Thank you, that solved it!

So item height/width is the space the item takes up in the inventory window, regardless of the sprite size. Now I understand. First-timer and all ^^; and I was thinking the code was messed up.

Crimzon Wizard:

 -My player character is called cSmileyface in the script. I assumed it would belong to him by default. Where should it be linked to him?

 -According to the script, the cursor switches to interact in the inventory, but I actually use interact cursor by default, with a pointer sprite.

 -I'm not sure how to do a breakpoint, I assume you don't mean separating the code there since that causes an error and I can't load the game.


 -My game resolution is 1920x1080. The Inventory window takes up most of the GUI's space, at 815x441 pixels.
However, "item height/width" is 20x30. The sprite seems to ignore this. Should I make these values larger?

Thank you, Crimson Wizard

Unfortunately still can't fix it :(

After my previous post I immediately realised I'd need to check the "Override built-in inventory handling". But that didn't fix it.

The GUI type is "Normal, initially off". I have an object in a specific room which, when clicked on, displays the inventory.
As I mentioned before, the item displays fine after it is collected, but clicking on it doesn't change the cursor ><

I'll keep experimenting... 

Thank you. I had checked that thread, but thought it might be different since they are making a game specifically with one mouse type only.

I attempted your suggested solution, fitting the code into the on_mouse_click section, but I think I must have made a mistake somewhere as I still cannot select the item in the inventory.

Code: Adventure Game Studio
  1. function on_mouse_click(MouseButton button) // called when a mouse button is clicked. button is either LEFT or RIGHT
  2. {
  3.   if (IsGamePaused() == 1) // Game is paused, so do nothing (ie. don&#39;t allow mouse click)
  4.   {
  5.   }
  6.   else if (button == eMouseLeft)
  7.   {
  8.     Room.ProcessClick(mouse.x,mouse.y, mouse.Mode);
  9.   }
  10.   else if (button == eMouseLeftInv) { // EDITED CODE STARTS HERE
  11.     // if no item selected, then select one
  12.     if (player.ActiveInventory == null)
  13.         player.ActiveInventory = inventory[game.inv_activated];
  14.     // otherwise use item on item
  15.     else
  16.         inventory[game.inv_activated].RunInteraction(eModeUseinv);
  17. } else if (button == eMouseRightInv) {
  18.     // if some item is selected, then deselect it
  19.     if (player.ActiveInventory != null)
  20.         player.ActiveInventory = null; //EDITED CODE ENDS HERE
  21. }
  22.   else // right-click, so cycle cursor
  23.   {  
  24.     mouse.SelectNextMode();
  25.   }
  26. }

Sorry if I'm out of my depth, I just find I learn a lot more by tackling things head on.

I have made a serious effort to solve this problem by myself.

I've created a custom inventory that appears when a button is clicked, and the item is showing up correctly after acquisition.
However, clicking on the item does not change the pointer to its cursor sprite.

For the inventory GUI I'm just using the code from the DemoQuest template

Code: Adventure Game Studio
  1.    function ShowInventoryWindow() {
  2. //
  3. // This function opens the inventory selection GUI.
  4. //-------------------------------------------------------------------
  5.         mouse.Visible = true;
  6.         gGui1.Visible = true;                                           // Show custom inventory window
  7.         mouse.Mode = eModeInteract;                     // switch to the Use cursor (to select items with)
  8.   mouse.UseModeGraphic(eModePointer);   // But, override the appearance to look like the arrow

From the item itself (iRatSkull) I created an event linked to this function

Code: Adventure Game Studio
  1. function iRatSkull_Interact()
  2. {
  3.   cSmileyface.ActiveInventory = iRatSkull;
  4. }

Is there something obviously wrong here? :(


Fixed. I honestly did do it via the event the first time, so I don't know why it wasn't working.
Sorry for taking your time.

Hi all,

So I'm shelving my cycle-through-item cursors-without-GUI idea, only because I don't have enough experience to script it properly.

I created a GUI for an item inventory and made a button with a cross to close it. However, it won't disappear for some reason.

My script (located in Global script)

Code: Adventure Game Studio
  1. function CloseInv_Click(GUIControl *control, MouseButton button) {
  3.   gGui1.Visible = false;
  4. }

CloseInv is the name I gave to the button for closing the window.

Since it won't disappear, I'm wondering if there's a clash with the button I used to make it visible in the first place?

Code: Adventure Game Studio
  1. function OpenInventory_AnyClick()
  2. {
  3.   gGui1.Visible = true;
  4. }

Thank you kindly for your replies.

I'm going to attempt Crimson Wizard's suggestion.

ManicMatt is right that it would be frustrating to cycle through lots of items before returning to "look".
However, items will be used and removed from the inventory, so typically you'd have 2 or maybe 3 at any given time.
I'll also make the sprite for the cursor very explicit.

Maybe it won't go down well, but I'll give it a try!

Hi everyone,

I am making a game that initially has 2 mouse modes active (interact and look)

I would like to make it so that item cursors will be added to the cycle of available cursors, once said item has been added to the player's inventory, bypassing the need for a GUI inventory.

I have tried to piece together how to do this on my own but I am not good at scripting and would be grateful for any pointers (no pun intended) on how to approach this.

Beginners' Technical Questions / Re: No background music
« on: 13 Nov 2018, 11:04 »
Thank you for your responses. I have fixed the error by inserting the code via the Event section of properties.
Writing in the code directly didn't seem to work for some reason.

Beginners' Technical Questions / Re: No background music
« on: 12 Nov 2018, 14:15 »
Apologies for reviving this thread from the dead, but I have the exact same issue.

Latest version of AGS,
My code for room1 is

function Room_AfterFadeIn ()

I also tested this after adding the following to connect it to an event, as was suggested:
Display("Music should be playing now");

In properties, the OGG file can be played and heard with no problem. 
But starting up the game gives no sound, even though volume in properties is set to 100.
I'm quite stumped.

Pages: [1]