Hello, readers. I would totally PM this to JR-Imagine, since this involves his buildables script, but since I haven't reached 20 posts yet (BibleThump), I was wondering if anyone could help me with scripting a door to clear whenever the buildable is finished? I don't entirely get why the buildables_bench_item() function includes a bench parameter; I figure that has something to do with it?
Do you want the players to buy the door before opening, or do you want it just to open automatically? Something like this will work.
Code Snippet
Plaintext
buildables_bench_item(trig, bench) { door = getEnt("buildable_door", "targetname"); //this will be the door that opens trig = getEnt("buildable_door_trig", "targetname"); //this is the trigger that you buy on the workbench cost = 1000; //This is how much it will cost to open the door while(1) { trig setCursorHint("HINT_NOICON"); trig sethintstring("Press &&1 to open Door [Cost: " + cost +"); //Change this is what you want the trig to say. trig waittill("trigger",player); if(player.score >= cost) { if( IsDefined( trig.script_flag ) ) { flag_set( trig.script_flag ); } else { iprintlnbold("Did not set the script flag on the trigger properly."); } play_sound_at_pos( "purchase", player.origin ); trig delete(); door MoveZ (500, 1); play_sound_at_pos("door_slide_open", door.origin); door delete(); door connectpaths(); wait 1; } else { play_sound_at_pos( "no_purchase", player.origin ); //I believe that is the no money sound. } } }
If you want it to open without it costing, then you don't need 90% of this code, just the stuff dealing with the door.
Make sure you set up the door and trig just like you do with every normal door. Make sure the trig has the script_flag for the name of the zone, and that the zone is set up properly.
Also make sure dynamic path is checked on the door.
If there are any problems just tell me. I kind of wrote this quick, and I am extremely tired xD
Last Edit: April 11, 2016, 02:22:41 am by thezombiekilla6
Do you want the players to buy the door before opening, or do you want it just to open automatically? Something like this will work.
Code Snippet
Plaintext
buildables_bench_item(trig, bench) { door = getEnt("buildable_door", "targetname"); //this will be the door that opens trig = getEnt("buildable_door_trig", "targetname"); //this is the trigger that you buy on the workbench cost = 1000; //This is how much it will cost to open the door while(1) { trig setCursorHint("HINT_NOICON"); trig sethintstring("Press &&1 to open Door [Cost: " + cost +"); //Change this is what you want the trig to say. trig waittill("trigger",player); if(player.score >= cost) { if( IsDefined( trig.script_flag ) ) { flag_set( trig.script_flag ); } else { iprintlnbold("Did not set the script flag on the trigger properly."); } play_sound_at_pos( "purchase", player.origin ); trig delete(); door MoveZ (500, 1); play_sound_at_pos("door_slide_open", door.origin); door delete(); door connectpaths(); wait 1; } else { play_sound_at_pos( "no_purchase", player.origin ); //I believe that is the no money sound. } } }
If you want it to open without it costing, then you don't need 90% of this code, just the stuff dealing with the door.
Make sure you set up the door and trig just like you do with every normal door. Make sure the trig has the script_flag for the name of the zone, and that the zone is set up properly.
Also make sure dynamic path is checked on the door.
If there are any problems just tell me. I kind of wrote this quick, and I am extremely tired xD
Well, I circumvented the problem by making two doors, one of them with only a targetname KVP. I probably won't try your method for now cause it takes forever for my map to compile, but thanks for the help!