Sign in to follow this  
Followers 0
AlmarM

Need help with GEngin

8 posts in this topic

Hello,

I'm just testing around with the GEngin made by Matwachich but before I could do antything cool, I ran into a DllStructSetData error.

You can get GEngin here.

This is my code.

#include "gengin\GEngin.au3"

Global Const $ciWidth = 600, $ciHeight = 500

Global $ahFadingBackgroundObjects[1] = [0]

_GEng_Start("test", $ciWidth, $ciHeight)
Global $hFont = _GEng_Font_Create("Lucida Console", 40, 1)

$ahFadingBackgroundObjects[0] = _GEng_Text_Create($hFont, "?", 0xFF004080, -10, Random(0, $ciHeight, 1), 50, 50)

While (GUIGetMsg()  -3)
    _GEng_ScrFlush(0xFFFFFFFF)

    ; code below
    UpdateFadingBackgroundObjects()

    _GEng_ScrUpdate()
WEnd

_GEng_Text_Delete($ahFadingBackgroundObjects[0])
_GEng_Font_Delete($hFont)
_GEng_Shutdown()

Func UpdateFadingBackgroundObjects()
    Local $iX, $iY, $iWidth, $iHeight

    _GEng_Text_PosGet($ahFadingBackgroundObjects[0], $iX, $iY, $iWidth, $iHeight)
    _GEng_Text_PosSet($ahFadingBackgroundObjects[0], $iX + 2, $iY, $iWidth, $iHeight)
    _GEng_Text_Draw($ahFadingBackgroundObjects[0])
EndFunc

And this is the error I'm getting.

C:\Users\Lyker\Desktop\gengin\GEngin\GEng_Text.au3 (421) : ==> Subscript used with non-Array variable.:
$iPosX = DllStructSetData($Struct[0], "X", $iPosX)
$iPosX = DllStructSetData($Struct^ ERROR

And just for the sake of it, here is the _GEng_Text_PosGet function from his UDF.

Func _GEng_Text_PosGet(ByRef $hTxtRect, ByRef $iPosX, ByRef $iPosY, ByRef $iWidth, ByRef $iHeight)
    If Not __GEng_Text_IsTextRect($hTxtRect) Then Return SetError(1, 0, 0)
    ; ---
    Local $Struct = $hTxtRect[2]
    $iPosX = DllStructSetData($Struct[0], "X", $iPosX)
    $iPosY = DllStructSetData($Struct[0], "Y", $iPosY)
    $iWidth = DllStructSetData($Struct[0], "Width", $iWidth)
    $iHeight = DllStructSetData($Struct[0], "Height", $iHeight)
    ; ---
    Return 1
EndFunc

Any help would be great!


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites



If I got it right, then your expected output is a GUI with '?' sign on top-left corner, with white-bg. So, I modified func. in GENG_TEXT.au3 as:

Func _GEng_Text_PosGet(ByRef $hTxtRect, ByRef $iPosX, ByRef $iPosY, ByRef $iWidth, ByRef $iHeight)
If Not __GEng_Text_IsTextRect($hTxtRect) then
    Return SetError(1, 0, 0)
EndIf
; ---
Local $Struct = $hTxtRect[2]
$iPosX = DllStructSetData($Struct, "X", $iPosX)
$iPosY = DllStructSetData($Struct, "Y", $iPosY)
$iWidth = DllStructSetData($Struct, "Width", $iWidth)
$iHeight = DllStructSetData($Struct, "Height", $iHeight)
; ---
Return 1
EndFunc

Bingo! Now its working. Hope this solves the problem.


----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites

Awesome work! It's working indeed.

The only problem is now, that the PosGet won't return the XY. Instead it just returns X:0 Y:0.

Any idea?


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites
:oops: Well, I am really sorry, but honestly I have used GEngin for the first time just minutes after you posted this. I really can't help in this matter.

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites

It's my first time too.

Thanks for the help though! Appriciated.


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

Sorry guys for the time wast, but this is a bug!

And thanks for testing, and i'm happy that it's usefull for someone!

The bug is in the _GEng_Text_PosGet function, it should be like this

Func _GEng_Text_PosGet(ByRef $hTxtRect, ByRef $iPosX, ByRef $iPosY, ByRef $iWidth, ByRef $iHeight)
If Not __GEng_Text_IsTextRect($hTxtRect) Then Return SetError(1, 0, 0)
; ---
Local $Struct = $hTxtRect[2]
$iPosX = DllStructGetData($Struct, "X")
$iPosY = DllStructGetData($Struct, "Y")
$iWidth = DllStructGetData($Struct, "Width")
$iHeight = DllStructGetData($Struct, "Height")
; ---
Return 1
EndFunc

You can modify it directly in the source code.

Hope it's the only remaining bug.

Gonna wait somedays befor uploading a corrected version, if you find some other bugs, please tell me. I don't have time to test them myself these days.

The modules that have not been very well tested are: Text, Sound and dynamic collisions (this last one isn't very reliable, so don't use it!)

Share this post


Link to post
Share on other sites

Awesome, thanks for your reply!

I'm currently testing, but it looks fine now.

What a stupid little error though >_


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

Yep! an Ctrl-C Ctrl-V error!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0