Scripts / glue_entity script and how to use it

Author
Message
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 25th Jun 2022 20:02 Edited at: 25th Jun 2022 20:03
https://vimeo.com/724055334

So this script is MAX only and is my attempt to get around the issue raised here: https://github.com/TheGameCreators/GameGuruRepo/issues/3340

So until that issue gets worked, if it gets worked, here is a way of accomplishing it. I would have preferred it to be automatic but without that issue worked it just isn't possible.

Anyhow, what the script does is allow entities to be 'glued' to another moving entity and to make the glued entities move smoothly in sync with it.

As described in the GitHub issue in order to do this properly the 'glued' entities need to all move in the same frame as the 'gluee', in order to do this the user has to follow this procedure:
1) Put the first entity to be 'glued' on the map and attach the behaviour.
2) Use the blobby logic connection system to link this entity to the 'gluee' (this is important, the first link must be to the moving entity)
3) Next identify the name of the behaviour that the 'gluee' has, for example Door Rotate, in the behaviour setting for the glued entity enter this in lower case with underscores, e.g. door_rotate
4) Next simply use the blobby linking system to link up to 9 more entities to the 'glued' entity.

Remember that in order to move entities must be dynamic not static.
Counter intuitively you should make the entities 'Issimobile', i.e. in Developer Settings for the entities tick the Issimobile box. This stops the physics engine from moving the entities but doesn't stop the script from doing so, it also makes it possible for the player to stand on the entities which is obviously very useful for platforms and lifts.
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 25th Jun 2022 20:07 Edited at: 25th Jun 2022 20:08
One restriction to this atm is that only 10 different moving scripts can be used at the same time on a level, so you can have any number of glued together doodads using say the sliding_door script, or as many as you want using door_rotate etc but after the tenth different behaviour you won't be able to add any more.

As it stands I don't think we even have 10 different behaviours that move entities so this shouldn't be too much of an issue yet.
Been there, done that, got all the T-Shirts!
PM
granada
Forum Support
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 25th Jun 2022 21:02
Very nice work Amen , thank you

Dave
Windows 10 Pro 64 bit
AORUS B550 Master Motherboard
GeForce RTX™ 2070 GAMING OC 8G
AMD Ryzen 9 5950X 16-Core Processor 3.40 GHz
128 GB DDR4 RAM
3840 x 2160 ,60 Hz
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 25th Jun 2022 21:07
@ AmenMoses
You can get the script some entity is using thru the map.ele file, you would have to read it via LUA.
Although, have no idea how to convert fpm to a zip file, unzip the file, and set up the password, via LUA.
Bad idea LOL
I wrote some VS code to do so, but VS code is not an option on GGMax, at least no atm.
Really nice script btw.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
Shadow_Master
3
Years of Service
User Offline
Joined: 7th Oct 2020
Location:
Posted: 25th Jun 2022 21:26 Edited at: 25th Jun 2022 21:55
@AmenMoses, your new script broke everything that I had already had glued, I took a screenshot of what it says. So I went back to the old version for now and the errors are gone. think I will stick with version 2 since this new version breaks the setup that I already have.
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 25th Jun 2022 22:15
@Shadow_Master did you enter the name of the behaviour?

MAX has a strange thing where if you change a behaviours parameters it doesn't register straight away in an existing level, you may need to re-assign the behavior in the editor and then set the behaviour name as described in step 3) before it will work.
Been there, done that, got all the T-Shirts!
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 25th Jun 2022 22:17
@3com I think a nice clean new Lua command that simply returns the _main function name for a given entity Id would be preferable.
Been there, done that, got all the T-Shirts!
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 25th Jun 2022 22:23
very neat, i like the solution to making sure your script runs after the linked entity
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Shadow_Master
3
Years of Service
User Offline
Joined: 7th Oct 2020
Location:
Posted: 25th Jun 2022 22:29
@AmenMoses, I will try that tomorrow and let you know happens
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 25th Jun 2022 23:07
I noticed lately that GGMax run the script even for non-activated entities, when the test game start, so, you need to include some condition to avoid it.
@ AmenMoses
I agree
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 26th Jun 2022 12:11
I want my scripts to run straight away, they need it in order to initialise everything.

Once initialised they tend to just sit there doing very little though so it's not really a performance issue.
Been there, done that, got all the T-Shirts!
PM
Shadow_Master
3
Years of Service
User Offline
Joined: 7th Oct 2020
Location:
Posted: 27th Jun 2022 20:38
@AmenMoses, I am confused with the new glue behavior script, version 2 is extremely simple to use. It just works which I love
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 28th Jun 2022 14:15 Edited at: 28th Jun 2022 14:17
What is confusing about it?

If you have say 3 entities attached to another which is running the sliding door behaviour you only need to attach the glue behaviour to one of them, it then gets linked to the 'door' entity and in the behaviour settings for the 'glue' entity you put the name of the behaviour it is using (i.e. door_sliding or whatever).
Then simply link the other two to the 'glue' entity.
You can link up to 9 more entities to the 'glue' entity. (so in total you can have 10 entities that move with the moving entity)
Been there, done that, got all the T-Shirts!
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 28th Jun 2022 17:22
@ Amen
Some mesh linked to the "Glue" entity, can be animated?
i.e. the doorknob.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 28th Jun 2022 19:09
@3com Not sure what you mean but any dynamic entity should work with it.
Been there, done that, got all the T-Shirts!
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 28th Jun 2022 20:47
@ Amen
The doorknob run anims> the door opens> the doorknob stop anim and moves with the door; that's the sequence I'm thinking about.
Of course, the doorknob will be linked (glued) to the door.
I recall something about the issue with the bulletholes and animated meshes, maybe your glue script might help
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 28th Jun 2022 20:53 Edited at: 28th Jun 2022 20:56
i might be wrong but i think he's asking if you could glue a door knob to a door and then the door knob could still rotate during it's animation.

if so - the script is intended to work with objects moved / rotated by lua only so you will likely get mismatch if you have animated movement / rotation - though it would likely be fine in the case of rotation around a center pivot

lol, posted at same time
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Shadow_Master
3
Years of Service
User Offline
Joined: 7th Oct 2020
Location:
Posted: 28th Jun 2022 22:00 Edited at: 28th Jun 2022 23:57
@AmenMoses. okay, let me show you why I have a hard time using the new glue instead of trying to explain. I do not know anything about the script (still learning)

first, the version 2 screenshot which has:

2 wall Candles that are glued to the sliding wall
2 flames (above the candle) are also glued to the sliding wall
and finally, the fireplace which is also glued to the sliding wall

Or how above a sliding wall covered with a picture and a globe that is glued to another sliding wall


Now screenshot of your new version with a script box, I have no clue or idea what to put in that box or even what it is for.
I am scared of breaking those walls because I have no idea of what I pose to do with the script box.


Now I hope you understand my frustration with your new glue script. Version 2 is easy to understand unlike your new version with a script box and no idea about scripts
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 28th Jun 2022 23:04
Quote: "if so - the script is intended to work with objects moved / rotated by lua only so you will likely get mismatch if you have animated movement / rotation - though it would likely be fine in the case of rotation around a center pivot"

Yes, most likely you are right.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 28th Jun 2022 23:12
Quote: "I am scared of breaking those walls because I have no idea of what I am pose to do with the script box."

You must have to enter the script name your entity is using; I guess if you don't enter anything it will return 0, meaning there is not any script attached to it.
Although, since it should be linked (glued) to an animated/moving mesh, so, most likely you are going to need a script, so, just enter this script name; i.e a door use door.lua, so, enter this name on the slot.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
Shadow_Master
3
Years of Service
User Offline
Joined: 7th Oct 2020
Location:
Posted: 28th Jun 2022 23:55 Edited at: 29th Jun 2022 00:03
@3com, that is why I am using his version 2 glue script, it is just easier for me. I put too much work into my hidden rooms to mess them up now. Until I am forced to upgrade to the next version, I will stick with the version 2 script because it works automatically without me adding anything to it. I like simple stuff and Version 2 is simple to a non-coder.

3com, just do me a favor and try version 2 and then you might understand where I am coming from
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 29th Jun 2022 09:26 Edited at: 29th Jun 2022 14:48
First take the glue behaviour off of all the entities.

Then in your first example:
1) Attach the new glue behaviour to the fireplace.
2) Link it to the sliding wall.
3) In the behaviour setting for the fireplace put the name of the script for the wall (door_sliding presumably)
4) Now link the fireplace to the two candles
5) And link the fireplace to the two flames.

That should now work.
(by 'link' I mean click on the 'shooter' icon up in the top right and then drag the blobby logic connector things between the two entities. The 'moving' entity must be the first 'link' you make)
Been there, done that, got all the T-Shirts!
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 29th Jun 2022 09:34 Edited at: 29th Jun 2022 09:37
Quote: "The doorknob run anims> the door opens> the doorknob stop anim and moves with the door; that's the sequence I'm thinking about.
Of course, the doorknob will be linked (glued) to the door.
I recall something about the issue with the bulletholes and animated meshes, maybe your glue script might help "


As long as:
1) The door is actually moving (i.e. using the door_rotate behaviour or whatever) and not simply animated.
2) The doorknob has a behaviour that handles the animation of it and triggers the door entity.

Then yes, you can attach the glue behaviour to another entity and link it to the door (first! important that) and the door knob and then the door knob should move with the door.
I would suggest that the third entity, i.e. the one with the glued behaviour attached) could be a coat hook or a door sign or whatever, something that fits the scene, or you could attach it to an invisible entity.

Btw, the issue with animated entities is that they are not actually moving so no amount of script can help with that.
That is why bullet holes can't work with either dynamic entities or animated entities only static ones (otherwise the bullet hole would stay where it is floating in mid air whilst the entity moves, or appears to move, out of the way).
Been there, done that, got all the T-Shirts!
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 29th Jun 2022 11:22
@ Amen
Thanks for clarifying mate.
Gonna try it next weekend
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 29th Jun 2022 11:23
@ Shadow_Master
I've got your point now.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
Shadow_Master
3
Years of Service
User Offline
Joined: 7th Oct 2020
Location:
Posted: 29th Jun 2022 20:11
@AmenMoses, okay, I understand now and that will be easy to do with the fireplace, candles and flame wall but guess I have to resize my picture on the other wall lol to relink it with the new glue script.

I just so use to the other version without the script box but I understand now how to use it lol thanks for the help.

One last question, I can do all this without unlocking my items, right? (Except for the picture wall because I will have to scale that down to link or maybe not.) I will try to relink it first without scaling the picture.

Thanks for explaining more details about the script box, AmenMoses
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 29th Jun 2022 20:22
Shouldn't matter what size they are to make the links, if you can't see the blobby doodahs to make the links with just move one entity to the side, make the link then move it back.
As we can put the x,y,z values in explicitly now you could just write them down, move the entity and then re-enter the values to put it back.
Been there, done that, got all the T-Shirts!
PM
Shadow_Master
3
Years of Service
User Offline
Joined: 7th Oct 2020
Location:
Posted: 29th Jun 2022 20:55
@AmenMoses, My fireplace wall does not slide down anymore and says function null, and the picture wall slides but the picture stays up. I think that I need to switch the globe with the picture and link the globe to the wall.

What would cause the fireplace wall to not open or do anything?
PM
Shadow_Master
3
Years of Service
User Offline
Joined: 7th Oct 2020
Location:
Posted: 29th Jun 2022 21:04
@AmenMoses, okay, I try linking the globe to the wall and the same thing happens lol wall goes down and the picture stays up with the globe, I have to be doing something wrong lol I promise, I will get this to work with your new script even if it kills me lol

PM
Shadow_Master
3
Years of Service
User Offline
Joined: 7th Oct 2020
Location:
Posted: 29th Jun 2022 21:29
Okay got the Picture/globe wall working, wish me luck with the fireplace wall, I do not know if the door script needs to be removed and then replace, so break that wall completely down and see if I can get the wall to slide by itself
PM
Shadow_Master
3
Years of Service
User Offline
Joined: 7th Oct 2020
Location:
Posted: 29th Jun 2022 22:12
@AmenMoses, Solved thank you so much for being patient with me. I had to break my fireplace wall lol but got it to work yahooooooo piece by piece. I also find out that there was a hidden wall candle stick behind one of the candle, that might been causing the function null error.

By remove the Sliding door script and then restarting Max, followed by reassigning the sliding door script to the wall it worked go figure lol Have a great evening, my friend
PM

Login to post a reply

Server time is: 2024-03-28 22:43:48
Your offset time is: 2024-03-28 22:43:48