2 years gone since Kael's Guide, and loads of things has changed. After hours of searching for an answer, I couldn't get even the simplest of Lua script into the game: the simple clock. I understand Lua, there's no problem with its mechanism, I've just had to learn its syntax, since I used Python before. But I can't understand the way Civ 5 treats Lua scripts. I have a Lua script containing the following code:
Which I assume to be a working one, that's why Kael has written such a code.
And of course I've done the XML parts, which controls the label's position on the screen:
Again, the same code by Kael. Seems quite easy, and it went smoothly for me as well. And the last part was well-known for me, for I've done quite a lot Civ 5 XML modding before, so when Kael wrote about the Actions part, and the Content part, I knew what to do. Or at least, I thought so.
So I added an action for clock.xml (the second code, obviously), set it for OnModActivated event, and UpdateDatabase action.
Then tried to add a content with a type of InGameUIAddin, then for both Name and Description, I wrote 'clock', and finally, when I tried to select clock.lua from the drop-down menu, clock.xml showed up instead. I selected that one, then clicked OK. I renamed clock.xml to clock.lua under the 'file' column then, built the solution, built the mod, then started the game, selected the mod, and voilà!, nothing happened.
I've tried several other methods after that failure, importing the lua file to the VFS, didn't work either. I honestly spent hours to work out a solution, yet I couldn't. I hope someone can help me, for I'm confused totally...
Code:
ContextPtr:SetUpdate(function()
local t = os.date("%I:%M");
Controls.ClockLabel:SetString(t);
end);
And of course I've done the XML parts, which controls the label's position on the screen:
Code:
<Context ColorSet="Beige_Black" Font="TwCenMT20" FontStyle="Shadow" >
<Label Anchor="C,T" Offset="0,10" Font="TwCenMT20" ColorSet="Beige_Black_Alpha" FontStyle="Shadow" ID="ClockLabel"/>
</Context>
So I added an action for clock.xml (the second code, obviously), set it for OnModActivated event, and UpdateDatabase action.
Then tried to add a content with a type of InGameUIAddin, then for both Name and Description, I wrote 'clock', and finally, when I tried to select clock.lua from the drop-down menu, clock.xml showed up instead. I selected that one, then clicked OK. I renamed clock.xml to clock.lua under the 'file' column then, built the solution, built the mod, then started the game, selected the mod, and voilà!, nothing happened.
I've tried several other methods after that failure, importing the lua file to the VFS, didn't work either. I honestly spent hours to work out a solution, yet I couldn't. I hope someone can help me, for I'm confused totally...
