Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple character problem #703

Closed
mihaillov opened this issue Oct 29, 2024 · 20 comments
Closed

Multiple character problem #703

mihaillov opened this issue Oct 29, 2024 · 20 comments
Labels
help wanted Extra attention is needed

Comments

@mihaillov
Copy link

Describe your problem here. If you are modding, please try testing your problem in a clean version of the engine instead, this ensures the problem is actually caused by the engine itself. Also, if you're using an older version of JSE, please try the latest action build in the Actions tab or the latest release build. The issue has probably been fixed since that version. Oh yeah, and also be sure to check the pinned 'JS Engine: Known Issues' issue, to double check if your issue hasn't already been found!

I use this script for marathons but if the opponent sings with note,other characters sings too!In the code i do not have the name_of_notetype2 line

Are you modding a build from source or with Lua?

Lua

What is your build target?

Windows x64

Did you edit anything in this build? If so, mention or summarize your changes.

no

@mihaillov mihaillov added the help wanted Extra attention is needed label Oct 29, 2024
@mihaillov
Copy link
Author

there is the code of character example:
-- script by ItsCapp don't steal, it's dumb
-- https://gamebanana.com/tools/8427

-- simply, offsets. they're the numbers in the top left of the character editor
idleOffsets = {'0', '0'} -- I recommend you have your idle offset at 0
leftOffsets = {'', ''}
downOffsets = {'', ''}
upOffsets = {'', ''}
rightOffsets = {'', ''}

-- change all of these to the name of the animation in your character's xml file including the leading 0. Caps Sensitive.
idle_xml_name = 'ant idle0'
left_xml_name = 'ant left0'
down_xml_name = 'ant down0'
up_xml_name = 'ant up0'
right_xml_name = 'ant right0'
-- horizontal and vertical positions
x_position = 250
y_position = 400

-- scales your character (set to 1 by default)
xScale = 1
yScale = 1

-- pretty self-explanitory
name_of_character_xml = 'ant'
name_of_character = 'ant'
charNote = 'abt'
--charNote2 = '' -- to distinguish between multiple characters singing at the same time (uncomment to use)
--altCharNote = '' -- this is used for alt animations (uncomment to use)
--altCharNote2 = '' -- this is used for alt animations and singing at the same time (uncomment to use)

playableCharacter = false -- change to 'true' if you want to the character on teamDad
flipX = true -- most likely change to 'true' if using a BF sided character
useIdle = true -- Use idle code or Dance code (EG: Skid&Pump, GF)
invisible = false -- invisible character (if you want to use the change character event, you need to make the second character invisible first)
teamplay = true -- Should character simply sing all notes on their side
layer = 2 --[[ Usable values:
0 : Behind stage
1 : Behind all
2 : In front of GF, behind Opponent and Player
3 : In front of GF and Opponent, behind Player
4 : In front of All
5+: Free Real Estate --]]



doIdle = true;
seriouslyDontIdle = false; -- if you want to play a longer animation you can use this when necessary to temporarily override doIdle.

function onCreate()
makeAnimatedLuaSprite(name_of_character, 'characters/' .. name_of_character_xml, x_position, y_position);

addAnimationByPrefix(name_of_character, 'idle', idle_xml_name, 24, false);
--addAnimationByIndices(name_of_character, 'danceLeft', idle_xml_name, '8,10,12,14' , 12);
--addAnimationByIndices(name_of_character, 'danceRight', idle_xml_name, '0,2,4,6', 12);
addAnimationByPrefix(name_of_character, 'singLEFT', left_xml_name, 24, false);
addAnimationByPrefix(name_of_character, 'singDOWN', down_xml_name, 24, false);
addAnimationByPrefix(name_of_character, 'singUP', up_xml_name, 24, false);
addAnimationByPrefix(name_of_character, 'singRIGHT', right_xml_name, 24, false);

setPropertyLuaSprite(name_of_character, 'flipX', flipX);
setPropertyLuaSprite(name_of_character, 'alpha', not invisible);
scaleObject(name_of_character, xScale, yScale);
setObjectOrder(name_of_character, layer, false);

end

function onCountdownTick(counter)
idleDance(counter);
end

function onEvent(name, value1, value2)
if name == "CharacterPlayAnimation" then
doIdle = false;
seriouslyDontIdle = true;
addAnimationByPrefix(value2, value1, value1, 24, false);
objectPlayAnimation(value2, value1, true);
elseif name == "ToggleTeamplay" then
local case = {["true"] = true, ["1"] = true, ["false"] = false, ["0"] = false, [""] = not teamplay};
if name_of_character == value1 then
teamplay = case[string.lower(value2)];
end
end
end

local singAnims = {"singLEFT", "singDOWN", "singUP", "singRIGHT"};
local singOffsets = {leftOffsets, downOffsets, upOffsets, rightOffsets};

-- I know this is messy, but it's the only way I know to make it work on both sides.
-- Don't worry bro I cleaned it up -Scarab

function opponentNoteHit(id, direction, noteType, isSustainNote)
if not playableCharacter then
if noteType == charNote or noteType == charNote2 then
doIdle = false;
objectPlayAnimation(name_of_character, singAnims[direction + 1], true);
setProperty(name_of_character .. '.offset.x', singOffsets[direction + 1][1]);
setProperty(name_of_character .. '.offset.y', singOffsets[direction + 1][2]);
elseif noteType == altCharNote or noteType == altCharNote2 then
doIdle = false;
objectPlayAnimation(name_of_character, altAnims[direction + 1], true);
setProperty(name_of_character .. '.offset.x', altOffsets[direction + 1][1]);
setProperty(name_of_character .. '.offset.y', altOffsets[direction + 1][2]);
elseif teamplay then
doIdle = false;
objectPlayAnimation(name_of_character, singAnims[direction + 1], true);
setProperty(name_of_character .. '.offset.x', singOffsets[direction + 1][1]);
setProperty(name_of_character .. '.offset.y', singOffsets[direction + 1][2]);
end
end
end

function goodNoteHit(id, direction, noteType, isSustainNote)
if playableCharacter then
if noteType == charNote or noteType == charNote2 then
doIdle = false;
objectPlayAnimation(name_of_character, singAnims[direction + 1], true);
setProperty(name_of_character .. '.offset.x', singOffsets[direction + 1][1]);
setProperty(name_of_character .. '.offset.y', singOffsets[direction + 1][2]);
elseif noteType == altCharNote or noteType == altCharNote2 then
doIdle = false;
objectPlayAnimation(name_of_character, altAnims[direction + 1], true);
setProperty(name_of_character .. '.offset.x', altOffsets[direction + 1][1]);
setProperty(name_of_character .. '.offset.y', altOffsets[direction + 1][2]);
elseif teamplay then
doIdle = false;
objectPlayAnimation(name_of_character, singAnims[direction + 1], true);
setProperty(name_of_character .. '.offset.x', singOffsets[direction + 1][1]);
setProperty(name_of_character .. '.offset.y', singOffsets[direction + 1][2]);
end
end
end

function noteMiss(id, direction, noteType, isSustainNote)
if playableCharacter then
if getPropertyFromGroup(noteType, i, 'mustPress') then
doIdle = false;
objectPlayAnimation(name_of_character, missAnims[direction + 1], true);
setProperty(name_of_character .. '.offset.x', missOffsets[direction + 1][1]);
setProperty(name_of_character .. '.offset.y', missOffsets[direction + 1][2]);
end
end
end

function onBeatHit()
if doIdle then
idleDance(curBeat);
end
if seriouslyDontIdle then
if getProperty(name_of_character .. '.animation.curAnim.finished') then
doIdle = true;
seriouslyDontIdle = false;
end
else
doIdle = true;
end
end

function idleDance(beat)
if useIdle then
if beat % 2 == 0 then
objectPlayAnimation(name_of_character, 'idle', false);
setProperty(name_of_character .. '.offset.x', idleOffsets[1]);
setProperty(name_of_character .. '.offset.y', idleOffsets[2]);
end
else
if beat % 2 == 0 then
objectPlayAnimation(name_of_character, 'danceLeft', false);
setProperty(name_of_character .. '.offset.x', idleOffsets[1]);
setProperty(name_of_character .. '.offset.y', idleOffsets[2]);
else
objectPlayAnimation(name_of_character, 'danceRight', false);
setProperty(name_of_character .. '.offset.x', idleOffsets[1]);
setProperty(name_of_character .. '.offset.y', idleOffsets[2]);
end
end
end

steveBanned = true

code of notes:
function onCreate()
--Iterate over all notes
for i = 0, getProperty('unspawnNotes.length')-1 do
if getPropertyFromGroup('unspawnNotes', i, 'noteType') == 'abt' then --Check if the note on the chart is a Bullet Note
--setPropertyFromGroup('unspawnNotes', i, 'texture', 'notetexture'); --Change notetexture
--setPropertyFromGroup('unspawnNotes', i, 'noteSplashHue', 0);
--setPropertyFromGroup('unspawnNotes', i, 'noteSplashSat', -20);
--setPropertyFromGroup('unspawnNotes', i, 'noteSplashBrt', 1);

		setPropertyFromGroup('unspawnNotes', i, 'noAnimation', true); -- make it so original character doesn't sing these notes

		if getPropertyFromGroup('unspawnNotes', i, 'mustPress') then --Doesn't let Dad/Opponent notes get ignored
			setPropertyFromGroup('unspawnNotes', i, 'ignoreNote', true); --Miss has penalties
		end
	end
end

end

@JordanSantiagoYT
Copy link
Owner

in that case, delete ALL cases of charNote2

@mihaillov
Copy link
Author

ok imma try this

@mihaillov
Copy link
Author

at this line:if noteType == charNote or noteType == charNote2 then

i need to remove:or noteTyoe == charNote 2 thingy,right?

@JordanSantiagoYT
Copy link
Owner

Yes.

@mihaillov
Copy link
Author

thanks

@mihaillov
Copy link
Author

and i need remove this?
function goodNoteHit(id, direction, noteType, isSustainNote)
if playableCharacter then
if noteType == charNote or noteType == charNote2 then
doIdle = false;
objectPlayAnimation(name_of_character, singAnims[direction + 1], true);
setProperty(name_of_character .. '.offset.x', singOffsets[direction + 1][1]);
setProperty(name_of_character .. '.offset.y', singOffsets[direction + 1][2]);
elseif noteType == altCharNote or noteType == altCharNote2 then
doIdle = false;
objectPlayAnimation(name_of_character, altAnims[direction + 1], true);
setProperty(name_of_character .. '.offset.x', altOffsets[direction + 1][1]);
setProperty(name_of_character .. '.offset.y', altOffsets[direction + 1][2]);
elseif teamplay then
doIdle = false;
objectPlayAnimation(name_of_character, singAnims[direction + 1], true);
setProperty(name_of_character .. '.offset.x', singOffsets[direction + 1][1]);
setProperty(name_of_character .. '.offset.y', singOffsets[direction + 1][2]);
end
end
end

@mihaillov
Copy link
Author

ok i removed everything about charNote2

@mihaillov
Copy link
Author

mihaillov commented Oct 29, 2024

now i have this error on my 3rd character(Ant stands for Anthony)
Снимок экрана 2024-10-29 201835

@mihaillov
Copy link
Author

-- script by ItsCapp don't steal, it's dumb
-- https://gamebanana.com/tools/8427

-- simply, offsets. they're the numbers in the top left of the character editor
idleOffsets = {'0', '0'} -- I recommend you have your idle offset at 0
leftOffsets = {'', ''}
downOffsets = {'', ''}
upOffsets = {'', ''}
rightOffsets = {'', ''}

-- change all of these to the name of the animation in your character's xml file including the leading 0. Caps Sensitive.
idle_xml_name = 'ant idle0'
left_xml_name = 'ant left0'
down_xml_name = 'ant down0'
up_xml_name = 'ant up0'
right_xml_name = 'ant right0'
-- horizontal and vertical positions
x_position = 250
y_position = 400

-- scales your character (set to 1 by default)
xScale = 1
yScale = 1

-- pretty self-explanitory
name_of_character_xml = 'ant'
name_of_character = 'ant'
charNote = 'abt'

playableCharacter = false -- change to 'true' if you want to the character on teamDad
flipX = true -- most likely change to 'true' if using a BF sided character
useIdle = true -- Use idle code or Dance code (EG: Skid&Pump, GF)
invisible = false -- invisible character (if you want to use the change character event, you need to make the second character invisible first)
teamplay = true -- Should character simply sing all notes on their side
layer = 2 --[[ Usable values:
0 : Behind stage
1 : Behind all
2 : In front of GF, behind Opponent and Player
3 : In front of GF and Opponent, behind Player
4 : In front of All
5+: Free Real Estate --]]



doIdle = true;
seriouslyDontIdle = false; -- if you want to play a longer animation you can use this when necessary to temporarily override doIdle.

function onCreate()
makeAnimatedLuaSprite(name_of_character, 'characters/' .. name_of_character_xml, x_position, y_position);

addAnimationByPrefix(name_of_character, 'idle', idle_xml_name, 24, false);
--addAnimationByIndices(name_of_character, 'danceLeft', idle_xml_name, '8,10,12,14' , 12);
--addAnimationByIndices(name_of_character, 'danceRight', idle_xml_name, '0,2,4,6', 12);
addAnimationByPrefix(name_of_character, 'singLEFT', left_xml_name, 24, false);
addAnimationByPrefix(name_of_character, 'singDOWN', down_xml_name, 24, false);
addAnimationByPrefix(name_of_character, 'singUP', up_xml_name, 24, false);
addAnimationByPrefix(name_of_character, 'singRIGHT', right_xml_name, 24, false);

setPropertyLuaSprite(name_of_character, 'flipX', flipX);
setPropertyLuaSprite(name_of_character, 'alpha', not invisible);
scaleObject(name_of_character, xScale, yScale);
setObjectOrder(name_of_character, layer, false);

end

function onCountdownTick(counter)
idleDance(counter);
end

function onEvent(name, value1, value2)
if name == "CharacterPlayAnimation" then
doIdle = false;
seriouslyDontIdle = true;
addAnimationByPrefix(value2, value1, value1, 24, false);
objectPlayAnimation(value2, value1, true);
elseif name == "ToggleTeamplay" then
local case = {["true"] = true, ["1"] = true, ["false"] = false, ["0"] = false, [""] = not teamplay};
if name_of_character == value1 then
teamplay = case[string.lower(value2)];
end
end
end

local singAnims = {"singLEFT", "singDOWN", "singUP", "singRIGHT"};
local singOffsets = {leftOffsets, downOffsets, upOffsets, rightOffsets};

-- I know this is messy, but it's the only way I know to make it work on both sides.
-- Don't worry bro I cleaned it up -Scarab

function opponentNoteHit(id, direction, noteType, isSustainNote)
if not playableCharacter then
if noteType == charNote then
doIdle = false;
objectPlayAnimation(name_of_character, singAnims[direction + 1], true);
setProperty(name_of_character .. '.offset.x', singOffsets[direction + 1][1]);
setProperty(name_of_character .. '.offset.y', singOffsets[direction + 1][2]);
end
end

function goodNoteHit(id, direction, noteType, isSustainNote)
if playableCharacter then
if noteType == charNote then
doIdle = false;
objectPlayAnimation(name_of_character, singAnims[direction + 1], true);
setProperty(name_of_character .. '.offset.x', singOffsets[direction + 1][1]);
setProperty(name_of_character .. '.offset.y', singOffsets[direction + 1][2]);
end
end

function noteMiss(id, direction, noteType, isSustainNote)
if playableCharacter then
if getPropertyFromGroup(noteType, i, 'mustPress') then
doIdle = false;
objectPlayAnimation(name_of_character, missAnims[direction + 1], true);
setProperty(name_of_character .. '.offset.x', missOffsets[direction + 1][1]);
setProperty(name_of_character .. '.offset.y', missOffsets[direction + 1][2]);
end
end
end

function onBeatHit()
if doIdle then
idleDance(curBeat);
end
if seriouslyDontIdle then
if getProperty(name_of_character .. '.animation.curAnim.finished') then
doIdle = true;
seriouslyDontIdle = false;
end
else
doIdle = true;
end
end

function idleDance(beat)
if useIdle then
if beat % 2 == 0 then
objectPlayAnimation(name_of_character, 'idle', false);
setProperty(name_of_character .. '.offset.x', idleOffsets[1]);
setProperty(name_of_character .. '.offset.y', idleOffsets[2]);
end
else
if beat % 2 == 0 then
objectPlayAnimation(name_of_character, 'danceLeft', false);
setProperty(name_of_character .. '.offset.x', idleOffsets[1]);
setProperty(name_of_character .. '.offset.y', idleOffsets[2]);
else
objectPlayAnimation(name_of_character, 'danceRight', false);
setProperty(name_of_character .. '.offset.x', idleOffsets[1]);
setProperty(name_of_character .. '.offset.y', idleOffsets[2]);
end
end
end

steveBanned = true

@mihaillov
Copy link
Author

nevermind i fixed this

@mihaillov
Copy link
Author

not working,i removed everything about altNoteTypes and noteType2 lines,but everyone keeps singing

@JordanSantiagoYT
Copy link
Owner

clearly not

@StinkTheStinker
Copy link

close as not planned after 1-2 days of inactivity

@mihaillov
Copy link
Author

im here now,because i am sleeping at this time,sorry

@mihaillov
Copy link
Author

hello?

@mihaillov
Copy link
Author

if i say that charNote2 deletion does not work,is this unfixable?

@JordanSantiagoYT
Copy link
Owner

JordanSantiagoYT commented Oct 29, 2024

i just don't know another fix

oh btw you had 'teamplay' turned on

OH THAT WAS THE PROBLEMMM

my bad lol

@mihaillov
Copy link
Author

i need to turn off the teamplay on all 3 characters?

@mihaillov
Copy link
Author

i turned off teamplay on antony and now anthony is not singing with opponent notes,thanks

Repository owner locked as resolved and limited conversation to collaborators Oct 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants