ShadowMario / FNF-PsychEngine

Engine originally used on Mind Games mod
Apache License 2.0
1.12k stars 2.19k forks source link

Lua Text Doesn't Appear During The Song #6364

Closed ManMaster707 closed 2 years ago

ManMaster707 commented 2 years ago

Describe your problem here.

I wanted to make some words appear in sequence in a song, so i made the first word, but the game didn't show it, but it didn't show an error either, i modified the code and looked the wiki multiple times, but nothing worked, if you want to help me, here's the code for the text (it's a test, obviously):

function onStepHit() if curStep == 4 then makeLuaText('escape', 'fijvfijidjicjdhfuhfduhfdufrfi', 2000, -500, -100); setTextSize('escape', 2); setTextAlignment('escape', 'center'); addLuaText('escape') end

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, i just added things trough the "mods" folder.

KirbyKid256 commented 2 years ago

You need another end to finish both the "if then" statement and the function. It should be:

function onStepHit() if curStep == 4 then makeLuaText('escape', 'fijvfijidjicjdhfuhfduhfdufrfi', 2000, -500, -100) setTextSize('escape', 2) setTextAlignment('escape', 'center') addLuaText('escape') end end

Of course, it should also be indented properly, but it doesn't show in the comments. Also, the semicolons in Lua are mainly used if you have more than one statement in a line, so you don't need them here.

ManMaster707 commented 2 years ago

thanks, but nothing is changing, the text doesn't appear and the engine doesn't give me an error, thank you for the information though.

frantastic24 commented 2 years ago

Are you sure the text isn't appearing offscreen

KirbyKid256 commented 2 years ago

I just tested it, and yeah. It seems there are multiple problems with the positioning. For one thing, you made the width WAY too big. Another thing is that the origin point of 0, 0 is at the top right corner. When x or y get smaller, x would move the text left and y would move the text up. When they get bigger, x would move right and y would move down. Since the text stays in one place no matter the camera movement, you won't need to use negative values most of the time unless you're tweening the position from offscreen to a place onscreen. Try using this:

function onStepHit() if curStep == 4 then makeLuaText('escape', 'fijvfijidjicjdhfuhfduhfdufrfi', 564, 100, 100) setTextSize('escape', 32) setTextAlignment('escape', 'center') addLuaText('escape') end end

ManMaster707 commented 2 years ago

Nope, still no text and still no error. (I'm on 0.5.1 btw)

frantastic24 commented 2 years ago

Okay here's something you can test

setObjectCamera('escape', 'hud')
screenCenter('escape')

If it still doesn't appear, it's likely some other part of your code is wrong

ManMaster707 commented 2 years ago

still nothing, I even followed your instructions, but nothing, here's the code, if you want to figure out what's wrong:

`function onGameOver() setPropertyFromClass('GameOverSubstate', 'characterName', 'sonicgameover'); end

function opponentNoteHit() health = getProperty('health') if getProperty('health') > 0.1 then setProperty('health', health- 0.01); if getProperty('dad.curCharacter') == 'x-terion2' then cameraShake('game', 0.005, 0.50) end

function onStepHit() if curStep == 4 then makeLuaText('escape', 'fijvfijidjicjdhfuhfduhfdufrfi', 564, 100, 100) setTextSize('escape', 32) setTextAlignment('escape', 'center') setObjectCamera('escape', 'hud') screenCenter('escape') addLuaText('escape') end end

function onUpdate() if getProperty('dad.curCharacter') == 'x-terion' then if keyJustPressed('space') then characterPlayAnim('dad', 'laugh', true); elseif getProperty('dad.curCharacter') == 'x-terion2' then if keyJustPressed('space') then characterPlayAnim('dad', 'laugh', true) end end end end end end`

frantastic24 commented 2 years ago

Just to make sure You are using 0.5+ right? And you've run only the text part of the script to make sure there's no errors elsewhere?

ManMaster707 commented 2 years ago

No. I've run the whole song script (and I'm using 0.5.2h now sorry for the confusion)