• 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 Individual monster variables

Zothion

Veteran OT User
Joined
Apr 28, 2014
Messages
1,092
Reaction score
394
I have added some custom variables to monster files, like (just an example)
Code:
<myown zone="1" type="2">
and am currently trying to figure out the best way to fetch those variables for various events like onKill/onDeath/onHealthChange, and the best thing i came up with was on server startup going through all monster files and using line:match to find that line then storing them as a table like:
Code:
monsters[monsterName]["zone"] = 1

is there any better way to store/load things like this other than going through every single monster file on startup and storing it like this?
 
I have added some custom variables to monster files, like (just an example)
Code:
<myown zone="1" type="2">
and am currently trying to figure out the best way to fetch those variables for various events like onKill/onDeath/onHealthChange, and the best thing i came up with was on server startup going through all monster files and using line:match to find that line then storing them as a table like:
Code:
monsters[monsterName]["zone"] = 1

is there any better way to store/load things like this other than going through every single monster file on startup and storing it like this?
The only better way is to do that but in C++, like all the other information is loaded to monstertypes. That if you really want the info to be located in the XML files. Otherwise you could just create a table in the library of your server.
 
yes @Codex NG, i use a global table for that right now, only difference is its got another name..
@MatheusMkalo

okay, thanks :)

is it much of a difference doing it in c++ versus loading them up to a global table performance wise?
 
yes @Codex NG, i use a global table for that right now, only difference is its got another name..
@MatheusMkalo

okay, thanks :)

is it much of a difference doing it in c++ versus loading them up to a global table performance wise?
Not really. Sometimes it can be even faster. Ofc the loading time is going to be slower but the indexing is faster.
 
@MatheusMkalo another question, if i want to go through every single file in the entire monster library, would something like this work?
Code:
for dir in io.popen([[dir "data\monster\" /b /aa]]):lines() do
  myfunction('data/monster/'..dir..'')
end
considering the same function but with lib instead of monster seems to go through every file in the lib directories and save them
 
@MatheusMkalo another question, if i want to go through every single file in the entire monster library, would something like this work?
Code:
for dir in io.popen([[dir "data\monster\" /b /aa]]):lines() do
  myfunction('data/monster/'..dir..'')
end
considering the same function but with lib instead of monster seems to go through every file in the lib directories and save them
You can modify this if you want to parse the monster files and save stuff to them
https://otland.net/threads/easily-add-new-stuff-to-all-your-monsters.238344/

Or these
https://otland.net/threads/parsers-for-1-2.238198/

The code is pure lua, and is run in the lua interpreter by default, however you can clean it up and modify it to work with the tfs framework.
 
the system related to this question just required parsing of the files and saving some of the data, but those parsers will definitely come in handy when i need to update all monsters/items for some things :)
 
Back
Top