Scripts / Entity Hide Script (Blocking Volume) ?

Author
Message
Nomad Soul
GameGuru Tool Maker
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location: United Kingdom
Posted: 1st Nov 2014 00:34
Hi,

I read Lee added a hide command recently so entities can be seen in the editor but hidden in the game and act as a blocker for the player e.g. can be used to prevent the player going beyond the edges of a map. I think it said this also has no performance impact on the engine which is nice.

I'm new to LUA and need to get my head around a basic script to begin with. Please can someone post a script I can assign to an entity so it will be hidden in the game and prevent the player from walking through it as above?

Thanks

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 1st Nov 2014 04:04
Rolfy posted an object for this quite awhile ago, so you could try that. You don't really need a script, just a 3D plane that has a transparent texture, the collision still works. If I were to add invisible walls, I would simply make a plane that has a 1x1 texture of say blue. Place them as needed, then, when happy change the textures alpha to 0 so you can no longer see them. I think Rolfy's models use LOD to do the same but without having to manually do that, but not having used it couldn't say for sure. Still, you certainly, don't need any scripting for invisible walls.
If you wanted to hide an object via scripting the command has been around for awhile, hide(e). Just add that to whatever script you have for the object in the init part. That way you wouldn't have to mess with textures later on.

Obviously, if there is a new command I have missed or in the wings that speeds things up, as hiding objects doesn't give you the speed boost you would imagine, then I would like to see it myself But that would show in editor and not in game I'm pretty sure.



SPECS: Q6600 CPU. Nvidia 660GTX. 8 Gig Memory. Win 7.
cybernescence
GameGuru Master
11
Years of Service
User Offline
Joined: 28th Jan 2013
Playing: Cogwheel Chronicles
Posted: 1st Nov 2014 11:04
I wrote the attached as a blocking zone script. To do the blocking It uses one hidden/invisible entity that is moved in front of player if they are inside a trigger zone with this script attached.

-- Attach script to a trigger zone and extend the zone to the full area to be blocked to the player
-- Also needs an entity to be added to the map with its known entity number set in the script
-- Tested with the 'Gates' entity
-- Set Gates entity to not spawn at start after placement in map - can be placed anywhere



Seems to work OK for me.

Attachments

Login to view attachments
Nomad Soul
GameGuru Tool Maker
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location: United Kingdom
Posted: 2nd Nov 2014 00:35
Thanks for the help guys.

@DVader
Do you know where the default.lua script is? I can't find it in the scriptbank folder and I was hoping to use this as a template.
I tried making a basic version of this using a modified health script but it didn't work.

@cybernescence
OMG I'm going to need to get some LUA books. So much for a simple script!!
It works great though and very generous of you to share. I think this should be part of the stock scripts to be honest.

tomjscott
User Banned
Posted: 2nd Nov 2014 00:46 Edited at: 2nd Nov 2014 00:47
There is no actual default.lua script, but if you make one of your own then all newly created entities will automatically use it. It's definitely a convenience depending on what you want to do.

System Specs: OS - Windows 7 Home Premium 64-bit SP1, CPU - AMD Phenom II X4 945, 3.0Ghz, RAM - 8Gb DDR3, GFX Card - 2048MB NVIDIA GeForce GT 640, FPSC-R Version - Beta 1.0085
cybernescence
GameGuru Master
11
Years of Service
User Offline
Joined: 28th Jan 2013
Playing: Cogwheel Chronicles
Posted: 2nd Nov 2014 02:19
@Nomad Soul

Your script works OK - have you made sure the entity you are attaching it to has 'static mode ' set to 'No'? And '80' is quite a close distance - try changing to say '180' to see the effect better - when you get close, the entity will beco
Nomad Soul
GameGuru Tool Maker
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location: United Kingdom
Posted: 2nd Nov 2014 09:32 Edited at: 2nd Nov 2014 10:26
@cybernescence

Thanks again. I had my entity set to static so it wasn't working but my script works now so there is hope for me yet.

I've attached my 1st contribution. Just comment out the prompt and sound lines if required.

Login to post a reply

Server time is: 2024-12-21 17:51:35
Your offset time is: 2024-12-21 17:51:35