Creating an Inventory

You must understand the Game Editor concepts, before post here.

Re: Creating an Inventory

Postby skydereign » Sat Apr 04, 2009 7:22 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Creating an Inventory

Postby TheIllusionist » Sun Apr 05, 2009 7:15 am

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?
"Have we not each experienced the beautiful sensation of a moment pass to quickly, and wished that we could make it linger?"
User avatar
TheIllusionist
 
Posts: 19
Joined: Fri Apr 03, 2009 1:49 am
Location: Vienna, Australia
Score: 0 Give a positive score

Re: Creating an Inventory

Postby skydereign » Sun Apr 05, 2009 7:33 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Creating an Inventory

Postby TheIllusionist » Tue Apr 07, 2009 10:26 pm

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:
"Have we not each experienced the beautiful sensation of a moment pass to quickly, and wished that we could make it linger?"
User avatar
TheIllusionist
 
Posts: 19
Joined: Fri Apr 03, 2009 1:49 am
Location: Vienna, Australia
Score: 0 Give a positive score

Re: Creating an Inventory

Postby TheIllusionist » Tue Apr 07, 2009 11:32 pm

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)
"Have we not each experienced the beautiful sensation of a moment pass to quickly, and wished that we could make it linger?"
User avatar
TheIllusionist
 
Posts: 19
Joined: Fri Apr 03, 2009 1:49 am
Location: Vienna, Australia
Score: 0 Give a positive score

Re: Creating an Inventory

Postby skydereign » Wed Apr 08, 2009 12:26 am

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).
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Creating an Inventory

Postby jimmynewguy » Wed Apr 08, 2009 12:27 am

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
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Creating an Inventory

Postby TheIllusionist » Wed Apr 08, 2009 3:36 am

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?
"Have we not each experienced the beautiful sensation of a moment pass to quickly, and wished that we could make it linger?"
User avatar
TheIllusionist
 
Posts: 19
Joined: Fri Apr 03, 2009 1:49 am
Location: Vienna, Australia
Score: 0 Give a positive score

Re: Creating an Inventory

Postby skydereign » Wed Apr 08, 2009 1:32 pm

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;
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Creating an Inventory

Postby TheIllusionist » Wed Apr 08, 2009 9:45 pm

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:
"Have we not each experienced the beautiful sensation of a moment pass to quickly, and wished that we could make it linger?"
User avatar
TheIllusionist
 
Posts: 19
Joined: Fri Apr 03, 2009 1:49 am
Location: Vienna, Australia
Score: 0 Give a positive score

Re: Creating an Inventory

Postby TheIllusionist » Sat Apr 11, 2009 2:38 am

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?
"Have we not each experienced the beautiful sensation of a moment pass to quickly, and wished that we could make it linger?"
User avatar
TheIllusionist
 
Posts: 19
Joined: Fri Apr 03, 2009 1:49 am
Location: Vienna, Australia
Score: 0 Give a positive score

Re: Creating an Inventory

Postby skydereign » Sat Apr 11, 2009 3:12 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Creating an Inventory

Postby TheIllusionist » Sat Apr 11, 2009 3:35 am

help would be very nice :mrgreen:
"Have we not each experienced the beautiful sensation of a moment pass to quickly, and wished that we could make it linger?"
User avatar
TheIllusionist
 
Posts: 19
Joined: Fri Apr 03, 2009 1:49 am
Location: Vienna, Australia
Score: 0 Give a positive score

Re: Creating an Inventory

Postby skydereign » Sat Apr 11, 2009 3:49 am

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
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Creating an Inventory

Postby TheIllusionist » Sat Apr 11, 2009 4:01 am

Ya, your right, it doesn't fit with mine. Thanx (in advance) for the demo :mrgreen:
"Have we not each experienced the beautiful sensation of a moment pass to quickly, and wished that we could make it linger?"
User avatar
TheIllusionist
 
Posts: 19
Joined: Fri Apr 03, 2009 1:49 am
Location: Vienna, Australia
Score: 0 Give a positive score

PreviousNext

Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron