New lines inside AddTimer()?

Posted by Zolomon on Mon 04 Jul 2011 06:55 PM — 3 posts, 15,402 views.

#0
Hello!

When I try to execute the following lua code at http://pastebin.com/fNcnp7c7, the code I wish to pass forward to the script engine does not seem to get entered on separate lines - everything ends up in one line.

What am I doing wrong?

I just wish to add a timer, from within my script file, that executes something on the script engine.
USA Global Moderator #1
Use semicolons instead to indicate the end of lua statements.
Australia Forum Administrator #2
Try using the square-bracket literals, eg.


AddTriggerEx(
"fighting",
"(You prepare to attack|moves aggressively towards you!|Noting the intentions)",
[[
  isFighting = false
  print(isFighting)
  AddTimer(\"timer_fighting\", 0, 0, 0.5 + math.random(3000)/10,
      \"print(\"FIGHTING!\")\",
      timer_flag.Enabled + timer_flag.OneShot, \"\")",
]]
      trigger_flag.Enabled, 0, 0, "", "", 12, 0)


(Untested)

You might be better off using AddXML:

http://www.gammon.com.au/forum/?id=7123

But honestly, adding triggers on the fly that add timers on the fly tends to indicate you are not doing things the most efficient way.

You can just enable or disable existing triggers or timers (or groups of them) - you may find that much easier to work with.