Blockland Forums > Modification Help

Using a switch to create a selectable list

Pages: (1/2) > >>

Obibital:

No code at the moment, im just trying to figure how this would work, plus the fact that it takes some while to get a response.

Im making something like a pestle & mortar

you type /p&m help   and you get a list similar to
1. Health Potion - (names of ingredients)
2. Poison - (ingredients)
3. Ect.....


Then after choosing one with /create 1    or /create 2  it would call a switch that would figure out what ingredients to look for, then create it if you have what you need.



Is there an easier way to do this?
or do i have the right idea?

(p.s. Im a Massive Newbie)


-----------------------------------

This is what i have at the moment :p


--- Code: ---//p&m.cs

function servercmdpotion(%client,%choice)
{
echo("p&m");
  switch(%choice)
    {
      case 1:
        //potion 1 stuff
        echo("Potion1");
        if(%client.redberry > 0 && %client.blueberry > 0)
          {
          echo("blu and red");
          }
         else
          {
          echo("Else");
          }
       case 2:
        //potion 2 stuff
        echo("Potion2");
       default:
         messageClient(%client,'','1. Health Potion - Red Berry(1), Glow Berry (1)');
    }
 
}

function servercmdpick(%client)
{
%client.redberry = 100;
%client.blueberry = 100;
}



--- End code ---

That all worked

Ill tell all you people how it goes

Headcrab Zombie:

You don't do callFunction(potioncheck);
Just potioncheck();


If I were doing this, I would use a single command for making and help, as it would be less commands to remember

--- Code: ---function serverCmdPotion(%client,%choice)
{
    switch(%choice)
    {
        case 1:
            //potion 1 stuff here
        case 2:
            //potion 2 stuff here
        //add more cases for more potions
        default:
            //help messages here
    }
}
--- End code ---


Obibital:

So what your saying is, that the /potion command will be used aswell instead of making a /make#


By Potion Stuff do you mean the Checks for the ingrediants or....errrr

What would i be using to set the value of the %choice?

SpreadsPlague:


--- Quote from: Obibital on July 26, 2010, 11:48:17 AM ---So what your saying is, that the /potion command will be used aswell instead of making a /make#


By Potion Stuff do you mean the Checks for the ingrediants or....errrr

What would i be using to set the value of the %choice?

--- End quote ---

%choice is whatever has been said after /potion

/potion mayonnaise

mayonnaise would then be %choice

Obibital:


--- Quote from: SpreadsPlague on July 26, 2010, 11:52:30 AM ---%choice is whatever has been said after /potion

/potion mayonnaise

mayonnaise would then be %choice

--- End quote ---

Wow, this just became a whole lot easier

o3o derp


Edit:

Ok then, ive got the switch working fine, and now all i have to set up is the checks for the ingredients.
im planning on using if(%client.ingredient1 > 0 Ect......

Is that a bad idea?

Pages: (1/2) > >>

Go to full version