ID:147470
 
i have scoreboards in my soccer area in my game
everything seems alright in DM
but when i score i get a runtime error

runtime error: Cannot modify null.icon_state.
proc name: Rscore (/proc/Rscore)

now, i dont understand that
im using a proc to change the scoreboard's icon state
here are the procs:
proc/Rscore(obj/rscoreboard/R)
if(Rscore == 1)
R.icon_state = "R1"
if(Rscore == 2)
R.icon_state = "R2"
if(Rscore == 3)
R.icon_state = "R3"
if(Rscore == 4)
R.icon_state = "R4"
if(Rscore == 5)
R.icon_state = "R5"
else
R.icon_state = "R0"
proc/Bscore(obj/bscoreboard/B)
if(Bscore == 1)
B.icon_state = "B1"
if(Bscore == 2)
B.icon_state = "B2"
if(Bscore == 3)
B.icon_state = "B3"
if(Bscore == 4)
B.icon_state = "B4"
if(Bscore == 5)
B.icon_state = "B5"
else
B.icon_state = "B0"

they seem fine
but i dont know
im calling them when my ball goes into the net turf
here is the net code:
    net1
icon = 'Soccer.dmi'
icon_state = "net1"
Entered(obj/O)
if(istype(O,/obj/soccerball))//replace /mob/player with your player's mob type
O.loc=locate(11,10,7)//location inside the location the door leads to
world << "<font color = red>The Red team scored!!"
Rscore += 1
walk(O,0)
Rscore()
if(Rscore >= 5)
world << "<font color = red>Red team WINS!!!!"
Rscore = 0
Bscore = 0
return ..()

net2
icon = 'Soccer.dmi'
icon_state = "net2"
Entered(obj/O)
if(istype(O,/obj/soccerball))//replace /mob/player with your player's mob type
O.loc=locate(11,10,7)//location inside the location the door leads to
world << "<font color = red>The Red team scored!!"
Rscore += 1
walk(O,0)
Rscore()
if(Rscore >= 5)
world << "<font color = red>Red team WINS!!!!"
Rscore = 0
Bscore = 0
return ..()
net3
icon = 'Soccer.dmi'
icon_state = "net3"
Entered(obj/O)
if(istype(O,/obj/soccerball))//replace /mob/player with your player's mob type
O.loc=locate(11,10,7)//location inside the location the door leads to
world << "The Blue team scored!!"
Bscore += 1
walk(O,0)
Bscore()
if(Bscore >= 5)
world << "Blue team WINS!!!!"
Rscore = 0
Bscore = 0
return ..()
Exited(obj/O)
if(istype(O,/obj/soccerball))
walk(src,0)
net4
icon = 'Soccer.dmi'
icon_state = "net4"
Entered(obj/O)
if(istype(O,/obj/soccerball))//replace /mob/player with your player's mob type
O.loc=locate(11,10,7)//location inside the location the door leads to
world << "The Blue team scored!!"
Bscore += 1
Bscore()
walk(O,0)
if(Bscore >= 5)
world << "Blue team WINS!!!!"
Rscore = 0
Bscore = 0
return ..()

if anyone can help i would appriciate it!!
This is how it's defined:
proc/Rscore(obj/rscoreboard/R)



This is how it's called:
Rscore()



That's your problem.
In response to Garthor
i tried that but it gave me errors

Coding Practice.dm:326:error:obj:undefined var
Coding Practice.dm:326:error:rscoreboard:undefined var
Coding Practice.dm:326:error:R:undefined var
Coding Practice.dm:342:error:obj:undefined var
Coding Practice.dm:342:error:rscoreboard:undefined var
Coding Practice.dm:342:error:R:undefined var
Coding Practice.dm:357:error:obj:undefined var
Coding Practice.dm:357:error:bscoreboard:undefined var
Coding Practice.dm:357:error:B:undefined var
Coding Practice.dm:374:error:obj:undefined var
Coding Practice.dm:374:error:bscoreboard:undefined var
Coding Practice.dm:374:error:B:undefined var

that doesnt work!!
In response to Tabu34
I didn't tell you to do anything. I was simply pointing out your problem.
In response to Garthor
So could u help me out?
i have no clue what to do!
Tabu34 wrote:
i have scoreboards in my soccer area in my game
everything seems alright in DM
but when i score i get a runtime error

runtime error: Cannot modify null.icon_state.
proc name: Rscore (/proc/Rscore)

now, i dont understand that
im using a proc to change the scoreboard's icon state
here are the procs:
> proc/Rscore(obj/rscoreboard/R)
> if(Rscore == 1)
> R.icon_state = "R1"
> if(Rscore == 2)
> R.icon_state = "R2"
> if(Rscore == 3)
> R.icon_state = "R3"
> if(Rscore == 4)
> R.icon_state = "R4"
> if(Rscore == 5)
> R.icon_state = "R5"
> else
> R.icon_state = "R0"
> proc/Bscore(obj/bscoreboard/B)
> if(Bscore == 1)
> B.icon_state = "B1"
> if(Bscore == 2)
> B.icon_state = "B2"
> if(Bscore == 3)
> B.icon_state = "B3"
> if(Bscore == 4)
> B.icon_state = "B4"
> if(Bscore == 5)
> B.icon_state = "B5"
> else
> B.icon_state = "B0"
>

they seem fine
but i dont know
im calling them when my ball goes into the net turf
here is the net code:
>   net1
> icon = 'Soccer.dmi'
> icon_state = "net1"
> Entered(obj/O)
> if(istype(O,/obj/soccerball))//replace /mob/player with your player's mob type
> O.loc=locate(11,10,7)//location inside the location the door leads to
> world << "<font color = red>The Red team scored!!"
> Rscore += 1
> walk(O,0)
> Rscore()
> if(Rscore >= 5)
> world << "<font color = red>Red team WINS!!!!"
> Rscore = 0
> Bscore = 0
> return ..()
>
> net2
> icon = 'Soccer.dmi'
> icon_state = "net2"
> Entered(obj/O)
> if(istype(O,/obj/soccerball))//replace /mob/player with your player's mob type
> O.loc=locate(11,10,7)//location inside the location the door leads to
> world << "<font color = red>The Red team scored!!"
> Rscore += 1
> walk(O,0)
> Rscore()
> if(Rscore >= 5)
> world << "<font color = red>Red team WINS!!!!"
> Rscore = 0
> Bscore = 0
> return ..()
> net3
> icon = 'Soccer.dmi'
> icon_state = "net3"
> Entered(obj/O)
> if(istype(O,/obj/soccerball))//replace /mob/player with your player's mob type
> O.loc=locate(11,10,7)//location inside the location the door leads to
> world << "The Blue team scored!!"
> Bscore += 1
> walk(O,0)
> Bscore()
> if(Bscore >= 5)
> world << "Blue team WINS!!!!"
> Rscore = 0
> Bscore = 0
> return ..()
> Exited(obj/O)
> if(istype(O,/obj/soccerball))
> walk(src,0)
> net4
> icon = 'Soccer.dmi'
> icon_state = "net4"
> Entered(obj/O)
> if(istype(O,/obj/soccerball))//replace /mob/player with your player's mob type
> O.loc=locate(11,10,7)//location inside the location the door leads to
> world << "The Blue team scored!!"
> Bscore += 1
> Bscore()
> walk(O,0)
> if(Bscore >= 5)
> world << "Blue team WINS!!!!"
> Rscore = 0
> Bscore = 0
> return ..()
>

if anyone can help i would appriciate it!!

Don't mind Garthor's reply. He just thinks he knows everything but won't share any of that knowledge he thinks he has. ;)

You need to pass the scoreboard object into the rscore and bscore functions. Let me give an example of how to pass things along to other procedures. (There are two different examples of what you want to do in the following.)
mob/verb/use_item(obj/item/O in contents)
O.use(src)//A
obj/item
proc/use(mob/user)
herb
use()
..();user.hp+=10
warp_thing
var/set_point
use()
..()
if(!set_point)
set_point=user.loc
else user.loc=set_point
mob
var
mob/target
hp=10
Click()
usr.target=src
verb/attack()
var/damage=rand(1,10)
damage(target,damage)//B
proc/damage(mob/target,damage)
target.hp-=damage
if(target.hp<=0)
var/OldLoc=target.loc
target<<"You fall unconcious."
target.loc=null
sleep(20)
target.loc=OldLoc
target<<"You've woken up."

Notice how the objects were passed to the procedure in the lines marked A and B. You must pass the actual object to the procedure in that way.
In response to Loduwijk
i dont quite get it
if you could point out how i can do this with my stuff that would be great.
i know you are trying to get me to do it myself but i just dont get it!
In response to Tabu34
Tabu34 wrote:
i dont quite get it
if you could point out how i can do this with my stuff that would be great.
i know you are trying to get me to do it myself but i just dont get it!

Try looking at this:
proc
WelcomeMob(mob/M)
M << "Hi!"

mob
Login()
WelcomeMob()
..()


You may think that there's nothing wrong with that, but look closer. WelcomeMob() takes an argument of mob/M, so that it knows who to welcome.

In Login(), no argument is passed. The WelcomeMob() proc has no clue who it's supposed to welcome, so at runtime, when a mob logs in, an error occurs.

The proper way to call WelcomeMob() would include providing an argument, eg WelcomeMob(src). That would cause src, whoever logged into the mob, to get a message of "Hi!" when they log in.


Your problem is with Rscore() and how you call it. As Garthor said, it takes a variable so that it knows what it's supposed to change the icon_state of. You never passed it an argument to tell it what scoreboard it's supposed to deal with.

What you need to do is, instead of calling Rscore() with no arguments, pass it the a variable that contains your scoreboard, so it knows what scoreboard object it's supposed to change.
In response to Jon88
i called it as Rscore(/obj/rscoreboard)
i get the runtime error
runtime error: Cannot modify /obj/rscoreboard.icon_state.
proc name: Rscore (/proc/Rscore)
In response to Tabu34
Tabu34 wrote:
i called it as Rscore(/obj/rscoreboard)
i get the runtime error
runtime error: Cannot modify /obj/rscoreboard.icon_state.
proc name: Rscore (/proc/Rscore)

You're trying to modify a path type. You have to make a new/obj/rscoreboard...
In response to Goku72
alright... no errors,but
the icon states dont change!!!!
In response to Tabu34
Tabu34 wrote:
alright... no errors,but
the icon states dont change!!!!

The icons states of what? The icon states of the new scoreboard object that you created should have changed. If you want to change the icon states of already existing scoreboards, you'll need to pass a variable that contains those *particular* scoreboards to the procedure.
In response to Jon88
umm
so im confused
should i have my scoreboards there?
or shoud there be none on the map?