1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Extending Civ V Lua with Libraries -- Help!

Discussion in 'Civ5 - SDK / LUA' started by croxis, Oct 1, 2010.

  1. croxis

    croxis Chat room op

    Joined:
    Dec 17, 2001
    Messages:
    3,277
    Location:
    Portland, OR, US
    I am attempting to add LuaSockets to try and implement in game IRC chat (and maybe xmpp or AIM down the road). Following Kael's excellent guide I set everything up in ModBuddy, installed the libraries to the mod's Lua folder. However when I call the basic line socket = require("socket") I obtain this output in the live tuner

    Runtime Error: [string "Lua/irc.lua"]:5: atempt to call global 'require' (a nil value)

    When plugging in socket = requires("socket") directly I get module socket not found, and lists all the path lua hunts for. I am not familiar with lua at all. Any suggestions?
     
  2. csebal

    csebal Chieftain

    Joined:
    Jun 19, 2005
    Messages:
    25
    I'm fairly sure, that the modules required for that script are not built into CIV, so the scripts obviously can't access it either. I think you are pretty much out of luck until the actual game dll SDK is released.
     
  3. ArgentumStudios

    ArgentumStudios Warlord

    Joined:
    Sep 18, 2010
    Messages:
    122
    Location:
    Utah, US
    Is the path to your module in the list printed by the loaders when you manually entire the requires in Tuner?

    You could manually load the library pusing packages.loadlib(). The syntax and more info about how Lua handles modules is at: http://www.lua.org/manual/5.1/manual.html#5.3

    I'll poke around at trying to do this after I finish up a couple other tasks I need to do early this week.
     
  4. croxis

    croxis Chat room op

    Joined:
    Dec 17, 2001
    Messages:
    3,277
    Location:
    Portland, OR, US
    The only path that I can see that is even close is ./irc.lua, but I am not sure what ./ is. I can't seem to find anything in the manual to spit the absolute path for it?
     
  5. EmperorFool

    EmperorFool Deity

    Joined:
    Mar 2, 2007
    Messages:
    9,633
    Location:
    Mountain View, California
    "." means the current directory and so "./irc.lua" means the file named "irc.lua" in the current directory. The "./" typically forces (or just reminds the developer) to use a relative path. Many systems treat "irc.lua" and "./irc.lua" as the same thing, but it depends on the library that's looking for the file.

    For example, in PHP if you require a file starting with "./" it will ignore the library path and only look in the current working directory, IIRC.
     
  6. croxis

    croxis Chat room op

    Joined:
    Dec 17, 2001
    Messages:
    3,277
    Location:
    Portland, OR, US
    I know that ./ means the current directory, but I don't know what the interpriter thinks the current directory is.

    What I am finding interesting is that "require" is nil when the script is loaded. But manual entry "require" exists.
     
  7. EmperorFool

    EmperorFool Deity

    Joined:
    Mar 2, 2007
    Messages:
    9,633
    Location:
    Mountain View, California
  8. croxis

    croxis Chat room op

    Joined:
    Dec 17, 2001
    Messages:
    3,277
    Location:
    Portland, OR, US
    Nope, using include throws a require error as well.
     

Share This Page