Right, I've been snooking around in the technical archive a bit, and i came over this toturial: http://www.digitalmindstudio.ch/script.php?id=4&langue=en
Yeah, that seemed alright. But i wanted to create the inventory at the bottom of the screen, so i had to do some changes. Still, when i try to pick up an object, it won't go to the inventory box. There is probably some n00bish solution on this, since i'm such a crappy coder. This is the script i used:
if (interface == 2) {
if ( button == 1 ) { //"Use" button
SetCursorMode ( 3 ) ;
SetMouseCursor ( 2 ) ;
} else
if ( button == 4 ) { //"Up" arrow
if ( game.top_inv_item > 0 )
game.top_inv_item = game.top_inv_item - game.items_per_line;
} else
if ( button == 5 ) { //"Down" arrow
if ( game.top_inv_item < game.num_inv_items - game.num_inv_displayed )
game.top_inv_item = game.top_inv_item + game.items_per_line;
}
} // end if interface 2
I havn't fixed the up and down buttons yet, wich should be left and right buttons. I need to get the inventory to work first, so i can be sure it works.
You can download my GUI here:
http://hbw.stickthemepark.com/ImagesHost/BG/sillygui.gui
Hmm...... checked the "Handle inventory clicks in script" in the general settings? If you have, post your on_mouse_click function here, if you haven't, post that function here anyway and try if checking it does anything...
erm... where's my on_mouse_click function? :-X
In the global script...
Technical Archive:
Custom Inventory GUI Thread (http://www.agsforums.com/yabb/index.php?board=10;action=display;threadid=10946;start=new;boardseen=1)
You might find what you need in there!
~ d
Quote from: Darth Mandarb on Thu 05/02/2004 18:22:56
Technical Archive:
Custom Inventory GUI Thread (http://www.agsforums.com/yabb/index.php?board=10;action=display;threadid=10946;start=new;boardseen=1)
You might find what you need in there!
~ d
Where do you think i got the toturial from? ;)
Quote from: TK on Thu 05/02/2004 17:57:52
In the global script...
Oh, right. You have to exuse me, it's been years and days since I've been using AGS. Hardly remember anything.
Here ye go:
function on_mouse_click(int 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==LEFT) {
ProcessClick(mouse.x, mouse.y, GetCursorMode() );
}
else { // right-click, so cycle cursor
SetNextCursorMode();
}
}
Atleast i think that's right, only on_mouse_click i found.
HHHMMMMMmmm...... I really can't say what's wrong then...
QuoteStill, when i try to pick up an object, it won't go to the inventory box.
???:o::):-[
Has it been a shortcut in my head, or do you mean, that when you AddInventory(1);, inventory item 1 doesn't appear in the inventory window you have created?
yes! I've also tried to check "player starts with this inventory item at start". Don't work. There is probably some obvious error I havn't discovered...
If the inventory window is smaller than the inventory items, they won't be displayed.
Try either resizing the inventory or fiddle around with the SetInvDimensions function.
You mean like this?
function game_start ( ) {
// called when the game starts, before the first room is loaded
SetInvDimensions ( 40,40 ) ;
}
Hell, it worked. Toh, the "use" button still don't work.
if ( button == 1 ) { //"Use" button
SetCursorMode ( 3 ) ;
SetMouseCursor ( 2 ) ;
} else
I've also tried using
if ( button == 1 ) { //"Use" button
SetCursorMode ( 2 ) ;
SetMouseCursor ( 2 ) ;
} else
Quote from: HillBilly on Fri 06/02/2004 06:48:34
Hell, it worked. Toh, the "use" button still don't work.
That's probably because the Use action defaults to selecting inventory items. Try not setting the Use button to be the actual Use interaction, but rather some other inventory-specific cursor mode, and setting use interactions to be triggered by that.
Either that, or I'm stupid.
Well, I did that. The script i used changed the cursor to use, but used the programming to "talk".
To quote the toturial:
Quote
Why have we chosen the "Talk" mode for the "use" action? Simply because the "interract" mode is used to select an inventory object.
Of course, if we want to create an interraction for an object, we must choose Talk to inventory item instead of interact inventory item in the Interaction Editor window.
Right, I've fixed the most important stuff, but there is still some errors:
The buttons(look at, interact, pick up etc): works fine
Up and down buttons: When i click down, the GUI turns black.
Inventory: Only displays one row at top, should be 2 rows.
GUI download:
http://hbw.stickthemepark.com/ImagesHost/BG/inventorygui.gui
According to the GUI I downloaded, your GUI buttons numbers doesn't match your GUI script :
Button 3 is the down arrow :
if (button == 3) {
// They pressed the OK button, close the GUI
GUIOff (INVENTORY);
SetDefaultCursor();
}
Button 4 is the UP arrow :
if ((button == 4) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed)) {
// scroll down
game.top_inv_item = game.top_inv_item + game.items_per_line;
}
Button 5 is the Talk button :
if ((button ==5) && (game.top_inv_item > 0)){
// scroll up
game.top_inv_item = game.top_inv_item - game.items_per_line;
}
Thanks. Still, there is a small bug with the inventory: When i insert this script:
function game_start ( ) {
// called when the game starts, before the first room is loaded
SetInvDimensions ( 20,20 ) ;
}
In the global script, it shows 2 rows, but the inventory items don't get smaller. Instead they get closer together. Is there any way to fix this, or do i need to redraw the inventory items smaller?
SetInvDimensions only change the size of each area that will contain the inventory object. Unfortunately, you will have to redraw your objects... or make your inventory square larger.
Okay, thanks.