Page 1 of 1

Code dump with last messages displayed

Posted: Sat Jul 03, 2010 10:22 pm
by shani
I wonder if you would be intersted in putting the last messages in the dump. It already works on my local version
As you can
It did require a small function to be added in LogDisplay.lua (engine file)

Code: Select all

  [Tome 4.00 @ www.te4.org Character Dump]

Sex              : Male         STR:  14
Race             : Hobbit       DEX:  29
Class            : Slinger      MAG:  10
Level            : 7            WIL:  10
Exp              : 2%           CUN:  20
Gold             : 3.55         CON:  12

Attack(Main Hand):  39          Life             :     181/181  Encumbrance      : 49/65
Damage(Main Hand):   4          Stamina          :     118/118  Difficulty       : Normal
APR   (Main Hand):   0          
Crit  (Main Hand):   5%         
Speed (Main Hand): 0.80         

Fatigue          : 7%           Spellpower       : 10
Armor            : 3            Spell Crit       : 5.5%
Class            : 14.65        Spell Speed      : 1
Class            : 14.65        


Physical Resist  : 7.125
Spell Resist     : 5.625
Mental Resist    : 8.125

Nature Resist:  10%

Number of NPC killed: 128
Most killed NPC: giant brown mouse (9)

  [Talents/Skills Chart]

 - Technique / Archery - slings       (mastery 1.30)
    Sling Mastery (talent)            5/10
    Eye Shot (talent)                 1/5
    Inertial Shot (talent)            0/5
    Multishot (talent)                0/5
 - Technique / Archery - common       (mastery 1.30)
    Steady Shot (talent)              1/5
    Aim (talent)                      0/5
    Rapid Shot (talent)               0/5
    Critical Shot (talent)            0/5
 - Technique / Archery - utility      (mastery 1.30)
    Ammo Creation (talent)            1/5
    Crippling Shot (talent)           2/5
    Pinning Shot (talent)             0/5
    Scatter Shot (talent)             0/5
 - Technique / Combat techniques      (mastery 0.90)
    Precise Strikes (skill)           0/5
    Rush (skill)                      0/5
    Perfect Strike (skill)            0/5
    Blinding Speed (skill)            0/5
 - Technique / Combat training        (mastery 1.30)
    Heavy Armour Training (skill)     0/5
    Massive Armour Training (skill)   0/5
    Health (skill)                    0/5
    Weapon Combat (skill)             4/10
    Sword Mastery (skill)             0/10
    Axe Mastery (skill)               0/10
    Mace Mastery (skill)              0/10
    Knife Mastery (skill)             0/10
 - Cunning / Survival                 (mastery 1.00)
    Trap Detection (skill)            1/5
    Heightened Senses (skill)         1/5
    Trap Disarm (skill)               0/5
    Evasion (skill)                   0/5

  [Current Effects]


  [Active Quests]

 -- Of trolls and damp caves
Explore the caves below the tower of Amon S?l and the trollshaws in search of treasure and glory!

   * You must explore Amon S?l and find out what lurks there and what treasures are to be gained!   
   * You have explored the Trollshaws and vanquished the Bill the Stone Troll.   

  [Character Equipment]

 In main hand
a) rough leather sling
   Type: weapon / sling
    0 Power [Range 1.10] (), 0 Attack, 0 Armor Penetration, Crit 0%
    Firing range: 8
    
 In off hand
 On fingers
b) copper ring of dexterity (+2)
   Type: jewelry / ring
    Increases stats: 2 Dexterity.
c) copper ring of defense (5 def, 0 armor)
   Type: jewelry / ring
    Armor 0, Defense 5
 Around neck
d) copper amulet of cunning (+2)
   Type: jewelry / amulet
    Increases stats: 2 Cunning.
 Light source
e) bright brass lantern of clear sight
   Type: lite / lite
    Increases blindness immunity: 50%.
    Light radius 3
 Main armor
f) rough leather armour of nature resistance (1 def, 2 armor)
   Type: armor / light
    Armor 2, Defense 1
    Fatigue 6%
    Increases resistances: 10% nature.
 On head
 On hands
 On feet
g) pair of rough leather boots (0 def, 1 armor)
   Type: armor / feet
    Armor 1, Defense 0
    Fatigue 1%
 Tool
 Quiver
h) 63 iron shot (8.5-10.2 power, 1 apr)
   Type: ammo / shot
    8 Power [Range 1.20] (+70% Dexterity,+50% Cunning), 0 Attack, 1 Armor Penetration, Crit 4%
    

  [Character Inventory]

a) Blood of Life
   Type: potion / potion
    It can be used to quaff the Blood of Life.
b) acid-proof potion of lesser healing
   Type: potion / potion
    It can be used to heal some life.
c) giant potion of greater healing
   Type: potion / potion
    It can be used to heal a lot.
d) 2 giant potion of lesser healing
   Type: potion / potion
    It can be used to heal some life.
e) 2 potion of cure poison
   Type: potion / potion
    It can be used to cure poison.
f) 14 potion of lesser healing
   Type: potion / potion
    It can be used to heal some life.
g) potion of lesser mana
   Type: potion / potion
    It can be used to restore some mana.
h) potion of see invisible
   Type: potion / potion
    It can be used to sense invisible for a while.
i) potion of slime mold juice
   Type: potion / potion
    It can be used to quaff.
j) 2 long scroll of identify
   Type: scroll / scroll
    It can be used to identify one object (or all with high magic stat).
k) 14 scroll of identify
   Type: scroll / scroll
    It can be used to identify one object (or all with high magic stat).
l) 5 scroll of light
   Type: scroll / scroll
    It can be used to light up the surrounding area.
m) scroll of magic mapping
   Type: scroll / scroll
    It can be used to map the area directly around you.
n) 20 scroll of phase door
   Type: scroll / scroll
    It can be used to teleport you randomly over a short distance.
o) scroll of teleportation
   Type: scroll / scroll
    It can be used to teleport you anywhere on the level, randomly.
p) elm staff
   Type: weapon / staff
q) shimmering linen robe of lightning resistance (0 def, 0 armor)
   Type: armor / cloth
    Increases resistances: 10% lightning.
    Maximum mana 10
r) iron shot (8.5-10.2 power, 1 apr)
   Type: ammo / shot
    8 Power [Range 1.20] (+70% Dexterity,+50% Cunning), 0 Attack, 1 Armor Penetration, Crit 4%
    
s) 184 iron shot (8.5-10.2 power, 1 apr)
   Type: ammo / shot
    8 Power [Range 1.20] (+70% Dexterity,+50% Cunning), 0 Attack, 1 Armor Penetration, Crit 4%
    
t) citrine
   Type: gem / yellow

  [Last Messages]

Wolf hits Che for    6.00 physical damage   .
War bear hits Che for    17.00 physical damage   .
   Talent Steady Shot is ready to use.
Wolf hits Che for    5.00 physical damage   .
Che is not stunned anymore.
Che shoots!
Che hits war bear for    29.00 physical damage   .
Wolf hits Che for    5.00 physical damage   .
Che shoots!
Che hits war bear for    29.00 physical damage   .
Che killed war bear!
Wolf misses Che.
Che uses Steady Shot.
Che hits wolf for    66.44 physical damage   .
Wolf hits Che for    5.00 physical damage   .
Che shoots!
Che hits wolf for    36.00 physical damage   .
Che killed wolf!
Steady Shot is still on cooldown for 1 turns.
Che shoots!
Che hits war bear for    29.00 physical damage   .
   Talent Steady Shot is ready to use.
Che uses Steady Shot.
Che hits war bear for    49.83 physical damage   .
Che shoots!
Che hits war bear for    29.00 physical damage   .
Steady Shot is still on cooldown for 1 turns.
Che shoots!
Che hits war bear for    28.00 physical damage   .
   Talent Steady Shot is ready to use.
Che uses Steady Shot.
Che hits war bear for    44.84 physical damage   .
Che shoots!
Che hits war bear for    28.00 physical damage   .
Che killed war bear!
   Welcome to level 7.
You have 3 stat point(s) to spend. Press G to use them.
You have 1 talent point(s) to spend. Press G to use them.
You have 1 skill point(s) to spend. Press G to use them.
Steady Shot is still on cooldown for 1 turns.

Re: Code dump with last messages displayed

Posted: Tue Jul 06, 2010 12:49 am
by darkgod
What change ?

Re: Code dump with last messages displayed

Posted: Tue Jul 06, 2010 5:06 am
by shani
Sorry about the subject, I was a little tired... :)
The change to LogDisplay.lua is:

Code: Select all

-- Get Last Lines From Log
-- @param number number of lines to retrieve
function _M:getLines(number)   
	local from = number
	if from > #self.log then from = #self.log end
	local lines = { }
	for i = from, 1, -1 do
 		lines[#lines+1] = self.log[i]
  	end
	return table.concat(lines, "\n")
end
If you approve I'll send you the change to the character dump that uses this function.

Re: Code dump with last messages displayed

Posted: Tue Jul 06, 2010 7:48 am
by darkgod
Yup:)
Just make it return the lines table instead of the concat of it, this way the caller is more free to do as he wishes

Re: Code dump with last messages displayed

Posted: Tue Jul 06, 2010 8:44 am
by shani
I realy need a way to post patches to your code, posting the whole character dump function :)

this comes right before the fff:close()

Code: Select all

	nl()
	nl("  [Last Messages]")
	nl()
	
	nl(table.concat(game.logdisplay:getLines(40), "\r"):gsub("#.-#", "   "))
And The function from logdisplay.lua:

Code: Select all

-- Get Last Lines From Log
-- @param number number of lines to retrieve
function _M:getLines(number)   
	local from = number
	if from > #self.log then from = #self.log end
	local lines = { }
	for i = from, 1, -1 do
 		lines[#lines+1] = self.log[i]
  	end
	return lines
end

Re: Code dump with last messages displayed

Posted: Tue Jul 06, 2010 11:38 am
by darkgod
Well, send me a diff :)

In a command line: diff -u file1 file2
Under windows: dunno but it is probably possible :)

Re: Code dump with last messages displayed

Posted: Sun Jul 11, 2010 6:26 pm
by shani
I hope this is the right way to do a diff file.... I did it with TortoiseSVN.
This is the new functnio for LogDisplay.lua and minor fixes to the Character dump.
Now I'm off to do the Achievements (interface/WorldAchievments and Character dump)
I hope it will be easier then coding a Distributed Tree algorithm as a part of an exam I had today :lol:
Either way, I can do artifact migration and ego items coding if needed. Lua is fun.

However:

Code: Select all

--- LogDisplay.lua-revBASE.svn000.tmp.lua
+++ game/engine/LogDisplay.lua
@@ -93,3 +93,16 @@
 	if self.scroll < 0 then self.scroll = 0 end
 	self.changed = true
 end
+
+-- Get Last Lines From Log
+-- @param number number of lines to retrieve
+function _M:getLines(number)   
+	local from = number
+	if from > #self.log then from = #self.log end
+	local lines = { }
+	for i = from, 1, -1 do
+ 		lines[#lines+1] = self.log[i]
+  	end
+	return lines
+end
+
And:

Code: Select all

---CharacterSheet.-revBASE.svn003.tmp.lua	
+++ game/modules/tome/dialogs/CharacterSheet.lua	
@@ -266,9 +266,9 @@
 	nl(makelabel("Spellpower", game.player:combatSpellpower() ..""))
 	nnl(("%-32s"):format(makelabel("Armor", game.player:combatArmor() .. "")))
 	nl(makelabel("Spell Crit", game.player:combatSpellCrit() .."%"))
-	nnl(("%-32s"):format(makelabel("Class", game.player:combatDefense() .. "")))
+	nnl(("%-32s"):format(makelabel("Defense", game.player:combatDefense() .. "")))
 	nl(makelabel("Spell Speed", game.player:combatSpellSpeed() ..""))
-	nnl(("%-32s"):format(makelabel("Class", game.player:combatDefenseRanged() .. "")))
+	nnl(("%-32s"):format(makelabel("Ranged Defense", game.player:combatDefenseRanged() .. "")))
 	nl()
 
 	nl()
@@ -405,8 +405,14 @@
 			nl(("   %s"):format(table.concat(o:getTextualDesc(), "\n    ")))
 		end
 	end
+	
+	nl()
+	nl("  [Last Messages]")
+	nl()
+	
+	nl(table.concat(game.logdisplay:getLines(40), "\r"):gsub("#.-#", "   "))
 
 	fff:close()
 
 	Dialog:simplePopup("Character dump complete", "File: "..fs.getRealPath(file))
-end
+end
\ No newline at end of file

Re: Code dump with last messages displayed

Posted: Sun Jul 11, 2010 7:24 pm
by darkgod
Yeah a diff is just nice :)
But tell your editor to indent with tabs not spaces, this messes up the diff real nice ;)

Anyway thanks!

I'll be awaiting the achievement one!
As for doing more stuff you're welcome, as you say lua is fun!

One thing I always want to do but never find time, the player profile interface.
A new entry to the main menu, that allows to see the current profile, switch it, create a new one and connect a profile to an online profile on te4.org, possibly creating it in the process.

If you feel up to it you're welcome ! :)

Re: Code dump with last messages displayed

Posted: Sun Jul 11, 2010 7:49 pm
by shani
Hmm.. A challenge... I'll take it.
I'll need more information of course,
What? Where? Who? When? :)

But first things first, I'll do the achievments

Re: Code dump with last messages displayed

Posted: Sun Jul 11, 2010 10:26 pm
by darkgod
Yeah I'll brief you when you've finished achievs :)