• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

Extending Civ V Lua with Libraries -- Help!

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?
 
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.
 
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.
 
"." 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.
 
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.
 
Back
Top Bottom