wrong #@object#

Farvardin
I thought the use of #@object# was for avoiding ambigus commands on objects with similar name, and to check if an object is in scope. Recently I added in my code such a command :


command <push #@table#> {
if ( %table_move% > 0 ) and ( %table_move% < 11 ) then {
msg <You push the table>
dec <table_move>
}
else msg <There is a wall preventing you to move anymore.>
}
command <pull #@table># {
if ( %table_move% > -1 ) and ( %table_move% < 10 ) then {
msg <You pull the table>
inc <table_move>
}
else msg <There is a wall preventing you to move anymore.>
}
command <push #@chair#> {
if ( %chair_move% > 0 ) and ( %chair_move% < 11 ) then {
msg <You push the chair>
dec <chair_move>
}
else msg <There is a wall preventing you to move anymore.>
}
command <pull #@chair#> {
if ( %chair_move% > -1 ) and ( %chair_move% < 10 ) then {
msg <You pull the chair>
inc <chair_move>
}
else msg <There is a wall preventing you to move anymore.>
}
command <push #@bed#> if not exists <book1> then {
msg <You notice a book has fallen between the wall and your bed.>
reveal <book1>
show <book1>


The problem now is if I write :

>push bed
You push the table
(and the value decrease for table_move)

the same goes for
>push chair

etc.

only the 1st command written is considered (command <push #@table#>)

So to avoid this problem, I removed the #@....# and all works fine, except it doesn't check if the object is in scope


I have also this :

	command <pull #@rope3#> {
if flag <gote_rope> and not flag <livolas_rope> then msg <You're not strong enough.>
if flag <gote_rope> and flag <livolas_rope> then {
msg <You help the Elf to pull the string. The princess is almost free now.>
flag on <liberee>
timeron <gote_lib>
}
}


and if someone type :

> pull tree
You help the Elf to pull the string. The princess is almost free now.

what is wrong ? It doesn't seem to be a normal behaviour.

Alex
You've misunderstood what the #...# and #@...# syntax is for. These surround names of variables, not object names. Whatever the player types in in that space is put into the variable you specify. If you use the #@...# form, the player is limited to typing in a valid object name, and the variable will contain the real (unaliased) name of the object.

In your example, don't use things like "push #@table#". Call it something like "push #@object#" instead, and then check whether the string variable "object" contains the name of the table. If the table object's real name is "table", then use:


command <push #@object#> {
if ( #object# = table ) then {
' insert table pushing code
}
else msg <You can't push that!>
}

Farvardin
:oops: :oops: :oops: :oops: :oops: :oops: :oops: :oops: :oops:

oh...
yes... :oops:

I read it was about variables several times, but I didn't analyse it correctly...

sorry. :roll:

And thank you for your explanation. :)

GameBoy
i never actually thought about using the #@..# script, i always seem to do things the hard way, grrrr

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums