-- LUA Script - precede every function and global member with lowercase name of script -- My load to zone script (modified from Moshroom's script) -- This script loads game data saved with my save_to_zone1 script -- you will need to change activeslot number for each level or create a global variable -- for each level with that level's slot number -- for each weapon in your previous level you will need to place a -- weapon of exact same type in an inaccessible location or set it to not spawn on start -- record the entity number for that weapon and type it in the section of this script -- for that weapon type i.e. if entity number for the sword is 3 go to the sword test -- section and change weapon = nil to weapon = 3 and repeat for each weapon type -- Define loadPhase as table to allow multiple load points newcash = {} g_Second = {} cash = 0 mobcount = 0 playroar = 0 Panel(90,80,98,84) TextCenterOnX(94,83,1,"Gold: "..cash) -- Init when level first runs function load_to_zone1_init(e) newsword = 0 newhalberd = 0 newdagger = 0 newcrossbow = 0 newstaff = 0 newbow = 0 newmace = 0 newflail = 0 newhatchet = 0 newslingshot = 0 activeSlot = 0 end function load_to_zone1_main(e) if g_Entity[e]['plrinzone']==1 then activeSlot = 1 local file = io.open("slot" .. activeSlot .. ".dat", "r") -- If slotx.dat doesn't exist, return nil if file == nil then Prompt("No saved game in slot " .. activeSlot .. ".") -- If slotx.dat does exist, load previous data from file else -- Load player health and lives local fHealth = file:read("*n", "*l") local fLives = file:read("*n", "*l") g_First = file:read("*n", "*l") for i = 1,10 do g_Second[i] = file:read("*l") end g_Third = file:read("*n", "*l") g_Fourth = file:read("*n", "*l") -- Set player data SetPlayerHealth(fHealth) SetPlayerLives(e, fLives) -- Add weapons collected in previous level for i = 1,10 do if g_Second[i] ~= nil and g_Second[i] ~= 0 then if g_Second[i] == 'sword' or g_Second[i] == 'Sword' then if newsword == 0 then -- entity number for placed sword weapon = 12 newsword = 1 end elseif g_Second[i] == 'halberd' or g_Second[i] == 'Halberd' then if newhalberd == 0 then -- entity number for placed halberd weapon = nil newhalberd = 1 end elseif g_Second[i] == 'dagger' or g_Second[i] == 'Dagger' then if newdagger == 0 then -- entity number for placed dagger weapon = 10 newdagger = 1 end elseif g_Second[i] == 'crossbow' or g_Second[i] == 'Crossbow' then if newcrossbow == 0 then -- entity number for placed crossbow weapon = nil newcrossbow = 1 end elseif g_Second[i] == 'staff' or g_Second[i] == 'Staff' then if newstaff == 0 then -- entity number for placed staff weapon = nil newstaff = 1 end elseif g_Second[i] == 'bow' or g_Second[i] == 'Bow' then if newbow == 0 then -- entity number for placed staff weapon = nil newbow = 1 end elseif g_Second[i] == 'mace' or g_Second[i] == 'Mace' then if newmace == 0 then -- entity number for placed mace weapon = 11 newmace = 1 end elseif g_Second[i] == 'flail' or g_Second[i] == 'Flail' then if newflail == 0 then -- entity number for placed mace weapon = nil newflail = 1 end elseif g_Second[i] == 'hatchet' or g_Second[i] == 'Hatchet' then if newhatchet == 0 then -- entity number for placed hatchet weapon = nil newhatchet = 1 end else if newslingshot == 0 then -- entity number for placed slingshot weapon = nil newslingshot = 1 end end AddPlayerWeapon(weapon) end end if g_First ~= nil then cash = g_First else cash = 0 end if g_Third ~= nil then mobcount = g_Third else mobcount = 0 end g_PlayerGunCount = g_Fourth end end Destroy(e) end