Page 2 of 3

Re: Creating an Inventory

PostPosted: Sat Apr 04, 2009 7:22 pm
by skydereign
Upon the actual pickup event, mousebutton down on item, set ActionNum to -1. If you want it to default to one of the other actions set it to that. -1 is so that nothing can be done until selected.

Re: Creating an Inventory

PostPosted: Sun Apr 05, 2009 7:15 am
by TheIllusionist
Well I did all that but every time I try to start the game it says:
s1-8 -> Draw Actor, line 1: READ attempted before allowed access area
What does this mean?

Re: Creating an Inventory

PostPosted: Sun Apr 05, 2009 7:33 am
by skydereign
Can you post the game? I can't tell what is really happening without some more to work with. I believe it is talking about the itemtype. That would be the only thing that would have an error like that. Show me the script for that event, it could be that there is not enough space within the array or something else entirely.

Re: Creating an Inventory

PostPosted: Tue Apr 07, 2009 10:26 pm
by TheIllusionist
I'v been trying to upload it, but every time I do, it just doesn't work. But it doesn't matter. I did some fiddling around, and BOOM, it's working :mrgreen:

Re: Creating an Inventory

PostPosted: Tue Apr 07, 2009 11:32 pm
by TheIllusionist
I'v got another question. After I click an option, how do I make it so that after I click on it, it does what I want it to do.
Example: I click Look at. Then I click on a pack of gum in my inventory. And then my main character says something like: Ew... this gum must be 60 years old (or sum such)

Re: Creating an Inventory

PostPosted: Wed Apr 08, 2009 12:26 am
by skydereign
In the most recent demo, I believe upon the mouse down event, it has switch. The switch looks like this.
Code: Select all
switch(ActionNum)
{
    case 0: //Give
    // The code for Give
    break;
    case 1: //Pickup
    // Probably nothing, as this is clicking in the inventory, meaning you already picked it up
    break;
    case 2: //Use
    switch(itemtype[ofst(a,0])
    {
        case 0: //Item type 0
        // Your event for item type 0
        break;
        // make a case for each itemtype
    }
    break;
    // make a case for each ActionNum
}

Now when you click on the Look at, it sets it to a certain number. Create a case for that number, and add the code. If you are going to use a lot of text, I would create a text actor. For this it will be called "itemDescription".
So the individual case would look like this
Code: Select all
case 4: // I believe this was the look at number
strcpy(itemDescription.text, "Ew... this gum must be 60 years old");
break;

In a broader sense, this would go into the gum case, whichever number that may be (goes into the case x: where x signifies gum).

Re: Creating an Inventory

PostPosted: Wed Apr 08, 2009 12:27 am
by jimmynewguy
make a vaible called "use" and when you click look use = 1;
then when you click gum make a text actor say what you want

Re: Creating an Inventory

PostPosted: Wed Apr 08, 2009 3:36 am
by TheIllusionist
but wouldn't this only work for things outside the inventory, because just the animation for slot 1 or whichever changes? How would I do it for inside the inventory?

Re: Creating an Inventory

PostPosted: Wed Apr 08, 2009 1:32 pm
by skydereign
No, in the mouse button down event, there is a switch that determines what item is in it. There is a variable that is stored into the item array... Don't remember what it is called, but that way you can choose what happens for each.
Code: Select all
switch(itemType) // determines the type of item
{
    case 0:
      switch(ActionNum) // determines what to do with it
      {
          case 0:
          break;
          case 1:
          break;
      }
    break;
    case 1:
      switch(ActionNum)
      {
          case 0:
          break;
          case 1:
          break;
      }
    break;
}

Re: Creating an Inventory

PostPosted: Wed Apr 08, 2009 9:45 pm
by TheIllusionist
I'm not seeing any script that looks like that.
You know, it probably tae a lot less explaining if you would make me a demo :mrgreen:

Re: Creating an Inventory

PostPosted: Sat Apr 11, 2009 2:38 am
by TheIllusionist
In the demo the script looks like this:
Code: Select all
switch(ActionNum)
{
    case 1:
   for (a=0; a<3; a++)  // Change the max depending on max amount of items in Global Script
   {
     if (itemtype[ofst(a,0)]==0)
     {
       itemtype[ofst(a,0)]=1;
       DestroyActor("Event Actor");
       break;
     }
     else if (itemtype[ofst(a,1)]==0)
     {
       itemtype[ofst(a,1)]=1;
       DestroyActor("Event Actor");
       break;
     }
     else if (itemtype[ofst(a,2)]==0)
     {
       itemtype[ofst(a,2)]=1;
       DestroyActor("Event Actor");
       break;
     }
     else if (itemtype[ofst(a,3)]==0)
     {
       itemtype[ofst(a,3)]=1;
       DestroyActor("Event Actor");
       break;
     }
     else if (itemtype[ofst(a,4)]==0)
     {
       itemtype[ofst(a,4)]=1;
       DestroyActor("Event Actor");
       break;
     }
     else if (itemtype[ofst(a,5)]==0)
     {
       itemtype[ofst(a,5)]=1;
       DestroyActor("Event Actor");
       break;
     }
     else if (itemtype[ofst(a,6)]==0)
     {
       itemtype[ofst(a,6)]=1;
       DestroyActor("Event Actor");
       break;
     }
     else if (itemtype[ofst(a,7)]==0)
     {
       itemtype[ofst(a,7)]=1;
       DestroyActor("Event Actor");
       break;
     }
     else
     {
         CreateTimer("Event Actor", "a+", 20);
         recycle=1;
     }
     }
     break;
}



where would I put your new code?

Re: Creating an Inventory

PostPosted: Sat Apr 11, 2009 3:12 am
by skydereign
Code: Select all
switch(itemtype[ofst(a,0)) // determines the type of item
{
    case 0: // empty item
    break;
    case 1: // item 1
      switch(ActionNum) // determines what to do with it
      {
          case 0:
          // action 0 on item 1
          break;
          case 1:
          // action 1 on item 1
          break;
      }
    break;
    case 2: // item 2
      switch(ActionNum)
      {
          case 0:
          break;
          case 1:
          break;
      }
    break;
    // and so on
}


Sorry I didn't respond. I was working on a fixed version, but the method I am using is slightly different. That is why I thought that code was in the demo. Anyway, replace that code with this, though you need to fill in the blanks. If you need help with that I can explain.

Re: Creating an Inventory

PostPosted: Sat Apr 11, 2009 3:35 am
by TheIllusionist
help would be very nice :mrgreen:

Re: Creating an Inventory

PostPosted: Sat Apr 11, 2009 3:49 am
by skydereign
This goes upon the keydown events of the storage actors, S1-8 I think. I can institute this code into a demo if you wish, or I can finish the better inventory and post that.
-Edit
Actually, this is probably wrong with the version you have. I will make a demo of it.

Code: Select all
switch(itemtype[ofst(a,cloneindex)]) // determines the type of item
{
    case 0: // empty item
    // there is no item here as this signifies no item
    break;

    case 1: // item 1, apple
      switch(ActionNum) // determines what action
      {
          case 0:  // Give item
          // I don't know what you will do with this, but I'll assume that you create the item actor and give it to the other actor
          CreateActor("apple", "apple", "(none)", "(none)", 0, 0, false);
          itemtype[ofst(a,cloneindex)]=0; // gets rid of item
          break;
          case 1: // pickup item
          // this should be left blank, you can't pickup an item that is in your inventory
          break;

          case 2: // use
          HP+=5; // apple's use is to increase hp
          itemtype[ofst(a,cloneindex)]=0; // gets rid of item
          break;
          // include a case for each of your actions
      }
    break;

    case 2: // item 2, sword
      switch(ActionNum) // determines what action
      {
          case 0:  // Give item
          CreateActor("sword", "sword", "(none)", "(none)", 0, 0, false);
          itemtype[ofst(a,cloneindex)]=0; // gets rid of item
          break;

          case 1: // pickup item
          // this should be left blank, you can't pickup an item that is in your inventory
          break;

          case 2: // use
          ChangeAnimation("player", "attack", FORWARD); // using sword will cause attack
          break;
          // include a case for each of your actions
      }
    break;
    // and so on
}

Re: Creating an Inventory

PostPosted: Sat Apr 11, 2009 4:01 am
by TheIllusionist
Ya, your right, it doesn't fit with mine. Thanx (in advance) for the demo :mrgreen: