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

#41
Well, in global script header I have:
String InteractingWith;
and in global script I have: InteractingWith = "";

And yes, oPanel_AnyClick is room script.
#42
That's the thing. The only time I set InteractingWith is on game start and when player clicks on the object. This code is when player clicks on a button located on inventory GUI. I think the problem is that the String is set on object click. Because when I set the String "panel_r1" on game start, the code works no problem.
#43
Code: ags
    Display ("%s", InteractingWith);
    Display ("%s", F1);
  if (!String.IsNullOrEmpty(InteractingWith)) Display ("Yes it is.");
  if (InteractingWith.IndexOf("panel_r1")>=0) {
    if (F1 == "open" && F2 == "door") player.ChangeRoom (2, 63, 168);
    }


I did as you said. Defined the InteractingWith at the game start, but than again when the string is set by player clicking on an object, it does display correctly. The above code only displays F1 string. Im hopeless :confused:
#44
The InteractingWith string is set when a player clicks on an object in in a room:
Code: ags
function oPanel_AnyClick()
{
 InteractingWith = "panel_r1";
 gInventory.Visible = true;
 btnInteracting.NormalGraphic = 53;
}


Than other string F1 is set when a player clicks on an inventory item in inventory window. Than, when player click on a button, this code should start:

Code: ags
    Display ("%s", InteractingWith);
    Display ("%s", F1);
  if (InteractingWith.IndexOf("panel_r1")>=0) {
    if (F1 == "open" && F2 == "door") player.ChangeRoom (2, 63, 168);
    }


The Display lines are there for control only. The weird thing is that the InteractingWith string wont even be displayed. Only the F1 will and than nothing happens. However, when I tried to put the same display line for InteractingWith right after it is set, it will display no problem.

Sometimes I get this error, but not always:

Error: Error running function 'Button1_OnClick':
Error: ScriptSprintf: argument 0 is expected to be a string, but it is null pointer
#45
I have a string defined in global script header called "Interacting With". However, when I try to run the IndexOf function, it says null pointer referenced. It is just one line of code, but I have no idea, what is wrong.

Code: ags
  if (InteractingWith.IndexOf("panel_r1")>=0) {} 
#46
Thanks Crimson, had to change the "Override built-in inventory window click handling" in General settings. Youre the best.
#47
This is the whole code:

Code: ags
function on_mouse_click(MouseButton button) // called when a mouse button is clicked. button is either LEFT or RIGHT
{    
  if (IsGamePaused() == 1) // Game is paused, so do nothing (ie. don't allow mouse click)
  {}
  else if (button == eMouseLeft) {
    ProcessClick(mouse.x,mouse.y, mouse.Mode);
  }
  else if (button == eMouseLeftInv) {
    InventoryItem *item = InventoryItem.GetAtScreenXY (mouse.x, mouse.y);
    if (btnWord1.Graphic == 11) btnWord1.NormalGraphic = item.Graphic;
    else if (btnWord2.Graphic == 11) btnWord2.NormalGraphic = item.Graphic;
    else if (btnWord3.Graphic == 11) btnWord3.NormalGraphic = item.Graphic;
    }
  else // right-click, so cycle cursor
  {   
    mouse.SelectNextMode();
  }
}


Before I made a new function. This time I put it under mouse click script. Still, it doesn't work. Inventory window opens and mouse mode is set to interact. When I click on inventory item, the cursor just changes to the image of the item as usual but no change in button graphic.
#48
Thanks. I've already tried adding a few messages like that all over the code. Not one of them fires up.
#49
Code: ags
function MouseInventory (MouseButton btn) {
if (btn == eMouseLeftInv) {
    InventoryItem *item = InventoryItem.GetAtScreenXY (mouse.x, mouse.y);
    if (btnWord1.Graphic == 11) btnWord1.NormalGraphic = item.Graphic;
    else if (btnWord2.Graphic == 11) btnWord2.NormalGraphic = item.Graphic;
    else if (btnWord3.Graphic == 11) btnWord3.NormalGraphic = item.Graphic;
    }
}


So far I have this, but nothing is happening. :undecided: Any idea why?
#51
Hello everyone! I have a simple question. I have an inventory window and three buttons on a GUI. I would like to change the graphic of the buttons when player clicks on an inventory item, so that the button looks the same as the inventory item itself (to have the same sprite). Can anyone suggest the best way to do this, so my script won't become a mess? Thank you!
#52
AnasAbdin, Crimson Wizard. Thank you! It was the filter. I chose the 2x filter and it works now. Thank you!
#53
No, the game resolution in AGS was 320x240, my screen res is 1300x760 something. The testing window was more like 640x280 when compared to my PC res. Now the testing window takes 320x240 pixels on the desktop. Before it was twice the size. It's hard to explain. If you try it, should do the same thing on your PC. AGS 3.3.5.11.
#54
Hello everyone!

I was testing my game, resolution 320x240, testing in a window. All was good. Than, I've built the exe file, tested it again, no problem. Than I ran the game setup and since than the game window when testing is too small. It now is matching my desktop resolution, but it was much larger before. Is there a way to restore the original size of the window? Btw. the game is also too small when running fullscreen. Thanks!
#55
Wow! Thanks for your reply. This looks a bit difficult but I will give it a shot.
#56
Hello there? Is there a way to move a GUI on top of a character or an object? By default if you use Move (char.x, char.y), it will be moved to its "feet". Is there a way to move it above its "head"? All my objects and characters are of different size so I cannot move guis like (char.x - 10).

Thanks!
#57
Good to see you old friend and thanks for the help!
#58
Basically what I'm trying to do is to have a function that checks if a player has an inventory item, if not, than gives the player that item and than displays that item text property on a label. How can I do this?

Thanks!
#59
Quote from: chaosgodkarl on Sun 04/09/2011 07:36:43
strenght?

Tremendous comment, thanks! If you would download the game, you would already see it has been corrected. It is just an older screenshot chaosgodkarl. ;)
#60
Yes, saw it. Thanks.  ;)
SMF spam blocked by CleanTalk