It seems that I am going to be asking many simple questions that don't deserve a topic.So I thought I could just ask them here whenever I need to.
So the first question is:
Is there a way to create an animation and then delete it once its finished.I tried using overlays and dynamicsprites but those don't work as well as objects. I heard somewhere that you can't delete objects.So is there another way?
Second question:
Does the mere existence of an object in a room effect game speed at all? Even if its not visible?
Quote from: Pajama Sam on Sat 23/04/2022 15:47:39
Is there a way to create an animation and then delete it once its finished.I tried using overlays and dynamicsprites but those don't work as well as objects. I heard somewhere that you can't delete objects.So is there another way?
Using room objects or characters: make them hidden by default, make visible when necessary, play animation and hide again.
If this is the effect that happens alot in different rooms - then character is a better choice. Objects have Visible flag, Characters don't for some weird reason, but you can set character to a non-existing room when it's no longer needed (e.g. Char1.ChangeRoom(-1)).
Quote from: Pajama Sam on Sat 23/04/2022 15:47:39
Does the mere existence of an object in a room effect game speed at all? Even if its not visible?
No.
OK thanks.
When making functions how would a parameter be made as optional?
Quote from: Pajama Sam on Sun 24/04/2022 04:20:17
When making functions how would a parameter be made as optional?
You tell it a default value in the function declaration:
function func(int a = 10);
This keeps giving me an error(Invalid use of '*').What's the problem?
String* text=text.Append("eOnce");
You don't need an asterisk when declaring a String.
Also you are using the text variable, which you are declaring here, as if it already existed. What are you trying to achieve? And why would you append "eOnce" to a string?
I have a function that inputs chosen settings into GLOB.Animate.I want the strings text either eRepeat or eOnce to be placed into GLOB.Animate where its needed.How would eOnce and eRepeat be made available as a parameter for a function. I assume there is a better way than using string.
Quote from: Pajama Sam on Tue 26/04/2022 07:02:09
I want the strings text either eRepeat or eOnce to be placed into GLOB.Animate where its needed
I don't think that's what you want. I think you want the
values eOnce or
eRepeat to be passed to the
.Animate() method.
eOnce and
eRepeat are values of the enum
RepeatStyle, so you can just declare a parameter of the
RepeatStyle type, just like the
.Animate() method does.
The difference between the
String "eOnce" and the
value eOnce is a fundamental coding concept that is important to learn and understand. It's just like the difference between the String "true" and the boolean value
true. The
String "true" is just a sequence of four characters: [t,r,u,e]. AGS just stores it, it doesn't understand what it means. You can't write something like
if(gWindow.Visible == "true"), because now you're comparing a boolean
.Visible with a String "true," and that's like asking "which is bigger, the number 5 or a post-it note?" It doesn't make sense. It doesn't matter what's written on the post-it note: it might be "Hello" or "4"; it's still not comparable. (There are ways to read the text of the String/post-it note and convert it to a boolean or number, but then you would have to code that.)
The
value true on the other hand is recognized when you compile the code, and converted into the computer's internal representation of the
concept of truth (which is actually just a number, usually either 1 or -1). This allows it to be used in logical expressions, for example
if(gWindow.Visible == true). When it is compiled, the actual words you've typed in the code are discarded, so that the internal representation of
if(gWindow.Visible == true) doesn't contain the string "true".
Exactly, here's example code:
// top of global script
RepeatStyle GLOB_Repeat; // type RepeatStyle (int would also work) enables the correct auto-complete options
// inside some function
GLOB_Repeat = eOnce; // no quotes, no strings are involved at any point
// elsewhere:
player.Animate(..., GLOB_Repeat);
Thanks khris and snarky.
How would I place the parameter globrepeatstyle in this function?
function nbobj(Object* GLOBALOBJ, int xpos, int ypos, int objview,int loop,int frame, int delay,globrepeatstyle)
EDIT:
Nevermind. I figured it out.
I have this script here that seems to totally ignore the else statement.I'm trying to get the character to only be visible while speaking.So what's the problem with this?
if(cfattymouth.Speaking)
{
cfattymouth.Transparency=0;
}
else
{
cfattymouth.Transparency=100;
}
By the way.This is in repeatedly execute.
Quote from: Pajama Sam on Tue 10/05/2022 14:14:06
I have this script here that seems to totally ignore the else statement.I'm trying to get the character to only be visible while speaking.So what's the problem with this?
if(cfattymouth.Speaking)
{
cfattymouth.Transparency=0;
}
else
{
cfattymouth.Transparency=100;
}
By the way.This is in repeatedly execute.
"repeatedly_execute" is not called during blocking actions, including blocking speech. Try placing this in "repeatedly_execute_always" instead.
More info on this: https://adventuregamestudio.github.io/ags-manual/RepExec.html
Thanks.I'll do that.Now for the sake of clarity.Since a room's script does not have repeatedly execute always it would not be able to do this script.Right?
You can do it in room scripts; repeatedly_execute_always is one of a few functions you can just add and they get called automatically, without the usual event linkage (the others being on_key_press and on_mouse_click).
Is there a plausible way to do costumes in AGS that are like extra layers/limbs?
Quote from: Pajama Sam on Wed 11/05/2022 17:10:40
Is there a plausible way to do costumes in AGS that are like extra layers/limbs?
Similar questions have been asked couple of times only recently, here are related discussions:
https://www.adventuregamestudio.co.uk/forums/index.php?topic=59912.0
https://www.adventuregamestudio.co.uk/forums/index.php?topic=59954.0
PS. I feel like we would benefit from a good tutorial and maybe an article in the manual on this topic.
Does drawing dynamic sprites have a baseline or z-order?
Quote from: Pajama Sam on Wed 11/05/2022 18:50:37
Does drawing dynamic sprites have a baseline or z-order?
Dynamic sprites are just raw graphic, they dont have any baseline or position on their own. But they may be drawn on or assigned to an object, and object has a baseline or z-order.
Is there a way to easily delay reading script without blocking?
Quote from: Pajama Sam on Wed 11/05/2022 19:03:58
Is there a way to easily delay reading script without blocking?
Please elaborate?
Is there another way than Wait(); that doesn't block.So far what I use is a integer adding up and whenever the integer reaches a number it runs certain script.This way works but you have to place the script in an if statement.I'm looking for something that merely stops reading of the script for a set time without blocking the already running scripts such as animations and mouse cursor.
Quote from: Pajama Sam on Wed 11/05/2022 19:40:05
Is there another way than Wait(); that doesn't block.So far what I use is a integer adding up and whenever the integer reaches a number it runs certain script.This way works but you have to place the script in an if statement.I'm looking for something that merely stops reading of the script for a set time without blocking the already running scripts such as animations and mouse cursor.
I am still not sure what the problem is, as Wait does that: it stops execution of the current script and does not block the active animations and the mouse cursor. Perhaps if you tell why you cannot use Wait, or expain your situation in more detail?
In general, if you need to wait until something, then it's one of the two solutions:
1. If you want to stop script right in the middle of the current function, then use Wait, and optionally some conditions to see at which point it needs to stop waiting.
2. Use timers, or any alternatives (like integer counters), and check in repeatedly_execute and similar functions to see when they are over.
The case 2 is also when you need player to keep ability to interact with things.
Quote from: Pajama Sam on Wed 11/05/2022 19:40:05This way works but you have to place the script in an if statement.
This is the only way to delay code non-blocking. If you want cleaner code, you can move the commands to a new custom function and call it:
function stuffHappens() {
// code here
}
// in rep_ex_always
if (my_timer >= 4000) stuffHappens();
I have a question that i'm sure was answered but I can't find it so i'll ask it again.How can I add a number to the name of something.Such as having an overlay that is made every time a function is called and the name of the new overlay is called myoverlay(number).To add a number to the overlays name every time its made so that it can be recalled through script without changing the previous one.I'm not asking how to change it every time its made.I'm asking how to add a number to the end of its name.
As explained last time around (https://www.adventuregamestudio.co.uk/forums/index.php?topic=59799.0), you can't, but this is a typical use-case for an array.
Also check out the last bit of this post (https://www.adventuregamestudio.co.uk/forums/index.php?topic=59873.msg636645136#msg636645136) (from "this is a common misunderstanding") for an explanation of why what you describe cannot be done.
I keep getting an error "something has a parse error".Something needs to be accessible by all of this script but I don't know how to put the parameter in the function and have it global.
int timer;
int startanimation;
int playagain;
function overplay(int xpos, int ypos,int something, int other,RepeatStyle)
{
flap=Overlay.CreateGraphical(xpos, ypos, sprite);
startanimation=1;
flap.Graphic=something;
}
function overplayagain(int something2, int other2,RepeatStyle)
{
startanimation=1;
playagain=1;
}
function Repeatedly_execute_always()
{
if(startanimation==1)
{
timer =1;
}
if(timer>=40)
{
timer=0;
startanimation=0;
if(playagain==1)
{
flap.Graphic=something2;
}
if(playagain==0)
{
flap.Graphic=something;
}
}
if(backwards==true)
{
if(something>other)
{
something-=1;
}
}
if(backwards==false)
{
if(something<other)
{
something =1;
}
}
if(backwards==true)
{
if(something2>other2)
{
something2-=1;
}
}
if(backwards==false)
{
if(something2<other2)
{
something2 =1;
}
}
}
import function overplay(int xpos, int ypos,something, int other,direction param);
import function overplayagain(something2, int other2,direction param);
The function in your script is supposed to something like
function overplay(int xpos, int ypos, int something, int other, RepeatStyle rs) {
RepeatStyle is just the type, you also need a name in order to be able to reference the passed value inside the function: if (rs == eOnce) ...
To make the function globally available, basically copy the line:
// in the header
import function overplay(int xpos, int ypos, int something, int other, RepeatStyle rs);
Thanks!
I have another problem now.This script is meant to animate an overlay but it's not changing to the next sprites.What is the reason for its not changing to the next sprite?
Certain integers and an overlay are declared global in "global variables".
globover2=overlay
backwardsnum=integer
somethingnum=integer
othernum=integer
backwardsnum2=integer
somethingnum2=integer
othernum2=integer
int timer;
int startanimation;
int playagain;
function overplay(Overlay* globover, int xpos, int ypos, int something, int other, bool backwards)
{
globover=Overlay.CreateGraphical(xpos, ypos, 26);
startanimation=1;
globover2=globover;
backwardsnum=backwards;
somethingnum=something;
othernum=other;
playagain=0;
}
function overplayagain(int something2, int other2,bool backwards2)
{
backwardsnum2=backwards2;
somethingnum2=something2;
othernum2=other2;
startanimation=1;
playagain=1;
}
function Repeatedly_execute_always()
{
if(startanimation==1)
{
timer+=1;
}
if(timer>40)
{
if(playagain==1)
{
if(backwardsnum2==true)
{
if(somethingnum2>othernum2)
{
somethingnum2-=1;
}
}
if(backwardsnum2==false)
{
if(somethingnum2<othernum2)
{
somethingnum2+=1;
}
}
globover2.Graphic=somethingnum2;
}
if(playagain==0)
{
if(backwardsnum==true)
{
if(somethingnum>othernum)
{
somethingnum-=1;
}
}
if(backwardsnum==false)
{
if(somethingnum<othernum)
{
somethingnum+=1;
}
}
globover2.Graphic=somethingnum;
}
timer=0;
}
}
EDIT:
Finally after days of strenuous searching I finally found the reason for this not animating.Reapeatedly execute was not actually repeately execute.It was making it a custom function.Now that that's fixed it animates flawlessly.
DOUBLE EDIT:
How do I change this script to animate an unknown number of multiple overlays?