Page 1 of 1

I need help with Functions...

Posted: Thu Nov 05, 2009 3:55 am
by Jules
Hey... Before you say to read how to set up Functions, I looked it up, and I understand the basic format... I think, but I need some help still...

I'm making a curing system for Lusternia. One of the things I'm trying to script is a function that takes out a specific purgative vial and drink it, but only if it's not in my inventory. So, here's what I've set up:

Code: Select all

Alias Name: Choleric
Pattern: ^drinkcholeric$
Code: CholericFromPack()

Code: Select all

Script Name: CholericFromPack
Code:
function CholericFromPack()
	if chol.n.pack == 0 then
		send("get choleric from pack;drink choleric")
		chol.n.pack = 1
	else
		send("drink choleric")
	end
end

function CholericInPack()
	if chol.n.pack == 1 then
		send("put choleric in pack")
		chol.n.pack = 0
	end
end
When I type in "drinkcholeric", nothing happens...

I do have all of my vial's individual variables called in the beginning in their own script's, so they should be able to be called... Any help with what I'm doing wrong? Or am I making this WAAY to complicated?

Re: I need help with Functions...

Posted: Thu Nov 05, 2009 10:06 am
by Heiko
I need to see your variable declarations as this is the problem here, so I'm just guessing:

The variable chol.n.pack means in Lua:
The table chol has a member n which is another table which holds the key pack.
This is a special syntax to access table elements.

You can use chol_n_pack as a proper variable name though.