Struct eos_rs::api::script_vars::ScriptVariables
source · pub struct ScriptVariables(_);
Expand description
Helper struct for manipulating the global and local script variables.
Implementations§
source§impl ScriptVariables
impl ScriptVariables
sourcepub unsafe fn get() -> Self
pub unsafe fn get() -> Self
Returns a struct for manipulating global and local script variables.
Safety
This is unsafe, since it essentially borrows a global mutable variable (static mut
), see
safety rules for static mut
s.
sourcepub fn init(&mut self)
pub fn init(&mut self)
Initialize the script variable values table (SCRIPT_VARS_VALUES).
The whole table is first zero-initialized. Then, all script variable values are first initialized to their defaults, after which some of them are overwritten with other hard-coded values.
sourcepub fn global_variable(
&self,
var_id: ScriptVariableId
) -> GlobalScriptVariableRef<'_>
pub fn global_variable( &self, var_id: ScriptVariableId ) -> GlobalScriptVariableRef<'_>
Get a reference to the global variable. This must not be used for local variables.
sourcepub fn global_variable_mut(
&mut self,
var_id: ScriptVariableId
) -> GlobalScriptVariableMut<'_>
pub fn global_variable_mut( &mut self, var_id: ScriptVariableId ) -> GlobalScriptVariableMut<'_>
Get a mutable reference to the global variable. This must not be used for local variables.
sourcepub unsafe fn local_variable(
&self,
local_var_vals: *mut c_void,
var_id: ScriptVariableId
) -> LocalScriptVariableRef<'_>
pub unsafe fn local_variable( &self, local_var_vals: *mut c_void, var_id: ScriptVariableId ) -> LocalScriptVariableRef<'_>
Get a reference to the local variable. This signature will probably update when we know the type of that table.
Safety
The pointer to the local variable table must be valid.
sourcepub unsafe fn local_variable_mut(
&mut self,
local_var_vals: *mut c_void,
var_id: ScriptVariableId
) -> LocalScriptVariableMut<'_>
pub unsafe fn local_variable_mut( &mut self, local_var_vals: *mut c_void, var_id: ScriptVariableId ) -> LocalScriptVariableMut<'_>
Get a mutable reference to the local variable. This signature will probably update when we know the type of that table.
Safety
The pointer to the local variable table must be valid.
sourcepub fn event_flag_backup(&mut self)
pub fn event_flag_backup(&mut self)
Saves event flag script variables (see the code for an exhaustive list) to their respective BACKUP script variables, but only in certain game modes.
This function prints the debug string “EventFlag BackupGameMode %d” with the game mode.
sourcepub fn dump_script_variable_values(&mut self) -> [u8; 1024]
pub fn dump_script_variable_values(&mut self) -> [u8; 1024]
Runs EventFlagBackup, then copies the script variable values table (SCRIPT_VARS_VALUES) to the given pointer.
Important: This high-level function assumes that the variable data is 1024 bytes long.
Should you somehow extend the table, you should use the low-level
ffi::DumpScriptVariableValues
directly.
sourcepub fn restore_script_variable_values(&mut self, src: &[u8; 1024]) -> bool
pub fn restore_script_variable_values(&mut self, src: &[u8; 1024]) -> bool
Restores the script variable values table (SCRIPT_VARS_VALUES) with the given data.
Important: This high-level function assumes that the variable data is 1024 bytes long.
Should you somehow extend the table, you should use the low-level
ffi::RestoreScriptVariableValues
directly.
sourcepub fn init_event_flags(&mut self)
pub fn init_event_flags(&mut self)
Initializes an assortment of event flag script variables (see the code for an exhaustive list).
sourcepub fn init_scenario_script_vars(&mut self)
pub fn init_scenario_script_vars(&mut self)
Initializes most of the SCENARIO_* script variables (except SCENARIO_TALK_BIT_FLAG for some reason). Also initializes the PLAY_OLD_GAME variable.
sourcepub fn init_world_map_script_vars(&mut self)
pub fn init_world_map_script_vars(&mut self)
Initializes the WORLD_MAP_* script variable values (IDs 0x55-0x57).
pub fn init_dungeon_list_script_vars(&mut self)
sourcepub unsafe fn global_progress_alloc<'a, 'b>(
&'a mut self
) -> &'b mut global_progresswhere
'b: 'a,
pub unsafe fn global_progress_alloc<'a, 'b>( &'a mut self ) -> &'b mut global_progresswhere 'b: 'a,
Allocates a new global progress struct.
This updates the global pointer and returns a copy of that pointer.
Safety
Calls to this function may deallocate old global progress structs.
sourcepub fn reset_global_progress(&mut self)
pub fn reset_global_progress(&mut self)
Zero-initializes the global progress struct.
sourcepub fn scenario_flag_backup(&mut self)
pub fn scenario_flag_backup(&mut self)
Saves scenario flag script variables (SCENARIO_SELECT, SCENARIO_MAIN_BIT_FLAG) to their respective BACKUP script variables, but only in certain game modes.
This function prints the debug string “ScenarioFlag BackupGameMode %d” with the game mode.
sourcepub fn get_language_type(&self) -> i32
pub fn get_language_type(&self) -> i32
Gets the language type.
This is the value backing the special LANGUAGE_TYPE script variable.
sourcepub fn get_notify_note(&self) -> bool
pub fn get_notify_note(&self) -> bool
Returns the current value of the NOTIFY_NOTE script variable.
sourcepub fn set_notify_note(&mut self, value: bool)
pub fn set_notify_note(&mut self, value: bool)
Sets the current value of the NOTIFY_NOTE script variable.
sourcepub fn get_game_mode(&self) -> i32
pub fn get_game_mode(&self) -> i32
Gets the value of the GAME_MODE script variable.
sourcepub fn get_special_episode_type(&self) -> i32
pub fn get_special_episode_type(&self) -> i32
Gets the special episode type from the SPECIAL_EPISODE_TYPE script variable.