Skip to content

Commit

Permalink
rework sysval-s.
Browse files Browse the repository at this point in the history
  • Loading branch information
DEntis-T committed Aug 1, 2024
1 parent 73b2696 commit 22a930e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 53 deletions.
54 changes: 7 additions & 47 deletions doc/sysval.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,9 @@
# System values

- System values are variables or more-likely constants that can be accessed from the PawnScript code, but are used and updated internally. Below is a list of accessible system values.
- System values are variables or more-likely constants that can be accessed from the PawnScript code, but are used and updated internally. Below is a list of accessible system values. System values are prefixed with `$`.

## `__proccessed_form_id`

Return type: `int`

- Returns a processed form id.

```cpp
new[int]formid=__proccessed_form_id
console.println("'inlinetest' is {formid}")
```

## `__majorver`

Return type: `int`

- Returns the major version number.

## `__minorver`

Return type: `int`

- Returns the minor version number.

## `__patch`

Return type: `int`

- Returns the patch version number.

## `__release`

Return type: `int`

- Returns the version release number.

## `__beta`

Return type: `int`

- Returns 1 if the build is beta and 0 if the build is stable.


## `__procspeed`
## `$system.speed`

Return type: `int`

Expand All @@ -53,11 +12,12 @@ Return type: `int`

```cpp
@task
this->interval=1000
void supercooltask() public
this->interval=4000
this->repeat=true
void myTask() private
{
new[int]process_speed=__procspeed
console.println.log("Process execution speed: {process_speed} Hz")
new[int]process_speed=$system.speed
console.println("Process speed: {process_speed} Hz")
#undef:process_speed
}
```
Binary file modified scriptfiles/index.ps
Binary file not shown.
12 changes: 7 additions & 5 deletions src/modules/header.inc
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,13 @@ stock dpp_createtask(const name[], interval, repeat)
stock dpp_argsystemval(arg[])
{
new newvalue[dpp_argcharsize];

if(!strcmp(arg, "__procspeed") || !strcmp(arg, "$system.speed"))
{
format(newvalue, sizeof newvalue, "%i", dpp_speedhz);
strmid(arg, newvalue, 0, dpp_argcharsize, dpp_argcharsize);
}
//keeping these for backwards compatibility
if(!strcmp(arg, "__proccessed_form_id"))
{
format(newvalue, sizeof newvalue, "%i", dpp_processfunc);
Expand Down Expand Up @@ -785,11 +792,6 @@ stock dpp_argsystemval(arg[])
format(newvalue, sizeof newvalue, "%i", DPP_VERSION_BETA);
strmid(arg, newvalue, 0, dpp_argcharsize, dpp_argcharsize);
}
if(!strcmp(arg, "__procspeed"))
{
format(newvalue, sizeof newvalue, "%i", dpp_speedhz);
strmid(arg, newvalue, 0, dpp_argcharsize, dpp_argcharsize);
}
return 1;
}
////////////////
Expand Down
5 changes: 4 additions & 1 deletion st3/syntax.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ contexts:
- match: '\b(-)?[0-9.@#]+\b'
scope: constant.numeric.example-c

- match: '\b(true|false|default)\b'
- match: '\b(true|false|default|callback)\b'
scope: constant.numeric.example-c

- match: '[@#]'
Expand Down Expand Up @@ -75,6 +75,9 @@ contexts:
- match: '\b(this|user)\b'
scope: variable.parameter.c++

- match: '\b($system)\b'
scope: variable.parameter.c++

- match: '[\w]+\('
scope: entity.name.impl.example-c
- match: '\)'
Expand Down

0 comments on commit 22a930e

Please sign in to comment.