0% found this document useful (0 votes)
2 views

SpaceNote

The document contains a script for a game that manages note mechanics, specifically for a 'SpaceNote' type. It includes functions to create and update strums, handle input from the spacebar, and calculate ratings for hits based on timing. Additionally, it allows for customization of gameplay features such as disabling strums and adjusting properties for notes in different game modes.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

SpaceNote

The document contains a script for a game that manages note mechanics, specifically for a 'SpaceNote' type. It includes functions to create and update strums, handle input from the spacebar, and calculate ratings for hits based on timing. Additionally, it allows for customization of gameplay features such as disabling strums and adjusting properties for notes in different game modes.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

function onCreate()

DisabledStrum=false
Hellmode=false
end
function onCreatePost()
for i = 0, getProperty('unspawnNotes.length')-1 do
if getPropertyFromGroup('unspawnNotes', i, 'noteType') == 'SpaceNote'
then
setPropertyFromGroup('unspawnNotes', i, 'texture',
"Bronzong_Gong_mechanic")
setPropertyFromGroup('unspawnNotes', i, 'noteData', 4)
if Hellmode then
setPropertyFromGroup('unspawnNotes', i, 'multAlpha', 0)
else
setPropertyFromGroup('unspawnNotes', i, 'multAlpha', 1)
end
setPropertyFromGroup('unspawnNotes', i, 'mustPress', true)
setPropertyFromGroup('unspawnNotes', i, 'noteSplashDisabled', true)

if getPropertyFromGroup('unspawnNotes', i, 'isSustainNote') then


runHaxeCode([[
var Note:Note=game.unspawnNotes[]]..i..[[];
Note.animation.addByPrefix('spacebarholdend','spacebar hold
end');
Note.animation.addByPrefix('spacebarhold','spacebar hold
piece');

if(Note.prevNote != null){
Note.animation.play('spacebarholdend',true);
if(Note.prevNote.isSustainNote){
Note.prevNote.animation.play('spacebarhold',true);
}
}
]])
setPropertyFromGroup('unspawnNotes', i, 'offsetX', 8)

else
runHaxeCode([[
var Note:Note=game.unspawnNotes[]]..i..[[];
Note.animation.addByPrefix('spaceScroll', "spacebar0");
Note.animation.play('spaceScroll',true);
]])
setPropertyFromGroup('unspawnNotes', i, 'offsetX', -138)
end
if DisabledStrum then
setPropertyFromGroup('unspawnNotes', i, 'multAlpha', 0)
setPropertyFromGroup('unspawnNotes', i, 'blockHit', true)
setPropertyFromGroup('unspawnNotes', i, 'ignoreNote', true)
setPropertyFromGroup('unspawnNotes', i, 'noteData', 2)
end
end
end

if not DisabledStrum then


CreateStrum()
else
for i=0,3 do
setPropertyFromGroup('opponentStrums',i,'x',(160 * 0.7) * i+50-278+
((screenWidth / 2) * 1)+3000)
if not middlescroll then
setPropertyFromGroup('playerStrums',i,'x',(160 * 0.7) * i+50+42+
((screenWidth / 2) * 0))
end
end
end
end
function onUpdate(elapsed)
for ProxNote=0,getProperty('notes.length')-1 do
if ProxNote~= -1 and not DisabledStrum and not botPlay then
local MustPress=getPropertyFromGroup('notes',ProxNote,'mustPress')
local isSUS=getPropertyFromGroup('notes',ProxNote,'isSustainNote')
local wasGood=getPropertyFromGroup('notes',ProxNote,'wasGoodHit')
local Late=getPropertyFromGroup('notes',ProxNote,'tooLate')
local CanHit=getPropertyFromGroup('notes',ProxNote,'canBeHit')
local Notedata=getPropertyFromGroup('notes',ProxNote,'noteData')
if keyJustPressed('space') then
if not isSUS and not wasGood and not Late and CanHit and
Notedata==4 and MustPress then
GoodSpaceHit(ProxNote)
else
Pressed()
end
elseif keyPressed('space') then
if isSUS and CanHit and not wasGood and not Late and Notedata==4
and MustPress then
GoodSpaceHit(ProxNote)
else
Pressed()
end
elseif keyReleased('space') then
runHaxeCode('getVar("SpaceBar").playAnim("static");')
setProperty('SpaceBar.resetAnim',0)
end
end
end
end
function CreateStrum()
addHaxeLibrary('StrumNote')
runHaxeCode([[
var NewStrum:StrumNote= new StrumNote(0,(ClientPrefs.downScroll ?
FlxG.height - 150 : 50)+30, 4, 1);
var Texture:String= "Bronzong_Gong_mechanic";
NewStrum.frames= Paths.getSparrowAtlas(Texture);
NewStrum.animation.addByPrefix('space', 'spacebar0');
NewStrum.animation.addByPrefix('static', 'spacebar0');
NewStrum.animation.addByPrefix('pressed', 'spacebar press', 24, false);
NewStrum.animation.addByPrefix('confirm', 'spacebar confirm', 24, false);
NewStrum.updateHitbox();
NewStrum.playAnim('static', true);

game.playerStrums.add(NewStrum);
NewStrum.downScroll= ClientPrefs.downScroll;
game.strumLineNotes.add(NewStrum);
setVar("SpaceBar",NewStrum);
]])
local Offset=100
if middlescroll then
Offset=268
end
for i=0,4 do
setPropertyFromGroup('opponentStrums',i,'x',(160 * 0.7) * i+50+
((screenWidth / 2) * 1)+3000)
setPropertyFromGroup('playerStrums',i,'x',(160 * 0.7) * i+50+
((screenWidth / 2) * 0)-40+Offset)
if i>1 then
setPropertyFromGroup('playerStrums',i,'x',(160 * 0.7) * i+50+
((screenWidth / 2) * 0)+220+Offset)
end
if i==4 then
setPropertyFromGroup('playerStrums',i,'x',(160 * 0.7) * 3+50+
((screenWidth / 2) * 0)-60+Offset)
end
end
end
function Pressed()
if runHaxeCode("return getVar(\"SpaceBar\") != null") then
if getProperty('SpaceBar.animation.curAnim.name')~='confirm' then
runHaxeCode('getVar("SpaceBar").playAnim("pressed", true);')
setProperty('SpaceBar.resetAnim',0)
end
end
end
function GoodSpaceHit(NoteID)
if not getPropertyFromGroup('notes',NoteID,'isSustainNote') then
setProperty('combo',getProperty('combo')+1)
local ratingOffset=getPropertyFromClass('ClientPrefs','ratingOffset')
local Rating= (getPropertyFromGroup('notes',NoteID,'strumTime') -
getSongPosition() + ratingOffset)
local List={}
debugPrint(Rating)
for i=0,getProperty('ratingsData.length')-1 do
table.insert(List,getProperty('ratingsData['..i..'].hitWindow'))
end
RatingScore=math.abs(Rating)
setPropertyFromGroup('notes',NoteID,'ratingMod',RatingScore)
if RatingScore <= List[1] then
setPropertyFromGroup('notes',NoteID,'rating','sick')
setProperty('sicks',getProperty('sicks')+1)
elseif RatingScore <= List[2] then
setPropertyFromGroup('notes',NoteID,'rating','good')
setProperty('goods',getProperty('goods')+1)
elseif RatingScore <= List[3] then
setPropertyFromGroup('notes',NoteID,'rating','bad')
setProperty('bads',getProperty('bads')+1)
elseif RatingScore <= List[4] then
setPropertyFromGroup('notes',NoteID,'rating','shit')
setProperty('shits',getProperty('shits')+1)
else
setPropertyFromGroup('notes',NoteID,'rating','shit')
setProperty('shits',getProperty('shits')+1)
end
end
callOnLuas('goodNoteHit',
{NoteID,4,'SpaceNote',getPropertyFromGroup('notes',NoteID,'isSustainNote')})

runHaxeCode([[
if(getVar("SpaceBar") != null){
getVar("SpaceBar").playAnim("confirm", true);
getVar("SpaceBar").resetAnim=0;
}

]])

setPropertyFromGroup('notes',NoteID,'wasGoodHit',true)
if not getPropertyFromGroup('notes',NoteID,'isSustainNote') then

runHaxeCode([[
var note:Note=game.notes.members[]]..NoteID..[[];
if(note != null){
note.kill();
game.notes.remove(note, true);
note.destroy();
}
]])
end
end

You might also like