UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Possible to hide a prefab until a trigger is hit?

broken avatar :(
Created 12 years ago
by Dust
0 Members and 1 Guest are viewing this topic.
2,344 views
broken avatar :(
×
broken avatar :(
The King of Zombies
Location: usLouisiana
Date Registered: 24 June 2013
Last active: 6 years ago
Posts
2,148
Respect
Forum Rank
King of the Zombies
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Signature
Donate to me if you enjoy my work. https://www.paypal.me/thezombiekilla6
×
Dust's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Dust's Contact & Social Linksdust103194MrZ0mbiesFanaticMrZ0mbiesFanatic
Is it possible to hide a misc_prefab with a script until someone hits a trigger? would it still work like getEnt or would it need a different command? I tried turning the prefab into a script_model but obviously you cant do that.
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
  • n123q45
  • Deleted Member
×
broken avatar :(
n123q45
This user is deleted :(
technically you would have to give the peices of the prefab a target name. then assign them a variable. use
Code Snippet
Plaintext
var hide(); 
to hide it. then use a waittill("trigger"); and then use the
Code Snippet
Plaintext
var show();
by the way var is the variable name
Last Edit: May 24, 2014, 04:43:44 am by n123q45
broken avatar :(
×
broken avatar :(
The King of Zombies
Location: usLouisiana
Date Registered: 24 June 2013
Last active: 6 years ago
Posts
2,148
Respect
Forum Rank
King of the Zombies
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
×
Dust's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Dust's Contact & Social Linksdust103194MrZ0mbiesFanaticMrZ0mbiesFanatic
technically you would have to give the peices of the prefab a target name. then assign them a variable. use
Code Snippet
Plaintext
var hide(); 
to hide it. then use a waittill("trigger"); and then use the
Code Snippet
Plaintext
var show();
by the way var is the variable name

So would for example
Code Snippet
Plaintext
ladder =getent ("piece","targetname"); //the parts of the prefab
ladder hide();
ladder_trigger ("trigger","targetname");//the trigger to make the prefab appear
ladder_trigger waittill("trigger");
ladder show();
work? then just have all pieces with the targetname of piece

Post Merge: May 24, 2014, 05:02:39 am
Also is it possible to hide a tool until they hit a trigger. Because this is going to be a ladder, so of course i need the ladder tool to make the players climb up. So even with the model not being there they can still climb up an invisible surface, which i dont want to happen
Last Edit: May 24, 2014, 05:02:39 am by thezombiekilla6
Marked as best answer by thezombiekilla6 12 years ago
broken avatar :(
×
broken avatar :(
Location: gbComing up in the world
Date Registered: 26 November 2013
Last active: 11 years ago
Posts
325
Respect
Forum Rank
Perk Hacker
Primary Group
Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
I own the hat!
×
DuaLVII's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
DuaLVII's Contact & Social LinksDuaLVIIthomas.gascoigne.7DuaLVIITheProlonger
Heya Killa,

Like n1 said, all pieces to the prefab would need their own targetnames (assuming that all peices also are script_brushmodels / script_models)

Best quick solution for this would be one trigger to a prefab, all targetnames on the prefab pieces being the same and have the trigger target that targetname such is targets all.

Hiding a script_brushmodel with ladder texture won't work since hiding is just making it invisible and not actually moving it else where and hopefully my hide show script example will help solve this.

I haven't tested this since I only just made it but with this you can like I said, set all pieces with the same targetname which then the trigger targets, However;
For the likes of ladder texture brushes add into the kvp:
"script_noteworthy"   "tool" = Which tells the script to hide it through origin setting
"script_vector"   "x y z" = This will be the hidden location however if not set it will hide it -50000 units under your map

With the script, when triggered it will bring it all back again.

Code Snippet
Plaintext
hide_show_triggers()
{
myTriggers = GetEntArray("my_trigger", "targetname");
array_thread(myTriggers,::my_trigger_think);
}

my_trigger_think()
{
if(!isDefined(self.target))
{
return;
}
else
{
myTargets = GetEntArray(self.target, "targetname"); // If there is multiple (brush)models with the same targetname, it needs to be arrayed)
array_thread(myTargets,::toggle_hide); // Start by hiding everything
self waittill("trigger", hero); // EAK!! Who's going to trigger it first HURRY UP!! The suspense is killing me
array_thread(myTargets,::toggle_hide); // Show the (brush)models again
}
}

toggle_hide()
{
if(!isDefined(self.hidding_away) || self.hidding_away == false)
{
self.hidding_away = true;
if(isDefined(self.script_noteworthy) && self.script_noteworthy == "tool")
{
self.original_location = self.origin; //Save the old origin so it know's where to place it back too
if(isDefined(self.script_vector))
{
self.origin = self.script_vector;
}
else
{
self.origin = self.origin - (0, 0, -50000);
}
//Similler to disable_trigger (Infact never checked to see if it would work on this but for now...)
}
self hide();
}
else
{
self.hidding_away = false;
if(isDefined(self.script_noteworthy) && self.script_noteworthy == "tool")
{
self.origin = self.original_location; // Bring it back to it's old location
}
else
{
self show();
}
}
}

Hope it helps, Like I said, I haven't tested it so, sorry if there is any syntax errors, may need to remove or add a bracket.

Thanks,
DuaLVII

Edit: The script allows for as many triggers and triggers targets as you want
Last Edit: May 24, 2014, 10:26:45 am by DuaLVII
broken avatar :(
×
broken avatar :(
The King of Zombies
Location: usLouisiana
Date Registered: 24 June 2013
Last active: 6 years ago
Posts
2,148
Respect
Forum Rank
King of the Zombies
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
×
Dust's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Dust's Contact & Social Linksdust103194MrZ0mbiesFanaticMrZ0mbiesFanatic
Heya Killa,

Like n1 said, all pieces to the prefab would need their own targetnames (assuming that all peices also are script_brushmodels / script_models)

Best quick solution for this would be one trigger to a prefab, all targetnames on the prefab pieces being the same and have the trigger target that targetname such is targets all.

Hiding a script_brushmodel with ladder texture won't work since hiding is just making it invisible and not actually moving it else where and hopefully my hide show script example will help solve this.

I haven't tested this since I only just made it but with this you can like I said, set all pieces with the same targetname which then the trigger targets, However;
For the likes of ladder texture brushes add into the kvp:
"script_noteworthy"   "tool" = Which tells the script to hide it through origin setting
"script_vector"   "x y z" = This will be the hidden location however if not set it will hide it -50000 units under your map

With the script, when triggered it will bring it all back again.

Code Snippet
Plaintext
hide_show_triggers()
{
myTriggers = GetEntArray("my_trigger", "targetname");
array_thread(myTriggers,::my_trigger_think);
}

my_trigger_think()
{
if(!isDefined(self.target))
{
return;
}
else
{
myTargets = GetEntArray(self.target, "targetname"); // If there is multiple (brush)models with the same targetname, it needs to be arrayed)
array_thread(myTargets,::toggle_hide); // Start by hiding everything
self waittill("trigger", hero); // EAK!! Who's going to trigger it first HURRY UP!! The suspense is killing me
array_thread(myTargets,::toggle_hide); // Show the (brush)models again
}
}

toggle_hide()
{
if(!isDefined(self.hidding_away) || self.hidding_away == false)
{
self.hidding_away = true;
if(isDefined(self.script_noteworthy) && self.script_noteworthy == "tool")
{
self.original_location = self.origin; //Save the old origin so it know's where to place it back too
if(isDefined(self.script_vector))
{
self.origin = self.script_vector;
}
else
{
self.origin = self.origin - (0, 0, -50000);
}
//Similler to disable_trigger (Infact never checked to see if it would work on this but for now...)
}
self hide();
}
else
{
self.hidding_away = false;
if(isDefined(self.script_noteworthy) && self.script_noteworthy == "tool")
{
self.origin = self.original_location; // Bring it back to it's old location
}
else
{
self show();
}
}
}

Hope it helps, Like I said, I haven't tested it so, sorry if there is any syntax errors, may need to remove or add a bracket.

Thanks,
DuaLVII

Edit: The script allows for as many triggers and triggers targets as you want

Thanks man! I will try it and i can change it if needs be
broken avatar :(
×
broken avatar :(
Location: gbComing up in the world
Date Registered: 26 November 2013
Last active: 11 years ago
Posts
325
Respect
Forum Rank
Perk Hacker
Primary Group
Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
I own the hat!
×
DuaLVII's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
DuaLVII's Contact & Social LinksDuaLVIIthomas.gascoigne.7DuaLVIITheProlonger
No problem, Hope it works well.

 
Loading ...