Log In  


Please help with the code
I would also like to add 2th High score next to in the pannel
Now I only have the Highscore

hiscore=dget(0)
input={}

newhiscore=false
if player and player.score>hiscore then
hiscore=player.score
newhiscore=true

dset(0,hiscore)
end

print(pad0(player.displayscore,5).."0",10,0,7)

if flash and player.score>hiscore then
else
print(pad0(hiscore,5).."0",57,0,7)
end



1
hiscore=dget(0)
hiscore2=dget(1)

if player and player.score>hiscore then
 hiscore2=hiscore
 hiscore=player.score
else if player and player.score>hiscore2 then
 hiscore2=player.score
end

dset(0,hiscore)
dset(1,hiscore2)

it works, but unfortunately after the reset the cart does not save the new score


@asa321 Are you calling cartdata() with a unique name beforehand? e.g. cartdata("mygame54321")


All its oki perfect,
Now Id like add 3th place Hscore to this code.
Please help me.


I haven't tested this, but hopefully it should work:

hiscore=dget(0)
hiscore2=dget(1)
hiscore3=dget(2)

if player and player.score>hiscore then
 hiscore3=hiscore2
 hiscore2=hiscore
 hiscore=player.score
else if player and player.score>hiscore2 then
 hiscore3=hiscore2
 hiscore2=player.score
else if player and player.score>hiscore3 then
 hiscore3=player.score
end

dset(0,hiscore)
dset(1,hiscore2)
dset(2,hiscore3)

Note that you may want to use local variables, and move the high scores into a table for better expandability.


thanks, works perfect


I have next problems
I have now program too large
I d like change this fragment code somethig small

function player_scoreadd(k)
local oldt=player.score
player.score+=k
if player.score>=1500 and oldt<1500 then
lives+=1 end
if player.score>=3000 and oldt<3000 then
lives+=1 end
if player.score>=4500 and oldt<4500 then
lives+=1 end

itd..


If the player gets an extra life every 1500 points, you could probably do this (sorry if it's buggy, this is just off the top of my head)

function player_scoreadd(k)
   local oldt=player.score
   player.score+=k
   lives=player.score\1500 > oldt\1500 and lives+1 or lives
end

It is good ,
and please how add sound every 1500 to this code
sfx(sfx_extralives,0)


If you want to do more than just add one to lives, you're probably better off with a traditional if block:

function player_scoreadd(k)
   local oldt=player.score
   player.score+=k
   if player.score\1500 > oldt\1500 then
      lives+=1
      sfx(sfx_extralives,0)
   end
end

my next request
here are some fragments of the game code

collectible_add(colt_ring,x,y,2,-5)

if collectibletype==colt_ring then
s.score=100
end
add(entities,s)
return s
end
function collectible_update(s)
end

now if on one level I have 3 rings the same and for each ring I get 100 points
I would like to change the code to something like this
if collectibletype==colt_ring then
s.bonus+=1 end
if s.bonus=1 then s.score=100 end
if s.bonus=1 then s.score=200 end
if s.bonus=1 then s.score=400 end
so that for getting the first ring in any order there would be 100 points, for the second 200 points, third 400 points



[Please log in to post a comment]