Inventory. There today, gone tomorrow.

Started by Barrett, Sun 13/09/2009 19:30:02

Previous topic - Next topic

Barrett

I know I've been posting a good bit, but I jumped into a blank template, and got too far in to go back and play with the demo. (Though I do keep it open in another window for ref.)

- I pickup my "grass." I open up my inventory. Hey look! Grass! I close my inventory. I open it again...no grass. Who took my grass?


Tijne

Check:
Closing Inventory Script
Repeatedly Executing Scripts
Open Inventory Script.


There could be a number of different possible things wrong.  I can't really think of any more advice to give other than just check all your scripts.  =/.

Check --everything-- that could happen?   Though it sounds like you did it already. =/. 

Barrett

I'll post my code. Maybe someone has had this trouble. I'm trying to wade through all the inventory problems, so I've made two rooms, each with one item that can be added to inventory. Torg can get grass from his bed, and go to room two and get a stick.

GLOBAL:

// main global script file

// called when the game starts, before the first room is loaded
function game_start() {}


// put anything you want to happen every game cycle in here
function repeatedly_execute()
{
}

function show_inventory_window ()
{
  gtorginvwindow.Visible = true;
  // switch to the Use cursor (to select items with)
  mouse.Mode = eModeInteract;
  // But, override the appearance to look like the arrow
  mouse.UseModeGraphic(eModePointer);
}

function hide_inventory_window() {
  gtorginvwindow.Visible = false;
  invwindowtorg.Visible = false;
}


//If the toolbar is visible, change the mouse to a pointer


// called when a key is pressed. keycode holds the key's ASCII code
function on_key_press(eKeyCode keycode)
{
  if (IsGamePaused()) keycode = 0; // game paused, so don't react to keypresses
 
  if (keycode == eKeyCtrlQ) QuitGame(1); // Ctrl-Q
  if (keycode == eKeyF9) RestartGame(); // F9
  if (keycode == eKeyF12) SaveScreenShot("scrnshot.pcx");  // F12
  if (keycode == eKeyCtrlS) Debug(0,0); // Ctrl-S, give all inventory
  if (keycode == eKeyCtrlV) Debug(1,0); // Ctrl-V, version
  if (keycode == eKeyCtrlA) Debug(2,0); // Ctrl-A, show walkable areas
  if (keycode == eKeyCtrlX) Debug(3,0); // Ctrl-X, teleport to room
}
#sectionend on_key_press  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
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 // right-click, so cycle cursor
  {   
    mouse.SelectNextMode();
  }
}
#sectionend on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart interface_click  // DO NOT EDIT OR REMOVE THIS LINE
function interface_click(int interface, int button)
{
  // OBSOLETE, NOT USED IN AGS 2.7 AND LATER VERSIONS
}
#sectionend interface_click  // DO NOT EDIT OR REMOVE THIS LINE


function dialog_request(int param) {
}
function istick_Look()
{
   Display("It's a handy dandy stick. You found it in your cave.");
}

function istick_Talk()
{
   Display("Alas, it isn't the talking version.");
}

function invbtn_OnClick(GUIControl *control, MouseButton button) {
  UpdateInventory()  ;
  show_inventory_window();
}

function Button1_OnClick(GUIControl *control, MouseButton button) {
 
  hide_inventory_window();
}


function istick_Interact()
{
   Display("Feels like wood. Tastes like wood. I'd venture to guess we have ourselves a piece of wood!");
}

ROOM 1:

// room script file

function hwaterfall_Look()
{
   Display("The water running into your cave is cool, and refreshing.");
}

function hbed_Look()
{
   Display("It's your grass bed, with the softest rock pillow available at Rocks-R-Us.");
}

function hcavewall_Look()
{
   Display("The cave is where the heart is!");
}

function hHotspot4_Look()
{
   Display("Hey look! It's the ground!");
}

function room_LeaveBottom()
{
   player.ChangeRoom(2, 35, 35);
}


function room_LeaveRight()
{
   player.ChangeRoom(3, 35, 35);
}

function hbed_Interact()
{
   player.Walk(160, 342, eBlock);
   {if (havegrass>>0) Display("You have enough grass. There'll be nothing to sleep on if you keep it up!");
   }
   if (havegrass==0)
   {player.AddInventory(igrass);
   UpdateInventory();
   Display("You grab a bit of grass from your bed, and pocket it.");
   GiveScore(2);
   havegrass+=1; }
   
}

ROOM 2:

// room script file

function room_LeaveBottom()
{
   player.ChangeRoom(2, 90, 35);
}



function hcavewallsouth_Look()
{
   Display("If these walls could talk...there still wouldn't be much to say.");
}

function ostick_Interact()
{
   player.Walk(485, 247, eBlock);
   ostick.Visible = false;
   player.AddInventory(istick);
   GiveScore(1);
   Display("Ah! A stick! Oh, and a point! That's the easiest one you'll get, so relish it.");
}

function ostick_Look()
{
   Display("Looks like a stick to me, and a darn good one.");
}




function room_LeaveTop()
{
   player.ChangeRoom(1,  399, 470);
}

Barrett

#3
I'd also note that I can :

A) Pick up grass, open inv, see grass, close inv, open inv, no grass...

B) Pick up grass, go to room 2, pick up stick, open inv, see stick and grass, close inv, open inv, no grass or stick

C) Go directly to room 2, pick up inv, see stick, close inv, open inv, no stick...

D) If I get the grass, open my inv, close my inv, go to room 2, and get the stick...when I open my inv, not only will the grass not be there, but the stick will not either.

Barrett

Fixed it.

Deleted the line,

invwindowtorg.Visible = false;

I'll have a drink now.

SMF spam blocked by CleanTalk