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 - 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
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!
#3
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?
#4
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!
#5
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)
#6
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!
#7
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?
#8
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);
}
#9
I put this topic here because it deals with the way the engine handles arrays and data types, but if it's in the wrong spot, feel free to move it.

I am trying to make a dynamic array of InventoryItems. However, every time I try to compile, it gives me the error message: "Cannot declare local instance of managed type."

I thought, okay, maybe I just can't declare it in the function, it's got to be declared at the top of my global script. So I do that, and depending on whether I put

"InventoryItem* opponentdeck[]"
or
"InventoryItem opponentdeck[]"


I either get "Cannot declare local instance of managed type."
or
"Parse error in expr near 'new' ". (Respectively).

Is it not possible to make an array of InventoryItems? Or am I doing something wrong?

Here's my code, maybe that will help:
Code: ags

// main global script file
InventoryItem* opponentdeck[];

function ShuffleDeck() {
	opponentdeck = new InventoryItem[OpponentDeck.ItemCount];
       // shuffling code here
}
#10
Hi all!

I'm having the weirdest problem. I'm making a card game. Obviously, I need a shuffling algorithm. Now, a while ago, I actually had working shuffling code. However, it was very clumsy, and I could foresee problems in the future if I left it that way. So I recently changed it from using only arrays to using characters (one character for the deck, one for the discard pile, one for opponent deck, etc.) This is the code I came up with to shuffle the player's deck:

Code: ags

function ShufflePlayerDeck() { // shuffles player's deck twice
  int i=0;
  InventoryItem* playerdeck[40];
  SetGameOption(OPT_MULTIPLEINV, 1);

  while (i<PlayerDeck.ItemCount) {
    playerdeck[i] = PlayerDeck.ItemAtIndex[i];
    i++;
  }
  SetGameOption(OPT_MULTIPLEINV, 0);
	
  InventoryItem* holder;
	
  i=0;
  while (i<GetCardsInPlayerDeck()) {
    int randomspot = Random(GetCardsInPlayerDeck()-1);
    holder = playerdeck[i];
    playerdeck[i] = playerdeck[randomspot];
    playerdeck[randomspot] = holder;
    i++;
  }
  i=0;
  while (i<GetCardsInPlayerDeck()) {
    int randomspot = Random(GetCardsInPlayerDeck()-1);
    holder = playerdeck[i];
    playerdeck[i] = playerdeck[randomspot];
    playerdeck[randomspot] = holder;
    i++;
  }
	
  while (PlayerDeck.ItemAtIndex[0] != null) {
    cPlayerdeckc.LoseInventory(PlayerDeck.ItemAtIndex[0]);
  }
	
  i=0;
  while ((i<40) && (playerdeck[i] != null)) {
    cPlayerdeckc.AddInventory(playerdeck[i]);
    i++;
  }
	
}


This is basically a translation of using arrays to using characters. The problem is that now it doesn't shuffle at all! I've run through the code a hundred times. Can anyone see the problem?

The GetCardsInPlayerDeck() function returns the number of cards in the player's deck. I've checked if that may be the problem, but it isn't. It returns 26, which is the correct number of cards the player has when I try shuffling the deck.

I'm using AGS version 3.0.1 beta.
#11
Hello all,

I'm having the most mysterious problem with this script. I've been working on this game in version 2.72 for a while, and when 3.0 cam out, I upgraded. No problems. Then 3.0.1 came out, I upgraded again.

Then, in order to make scripting a bit easier for myself, I redid a lot of my older script and changed it to manage inventory with characters rather than arrays. That's when these weird errors occured.

This code worked in the previous, non-updated code and shuffled correctly. Now, not only does it not shuffle, but it also causes and error which crashes the game.

Code: ags

function ShufflePlayerDeck() { // shuffles player's deck twice
  int i=0;
	
  InventoryItem* playerdeck[40];
  SetGameOption(OPT_MULTIPLEINV, 1);
  
  while (i<PlayerDeck.ItemCount) {
    playerdeck[i] = PlayerDeck.ItemAtIndex[i];
    i++;
  }
  
  SetGameOption(OPT_MULTIPLEINV, 0);
	
  while (PlayerDeck.ItemAtIndex[0] != null) {
    cPlayerdeckc.LoseInventory(PlayerDeck.ItemAtIndex[0]);
  }
	
  InventoryItem* holder;
	
  i=0;
  while (i<GetCardsInPlayerDeck()) {
    int randomspot = Random(GetCardsInPlayerDeck()-1);
    holder = playerdeck[i];
    playerdeck[i] = playerdeck[randomspot];
    playerdeck[randomspot] = holder;
    i++;
  }

  i=0;
  while (i<GetCardsInPlayerDeck()) {
    int randomspot = Random(GetCardsInPlayerDeck()-1);
    holder = playerdeck[i];
    playerdeck[i] = playerdeck[randomspot];
    playerdeck[randomspot] = holder;
    i++;
  }
	
  i=0;
  while (i<40) {
    cPlayerdeckc.AddInventory(playerdeck[i]);
    i++;
  }
	
}





The GetPlayerCardsInPlayerDeck function simply checks to see how many cards in the player's deck.

Code: ags

function GetCardsInPlayerDeck() {
  int i=1;
  int numofcards = 0;
  while (i<=Game.InventoryItemCount) {
    numofcards = numofcards + cPlayerdeckc.InventoryQuantity[i];
    i++;
  }
  return numofcards;
}




I have 56 inventory items (cards) in my game so far. Anybody see the problem?
#12
I'm making a collectible trading card game, where the player gets cards as inventory items. I want to have these cards able to be sorted by various aspects of those cards (attack, defense, type of card, etc). So far I've used a Bubble Sort, but the variables that I use (InvWindow.ItemCount, InvWindow.ItemAtIndex, etc) are read-only, and i can't update them. So then I tried to modify the contents of the Character.InventoryQuantity[] array, but then I have to call UpdateInventory() in order for it to be shown on screen, and that totally defeats the purpose of sorting it to begin with, since UpdateInventory resets all items back to their index based on the order they were created in the editor.

Does anyone have any idea how to sort inventory items well? Thanks in advance!  ;D
#13
Hi there!

I've finally finished my game so that it is playable. All I want to do now is add a small cutscene at the end that shows the credits. However, I'm not quite sure what to script...

I'm using textual overlays for the actual credits, and there's a scene in the background where there are some people jumping up and down in celebration. Then the screen scrolls over to the right and reveals even more celebrating going on. To make the screen scroll, I used the player character with an invisible view and had him walk to the right. The scrolling works very well, but the characters in the background don't do anything because of a wait command. I wanted to have them jump with the repeatedly_execute_always function, but their jumping function is blocking, so that doesn't work.

Here's the code I have: cPlayer = player character, cTga - cTgc = people jumping

Code: ags

// room script file

#sectionstart room_a  // DO NOT EDIT OR REMOVE THIS LINE
function room_a() {
  // script for Room: Player enters room (before fadein)

  cPlayer.LockView(35); // sets character view to invisible

#sectionend room_a  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart room_b  // DO NOT EDIT OR REMOVE THIS LINE
function room_b() {
  // script for Room: Player enters room (after fadein)

  FadeIn(1);
	Wait(80);
	Overlay* credits1 = Overlay.CreateTextual(80, 120, 160, 3, 65472, "Title goes here");

	cPlayer.Walk(518, 152, eNoBlock, eAnywhere);
	Wait(400);
	credits1.Remove();
}
#sectionend room_b  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart room_c  // DO NOT EDIT OR REMOVE THIS LINE
function room_c() {
  // script for Room: Repeatedly execute

  int i=0;
  while (i<400) {
	  jump(cTga.ID, 125, 145);
	  jump(cTgb.ID, 80, 100);
	  jump(cTgc.ID, 180, 200);
              i++;
  }
}
#sectionend room_c  // DO NOT EDIT OR REMOVE THIS LINE



Code: ags

// global script

function jump(int characterID, int ymin, int ymax) { // characterID jumps from ymax to a height of ymin, then comes back down
  int i = 0;
  while (i<2) {
	if (character[characterID].y <= ymin) {
		while (character[characterID].y < ymax ) {
			character[characterID].y++;
			Wait(1);
		}
	}
	else if (character[characterID].y >= ymax) {
		while (character[characterID].y > ymin) {
			character[characterID].y--;
			Wait(1);
		}
	}
	i++;
	}
}


I will keep trying to come up with my own answer, but any help would be appreciated! Thanks  ;D
#14
I'm making my own functions in the global script. However, they are not working at all whenever i call them in other rooms. I've made one other function before, and that one worked (and still is), but all the new functions I'm making don't do anything. And I'm not getting any errors, either, unless I call the functions in room scripts.

This is my code for one of the functions that don't work:

Code: ags
function transtohuman() {
        GUIOff(6);
        PlaySound(9);
          if (character[PLAYER].view == 10) { //from dragon monster view
            SetCharacterView(PLAYER,  10);
            AnimateCharacterEx(PLAYER, 3, 5, 0, 1, 1);
          }
          else if (character[PLAYER].view == 8) { //from Tree Dweller view
            SetCharacterView(PLAYER, 10);
            AnimateCharacterEx(PLAYER, 0, 5, 0, 1, 1);
          }
          else if (cPlayer.View == 14) { //from bird
            cPlayer.LockView(10);
            cPlayer.Animate(4, 5, eOnce, eBlock, eBackwards);
          }
          else if (cPlayer.View == 16) { //from dragon
             cPlayer.LockView(10);
             cPlayer.Animate(5, 5, eOnce, eBlock, eBackwards);
          }
          else if (cPlayer.View == 22) { //from seer
            EnableCursorMode(eModeInteract);
            cPlayer.LockView(10);
            cPlayer.Animate(6, 5, eOnce, eBlock, eBackwards);
          }
        SetCharacterView(PLAYER, 10);
        if (GetGlobalInt(2) == 1) {
          AnimateCharacterEx(PLAYER, 2, 5, 0, 0, 1);
          SetCharacterViewEx(PLAYER, 6, 0, ALIGN_CENTRE);
          cPlayer.SetWalkSpeed(5, 5);
          SetCursorMode(0);
        }
        else{
          AnimateCharacterEx(PLAYER, 1, 5, 0, 0, 1);
          SetCharacterViewEx(PLAYER, 1, 0, ALIGN_CENTRE);
          cPlayer.SetWalkSpeed(5, 5);
          SetCursorMode(0);
        }
}


It's supposed to be an animation sequence that shows transformation into a human from various other forms... yes, i realize some of the script is AGS 2.62 and some is AGS 2.72... but that shouldn't make a difference. Does it? That's the last thing I have to try yet, and then I'm lost.

Any help is appreciated!

And a side question which is not as important... my .chm help file (the manual) doesn't work anymore. Is this because I have IE7 now instead of IE6? Thanks again.
#15
Just a quick question... Is it possible to set antiglide on/off for just one character instead of for the whole game? I know you can change the game options, but I'm talking about for one specific character.
#16
In my game, the main character climbs up a ladder, and then back down again later. The going up part is easy; I just have cplayer.walk(...) and he goes the right way. But when he comes down again, he's not facing the ladder. I tried using FaceLocation before he moves, and I also tried animate the character and move him at the same time. These didn't work. Any suggestions?
#17
I used the search function to see if it was possible to make the game play part in greyscale. I found out it couldn't, but it recommended using TintScreen(100, 50, 0) to make the screen look like an aged photo. (This is the topic.) However, when I go to the rooms where the Tintscreen has effect and I display a message, the mouse cursor gets rid of the tintscreen effect around it. Is there any way to change this?
#18
I am a huge fan of the King's Quest Series, and would like to integrate the basic format into my game. One of the things I am having the most trouble with are the sliders. From the research that I've done, I know that I am supposed to use the GetSliderValue command in the interface_click section of the global script. Other than that, I am clueless as to what I am supposed to script. I need sliders specifically for game speed and music volume. If anyone can help, that would be greatly appreciated.
#19
I have three question to ask:

1) Is it possible to move a character across the room WITHOUT having them activate a Player stands in Hotspot interaction? Or maybe is there a ignore hotspot script command? (The hotspot I'm referring to stretches across the top to the bottom of the room, that's why I'm asking.)

2) I am trying to make a custom inventory GUI that includes a interaction button (hand). I've set up the script, but everytime I click on an inventory item with that cursor, it activates that item, just like the select button does. I checked the script, and realized that the select button is the same as the interact button, only with a different image! Is there any way to correct this?

and lastly...

3) How do I make an unhandled_event for using one inventory item on another? I found some info in the manual, but it wasn't really specific. I know it has something to do with the numbers 5 and 3, but I am not sure what the script should be.

If anyone could help me with any of these problems, I would much appreciate it.Ã,  ;D
#20
Is it possible to stop repeatedly_execute commands? I was trying it with variables, where if the variable is set to a certain value, it doesn't repeatedly_execute. However, it is not working. Help, please? :P
SMF spam blocked by CleanTalk