Name Typ Von
Highscore (aktualisiert über Funktion) Definition AFRLme

Mit diesem Skript erstellst du ein Interface für einen Highscore und kannst Punkte addieren oder abziehen; positive und negative Punktwerte sind erlaubt.

Anweisungen

1. Füge das Hauptskript im Skripteditor von Visionaire Studio hinzu und lege es als Definitionsskript fest.
2. Lege ein neues Interface score_interface an.
3. Lege 8 Buttons an und benenne sie so: btn_inc, btn_d1, btn_d2, btn_d3, btn_d4, btn_d5, btn_d6, btn_d7.
4. Erstelle das Hintergrundbild für das Interface und füge es in den Eigenschaften des Interface ein.
5. Lege die absolute Position des Interface fest, ausgehend von der Standardauflösung des Spiels.
6a. Du brauchst 12 PNG-Bilder mit transparentem Hintergrund, alle exakt gleich breit und hoch.

  • b. 10 der Bilder sollten eine einzelne Zahl enthalten; von 0 zu 9.
  • c. ein einzelnes Bild sollte leer bleiben; Dies wird verwendet, um inaktive Ziffern auszublenden.
  • d. Der letzte sollte a enthalten -; wenn der Score-Wert negativ ist, wird dieser vor der ersten Zahl angezeigt.
  • e. Speichere jedes Zahlenbild unter seiner Zahl, also n_0, n_1, n_2 usw.
  • f. Speichere das leere Bild als n_10. So benannt kannst du alle Bilder als Satz in eine Animation importieren, statt jeden Frame einzeln hinzuzufügen.
  • g. Das Bild - kannst du beliebig benennen.

7. Lege für jeden Button eine Animation an und benenne sie so: ani_d1, ani_d2, ani_d3, ani_d4, ani_d5, ani_d6, ani_d7, ani_inc; der Name entspricht jeweils dem Teil nach dem Präfix btn_.
8. Lade die Zahlenanimationen als Satz in jeden der nummerierten Buttons.
9. Lege für die Animation btn_ani 2 Frames an: das leere Bild in den ersten Frame, das Bild „-“ in den zweiten.
10. Stelle in den Eigenschaften jedes Buttons die Standardanimation auf die Animation, die du dem Button hinzugefügt hast.
11. Füge im Reiter Werte des score_interface den Wert v_score hinzu und setze den Standardwert auf 0.
12. Um Punkte zum aktuellen Stand hinzuzufügen, legst du einen Aktionsteil Skript ausführen mit folgendem Inhalt an ...

setScore(n, true) -- replace n with number you want to add to the current score.

13. Um Punkte abzuziehen, legst du einen Aktionsteil Skript ausführen mit folgendem Inhalt an ...

setScore(n, false) -- replace n with number you want to subtract from the current score.

Hauptskript

--[[
High Score (updated via function) [v2.1] (29/03/2014)
Written by AFRLme [Lee Clarke]
-- + --
alternatingfrequencies@hotmail.com | skype @ AFRLme
-- + --
This script is donation optional. In game credit is non-negotiable.
You are free to: ¹ use it in your game(s). ² modify the script.
Do not remove - or edit - this comment block.
--]]

-- * local variables * --
local score = getObject("Values[v_score]") -- store score value

-- * function used to set score value & determine which animations/frames should be displayed * --
function setScore(val, inc)
if inc then score:setValue(VValueInt, (score:getInt(VValueInt) + val)) else score:setValue(VValueInt, (score:getInt(VValueInt) - val)) end -- if true add val to current score else remove val from current score
if string.len( math.abs( score:getInt(VValueInt ) ) ) < 7  then -- check digit value less than 7 & if so, hide the invalid digits
 for i = (string.len(val) + 1), 7 do  -- actual digit value (+1) to max digit value
  getObject("ActiveAnimations[ani_d" .. i .. "]"):setValue(VAnimationFirstFrame, 11); getObject("ActiveAnimations[ani_d" .. i .. "]"):setValue(VAnimationLastFrame, 11) -- blank animation frame
  end
 end
 if score:getInt(VValueInt) >= 0 then -- if value is positive do positive block else do negative block
  for i = 1, string.len( score:getInt(VValueInt) ) do -- set the frame value to match the digit number
   getObject("ActiveAnimations[ani_inc]"):setValue(VAnimationFirstFrame, 1); getObject("ActiveAnimations[ani_inc]"):setValue(VAnimationLastFrame, 1) -- positive value; set blank frame
   getObject("ActiveAnimations[ani_d" .. i .. "]"):setValue(VAnimationFirstFrame, string.sub( score:getInt(VValueInt), i, i ) + 1) -- set linked animation first frame to digit value (+1)
   getObject("ActiveAnimations[ani_d" ..  i .. "]"):setValue(VAnimationLastFrame, string.sub( score:getInt(VValueInt), i, i ) + 1) -- set linked animation last frame to digit value (+1)
  end
 else for i = 1, string.len( - score:getInt(VValueInt) ) do -- set the frame value to match the digit number
  getObject("ActiveAnimations[ani_inc]"):setValue(VAnimationFirstFrame, 2); getObject("ActiveAnimations[ani_inc]"):setValue(VAnimationLastFrame, 2)  -- negative value; set negative frame
  getObject("ActiveAnimations[ani_d" .. i .. "]"):setValue(VAnimationFirstFrame, string.sub( - score:getInt(VValueInt), i, i ) + 1) -- set linked animation first frame to digit value (+1)
  getObject("ActiveAnimations[ani_d" ..  i .. "]"):setValue(VAnimationLastFrame, string.sub( - score:getInt(VValueInt), i, i ) + 1) -- set linked animation last frame to digit value (+1)
  end
 end
end