@@ -528,19 +528,20 @@ fn hook_infos(src: ByondValue) -> Result<ByondValue> {
528528fn update_visuals ( src : ByondValue ) -> Result < ByondValue > {
529529 use super :: gas;
530530 match src. read_var_id ( byond_string ! ( "air" ) ) {
531- Err ( _) => Ok ( ByondValue :: null ( ) ) ,
532- Ok ( air) => {
531+ Ok ( air) if !air. is_null ( ) => {
533532 // gas_overlays: list( GAS_ID = list( VIS_FACTORS = OVERLAYS )) got it? I don't
534533 let gas_overlays = ByondValue :: new_global_ref ( )
535534 . read_var_id ( byond_string ! ( "GLOB" ) )
536- . wrap_err ( "GLOB is null " ) ?
535+ . wrap_err ( "Unable to get GLOB from BYOND globals " ) ?
537536 . read_var_id ( byond_string ! ( "gas_data" ) )
538- . wrap_err ( "gas_data is null " ) ?
537+ . wrap_err ( "gas_data is undefined on GLOB " ) ?
539538 . read_var_id ( byond_string ! ( "overlays" ) )
540- . wrap_err ( "overlays is null " ) ?;
539+ . wrap_err ( "overlays is undefined in GLOB.gas_data " ) ?;
541540 let ptr = air
542- . read_number_id ( byond_string ! ( "_extools_pointer_gasmixture" ) )
543- . wrap_err ( "Gas mixture doesn't have a valid pointer" ) ? as usize ;
541+ . read_var_id ( byond_string ! ( "_extools_pointer_gasmixture" ) )
542+ . wrap_err ( "air is undefined on turf" ) ?
543+ . get_number ( )
544+ . wrap_err ( "Gas mixture has invalid pointer" ) ? as usize ;
544545 let overlay_types = GasArena :: with_gas_mixture ( ptr, |mix| {
545546 Ok ( mix
546547 . enumerate ( )
@@ -569,6 +570,12 @@ fn update_visuals(src: ByondValue) -> Result<ByondValue> {
569570 )
570571 . wrap_err ( "Calling set_visuals" ) ?)
571572 }
573+ // If air is null, clear the visuals
574+ Ok ( _) => Ok ( src
575+ . call_id ( byond_string ! ( "set_visuals" ) , & [ ] )
576+ . wrap_err ( "Calling set_visuals with no args" ) ?) ,
577+ // If air is not defined, it must be a closed turf. Do .othing
578+ Err ( _) => Ok ( ByondValue :: null ( ) ) ,
572579 }
573580}
574581
0 commit comments