share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua
branchspacecampaign
changeset 9630 df942cfac4e6
parent 9582 bf314b2258b3
child 9636 e1921235fc78
equal deleted inserted replaced
9629:1655c50d9c51 9630:df942cfac4e6
    63 end
    63 end
    64 
    64 
    65 function saveCheckpoint(cp)
    65 function saveCheckpoint(cp)
    66 	SaveCampaignVar("CurrentMissionCheckpoint", cp)
    66 	SaveCampaignVar("CurrentMissionCheckpoint", cp)
    67 end
    67 end
       
    68 
       
    69 -- saves what bonuses are available
       
    70 -- times is how many times the bonus will be available, this will be mission specific
       
    71 function saveBonus(index, times)
       
    72 	--        1         2        3
       
    73 	-- order: desert03, fruit03, death02
       
    74 	local bonus = "000"
       
    75 	if tonumber(GetCampaignVar("SideMissionsBonuses")) then
       
    76 		bonus = GetCampaignVar("SideMissionsBonuses")
       
    77 	end
       
    78 	if i == 1 then
       
    79 		bonus = times..bonus:sub(index+1)
       
    80 	elseif i == bonus:len() then
       
    81 		bonus = bonus:sub(1,index-1)..times
       
    82 	else
       
    83 		bonus = bonus:sub(1,index-1)..times..bonus:sub(index+1)
       
    84 	end
       
    85 	SaveCampaignVar("SideMissionsBonuses",bonus)
       
    86 end
       
    87 
       
    88 function getBonus(index)
       
    89 	local bonus = 0
       
    90 	if tonumber(GetCampaignVar("SideMissionsBonuses")) then
       
    91 		bonusString = GetCampaignVar("SideMissionsBonuses")
       
    92 		bonus = bonusString:sub(index,index)
       
    93 	end
       
    94 	return bonus
       
    95 end