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
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/85395/picocolordance_24.gif)
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) |
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/bimg/pi/pi13.png)
it works, but unfortunately after the reset the cart does not save the new score
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/bimg/pi/pi13.png)
All its oki perfect,
Now Id like add 3th place Hscore to this code.
Please help me.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/92447/Logo.png)
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.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/bimg/pi/pi13.png)
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..
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/14590/2_2bitchuck.png)
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 |
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/bimg/pi/pi13.png)
It is good ,
and please how add sound every 1500 to this code
sfx(sfx_extralives,0)
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/14590/2_2bitchuck.png)
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 |
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/bimg/pi/pi13.png)
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]