Page 2 of 5

Re: Tome Library

Posted: Tue Sep 25, 2012 5:36 pm
by Montis
SpacialKatana wrote:I'm going to use that code for my random barrel drops.
Random barrel drops sound like donkey kong :D
(I know what you mean with that but still ;))

Re: Tome Library

Posted: Tue Sep 25, 2012 5:46 pm
by J. Trudel
Ixnatifual wrote:Written by a man whose name bears an odd resemblance to a toxic beverage, this book's pages detail how men of the enigmatic tribes of the south have learned to run for days without tiring.
Is this a reference to the Tarahumaras? :) I really like all the tomes descriptions.

Re: Tome Library

Posted: Tue Sep 25, 2012 6:42 pm
by SpacialKatana
Hmmm having a spot of bother

Barrel object has hook:-

Code: Select all

onDie = function(self)
barreldrop.randomdrop()
end
Entity called global_functions has code:-

Code: Select all

function getrandomdrop()
local item = {"arrow", "cold_arrow", "fire_arrow",
      "poison_arrow", "shock_arrow", "baked_maggot", "boiled_beetle",
      "cave_nettle", "grim_cap", "milkreed", "blooddrop_blossom",
      "pitroot_bread", "poison_bomb", "fire_bomb", "frost_bomb",
      "shock_bomb", "sandals", "slime_bell",
      "tar_bead","throwing_dagger"}   
   return item[math.random(1, table.getn(item))]
end
Entity called barreldrop with code:-

Code: Select all

function randomdrop()
spawn(global_functions.getrandomdrop(),self.level,self.x,self.y,self.facing)
end
The barrel breaks fine but nothing drops....prolly the self.x,self.y etc

What have I done wrong???

Re: Tome Library

Posted: Tue Sep 25, 2012 7:04 pm
by petri
You're spawning in the cell where the script entity is. Perhaps you wanted to pass the self parameter to randomdrop?

Re: Tome Library

Posted: Tue Sep 25, 2012 7:11 pm
by Ixnatifual
J. Trudel wrote:
Ixnatifual wrote:Written by a man whose name bears an odd resemblance to a toxic beverage, this book's pages detail how men of the enigmatic tribes of the south have learned to run for days without tiring.
Is this a reference to the Tarahumaras? :) I really like all the tomes descriptions.
Yeah. And the vague comment on the writer is a reference to this dude.

Re: Tome Library

Posted: Tue Sep 25, 2012 7:15 pm
by SpacialKatana
petri wrote:You're spawning in the cell where the script entity is. Perhaps you wanted to pass the self parameter to randomdrop?
okay so I know what I did wrong....I was asking how to fix it....not drink more Jack Daniels :evil:

Help? pretty please, I'm new to lua

Re: Tome Library

Posted: Tue Sep 25, 2012 8:44 pm
by SpacialKatana
Okay so I kind of figured it out eventually:-

Code: Select all

onDie = function(object)
barreldrop.randomdrop(object.level, object.x, object.y, object.facing)
end
Entity called barreldrop with code:-

Code: Select all

function randomdrop(level, x, y, facing)
spawn(global_functions.getrandomdrop(), level, x, y, facing)
end
The loot drops where the barrel was broken but when exiting the preview the editor crashes:-

[string "Map.lua"]:0: table index is nil
stack traceback:
[string "Map.lua"]: in function 'registerNode'
[string "Blockage.lua"]: in function 'entityRemovedFromMap'
[string "Map.lua"]: in function 'removeEntity'
[string "Map.lua"]: in function 'destroy'
[string "Dungeon.lua"]: in function 'unload'
[string "DungeonEditor.lua"]: in function 'stopPreview'
[string "DungeonEditor.lua"]: in function 'previewButtons'
[string "DungeonEditor.lua"]: in function 'update'
[string "Grimrock.lua"]: in main chunk

OS Version 6.1

OEM ID: 0
Number of processors: 8
Page size: 4096
Processor type: 586

Total memory: 8147 MB
Free memory: 5804 MB

Display device 0:
Device name: \\.\DISPLAY1
Device string: NVIDIA GeForce GTX 570
State flags: 00000005

Display device 1:
Device name: \\.\DISPLAY2
Device string: NVIDIA GeForce GTX 570
State flags: 00000000

Display device 2:
Device name: \\.\DISPLAYV1
Device string: RDPDD Chained DD
State flags: 00000008

Display device 3:
Device name: \\.\DISPLAYV2
Device string: RDP Encoder Mirror Driver
State flags: 00200008

Display device 4:
Device name: \\.\DISPLAYV3
Device string: RDP Reflector Display Driver
State flags: 00200008

Re: Tome Library

Posted: Tue Sep 25, 2012 8:55 pm
by J. Trudel
Ixnatifual wrote:
J. Trudel wrote:
Ixnatifual wrote:Written by a man whose name bears an odd resemblance to a toxic beverage, this book's pages detail how men of the enigmatic tribes of the south have learned to run for days without tiring.
Is this a reference to the Tarahumaras? :) I really like all the tomes descriptions.
Yeah. And the vague comment on the writer is a reference to this dude.
I was actually quite surprised (and pleased) to see this reference, I'll have a look at this dude he seems to know his stuff. :)

Re: Tome Library

Posted: Tue Sep 25, 2012 9:53 pm
by Ixnatifual
J. Trudel wrote:I was actually quite surprised (and pleased) to see this reference, I'll have a look at this dude he seems to know his stuff. :)
Daniel's Running Formula is a very informative read, although it is most certainly overkill for someone like me who just runs casually now and then. Now if I was coaching a team of runners it'd probably be an amazing resource.

Re: Tome Library

Posted: Tue Sep 25, 2012 10:52 pm
by Emciel
very nicely done ixnatifual.
the randomtome table is a very appealing way of dealing with random loot, i might make use of it in a dungeon or two =)
although i guess it'd require a bit more work to make some items more likely than others.