Scripts / Help with ladder script

Author
Message
Necrym59
8
Years of Service
User Offline
Joined: 2nd Jul 2016
Location:
Posted: 26th Jan 2022 23:38
Hi all
Im editing Gubblys ladder script to auto get and set the ladder objects height
im using the physics function call
local dims = P.GetObjectDimensions ( e )
Prompt( "height=" .. dims.h )
Now this works fine and collects and applies the height to the variable
However when a second or third ladder is introduced the script errors saying
' attempt to index local 'dims' (a nil value)'
Ive scratched my head over this for hours, can anyone shed some light on my sad attempt at scripting

Attachments

Login to view attachments
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 27th Jan 2022 06:55
Is that mine or someone else's? Oh I see, you are adding functionality, - that didn't look familiar.
I could look it over, but those are AmenMoses libraries. Glad that part works, if so.
Okay I looked through the physics script and it calls for using Objects instead of Entity #

Try this
**BEFORE the init;
local ladnecw, ladnech, ladnecl, ladnecm, ladneccx, ladneccy, ladneccz, ladneccxs, ladneccys , ladnecczs = {}
**INSIDE init;
ladnecw[e], ladnech[e], ladnecl[e], ladnecm[e], ladneccx[e], ladneccy[e], ladneccz[e], ladneccxs[e], ladneccys[e], ladnecczs[e] = P.GetObjectDimensions ( g_Entity[e]['obj'] )

You will want to refer to "ladnech[e]" for height- if that works, and let us know cause I never used that one before.

My physlib date is 12-1-2020 is that the same as yours?
With a nil error; usually you just need to see if the variable is assigned a value before it's compared or used in any manner that requires a value instead of nil- obviously! ( often 0 works as preliminary setting ). Either in the init or before the init if you are using multiple entities with same script, and then turn the value into an array (table) using --
** BEFORE init;
local var = {}
** AFTER init
var[e] = __your value__

Now I gotta ask these masters a question about particles! Maybe later...
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 27th Jan 2022 07:46
Scratch that, that seldom (but occasionally works for me). For some reason this time it wouldn't acknowledge variables existence until I separated them all into their own table list.

Even though it's 2:30 am here now, I couldn't let it go. Couldn't let the tiger go.
So I got it working but in a bit of a different method by extracting bits and pieces of critical data from physlib.lua

Attachments

Login to view attachments
PM
Necrym59
8
Years of Service
User Offline
Joined: 2nd Jul 2016
Location:
Posted: 27th Jan 2022 08:42
Ha i couldnt let it go either i spent heaps trying different itterations before i went back to the one i posted here i must admit i was a bit lazy about seperating all the bits it 'should' have worked. That P.GetObjectDimensions( e ) is supposed to work either way as entity or object it had me tricked, sometimes you just work blindly. Ill check it out. If it works at auto setting the height of a climable object Gubbly you should send it to Lee they may include it in the MAX product as its an awsome script that could work with anything. Thanks for the time sacrifice on it mate, im still coming to grips with lua, it seems to have strange limiitations when it comes to GG from what i can see.
PM
Necrym59
8
Years of Service
User Offline
Joined: 2nd Jul 2016
Location:
Posted: 27th Jan 2022 09:48
Tried it and just tweaked it and tidied it up a bit - it works an absolute treat in GGMAX (and i presume in GG) with multiple ladders/objects of different heights all running the one script, such a great bit of usefull script should be a standard for FPS games in MAX. You are a legend. Attached the tweaked version.

Attachments

Login to view attachments
PM
GraPhiX
Forum Support
19
Years of Service
User Offline
Joined: 15th Feb 2005
Playing:
Posted: 27th Jan 2022 12:08 Edited at: 27th Jan 2022 12:10
@Necrym59
you could have used this https://forum.game-guru.com/thread/217932?page=16#msg2641368

just stretch the place holder to the height of ladder
Welcome to the real world!
Main PC - Windows 10 Pro x64 - Core i7-9700K @4.2GHz - 64GB DDR4 RAM - GeForce RTX 2070 SUPER 8GB - 2TB NVe, 1TB NVe, 2TB Hybrid Data Drive
Test PC - Windows 10 Pro x64 - Core i7-7700K @4.2GHz - 32GB DDR4 RAM - GeForce GTX 1060-6G 6GB - 1TB NVe SSD
Laptop - Helios 300 Predator - i7 7700HQ - 32GB - Nvidia GTX1060 6GB - 525GB M2 - 500 SSD - 17.3" IPS LED Panel - Windows 10 Pro x64
Asset Manager
xRange No Nonsense Tools
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 27th Jan 2022 13:35
Thanks for the compliment @ Necrym59 but on the best of days I'm closer to a used ledge for birds than legend.
"Send it to Lee"
The script has a few obstacles namely it's just straight vertical up and down and needs a little forward access. Now that object dimensions are in (excellent suggestion btw), that shouldn't be too hard- pretty straight forward. So maybe that could be the next tweak.
It's also a little awkward with exiting the ladder sideways or backward (maybe- do you think?) but in fact a real person on a real ladder only has those two options unless the ladder is built into the structure (with handrails, et-al).
Maybe AmenMoses script @GraPhiX tackles those issues? IDK, haven't looked at it yet but I'm sure it's a shiny new Ferrari 812 GTS compared to my 2003 Ford Escape attempts.
PM
Necrym59
8
Years of Service
User Offline
Joined: 2nd Jul 2016
Location:
Posted: 27th Jan 2022 18:36
Hi GraPhiX, dammit i didnt even see that one about, its a great option. This all started because I was just originally trying to use any ladder/object and to get its height automatically to make a one-fits-all script for any climable object. GubbyBlips As for exiting the ladder your right it could just sense when the top is reached for auto forward/left/right access perhaps for smoother exit i might have a fiddle with it. Its funny once you start you just cant let it go sometimes. I think the gurus could play with it more it makes for an excellent base for a generic climbing script.
PM
Necrym59
8
Years of Service
User Offline
Joined: 2nd Jul 2016
Location:
Posted: 6th Mar 2022 06:00
This script is now part of MAX.
PM

Login to post a reply

Server time is: 2024-12-22 01:17:09
Your offset time is: 2024-12-22 01:17:09