ID:177191
 

ok this is the problem im running into. this if statement is returning true even when tripoliloc is not "001". the reason I have the "" there is because other values in that var will have a text string. there is nothing wrong with the tripoliorbit var if returns the correct value so I am left to believe that my problem lies in my text string. please help.


if(tripoliorbit==1&&tripoliloc=="001")

is there another way to write this so that both must be true for the if statement to be in effect?
Treasurecat wrote:
ok this is the problem im running into. this if statement is returning true even when tripoliloc is not "001". the reason I have the "" there is because other values in that var will have a text string. there is nothing wrong with the tripoliorbit var if returns the correct value so I am left to believe that my problem lies in my text string. please help.

if(tripoliorbit==1&&tripoliloc=="001")

is there another way to write this so that both must be true for the if statement to be in effect?

Frankly I don't think the effect you're observing is possible. I think you've made a mistaken observation, because the code you've shown us should work. You'll need to post a little more than that for us to figure out exactly where the trouble is.

Lummox JR
In response to Lummox JR
obj
trasporter_pad
icon = 'transporter.dmi'
icon_state = "pad"
density = 0
verb/Energize()
set src in oview(0)
if(tripoliorbit==1&&tripoliloc=="001")
switch(input("chief: good day sir. where would you like to go?")in list("Tripoli","nowhere"))
if("Tripoli")
usr.loc = locate(12,20,3)
usr << "Hello sir welcome aboard."
if("nowhere")
return()
else
usr << "Sorry sir there are no ships in orbit"
In response to Treasurecat
You have to make sure you're setting the variable like:

varname = "001"

and not:

varname = 001
Treasurecat wrote:
is there another way to write this so that both must be true for the if statement to be in effect?

That is what the && operator does(the AND operator).

if conditionOne equals valueOne AND conditionTwo equals valueTwo

As opposed to the || operator(the OR operator).

if conditionOne equals valueOne OR conditionTwo equals valueTwo
In response to Nadrew
ok then perhaps my problem is this

verb/set_course(tripoliloc as text)
set src in view(1)
view() << "course set for sector [tripoliloc]"

I tried adding this

tripoliloc = tripoliloc but that didnt help also note the view() is outputting a new tripoliloc does anyone know what the problem might be?


In response to Treasurecat
Treasurecat wrote:
tripoliloc = tripoliloc but that didnt help also note the view() is outputting a new tripoliloc does anyone know what the problem might be?

If tripoliloc is a variable, tripoliloc=tripoliloc will do nothing because it's saying "give tripoliloc the value of tripoliloc", which will of course appear to do nothing (because nothing will change).

What do you mean by a "new tripoliloc"? Are you sure you're calling set_course() with a value? (Oh wait, it's a verb... is that your ENTIRE set_course() verb? Because if it is it won't do anything except display a message.)
In response to Crispy
What do you mean by a "new tripoliloc"? Are you sure you're calling set_course() with a value? (Oh wait, it's a verb... is that your ENTIRE set_course() verb? Because if it is it won't do anything except display a message.)

yes it is my entire set course verb. what do I need to add?
In response to Treasurecat
can someone help me with this verb?
In response to Treasurecat
Look at this verb:

say (message as text)
view() << "[src] says [message]."

Now look at this verb:

set_course (tripoliloc as text)
view() << "[src] sets course for [tripoliloc]."

What's different between the two? Well, the name of the verb is different. The name of the argument (that is, the variable that you type in when you use the verb) is different. The text that gets output in the middle part of the message is different. Other than that, the verbs are identical.

What you have done is make a say verb with a different name!

I imagine that you have a variable defined somewhere outside the verb called tripoliloc and you want this verb to actually set. Well, (tripoliloc as text) is telling the computer to create a new variable which although it happens to have the same name as the other variable called tripoliloc, only exists from the time the verb starts running to the time it concludes... much like the message variable you might use in a say verb. If you want a verb to change a player's variable, you have to tell it to do so.

Consider this verb:
mob
var/strength
set_strength(s as num)
view() << "[src] set strength to [s]."
src.strength = s

We didn't name the verb's argument/variable strength, even though that's what it represents, because the mob already has a variable called strength, and even though giving the verb a variable with the same name won't cause any problems for the computer, it can be confusing to us as we read through it, figuring out when the code means mob.strength and when it means the verb argument strength. You could use this example and rename s to strength, or orangatang, or whatever you wanted. The point is to take the argument, whatever you have chosen to call it, and set the previously created variable = to the argument.