Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define types for special variables TimerA and TimerB #220

Closed
Tracked by #231
MiranDMC opened this issue Mar 16, 2023 · 4 comments
Closed
Tracked by #231

Define types for special variables TimerA and TimerB #220

MiranDMC opened this issue Mar 16, 2023 · 4 comments
Labels
priority:p3 Low priority scope:compiler type:nice-to-have minor enhancements workaround-available Users can fix for themselves
Milestone

Comments

@MiranDMC
Copy link

MiranDMC commented Mar 16, 2023

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.

@x87
Copy link
Collaborator

x87 commented Mar 16, 2023

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.

@x87 x87 added priority:p3 Low priority type:nice-to-have minor enhancements scope:compiler labels Mar 16, 2023
@MiranDMC
Copy link
Author

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

@x87
Copy link
Collaborator

x87 commented May 7, 2023

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

@x87 x87 added the workaround-available Users can fix for themselves label May 7, 2023
@x87
Copy link
Collaborator

x87 commented May 7, 2023

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.

@x87 x87 added this to the v3.9.0 milestone Jul 1, 2023
@x87 x87 mentioned this issue Jul 1, 2023
46 tasks
@x87 x87 closed this as completed Sep 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:p3 Low priority scope:compiler type:nice-to-have minor enhancements workaround-available Users can fix for themselves
Projects
None yet
Development

No branches or pull requests

2 participants