ID:1947706
 
(See the best response by Kaiochao.)
Code:
/client/proc/freeze(mob/living/M as mob in mob_list)
set category = "Special Verbs"
set name = "Freeze"
if(!holder)
src << "Only administrators may use this command."
return
if(!mob)
return
if(!istype(M))
alert("Cannot freeze a ghost")
return
if(usr)
if (usr.client)
if(usr.client.holder)
if (istype(M, /mob/living/carbon/slime))
if(!M.paralysis)
M.adjustToxLoss(2147483647)
M.AdjustParalysis(2147483647)
var/adminomaly = new/obj/effectsphoenix/overlay/adminoverlay
name = "adminoverlay"
icon = 'icons/effects/effectsphoenix.dmi'
icon_state = "admin"
layer = 4.1
spawn(50)
M.overlays += adminomaly
M << "<b><font color= red>You have been frozen by <a href='?priv_msg=\ref[usr.client]'>[key]</a></b></font>"
message_admins("\blue [key_name_admin(usr)] froze [key_name(M)]")
log_admin("[key_name(usr)] froze [key_name(M)]")
log_admin_single("[key_name(usr)] froze [key_name(M)]")
else if (M.paralysis)
M.AdjustParalysis(-2147483647)
M.blinded = 0
M.lying = 0
M.stat = 0
M << "<b> <font color= red>You have been unfrozen by <a href='?priv_msg=\ref[usr.client]'>[key]</a></b></font>"
message_admins("\blue [key_name_admin(usr)] unfroze [key_name(M)]")
log_admin("[key_name(usr)] unfroze [key_name(M)]")
log_admin_single("[key_name(usr)] unfroze [key_name(M)]")
M.revive()
else
if(!M.paralysis)
M.AdjustParalysis(2147483647)
var/adminomaly = new/obj/effectsphoenix/overlay/adminoverlay
spawn(50)
M.overlays += adminomaly
M << "<b><font color= red>You have been frozen by <a href='?priv_msg=\ref[usr.client]'>[key]</a></b></font>"
message_admins("\blue [key_name_admin(usr)] froze [key_name(M)]")
log_admin("[key_name(usr)] froze [key_name(M)]")
log_admin_single("[key_name(usr)] froze [key_name(M)]")
else if (M.paralysis)
M.AdjustParalysis(-2147483647)
M.blinded = 0
M.lying = 0
M.stat = 0

M << "<b> <font color= red>You have been unfrozen by <a href='?priv_msg=\ref[usr.client]'>[key]</a></b></font>"
message_admins("\blue [key_name_admin(usr)] unfroze [key_name(M)]")
log_admin("[key_name(usr)] unfroze [key_name(M)]")
log_admin_single("[key_name(usr)] unfroze [key_name(M)]")


/client/proc/freezemecha(obj/mecha/O as obj in world)
set category = "Special Verbs"
set name = "Freeze Mech"
if(!holder)
src << "Only administrators may use this command."
return
var/obj/mecha/M = O
if(!istype(M,/obj/mecha))
src << "\red <b>This can only be used on Mechs!</b>"
return
else
if(usr)
if (usr.client)
if(usr.client.holder)
var/adminomaly = new/obj/effectsphoenix/overlay/adminoverlay
if(M.can_move == 1)
M.can_move = 0
M.overlays += adminomaly
if(M.occupant)
M.removeVerb(/obj/mecha/verb/eject)
M.occupant << "<b><font color= red>You have been frozen by <a href='?priv_msg=\ref[usr.client]'>[key]</a></b></font>"
message_admins("\blue [key_name_admin(usr)] froze [key_name(M.occupant)] in a [M.name]")
log_admin("[key_name(usr)] froze [key_name(M.occupant)] in a [M.name]")
log_admin_single("[key_name(usr)] froze [key_name(M.occupant)] in a [M.name]")
else
message_admins("\blue [key_name_admin(usr)] froze an empty [M.name]")
log_admin("[key_name(usr)] froze an empty [M.name]")
log_admin_single("[key_name(usr)] froze an empty [M.name]")
else if(M.can_move == 0)
M.can_move = 1
M.overlays -= adminomaly
if(M.occupant)
M.addVerb(/obj/mecha/verb/eject)
M.occupant << "<b><font color= red>You have been unfrozen by <a href='?priv_msg=\ref[usr.client]'>[key]</a></b></font>"
message_admins("\blue [key_name_admin(usr)] unfroze [key_name(M.occupant)] in a [M.name]")
log_admin("[key_name(usr)] unfroze [M.occupant.name]/[M.occupant.ckey] in a [M.name]")
log_admin_single("[key_name(usr)] unfroze [M.occupant.name]/[M.occupant.ckey] in a [M.name]")
else
message_admins("\blue [key_name_admin(usr)] unfroze an empty [M.name]")
log_admin("[key_name(usr)] unfroze an empty [M.name]")
log_admin_single("[key_name(usr)] unfroze an empty [M.name]")


Problem description: Error appears at line 24, and is as follows:

code\modules\admin\verbs\freeze.dm:24:error: spawn: expected end of statement


The exact piece of code I believe is causing this error is as follows:

new/obj/effectsphoenix/overlay/adminoverlay
name = "adminoverlay"
icon = 'icons/effects/effectsphoenix.dmi'
icon_state = "admin"
layer = 4.1
spawn(50)
M.overlays += adminomaly
M << "<b><font color= red>You have been frozen by <a href='?priv_msg=\ref[usr.client]'>[key]</a></b></font>"

Best response
If that's supposed to be a modified type, you need to surround the initializations with curly braces, like so:
new /obj/effectsphoenix/overlay/adminoverlay {
name = "adminoverlay"
icon = 'icons/effects/effectsphoenix.dmi'
icon_state = "admin"
layer = 4.1
}
I don't think it was intended as a modified type. I'd change it like so:

var/obj/effectsphoenix/overlay/adminoverlay/adminomaly = new
adminomaly.name = "adminoverlay"
adminomaly.icon = 'icons/effects/effectsphoenix.dmi'
adminomaly.icon_state = "admin"
adminomaly.layer = 4.1

Sadly, neither fixed my error. The line of code is supposed to clarify what 'adminomaly' is, because without it, the program doesn't work.

Unfortunately, I can't understand the error, and after hours of stressful debuging, decided to post it here.

I tried changing the 'spawn' verb to sleep, same error + 2 more errors.

I tried changing it's position. It determines that the next line of code has the same error.

var/obj/effectsphoenix/overlay/adminoverlay/adminomaly = new
adminomaly.name = "adminoverlay"
adminomaly.icon = 'icons/effects/effectsphoenix.dmi'
adminomaly.icon_state = "admin"
adminomaly.layer = 4.1


This code gave me the following errors:

code\modules\admin\verbs\freeze.dm:20:error: adminomaly.name: undefined type: adminomaly.name
code\modules\admin\verbs\freeze.dm:21:error: adminomaly.icon: undefined type: adminomaly.icon
code\modules\admin\verbs\freeze.dm:22:error: adminomaly.icon_state: undefined type: adminomaly.icon_state
code\modules\admin\verbs\freeze.dm:23:error: adminomaly.layer: undefined type: adminomaly.layer
code\modules\admin\verbs\freeze.dm:25:error: adminomaly: undefined type: adminomaly
code\modules\admin\verbs\freeze.dm:29:error: log_admin_single: undefined proc
code\modules\admin\verbs\freeze.dm:38:error: log_admin_single: undefined proc
code\modules\admin\verbs\freeze.dm:43:error: /obj/effectsphoenix/overlay/adminoverlay: undefined type path
code\modules\admin\verbs\freeze.dm:49:error: log_admin_single: undefined proc
code\modules\admin\verbs\freeze.dm:59:error: log_admin_single: undefined proc
code\modules\admin\verbs\freeze.dm:76:error: /obj/effectsphoenix/overlay/adminoverlay: undefined type path
code\modules\admin\verbs\freeze.dm:85:error: log_admin_single: undefined proc
code\modules\admin\verbs\freeze.dm:89:error: log_admin_single: undefined proc
code\modules\admin\verbs\freeze.dm:98:error: log_admin_single: undefined proc
code\modules\admin\verbs\freeze.dm:102:error: log_admin_single: undefined proc
code\modules\admin\verbs\freeze.dm:19:error: adminomaly: unknown variable type
code\modules\admin\verbs\freeze.dm:20:error: : invalid expression
Try var/obj/effectsphoenix/overlay/adminoverlay/adminomaly = new(M.loc)
Not an answer per se - but many a night of stressful debugging with inexplicable errors have been because of weird shit you wouldn't expect.

I would try the following:

* Try running the bare essentials of this code in a new/blank project (if feasible to do so). This will act as a sanity check. If it doesn't compile/has the same errors you KNOW its in that part of the code. If it compiles fine, you should look elsewhere. Sometimes a typo in a crucial place can cause huge error in unrelated .dm files.

* If the problem persists, try calling /obj = new(param1, param2, param 3) and parsing the variable's own New() proc

* Take a break - try theorizing solutions/causes as a means of "counting sheep" while you sleep/nap. or jump in the shower. r/ShowerThoughts is a thing for a reason.

* //comment out a bunch of lines -- more and more until it compiles fine. Then un-comment them out (1 or 2 lines at a time) until the error pops up. That will pinpoint the source of the problem. Then just follow the breadcrumbs back to the cause.

(That last one might be of no use here though)
In response to ZOMGbies
All great advice and things I also do!

That dreaded missing ', " or a closing ) can really drive someone nuts at 2-3 in the morning! :)
Especially if the code is a mess and difficult to read with little or bad commenting.
In response to NikolaAnicic007
The error you're getting is almost certainly from an indentation problem--which your original code has. Either of the suggested fixes should have taken care of that, suggesting that when you changed the code there was a mistake. Can you post what your changed code looks like?

Changing spawn() to sleep() also won't work without altering the indentation, because they function differently.
In response to Lummox JR
Especially if they copied the code from the forum, which inserts spacebar spaces as the tabs and will always return errors in DM. Indentation is another one of those irritating things in the middle of the night!
In response to AERProductions
AERProductions wrote:
Especially if the code is a mess and difficult to read with little or bad commenting.

This is something I need to do more of. Too often I write new functions and whatnot, comeback to it the next day and I'm just like "whut? ._. "
In response to ZOMGbies
Well I didn't mean to imply that was the case with your project, I was actually projecting about my own. :)

The commenting in my project is a mishmash of nonsense that the find and replace has completely torn to pieces and I'd say less than 5% of the comments are mine so the rest is really dreadful stuff. I simply ignore it. :)