ID:180168
 
If anyone can tell me a better way to find answers for questions like these I'd be glad to use it, but in the mean time here we go again:

What I want to do is make a verb that has the option to select either an object in your contents or an item from a list. So, as an example, suppose a wizard character has a list of built in spells, and also has spells in the form of items in his inventory.

Now, this wizard needs a "cast" verb that allows him to use "cast [obj in contents]" or "cast [item in list]"

Something like...

verb/cast(obj/O as obj in usr.contents || O in list ("thingy1","thingy2","thingy3","thingy4"))

Sept I have no idea to do this correctly.
Any help is appreciated.
Foomer wrote:
If anyone can tell me a better way to find answers for questions like these I'd be glad to use it, but in the mean time here we go again:

What I want to do is make a verb that has the option to select either an object in your contents or an item from a list. So, as an example, suppose a wizard character has a list of built in spells, and also has spells in the form of items in his inventory.

Now, this wizard needs a "cast" verb that allows him to use "cast [obj in contents]" or "cast [item in list]"

Something like...

verb/cast(obj/O as obj in usr.contents || O in list ("thingy1","thingy2","thingy3","thingy4"))

Sept I have no idea to do this correctly.
Any help is appreciated.

Ummm, I dont know much about lists, but you could have your verb simply call for a choice between obj list and spell list. once you have the list name, then you could select from the list itself. I assume that most people would not want to accidently select a one shot item because it was mixed in with a bunch of spells.

so the steps are:
1. select: Spell | Item
2. store the choice. (tmp/choice)
3. generate list based on choice
4. select: x from list(choice)
5. activate spell effect.

so basically its just like selecting from a regular list, but first the player has to pick a list to choose from.

Hope that this helps.
Foomer wrote:
What I want to do is make a verb that has the option to select either an object in your contents or an item from a list. So, as an example, suppose a wizard character has a list of built in spells, and also has spells in the form of items in his inventory.

You can create a function that returns a list and specify that function in the verb declaration.

That function can put together any set of items you want.
In response to Deadron (#2)
Deadron wrote:
Foomer wrote:
What I want to do is make a verb that has the option to select either an object in your contents or an item from a list. So, as an example, suppose a wizard character has a list of built in spells, and also has spells in the form of items in his inventory.

You can create a function that returns a list and specify that function in the verb declaration.

That function can put together any set of items you want.

Mmm...I still haven't a clue how to write it out or where exactly to find out how.
In response to Foomer (#3)
Foomer wrote:
Mmm...I still haven't a clue how to write it out or where exactly to find out how.

mob/proc/SpellList()
// Return list of all spells that apply

mob/verb/choose_spell(obj/spell/S in SpellList())
// Do stuff with S.

Or however you have spells defined.