ID:143597
 
Code:
mob
var
slot1=""
slot2=""
verb
slot1()
set hidden = 1
if(slot1 == "")
src << "You have pushed slot 1"
switch(src.slot1)
if("Punch")
src.Punch()
if("Kick")
src.Kick()
if("Sweep")
src.Sweep()
if("Headbutt")
src.Headbutt()
if("Jab")
src.Jab()
if("Chop")
src.Chop()
mob
proc
Punch()
set hidden = 1
src << "You aimlessly punch the air"
Kick()
set hidden = 1
src << "You aimlessly kick the air."
Sweep()
set hidden = 1
src << "You aimlessly Sweep the air."
Headbutt()
set hidden = 1
src << "You aimlessly Headbutt the air."
Jab()
set hidden = 1
src << "You aimlessly Jab the air."
Chop()
set hidden = 1
src << "You aimlessly Chop the air."


Problem description:

Hey Guys! I was wondering if there is a better way of doing this? All of thouse If's dont seem to good? If there is a better way of doing this please let me know!



Carnia :)
    verb
slot1()
set hidden = 1
if(slot1 == "")
src << "You have pushed slot 1"
call("/mob/proc/[src.slot1]")()
In response to Abhishake
Abhishake wrote:
>     verb
> slot1()
> set hidden = 1
> if(slot1 == "")
> src << "You have pushed slot 1"
> call(text2path("/mob/proc/[src.slot1]"))()
>


I dunno if call automatically makes it text2path, but I'd put it in there anyways.
In response to Kaiochao2536
Kaiochao2536 wrote:
I dunno if call automatically makes it text2path, but I'd put it in there anyways.

You don't need to text2path() it.
I think a better way is to let each skill be an object, which you'd be dragging onto the bar, and then simply call the skill.use() or something.

obj
skill
punch
verb/use()
set hidden = 1
usr<<"You punch!"

Next, for each slot, you make the variable that keeps track of the slot an object variable.
mob
var
obj/slot1

Now, when you drag the skill object to your bar, set the mob's corresponding slot variable to the skill object.
usr.slot1 = (thedraggedobject)

Now, you can just call usr.slot1.use() to get the skill in slot1 to be used!

This simplifies things a lot and you won't have to be making a bunch of if statements for each slot.

-TKL
In response to Kangchao
Thanks hun but Im really not understanding the way your trying to explain to me.