mob//Teacher
verb
Modify_House_Points(mob/M in world)
var/points = input("Input the number of points you'd like to add. Put a - infront of the number to take away points.","House Points")
if(M.house=="Ravenclaw")
var/p = text2num(points)
rpoints += p
if(findtext(points,"-"))
points -= "-"
world<<"[M] has caused Ravenclaw to lose [points] points!"
Problem description: I've never done something like this before, but I'm currently trying to remove "-" from a text string. The problem here is that points -= "-" causes a type mismatch and stops the message from being given.
The point of this verb is to make it that to change "House Points" the usr only needs the one verb, where they simply make the number negative to remove some of the points. Unfortunately, when displaying said number, I don't want the players to be wondering about the - that will randomly have appeared there (at least to them, since most games of this type simply feature a remove and add).
If you had looked up the -= / - operator, you'd have seen that there's no use of it that involves strings. You just guessed there was.
To remove something from a text string, you need to do it 'manually' with findtext() and copytext(), generally like this:
You could probably find something similar in various libraries. Of course, in this case, since all you want to remove is the first character of the string (note you haven't actually ever validated "-" was in the beginning, but you should have), it's enough to do something like this:
The result is the text string "10", which is output to the world.
However-
-to do this, you don't need to worry about string removals at all, because you don't have to ever use strings here in the first place, and it's better not to. Just stick to using numbers throughout all the code there: the as num input type does allow players to input in not only number digits, but also the "-" and "." characters, to allow them to also input negative or fractional numbers (and you very often need to watch out for that!). Then you can just use the simple math operators and the abs() proc to do anything that is needed - I leave it to you to figure it out.
Also, I'll note that the design of...
...is weak (and, of course, repetitive). I'd try to come up with a better design (and I don't mean changing to using switch() there, though that would still be a minor improvement), if I were you.
EDIT: typofix