Hey all, im trying to make a semi-decent MUD, hoping you could help me with a problem.
This is my code
var/list/players
mob
icon='char.dmi'
var/blar
Login()
if(players!=usr) //check if the usr is in the players list, if not
players += usr //add the user to the players list
var/stats[] //define the user's stats
stats["power"] = rand(1,10)
stats["defense"] = rand(1,10)
stats["speed"] = rand(1,10)
stats["magic"] = rand(1,10)
stats["points"] = rand(1,10)
stats["points"] += 5 //add start points
var/savefile/F = new(ckey)
Write(F) //then create a playerfile
..() //after all is said and done, load teh parent.
verb
say(msg as text)
world << "[usr]: [msg]" //the world sees chat output
turf
square
icon='square.dmi'
Click()walk_to(usr,src)
client
Stat()
statpanel("Stats")
stat("Power", mob.stats["power"] )
world
turf= /turf/square
And its saying that mob.stats is an undefined variable.
(newworld.dm:36:error:mob.stats:undefined var)
Thanks in advance.
ID:169073
Jul 31 2005, 4:21 pm (Edited on Jul 31 2005, 4:29 pm)
|
|
In response to Polaruis
|
|
Same error :X
(newworld.dm:36:error:src.power:undefined var) |
In response to Nukes4U
|
|
mob/var/power
|
In response to Polaruis
|
|
Polaruis wrote:
mob/var/powerNo difference.....:X (newworld.dm:36:error:var/power:undefined var) |
In response to Nukes4U
|
|
No.
mob/var/power |
In response to Polaruis
|
|
Polaruis wrote:
No. > mob/var/power Oh, so i cant use a list? |
In response to Nukes4U
|
|
God damn...
mob Sheesh explain before giving code. |
Like it says, stats is an undefined variable. You need to define it for /mob. Like you have var/blah defined for /mob.
|
In response to Jon88
|
|
Eh, i defined it and everything now, but i got a new error.
Here's the new code. var/list/players mob icon='char.dmi' var/blar Login() if(players!=usr) //check if the usr is in the players list, if not players += usr //add the user to the players list var //define the user's stats power defense speed magic points //set initial stat value power = rand(1,10) defense = rand(1,10) speed =rand(1,10) magic = rand(1,10) point +=5 var/savefile/F = new(ckey) Write(F) //then create a playerfile ..() //after all is said and done, load teh parent. verb say(msg as text) world << "[usr]: [msg]" statpanel("Stats") stat("Power",src.power) turf square icon='square.dmi' Click()walk_to(usr,src) world turf= /turf/square And now it saws src.power is a duplicate definition. (newworld.dm:33:error:src.power:duplicate definition) Sorry to just dump code and errors on ya, guys, but im new and really need some help. |
In response to RaditzX
|
|
RaditzX wrote:
God damn...Don't you think thats a bit, harsh? > mob Sheesh explain before giving code.You did'nt explain either. As, for that. mob/var |
In response to Quest Industries
|
|
Quest Industries wrote:
> mob/var usr is not totally safe in mob/State(). I'd use src instead. In this case, src is the desired variable. usr isn't the mob that Stat() belongs to, but rather the player viewing the statpanel. Usually they are one and the same, but some games might show one mob's statpanel to another player for one reason or another, and using usr would cause bugs. For more information, see http://bwicki.byond.com/?WhatIsUsr and http://bwicki.byond.com/?UsrLecture |
In response to Jon88
|
|
I think you may wish to check here: ID: 188538
|
In response to Quest Industries
|
|
newworld.dm:12:power :warning: variable defined but not used
newworld.dm:33:error:power:undefined var Wtf? Something's teribbly wrong here. (and mob.power doesn't work either. |
In response to Nukes4U
|
|
You may have to indent it just a bit.
|
In response to Quest Industries
|
|
Quest Industries wrote:
I think you may wish to check here: ID: 188538 Well, it's safe in Stat() as long as client.statobj is never changed. :) |
In response to Jon88
|
|
Alright, I solved my problem :P If i were you i'd laugh at me.
The script didn't work because i was conditionally declaring variables, and apparently thats not good. Thanks alot, all. |
In response to Nukes4U
|
|
Ughh... use DM and /DM inside of <>'s when putting code...
|
stat("Power",src.power)