I cant figure out why this error keeps coming up!
please help me
Code:
soda
icon='soda.dmi'
name="Shane's Soda!"
var/edible= 1
vebr/drink()
if (usr.thursty = 0
world << "[usr] donsent feel thirsty right now."//43
elsc
world << "[usr] drinks [scr] anbd feels replanished."
usr.hungery = 0
Error:
Chicken Hunter.dm:43:error: world: missing comma ',' or right-paren ')'
ID:151141
Mar 8 2001, 9:49 am
|
|
In response to Guy T.
|
|
yay thanx i get it.....but now..
Code: soda icon='soda.dmi' name="Shane's Soda!" var/edible= 1 verb/drink() if (usr.thirsty = 0) world << "[usr] donsent feel thursty right now." else if (src.edible = 0) world << "[urs] drink [src] and pukes!" else world << "[usr] drinks [scr] and feels replanished." usr.hungery = 0 Error: Chicken Hunter.dm:45:error:src.edible:bad var Chicken Hunter.dm:46:error:world:duplicate definition Chicken Hunter.dm:46:error:urs:value not allowed here Chicken Hunter.dm:46:error::duplicate definition Chicken Hunter.dm:46:error:src:value not allowed here Chicken Hunter.dm:46:error::duplicate definition Chicken Hunter.dm:46:error:text "[] drink [] and pukes!":value not allowed here Chicken Hunter.dm:46:error::duplicate definition Chicken Hunter.dm:46:error:<< :instruction not allowed here Chicken Hunter.dm:48:error:world:duplicate definition Chicken Hunter.dm:48:error:usr:value not allowed here Chicken Hunter.dm:48:error::duplicate definition Chicken Hunter.dm:48:error:scr:value not allowed here Chicken Hunter.dm:48:error::duplicate definition Chicken Hunter.dm:48:error:text "[] drinks [] and feels replanished.":value not allowed here Chicken Hunter.dm:48:error::duplicate definition Chicken Hunter.dm:48:error:<< :instruction not allowed here Chicken Hunter.dm:49:error:usr.hungery:bad var Chicken Hunter.dm:151:'door.dmi':warning: file found only in .rsc Chicken Hunter.dm:42:error:usr.thirsty:bad var Chicken Hunter.dm:42:error::missing expression 20 ERRORS! ahhh!! Thanx Shane |
In response to Shane
|
|
verb/drink() Look at the indentation. |
In response to Guy T.
|
|
its gettin better!
Code: soda icon='soda.dmi' name="Shane's Soda!" var/edible= 1 verb/drink() if (usr.thirsty = 0) world << "[usr] donsent feel thursty right now." else if (src.edible = 0) world << "[urs] drink [src] and pukes!" else world << "[usr] drinks [scr] and feels replanished." usr.hungery = 0 Errors: Chicken Hunter.dm:46:error:urs:bad var Chicken Hunter.dm:48:error:scr:bad var Chicken Hunter.dm:151:'door.dmi':warning: file found only in .rsc Chicken Hunter.dm:42:error:usr.thirsty:bad var Chicken Hunter.dm:49:error:usr.hungery:bad var Chicken Hunter.dm:42:error::missing expression Chicken Hunter.dm:45:error::missing expression |
In response to Shane
|
|
Chicken Hunter.dm:46:error:urs:bad var Now, come on. Are you even looking at the first error?! :) |
In response to Guy T.
|
|
On 3/8/01 12:33 pm Guy T. wrote:
Chicken Hunter.dm:46:error:urs:bad var I'll give a bit of an additional hint... How many urs does it take to scr in a lightbulb? |
In response to Deadron
|
|
On 3/8/01 1:26 pm Deadron wrote:
On 3/8/01 12:33 pm Guy T. wrote: The same amount it does when they're hungery. |
In response to Guy T.
|
|
Now, come on. Are you even looking at the first error?! :) You know... this may have sounded more negative than I meant it to be. The last thing I want to do is be a jerk to someone who loves video games and wants to learn programming! My point was just that the very first error in the list offers a good clue to your problem--namely, it mentions that "urs" is a bad var, which is true because you meant to use "usr". Mystery solved! |
In response to Spastic
|
|
Thanx everyone i got i down to 4 errors :)
verb/drink() if (usr.thirsty = 0) world << "[usr] donsent feel thursty right now." else if (src.edible = 0) world << "[usr] drink [src] and pukes!" else world << "[usr] drinks [src] and feels replanished." usr.thirsty = 0 Chicken Hunter.dm:42:error:usr.thirsty:bad var Chicken Hunter.dm:49:error:usr.thirsty:bad var Chicken Hunter.dm:42:error::missing expression Chicken Hunter.dm:45:error::missing expression SO SO sorry for all the posts i think this one will be my last one..... Thanx Shane |
In response to Shane
|
|
verb/drink() The bad var errors come from BYOND's assumption that usr is of type /mob, and *only* /mob... if your default player type is /mob/player or something, BYOND doesn't care... it assumes usr is just /mob. You could get around this by creating a temporary variable of the type that you know usr will be: verb/bla() var/mob/player/X = usr //X will be the same object as usr, but can access vars of /mob/player The "missing expression" errors are simple to fix. In comparisons, you can't use a single equals sign. You need to use a double, like so: if(a == b) A single equals sign is used for assigning values, like this: a = b //set a to the value of b Some languages, like BASIC, allow you to use a single equals sign for both assignment and comparison. But DM doesn't. It's just something you have to get used to. And, as a BASIC programmer of about 19 years now, I can tell you I still forget it now and then... the trick is that I now know, when the error message comes up, what I did wrong. You'll learn it, too, with experience! |
In response to Guy T.
|
|
dont really got what ya mean about the first one sorry :(
|
In response to Shane
|
|
On 3/8/01 8:43 pm Shane wrote:
dont really got what ya mean about the first one sorry :( He means you can't use usr if the player's mob will not be of the type /mob. For example, if you have /mob/player, then usr won't work unless you use a colon ":" in place of the period ".". That is, usr:thirsty rather than usr.thirsty Actually, it's better to use src in this case, because the mob is affecting itself in that verb. So you should replace all those "usr"'s with "src"'s. If you use src, you don't need colons, either. |
In response to Spuzzum
|
|
On 3/8/01 10:47 pm Spuzzum wrote:
... He means you can't use usr if the player's mob will not be of the type /mob. For example, if you have /mob/player, then usr won't work unless you use a colon ":" in place of the period ".".... Then than I set defualt to /mob/Player this way? (Trying to make usr to mob/Player) //set default mob to be called Player world/ mob = /mob/Player //end of world/mob |
In response to sunzoner
|
|
Then than I set defualt to /mob/Player this way? (Trying to make usr to mob/Player) Nope, usr will always be assumed to be type /mob, even if you set world.mob. All that does is connect the player to a mob of that type. world.mob is used to see which type the usr should connect to; when playing, usr will indeed point to the mob the player is currently connected to, but the compiler will assume that usr won't necessarily have those mobs variables, because usr doesn't HAVE to be /mob/Player. So if you were to suddenly connect to a /mob/NPC, and it assumes that you're of the type /mob/Player, it could try to access variables that don't exist (because they were defined under /mob/Player but weren't under /mob/NPC). And horrible things would happen if it tried to get something that didn't exist. See the discussion over in General about whether or not usr should assume it is of the world.mob type or not, and lend your opinion. |
Look at line 42, and read the error message one more time...