sannybuilder / dev

Sanny Builder Bug Tracker and Roadmap development
https://sannybuilder.com
43 stars 0 forks source link

Request: To Compile Identical Script for PC or Mobile #38

Open OrionSR opened 3 years ago

OrionSR commented 3 years ago

The overall problem occurs when a script is developed on PC and ported to Android - it's difficult to maintain updates in the PC "prime" file as I make adjustments to the Android version based on testing. Script management would be much easier there was a method to only compile certain code segments if a specific edit mode was enabled.

This idea was suggested by the form used in one of my current scripts. I'm not really sure how a solution might work or look - I didn't want to throw out a problem without offering any kind of solution. This illustrates the idea nicely, and looks pretty similar to the code I'm currently work with.

Idea 1:

{SA
// compile commands only if edit mode is SA
} 
{SA_mobile
// compile commands only if edit mode is SA_mobile
} 

BlipFix6.txt

A snippet from a project to reset radar blips to standard markers only. Currently I need to move the end brackets around to port the script::

{SA}
0ADF: add_dynamic_GXT_entry "BLIPS1" text "Active blips found: ~y~~1~~s~ of ~y~~1~~s~"
0ADF: add_dynamic_GXT_entry "BLIPS2" text "Stray destination blips removed: ~y~~1~~s~~n~Hidden blips removed: ~y~~1~~s~"
0ADF: add_dynamic_GXT_entry "BLIPS3" text "Unknown blips removed: ~y~~1~~s~~n~Current blips active: ~y~~1~~s~ of ~y~~1~~s~"
0ADF: add_dynamic_GXT_entry "BLIPVAR" text "~r~Abnormal VarSpace!~s~"
0ADF: add_dynamic_GXT_entry "BLIPOM0" text "~r~Player on Mission!~n~~s~Current blips active: ~y~~1~~s~ of ~y~~1~~s~"
0ADF: add_dynamic_GXT_entry "BLIPYAY" text "~r~Yay Courier Active!~n~~s~Current blips active: ~y~~1~~s~ of ~y~~1~~s~"
0ADF: add_dynamic_GXT_entry "BLIPGRL" text "~r~Girlfriend Active!~n~~s~Current blips active: ~y~~1~~s~ of ~y~~1~~s~"

while true
  wait 0
  {SA}
  if  
    0ADC:   test_cheat CheatString 
  then
  {SA_mobile
  if  
    zero == 0 // triggered with Cleo Menu
  then
    gosub @Get_Android_Addresses }
    if or
      not &3(zero,1i) == NormalVarspace
      $OnMission == true
      $YayCourier_Active == true
      08B4:   test $Dating_Flags bit Dating_OnDate 
      08B4:   test $Dating_Flags bit Dating_Meeting
    then
      gosub @Error_Report
    else   
      gosub @Fill_MarkerArray
      gosub @Get_Special_Markers
      gosub @Create_Handle_Array
      gosub @Remove_Stray_Blips
      gosub @Remove_Hidden_Blips
      gosub @Ignore_Standard_Markers
      gosub @Remove_Unknown_Blips
      gosub @Count_Current_Blips
      gosub @Display_Report
    end
    {SA_mobile end_thread}
  end
end
x87 commented 3 years ago

Yes, this sounds like a use-case for preprocessor directives that can be found in many languages: https://en.wikibooks.org/wiki/C_Programming/Preprocessor_directives_and_macros##ifdef,#ifndef