Options Help

Well, I’m trying to make an Option for semi-transparent trees. I’m using an Option for that, and here’s my code. Tells me to add something. Syntax Error.

Public Sub DrawMapResource(ByVal Resource_num As Long, Optional ByVal screenShot As Boolean = False)

Dim Resource_master As Long

Dim Resource_state As Long

Dim Resource_sprite As Long

Dim rec As RECT

Dim X As Long, Y As Long

Dim i As Long, Alpha As Long

’ If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

If Options.STT = 0 Then

’ make sure it’s not out of map

If MapResource(Resource_num).X > Map.MaxX Then Exit Sub

If MapResource(Resource_num).Y > Map.MaxY Then Exit Sub

’ Get the Resource type

Resource_master = Map.Tile(MapResource(Resource_num).X, MapResource(Resource_num).Y).data1

If Resource_master = 0 Then Exit Sub

If Resource(Resource_master).ResourceImage = 0 Then Exit Sub

’ Get the Resource state

Resource_state = MapResource(Resource_num).ResourceState

If Resource_state = 0 Then ’ normal

Resource_sprite = Resource(Resource_master).ResourceImage

ElseIf Resource_state = 1 Then ’ used

Resource_sprite = Resource(Resource_master).ExhaustedImage

End If

’ cut down everything if we’re editing

If InMapEditor Then

Resource_sprite = Resource(Resource_master).ExhaustedImage

End If

’ src rect

With rec

.Top = 0

.Bottom = Tex_Resource(Resource_sprite).Height

.Left = 0

.Right = Tex_Resource(Resource_sprite).Width

End With

’ Set base x + y, then the offset due to size

X = (MapResource(Resource_num).X * PIC_X) - (Tex_Resource(Resource_sprite).Width / 2) + 16

Y = (MapResource(Resource_num).Y * PIC_Y) - Tex_Resource(Resource_sprite).Height + 32

Next

Then if Options.STT = 0

Then

’ render it

If Not screenShot Then

Call DrawResource(Resource_sprite, X, Y, rec)

Else

Call ScreenshotResource(Resource_sprite, X, Y, rec)

End If

Else

’ render it

Call DrawResource(Resource_sprite, Alpha, X, Y, rec)

’ Semi Transparent Trees :D

For i = 1 To Player_HighIndex

If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then

If ConvertMapY(GetPlayerY(i)) < ConvertMapY(MapResource(Resource_num).Y) And ConvertMapY(GetPlayerY(i)) > ConvertMapY(MapResource(Resource_num).Y) - (Tex_Resource(Resource_sprite).Height) / 32 Then

If ConvertMapX(GetPlayerX(i)) >= ConvertMapX(MapResource(Resource_num).X) - ((Tex_Resource(Resource_sprite).Width / 2) / 32) And ConvertMapX(GetPlayerX(i)) <= ConvertMapX(MapResource(Resource_num).X) + ((Tex_Resource(Resource_sprite).Width / 2) / 32) Then

Alpha = 150

Else

Alpha = 255

End If

Else

Alpha = 255

End If

End If

Next

’ Error handler

Exit Sub

errorhandler:

HandleError “DrawMapResource”, “modGraphics”, Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Eh…what is this? :P


Then if Options.STT = 0

Then

It should be:


If Options.STT = 0 Then

Ugh reading it in this format gives me a headache, overall this code is a big mess!


Public Sub DrawMapResource(ByVal Resource_num As Long, _

						   Optional ByVal screenShot As Boolean = False)

    Dim Resource_master As Long

    Dim Resource_state  As Long

    Dim Resource_sprite As Long

    Dim rec			 As RECT

    Dim X			   As Long, Y As Long

    Dim i			   As Long, Alpha As Long

    ' If debug mode, handle error then exit out

    If Options.Debug = 1 Then On Error GoTo errorhandler

    If Options.STT = 0 Then

	    ' make sure it's not out of map

	    If MapResource(Resource_num).X > Map.MaxX Then Exit Sub

	    If MapResource(Resource_num).Y > Map.MaxY Then Exit Sub

	    ' Get the Resource type

	    Resource_master = Map.Tile(MapResource(Resource_num).X, MapResource(Resource_num).Y).Data1

	    If Resource_master = 0 Then Exit Sub

	    If Resource(Resource_master).ResourceImage = 0 Then Exit Sub

	    ' Get the Resource state

	    Resource_state = MapResource(Resource_num).ResourceState

	    If Resource_state = 0 Then ' normal

		    Resource_sprite = Resource(Resource_master).ResourceImage

	    ElseIf Resource_state = 1 Then ' used

		    Resource_sprite = Resource(Resource_master).ExhaustedImage

	    End If

	    ' cut down everything if we're editing

	    If InMapEditor Then

		    Resource_sprite = Resource(Resource_master).ExhaustedImage

	    End If

	    ' src rect

	    With rec

		    .Top = 0

		    .Bottom = Tex_Resource(Resource_sprite).Height

		    .Left = 0

		    .Right = Tex_Resource(Resource_sprite).Width

	    End With

	    ' Set base x + y, then the offset due to size

	    X = (MapResource(Resource_num).X * PIC_X) - (Tex_Resource(Resource_sprite).Width / 2) + 16

	    Y = (MapResource(Resource_num).Y * PIC_Y) - Tex_Resource(Resource_sprite).Height + 32

	    ' render it

	    If Not screenShot Then

		    Call DrawResource(Resource_sprite, X, Y, rec)

	    Else

		    Call ScreenshotResource(Resource_sprite, X, Y, rec)

	    End If

    Else

	    If Options.STT = 1 Then

		    ' render it

		    Call DrawResource(Resource_sprite, Alpha, X, Y, rec)

		    ' Semi Transparent Trees ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png)

		    For i = 1 To Player_HighIndex

			    If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then

				    If ConvertMapY(GetPlayerY(i)) < ConvertMapY(MapResource(Resource_num).Y) And ConvertMapY(GetPlayerY(i)) > ConvertMapY(MapResource(Resource_num).Y) - (Tex_Resource(Resource_sprite).Height) / 32 Then

					    If ConvertMapX(GetPlayerX(i)) >= ConvertMapX(MapResource(Resource_num).X) - ((Tex_Resource(Resource_sprite).Width / 2) / 32) And ConvertMapX(GetPlayerX(i)) <= ConvertMapX(MapResource(Resource_num).X) + ((Tex_Resource(Resource_sprite).Width / 2) / 32) Then

						    Alpha = 150

					    Else

						    Alpha = 255

					    End If

				    End If

			    End If

		    Next

	    End If

    End If

errorhandler:

    HandleError "DrawMapResource", "modGraphics", Err.Number, Err.Description, Err.Source, Err.HelpContext

    Err.Clear

    Exit Sub

End Sub

See if this would help….

Edit: I clean up the code a bit.

Now it’s telling me:

Byref argument type mismatch.

with the Line.

Call DrawResource(Resource_sprite, Alpha, X, Y, rec)

Is it already declared?

I’m using EO 3.0, with this tut: http://www.touchofdeathforums.com/community/index.php?/topic/131189-semi-transparent-trees/

Log in to reply