ID:178395
 
Hi. Haven't found any examples to guide me here, and my brain's hurting.

Say usr has three objects currently in contents, each with a combat_value variable.

pistol
combat_value = 10
sword
combat_value = 5
cheese
combat_value = 0


Now, I want to prompt usr with a switch-input dialog, "Choose your weapon." I want the choices to be the set of objects currently in contents with a combat_value > 0.

I've been doing things like this to determine which contents are combat-worthy:

var/list/weapons = list()
for(var/obj/O in usr.contents)
if(0:combat_value > 0)
weapons += O

So far, so good, I've got the list "weapons." But I can't get the switch-input code to use that list as its choice list.

Any ideas? Or examples from existing code?

Much obliged!

H

Humbabba wrote:
So far, so good, I've got the list "weapons." But I can't get the switch-input code to use that list as its choice list.

Any ideas? Or examples from existing code?

Much obliged!

H

Well, you are most of the way there. The key is to use the 'in list' arguement for the input proc. Study this:

var/obj/o = input("Choose the weapon:") in weapons
var/combat_value = o.combat_value
In response to Ebonshadow
Cool, that put me on track. Thanks!
In response to Humbabba
Hey, just wondering, how did you find this place? Says your key was made 3 days ago...


*hopes it was from his advertising*