PDA

View Full Version : Lich Scripts



ryaden
10-28-2016, 12:20 PM
I am new to lich scripts and have 2 basic question if anyone call help.

1
I want to reassign script.vars[1] to another variable name. Here is what I tried.

scripts.vars[1] = name

I subsequently tried to use the variable as #{name}

Incidentally I would like to be able to continue to use script.vars[1] and the variable name in the script because I plan to shift the variables with script.vars[1].shift

2.
I would like to use the checkspell function but have been unclear how it functions within the script. Essentially I want to check if a spell is active and then cast it if it isn't. Here is what I tried (unsuccessfully). I am on Avaalon if that makes a different.

if checkspell "presence" == nil
fput "incant 402"
else
end

I appreciate any help that can be provided.

Donquix
10-28-2016, 12:32 PM
I am new to lich scripts and have 2 basic question if anyone call help.

1
I want to reassign script.vars[1] to another variable name. Here is what I tried.

scripts.vars[1] = name

I subsequently tried to use the variable as #{name}

Incidentally I would like to be able to continue to use script.vars[1] and the variable name in the script because I plan to shift the variables with script.vars[1].shift

2.
I would like to use the checkspell function but have been unclear how it functions within the script. Essentially I want to check if a spell is active and then cast it if it isn't. Here is what I tried (unsuccessfully). I am on Avaalon if that makes a different.

if checkspell "presence" == nil
fput "incant 402"
else
end

I appreciate any help that can be provided.

1) you're assigning the variable backwards. In "a = b", you're saying "set the variable a to the value of variable b", so you're trying to set script.vars[1] to the value of "name", rather than setting "name" to the value of "script.vars[1]"

Lich syntax is all ruby, I would highly suggest reading introductory ruby coding guides of which there are many.
https://www.codecademy.com/learn/ruby

2) nil means nothing. checkspell is a boolean (true / false) check, and nil is not equal to false. So your if statement will not evaluate since you are asking "is false equal to nothing", the answer is no because false is not nothing, it's false. Also why do you have the else there? That is completely unnecesarry unless you actually want to do something when your if statement is not met.

if checkspell "presence" == false
<do some shit>
end

you could also do

if not checkspell "presence"
<do some shit>
end

but i generally prefer the more explicit condition.

also you should be posting in the actual lich folder :D

ryaden
10-28-2016, 12:59 PM
1) you're assigning the variable backwards. In "a = b", you're saying "set the variable a to the value of variable b", so you're trying to set script.vars[1] to the value of "name", rather than setting "name" to the value of "script.vars[1]"

Lich syntax is all ruby, I would highly suggest reading introductory ruby coding guides of which there are many.
https://www.codecademy.com/learn/ruby

2) nil means nothing. checkspell is a boolean (true / false) check, and nil is not equal to false. So your if statement will not evaluate since you are asking "is false equal to nothing", the answer is no because false is not nothing, it's false. Also why do you have the else there? That is completely unnecesarry unless you actually want to do something when your if statement is not met.

if checkspell "presence" == false
<do some shit>
end

you could also do

if not checkspell "presence"
<do some shit>
end

but i generally prefer the more explicit condition.

also you should be posting in the actual lich folder :D

thanks! That is a huge help

Donquix
10-28-2016, 08:41 PM
No problem. If you haven't already joined, people on the code channel on lnet (;tune code) tend to be very helpful. But definitely check out the intro to ruby things online, then you can keep your annoying noob (term of endearment! :) questions to the lich specific things, rather then the underlying ruby bits.