Questions for DarkGod (or others)

If you have a module that you'd like comments on or would like to know how to create your very own module, post here

Moderator: Moderator

Message
Author
Grey
Loremaster
Posts: 3517
Joined: Thu Sep 23, 2010 10:18 pm
Location: London, England
Contact:

Re: Questions for DarkGod (or others)

#31 Post by Grey »

Fixed the speed issue. A little new question:

I have a PlayerDisplay that shows an attribute from Player.lua. I have a command to change that attribute. But the PlayerDisplay doesn't update until after a turn is taken. Is there a way to instantly refresh it? I've made a lot of different attempts to call the player display function directly, but none seem to work.
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

Goblinz
Module Developer
Posts: 163
Joined: Tue Dec 14, 2010 3:23 am
Location: Where I need to be

Re: Questions for DarkGod (or others)

#32 Post by Goblinz »

okay I have a question to. how do I remove a equipped item?
my code goes something like this

Code: Select all

local body = self:getInven(self.INVEN_BODY)
		local inven = self:getInven("INVEN")
                --talent code 
               self:removeObject(inven, body[1])
I have tried several things like local inven = self:getInven("INVEN_BODY") and local inven = self:getInven("BODY") but I either get object undefined errors or it does'nt remove the item. any ideas?
Those who complain are just Volunteering to fix the problem

<yufra> every vault designer should ask themselves exactly that: What Would Grey Do?

Grey
Loremaster
Posts: 3517
Joined: Thu Sep 23, 2010 10:18 pm
Location: London, England
Contact:

Re: Questions for DarkGod (or others)

#33 Post by Grey »

Hmm, in the ToME code the arrows when shooting are removed by "a = self:removeObject(self:getInven("QUIVER"), 1)". Can some perversion of that work for you?

I've gotten a bit worn out from coding, in spite of not achieving much yet (or maybe because of it). To help alleviate the strain I've taken a break from coding to make a cool image:

https://sites.google.com/site/darrenjoh ... uerage.png

No more booby lady on my load screen :P
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

BasiC
Higher
Posts: 57
Joined: Thu Mar 01, 2012 6:09 pm

Re: Questions for DarkGod (or others)

#34 Post by BasiC »

A question:
What are the top dev priorities?
What can we expect in the future?
What are you working on now?

Grey
Loremaster
Posts: 3517
Joined: Thu Sep 23, 2010 10:18 pm
Location: London, England
Contact:

Re: Questions for DarkGod (or others)

#35 Post by Grey »

This thread is for questions relating to the development of T-Engine modules (note the subforum this post is in). Questions relating to ToME4 should go in the appropriate forum.
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

bricks
Sher'Tul
Posts: 1262
Joined: Mon Jun 13, 2011 4:10 pm

Re: Questions for DarkGod (or others)

#36 Post by bricks »

For some reason your 7DRL's name cracks me up, Grey. I keep thinking "Rogue Warrior" and "Rogue Rash."

I'm probably not going to finish, both due to lack of experience and an extremely shortened time window. I've decided to call my project Going Rogue, the story of a prominent thief who thinks his gang needs a change of leadership. Unfortunately, it looks like someone called ahead.

Honestly, I'll be shocked if I get further than deleting all the example module stuff and renaming it.
Sorry about all the parentheses (sometimes I like to clarify things).

Grey
Loremaster
Posts: 3517
Joined: Thu Sep 23, 2010 10:18 pm
Location: London, England
Contact:

Re: Questions for DarkGod (or others)

#37 Post by Grey »

Well you may as well start with Run from the Shadow instead of the example module in my opinion. It has inventory and other things set up already, so less work involved. It has various things removed as well though, such as the talent code.

Quick Q from me: How do I turn off a particle effect? I can turn one on well enough, but removing it seems more difficult.
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

yufra
Perspiring Physicist
Posts: 1332
Joined: Tue Jul 13, 2010 2:53 pm

Re: Questions for DarkGod (or others)

#38 Post by yufra »

Grey wrote: Quick Q from me: How do I turn off a particle effect? I can turn one on well enough, but removing it seems more difficult.
Take a look at T_HYMN_OF_SHADOWS. You need to store the return value of the "addParticles" call, and then pass it to the "removeParticles" call.
<DarkGod> lets say it's intended

Grey
Loremaster
Posts: 3517
Joined: Thu Sep 23, 2010 10:18 pm
Location: London, England
Contact:

Re: Questions for DarkGod (or others)

#39 Post by Grey »

Hmm, shoulda thought of that really... Cheers, yufra.

Okay, new question for tiger_eye (you know you like to help :P) - in hex mode, how do I target an action on a specific tile around the player? In cartesian I'd say x+1 (or whatever else) but I'm not so sure with the hex grid. Is it just taking all the grids except x+1 and x-1? Or is it more involved than that?
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

yufra
Perspiring Physicist
Posts: 1332
Joined: Tue Jul 13, 2010 2:53 pm

Re: Questions for DarkGod (or others)

#40 Post by yufra »

Grey wrote: Okay, new question for tiger_eye (you know you like to help :P) - in hex mode, how do I target an action on a specific tile around the player? In cartesian I'd say x+1 (or whatever else) but I'm not so sure with the hex grid. Is it just taking all the grids except x+1 and x-1? Or is it more involved than that?
tiger_eye is definitely your man, but I'll try to clarify a few things before he gets in. The hex mode still uses x+/-1, the interesting behavior is on the y-side. It is something like on the odd x coordinates you use y and y+1 and on the even x coordinates you use y-1 and y. You can write your code in a grid-agnostic fashion, though, by using some of the handy functions created in utils.lua. I took a few minutes to document them, and pasted the results below. I'll guess at a specific use case, though.

Use case
Say you want to get the tile that is in the "9" direction from your current actor's tile. You could do this and have it work in both the square and hex grid modes:

Code: Select all

tx, ty = util.coordAddDir(self.x, self.y, 9)
Documentation

Code: Select all

--- Returns true if using a hex-grid, false otherwise.
function util.isHex()

Code: Select all

--- Converts a direction to an angle.
-- @param dir The numpad direction from the source tile.
-- @param sx The x-coordinate of the source tile.
-- @param sy The y-coordinate of the source tile.
-- @return The angle in degrees.
function util.dirToAngle(dir, sx, sy)

Code: Select all

--- Converts a direction into an absolute map coordinate.
-- @param dir The numpad direction from the source tile.
-- @param sx The x-coordinate of the source tile.
-- @param sy The y-coordinate of the source tile.
-- @return A {x, y} array of the destination tile.
function util.dirToCoord(dir, sx, sy)

Code: Select all

--- Converts an offset map coordinate into a numpad direction.
-- Note that all possible offsets are not valid depending on the grid mode.
-- @param dx The x-offset (-1, 0, 1).
-- @param dy The y-offset (-1, 0, 1).
-- @param sx The x-coordinate of the source tile.
-- @param sy The y-coordinate of the source tile.
-- @return A {x, y} array of the destination tile.
function util.coordToDir(dx, dy, sx, sy)

Code: Select all

--- Returns a table of the directions to the side of the provided direction.
-- @param dir The numpad direction from the source tile.
-- @param sx The x-coordinate of the source tile.
-- @param sy The y-coordinate of the source tile.
-- @return A table with the keys "left", "right", "hard_left", and "hard_right" and the appropriate numpad directions.
function util.dirSides(dir, sx, sy)

Code: Select all

--- Returns the numpad direction opposite the provided direction.
-- @param dir The numpad direction from the source tile.
-- @param sx The x-coordinate of the source tile.
-- @param sy The y-coordinate of the source tile.
-- @return The numpad direction opposite the dir argument.
function util.opposedDir(dir, sx, sy)

Code: Select all

--- Returns the numpad direction between two absolute map coordinates.
-- @param x1 The x-coordinate of the source tile.
-- @param y1 The y-coordinate of the source tile.
-- @param x2 The x-coordinate of the destination tile.
-- @param y2 The y-coordinate of the destination tile.
-- @return The numpad direction from {x1, y1} towards {x2, y2}.
function util.getDir(x1, y1, x2, y2)

Code: Select all

--- A list of adjacent coordinates depending on core.fov.set_algorithm.
-- @param x x-coordinate of the source tile.
-- @param y y-coordinate of the source tile.
-- @param no_diagonals Boolean that restricts diagonal motion.
-- @param no_cardinals Boolean that restricts cardinal motion.
-- @return Array of {x, y} coordinate arrays indexed by direction from source.
function util.adjacentCoords(x, y, no_diagonals, no_cardinals)

Code: Select all

--- Converts a source coordinate + numpad dir into a new absolute coordinate.
-- @param x The x-coordinate of the source tile.
-- @param y The y-coordinate of the source tile.
-- @param dir The numpad direction from the source tile.
-- @return A {x, y} array of the destination coordinate.
function util.coordAddDir(x, y, dir)
<DarkGod> lets say it's intended

Grey
Loremaster
Posts: 3517
Joined: Thu Sep 23, 2010 10:18 pm
Location: London, England
Contact:

Re: Questions for DarkGod (or others)

#41 Post by Grey »

Zonk wrote:
Grey wrote:
6. Adding blood stains to the map on creature death - essentially just recolouring the tiles.
Check BloodyDeath.lua in /engine/interface.lua
Might take some tweaking for what you want to do, though, but I did get it to work time ago.
Even after much fiddling this won't work for me. I even tried copying the code from it into a simple:

Code: Select all

game.level.map(self.x, self.y, engine.Map.TERRAIN, game.level.map(self.x, self.y, engine.Map.TERRAIN):clone{
					color_r=255,color_g=0,color_b=10
				})
But this didn't work.

Yufra's hackier method works, but is a little more dull :(
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

yufra
Perspiring Physicist
Posts: 1332
Joined: Tue Jul 13, 2010 2:53 pm

Re: Questions for DarkGod (or others)

#42 Post by yufra »

Grey wrote: Even after much fiddling this won't work for me. I even tried copying the code from it into a simple:

Code: Select all

game.level.map(self.x, self.y, engine.Map.TERRAIN, game.level.map(self.x, self.y, engine.Map.TERRAIN):clone{
					color_r=255,color_g=0,color_b=10
				})
But this didn't work.

Yufra's hackier method works, but is a little more dull :(
Which is my hackier method? For Blood Arbiter I ended up taking from engine.BloodyDeath and tweaking it a bit. Here is the link to the relevant commit: link.
<DarkGod> lets say it's intended

Grey
Loremaster
Posts: 3517
Joined: Thu Sep 23, 2010 10:18 pm
Location: London, England
Contact:

Re: Questions for DarkGod (or others)

#43 Post by Grey »

Ah, cool! With a bit of tweaking that works. Don't suppose you know how to make the tile symbol colours change too?
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

Grey
Loremaster
Posts: 3517
Joined: Thu Sep 23, 2010 10:18 pm
Location: London, England
Contact:

Re: Questions for DarkGod (or others)

#44 Post by Grey »

Got blood workly nicely now.

New question, since I'm always after more visual polish - how do I add smooth movement and things like knockback moving smoothly?

Also recursive knockback seems to fail on me. I get an error on line 296 of engine/Actor.lua saying "attempt to call local 'recursive' (a boolean value)". Non-recursive knockback works just fine, knockback triggering knockback would be such a fun thing to add...
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Questions for DarkGod (or others)

#45 Post by darkgod »

Recursive knockback, copy the code from field-control/heave the parameter is not a bool it's a function.

Smooth move is very easy. In load.lua you do:

Code: Select all

local Map = require "engine.Map"
Map.smooth_scroll = 3
Then in Actor.lua look for setMoveAnim in ToME's Actor.lua, there is one for :move() and one for knockback. That's all :)
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Post Reply