AlliedModders (
-   Scripting (
-   -   Trying to compile snake (

enderandrew 07-25-2020 18:27

Trying to compile snake
So it doesn't compile in newer versions of SM. I decided to try and update the syntax to get it to compile. For some reason enum structs (when to use then and when not and how to handle them) are what always throw me for a loop.

So my first attempt (code here - )was to update everything to new syntax as normal and the only error I'm left with is to update the enum to enum struct.


snake.sp(91) : warning 213: tag mismatch (expected "WormMode", got "int")
snake.sp(92) : warning 213: tag mismatch (expected "WormMode", got "int")
snake.sp(293) : warning 213: tag mismatch (expected "WormMode", got "int")
snake.sp(298) : error 153: Array-based enum structs have been removed. See
snake.sp(299) : warning 213: tag mismatch (expected "int", got "WormMode")
snake.sp(300) : warning 213: tag mismatch (expected "int", got "WormMode")
snake.sp(301) : warning 213: tag mismatch (expected "WormMode", got "int")
snake.sp(316) : warning 213: tag mismatch (expected "WormMode", got "int")
snake.sp(380) : warning 213: tag mismatch (expected "WormMode", got "int")
snake.sp(381) : warning 213: tag mismatch (expected "WormMode", got "int")

The warnings are all related to the same.

However I don't understand the difference here. Both of these enums appear to have set values and don't mix data types.


enum WormDirection
        Direction_Right = 0,

enum WormMode
        Mode_Snake1, // walls are solid
        Mode_Snake2 // walls are walkable

But I'm getting an error telling me to turn WormMode into an enum struct, but not for WormDirection.

Changing it to an enum struct introduces a lot more errors and complications that I can't seem to fix.

Now I have this code -

And I have a lot more errors I don't know how to fix:


snake2.sp(182) : error 017: undefined symbol "Mode_Snake1"
snake2.sp(194) : error 017: undefined symbol "Mode_Snake2"
snake2.sp(293) : error 033: array must be indexed (variable "g_iSnakeMode")
snake2.sp(298) : error 174: symbol 'WormMode' is a type and cannot be used as a value
snake2.sp(299) : error 017: undefined symbol "Mode_Snake1"
snake2.sp(300) : error 017: undefined symbol "Mode_Snake2"
snake2.sp(301) : error 033: array must be indexed (variable "g_iSnakeMode")
snake2.sp(310) : error 017: undefined symbol "Mode_Snake1"
snake2.sp(316) : error 033: array must be indexed (variable "g_iSnakeMode")
snake2.sp(565) : error 017: undefined symbol "Mode_Snake1"
snake2.sp(629) : error 017: undefined symbol "Mode_Snake1"
snake2.sp(693) : error 017: undefined symbol "Mode_Snake1"
snake2.sp(756) : error 017: undefined symbol "Mode_Snake1"

13 Errors.

Fyren 07-26-2020 23:50

Re: Trying to compile snake
An enum struct acts similarly to a struct or class from an OOP language. It replaces the old method of indexing arrays using an enum because that was extremely obtuse.

So in your second code link, it doesn't make sense to use just Mode_Snake1 on the right side of an assignment since it's the name of a property/field on an object (using OOP terms). You have WormMode g_iSnakeMode[MAXPLAYERS+1]; so each thing in that array is-a WormMode. With that declaration, you can do something like g_iSnakeMode[1].Mode_Snake1 = 42;.

All times are GMT -4. The time now is 02:55.

Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.