Home   Help Search Login Register  

Author Topic: Checking alphabetic variables in a script.  (Read 571 times)

0 Members and 3 Guests are viewing this topic.

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Checking alphabetic variables in a script.
« on: 15 Jan 2004, 21:25:35 »
Im running in to problems passing letters to a script which I then want to check and do other things etc.

For example, I call a script with this line;

[cachetarget, E]exec "scud2.sqs"

I give the letter a variable name with this line;

_direction = _this select 1

And then I check the variable with the following line;

?_direction==E: goto "east"

But this doesnt seem to work.  I can pass the letter to the script easily enough, but I dont think the third line is working.  What do I have do to the check line, or when passing the letter, so that it works?

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:Checking alphabetic variables in a script.
« Reply #1 on: 15 Jan 2004, 21:37:48 »
have you checked with hint format ["%1",_direction] what it gives you?
Not all is lost.

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:Checking alphabetic variables in a script.
« Reply #2 on: 15 Jan 2004, 21:48:40 »
Yea its working now.  I replaced the single letter with the full word and its working.  Now Im trying to add support for the half compass points, and its not working.  But I shall prevail!  ;D

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Checking alphabetic variables in a script.
« Reply #3 on: 15 Jan 2004, 21:52:08 »
hmm - if you do not initialize E anywhere, could it be that
there would be no difference, wether you say:

?_direction == E

or

?_direction == F

As if both are not initialized, both letters would return the
same value/state

(can't try that out at work - give it a shot)

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:Checking alphabetic variables in a script.
« Reply #4 on: 15 Jan 2004, 22:11:26 »
Ok what does that mean?!

Now Ive changed the check to work with the full direction names; north , south, east , west etc.

the script works fine if I pass the word "east" to the script;

[cachetarget,east]exec "scud2.sqs"

A hint reports the the variable _direction as correctly being EAST, and the rest of the script works fine as well.

The same thing happens when "west" is passed to the script.  the hint shows _direction being set to WEST and the rest of the script works as normal.

However when using north, or south (or any of the inbetween direction names, which are all setup in the exact same way as the east and west checks) it doesnt work.  And the hint reports an error instead of the word that is passed.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Checking alphabetic variables in a script.
« Reply #5 on: 15 Jan 2004, 22:31:07 »
Dont know if this is what you need, but:

[cachetarget,"E"] exec "scud2.sqs"

works


Planck
I know a little about a lot, and a lot about a little.

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:Checking alphabetic variables in a script.
« Reply #6 on: 16 Jan 2004, 02:53:57 »
Something is wrong.

The full front end of the script is this;


;Target location and projectile direction.
_targ = _this select 0
_direction = _this select 1
hint format ["%1", _direction]

?_direction==north: goto "north"
?_direction==northeast: goto "northeast"
?_direction==east: goto "east"
?_direction==southeast: goto "southeast"
?_direction==south: goto "south"
?_direction==southwest: goto "southwest"
?_direction==west: goto "west"
?_direction==northwest: goto "northwest"
man globalchat "Direction incorrectly specified"
goto "exit"


All Ive done to the script is add in support for four more compass points and changed the names up their full unabbrieviated versions.

Now, I know the basis of the script is sound, because Ive tested it with numbering the compass points instead of using names, and it works fine that way.  The stumbling block is passing a word to the script, and checking that the work is the same as one of eight possible options, if not, the script exits.

If I use, as above, the word in quotes;

[cachetarget,"East"] exec "scud2.sqs"

Then the hint line displaying _direction correctly says its East, however I get an error;

_direction==west |#| Generic error in expression

And the chat line I put in to tell if a variable hasnt been accepted displays;

"Direction incorrectly specified"

Removing the quotes from around the word when it calls the script works, with the East Direction.  However when choosing another direction, for example, South, the hint _direction line displays;

Scalar Bool Array String 0xfcffffef

And the chat line says that Ive incorrectly specified a direction.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Checking alphabetic variables in a script.
« Reply #7 on: 16 Jan 2004, 03:03:09 »
What about:

?_direction=="north": goto "north"
?_direction=="northeast": goto "northeast"

etc


Planck
I know a little about a lot, and a lot about a little.

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:Checking alphabetic variables in a script.
« Reply #8 on: 16 Jan 2004, 03:22:11 »
Yep, that was it.  All working now.  Good work team.  

Job jobbed.