• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Need little config support, rather simple

sestorme

Member
Joined
Dec 9, 2011
Messages
272
Reaction score
6
Location
Birmingham, UK
How to stick number to this:
LUA:
local Monsters = {
"Demon" [100],
"Wolf" [200],
}
So I could:

LUA:
        if isInArray(Monsters,getCreatureName(thing.uid)) then
            local omg = "(number from config matching thing.uid name)"

Any clues? I am 100% sure it's possible, but arrays were always my miss :/
 
Remove the comma after:

LUA:
"Wolf" [200],

So:

LUA:
local Monsters = {
"Demon" [100],
"Wolf" [200]
}
 
LUA:
local Monsters = {
	['Demon'] = 100,
	['Wolf'] = 200,
}

local omg = Monsters[getCreatureName(thing.uid)]
if omg then
 
LUA:
local Monsters = {
	['Demon'] = 100,
	['Wolf'] = 200,
}

local omg = Monsters[getCreatureName(thing.uid)]
if omg then

Don't you have to remove the comma at the end of the array?
Otherwise the program is going to think there's more to it when there really isn't.
 
Oh alright, I didn't know that.
I just vaguely remember running into an issue like this before and all I had to do was remove the comma to fix it.
 
Erm,

LUA:
	local tmp = getThingFromPos(toPos)

		if(tmp.uid ~= 0) then
		
			if(isCreature(tmp.uid)) then

				if isInArray(Monsters,getCreatureName(tmp.uid)) then

It is wolf being checked, it fails.
 
which is the same thing I posted above, you're just not storing value of Monsters[creaturename] into a variable
 
Back
Top