DoAfter

Posted by Mistrandir The White on Wed 26 Apr 2006 01:51 AM — 10 posts, 31,802 views.

#0
Alright, I know next to absoloutly nothing about scripting. I'm attempting to use a DoAfter, but I keep recieving an error.

Lets say I want to 'look' after I see 'You nod.' What would I put as a trigger? I've tried DoAfter 6, "look" as the send and You nod. as the trigger.

What I see is:

Error number: 0
Event: Compile error
Description: [string "Trigger: "]:1: `=' expected near `3'
Called by: Immediate execution

If this is unbelivebly easy, I give you permission to laugh, sneer, jest and make fun of me, just please help me fix the problem.
#1
Alright, all I want is two scripts that does this:

Trigger:
You are successful at weaving a grass headband.

Send:
(seven seconds after)drop headband
(three seconds later)get grass
(two seconds latter)weave grass headband

and

Trigger:
You mess up while weaving a grass headband.

Send:
(five seconds later)get grass
(two secnds later)weave grass headband

I'm using Lua, and can change it if you want.
Australia Forum Administrator #2
It helps if you paste your whole trigger in, see this post:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4776

I couldn't see how you got the error "`=' expected near `3'" when there is no "3" in your example. I guess you changed it from 3 to 6 at some stage?

Anyway, in Lua, function arguments need to be in brackets, unless you have a single string, or a table constructor, as the argument.

eg.


Note "hello" --> is ok
Note ("hello") --> also works
DoAfter (6, "look") --> must have brackets here

tprint {"a", "b", "c"} --> this works, argument is a table
tprint ({"a", "b", "c"}) --> also works

Note [[
I am doing a multi-line
note here and don't
need brackets ]]


The trigger which works for me is:


<triggers>
  <trigger
   enabled="y"
   match="You nod."
   send_to="12"
   sequence="100"
  >
  <send>DoAfter (6, "look")</send>
  </trigger>
</triggers>

Amended on Wed 26 Apr 2006 06:52 AM by Nick Gammon
Australia Forum Administrator #3
For your second question, this is how I would do it:


<triggers>
  <trigger
   enabled="y"
   match="You are successful at weaving a grass headband."
   send_to="12"
   sequence="100"
  >
  <send>
DoAfter (7, "drop headband")
DoAfter (10, "get grass")
DoAfter (12, "weave grass headband")
</send>
  </trigger>
</triggers>


I'm sure you can work out the other one yourself. :)
Australia Forum Administrator #4
The examples in the online documentation (which is identical to the help file) have the brackets. It is always useful to start with one of the examples there if you are getting syntax errors:

http://www.gammon.com.au/scripts/doc.php?function=DoAfter
#5
Ah, you lost me right about when you said eg... but, luckily, I am smart enough to copy and paste, yet it dosen't seem to work. I copied and pasted the scripts directly from you, and it should have worked. I turned scripting off and got a echo from the client stating: Send-to-script cannot execute because scripting is not enabled. So, it should have worked. Nothing happened, however. I also tried putting diffrent times in, with little luck.
Australia Forum Administrator #6
Please show us your actual trigger by copying it from the trigger list and pasting here. Read this post:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4776


Quote:

I copied and pasted the scripts directly from you, and it should have worked


Can you be more specific? In what way did it not work? Error message? What was that message? Simply didn't work?
#7
<triggers>
<trigger
enabled="y"
match="You are successful at weaving a grass headband."
send_to="12"
sequence="100"
>
<send>DoAfter (7, "drop headband")
DoAfter (10, "get grass")
DoAfter (12, "weave grass headband")
</send>
</trigger>
</triggers>

<triggers>
<trigger
enabled="y"
match="You mess up while weaving a grass headband."
send_to="12"
sequence="100"
>
<send>DoAfter (5, "get grass")
DoAfter (7, "weave grass headband")
</send>
</trigger>
</triggers>
---
No error message... it just didn't respond to them at all. When I turned the scrip off, it did, however.
Australia Forum Administrator #8
So the trigger fires? Edit each one and you should see a "fire count" which is greater than zero.

Have you turned timers off in the timer configuration screen? DoAfter actually creates a temporary timer. If you have turned timers off then nothing will happen.
#9
Ah, that was it. I turned them on and about 100 lines of text hit me.

Thank you for your time, I appreciate it.