Advertisement
Civilization Fanatics' Center  

Welcome to Civilization Fanatics' Center.

You are currently viewing our site as a guest which gives you limited access to our site features. By joining our free community, you will be able to participate in the discussions, search the forum, send private messages, vote in polls, upload your own screenshots to the gallery, and access many other special features. Registration is fast, simple and absolutely free, so sign up today! If you have any problems with the registration process or your account login, please contact support.

Go Back   Civilization Fanatics' Forums > CIVILIZATION V > Civ5 - Creation & Customization > Civ5 - SDK / LUA

Notices

Reply
 
Thread Tools
Old Jul 20, 2012, 03:34 PM   #1
3335d
CCtP Player
 
3335d's Avatar
 
Join Date: Jun 2012
Posts: 498
Altering City Radius

Would it be possible to alter the city radius through Lua? Nothing in the XML seems to have anything to do with city radius, so I'm hopeful that the Lua has something I can use. I'm working on a component of the Community Call to Power Project in order to allow food importation without needing the DLL, so making the city radius infinite would be an important step in that. I've already made the necessary XML to deal with other factors involved such as the gold cost and yield losses, so I'm not concerned about that now. Nor am I concerned about the UI for now, as I at least need to get this component off the ground.
3335d is offline   Reply With Quote
Old Jul 21, 2012, 12:59 AM   #2
DonQuiche
King
 
DonQuiche's Avatar
 
Join Date: May 2011
Posts: 946
Unless the radius is stored in the XML files (did you look at gamedefines?), I do not think so. Still there is something that may be worth a try: using LUA to forcefully make the city work hexes beyond the 3-hex radius. I would not bet on your success but it's worth trying.

To clarifying things up a little... Regarding the API, only two functions are relevant: the one to make the city work a tile (city:something), and the one to assign hexes to a city (plot:SetOwner). There is of course no "radius" concept anywhere in the API.
__________________
Reseed! Preview and regenerate map in-game.
Ingame Editor (IGE): An in-game editor for terrain, units, cities, civilizations, etc.
Lua and UI reference
DonQuiche is offline   Reply With Quote
Old Jul 23, 2012, 11:55 AM   #3
3335d
CCtP Player
 
3335d's Avatar
 
Join Date: Jun 2012
Posts: 498
Quote:
Originally Posted by DonQuiche View Post
Unless the radius is stored in the XML files (did you look at gamedefines?), I do not think so. Still there is something that may be worth a try: using LUA to forcefully make the city work hexes beyond the 3-hex radius. I would not bet on your success but it's worth trying.

To clarifying things up a little... Regarding the API, only two functions are relevant: the one to make the city work a tile (city:something), and the one to assign hexes to a city (plot:SetOwner). There is of course no "radius" concept anywhere in the API.
GlobalDefines.xml does not have a <CityRadius> field. Perhaps, then, Firaxis decided to go the easy route and bundle that into the DLL. I'll see what I can do with plot:SetOwner, and then maybe I can enable working tiles with city:something. Perhaps then I can make the food importation feature that I've always wanted....

Thank you DonQuiche. But one more question - in which files can these functions be found?
3335d is offline   Reply With Quote
Old Jul 23, 2012, 12:11 PM   #4
DonQuiche
King
 
DonQuiche's Avatar
 
Join Date: May 2011
Posts: 946
The function to toggle the "worked" flag is city:AlterWorkingPlot. The examples are obviously in the city screen. No idea for setowner, though. I suggest you use notepad++ for its formidable "search in all files" feature (ctrl + shift + f), it totally rocks for civ5 modding (and for text edition in general).

Now you could also look at the IGE code, especially IGE_API_Terrain.lua which contains a function named UpdateOwnership. This function is used anytime a resource is set on a hex to prevent two civ5 bugs (one where the new resource is not completely taken into account unless you remove and add again the ownership, another bug that causes perment yield computations errors if you remove the ownership on a hex worked by a city).

So this function first stores the plots forcefully worked by the city ("forced plots"), then it removes the "worked" flag from this hex, then it removes ownership and adds it again, then it forces the city to reset worked plots to let the AI decides what it thinks is best now, then it restores forced plots. Which means it uses all the functions you could have to use.
__________________
Reseed! Preview and regenerate map in-game.
Ingame Editor (IGE): An in-game editor for terrain, units, cities, civilizations, etc.
Lua and UI reference
DonQuiche is offline   Reply With Quote
Old Jul 23, 2012, 12:47 PM   #5
3335d
CCtP Player
 
3335d's Avatar
 
Join Date: Jun 2012
Posts: 498
I haven't found these functions anywhere in the city screen.

I'm new to Lua, so I really don't know how to program it to perform my desired function. I cannot find anywhere the definition of the function AlterWorkingPlot.

Last edited by 3335d; Jul 23, 2012 at 01:07 PM.
3335d is offline   Reply With Quote
Old Jul 24, 2012, 11:32 AM   #6
Jabberwockxeno
Prince
 
Jabberwockxeno's Avatar
 
Join Date: Jul 2012
Posts: 450
New to modding civ 5, what's the difference between Lua and modbuddy? I thought Lua was the language it used.

Anyways, tell me if something comes out of this, its incredibly annoying to have a tile in between 3 of your cities but not workable by any of them.
Jabberwockxeno is offline   Reply With Quote
Old Jul 24, 2012, 11:42 AM   #7
DonQuiche
King
 
DonQuiche's Avatar
 
Join Date: May 2011
Posts: 946
Quote:
Originally Posted by 3335d View Post
I'm new to Lua, so I really don't know how to program it to perform my desired function. I cannot find anywhere the definition of the function AlterWorkingPlot.
There is no documentation asides of a list of functions. You need to look at the game files and understand things by yourself.

Quote:
Originally Posted by Jabberwockxeno View Post
New to modding civ 5, what's the difference between Lua and modbuddy? I thought Lua was the language it used.
Lua is indeed the proramming language. Modbuddy is the IDE (integrated environment development). If you don't know what an IDE is, it's basically a code editor with additional features that developers need.
__________________
Reseed! Preview and regenerate map in-game.
Ingame Editor (IGE): An in-game editor for terrain, units, cities, civilizations, etc.
Lua and UI reference
DonQuiche is offline   Reply With Quote
Old Jul 24, 2012, 12:06 PM   #8
3335d
CCtP Player
 
3335d's Avatar
 
Join Date: Jun 2012
Posts: 498
Never mind, I found a city radius definition in Defines. However, I still have no idea what file it belongs to, only the database. I'll see if it works.
3335d is offline   Reply With Quote
Old Jul 24, 2012, 03:56 PM   #9
Spatzimaus
Mad Scientist
 
Spatzimaus's Avatar
 
Join Date: Sep 2005
Location: Los Angeles, CA
Posts: 3,062
Quote:
Originally Posted by 3335d View Post
Never mind, I found a city radius definition in Defines.
That value sets the minimum spacing between cities. The radius of tiles worked can't be altered until we get the DLL.
__________________
Once upon a time there was the Ages of Man mod set. Then Firaxis broke it. But thanks to the DLL efforts of the community, the mods shall rise again!
Spatzimaus is offline   Reply With Quote
Reply

Bookmarks

Go Back Civilization Fanatics' Forums > CIVILIZATION V > Civ5 - Creation & Customization > Civ5 - SDK / LUA > Altering City Radius

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Advertisement

All times are GMT -6. The time now is 03:24 PM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
This site is copyright © Civilization Fanatics' Center.
Support CFC: Amazon.com | Amazon UK | Amazon DE | Amazon CA | Amazon FR