• 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 Grizzly Adams Bug

Nobrusz

New Member
Joined
Mar 23, 2014
Messages
48
Reaction score
2
Hello, OtLand.

Recently i have compiled TFS 1.0 10.37 64 bits (as i posted in "Data Packs" for download)
I was testing my server and received the following erros while trying to start tasks in Grizzly Adams:

free image host


I tried to add a 10.35 files of Grizzly Adams to my folder with 10.37 version, but the error keeps the same way.
Could please someone help me?
 

Ok, im gonna try and edit this post later with the answer. (it will take just little while ;)

Edit: It seems that all the links that you sended me, are for older versions. Im using TFS 1.0. You think that it really can fix my problem? (im new on ot creation, but i think that old versions don't solve new versions problem, right?)
 
Last edited:
The message doesn't tell what the underlying cause of your problem is, but there's some useful information there.

npchandler.lua is part of the distribution, You can find it here: \data\npc\lib
It's probably not bugged

Some stuff happened, then -
npchandler.lua called grizzlyadams.lua, function onCreatureSay()
onCreatureSay() "blew up" at line 224 of grizzlyadams.lua
somewhere in that line there's some code that looks like this: tasks[ ... ] (the dots can be anything)
That's an attempt to reference variable "tasks" as an array or a table
It fails because "tasks" doesn't have a value (that's what the "nil" tells you)
It also tells you (because "global") that "tasks" is not defined in grizzlyadams.lua

So Limos suggested you find a compatible "definition for "tasks", and put it somewhere where it will have been executed before grizzlyadams.lua is ever used.

That's a good suggestion, and might well get you up and running.

Still - if you put all this together, it seems you've moved only part of the feature you wanted to your new server.
If you go back to where you got that script from, and look for where "tasks" is defined, there's a good chance you can find the rest of the Grizzly Adams package. The links Limos provided will provide clues as to what pieces are needed, and where they're usually installed.

BTW: Notepad++ (which you absolutely should have - genuine freeware - 15 minutes find/download/install) supports multi-document and multi-file Find (and Replace).
Learn to use it first (top-level menu item "Search"), and then go hunting for the rest of your package.
 
The message doesn't tell what the underlying cause of your problem is, but there's some useful information there.

npchandler.lua is part of the distribution, You can find it here: \data\npc\lib
It's probably not bugged

Some stuff happened, then -
npchandler.lua called grizzlyadams.lua, function onCreatureSay()
onCreatureSay() "blew up" at line 224 of grizzlyadams.lua
somewhere in that line there's some code that looks like this: tasks[ ... ] (the dots can be anything)
That's an attempt to reference variable "tasks" as an array or a table
It fails because "tasks" doesn't have a value (that's what the "nil" tells you)
It also tells you (because "global") that "tasks" is not defined in grizzlyadams.lua

So Limos suggested you find a compatible "definition for "tasks", and put it somewhere where it will have been executed before grizzlyadams.lua is ever used.

That's a good suggestion, and might well get you up and running.

Still - if you put all this together, it seems you've moved only part of the feature you wanted to your new server.
If you go back to where you got that script from, and look for where "tasks" is defined, there's a good chance you can find the rest of the Grizzly Adams package. The links Limos provided will provide clues as to what pieces are needed, and where they're usually installed.

BTW: Notepad++ (which you absolutely should have - genuine freeware - 15 minutes find/download/install) supports multi-document and multi-file Find (and Replace).
Learn to use it first (top-level menu item "Search"), and then go hunting for the rest of your package.
I will try to do it. The only problem is that i understand absolutely NOTHING about lua. (But is always possible to learn xD)
 
If you know how to code in any modern script language, most of Lua is not difficult.
(The main exception to that is "high-end" use of Tables, including the way Lua implements object orientation.)

Anyway, your problem is probably one of two things:
  1. You've copied/installed only part of the feature you want.
    Symptoms are non-existent variables (which show up as "nil" values, scripts that don't get called at all, etc)
  2. You're using a feature designed for an earlier release of OT that the one you're using.
    Same symptoms, but also you see attempts to use old Lua functions which have different names in the newer OT version
Your best move is to check those two things carefully:
  • Go back to where you got the package from, and ask yourself "did I get everything?".
  • If you copied bits and pieces from a complete server, look for the original package and see if there's a a piece you don't have on you server
  • Check (if you can) the source / current OT levels. I've noticed packages tend not to have internal comments explaining this kind of information, which is unfortunate, but do your best :)
If that doesn't help, but you're not in a hurry, let me know here. I'll have a server running this week, and once I have a test environment it will be a lot easier to trace problems.

Let me know if you want to learn some Lua too - I'm thinking of writing a tutorial to complement the ones that are already available, and you might be a good "Guinea Pig" for it :)
 
If you know how to code in any modern script language, most of Lua is not difficult.
(The main exception to that is "high-end" use of Tables, including the way Lua implements object orientation.)

Anyway, your problem is probably one of two things:
  1. You've copied/installed only part of the feature you want.
    Symptoms are non-existent variables (which show up as "nil" values, scripts that don't get called at all, etc)
  2. You're using a feature designed for an earlier release of OT that the one you're using.
    Same symptoms, but also you see attempts to use old Lua functions which have different names in the newer OT version
Your best move is to check those two things carefully:
  • Go back to where you got the package from, and ask yourself "did I get everything?".
  • If you copied bits and pieces from a complete server, look for the original package and see if there's a a piece you don't have on you server
  • Check (if you can) the source / current OT levels. I've noticed packages tend not to have internal comments explaining this kind of information, which is unfortunate, but do your best :)
If that doesn't help, but you're not in a hurry, let me know here. I'll have a server running this week, and once I have a test environment it will be a lot easier to trace problems.

Let me know if you want to learn some Lua too - I'm thinking of writing a tutorial to complement the ones that are already available, and you might be a good "Guinea Pig" for it :)
Man, i really like your way to teach! You should do this tutorial when you're able.
I would like to apologize for my bad english, i was a lot of time without pratice, so, be patient. xD

I tried to go back my version, but it seems that the NPC was bugged anyway.
I recently added a few other things to my server (from a 10.37 source that i found random on github) and this source maded all things work fine.
The only exception is that some actions, movements, creaturescripts and xml need to be put mannualy in order to work properly, so, the GA problem is fixed. Now i have problems with my server when i kill any boss of inquisition or some slimes. TFS show me an error in Arena.lua.
You have any way that we can talk? I have a teamspeak server, skype or even facebook. (Talk directly and giving some permissions to see what really happens, is a lot easier than talk in forums, dont you think?)
 
I'm not set up for "real time" communication yet. Maybe in a month or so, when I've learned a bit more about the rest of OT, and have done some serious scripting (I have a couple of ideas for relatively challenging projects that will either force me to learn a lot about OT ... or maybe break my spirit forever :)

In the meantime, here's the first draft of the introduction to my Lua tutorial (it just sets the scene - nothing about actual coding) ...

It'll be a little while before I write the second section (maybe a week).

In the meantime let me know if the intro works for you.
 
Last edited:
Some background information to "set the scene" for learning Lua for use with OT.

1. Script Languages (like Lua) vs Compiled languages (like C++) (the short version)
Compiled languages can do more, and run much faster than scripts, and have many other more technical benefits as well. But they are a poor choice for dynamic modification of a server environment like OT.

Script languages are (almost) as good as compiled languages for logic, and can call functions (like the OT Lu fUnctions that are implemented in C++) to do things the script language isn't capable of. And unlike a compiled language, you don't need a lot of IT skills to work with scripts.

2. Why Lua?
Lua is very widely used, especially for scripting games. It's also open source, so it doesn't introduce an annoying "Intellectual Capital" issues.
If I'd designed OT I'd have gone with Lua too.

3. How does it work?
You'll have noticed that you don't need to compile Lua scripts. They are very convenient: just modify the .lua file, save it, and you can run it immediately.
It works this way because there's some Lua code (the Lua runtime) running inside your OT server (more or less - the low-level technical detals may vary a little, but aren't relevant anyway).
When told to run a script, OT's Lua code:
  • Checks if the file is new or has been changed - if so, it loads a new copy of the script from the file
  • Interprets the Lua instructions and function calls
  • Does whatever the script tells it to do - most of this leads to calling the OT server runtime to affect things in the game
The Lua runtime can call the OT server because the server's C++ code has a Lua interface coded into it, and it has a bunch of functions that conform to Lua's API requiremeients.
So it's all "simple" (at least to the Lua coder :)
OT sets up the Lua runtime for you, and provides a whole bunch of OT-relevant functions that Lua scripts can call. Lua provides the ability to read script files, figure out what they mean "on the fly", and (if it's told to) interact with the OT server and its environment (map, players, items, etc) in real time.

4. What's Lua and what isn't (exactly) Lua
This is quite important, because the Lua language itself doesn't know anything about OT. Also, while there are C++ functions provided by OT that Lua can call for you, but there are also Lua functions that it can call, and they look the same in a Lua script.
Still, in principle the answer is simple:
  • Lua provides the logic and the data structures
  • OT provides a bunch of Lua-compatible functions (i.e. functions that can be called directly from a Lua script)
One thing to remember: Lua isn't the only helper component. At least one other runtime turns up in scripts: SQL, which is implemented not in Lua, but in your database server (e.g. MySQL). Lua can use SQL to interact with database tables vioa Lua functions (I'm not sure (yet) if these are OT functions or a Lua DB package, but it makes no practical difference to a scripter.

5. Comments on this background information
Some important implications:
  • To use Lua effectively within OT you need to know and understand the range of Lua functions provided by OT
  • Setting up some of the interactions between Lua and the OT server seems complex at first
... but ...
  • The right place to start is still to learn the basic capabilities of the Lua language.
Of course it's possible to modify existing scripts without much Lua knowledge, but sooner or later (usually sooner) you'll run into a problem you can't deal with. It's better to learn enough Lua to read the Lua documentation and existing OT/Lua scripts before you try to make any significant modifications to existing scripts or write new ones.
 
Nice, man. It's really a good "scene" of what it will be!
I'm fixing my server problems. Im trying to put a server the most real as possible (Even with the worthless quests of Tibia), i guess that it will take me a long time and a great job on my way, but, i always wanted it and i will fight for this. Anyway, thank you for the help and the attention! I will try to sleep now. Here are 6 AM and i just ran through the night fixing my server problems. Cya!
 
Back
Top