Using lua console to change zone
Moderator: Moderator
-
- Spiderkin
- Posts: 454
- Joined: Sat May 15, 2010 3:09 am
Using lua console to change zone
I'm trying to mess around with the Far East wilderness map, and I'd like to zip a character there to walk around and admire my handiwork. I figured out how to get the lua console up and running, but I don't know how to make it do anything. Where might I find a list of common commands to help with debugging? Eg, changing zones, granting experience, generating objects, etc.
Re: Using lua console to change zone
If you already have the tome cheating enabled then you can use one of DG's (subject to change) shortcuts key combos. They are in there specifically for testing, and add a few extra flags like invulnrability, ESP, and insane damage that may not be sufficient for your exact situation. You can find the keys in tome/class/Game.lua, and search for "self.key:addCommands". Ctrl+d is the one you probably want, and contains hints as to how to change zone/level and force an increase in character level. If you are going to be repeatedly testing something I suggest you change the Ctrl+d or other key combos to set up exactly your testing situation. Cheers!
<DarkGod> lets say it's intended
-
- Spiderkin
- Posts: 454
- Joined: Sat May 15, 2010 3:09 am
Re: Using lua console to change zone
Thanks! That's going to be very helpful. I ended up changing the human starting dungeon to the Gates of Morning and creating a new human character to explore my Far East map. Now I've got a new question: how do I change the vision radius in the Far East wilderness map? The game defaults to a radius of 20 or so, which makes the fog of war a complete non-issue. I didn't even notice it until today. I want to bring that radius down to 1 or 2, but I'm not having any luck. In zone.lua in the far east folder, I uncommented '-- wilderness_see_radius = 3,' but that didn't do anything. Any ideas?
Re: Using lua console to change zone
I didn't actually know about the "wilderness_see_radius" variable, but a quick recursive grep pointed to the mod/class/Player.lua file, specifically the playerFOV function. Here is more detail than you probably want, for the simple reason that I am not entirely sure what is going on and want to have my logic layed out for you and others to correct as necessary. The engine/interface/ActorFOV:computeFOV has the following documentation:
The playerFOV call when it sees the wilderness_see_radius variable makes two calls to computeFOV. The first call uses self.sight (20) and applies game.level.map.apply to each grid seen. That function call adds a grid to seen/remembers if it is lit (stored in game.level.map.lites). If the wilderness map is lit to start with (probably is) then you will have the full radius 20 vision at this stage. The second call uses wilderness_see_radius and applies game.level.map.applyLite to each grid seen. The applyLite function forces the grid to be seen regardless of its natural lited state (I know it lighted, but I am keeping with the variable naming), but remembers it if there is naturally lit or if it has the "always_remember" flag set (look at arda-fareast.lua... all the tiles should have that flag set). The classic fog of war is that you remember everything, but can only see in a limited radius. In order to emulate that you should use the following code in playerFOV:
That should limit the radius on the wilderness map, forcibly view all grids when you are close and remember them if they are naturally lit. I haven't tested it, though.
Code: Select all
--- Computes actor's FOV
-- @param radius the FOV radius, defaults to 20
-- @param block the property to look for FOV blocking, defaults to "block_sight"
-- @param apply an apply function that will be called on each seen grids, defaults to nil
-- @param force set to true to force a regeneration even if we did not move
-- @param no_store do not store FOV informations
-- @param cache if true it will use the cache given by the map, for the map actor. It can be used for other actors is they have the same block settings
function _M:computeFOV(radius, block, apply, force, no_store, cache)
Code: Select all
if game.zone.wilderness_see_radius then
self:computeFOV(game.zone.wilderness_see_radius, "block_sight", function(x, y, dx, dy, sqdist) game.level.map:applyLite(x, y, fovdist[sqdist]) end, true, true, true)
else
<DarkGod> lets say it's intended