ID:148090
 
i have a list in my battle system that directs the users attack and its formatted like this:
mob/proc/fight()
switch(input("Attack who?",text) in list ("Enemy","Enemy2"))

if("Enemy")
//coding for attacking the first enemy

well i want to take out the "Enemy" and "Enemy2" with variables that the usr has like E and E2 which are assigned to be the name of the Enemy when battle start. i tried doing it like this:
mob/proc/fight()
switch(input("Attack who?",text) in list ("[E]","[E2]"))

if("[E]")

but it said expected a constant expression.
Is there a way to do this??
Well, it's been a while since I've coded here on BYOND, and believe me, when I say while, I mean while. But what I think is that you need both if's. And if you already put this, try this:

Declare a var and call it who or something like that. Next, instead of if, use who = if and the rest of your code. Something like this:

[DM]
mob/proc/fight()
switch(input("Attack who?",text) in list ("[E]","[E2]"))
var/who
who = if("[E]")
coding here
else
coding here
[/DM]

If that doesn't work, try:


[DM]
mob/proc/fight()
switch(input("Attack who?",text) in list ("[E]","[E2]"))
var/who = if("[E]")
coding here
else
coding here
[/DM]

If those don't work, then I can't help you because remember, it's been a while so I don't remember clearly. Heck, I don't even have BYOND installed on my computer since after my reformat.
In response to DiZzyBonne
that didnt work but thank you for trying.
In response to DiZzyBonne
Yikes, that's so totally wrong it makes my brain hurt... back to the Tutorials section for you, friend... =P

Siefer, looking at that battle system, you're far better off using a list than bothering with separate variables for each enemy. It'd be shorter (code-wise), and could expand or contract to fit however many enemies you want with minimal effort.
In response to Crispy
a list? i dont know the first thing about lists. i'll give it a shot though..
In response to Siefer
This post might help: [link]
In response to DiZzyBonne
This isn't a UBB forum; use angle brackets around the DM tag, not regular brackets.

Lummox JR