ID:158128
 
I have some code layed out, yet it does nothing when a race is selected.
mob/verb/create_character()
usr.name = input("Choose a name for your character.",
"Your Name",
usr.name)

usr.group = input("Choose your character's race.",
"Your Race",
usr.group) in list("Warrior","Guardian","Barbarian","Naturalist","Wind Wizard","Water Wizard","Fire Wizard","Earth Wizard","Dark Wizard","Holy Wizard","Witch","Archer","Dwarf","Blacksmith")
if("Warrior")
usr.icon = 'mob.dmi'
usr << "You have chosen the race of the warriors!"
sleep(5)
usr << "You have the ability of leveling up faster in attack!"
if("Guardian")
usr.icon = 'mob.dmi'
usr << "You have chosen the way of the guardians!"
sleep(5)
usr << "You have the ability of leveling up faster in defense!"
if("Barbarian")
usr.icon = 'mob.dmi'
usr << "You have selected the life of a barbarian!"
sleep(5)
usr << "You have the ability of leveling up faster in strength!"
if("Naturalist")
usr.icon = 'mob.dmi'
usr << "You have chosen to be a naturalist!"
sleep(5)
usr << "You have the ability of leveling up faster in naturalism!"
if("Wind Wizard")
usr.icon = 'mob.dmi'
usr << "You are now a wizard of wind!"
sleep(5)
usr << "You have the ability of leveling up faster in wind magic."
if("Water Wizard")
usr.icon = 'mob.dmi'
usr << "You are now a wizard of water!"
sleep(5)
usr << "You have the ability of leveling up faster in water magic."
if("Fire Wizard")
usr.icon = 'mob.dmi'
usr << "You are now a wizard of fire!"
sleep(5)
usr << "You have the ability of leveling up faster in fire magic."
if("Dark Wizard")
usr.icon = 'mob.dmi'
usr << "You are now a dark wizard!"
sleep(5)
usr << "You have the ability of leveling up faster in dark magic."
if("Holy Wizard")
usr.icon = 'mob.dmi'
usr << "You are now a holy wizard!"
sleep(5)
usr << "You have the ability of leveling up faster in holy magic."
if("Witch")
usr.icon = 'mob.dmi'
usr << "You now follow the ways of the witches!"
sleep(5)
usr << "You have the ability of leveling up faster in witchery."
if("Archer")
usr.icon = 'mob.dmi'
usr << "You have chosen the life of an archer!"
sleep(5)
usr << "You have the ability of leveling up faster in archery."
if("Dwarf")
usr.icon = 'mob.dmi'
usr << "You have foreseen the ways of the dwarfs!"
sleep(5)
usr << "You have the ability of leveling up faster in mining."
if("Blacksmith")
usr.icon = 'mob.dmi'
usr << "You are a blacksmith!"
sleep(5)
usr << "You have the ability of leveling up faster in smithing."

How would I make it to where if you choose for example "Dwarf" word's come to the user and the user's icon is 'dwarf.dmi'.

Also the special ablilities for the certain race you choose. I have an equation to do so.
mob
Stat()
stat("Mining Level:",mininglvl)
stat("Mining Experience:",miningexp)
stat("Mining Experience Needed:",miningexpn)
proc/mininglevelcheck()
if(usr.miningexp >= usr.miningexpn)
usr.mininglvl += 1
usr.miningexp = usr.miningexp - usr.miningexpn
usr.miningexpn = usr.miningexpn * 2
usr << "Congratulations! You just advanced an mining level!"
if(usr.group == "Dwarf")
usr.miningexpn = usr.miningexp * 15 / 10
if(usr.mininglvl == 100)
usr << "You have mastered mining!"

But I don't know what to put within if() to make it to where dwarfs mining level exp needed (mingexpn) multiply by 15/10 (1.5) instead of 2 when they level up mining.

Long story short, I want to know how I would make it to where if I choose "Dwarf" from a list in mob/verb/create_character() I would see some messages, have 'dwarf.dmi' as my icon, and get faster leveling up in mining.
For the first question, you need to read how to create if() statements. That would be in the Guide.

For the second question, you need to learn how to replace a single damn number. That would be in the Guide.
In response to Garthor (#1)
Umm...

I know how to use if, this case is unusual to me.

Also, I know how to replace a number, but, like I said before, this case is unusual to me.

Hint: Stop throwing curse words around unless your looking for somebody to ban you.
In response to Kokomo0020 (#2)
The mods generally only get annoyed at curse words that are offensive, or the "forbidden" ones.
In response to Vic Rattlehead (#3)
Oh, okay my bad.
I still need some help with my questions though.
As Garthor said, you're not using if correctly. The way you're using them requires a switch statement to be used before them.

I recommend that you reread those portions of the guide about if, else-if, else and switch statements.
In response to Garthor (#1)
I also tried this, but it doesn't work either.
mob/verb/choose_your_race()
usr.group = input("Choose Your Race.",
"Your Race",
usr.group) in list("Warrior")
if(usr.group == "Warrior")
usr << "You are a warrior!"
sleep(5)
usr << "You level up faster in attack."

Since it was inputing usr.group I tried (usr.group == "") but that also didn't do anything.
In response to Kokomo0020 (#6)
What you wrote should be correct. Note that you don't necessarily have to assign to group immediately upon selecting it, you can just use a local variable:

mob/verb/choose_race()
var/selection = input(MESSAGE, TITLE, DEFAULT) in OPTIONS
if(selection == "Warrior")
usr.group = "Warrior"


Also: if you only have one option, the input() won't show up, and it will just automatically choose the only option.
In response to Kokomo0020 (#6)
Your problem is that you're using the group variable, which is a built-in variable and its value is a list, and you cannot change said value (like your attempt to set it to a text string), doing so for group in particular should give you a runtime error saying so.
You should use your own variable for your own stuff, instead of misusing a built-in variable. For something like a race or class though, you're often better off using subtypes to represent different races rather than having a variable flagging it with a string -- or at least having a variable referring to another object representing the race.
mob/combatant
var/HP,strength,defense,magic
player
warrior
HP = 15
strength = 15
defense = 7
magic = -10
monk
HP = 10
strength = 8
defense = 10
magic = 3
troll
HP = 25
strength = 8
defense = 10
magic = -10
mage
HP = 10
strength = 5
defense = 5
magic = 15

Having such a setup allows you to use object-oriented approaches when designing and implementing the various classes, such as override procs to perform different behavior for a certain subtype. For example, assuming you have a procedure called TakeDamage() defined on /mob/combatant that is used whenever they take damage, you could implement melee-attack-dodging for monks and magic-resistance for trolls like so:
mob/combatant/proc/TakeDamage(amount,atk_type,mob/combatant/attacker)
mob/combatant/player
monk/TakeDamage(amnt,type,atker)
if(type == MELEE_ATTACK && prob(20))
viewers(src) << "[src] dodges [atker]'s attack!"
return 0 //attack dodged, no damage
else return ..() //damage
troll/TakeDamage(amnt,type,atker)
if(type == MAGIC)
amnt = round(amnt / 2,1)
return ..(amnt,type,atker) //pass a lower damage value to the parent (note calling ..() like this isn't as robust and can be done better)
else return ..()

Some of this might be over your head at the moment, so just disregard it for now if so.
In response to Garthor (#7)
I figured it out.
Group was a bad definition for input so i created a var for the input
<DM>
mob/var/character_creation()
usr.race = input("Warrior")
if(usr.race == "Warrior")
usr.attackexpn = usr.attackexpn * 15 / 10
In response to Kokomo0020 (#9)
Kokomo0020 wrote:
Group was a bad definition for input

o, rly

> mob/var/character_creation()
> usr.race = input("Warrior")
> if(usr.race == "Warrior")
> usr.attackexpn = usr.attackexpn * 15 / 10
If you stick to using that bad method of implementing races, you'll want to at least use switch() instead of a chain of else-ifs (or worse, a series of if()s), and get used to using it.
Your initial code posted in the first post of this thread had a partial attempt of using switch() (which I'd have to assume you cut&pasted together without knowing what you're doing)... which of course doesn't work, since it misses actually invoking the switch() statement.
But you could also do it the shorter way:

mob/verb/create_character()
// [name input placeholder]
var
list/racelist = list(
"Warrior" = "attack",
"Guardian" = "defence",
"Barbarian" = "strength"
)
new_race = input("Choose your character's race.","Your Race") as null|anything in racelist
if(new_race)
icon = 'mob.dmi'
race = new_race
src << "You have chosen the race of the [new_race]!"
sleep(5)
src << "You have the ability of leveling up faster in [racelist[new_race]]!" // racelist[new_race] returns the value of the chosen race in the list "racelist"

In response to Kaioken (#10)
What?
In response to Kokomo0020 (#12)
Kokomo0020 wrote:
What?

How amazingly descriptive and meaningful of you to say that.

You may benefit from reading http://www.byond.com/docs/ref/info.html#/proc/switch