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

#1
Hey all,

I just found something a little weird, and I thought I should ask here to make sure I'm doing everything correctly.

I'm trying to have a GUI that pops up when the user right clicks an inventory item. There are four buttons on the GUI, each of which does some inventory management action.

What I want to happen is for the buttons to display a border around a section of the background image when the mouse hovers over them. The button should have no image (image 0) at all other times. Naturally, I am trying to use the MouseOverGraphic property that all Buttons have.

However, I've noticed that the setting the NormalGraphic to 0 causes the button to act like it's half invisible - you can still click it and it still functions correctly, you just can't see it. You also can't see the MouseOverGraphic. I've tested specific values in game with the Display command; though the button images don't appear, the MouseOverGraphic reads as the one I set, and the button also reads as Visible. I'm just wondering if this is normal behavior, or if it's a bug.

In any case, I have a workaround - I just set the NormalGraphic to a single transparent pixel, and then set the MouseOverGraphic as normal. I'd still like to figure out this weird problem, though.
#2
Khris:

I can't open the default GUI in the editor. I'm talking about the built-in ones that pop up with SaveGameDialog()... as far as I know, it's impossible to edit those. That's why I'm trying to make the custom GUIs.

1. It is possible for the player to select different characters, each of which has a different view. My problem is that when I save the game with one view, and try to load with another, it keeps the first view. So, for example, the player chooses view A as a character, then saves the game and turns it off. Later, he restarts the game, makes a new character with view B, and saves again. If he tries to restore to the first game, the game will successfully load, but the character will still have view B (not view A, as expected).

2. Thanks. I'm not sure how I missed that...  :P

3. Again, thanks. I'm still a bit new the Windows 7 environment.  :)

EDIT: Alright, I figured out what I was doing wrong regarding 1. I wasn't using the ListBox.SaveGameSlots[] array, instead loading games directly from ListBox.SelectedIndex. This of course loaded the wrong game, even though I thought it was the right one.

Thanks for the help Khris!
#3
I'm trying to make a custom Save/Load system for my game, and while I'm making a bit of progress, I could use some help.

The most important thing is this: is it possible to change the default save/load GUIs to look different, or do I have to make a new GUI(s) to handle this?

If I do, as I suspect is the case, I have some more questions. First, some background: I am using the default save/load system built into AGS (using functions like SaveGameSlot and RestoreGameSlot). However, I've noticed a few limitations to this system which I am having a hard time getting around.

1. How would I go about saving the current character's view in the save state? I let the player choose different characters at the start of the game, and whenever an old game is restored, the view from the newer game is carried over, which is not what I want. More specifically, is there a way I can do this without writing to an external file? Because if I have to write to another file, how would I synchronize the file with the save slot?

2. I have a delete game GUI set up, but I can't figure out how to actually delete save games. Is this even possible, or do I have to manually find the folder the games are saved in and delete them?

3. Where is the save game folder? Where is the default location of $SAVEGAMEDIR$ on a Windows 7 machine?

I might have more questions, but I can't think of any more right now. I'll add them when I think of them.

Thanks for the help!
#4
I've noticed that when I delete views, I cannot get those view numbers back. What I mean is, if I delete view one, the next view I make will not a be another view one, but the numbering will start at view two. It's kind of weird, and very annoying. Is there any way to renumber the views?

EDIT: Suddenly it is giving me those view numbers again, but they are all out of order. I have View2, View4, View5, View1, View3, in that order. Is there some way to reorder these?
#5
I know you said it was discontinued, but would it be possible to upload a copy of the plugin for people who are using older versions of AGS?
#6
I understand the object oriented way of doing it, it's just that I need to know how to implement the Room.MusicOnLoad property if it doesn't exist anymore.

What I'm trying to accomplish is, the player enters the room, and music plays. Sometime while the player is in the room, he clicks on a menu, which opens different music. When the menu is closed, whatever music the room loads with starts over again. Depending on which room the player is in, this could be a different song - so I need the MusicOnLoad property.
#7
Hi everyone,

I am returning to AGS after a few years break, and I am amazed at the changes that have happened. I think I can handle most of the bigger changes, but the new audio system is really getting me. I am trying to convert an old version 3.1.2 game to the new 3.2 RC3 version. I am going through all my scripts, and converting PlayMusic(#) to what they are supposed to be. However, there is one point where I coded this:

PlayMusic(Room.MusicOnLoad);

How would you convert this into the new version? Thanks in advance for the help!
#8
I tried the code, and like you predicted, the item was null. Even if I hard code the values in, it's still null.

But, after some more experimenting, I found the problem. When the GUI is off, it can get the inventory item underneath it because the GUI is not there. When it is visible, it's X and Y coordinate is actually the top left pixel of the GUI. Of course, there is no inventory item on that pixel - or GUI, for that matter. Calling this:

Code: ags

    cPlayerDiscard.AddInventory(InventoryItem.GetAtScreenXY(gRClickMonstDef.X - 1, gRClickMonstDef.Y - 1)); // game crashes at this line


fixes the problem. (subtract 1 from the GUI's coordinates.)

EDIT: yup, Trent, i guess you found it before me. Nice work! And btw, that spelling error has been in AGS since 2.72 at least, if I remember correctly. hehe  ::) ;D
#9
Sure thing.

Here is my code:
Code: ags

function btnMonstDefDiscard_OnClick(GUIControl *control, MouseButton button)
{
    gRClickMonstDef.Visible = true; // if true, game crashes. if false, game runs fine.
    cPlayerDiscard.AddInventory(InventoryItem.GetAtScreenXY(gRClickMonstDef.X, gRClickMonstDef.Y)); // game crashes at this line
    cPlayerHandInBattle.LoseInventory(InventoryItem.GetAtScreenXY(gRClickMonstDef.X, gRClickMonstDef.Y));
}
#10
This is really weird.

First, a little background: I'm trying to make a game that has a right-click menu. Whenever the player right-clicks on an inventory item, a menu GUI with a few options opens at (mouse.x, mouse.y). Depending on which option is clicked, I run a function. One of those functions accesses the GUI's x and y coordinates to find out which item was clicked using the InventoryItem.GetAtScreenXY() function.

Now the weird part: it seems that if the GUI is visible, it's x and y are null, yet at the same time a valid integer. My game crashes if I call the GetAtScreenXY() function while the GUI is visible, but if it's not, then it runs fine. I've checked with a display the GUI coods while it's visible, and it returns a valid location. Any ideas what's going on?

The error I'm getting:
AddInventoryToCharacter: invalid invnetory number

I've checked and double checked, it should be calling the right inventory number. Besides, all I change is the visibility setting og the GUI and it works.
(And yes, it is spelled invnetory in the error  :P)
#11
Another solution is to have the character walk away with the normal Walk command, then in the repeatedly_execute function check to see if the character is moving. If not, change the room, if yes, don't.

I'm thinking something like this:

In function where character changes rooms:
Code: ags

cCharToChangeRooms.Walk(X, Y);


In the repeatedly_execute function:
Code: ags

if (cCharToChangeRooms.Moving == false)
    cCharToChangeRooms.ChangeRoom();


That will enable the player to continue moving or doing whatever while the other character moves off screen and then changes rooms.
#12
Wow, that was fast  ;D

That's kind of what I thought, but I wasn't certain and I couldn't find it in the manual.

Thanks for the quick reply!
#13
I was just wondering if what I'm thinking is the correct way of doing things or not.

I want to have the player press an arrow key on the keyboard, but depending on which room it's pressed in, it does different things. There's the default action (move character) which I placed in the global script. In one room, however, I want to scroll the room with ViewPort.

So my question is this:
Can I make a on_key_press function in a room script? Or do I put the code in the room's repeatedly_execute?

Either way, I believe I need to put a ClaimEvent call somewhere in the room, correct?

Thank you!
#14
I think I found a small bug:

I named one of my GUIs "gPlayerDeck" and then tried to name one of my characters "cPlayerDeck". I made sure the first letters are different, so technically they are different names. But I still got an error:

---------------------------
Adventure Game Studio
---------------------------
This script name is already used by another item.
---------------------------
OK   
---------------------------


I can get around it by naming my character cPlayerDeckc, but that's annoying. Is it a bug, or did I do something wrong?
#15
Hey everyone, it's been a  while since I last posted here. Doubt anyone remembers me, but that's okay.  ::)

EDIT: Never mind, I figured it out myself, after an hour of brain-frying madness. You can now ignore this post. (though it seems that's what you were doing anyway... :P)

Anyway, I am having a lot of difficulty with a custom save/load GUI. I decided, after tinkering with my old (and broken) game, I would just upgrade it to AGS 3.1. Unfortunately for me, I can't figure out a lot of the new functions.  :-\

I got the Restore Game GUI to work (at least I think so... I haven't been able to save yet) but the Save Game dialog is messing me up. Basically, what I've got is a text box, a list box, and an OK button. What supposed to happen is when the player clicks on the list box and selects an item, that text goes into the text box. If the player presses save, that slot is overridden. I think I got this part to work.

What I can't figure out is how to get it to save for the first slot, since SaveGameSlot needs an index to save to. I don't want to put it at 0, because that might override the slot at the top, but the TopItem property doesn't return -1 if there is no top item - it returns 0! So I can't put an if statement to check if TopItem is nonexistant.

I know there's a custom save/load GUI module floating around here somewhere, but I'd rather get the experience doing it myself. I already feel like I cheated a little by downloading strazer's KeyboardMovement module.  :-[

Any help, guys?
Thanks,
Niksterg

PS here's the code:

Code: ags

//global script file
function btnSaveGameCancel_OnClick(GUIControl *control, MouseButton button)
{
        gSaveGame.Visible = false;
}
function SaveGameList_OnSelectionChange(GUIControl *control)
{
	tbSaveGameText.Text = SaveGameList.Items[SaveGameList.GetItemAtLocation(mouse.x, mouse.y)];
}

function tbSaveGameText_OnActivate(GUIControl *control)
{
	int i = SaveGameList.SelectedIndex;
	if (i == -1) 
		i = SaveGameList.TopItem + 1;
	SaveGameSlot(SaveGameList.SaveGameSlots[i], tbSaveGameText.Text);
}

function btnSaveGameOk_OnClick(GUIControl *control, MouseButton button)
{
	tbSaveGameText_OnActivate(control);
}
#16
As far as I know, the game can't be run from a CD or DVD. You have to have all files on the actual computer you want to play it on. Correct me if I'm wrong.  ;)
#17
I asked this a long time ago, and the answer is, unfortunately, no, unless something has changed that I'm not aware of.
#18
AHA! I told it was a version problem.  ;D

I downloaded 3.0.2 SP1 and problem disappeared. Thanks Chris! Is there anything you can't solve?  ;)
#19
Well, since you really seem to want to check it out, I'll upload it. I don't know if the rooms, code, etc will compile correctly, since I did add a number of PlayMusic and other commands. I'm just leaving the code like it is (again, fairly sloppy, not much commenting :P)

The lines of code you are looking for are lines 57 where I declare the dynamic array, and line 772 where I try to set it to a value.

Sorry for the horrible coding... I'm remaking this now, so it should be a little better in version 2.0  ;D

http://www.freewebs.com/magicianxy/niksterg_oldgame.zip
#20
That seems to have fixed it, thanks.

Yes, what you did to replicate it was exactly what I did. Glad you figure that out so fast!
SMF spam blocked by CleanTalk