- 
                Notifications
    
You must be signed in to change notification settings  - Fork 2
 
Add ability to execute scripts inside a script scope #3
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
Add ability to execute scripts inside a script scope #3
Conversation
Add VScript_ReleaseScript Fix gamedata
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured it'd be best to stay on the safe side in case more specialized code takes place versus releasing it using ReleaseValue.
I don't think there a difference between it? Looking at cstrike leaked code it should follow the exact same steps. Although ReleaseScope have extra steps and that games may have handled it differently, so it may makes sense in the long term.
I haven't tested in other games so ReleaseScript's offsets in "#default" is just a guess. For TF2 specifically, I'm not sure if I should've used ExtraOffsets.
TF2's extra offset is above these script offsets, so it fine as it matches with CSGO's offsets.
        
          
                scripting/include/vscript.inc
              
                Outdated
          
        
      | // @param script Script address to execute. | ||
| public native VScriptExecute(HSCRIPT script); | ||
| // @param scope The script scope to execute the script inside of. | ||
| public native VScriptExecute(HSCRIPT script, HSCRIPT scope = view_as<HSCRIPT>(0)); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HSCRIPT_RootTable variable can be used as default scope value, to make it more clearer that root table is used as default.
        
          
                gamedata/vscript.txt
              
                Outdated
          
        
      | 
               | 
          ||
| "IScriptVM::CompileScript" | ||
| { | ||
| "linux" "9" | ||
| "windows" "11" | ||
| } | ||
| 
               | 
          ||
| "IScriptVM::ReleaseScript" | ||
| { | ||
| "linux" "10" | ||
| "windows" "12" | ||
| } | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Offset looks correct, but now there duplicate offsets under same name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should both the CompileScript and ReleaseScript offsets be used in "#default" instead? I put these for TF2 specifically because I wasn't sure if they're the same for CSGO (which I'm assuming is the game that "#default" is based on).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah put in #default, TF2 will use default offsets but auto-adjusts its based on ExtraOffsets
        
          
                scripting/include/vscript.inc
              
                Outdated
          
        
      | /** | ||
| * Releases a compiled script. | ||
| * | ||
| * @param hscript HSCRIPT of compiled script | ||
| */ | ||
| native void VScript_ReleaseScript(HSCRIPT hscript); | ||
| 
               | 
          
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would prefer to have methodmap function HSCRIPT.ReleaseScript() to match with HSCRIPT.Release()
Add HSCRIPT.ReleaseScript Use HSCRIPT_RootTable as default for scope
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Adds an extra parameter to
VScriptExecute's constructor to specify a script scope, or use root table by default.Also added a
VScript_ReleaseScriptnative to pair withVScript_CompileScript(File). Since it exists on the interface, I figured it'd be best to stay on the safe side in case more specialized code takes place versus releasing it usingReleaseValue.I also corrected the offsets for both
CompileScriptandReleaseScriptfor TF2. Both have been tested on TF2 Windows and Linux, but I haven't tested in other games soReleaseScript's offsets in "#default" is just a guess. For TF2 specifically, I'm not sure if I should've usedExtraOffsets.I used this code to test them along with the scopes:
vscript_test.txt:
Output: