Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Gurok

#1701
I had that working for global variables, but not stack variables. Some wrinkles in addressing that weren't immediately apparent. I'm going to pull it apart and try again, of course.

Is it possible for me to close issue 503? http://www.adventuregamestudio.co.uk/forums/index.php?issue=503.0

I'm going to make a new thread, "AGS 3.3.1 - Test Build" with a changelog and download link tonight.
#1702
Quote from: Crimson Wizard on Mon 10/03/2014 15:06:51
You might need to make a new type of dynamic object manager in the engine that handles user structs.

Yes, that is what I fear :D. Right now, switch...case seems easier. Also I've been trying to fix general bugs, but I find myself drawn to the script compiler.
#1703
Static extender functions

Syntax as follows.

Module:
Code: ags

function AbsInt(static Maths, int value)
{
    if(value < 0)
        value = 0 - value;

    return(value);
}


Header:
Code: ags

import function AbsInt(static Maths, int value);


Example call:
Code: ags

int x = Maths.AbsInt(-3);


https://github.com/gurok/ags/compare/adventuregamestudio:develop-3.3.1...331_static_extender_functions

Better warning for function delcaration inside a struct

https://github.com/gurok/ags/compare/adventuregamestudio:develop-3.3.1...bugtracker_function_in_struct_error_msg

http://www.adventuregamestudio.co.uk/forums/index.php?issue=503.0

--

I should probably listen to CW's advice and stop piling features into this thread. It's just every time I look at the scripting engine (and this weekend I spent some time looking at for/break/continue), I see things which could very easily be made better.
#1704
I've also devised an extraordinarily complicated way to do switch() statements if anyone's interested. This:

Code: ags

switch(x)
{
	case 5:
		Display("Five");
	case 6:
		Display("Six");
	default:
		Display("Default");
	case 7:
		Display("Seven");
}


translates into lots of jumps. Pseudo-assembly follows:

Code: ags

# Switch statement
jmp condition1:
exit:
jmp 0
condition1:
evaluate_expression("x == 5");
jz condition2:
code1:
Display("Five");
jmp code2:
condition2:
evaluate_expression("x == 6");
jz condition3:
code2:
Display("Six");
jmp code3:
condition3:
# No jumps or evals
code3:
Display("Default");
jmp code4:
condition4:
evaluate_expression("x == 7");
jz 0
code4:
Display("Seven");
end_of_statement:


With the 0 addresses being filled in as "end_of_statement" after the switch statement is fully parsed
Might need some temporary 0 addresses for lines like "jmp code2:" too
But with this, a break statement just becomes:

Code: ags

# Break statement
jmp exit:


I haven't coded the above yet, but that is what I plan to do. Comments welcome.
AGS script is a single pass compiler, so there are a lot of cases where jmp 0 is used temporarily. A few variables about how things are currently nested (almost to the point of having a second pass) are stored to help fill in the blank addresses later.

Side note: Passing structs as parameters is more complex than I first thought and might take some time.
#1705
Hello all,

I've found some more low-hanging fruit. It's pretty easy to lift the static restrictions on extender functions such that you could do this:

Code: ags

static function DoIt(this Character *, int a)
{
    Display("I did it! %d", a);
}


and then in your module header, this:

Code: ags

import static function DoIt(this Character *, int a);


and then later somewhere in your code, this:

Code: ags

    Character.DoIt(3);


The trouble is that
a) "this" is not defined for a static extender function
b) the syntax is a bit ugly

"This" being undefined is not such a problem because the compiler picks that up anyway. If I were to tidy up the syntax (which I could), do people think this might be useful? Something like this might be possible for the syntax:
Code: ags

static function DoIt(extends Character, int a)

or this (which is the nicest I've thought of so far):
Code: ags

function AbsInt(static Maths, int value)


Though I am open to suggestions.
#1706
Hints & Tips / Re: Don't push the button
Sun 09/03/2014 09:35:51
This thread is full of spoilers. I assume there is a countdown and a button later in the game. Not quite there yet. I am stuck on:
Spoiler

Starting the executable
[close]
Appreciate any help.
#1707
Progress is slow, but I fixed one of the errors CW mentioned. It's coming to a test build soon, hopefully.
#1708
There are lots of ways to achieve this. I think you just need to store the room number somewhere. Storing the room before fade in might be the simplest. Assuming it's in your global script:

Code: ags

int lastSewerRoom;

function on_event(EventType event, int data)
{
	if(event == eEventEnterRoomBeforeFadein && cCharles.Room > 20 && cCharles.Room < 24)
		lastSewerRoom = cCharles.Room;

	return;
}

function Button75_OnClick(GUIControl *control, MouseButton button)
{
	if(lastSewerRoom > 20 && lastSewerRoom < 24 && Button75.NormalGraphic == 1861 && (cCharles.Room == 19 || cCharles.Room == 20))
	{
		cCharles.Say("I think I'll go back to the old sewers.");
		cCharles.ChangeRoom(lastSewerRoom);
	}

	return;
}


An alternative would be to store the sewer room as you step on the region that takes you to room 19 or 20. Slightly more efficient, but I think the method above is easier to maintain.
#1709
They do stack.

Code: ags

void PauseGame() {
    game_paused++;
    DEBUG_CONSOLE("Game paused");
}
void UnPauseGame() {
    if (game_paused > 0)
        game_paused--;
    DEBUG_CONSOLE("Game UnPaused, pause level now %d", game_paused);
}

int IsGamePaused() {
    if (game_paused>0) return 1;
    return 0;
}


Not sure why your IsGamePaused() variant wasn't pausing the game though. Perhaps something else is interfering with it. My immediate thought was that PauseGame() might be delayed until a function exits, but as you can see above, that's not the case.
#1710
The Rumpus Room / Re: *Guess the Movie Title*
Sat 08/03/2014 13:56:02
Quote from: Snarky on Sat 08/03/2014 13:37:19
I get the impression some people don't know the meaning of "non-occidental"...

Good point. I had to look that up, and now I feel embarrassed :(.

It's not exactly an everyday word though.

For others' benefit, Occidental means "Western" and so non-Occidental means non-Western.
#1711
Quote from: miguel on Sat 08/03/2014 13:06:20
In Portugal, expensive coders have their testicles removed.

As a Windows programmer, I can vouch that this is pretty common. I am often asked if I'm comfortable working in a eunuchs environment.
#1712
The Rumpus Room / Re: *Guess the Movie Title*
Sat 08/03/2014 10:58:30
Field of Dreams?
#1713
I took a look at the code and I think it's easier to just live with limited dialog options for now.

Thanks for the answer though, CW. I appreciate the perspective.
#1714
The Rumpus Room / Re: A math problem!
Sun 02/03/2014 00:51:38
On the surface, I would be tempted to say very stupid, but he got $100,000 somehow. Perhaps he had some intelligence and he just invested poorly this once.
#1715
Hello,

When conversing with another character, is there an easy way to allow the player to press ESC to exit the dialog? Ideally I'd like to be able to have the player say goodbye when ESC is pressed, but I'd settle for just stopping the dialog.
#1716
The Rumpus Room / Re: *Guess the Movie Title*
Sat 01/03/2014 12:30:10
Me and you and pink shoes?
#1717
Thanks for the snippet, Ghost. Now that I know, I'll just check out the 9Verb template if I get stuck. Your save GUI looks great, by the way.
#1718
The Rumpus Room / Re: Name the Game
Thu 27/02/2014 08:07:01
Guess my pic then! :D
#1719
The Rumpus Room / Re: Name the Game
Thu 27/02/2014 02:11:04
This one should be easy:



EDIT: Oh, am I not supposed to post? Forgive me if I was being rude. I didn't realise the thread had split up into two threads.
#1720
I am working on save and load GUIs at the moment and I'd like to know what other people do to avoid using those terrible built-in scrollbars. At the moment, I am thinking of doing this:



But I'd like to know if somebody has implemented proper scrollbars as a module that I can just use.
SMF spam blocked by CleanTalk