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)

#46 Post by Grey »

Awesome - thanks, DG!
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)

#47 Post by Grey »

Here's a video of how the game looks at the moment:

http://youtu.be/TvJ4sqq_b6A

Will hopefully improve over the next 24 hours...
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

edge2054
Retired Ninja
Posts: 3756
Joined: Fri May 28, 2010 4:38 pm

Re: Questions for DarkGod (or others)

#48 Post by edge2054 »

I'm probably going to have a ton of these UI related questions but here's the first one...


I shamelessly stole the player display code from Rogue Rage and I'm wondering if anyone knows how I'd go about repositioning it. Basically I want to display my resources and zone name at the top of the screen rather then the bottom.

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

Re: Questions for DarkGod (or others)

#49 Post by Grey »

In Game.lua there's a call for PlayerDisplay which sets its position. Just position it at 0,0 instead of 0,h-30 (or whatever it is).

However I should warn that I've had problems in the past with the PlayerDisplay being at the top of the screen ends up interfering with mouse control on the main map screen.
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

edge2054
Retired Ninja
Posts: 3756
Joined: Fri May 28, 2010 4:38 pm

Re: Questions for DarkGod (or others)

#50 Post by edge2054 »

Thanks Grey, it took a bit of finagling (I had to add some arguments to the playerDisplay ini) but this pointed me in the right direction and I got it working :D

http://i.imgur.com/hW9IS.png

Did you ever get smooth fog of war to work?

I also need to figure out how to convert the game log and mini-map into dialogues. Basically I want to keep the log output at the top of the screen and give the player the option to pull up a more verbose log with a hotkey and I want to hide the mini-map inside a hotkey as well. I also need to figure out how to register a more verbose tooltip on keypress (right now it's just the name of the entity with no border, as per the grass in the screen shot with life being represented by the color of the tooltip).

So the basic idea is to replace everything on the bottom with 10 hotkeys and maybe five smaller ones above that to switch stances.

That would be the basic UI (not counting anything like level up dialogues, inventories, and character sheets).

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

Re: Questions for DarkGod (or others)

#51 Post by Grey »

Multiple logs shouldn't be a problem - have one function which outputs to two logs, with conditions of verbosity. I never liked that flasher thing on the top though, myself... I'm not sure any sort of log is needed if you have flyout text, particles effects and sound.

Toggable map I'm less sure about - DarkGod will hopefully be able to instruct.

For smooth FOV your source is tiger_eye.
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)

#52 Post by darkgod »

Just dont display the minimap when you dont need it ;)
[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 ;)

edge2054
Retired Ninja
Posts: 3756
Joined: Fri May 28, 2010 4:38 pm

Re: Questions for DarkGod (or others)

#53 Post by edge2054 »

Grey wrote:Multiple logs shouldn't be a problem - have one function which outputs to two logs, with conditions of verbosity. I never liked that flasher thing on the top though, myself... I'm not sure any sort of log is needed if you have flyout text, particles effects and sound.
Yeah, I ended up ditching the flasher. I'm going to keep the pull up log with control + m so players can refer to it if they feel they miss something important (I kinda want a story which I'll present through emotes and what not, if the player misses those emotes I want a way for them to find out what was said easily).
Toggable map I'm less sure about - DarkGod will hopefully be able to instruct.
hehe.. thanks darkgod :)
For smooth FOV your source is tiger_eye.
Yes... I also need tiger_eye to help me implement auto-explore. Hopefully his current break is shorter then his last break ;) (And I may just leave the mini-map out completely, auto-explore makes it less of a necessity).

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

Re: Questions for DarkGod (or others)

#54 Post by yufra »

edge2054 wrote: Yes... I also need tiger_eye to help me implement auto-explore. Hopefully his current break is shorter then his last break ;) (And I may just leave the mini-map out completely, auto-explore makes it less of a necessity).
I can help out there, what do you need?
<DarkGod> lets say it's intended

edge2054
Retired Ninja
Posts: 3756
Joined: Fri May 28, 2010 4:38 pm

Re: Questions for DarkGod (or others)

#55 Post by edge2054 »

I got it thanks yufra :) However...

What do resolvers do? Like I know how ToME uses them but I tried to make my own and it didn't work how I expected.

Code: Select all

--- Dice roll
function resolvers.success(dice, sides, target)
	return {__resolver="success", dice, sides, target}
end
function resolvers.calc.success(t)
	local successes = 0
	local dice = t[1] or 1
	local sides = t[2] or 6
	local target = t[3] or sides /2 + 1
	for i = 1, dice do
		if rng.dice(1, sides) >= target then
			successes = successes + 1
		end
	end
	return successes
end
So what I wanted was something I could call with resolvers.success(10, 6, 4) from anywhere in the game to get back a number like rng.range would do. But it didn't work.

I wrote a similar function in combat.

Code: Select all

function _M:getSuccesses(dice, sides, target_number)
	local successes = 0
	local dice = dice or 1
	local sides = sides or 6
	local target_number = target_number or sides/2 + 1
	for i = 1, dice do
		if rng.dice(1, sides) >= target_number then
			successes = successes + 1
		end
	end
	print(("[ROLLING] %sd%s against target number %s, successes %s"):format(dice, sides, target_number, successes))
	return successes
end
Which works fine.

I guess I just don't really now what resolvers are for. Can anyone elaborate?

edge2054
Retired Ninja
Posts: 3756
Joined: Fri May 28, 2010 4:38 pm

Re: Questions for DarkGod (or others)

#56 Post by edge2054 »

Alright, I guess I still don't really understand resolvers.

I have the following two resolvers, neither of which works on birth (I did get them to work for an npc so they do function).

Code: Select all

--- Resolves equipment creation for an actor
function resolvers.equip(t)
	return {__resolver="equip", __resolve_last=true, t}
end
--- Actually resolve the equipment creation
function resolvers.calc.equip(t, e)
	print("Equipment resolver for", e.name)
	-- Iterate of object requests, try to create them and equip them
	for i, filter in ipairs(t[1]) do
		print("Equipment resolver", e.name, filter.type, filter.subtype)
		local o
		if not filter.defined then
			o = game.zone:makeEntity(game.level, "object", filter)
		else
			o = game.zone:makeEntityByName(game.level, "object", filter.defined)
		end
		if o then
			print("Zone made us an equipment according to filter!", o:getName())

			-- Auto alloc some stats to be able to wear it
			if filter.autoreq and rawget(o, "require") and rawget(o, "require").stat then
				print("Autorequire stats")
				for s, v in pairs(rawget(o, "require").stat) do
					print(s,v)
					if e:getStat(s) < v then
						e.unused_stats = e.unused_stats - (v - e:getStat(s))
						e:incStat(s, v - e:getStat(s))
					end
				end
			end

			e:wearObject(o, true, false)

			game.zone:addEntity(game.level, o, "object")
		end
	end
	-- Delete the origin field
	return nil
end

--- Resolves inventory creation for an actor
function resolvers.inventory(t)
	return {__resolver="inventory", __resolve_last=true, t}
end
--- Actually resolve the inventory creation
function resolvers.calc.inventory(t, e)
	-- Iterate of object requests, try to create them and equip them
	for i, filter in ipairs(t[1]) do
		print("Inventory resolver", e.name, filter.type, filter.subtype)
		local o
		if not filter.defined then
			o = game.zone:makeEntity(game.level, "object", filter)
		else
			o = game.zone:makeEntityByName(game.level, "object", filter.defined)
		end
		if o then
			print("Zone made us an inventory according to filter!", o:getName())
			e:addObject(e.INVEN_INVEN, o)
			game.zone:addEntity(game.level, o, "object")

			if t[1].id then o:identify(t[1].id) end
		end
	end
	e:sortInven()
	-- Delete the origin field
	return nil
end
Both produce on error similar to this.

Code: Select all

Lua Error: /engine/Birther.lua:46: /data/birth/descriptors.lua:31: attempt to call field 'inventory' (a nil value)
	At [C]:-1 
	At [C]:-1 error
	At /engine/Birther.lua:46 loadDefinition
	At /mod/load.lua:54 
	At [C]:-1 require
	At /engine/Module.lua:159 load
	At /engine/Module.lua:566 instanciate
	At /engine/utils.lua:1681 showMainMenu
	At /engine/init.lua:124 
	At [C]:-1 dofile
	At /loader/init.lua:170 
I have this in my load file..

Code: Select all

-- Additional entities resolvers
dofile("/mod/resolvers.lua")
And my calls look like this.. (which I've tried in the copy table, outside the copy table, with an inventory = in front of it without success).

Code: Select all

		resolvers.inventory{ id=true,
			{type="weapon", subtype="battleaxe", name="iron battleaxe"},
		},
And I can find both resolver functions with the console so they're getting loaded.

Any ideas what I might doing wrong?

edge2054
Retired Ninja
Posts: 3756
Joined: Fri May 28, 2010 4:38 pm

Re: Questions for DarkGod (or others)

#57 Post by edge2054 »

To answer my own question for future module makers...

It's important that when you add your resolver code (shown below) that you put it pretty high up in the load list. I had it after the birther :(

Code: Select all

-- Additional entities resolvers
dofile("/mod/resolvers.lua")

Post Reply