-- LUA Script - precede every function and global member with lowercase name of script -- script by Moshroom edited by honkeyboy -- Returnzone 2.1 (compatibility with the official Save/Load system) by Moshroom -- Activates Return Trigger -- Saves RPG and Quest data to a temporary file to be reloaded later by Return entity -- Define the constants NUM_INV = 39 NUM_COUNTERS = 9999 -- Define tables for inventory InvItem = {} InvWeapon = {} InvArmor = {} InvAccessory = {} -- Define table for Quest Counters QCounter = {} function moshroom_map_returnzonep1_init(e) -- NOTE: All RPG and Survival statistics are initiated in the global function RPG_Initiate() -- This is done because otherwise the values would be reset to zero after a Load Game end function RPG_Initiate() -- Init the clock if TimeCounter == nil then TimeCounter = 0 end if TimeSecond == nil then TimeSecond = 0 end if TimeMinute == nil then TimeMinute = 0 end if TimeHour == nil then TimeHour = 0 end -- Init the options if CursorPosition == nil then CursorPosition = 1 end if TextSize == nil then TextSize = 1 end if FrontPageText == nil then FrontPageText = 1 end if MessageWindow == nil then MessageWindow = 1 end if BMessageWindow == nil then BMessageWindow = 1 end -- Init the RPG stats if g_RPG_Level == nil then g_RPG_Level = 1 end if g_RPG_EXP == nil then g_RPG_EXP = 0 end if g_RPG_Threshold == nil then g_RPG_Threshold = 0 end if g_RPG_ToNextLevel == nil then g_RPG_ToNextLevel = 0 end if g_RPG_MAXHP == nil then g_RPG_MAXHP = g_PlayerHealth end if g_RPG_SpellPower == nil then g_RPG_SpellPower = 100 end if g_RPG_Vitality == nil then g_RPG_Vitality = 100 end if g_RPG_Agility == nil then g_RPG_Agility = 100 end if g_RPG_Sight == nil then g_RPG_Sight = 100 end if g_RPG_State == nil then g_RPG_State = 1 end if g_RPG_Gold == nil then if FLAG_AI == nil then g_RPG_Gold = 10000 else g_RPG_Gold = 0 end if g_animal_items == nil then g_animal_items = 0 end if g_kills == nil then g_kills = 0 end if g_alien_items == nil then g_alien_items = 0 end if g_robot_items == nil then g_robot_items = 0 end if g_rootscollected == nil then g_rootscollected = 0 end if g_fiberscollected == nil then g_fiberscollected = 0 end if g_tuberscollected == nil then g_tuberscollected = 0 end if g_goldnuggetscollected == nil then g_goldnuggetscollected = 0 end if g_woodcollected == nil then g_woodcollected = 0 end if g_rockscollected == nil then g_rockscollected = 0 end if g_ironscollected == nil then g_ironscollected = 0 end if g_gemscollected == nil then g_gemscollected = 0 end if g_watercollected == nil then g_watercollected = 0 end if g_coppercollected == nil then g_coppercollected = 0 end if g_tungstencollected == nil then g_tungstencollected = 0 end if g_zincscollected == nil then g_zincscollected = 0 end if g_sodiumcollected == nil then g_sodiumcollected = 0 end if g_potassiumcollected == nil then g_potassiumcollected = 0 end if g_titanitecollected == nil then g_titanitecollected = 0 end if g_promethiumcollected == nil then g_promethiumcollected = 0 end if g_mk1_auto_miner_schematic == nil then g_mk1_auto_miner_schematic = 0 end if g_mk1_scanner_miner == nil then g_mk1_scanner_miner = 0 end if g_base_hanger_beacon_schematic == nil then g_base_hanger_beacon_schematic = 0 end if g_base_hanger_beacon_active == nil then g_base_hanger_beacon_active = 0 end if g_base_factory_schematic == nil then g_base_factory_schematic = 0 end if g_base_factory_active == nil then g_base_factory_active = 0 end if g_base_med_bay_schematic == nil then g_base_med_bay_schematic = 0 end if g_base_med_bay_active == nil then g_base_med_bay_active = 0 end if g_base_crafting_schematic == nil then g_base_crafting_schematic = 0 end if g_base_crafting_active == nil then g_base_crafting_active = 0 end if g_base_command_schematic == nil then g_base_command_schematic = 0 end if g_base_command_active == nil then g_base_command_active = 0 end if g_medipack_schematic == nil then g_medipack_schematic = 0 end if g_ammo_schematic == nil then g_ammo_schematic = 0 end if g_food_schematic == nil then g_food_schematic = 0 end if g_water_schematic == nil then g_water_schematic = 0 end if g_adrenaline_schematic == nil then g_adrenaline_schematic = 0 end -- if g_miner == nil then -- g_miner = 0 -- end end -- Init the Spell system if g_RPG_MP == nil then g_RPG_MP = 100 end if g_RPG_MAXMP == nil then g_RPG_MAXMP = 100 end -- Init the equipment if g_Eq_Weapon == nil then g_Eq_Weapon = 0 end if g_Eq_Armor == nil then g_Eq_Armor = 0 end if g_Eq_Accessory == nil then g_Eq_Accessory = 0 end if g_Eq_Accessory_Target == nil then g_Eq_Accessory_Target = 0 end if g_Eq_Accessory_Effect == nil then g_Eq_Accessory_Effect = 0 end -- Init the abnormal states if g_RPG_FeeblePenalty == nil then g_RPG_FeeblePenalty = 0 end if g_RPG_WeakPenalty == nil then g_RPG_WeakPenalty = 0 end if g_RPG_SlowPenalty == nil then g_RPG_SlowPenalty = 0 end if g_RPG_BlindPenalty == nil then g_RPG_BlindPenalty = 0 end -- Initiate Survival variables if g_Survival_Hunger == nil then g_Survival_Hunger = 0 end if g_Survival_Thirst == nil then g_Survival_Thirst = 0 end if g_Survival_Tiredness == nil then g_Survival_Tiredness = 0 end end function moshroom_map_returnzonep1_main(e) g_planet[1] = 1 -- Initiate the RPG Module RPG_Initiate() -- The action... if g_Entity[e]['plrinzone'] == 1 then -- Create local variable file and link it to temp.dat local file = io.open("temp.dat", "w") -- Write player data to file file:write( TimeHour .. "\n" .. TimeMinute .. "\n" .. TimeSecond .. "\n" .. g_RPG_Gold .. "\n" .. g_RPG_Level .. "\n" .. g_RPG_EXP .. "\n" .. g_RPG_SpellPower .. "\n" .. g_RPG_Vitality .. "\n" .. g_RPG_Agility .. "\n" .. g_RPG_Sight .. "\n" .. g_RPG_State .. "\n" .. g_PlayerHealth .. "\n" .. g_PlayerLives .. "\n" .. --added items g_kills .. "\n" .. g_animal_items .. "\n" .. g_alien_items .. "\n" .. g_robot_items .. "\n" .. g_rootscollected .. "\n" .. g_fiberscollected .. "\n" .. g_tuberscollected .. "\n" .. g_goldnuggetscollected .. "\n" .. g_woodcollected .. "\n" .. g_rockscollected .. "\n" .. g_ironscollected .. "\n" .. g_gemscollected .. "\n" .. g_watercollected .. "\n" .. g_coppercollected .. "\n" .. g_tungstencollected .. "\n" .. g_zincscollected .. "\n" .. g_sodiumcollected .. "\n" .. g_potassiumcollected .. "\n" .. g_titanitecollected .. "\n" .. g_promethiumcollected .. "\n" .. g_mk1_auto_miner_schematic .. "\n" .. g_mk1_scanner_miner.. "\n" .. g_base_hanger_beacon_schematic .. "\n" .. g_base_hanger_beacon_active .. "\n" .. g_base_factory_schematic .. "\n" .. g_base_factory_active .. "\n" .. g_base_med_bay_schematic .. "\n" .. g_base_med_bay_active .. "\n" .. g_base_crafting_schematic .. "\n" .. g_base_crafting_active .. "\n" .. g_base_command_schematic .. "\n" .. g_base_command_active .. "\n" .. g_medipack_schematic .. "\n" .. g_ammo_schematic .. "\n" .. g_food_schematic .. "\n" .. g_water_schematic .. "\n" .. g_adrenaline_schematic .. "\n" .. -- g_miner .. "\n" .. g_Eq_Weapon .. "\n" .. g_Eq_Armor .. "\n" .. g_Eq_Accessory .. "\n" .. TextSize .. "\n" .. CursorPosition .. "\n" .. FrontPageText .. "\n" .. MessageWindow .. "\n" .. BMessageWindow .. "\n") -- Write the inventory tables to file for i = 1,NUM_INV do if InvItem[i] ~= nil then file:write(InvItem[i] .. "\n") else file:write("0\n") end end for i = 1,NUM_INV do if InvWeapon[i] ~= nil then file:write(InvWeapon[i] .. "\n") else file:write("0\n") end end for i = 1,NUM_INV do if InvArmor[i] ~= nil then file:write(InvArmor[i] .. "\n") else file:write("0\n") end end for i = 1,NUM_INV do if InvAccessory[i] ~= nil then file:write(InvAccessory[i] .. "\n") else file:write("0\n") end end -- Write the QCounter table to file for i = 1,NUM_COUNTERS do if QCounter[i] ~= nil then file:write(QCounter[i] .. "\n") else file:write("0\n") end end file:close() -- When ready, set the Return flag in temp3.dat file local file = io.open("temp3.dat", "w") file:write("1") file:close() -- Jump to level specified in IfUsed field JumpToLevelIfUsed(e) end end