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

C++/Lua Request Thread

Discussion in 'Civ5 - SDK / LUA' started by Nefliqus, Jun 11, 2012.

  1. Hambil

    Hambil Emperor

    Joined:
    Oct 16, 2006
    Messages:
    1,100
    Would it be possible to add the missing events for Building Constructed and Building Destroyed - like for roads and improvements? I have no idea why it isn't there in the first place...
     
  2. Hambil

    Hambil Emperor

    Joined:
    Oct 16, 2006
    Messages:
    1,100
    Never mind, the one for improvements doesn't even do what I would expect. No wonder none of this is making sense to me. It's all about graphics events and when stuff is drawn or becomes visible. Where's the beef?
     
  3. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,533
    Location:
    Near Portsmouth, UK
    GameEvents.Anything() trigger in response to events within the game core for all players - typically these are the ones you want

    Events.SerialEventAnything() trigger when the visible map needs to be updated - typically these are no use whatsoever (as they won't trigger for the AI players unless the human player has revealed the plot they happen on)

    RESOURCE_COW ;)
     
  4. SMonetathchi

    SMonetathchi Chieftain

    Joined:
    Feb 22, 2009
    Messages:
    2
    Location:
    SW Oklahoma, USA
  5. Hambil

    Hambil Emperor

    Joined:
    Oct 16, 2006
    Messages:
    1,100
    Taken from tutorial:
    "A good idea in theory would be to detect when the user is going to save his game so that you only write data at this point. Unfortunately there is no event for this circumstance"

    That's insane! I am supposed to do database writes to presist data on every do turn? Is there a DLL fix for this performance nightmare?
     
  6. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,533
    Location:
    Near Portsmouth, UK
    You can always hack the Lua to intercept the Save button click ... from multiple menus. And don't forget auto-save and quick save ... and save to cloud ... and probably a few others I've forgotten.
     
  7. Hambil

    Hambil Emperor

    Joined:
    Oct 16, 2006
    Messages:
    1,100
    Ah yes, nothing like handling things all the hell all over the place instead of at some clean pinch point :)
     
  8. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,533
    Location:
    Near Portsmouth, UK
    You forgot "or copy-and-paste instead of using functions". And what's really sad is that the C++ is no better than the Lua
     
  9. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,533
    Location:
    Near Portsmouth, UK
    No. As the save code (UI.SaveGame()) is in the UI DLL and we don't have the source code for that
     
  10. Hambil

    Hambil Emperor

    Joined:
    Oct 16, 2006
    Messages:
    1,100
    Code:
    UI.SaveGame( Controls.NameBox:GetText() );
    There is a UI.SaveGame()

    If this lua engine supports it we might could override that in lua and screw the DLL...

    lua Inheritance Tutorial
     
  11. Hambil

    Hambil Emperor

    Joined:
    Oct 16, 2006
    Messages:
    1,100
    Dang, I guess I don't understand how he lua to cpp bridge works. We don't need an include to use globals like UI should have been my first clue.
     
  12. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,533
    Location:
    Near Portsmouth, UK
    UI is a C++ object with a Lua wrapper, not a Lua object
     
  13. Pazyryk

    Pazyryk Deity

    Joined:
    Jun 13, 2008
    Messages:
    3,584
    At the bottom of this post is a file called ExampleMain.lua. It shows how to intercept the 4 gamesave types in Lua: cntl-S, save from menu, F11 quicksave, and endturn for autosave (now coded for every turn but could perhaps be changed to reflect user autosave setting). It's slightly strange for the user at first because cntl-S and save from menu don't take you to the save menu, but instead save the game (with a Lua generated name) and give a notification in game. I would assume though that the save menu is a typical UI lua/xml system that could be triggered -- I just haven't gotten around to that yet. I use this to drive my TableSaverLoader.
     
  14. Hambil

    Hambil Emperor

    Joined:
    Oct 16, 2006
    Messages:
    1,100
    That would do it. I thought maybe UI *was* a lua wrapper to a C++ UI object.
     
  15. Irkalla

    Irkalla ENTP POWWWEEEEEER

    Joined:
    Sep 25, 2012
    Messages:
    1,009
    Location:
    Way down around Vicksburg
    How can I intercept clicks like these?
     
  16. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,533
    Location:
    Near Portsmouth, UK
    Pretty sure the TableSaverLoader mod utils do this, so that would be a good place to find some examples.

    Other than that, you just need to find the Lua files with those functions in, copy them to your mod, set VFS=true, and then make any required edits to do what you need to do in addition to the standard stuff
     
  17. croxis

    croxis Chat room op

    Joined:
    Dec 17, 2001
    Messages:
    3,277
    Location:
    Portland, OR, US
    Sockets. All I want is just a basic tcp socket.
     
  18. Genghis.Khan

    Genghis.Khan Person

    Joined:
    Jun 9, 2012
    Messages:
    934
    Location:
    Somewhere
    Methods to Add :c5faith: :c5culture: and :c5happy: (How impossible is it?)

    Code:
    City.ChangeBaseYieldRateFromMisc(GameInfoTypes.YIELD_FAITH, LOCAL_NAME)
    City.ChangeBaseYieldRateFromMisc(GameInfoTypes.YIELD_CULTURE, LOCAL_NAME)
    City.ChangeBaseYieldRateFromMisc(GameInfoTypes.YIELD_HAPPINESS, LOCAL_NAME)
     
  19. Leugi

    Leugi Supreme Libertador

    Joined:
    Jan 25, 2013
    Messages:
    1,675
    Location:
    Bolivia
    I have a request, a way of making specialists actually yield faith. Right now the mechanic for specialists is hard coded so neither culture nor faith may be yielded from Specialists, even if you do declare it via database (either through xml or sql), with culture it isn't such an isse, as there's a different tag that allos Artists to generate culture, but there's no way of making a specialist yield religion via xml or sql.
     
  20. mrc2022

    mrc2022 Capitão Rolinho

    Joined:
    Sep 2, 2012
    Messages:
    346
    Gender:
    Male
    Location:
    Portugal
    I've two requests

    1. I'm making a barbarian civ and they should be able to build barbarian camps, now to generate units I would need a lua code for that...

    2. Is it possible to increase a tile yield if there is a road in the tile? PS: Got it, didn't saw it on the xml...

    Just le me know ;)
     

Share This Page