[lua]quick lua question

starter

Chieftain
Joined
Dec 22, 2011
Messages
14
I'm really naive but interested in lua modding. I just want to know some basic stuff:
If I want it to print "I'm here" each time when a new city is created, can I just use such a
code:

function iamhere()
print("I'm here")
end
Events.SerialEventCityCreated.Add(iamhere)

and save this code as iamhere.lua, put this file in a folder called "testingmod", which is a subfolder in Sid Meier's Civilization5->MODS?

I tried this, but it didn't work at all, even when I checked this mod in the game. Where am I wrong?

I really really appreciate your help!
 
If your not using modbuddy, you'll need to create a *.modinfo file in your mod folder called "testingmod.modinfo"

It's a text file containing info on the mod for the game to read.

see here for an example of that file (and information)

your should include this code in the <EntryPoints> section
Code:
    <EntryPoint type="InGameUIAddin" file="iamhere.lua">
      <Name>Put a name here</Name>
      <Description>Put the description here</Description>
    </EntryPoint>
to tell the game to load your lua file.
 
A great way to understand mods (in addition to reading tutorials here) is to download other people's mods and spend some time looking at the file contents. As Gedemon points out, you will always see a modinfo file.

Unfortunately, one thing that you will see in the modinfo file is that each file has an MD5 value. This is going to prevent you from making your mod by simply text-editing another mod. If you edit an existing Lua file, that file will now need a new MD5 value. There are programs (even web aps, I think) that can get you this value. Modbuddy generates this value for you, in addition to building folders and the modinfo file (and being a good editor for Lua, XML and SQL). So, even though your mod is very small, it may be easiest to learn how to use Modbuddy.
 
The MD5 values are only used during upload to and download from the "mod hub", if the mod is only for personal use you can ignore the MD5 values
 
thank you all. These suggestions are really helpful.
I finally figured it out -- print function will only print on the firetuner. It won't display in the game.
And I need to use modbuddy too, instead of just writing a lua file.


Another question:
Is there any database to find out the arguments for game events? Wiki tells me to print the argument in the firetuner to find out, but it seems too inconvinient...
 
Is there any database to find out the arguments for game events?

Best source is to search the core game and DLC Lua files for the event and see what they use.
 
Thank you. Do you have any recommendations on the software that can be used to search from lots of lua files?
Notepad++ (an excellent text editor for coders) has a built-in feature for that, it's a life-saver for anyone working with a weakly typed language like lua.
Just hit ctrl+shift+f and look at the options.
 
while we're talking text editors here, anyone knows one capable of displaying the same line number of multiple files, whatever text being on the line ?
 
Back
Top Bottom