

save_skip_list <-
{
  save_skip_list=1
  save_state_list=1
  monster_spawn_enabled=1
  PI=1
  GOLD_RATIO=1
  RAND_MAX=1
  universe=1
  scheme_weights=1
  schemes=1
  modifiers=1
  world_palettes=1
  universe_devmode=1
  update_check_delay=1
  in_main_menu=1
  cur_world=1
  cur_mod=1
  wgen=1
  world_elements=1
}


save_state_list <-
{
  cur_world_pal=1
  listeners=1
  destroyed_listeners=1
}


function get_savegame_globals()
{
  local errcnt=0
  local data={}

  foreach (name, val in getroottable())
  {
    if (name in save_state_list)
    {
      // print(format("'%s' (%s) will be saved\n", name, typeof val));
      data[name]<-val
      continue;
    }

    if (name in save_skip_list) continue;

    if (name[0]=='_' && name[name.len()-1]=='_') continue;

    local t=typeof val

    // if (t=="class")
    // {
    //   print("class "+name+":\n")
    //   foreach (mname, mval in val)
    //     print(format("  %s: %s\n", mname, typeof mval))
    // }

    if (t=="function" || t=="class") continue;

    print(format("Error: unknown script global '%s' (%s)\n", name, t))
    ++errcnt;
  }

  if (errcnt)
  {
    print(format("Error: %d unknown script globals\n", errcnt))
    return null;
  }

  return data;
}
