{FIXED} How can I make the camera stay fixed between dad and bf in Friday Night Funkin game? - lua

fix: use "Cam follow pos" event at the very begining of the song.
I'm trying to get the camera to stay fixed between dad and bf, but it still moves between characters, and I'd rather not edit the character JSON files or the charts of each song.
This is my code so far:
function onCreate()
-- This zooms the camera out a bit so it includes both characters
setProperty('defaultCamZoom', 0.8);
-- This is supposed to make the camera stay fixed between dad and bf
setProperty("camFollowPos.x", getCharacterX("gf"));
setProperty("camFollowPos.y", getCharactery("gf"));
end
I tried to set the follow position to gf's pos but that didn't work as expected.
I expected for it to stay fixed between dad and bf but it moved between each section.
I know it was originally supposed to move if a section's "must hit section" property changes, but I don't want that when this script is running.

Related

ANSI control sequence: after setting line home and limit, how should cursor movements behave? which coordinates to use?

Context:
I'm working on a device which inserted between an electronic typewriter's controller and its keyboard turns it into a serial printer/terminal.
I want it to support some of the control sequences from ECMA-48 / ISO-6429 / ANSI X3.64. (also known as ANSI escape code)
I'm having some uncertainty if I'm understanding correctly the standard, so I would like to ask to know how it should be.
It's related to the commands SLH - SET LINE HOME and SLL - SET LINE LIMIT.
For example I could have the situation that I have 1/12 inch wide characters, I want a left margin of 1 inch, and 80 columns of text.
Then I would set page home to 13 and page limit to 92.
(since character positions are counted from 1, home is the first position, limit is the last)
So far ok.
But when I already have set the home, than how should the functions:
CHA - CURSOR CHARACTER ABSOLUTE
CUP - CURSOR POSITION
HPA - CHARACTER POSITION ABSOLUTE
CPR - ACTIVE POSITION REPORT
and others related to the cursor position work?
Should they use coordinates relative to to the actual edge, or to the home position.
So in my above example if I wanted to move to column 2 of the text print area (home being 13), I should use coordinate 2 or 14?
(similarly for vertical position and page home & limit)
My understanding is that these control sequences still use the absolute coordinates.
so in my example I would have to use coordinate 14.
Is this correct?
And if it is correct, this raises some additional problems:
I would have to know where the margins are to know which horizontal and vertical offset to use when moving the cursor to absolute positions.
If a program sets the margins first, then no problem, but I a program connects to the device and does not change the margins then it does not know the offset.
(There is a way, it could send a carriage return to move to the home position and then request the ACTIVE POSITION REPORT to discover the left margin position, but it does not look like a nice solution)
What should my device do if it is requested to move to a position outside the defined home and limit?
The standard says that beyond these limits no implicit movement should happen, but this is explicit movement.
If it receives a command to move to position 1 when the home is 13 what should it do? Move to 1? Move to 13? ignore?
When it is at position 15, home is at 13 and receives command to move cursor left by 4 positions should it move by 4 to 11? move by 2 to 13? ignore?
Another problem I see is that there is a command to set page home, and page limit, but not total page height.
It is only possible to select predefined formats by PFS - PAGE FORMAT SELECTION.
But I don't see a way to select any other height.
If I want to use continuous paper with 12 inch long pages (72 lines of text at 1/6 inch line height) connected together into a long tape then I see no way to define that height so that my device can correctly keep track of its positions on the following pages. Is there a way to do it?
Looks like I had to find the answers by myself.
question 0:
Yes, it appears, that the coordinates should still be absolute.
he standard says about character positions in a line and line positions in a page and these are specified in the beginning of the document and nowhere at all is said about it being relative. Looks like the only role of line home and limit is the place where CR (and some others) returns to, and limit of where implicit movement (like advancing forward after printing a character) can go, similar for page home and page limit.
question 1:
There is no easy way for a program to recognise where the home and limit positions are. As I mentioned, requesting ACTIVE POSITION REPORT can help if this is implemented. (my devece does not support it yet).
Anyway, many programs don't recognise the concept of line home, and assume that normal character positions start from 1.
My solution to this is that after power on, the line home IS exactly at position 1, and if you want something else, you have to specify it.
This way a program can safely make this assumption.
(However after the PFS - PAGE FORMAT SELECTION command I do set the line home to 1 inch as this is what the standard proposes)
question 2:
As above, the home and limit are only a margin for implicit movements. So the cursor movement commands will move outside these limits with no problem. Only the actual page size will limit them.
question 3:
(but I didn't give it a number when asked)
DTA - DIMENSION TEXT AREA is the command for this purpose. It specifies the size of the text area limited by the actual page size, not by the home and limit positions.

Roblox hip height script only works for certain players

I have a very basic script which raises a player above the ground. The script is player.Character.Humanoid.HipHeight = 15. When the game runs, it works for some players and not for others (the others stay on the game surface). I added a line to the script to confirm the hip height of each player via: print (player.Character.Humanoid.HipHeight) and for all the players it prints out 15. So why do some players stay on the game surface even when it says their hip height is 15 and other players are raised higher? Would love any ideas / theories. Thank you!
Some players stay on the floor, because of their avatar height, for example, anthro players are taller than normal ones, and different body parts from the catalog can have different heights and thus different hipheights. A solution is to add 15(or any number) to the hipheight, for example: player.Character.Humanoid.HipHeight += 15

Lua tables and screen coordinates. For every {x} at y do

I'm having a little curious sense of art in programming at the moment. And I want to script my Autotouch App on my iOS to generate Pixel Art inside of another app.
I was doing this previously by typing in code to tap at the screen at one coordinate, I did this 2000+ times and it got the job done. But there should be a better, smarter way to get it done.
My test image is going to be very symetrical to make things easy.
There is a code in the Lua app that I'm using to simply tap on the screen,
tap(x, y)
But I want to set this up like:
tap({xTable}, y)
But I'm not sure if that will "tap" at each x coordinate that I've listed for the y variable.
I want to paint a pixel at one very specific coordinate, and then step 5 pixels away and paint the next one, and repeat that until the end of the line.
Is this at all possible or am I reaching beyond the language capabilities?
Edit: for some reason my phone is not blocking code when I'm asking a question, if someone sees this and wants to edit, I would be grateful.
Is this at all possible or am I reaching beyond the language capabilities?
Not even close. I recommend you read Programming in Lua.
tap({xTable}, y)
But I'm not sure if that will "tap" at each x coordinate that I've listed for the y variable.
Why are you not sure? Did you not write it? If not, you can trivially write it yourself given tap:
function tapxs(xs, y)
for i,x in ipairs(xs) do
tap(x,y)
end
end
...
tapxs({10,20,30,40}, 10) -- tap at 10,10; 20,10; 30,10; etc.
I want to paint a pixel at one very specific coordinate, and then step 5 pixels away and paint the next one, and repeat that until the end of the line.
What is "the line"? Is it purely horizontal? You could write:
function tapHorizontally(startX, maxX, y, increment)
for x=startX,maxX,increment do
tap(x,y)
end
end
...
tapHorizontally(10,100,20,5) -- tap from 10,20 to 100,20 in 5 pixel increments
Of course, that's a bizarrely specific function. You'd typically write something that takes a starting x,y and ending x,y and draws between them, so you can support horizontal, vertical, diagonal lines all with the same function, but that requires more math.
The bottom line is: Lua is a full blown, powerful, high level programming language. It could be used to write the very app you're tapping on, or the app you're using to generate taps, so the limits are going to be your knowledge of programming/algorithms/math/etc.

Shifting elements in match3 kind of game

I am a beginner at ActionScript3, and for my learning purpose, I am trying to build a match3 kind of game. I am making is a clone of bejeweled kind of game. but instead of swapping, I have to delete those elements and shift the upper elements down and add new elements above those shifted elements.
I am able to delete matched elements and after matching I'm removing those elements but I am stuck with the shifting code. I am not able to shift those elements down.
I believe that you should take a look at Richard Lord's Tetris source code as your game may be somehow similar in mechanics to Tetris. Tetris shifts down rows when you get lucky.
Richard Lord is one of the Flash Gurus and his way of doing things may seem pretty advanced for a starter like you. Take a look over the source code and see if it fits you. What I can tell is that this is the proper way to make a game but maybe it's not the best point to start for a novice like you that is in urgent need.
http://www.richardlord.net/blog/actionscript-3-tetris-source-code
I would approach it like this in 2 parts.
Loop through your array of board positions starting from the bottom row and check for an empty unoccupied slot, if you find one do another loop through the row above till you find a piece on the same column. If you find a piece on the row above apply a tween to move it down to the empty slot and continue your loop.
Once you have looped through all rows, and animated all the tweens you need to loop through again to find all the gaps that need gems dropped into them. Create new elements at those positions and then move them up by (element height * row), apply another tween to animate them back to their starting position.

ActionScript Timeline Control

I'm dynamically loading a file that will indicate when to show certain words at certain frames. However, I'm having trouble with the concept of timeline control from ActionScript (I'm building everything programmatically in Flash Builder). Let's say my tuples has frame and word:
5, "duck"
13, "cow"
22, "pig"
There is a sprite associated with each. What I would like to do is something like the following:
for (frame in timeline) { //should iterate from frame 0-22 (last frame in list)
if (frame in list) {
list[frame].alpha = 0;
}
}
I already know that my display of sprites works and whatnot, I'm just confused on how to play through the timeline in this kind of way, or if it's possible to dynamically do this.
EDIT: Related, can I control how fast the timeline plays?
EDIT: To give a more thorough explanation, I'm looking to visualize word appearances over time in a text. So "duck" may appear as the 5th word in a corpus, "cow" as the 13th word, etc. My list contains tuples of word positions (unique) and the word that appears at that position. I have a small selection of words that I'm interested in from the corpus, so not every position is represented. I would like to be able to have a SWF movies that essentially starts at the beginning of the corpus, go through my word list in order of appearance in the corpus, and then display the word (and have it fade out). So, if there's a word at position 5 and 10, then should appear in much more rapid succession than if there's a word at position 15, and the next one doesn't appear until 50. Basically, I would like to keep that temporal component.
I'm having a little trouble understanding exactly what you're asking about, but in general for controlling the timeline use the commands play() stop() gotoAndPlay() gotoAndStop()
Beyond that I'm gonna need you to explain more clearly what exactly you are trying to do.
ADDITION: From your edits it sounds like you simply want to trigger an animation when the user clicks a button or something. So make the animation in Flash and then use the commands I listed to play it.
ADDITION2: If however you definitely want to do this in code then that has nothing to do with the timeline; program the fading in and out using a tweening library like http://www.greensock.com/tweenlite/

Resources