pub struct ScriptVariables(_);
Expand description

Helper struct for manipulating the global and local script variables.

Implementations§

source§

impl ScriptVariables

source

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 muts.

source

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.

source

pub fn global_variable( &self, var_id: ScriptVariableId ) -> GlobalScriptVariableRef<'_>

Get a reference to the global variable. This must not be used for local variables.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn init_event_flags(&mut self)

Initializes an assortment of event flag script variables (see the code for an exhaustive list).

source

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.

source

pub fn init_world_map_script_vars(&mut self)

Initializes the WORLD_MAP_* script variable values (IDs 0x55-0x57).

source

pub fn init_dungeon_list_script_vars(&mut self)

source

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.

source

pub fn reset_global_progress(&mut self)

Zero-initializes the global progress struct.

source

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.

source

pub fn get_language_type(&self) -> i32

Gets the language type.

This is the value backing the special LANGUAGE_TYPE script variable.

source

pub fn get_notify_note(&self) -> bool

Returns the current value of the NOTIFY_NOTE script variable.

source

pub fn set_notify_note(&mut self, value: bool)

Sets the current value of the NOTIFY_NOTE script variable.

source

pub fn get_game_mode(&self) -> i32

Gets the value of the GAME_MODE script variable.

source

pub fn get_special_episode_type(&self) -> i32

Gets the special episode type from the SPECIAL_EPISODE_TYPE script variable.

Auto Trait Implementations§

§

impl RefUnwindSafe for ScriptVariables

§

impl Send for ScriptVariables

§

impl Sync for ScriptVariables

§

impl Unpin for ScriptVariables

§

impl UnwindSafe for ScriptVariables

Blanket Implementations§

§

impl<T> Any for Twhere T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dstwhere T: Cast<Dst>,

Casts the value.
§

impl<T> Borrow<T> for Twhere T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dstwhere Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for Twhere U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

source§

impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere Dst: LosslessTryFrom<Src>,

source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
source§

impl<Src, Dst> LossyInto<Dst> for Srcwhere Dst: LossyFrom<Src>,

source§

fn lossy_into(self) -> Dst

Performs the conversion.
source§

impl<T> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dstwhere T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dstwhere T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dstwhere T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.