Skip to content

Define types for special variables TimerA and TimerB #220

Closed

Description

@MiranDMC

Currently timera and timerb are predefined constants.
It seems like the types of underlaying variables should be predefined too, so there will be no need to add

var
TimerA : int
TimerB : int
end

to every script.

Maybe $ONMISSION (and other predefined variables) could be handled in same way too.

Activity

  1. x87 commented on Mar 16, 2023

    @x87
    Collaborator

    interesting. timers are usually used with number constants, like this:

    TIMERA = 0
    
    while TIMERA < 3000
        wait 0
    end
    

    so the compiler would use integer opcodes. I agree in principle that they could be declared by default as int variables, just curious to see the code where it is needed.

  2. MiranDMC commented on Mar 16, 2023

    @MiranDMC
    Author

    Real example:
    0@ = DebugTimeOffset
    0@ += TimerB
    008F: 0@ = integer 0@ to_float
    0@ *= 0.001 // ms to seconds

  3. x87 commented on May 7, 2023

    @x87
    Collaborator

    File constants.txt is implicitly imported in any script as a source file. It means that it is possible to modify the content of it to include a var..end construct.

    For example, for data\sa\constants.txt:

    const
    false=0
    true=1
    TIMERA=32@
    TIMERB=33@
    end
    var
    TimerA : int
    TimerB : int
    end
    
  4. added
    workaround-available
    on May 7, 2023
  5. x87 commented on May 7, 2023

    @x87
    Collaborator

    File constants.txt is implicitly imported in any script as a source file. It means that it is possible to modify the content of it to include a var..end construct.

    For example, for data\sa\constants.txt:

    const
    false=0
    true=1
    TIMERA=32@
    TIMERB=33@
    end
    var
    TimerA : int
    TimerB : int
    end
    

    Note to self: this breaks main.scm compilation as the compiler does not expect var..end to go before a DEFINE header.

  6. added this to the v3.9.0 milestone on Jul 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:p3scope:compilertype:nice-to-haveworkaround-available

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions