Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Options Help


Kemerd
 Share

Recommended Posts

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](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
>
> 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
Link to comment
Share on other sites

Eh…what is this? ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)

```

Then if Options.STT = 0

Then

```

It should be:

```

If Options.STT = 0 Then

```
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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/](http://www.touchofdeathforums.com/community/index.php?/topic/131189-semi-transparent-trees/)
Link to comment
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
 Share

×
×
  • Create New...