Re: Dialog Extension

BMJ

  • Posts: 278
Hi again --

I've upgraded to Stencyl 3.2, so I'm trying to also upgrade to Dialog 1.4 ... having a very difficult time, though.  I've read through the Getting Started file and studied the Dialog Extension Sample ... I've read through this thread. I've copied all the related files over from the sample into my game's folder ... I run into a Null Pointer Exception every time. I've included my log ... I don't know what else to try. Any thoughts?

Justin

  • *
  • Posts: 4716
Could you send me your game? Or, try copying a more verbose error from flash player.

I'm seeing a lot of this:

Error #1009: Cannot access a property or method of a null object reference.

A full error should show some more detailed info that would help track the source of it.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

BMJ

  • Posts: 278
The error message from Flash says this:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
   at ScalingImage()[C:\Users\Kevin\AppData\Roaming\Stencyl\stencylworks\engine-extensions/dialog/src/ScalingImage.hx:13]
   at DialogWindow()[C:\Users\Kevin\AppData\Roaming\Stencyl\stencylworks\engine-extensions/dialog/src/DialogWindow.hx:28]
   at MethodInfo-4249()[C:\Users\Kevin\AppData\Roaming\Stencyl\stencylworks\engine-extensions/dialog/src-ext/DialogBase.hx:33]
   at DialogBox/runCallbacks()[C:\Users\Kevin\AppData\Roaming\Stencyl\stencylworks\engine-extensions/dialog/src/DialogBox.hx:550]
   at DialogBox/beginDialog()[C:\Users\Kevin\AppData\Roaming\Stencyl\stencylworks\engine-extensions/dialog/src/DialogBox.hx:230]
   at Dialog$/cbCall()[C:\Users\Kevin\AppData\Roaming\Stencyl\stencylworks\engine-extensions/dialog/src/Dialog.hx:109]
   at MethodInfo-9903()[Source/scripts/Design_396_396_SaySomething.hx:125]
   at com.stencyl::Engine$/invokeListeners2()[C:\Program Files (x86)\Stencyl\plaf\haxe\lib/stencyl/1,00/com/stencyl/Engine.hx:4022]
   at com.stencyl.models::Actor/handleCollisions()[C:\Program Files (x86)\Stencyl\plaf\haxe\lib/stencyl/1,00/com/stencyl/models/Actor.hx:2099]
   at com.stencyl.models::Actor/innerUpdate()[C:\Program Files (x86)\Stencyl\plaf\haxe\lib/stencyl/1,00/com/stencyl/models/Actor.hx:1485]
   at com.stencyl::Engine/update()[C:\Program Files (x86)\Stencyl\plaf\haxe\lib/stencyl/1,00/com/stencyl/Engine.hx:2471]
   at com.stencyl::Engine/postUpdate()[C:\Program Files (x86)\Stencyl\plaf\haxe\lib/stencyl/1,00/com/stencyl/Engine.hx:2632]
   at com.stencyl::Engine/onUpdate()[C:\Program Files (x86)\Stencyl\plaf\haxe\lib/stencyl/1,00/com/stencyl/Engine.hx:2625]


Does that help?

Justin

  • *
  • Posts: 4716
Okay, it looks like that one is due to a "scaling image" not having an image from your extras folder selected as the base.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

BMJ

  • Posts: 278
Glory! That was one of the issues ... which is very odd, because I could swear i checked those before ... but apparently I didn't.  I once had your sample game and my game open side-by-side and I must have gotten mixed up.  It seems I also hadn't typed the animation name into the textbox after Pointer in the Flow Settings.

Anyhow, thanks again! I'll probably have more questions later. :)

Justin

  • *
  • Posts: 4716
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

BMJ

  • Posts: 278
Oooh, I thought of a question already -- for the Dialog 1.3 version, you had kindly made me some custom blocks that would allow me to set the dialog window's x/y coords  relative to an actor's location at runtime ... they don't seem to work with 1.4 ... Is that feature built into 1.4 in any way? If not, would you possibly be so kind as to adapt the custom blocks you made for me so they work with 1.4?

Justin

  • *
  • Posts: 4716
It's built in now, but doesn't work exactly the same.

You can use the [set [text] for [text] to [anything]] block from the data structures extension to modify any of the values you've set up for your dialog. (Don't confuse this block with the [set [text] for [anything] to [anything]] block.)

set [property identifier] for [structure name] to [value]

ex: set [msgBounds] for [Default Style] to [rectangle x: [10] y: [10] w: [400] h: [180]]

It's a little annoying right now, but you have to open the structure definition editor to actually see what the property identifiers are. They have to be valid variable names, so usually they'll be similar to the property label but with no spaces and camel-cased. For example: Default Type Sound --> defaultTypeSound.

You also have to put an object of the correct value into the last field. You can also see what value each property expects by looking at the structure definition. In the above example, that's a rectangle.

I think Stencyl should have you pretty well covered for most types of data. There are a couple types specific to the dialog extension though, and I haven't created blocks for them yet, so I'll cover them here.

Ratio Point: this is point that has both an absolute x/y component as well as a percentage, and it's used for positioning certain elements relative to a set of bounds. For example, a window's "position" field is a Ratio Point, so you could place it at (0, 100% - 100): The left of the screen and 100 pixels from the bottom.

code: new scripts.ds.dialog.RatioPoint(x value, x percent, y value, y percent)
ex: new scripts.ds.dialog.RatioPoint(-100, .5, -40, .5)
That would be (50% - 100, 50% - 40)

There's also RatioInt which is similar to RatioPoint, but it's not 2-dimensional.
code: new scripts.ds.dialog.RatioInt(value, percent)
example: new scripts.ds.dialog.RatioInt(-100, .5)
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

BMJ

  • Posts: 278
Justin -- thanks for the explanation. I think I see that the property I want to set is "position" and that it is set to take a RatioPoint value. (If I try to change this RatioPoint to a simple "Point" value, Stencyl crashes every time when i try to X out of the Data Structures Editor.) ... but ... if I wanted to hard code a position using RatioPoint values, I assume it should look like the attached picture ... ?

 ... but that gives me this error:

ReferenceError: Error #1056: Cannot create property position on scripts.ds.dialog.Style.
   at Reflect$/setField()[C:\Program Files (x86)\Stencyl\plaf\haxe/std/flash/_std/Reflect.hx:34]
   at MethodInfo-9922()[Source/scripts/Design_396_396_SaySomething.hx:144]
   at com.stencyl::Engine$/invokeListeners2()[C:\Program Files (x86)\Stencyl\plaf\haxe\lib/stencyl/1,00/com/stencyl/Engine.hx:4022]
   at com.stencyl.models::Actor/handleCollisions()[C:\Program Files (x86)\Stencyl\plaf\haxe\lib/stencyl/1,00/com/stencyl/models/Actor.hx:2099]
   at com.stencyl.models::Actor/innerUpdate()[C:\Program Files (x86)\Stencyl\plaf\haxe\lib/stencyl/1,00/com/stencyl/models/Actor.hx:1485]
   at com.stencyl::Engine/update()[C:\Program Files (x86)\Stencyl\plaf\haxe\lib/stencyl/1,00/com/stencyl/Engine.hx:2471]
   at com.stencyl::Engine/postUpdate()[C:\Program Files (x86)\Stencyl\plaf\haxe\lib/stencyl/1,00/com/stencyl/Engine.hx:2632]
   at com.stencyl::Engine/onUpdate()[C:\Program Files (x86)\Stencyl\plaf\haxe\lib/stencyl/1,00/com/stencyl/Engine.hx:2625]

At any rate, I don't really want to hard code the position, but I thought I'd start there and try to get that to work first. Where did I go wrong?

Justin

  • *
  • Posts: 4716
Yeah, it makes sense to start with a hardcoded value and go from there.

Well, there is no property "position" on a Style. "position" is a property of windows. So you should choose a window, such as "Dialog Main Window" for the second argument rather than a style.

As for the value, it requires some code (you can find a code block under Flow > Advanced). "new scripts.ds.dialog.RatioPoint(xValue, xPercent, yValue, yPercent)". To make this easier for yourself (because I don't think I'll have time to update any of my extensions for a while), you might want to wrap the code for creating a ratio point in a global custom block.

To refer to attributes in code, it's usually the same as the attribute name, but it starts with an underscore and has no spaces. (My Attribute becomes _MyAttribute)
If you make a global custom block for it, you can access custom block parameters with the parameter name, no spaces, starting with two underscores. (My Parameter becomes __MyParameter)
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

BMJ

  • Posts: 278
Ah! The hard-coded attempt works perfectly now. Thank you. :)

BMJ

  • Posts: 278
I think we're almost there ... but when I try to use the variabled code, I get a "float should be int" error. I've rounded the floats before passing them to Dialog, but that doesn't seem to make a difference, as i still get the same error:

Say Something:  Float should be Int
   from scripts.Design_396_396_SaySomething
   line: 144
   columns: 128-142
Say Something:  For function argument 'xv'
   from scripts.Design_396_396_SaySomething
   line: 144
   columns: 128-142

As you can see, I even rounded the zeros for good measure while side-eyeing the computer, but it doesn't seem to appreciate my effort. :P

BMJ

  • Posts: 278
My guess is that maybe that doesn't convert them to ints, but just makes them rounded floats?

Justin

  • *
  • Posts: 4716
That's exactly right. You can use Std.int(floatValue) to turn a float into an int.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

BMJ

  • Posts: 278
Stupendous. It now creates a dialog window relative to the character's x/y position. Perfect. Thank you. :)

I'm sure I'll have more questions tomorrow.