• 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 Lua Environment on TFS

Stellow

C++/C#/PHP/LUA
Joined
Oct 23, 2008
Messages
1,106
Reaction score
214
Location
Germany
GitHub
eubrunomiguel
I have created a script, in which the functions are located in /lib and the others scripts /actions for example interact with them,

Keep in mind that I have done the exactly same thing on the past.

The script worked perfectly on my pc, but when I sent to a linux machine, for some reason the /action cannot locate the config table on /lib, but the talkaction can.

Script files:

/lib/arena_config
Code:
Arena = {
            [1] =     {                    
                        ENTRANCE_FEE = {-1000, -2000, -3000},
                        MAXTIME_WAVE = {60, 60, 60},
                        LEVEL_REQUIREMENT = {100, 150, 200},
[...]

/lib/arena_entrance
Code:
function isArenaPlayerOverRequirement(cid, level, difficult)
    local playerLevel = getPlayerLevel(cid)
    local arena = Arena[level]
    local levelRequirement = arena.LEVEL_REQUIREMENT[difficult]
    if playerLevel >= levelRequirement then
[...]

/action/arenajoin
Code:
local function joinArenaWaitList(cid)
    if not isArenaActive(ArenaLevel) then
        if isArenaPlayerOverRequirement(cid, ArenaLevel, ArenaDifficult) then
            [...]

Error:
4qM3iez.png


Obs:
All parameters has been checked before and after entering the function. It seems like it cannot locate the table, even if I use the table on the same file.

Suggestions?
 
print these values
ArenaLevel, ArenaDifficult

Maybe you aren't sending the correct values, its always best to check if the value exist before using it.
 
print these values
ArenaLevel, ArenaDifficult

Maybe you aren't sending the correct values, its always best to check if the value exist before using it.

I have checked the values before entering the function, and after entering the function. In fact, I even tried to call the function with number (cid,1,1). I called from actions, and from talkactions. Actions gives me this error, and talkaction works fine. Isn't this weird?
 
I have checked the values before entering the function, and after entering the function. In fact, I even tried to call the function with number (cid,1,1). I called from actions, and from talkactions. Actions gives me this error, and talkaction works fine. Isn't this weird?
It shouldn't be happening this, tested here and it works (the environments are still separated so values assigned in one environment wont be available in the other but the values in the lib are properly loaded in every environment.)

You can add this to data/actions/lib/actions.lua it will force loading them:
Code:
dofile('data/lib/arena_config.lua')
dofile('data/lib/arena_entrance.lua')
 
It shouldn't be happening this, tested here and it works (the environments are still separated so values assigned in one environment wont be available in the other but the values in the lib are properly loaded in every environment.)

You can add this to data/actions/lib/actions.lua it will force loading them:
Code:
dofile('data/lib/arena_config.lua')
dofile('data/lib/arena_entrance.lua')
I thought about that too but I wanted to give em the benefit of doubt :p
 
It shouldn't be happening this, tested here and it works (the environments are still separated so values assigned in one environment wont be available in the other but the values in the lib are properly loaded in every environment.)

You can add this to data/actions/lib/actions.lua it will force loading them:
Code:
dofile('data/lib/arena_config.lua')
dofile('data/lib/arena_entrance.lua')
The script still working on the windows, but on the other machine it isn't. Any other suggestion?
 
Maybe this will be helpful
http://stackoverflow.com/questions/24327452/declaring-global-variable-inside-a-function-in-lua

Even if you aren't exactly sure what the problem is, try using a search engine to determine the problem, chances are high someone else has had the same or similar issue(s) as well.

I went into google and typed "linux server can't see global variables lua" and chose the 1st link that came up due to stackoverflowing.com being a well known q & a site for technical issues :)

If the solution provided doesn't work, you try something else, this what is known as "process of elimination", eventually after several steps/test you find your solution.

Even if you know this already, this explanation is meant for those who don't :)
 
Last edited:
The script still working on the windows, but on the other machine it isn't. Any other suggestion?
Most likely the environment of actions is bugged, I bet it won't load anything you put in libs.
You can put the dofiles inside the action script, that way it has to load it.
 
is there a chance that there is another global variable in your actions enviroment named "Arena"? try renaming "Arena" to something like "event_Arena", "local arena = event_Arena[level]" and try
 
Back
Top