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

#21
I had found a few posts on this subject, but I can't seem to get where I need to be and I'm a bit confused.

TextArea Module v0.0.1.1 BETA (Multi-line textboxes)
http://www.adventuregamestudio.co.uk/forums/index.php?topic=34560.msg451995

Description Module:
http://www.adventuregamestudio.co.uk/forums/index.php?topic=26306.0

and this MultiTextBox v1.00 Module (Handle multiple text boxes)
http://www.adventuregamestudio.co.uk/forums/index.php?topic=26539.msg335878#msg335878

All I'm doing is making it so that when I click a button in the gui, let's say "Strength", then it will display "Your ability to carry lots of equipment blah blah" in a text box area at the bottom right of the screen. I can get it to do that, but of course it's just 1 line that trails off the screen.

I'm just wondering what the most efficient way would be to get this done. I also don't want another text box filling up unrelated ones. Right now if I type in the character's name then it will also fill the description box until I click on "strength" and it's cleared.


Should I use one of these modules or am I just making it more complicated than it is? My prediction is that I should use a text box to enter the character name and a separate listbox for the description box (info for each button). Sorry, I can't always figure out if a module is exactly what I need or if it's not necessary.

It seems like I'll need one of these modules since you can only have 1 text box displayed at a time (from what I've tried). I don't want to disable one at any time, I need them both to display at once.


Important note: The MultiTextBox Module gives me an error just running the game after. It says:
"
Error(line 55): Array size must be constant value

struct MultiTextBox {
  import static Label *HighlightCloseLabel(GUIControl *gc, int color);
  TextBox *stack[AGS_MAX_GUIS];

"


Incase all of that mess confused you, I'm just asking what any of you would do to solve two problems:

1. Text boxes don't wrap and just make a straight line off the screen"
2. I can't have multiple independent text boxes without a module (from what I can tell). So should I use listboxes or somehow set a label to display different wrapped text for each button (strength, dexterity, etc)?



Thanks in advance!
#22
Quote from: Khris on Wed 31/10/2012 21:13:12
A GUI needs to be clickable if it has buttons and stuff on it (as opposed to being used just for graphic effects).
Thus, regardless of the background, only one GUI will work if you put them on top of each other.
Giving them the same zOrder won't magically make them merge or something, it'll just make the order depend on arbitrary things like the order in the editor.

You can of course turn them clickable and not clickable in repeatedly_execute:
Code: ags
  gGUI1.Clickable = (mouse.y < 384);
  gGUI2.Clickable = !gGUI1.Clickable;


What I would do though is put the background on the bottom GUI, then put the other GUI on top but make it only half as wide/tall so it doesn't cover the controls of the bottom one. Problem solved, and without annoyances.

That was incredibly helpful, thank you! That completely solved it. I knew there was a simple shortcut out there  :)
#23
Imagine a character creation gui separated into 2 parts (AGS only allows a certain number of buttons per Gui). The top Gui (1024x768) has a background and buttons/input boxes. The bottom Gui (1024x768) has more buttons, a description box and a transparent background/border.

I have the top and bottom Guis both set to ZOrder 0. The bottom gui has a transparent background (I was simply trying to overlap the top layer) so when they are both displayed at once (1024x768 dimensions each) I can see everything BUT I can't click the top Gui buttons at all. It's just displayed as if the top Gui is a solid static picture while the bottom is active.

Is there a way to make the top and bottom guis active depending on which half of the screen that the mouse is in? The annoying solution I already realize is to separate the background into two sections and map one to only display at the top (0,0) - (1024,384) (as if drawing a box), while the other would be (0,384) - (1024,768).
#24
Quote from: Khris on Sat 27/10/2012 01:42:30
The main purpose of the module is to add inventories to rooms; displaying them is completely optional and according to the module's thread, in order to do so, you have to manually place the assigned character.
In other words, after calling player.DropInventoryItem(...), you need to call:
Code: ags
  cSMG.ChangeRoom(player.Room, player.x, player.y + 3);

(You can of course add this line to the module's function, using the Character* variable of the function instead of cSMG.)

perfect, thank you!
#25
Sorry if you had just helped me with my previous method. It's pointless when I can just figure out this module. I set the iSMG with the cSMG(character) using the module script, but what I can't figure out is how the item is displayed.

I set the cSMG location to display coordinates with every click so that I could track it. It just stays in the current room at the default location.

I took a look at the RoomInv script to see what it actually does and apparently it's very automated so I really shouldn't have to do very much besides setting the InventoryItem to link the Character to.

Module Link:
http://www.adventuregamestudio.co.uk/forums/index.php?topic=28770

Code: AGS


//If player brings grabbed item to the DropItem area (I haven't made it where player has to click it yet)

if(GUIControl.GetAtScreenXY(mouse.x, mouse.y) == DropItem && Mouse.Mode == eModeUseinv)
{    
     RoomInv[1].AddInventory(player.ActiveInventory); // add the item to room 1
     RoomInv[1].SetCharacterToUse(player.ActiveInventory, cSMG); //This should make cSMG auto change rooms to where the player is at, right?
     
     cEgo.DropInventoryItem(player.ActiveInventory, 1); //I figured this would work to display the item, but I don't see anything.
     
     //Inventory windows close
     gInventory.Visible = false;
     gInventory2.Visible = false;
     gInventory3.Visible = false;
     
}



The module has this in the ReadMe:

"
bool Character::DropInventory()
  Drops all of the character's inventory items into the current room. This will remove
  the items from the character's inventory.

bool Character::DropInventoryItem(InventoryItem*, optional int quantity)
  Drops the specified item into the character's current room (if the character was
  carrying the item). QUANTITY may be used to drop more than one of the item at once.

bool RoomInv[INDEX].SetCharacterToUse(InventoryItem*, Character*, optional int x,
optional int y)
  Sets the character to be used by the specified inventory item within the room
  specified by INDEX. In this way it is possible to show the room's inventory as
  "objects" that you can interact with.

bool RoomInv[INDEX].SetInventoryQuantity(InventoryItem*, int quantity)
  Sets the inventory quantity of the specified item in the room specified by INDEX to
  QUANTITY.
"

and others. I also went through the main post to see if I could get it working.


There's just something I'm leaving out or not understanding fully. I just would like to finally get this drop item method working.

Thanks to those helping repeatedly. It means a lot  :)
#26
Got it.
Code: AGS

bool inside = (mouse.x + GetViewportX() >= dropmap1x1 && mouse.x + GetViewportX() <= dropmap1x1 + 10 && mouse.y + GetViewportY() >= dropmap1y1 && mouse.y + GetViewportY() <= dropmap1y1 + 10);
#27
Quote from: Khris on Fri 26/10/2012 13:39:15
The bottom line is:
You're constantly biting off more than you can chew, and every time you ask for help, we have to wade through messy code.
I'm sorry, but that's the way I see it. I'm not sure what can be done about that, you seem very ambitious about what I assume is a pretty complex fallout type game, so I guess the positive thing is that you're developing your coding skills. I'm just a hesitant about providing in-depth help because you keep starting off in a bad way, and I'd rather tear everything down and rebuild it properly instead of putting duct tape all over it.

I appreciate your patience as I'm exploring some new territory and magnifying some fuzzy areas. I'm working as quickly as I can to get where I need to be, and although I have some lazy moments, (as seen earlier throwing together the "dropmap1x1+1 ||" list) I'm almost always giving it 100% effort unless I've stayed up until 8AM (like now). So yea I'm a bit tired, lol.

I took Java and C++ many years ago so all of this is coming back to me. I love piecing it all together, and this forum (especially you two) are incredibly knowledgeable and have much more important things to attend to, I'm sure. Sometimes I know what I want to do but I just can't churn out the code like second nature quite yet. I'll get there.


Quote from: Khris on Fri 26/10/2012 13:39:15
As far as my code not working, what I posted was meant to show the proper way of doing it, it's not necessarily ready to implement as-is.
For instance I assume that the dropmap coordinates are room coordinates, while the mouse coordinates are screen coordinates.

I didn't just copy and paste it. I was trying to implement your strategy of the box search method vs the cross (as I had it). I see how yours works and I guess basically it should work but I have some little thing wrong I'm sure.


Quote from: Crimson Wizard on Fri 26/10/2012 13:36:15
You may do that - by iterating all inventory items and finding one that has same graphic.
But easier way would to be to remember actual inventory item pointer instead of item's graphic.

You may also use custom structs to store information on dropped items, something like this:
Code: ags

struct DroppedItem
{
   int Room;
   int x;
   int y;
   int Graphic; // sprite to use to draw dropped item
   InventoryItem *InvItem; // pointer to actual inventory item, use it to give item to player
};


Thanks, I'll keep structs in mind. I hadn't used them before, but I get the idea.


Bottom Line: I completely agree; I don't want to do more work than I have to. That being said, I should just learn to use the RoomInv Module.
#28
Quote from: Khris on Fri 26/10/2012 12:42:27

You subtract GetViewportX() when you want to get from a room coordinate to a screen coordinate, but surface is the room's background surface and thus wider than the screen, ie. drawing to it is done using room coordinates.

Thanks, I needed to clear that up some. I feel like I've tried everything to get accurate coordinates, including just using room coordinates. I'll try again.



Quote from: Khris on Fri 26/10/2012 12:42:27
Also keep in mind that as opposed to using Characters, drawing dropped items to the background makes them ignore scaling, lighting, walkbehinds and other characters and objects.

As far as I understand, the player clicks a GUIControl while holding an item, and it is dropped to the ground in front of the player, right?
Yes. And thank you, I figured most of that would be the case but wanted to try it out.


Quote from: Khris on Fri 26/10/2012 12:42:27
You need to use:
Code: ags
  bool inside = (mouse.x >= dropmap1x1 && mouse.x <= dropmap1x1 + 4 && mouse.y >= dropmap1y1 && mouse.y <= dropmap1y1 + 4);
  if (inside && gInventory.Visible != true) ...


Wow, that is really simplified. I knew I wasn't doing it the intended way so I appreciate you showing me how to do the box search rather than my goofy way.

It doesn't work though. I'm not sure if I did something wrong but I logically replaced my garbage with your nice code. Hmm...trying to get it working again.

Edit: I wanted to clarify that I know your code works, but implemented in my game right now it's not working...yet. I'm trying.

Also am I able to convert "player.ActiveInventory.Graphic" stored in Citem1 back into the inventory item number?

Edit2: I got the item to drop infront of the player anywhere on the map now (thanks), but the "inside" function isn't working still.
#29
Quote from: Crimson Wizard on Fri 26/10/2012 12:04:34
I'd say it is not a good idea to store only one pixel. Try to store a rectangle bounds instead; you may get Graphic metrics by using Game.SpriteHeight[index] and Game.SpriteWidth[index].

More, you are making the mistake when you try to erase your sprite with transparent rectangle. Drawing transparent rect over image will result in nothing.
If you want to do this properly, you should copy and store an underlying piece of background and redraw that on same coordinates.

I managed to get it to work with this, but it still doesn't solve converting the stored graphic ID into the inventory item ID. I laughed when this horrible code worked. Note: I didn't implement the erase drawn image fix you mentioned yet.
Code: AGS

if(Mouse.Mode == eModeInteract && mouse.x == dropmap1x1 || mouse.x == dropmap1x1+1
  || mouse.x == dropmap1x1+2 || mouse.x == dropmap1x1+3 
  || mouse.x == dropmap1x1+4 && mouse.y == dropmap1y1+1 ||
  mouse.y == dropmap1y1+2 || mouse.y == dropmap1y1+3 || mouse.y == dropmap1y1+4 && dropmap1x1 != -5000 && gInventory.Visible == false
  && gInventory2.Visible == false && gInventory3.Visible == false)
  {
    
    
    
    
    cEgo.AddInventory(iSMG);
    
    DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();
    surface.DrawImage(dropmap1x1, dropmap1y1, 164, 0, 35, 25);
    
    surface.Release();
    
    gInventory.Visible = true;
    gInventory2.Visible = true;
    gInventory3.Visible = true;
  }
#30



Thanks for your help. I'll probably need help with the RoomInv Module so I'm sure I will post a new topic if I scrap this idea completely. Either that or just have chests/shelves in each map (set as characters) that you can store items in. It would be the easy way out  :)
#31
Quote from: Crimson Wizard on Fri 26/10/2012 11:47:46
Is there just any rational reason you want to make it that way?
You are basically on a path to invent a new class of room objects, that you have to manually process: store data in memory, (re)draw, detect interaction, etc, while there is already a solution which makes engine do that.

By the way, did you know that:
Quote from: AGS manual
GetDrawingSurfaceForBackground
<...>
Any changes you make will only last until the player leaves the room, at which point they will be lost.

Well, I can sortof see what you're saying, but I feel like it's a bit simpler than that. Bear with me if I sound like a moron, but all I'm doing is saving coordinates. Let's say I drop an item at (200,400) and it's just a drawing of the gun. I can then walk around the map, go to another map, come back to map1 and all items can be redrawn at their coordinates (stored in dropmap1x1,dropmap1y1 then dropmap1x2,dropmap1y2, up to a max of 10 items dropped per map).

I just can't, for the life of me, get the mouse to detect those coordinates stored in (dropmap1x1,dropmap1y1) to where the item was drawn. I walk up to the little gun drawn on the ground with the interact hand and it just won't detect the coordinates. Is it too exact since it's 1 pixel on the screen?

The reason why I resorted to this is because I couldn't figure out the RoomInv Module. I'll give that a try again.
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=28770.0
#32
This is the code that makes my character "drop" their grabbed inventory item onto the ground 10 pixels below (removed from inventory, then drawn smaller).

Code: AGS

if(GUIControl.GetAtScreenXY(mouse.x, mouse.y) == DropItem && Mouse.Mode == eModeUseinv)
  {
     if(cEgo.Room == 1 && dropmap1x1 == -5000)
     {
       dropmap1x1 = XTarget;
       dropmap1y1 = YTarget + 10;
     }
     
     Citem1 = player.ActiveInventory.Graphic;
     DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();
     surface.DrawImage(dropmap1x1 - GetViewportX(), dropmap1y1, Citem1, 0, 35, 25);
     surface.Release();
     player.LoseInventory(player.ActiveInventory);
     gInventory.Visible = false;
     gInventory2.Visible = false;
     gInventory3.Visible = false;
    
  }


I can't figure out how to detect the sprite drawn to re-equip the item again. I know there's a way. Yes, I realize the main method people use is creating a character per item that is stored on the map. I wanted to try this way. Here is the code I'm using that doesn't work. The script never activates to pick up the item. I'm not sure if my coordinates system is all screwy.

Code: AGS

if(Mouse.Mode == eModeInteract && mouse.x == dropmap1x1 && mouse.y == dropmap1y1)
  {
    
    
    
    gInventory.Visible = true;
    gInventory2.Visible = true;
    gInventory3.Visible = true;
    cEgo.ActiveInventory = iSMG;
    DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();
    surface.DrawImage(dropmap1x1, dropmap1y1, 164, 0, 35, 25);
    surface.Release();
  }



Note: Without moving my character it reads as:
player coordinates: 1502,265
item dropped at: 1502,275
viewport: 495,0

I tried to make it where the coordinates of the sprite drawn were saved so that if you position the mouse back over those coordinates then the mouse will change so that you can grab at the sprite, which would then kick in the script to write over that item (with a blank, transparent surface aka: sprite 164) and then add that stored item. I'm starting to see why people just go with the character as inventory item option. Am I crazy or is this method possible?
#33
All of the links seem to be down here:
http://www.adventuregamestudio.co.uk/forums/index.php?topic=28770


This is a Godsend in terms of how much simpler it will make it (in coding) to drop items and come back for them later in the map. I really hope that someone out there happens to have this rare module. If anyone has an alternative module then please let me know  :)


Edit: Lmao..I think the guy who put the last  comment at the bottom and I both clicked the wrong links. It's right here: https://sites.google.com/site/monkey0506/RoomInv_3_0_0.rar?attredirects=0ight

I clicked the Brinkster and below links but not literally the one that says "download". This is one of those times where I wish I could delete my post.
#34
Many thanks to you both for the quick responses.
#35
Quote from: Khris on Sun 21/10/2012 10:53:42

GUI is the gui class, and LeftHand is an instance of it. .GetAtScreenXY isn't a method that does something to a specific GUI, like for instance .SetPosition; it should be a static method that can only be called like it's supposed to. Unfortunately it isn't, and not only will it compile, the end result is the same. But you shouldn't use it like that, if only to avoid other people seeing that and adopting it.

Actually it turns out I was using the commands with inventory windows as well. What is supposed to be here instead of "GUI.GetAtScreenXY"? This isn't a Gui, it's an inventory window, so what is the proper form?

Code: AGS

if(RightHand.GetAtScreenXY(mouse.x, mouse.y) == RightHand && RHITEMSET == 1)
  {
    InventoryChar2.SetAsPlayer();
  }
#36
Ahh okay, gotcha =]. Thanks for explaining that, it wasn't quite clicking. Good to know so I don't help someone out technically wrong (as you said).

I went ahead and replaced all of the mistypes. It's funny 'cause I'd always stare at that code and be like "why the hell is this working?" then shrugged it off when it actually worked consistently =P
#37
Quote from: Khris on Sat 20/10/2012 22:00:11
The command is GUI.GetAtScreenXY(...), with the GUI part actually being "GUI", not the name of some GUI that might or might not be there. It'll still work how you're doing it because apparently the method isn't static, but it's bad form and makes no sense.

Please explain what you mean. This method has worked flawlessly to detect if a mouse is at certain parts of a gui or an entire gui. What should I change in my code? Keep in mind I have about 120 lines of code just for the inventory system so far (still have a lot needed) including that little section I posted. I didn't want to post the bulk of it.
#38
Whoops, scratch all that. I read what you said as "Is it supposed to open from a gui?"
#39
Quote from: Khris on Sat 20/10/2012 12:37:49
Code: ags
  if (mouse.Mode == eModeUseinv) ...


The InventoryItem* is player.ActiveInventory.

Sometimes it's the simple things that get me...thanks again Khris. I'm sure you might literally be staring at the screen with a gun ready from my last post. I think I was asking for too much  :=
#40
When you select an item in your inventory what is the code that basically does the function of "iSMG.selected == true". And by detected I mean in eModeInteract you grab the item and you can move it around.

Better yet, is there a code that reads whether ANY item is currently selected? As in the cursor mode is not any of the defaults or listed in the "cursors" section of AGS.


The reason I need to know this is for dragging the item into a different character's inventory. I have 3 inventories for specific functions such as what is in the player's right or left hand. Eventually I'll make another one for an Armor slot. Anyway, more of that can be seen in my previous post. I managed to get all 3 up at once and I'm still messing with code and looking around since I'm lost.

If I use the code "cEgo.ActiveInventory == iSMG" does that detect if the item is in my inventory at all or is this for if I select the item? I'm looking for the code for when the item is selected and "picked up".

Anyone out there  :)?
SMF spam blocked by CleanTalk