Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Entity's physics not setting to static
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#1
Entity's physics not setting to static

I have a script that's supposed to switch a certain entity's physics to static. However, since there are 4 different versions of the aforementioned entity on the map I only want the one that player grabs and places in a certain spot to become static. I used for ints.

Here's the code:

PHP Code: (Select All)
for(int i=1;i<=4;i++) AddEntityCollideCallback("rock_"+i"Puzzle_UseSoil""UseRockOnPedestal"true1); 

void UseRockOnPedestal(string &in asParentstring &in asChildint alState)
{
    
AddGlobalVarInt("ElementsPuzzle"1);
    
PuzzleCheck();
    for(
int i=0;i<4;i++) SetPropStaticPhysics(asParent+itrue);
    
PlaySoundAtEntity("""impact_rock_high.snt""Player"0false);
    
GiveSanityBoost();


So as you can see since I have 4 entities named rock_1, rock_2, etc, it would be pretty stupid to make the static function for each one. I thus instead tried to avoid doing it like
PHP Code: (Select All)
SetPropStaticPhysics("Rock_"true); 
because that would pretty much eat too much time, and would set all those various entities around the map static. I tried using asParent name instead, but it doesn't help.

Any ideas on how I can fix this up?
08-07-2016, 09:00 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Entity's physics not setting to static

Wait, you're using asParent+i ? That would be incorrect, since you've already done "rock_"+i above. How about this:

PHP Code: (Select All)
void UseRockOnPedestal(string &in asParentstring &in asChildint alState)
{
    
AddGlobalVarInt("ElementsPuzzle"1);
    
PuzzleCheck();
    
SetPropStaticPhysics(asParenttrue);
    
PlaySoundAtEntity("""impact_rock_high.snt""Player"0false);
    
GiveSanityBoost();


No need to do the for-loop twice, because you've already created callbacks for each individual rock. Doing so would effectively just double it, making it become rock_1_1 or in your case rock_10, rock_21, rock_32, rock_43 because you're adding another number (the +i onto asParent) to a name that already has a number.

(This post was last modified: 08-07-2016, 10:19 PM by Mudbill.)
08-07-2016, 10:17 PM
Find
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#3
RE: Entity's physics not setting to static

(08-07-2016, 10:17 PM)Mudbill Wrote: Wait, you're using asParent+i ? That would be incorrect, since you've already done "rock_"+i above. How about this:

PHP Code: (Select All)
void UseRockOnPedestal(string &in asParentstring &in asChildint alState)
{
    
AddGlobalVarInt("ElementsPuzzle"1);
    
PuzzleCheck();
    
SetPropStaticPhysics(asParenttrue);
    
PlaySoundAtEntity("""impact_rock_high.snt""Player"0false);
    
GiveSanityBoost();


No need to do the for-loop twice, because you've already created callbacks for each individual rock. Doing so would effectively just double it, making it become rock_1_1 or in your case rock_10, rock_21, rock_32, rock_43 because you're adding another number (the +i onto asParent) to a name that already has a number.

I already tried doing it that way before. It didn't work either. The functions are called because I'm able to complete the puzzle but I can still carry the rock with me.
08-07-2016, 10:35 PM
Find
Darkfire Offline
Senior Member

Posts: 371
Threads: 22
Joined: May 2014
Reputation: 15
#4
RE: Entity's physics not setting to static

Maybe the entity can't be set to static physics ? If there's no tickbox in it's properties then yes. But it's an entity you can pick up, and those usually can be set to static. Anyway, just sayin.

Other thing, which is even more stupid: Try swapping child and parent in the function. I have a vague memory it fixed something for me once.
I'm probably just (unpurposely) bullshitting you, but it's worth a try if everything else fails.

EDIT You can also try using Sticky areas, just be sure to untick the "can detach" box. Should have the same effects you're trying to script. You would just have to add some script using if(getentitiescollide etc) or addentitycollidecallback to finish the puzzle.

(This post was last modified: 08-07-2016, 11:10 PM by Darkfire.)
08-07-2016, 11:05 PM
Find
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#5
RE: Entity's physics not setting to static

(08-07-2016, 11:05 PM)Darkfire Wrote: Maybe the entity can't be set to static physics ? If there's no tickbox in it's properties then yes. But it's an entity you can pick up, and those usually can be set to static. Anyway, just sayin.

Other thing, which is even more stupid: Try swapping child and parent in the function. I have a vague memory it fixed something for me once.
I'm probably just (unpurposely) bullshitting you, but it's worth a try if everything else fails.

EDIT You can also try using Sticky areas, just be sure to untick the "can detach" box. Should have the same effects you're trying to script. You would just have to add some script using if(getentitiescollide etc) or addentitycollidecallback to finish the puzzle.

Unfortunately your tips didn't work, but I appreciate the help anyway. This is getting fucking ridiculous, I swapped the script so that it sets all the rocks static on the map and it still doesn't work.

EDIT:

I added a SetEntityInteractionDisabled func to my script and it seemed to have fixed that issue! The thread can be locked up now.
(This post was last modified: 08-07-2016, 11:35 PM by Slanderous.)
08-07-2016, 11:30 PM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#6
RE: Entity's physics not setting to static

Issue seems to be solved, so locking on behalf of Slanderous' request!

Discord: Romulator#0001
[Image: 3f6f01a904.png]
08-08-2016, 03:06 AM
Find




Users browsing this thread: 1 Guest(s)