Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: VegeTato on Wed 05/04/2017 01:21:47

Title: SOLVED:Help in ActiveInventory code + changing game speed
Post by: VegeTato on Wed 05/04/2017 01:21:47
Hey, i am trying to tell ags whe ni activate the "key" in my inventory and press it on "the other character" do display text
but every time i run it, it gives me this error
end of input reached in middle of expression

here is the full code:

function Dead_UseInv()
{
if (player.ActiveInventory==key)(
(Display("you toke the dead key ! WOW..."));
}


Title: Re: Help in ActiveInventory code
Post by: Gurok on Wed 05/04/2017 01:46:17
The opening bracket after your if statement '(' should be an opening brace '{'. You're also missing a closing brace for the if statement. Finally, you don't need brackets around the Display statement. Try this:

function Dead_UseInv()
{
    if (player.ActiveInventory==key) {
        Display("you toke the dead key ! WOW...");
    }
}


If you have just one statement within an if, you can leave out the braces ('{' and '}'). This is perfectly valid:

function Dead_UseInv()
{
    if (player.ActiveInventory==key)
        Display("you toke the dead key ! WOW...");
}


Also, if you're including code in a post, wrap it in [ code ] [ /code ] tags (without the spaces) to format it as above.
Title: Re: Help in ActiveInventory code
Post by: VegeTato on Thu 06/04/2017 18:51:19
Thank you so much it works perfect ! :D

i got one more question please :)


is there is anyway to change the game speed default ?
(the character moving so slow and lagy i keep going to the top of the screen and go to options and set game speed to max then it works fine)
is is there is anyway yo make it speed without changing the options in the game every time i play it ? :) Thanks.
Title: Re: Help in ActiveInventory code + changing game speed
Post by: Khris on Thu 06/04/2017 20:42:02
Open the player character in the editor, then lower their AnimationSpeed value. Afaik it's set to 4; try 3 or 2.
Title: Re: Help in ActiveInventory code
Post by: NicolaGs on Thu 06/04/2017 20:44:41
Quote from: VegeTato on Thu 06/04/2017 18:51:19
is there is anyway to change the game speed default ?
SetGameSpeed (int new_speed)
new_speed is the speed in frames per second.
If you use a template with a slider for speed adjustment , then you may have to change its default value.

edit : Khris was faster than me and may have better understood your question...
Title: Re: Help in ActiveInventory code + changing game speed
Post by: Khris on Thu 06/04/2017 20:52:59
Changing the game's speed will make everything faster or slower, but if this is about a slowly walking character, decreasing the number of game frames in between animation frames is probably a better solution.

I checked my Default Game, and I always flip the values, setting Roger to MovementSpeed 4 (which better fits the walkcycle frames) and AnimationSpeed 3, which speeds him up by 33% on top.