Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [solved] Help with DFHack - Custom LUA Scripts  (Read 3970 times)

keio

  • Escaped Lunatic
    • View Profile
[solved] Help with DFHack - Custom LUA Scripts
« on: September 29, 2013, 11:11:30 pm »

Hi,

I've been playing around with dfhack custom lua scripts, and I've come across something I'm not entirely sure how to do...

I may just be missing something obvious, but anyway...
It is possible / how do you: pass two parameters?

i.e. In the dfhack console you type in scriptname <param> and it executes the script with that parameter... which is grabbed in the code using "local opt = ..."
Is there some way I can have 2 or 3 params? (eg. scriptname <param> <param>)

Cheers for any assistance,
~ Keio

(P.S. Off topic, but does anyone know why the DF Mantis Bugtracker rego doesn't seem to be sending the confirmation email for registration?)
« Last Edit: September 30, 2013, 12:25:24 am by keio »
Logged

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: Help with DFHack - Custom LUA Scripts
« Reply #1 on: September 30, 2013, 12:12:38 am »

Hi,

I've been playing around with dfhack custom lua scripts, and I've come across something I'm not entirely sure how to do...

I may just be missing something obvious, but anyway...
It is possible / how do you: pass two parameters?

i.e. In the dfhack console you type in scriptname <param> and it executes the script with that parameter... which is grabbed in the code using "local opt = ..."
Is there some way I can have 2 or 3 params? (eg. scriptname <param> <param>)

Cheers for any assistance,
~ Keio

(P.S. Off topic, but does anyone know why the DF Mantis Bugtracker rego doesn't seem to be sending the confirmation email for registration?)
It works like you said "scriptname param param". In script you use "local opt={...}" and then opt[1],opt[2]. Or you could (haven't tested but should work) try this: "local opt1,opt2=...". Also there is another feature if you type ":scriptname param param" then script gets only 1 argument, but it's not parsed in any way. Useful for lua: ":lua print("hello world",df.global.cursor.x, "something else")"

keio

  • Escaped Lunatic
    • View Profile
Re: Help with DFHack - Custom LUA Scripts
« Reply #2 on: September 30, 2013, 12:25:04 am »

It works like you said "scriptname param param". In script you use "local opt={...}" and then opt[1],opt[2]. Or you could (haven't tested but should work) try this: "local opt1,opt2=...". Also there is another feature if you type ":scriptname param param" then script gets only 1 argument, but it's not parsed in any way. Useful for lua: ":lua print("hello world",df.global.cursor.x, "something else")"

Awesome, thanks!

I was trying "opt1 = ..." and "opt2 = ..." which didn't want to cooperate, but "opt1, opt2 = ..." did the trick :D

Thanks for the fast reply too!
Logged