ive been trying to figure this one out for awhile.
Write_a_movie_script()
new /obj/production (usr)
var
mob/M
obj/production/P
M.ws += P.value
when I try to use the verb its giving me a runtime error saying that it cannot read nul.value
now what I want is for usr.ws to be added to the new production obj in the usr inventory. Its important that only the obj in the usr inventory gets changed.
ID:175156
Jun 3 2003, 9:19 pm
|
|
In response to Flick
|
|
Flick wrote:
Treasurecat wrote: > mob You stated that you wanted the mobs 'ws' var to be added to the /obj/production, so I wrote it that way, although you have it reversed in your example. I dont understand why im getting this error runtime error: Cannot read null.ws proc name: Write a movie script (/mob/verb/Write_a_movie_script) usr: Treasurecat (/mob/DM) src: Treasurecat (/mob/DM) call stack: Treasurecat (/mob/DM): Write a movie script() ws is a var set to 1 at the begining. I tried reversing to P.value += M.ws but I got the excact same error the only thing I really am trying to do here is add the value of M.ws to P.value |
Treasurecat wrote:
ive been trying to figure this one out for awhile. You never set P to anything. Thus, P is null. You have the same problem with M. When you created the /obj/production you never assigned it to a var, and it looks like P was the intended target for that. So you need P=new(usr) instead of the new/obj/production(usr) line above, and M.ws should probably be usr.ws instead. Lummox JR |
In response to Lummox JR
|
|
Lummox JR wrote:
Treasurecat wrote: P is an object being created in the usr inventory however it looks like my M.ws was the problem I changed it to usr.ws and now the error is gone and I believe the value was added |
I'm not exactly sure what you're shooting for here, but heres my guess.
You need to create a reference to that new production object you've created. Try something like this:
// (...assuming this is a mob verb...)
You stated that you wanted the mobs 'ws' var to be added to the /obj/production, so I wrote it that way, although you have it reversed in your example.
*EDIT* : By the way, the reason you get a 'null.value' error is you are attempting to read the variable of an empty reference. The line 'var/obj/production/P' creates a reference which CAN be pointed to an actual object, but at this point, it doesn't point to anything, therefore, it is 'null'.