Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: arj0n on Sat 25/12/2021 23:15:31

Title: create new guicontrol (button) via script?
Post by: arj0n on Sat 25/12/2021 23:15:31
I have a gui that does not contain any guicontrol.
I would like to create a new guicontrol as button via script (without first creating an empty button in the gui editor), is this possible?
Title: Re: create new guicontrol (button) via script?
Post by: Cassiebsg on Sun 26/12/2021 12:52:58
I don't think it's possible, but I might be wrong.

Is there a reason you don't want to create an empty/hidden button?
Title: Re: create new guicontrol (button) via script?
Post by: arj0n on Sun 26/12/2021 13:25:48
Quote from: Cassiebsg on Sun 26/12/2021 12:52:58
I don't think it's possible, but I might be wrong.

Is there a reason you don't want to create an empty/hidden button?

I'm afraid too it isn't possible.

It's for an arcade/puzzle game.
When loading an existing or custom level, I would like to calculated how many buttons (wall pieces and so on) are needed and create and place them on the grid/board (gui).

Currently i have to create the total amount of buttons possible on the grid. Which would be a max total of 19x16...
This works of course but i would prefer a solution where i can create, via script, just only the amount of buttons needed for the level. That would also drastically reduce the amount of buttons to be created.
Title: Re: create new guicontrol (button) via script?
Post by: Crimson Wizard on Sun 26/12/2021 13:29:16
AGS does not support creating most of the game objects at runtime*, the only alternate way is to use custom structs and script your own drawing and interaction.


* exceptions are: Overlays, Viewport, Camera and dynamic sprites.
Title: Re: create new guicontrol (button) via script?
Post by: arj0n on Sun 26/12/2021 13:49:53
Ah, thanx for the info CW.
I'm currently using customs structs and scripts to draw, but was hoping creating gameobjects at runtime was possible. Alas, no problem. Thanx.
Title: Re: create new guicontrol (button) via script?
Post by: Snarky on Sun 26/12/2021 16:01:46
The ImGi module (https://www.adventuregamestudio.co.uk/forums/index.php?topic=58842.0) does something along those lines. (Personally I have found it too limited to be much use in practice, but perhaps it will suit your needs.)
Title: Re: create new guicontrol (button) via script?
Post by: arj0n on Sun 26/12/2021 17:14:24
Thanx for the heads up, Snarky
I'll look into that module.