ID:2026352
 


Problem description:
Hello Byond back again, this time with a run-time error I can make no sense of.
runtime error: undefined variable /client/var/Slash_Delay
proc name: Speed Slash (/speed/verb/Speed_Slash)
source file: Verbs.dm,22
usr: the asca (/mob/characters/Human)
src: Dragonpearl123 (/client)
usr.loc: the grass (44,39,1) (/turf/grass)
call stack:
Dragonpearl123 (/client): Speed Slash()

Every verb I call under speed that happens, That was just an example but they say pretty much the same thing. Actually I will show you both of them for my own sake.

Code:

speed
verb
Speed_Slash()
if(Slash_Delay==1)
set category = "Techniques"
var/list/Players = new()
for(var/mob/M in view(5))
if(M.client)
Players+="[M]"
Players-="[usr]"
var/T = input("What player would you like to Slash to?","Teleport")in Players
for(var/mob/M in view(5))
if(T == M.name)
var/damage = usr.speed - M.defense
M.power -= damage
usr.loc = locate(M.x+rand(1,5),M.y+rand(1,5),M.z)
M<<{"<font size="-1" color="#F0AF23">[usr] slashed you with his speed for [damage] damage!."}
usr<<{"<font size="-1" color="#F0AF23">You slash [M] for [damage] damage!"}
M.deathcheck()
usr.Levelup()
spawn(3)
usr.icon_state=""
if(value != 1)
Slash_Delay=0
value = 1
spawn() Cooldown()
valueCD = world.timeofday + 100

speed
verb
Ultra_Buff()
set category = "Techniques"
set name = "Acceleration"
//src.overlays += /obj/aura
src<<"Your speed has been boosted for a shurt duration!"
src.speed += src.speed * 0.5
spawn(60*2.5)
src<<"Your speed has reverted to normal!"
src.speed -= src.speed * 0.5

Runtime Errors

runtime error: undefined variable /client/var/Slash_Delay
proc name: Speed Slash (/speed/verb/Speed_Slash)
source file: Verbs.dm,22
usr: the asca (/mob/characters/Human)
src: Dragonpearl123 (/client)
usr.loc: the grass (44,22,1) (/turf/grass)
call stack:



Dragonpearl123 (/client): Speed Slash()
runtime error: undefined variable /client/var/speed
proc name: Acceleration (/speed/verb/Ultra_Buff)
source file: Verbs.dm,54
usr: the asca (/mob/characters/Human)
src: Dragonpearl123 (/client)
usr.loc: the grass (44,22,1) (/turf/grass)
call stack:
Dragonpearl123 (/client): Acceleration()
Your speed has been boosted for a shurt duration!
<--- It shows that but doesn't increase my speed at alll.

client
New()
if(key in admins)
verbs.Add(typesof(/admin/verb))
verbs.Add(typesof(/speed/verb))
..()

That was where I gave myself the verbs.
Slash_Delay=0

The problem is that you are implying src when what you should be using is usr in this case. When you are storing verbs in a datum like this, it's technically okay to use usr. In this case, src is the client because you have changed the owner of the verb to the client, not their player. This is ugly ass code, though because it's become incredibly unsafe to use because of the potentially unknown src value.

I'm also going to fix a few things, though.

1) You don't need to loop through the view twice.

2) src isn't technically src in this case. It's implied that usr is src, but usr ought to be typecast to the correct type for safety.

3) Your ultra buff was bugged because it added 50% to the speed, but took 50% of the added value away. If your speed was 100 when you used it, your speed would be boosted to 150, but then dropped to 75 after you used it. Permanently.

4) I also removed most of your spawns. They were broken anyway. There's no need to spawn inside of a verb that you aren't going to call as a proc. Even then if you are, just set waitfor = 0.

5) I fixed your settings. They were wrong.

speed
verb
Speed_Slash()
set category = "Techniques"
var/mob/user = usr
if(user.Slash_Delay==1) //this is probably intensely unsafe
var/list/Players = new()
var/mob/M
for(M in oview(5,user))
if(M.client)
Players += M
M = input("What player would you like to Slash to?","Teleport") as mob in Players
if(user.loc&&user.z==M.z&&get_dist(M,user)<=5)
var/damage = usr.speed - M.defense
M.power -= damage
user.loc = locate(M.x+rand(1,5),M.y+rand(1,5),M.z) //setting loc manually is unsafe. You should create a ForceMove() function
M<<{"<font size="-1" color="#F0AF23">[user] slashed you with his speed for [damage] damage!."}
usr<<{"<font size="-1" color="#F0AF23">You slash [M] for [damage] damage!"}
M.deathcheck()
user.Levelup()
sleep(3)
user.icon_state=""
if(user.value != 1) //this is probably intensely unsafe
user.Slash_Delay=0
user.value = 1
spawn() Cooldown() //this is probably broken
user.valueCD = world.timeofday + 100 //this is definitely broken

speed
verb
Ultra_Buff()
set category = "Techniques"
set name = "Acceleration"
var/mob/user = usr
user.overlays += /obj/aura
user<<"Your speed has been boosted for a short duration!"
var/cspeed = user.speed * 0.5
user.speed += cspeed
sleep(60*2.5)
user<<"Your speed has reverted to normal!"
user.speed -= cspeed
There are a lot more problems with this than I can get into here. All kinds of stuff smells broken to me.

Using timeofday to track a cooldown is just insanity. Your cooldown stuff makes zero sense at all. The way you are dealing damage just makes zero sense... There's a lot more that's messed up too. Throw away the rip source. It's ruining you.
In response to Ter13
It wasn't rip, I worked super hard on it, Guess I should start the whole game over from scratch.
also got this now.
runtime error: bad output
proc name: CreateNewCharacter (/mob/other/choosing_character/proc/CreateNewCharacter)
source file: Start.dm,86
usr: (src)
src: Dragonpearl123 (/mob/other/choosing_character)
src.loc: null
call stack:
Dragonpearl123 (/mob/other/choosing_character): CreateNewCharacter()
Dragonpearl123 (/mob/other/choosing_character): ChooseCharacter()
Dragonpearl123 (/mob/other/choosing_character): Login()
You haven't posted any of the code for the CreateNewCharacter() function.

Start.dm line 86 is where the error is.

Guess I should start the whole game over from scratch.

If you decide to do that, you need to take a good hard look at some better resources. Whatever you are using as a guide is failing you. Badly. I've got a knack for recognizing programming habits and where they come from. Some of the habits you've picked up are from rip source code. You've picked up some of the worse habits.

Learning by doing is good, but you need to make an effort to figure out why what you are doing isn't working. Just starting over and blindly doing it again isn't going to teach you anything.
In response to Ter13
CreateNewCharacter()
var/char_name
do
char_name = input(src, "What is your name?","New Character") as null|text
if(!char_name)
return
if (ckey(char_name) in characters)
alert("This name isn't good enuff.")
char_name = null
while(!char_name)

var/char_race = input(src, "What race do you wish to be?", "New Character", "Human", "Mage") in _races
var/rtype = _races[char_race]
var/mob/new_mob = new rtype()
if(prob(10))
src<<"You were born with some of saitamas bloos inside of you, giving you the potential to be like him!"
usr.potential = "All"
else
src<<"You were born as a commoner, tough luck!"
usr.potential = "???"
play_cutscene()
new_mob.client = client //after creating the new character, you need to set the new mob's client to end the character creation process and suspend the loop.
new_mob.savable = 1
new_mob.name = char_name
savefile[ckey(char_name)] << new_mob //save the character in the savefile before this mob is garbage collected.
Ah, yeah. That bad output is a BYOND bug. It only happens the first time that you try to save something to a savefile per world.

Lummox swears up and down that this bug doesn't happen on his end. I have no idea why it's happening, and I have no ETA on a fix.

A quick fix would be to write an object to a savefile during world startup then delete the savefile.
Also, for the love of god, please read this:

http://www.byond.com/forum/?post=2003116#comment17822051

usr isn't valid in most procs.
In response to Ter13
I have never heard of ForceMove() can you please explain because whatever I try runetime error still happens
ForceMove() is a type of function I use frequently that is sort of like Move() but only calls Crossed/Uncrossed()/Entered()/Exited(), and not their permissive variants.

It's a function you need to define yourself:

//This is like Move(), except it forces the movement to succeed. Enter()/Exit()/Cross()/Uncross() are not called. However, Entered()/Exited()/Crossed()/Uncrossed() are called.
atom
movable
proc
ForceMove(atom/NewLoc,Dir=0,Step_x=0,Step_y=0)
var/oDir = dir
var/oSx = step_x
var/oSy = step_y
var/oz = z, nz
var/ox = (x-1)*TILE_WIDTH+bound_x+step_x, nx
var/oy = (y-1)*TILE_HEIGHT+bound_y+step_y, ny
if(NewLoc)
nx = (NewLoc.x-1)*TILE_WIDTH+bound_x+Step_x
ny = (NewLoc.y-1)*TILE_HEIGHT+bound_y+Step_y
nz = NewLoc.z
if(oz!=nz||ox!=nx||oy!=ny) //if this is an actual movement
//get the old objects, turfs, and areas that this object is overlapping
var/list/ol = locs, list/om = obounds(src) - ol, list/oa = get_areas(ol)

//actually turn and move the player
var/atom/OldLoc = loc
if(Dir&&dir!=Dir) dir = Dir
loc = NewLoc
step_x = Step_x
step_y = Step_y

//get the object's we've entered, crossed, etc and those that we are no longer standing over
var/list/nl = locs, list/nm = obounds(src) - nl, list/na = get_areas(nl)
var/list/xl = ol - nl, list/xm = om - nm, list/xa = oa - na

nl = nl - ol
nm = nm - om
na = na - oa

//loop through and call the movement notifiers
var/atom/t, atom/movable/o, area/a
for(o in xm)
o.Uncrossed(src)
for(t in xl)
t.Exited(src,NewLoc)
for(a in xa)
a.Exited(src,NewLoc)
for(a in na)
a.Entered(src,OldLoc)
for(t in nl)
t.Entered(src,OldLoc)
for(o in nm)
o.Crossed(src)
return 1
else if(Dir&&dir!=Dir) //otherwise, just turn the mob.
dir = Dir
return 1
return 0


It's quite a helpful little function to have.
In response to Ter13
If you decide to do that, you need to take a good hard look at some better resources. Whatever you are using as a guide is failing you. Badly. I've got a knack for recognizing programming habits and where they come from. Some of the habits you've picked up are from rip source code. You've picked up some of the worse habits.

Just saw this, and I think you are right, I have collected sources for years now and have been looking at how various games differ and different habits have been unintentionally picked up. I probably might have to restart those moves from scratch by itself.