Light command: when there's no second object
TriangleGames
28 Dec 2013, 04:08EDIT: After digging around a little, I've noticed that there are two separate commands for "use object" and "use object on|with object." I'm guessing my answer lies there. So, for now, I'm just gonna split up my code into two separate commands. If there's another way to deal with this issue, please let me know for future reference.
I'm making a command for lighting flammable objects like candles, matches, lamps, torches, etc.
In some cases, the object can be lit by itself (a match), in other cases it needs something to ignite it (a candle).
I have everything working fine as long as there are TWO objects put in ("light candle with match"),
but I can't get it to do anything with just one object ("light match"). It always says "I don't understand your command."
I'm not sure if the problem is my basic understanding of command patterns, the way I tried to use "object2 = null," or something else in the script (or all of those things).
I'm using the command pattern setting with the pattern light #object1# with #object2#.
Here's the code for the script:
I'm making a command for lighting flammable objects like candles, matches, lamps, torches, etc.
In some cases, the object can be lit by itself (a match), in other cases it needs something to ignite it (a candle).
I have everything working fine as long as there are TWO objects put in ("light candle with match"),
but I can't get it to do anything with just one object ("light match"). It always says "I don't understand your command."
I'm not sure if the problem is my basic understanding of command patterns, the way I tried to use "object2 = null," or something else in the script (or all of those things).
I'm using the command pattern setting with the pattern light #object1# with #object2#.
Here's the code for the script:
if ((HasAttribute(object1, "flammable") or HasAttribute(object1, "ignite"))) {
if (object2 = null) {
if (HasAttribute(object1, "ignite")) {
do (object1, "ignite")
}
else {
msg ("Light the " + object1.alias + " with what?")
}
}
else {
if (HasAttribute(object1, "ignite")) {
msg ("You realise the " + object1.alias + " is self-lighting.")
do (object1, "ignite")
}
else {
if (Got(object2)) {
if (HasAttribute(object2, "ignite")) {
msg ("You light the " + object1.alias + ".")
}
else {
msg (object2.alias + " cannot light " + object1.alias + ".")
}
}
else {
msg ("You don't have the " + object2.alias + ".")
}
}
}
}
else {
msg ("You can't light the " + object1.alias + ".")
}
HegemonKhan
28 Dec 2013, 05:19I'm not that experienced with Commands yet... but *maybe* this might work:
<command name="blah_lol_too lazy_to_look_at_what_you_called_your_command_lol_err_you_never_did_haha_laughs">
-> <pattern>light #object1# ; light #object1# with #object2#</pattern>
</command>
you may need to take out the spaces to left and right of the semi-colon (I just put the spaces in to make it more visible~notice'able for you in that you're using the semicolon for having two patterns ~ but we'll see if this can be done or not, ie if it works or not, lol)
(and of course you'd need to code~script for or to match with having these two different pattern inputs, if this works, lol)
------------------
some resources:
http://quest5.net/wiki/Command_element
the wiki's "tutorial", the "guides" (the "how to" main wiki page's section~link), and...
also, try looking at some of the libraries with how they use commands too, as maybe they could be relevant to what you want to do or helps in what you want to do.
----------------
also you may be interested in Shadowpile's "Brass Lantern" Library:
viewtopic.php?f=18&t=3743
and there's Sora's Stackable Library as well:
viewtopic.php?f=18&t=3515
enjoy
<command name="blah_lol_too lazy_to_look_at_what_you_called_your_command_lol_err_you_never_did_haha_laughs">
-> <pattern>light #object1# ; light #object1# with #object2#</pattern>
</command>
you may need to take out the spaces to left and right of the semi-colon (I just put the spaces in to make it more visible~notice'able for you in that you're using the semicolon for having two patterns ~ but we'll see if this can be done or not, ie if it works or not, lol)
(and of course you'd need to code~script for or to match with having these two different pattern inputs, if this works, lol)
------------------
some resources:
http://quest5.net/wiki/Command_element
the wiki's "tutorial", the "guides" (the "how to" main wiki page's section~link), and...
also, try looking at some of the libraries with how they use commands too, as maybe they could be relevant to what you want to do or helps in what you want to do.
----------------
also you may be interested in Shadowpile's "Brass Lantern" Library:
viewtopic.php?f=18&t=3743
and there's Sora's Stackable Library as well:
viewtopic.php?f=18&t=3515
enjoy
