Page 8 of 10

Re: Petri consumes glögg and codes with you

Posted: Tue Dec 04, 2012 9:58 pm
by LordYig
petri wrote:http://i.imgur.com/VdTj3.jpg
And this is how it's done:
Freaking awesome ! :o

Re: Petri consumes glögg and codes with you

Posted: Tue Dec 04, 2012 10:01 pm
by flatline
Amazing indeed. Looking forward to the patch!
Grimwold wrote:I was keen for a way to make monsters flee for a time.. alternative solutions would be

#1 a new AI type = flee (instead of default or guard)

#2 monster:setFlee(5)
to make it flee the party for 5 seconds.

#3 monster:setSight(0)
set the sight of the monster on the fly so that it would at least wander
Oh, and this +1

Re: Petri consumes glögg and codes with you

Posted: Tue Dec 04, 2012 10:11 pm
by petri
Ok, folks, our time is up! Thanks to all for ideas & participating!

Here is the complete changelog and documentation for the new gui system:

- lever click box can be adjusted by placing a Node named "lever_node" in the model file
- added Item:insertItem(slot, item), Item:removeItem(slot), Item:getItem(slot) and Item:getItem(slot)
- added new LightSource property: flicker (default value is true)
- added new optional 15th parameter for shootProjectile(): championOrdinal
- added Item:onEquipItem(champion, slot) and Item:onUnequipItem(champion, slot) hooks (works for all inventory slots)
- added Monster:setPosition(x, y, level, facing) and Party:setPosition(x, y, level, facing) for instantly teleporting the monster or party
- bug fix: shootProjectile's offsetX, offsetY, offsetZ parameters don't work
- added onGuiDraw, onDrawInventory, onDrawSkills, onDrawStats hooks to Party class for implementing custom guis (see below)

onGuiDraw hook is a Lua function which receives a single argument, a graphics context which can be used to draw custom gui graphics to the screen. The context has the following properties and methods:

width returns the width of the screen
height returns the height of the screen
color(r,g,b,a) set the pen current color
drawRect(x, y, width, height) draws a filled rectangle with current pen color
drawImage(filename, x, y) draws an image modulated with current pen color
drawText(text, x, y) draws a line of text with current pen color
button(id, x, y, width, height) returns true if the mouse was clicked in the given button rectangle

Buttons must be identified by unique string IDs.

onDrawInventory, onDrawSkills and onDrawStats are called when the corresponding page of the character sheet is visible. These functions receive a secondary parameter, the champion whose sheet is currently visible.

For example,

Code: Select all

cloneObject{
	name = "party",
	baseObject = "party",
	onGuiDraw = function(g)
      -- draw transparent background
      g.color(30,30,30,150)
      g.drawRect(30, 50, 345, 300)

      -- draw the portrait
      g.color(255,255,255,255)
      g.drawImage("assets/textures/portraits/human_female_01.tga", 40, 60)

      -- draw some text
      g.color(255, 128, 128)
      g.drawText("Well, Hello", 200, 80)
      g.color(128, 128, 255)
      g.drawText("Grimrockers!", 200, 95)

      -- draw button with text
      g.color(128, 128, 128)
      g.drawRect(200, 120, 115, 20)
      g.color(255, 255, 255)
      g.drawText("How u doing?!", 210, 135)

      -- button logic
      if g.button("button1", 200, 120, 115, 20) then
         hudPrint("*kick in the groin*")
      end
   end,
}

Re: Petri consumes glögg and codes with you

Posted: Tue Dec 04, 2012 10:11 pm
by Ancylus
I agree with the others, you're doing wonderful work, Petri!

As for suggestions, could you add Item:setPosition method, too?

Other things that occur to me are a method for controlling the exact angle at which an item is placed on the ground for situations where the normal random variation isn't fitting, and Item:getSubtileOffset method.

Re: Petri consumes glögg and codes with you

Posted: Tue Dec 04, 2012 10:18 pm
by HaunterV
We can have monster health bars over their heads now if we wanted... Via a spell of course.

Re: Petri consumes glögg and codes with you

Posted: Tue Dec 04, 2012 10:22 pm
by Xanathar
Wow Petri, thanks!
:)

Re: Petri consumes glögg and codes with you

Posted: Tue Dec 04, 2012 10:22 pm
by thomson
There are couple questions that everyone (community wide, I presume) would like to ask: Will those new goodies (together with result of the previous beverage enhanced coding sprint) be released soon or do we have to wait till OSX version is released? In any case, is there anything we can do help speed this patch up? Would OSX testers be helpful for you in any way?

Re: Petri consumes glögg and codes with you

Posted: Tue Dec 04, 2012 10:22 pm
by JKos
It's truly amazing indeed, but from that documentation I could not quite get it how the onGuiDraw get's triggered. If it's called continuously by small interval then it it's super awesome and gives endless possibilities for custom GUIs.

Re: Petri consumes glögg and codes with you

Posted: Tue Dec 04, 2012 10:25 pm
by petri
All gui drawing hooks are called every frame so you can build animated guis or even complete mini games :)

Re: Petri consumes glögg and codes with you

Posted: Tue Dec 04, 2012 10:29 pm
by JKos
Ok, now I get it that's just perfect. Thanks again.