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

P#148481 2024-05-16 14:11

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)
P#148484 2024-05-16 14:31

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

P#148511 2024-05-16 22:43

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

P#148512 2024-05-16 22:51

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

P#148559 2024-05-17 17:39

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.

P#148575 2024-05-17 21:54

thanks, works perfect

P#148858 2024-05-23 18:00

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..

P#148859 2024-05-23 18:07

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
P#148861 2024-05-23 18:45

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

P#148864 2024-05-23 19:29

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
P#148899 2024-05-24 11:31

[Please log in to post a comment]