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
Doubt about a puzzle idea (script)
sabrinagsoledad Offline
Junior Member

Posts: 32
Threads: 10
Joined: Feb 2016
Reputation: 0
#11
RE: Doubt about a puzzle idea (script)

I attached the picture.. its the same for every vase (the ones that are correct to break is suposed to be vase_1, vase_2, vase_3 and vase_4.

I think is not runing.


Attached Files
.jpg   vases.jpg (Size: 172.11 KB / Downloads: 160)
03-09-2016, 12:51 AM
Find
Spelos Away
Banned

Posts: 231
Threads: 19
Joined: Sep 2014
#12
RE: Doubt about a puzzle idea (script)

Ok, so I think Mudbill made a mistake.
It's not OnBreak, it's just Break.
And you should also change the 4 to the max number of your vases like this:

PHP Code: (Select All)
int vasesBroken 1;

void BreakVase(string &in asEntitystring &in type)
{
    if(
type != "Break") return;

    if(
asEntity == "vase_" vasesBroken)
    {
        if(
vasesBroken == 19//This should correspond to the last vase
        
{
            
//The Player got it right!
            
return;
        }
        
vasesBroken++;
        return;
    }

    
vasesBroken 1;
    
ResetProp("vase_*");

03-09-2016, 07:19 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#13
RE: Doubt about a puzzle idea (script)

Yeah was a bit unsure about that one. Not sure why that one lacks the "On". This is what I was thinking of:

[Image: ZDaTcYw.png]

Please excuse my number of silly mistakes. Hope it works now!

(This post was last modified: 03-09-2016, 08:39 AM by Mudbill.)
03-09-2016, 08:38 AM
Find
sabrinagsoledad Offline
Junior Member

Posts: 32
Threads: 10
Joined: Feb 2016
Reputation: 0
#14
RE: Doubt about a puzzle idea (script)

Hi guys.. yes that was the only issue! now its solved thank you both so much!... But I need to find another way to restart the vases because when u die (and the chekpoint is called) the broken ones doesnt restart or renew, they keep broken.
03-09-2016, 04:23 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#15
RE: Doubt about a puzzle idea (script)

So ResetProp() isn't working?

If so, then what you can do is create new objects in their place.
First create a script area where the vases are located, then use a script like this:

PHP Code: (Select All)
CreateEntityAtArea("vase_1""vase_file.ent""area_vase_1"false); 

"vase_1" is the entity name that will be created, so basically you need to loop this for the amount of vases you have. "vase_file.ent" is the entity file, which is somewhere in the entities folder. Just find out what it's called. It should be listed at the bottom of the "General" tab in the level editor. "area_vase_1" is the name of the script area that is placed on the vase.

When you place the script areas down, I recommend you name them "area_" + the name of the vase that is there. That way you can use this loop to create the new vases:

PHP Code: (Select All)
for(int i 1<= 4i++) {
    
CreateEntityAtArea("vase_"+i"vase_file.ent""area_vase_"+ifalse);


This will loop 4 times and create vase_1, vase_2, vase_3 and vase_4. Edit the '4' inside the for-loop to match the amount of vases you have. Run this inside your CheckPoint callback.

Edit: Actually, this might create more than wanted in case the player didn't break all the vases. Perhaps that's fixed by setting the previous vases inactive.

PHP Code: (Select All)
for(int i 1<= 4i++) {
    
SetEntityActive("vase_"+ifalse);
    
CreateEntityAtArea("vase_"+i"vase_file.ent""area_vase_"+ifalse);


This might fix that. Use this instead of the previous code.

(This post was last modified: 03-09-2016, 05:21 PM by Mudbill.)
03-09-2016, 05:15 PM
Find
sabrinagsoledad Offline
Junior Member

Posts: 32
Threads: 10
Joined: Feb 2016
Reputation: 0
#16
RE: Doubt about a puzzle idea (script)

Hi. I could try that, when i got home. But I think that wont work, because the new entitys that will appear dont have the break callback, so I suposed when I destroy the new vases all the funtion wont run.
03-09-2016, 11:21 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#17
RE: Doubt about a puzzle idea (script)

You got a point. That's an easy fix though. Add that callback manually, in the same loop.

PHP Code: (Select All)
for(int i 1<= 4i++) {
    
SetEntityActive("vase_"+ifalse);
    
CreateEntityAtArea("vase_"+i"vase_file.ent""area_vase_"+ifalse);
    
SetEntityCallbackFunc("vase_"+i"BreakVase");


03-10-2016, 01:25 AM
Find
Spelos Away
Banned

Posts: 231
Threads: 19
Joined: Sep 2014
#18
RE: Doubt about a puzzle idea (script)

Mudbill's right, that will most likely work.
Although, if we were to future-proof the code, we're now using the number of vases on multiple occasions. If the number were to change and you forget to change one of those values, it might not work.

So I recommend creating an Integer variable for the number of vases like this:

And actually... I would check if some entities even exist. I doubt that setting them in-active counts as destroying.

I think there is no need to recreate the unbroken vases.

PHP Code: (Select All)
int vasesBroken 1;
int numberOfVases 19;

void BreakVase(string &in asEntitystring &in type)
{
    if(
type != "Break") return;

    if(
asEntity == "vase_" vasesBroken)
    {
        if(
vasesBroken == numberOfVases)
        {
            
//The Player got it right!
            
return;
        }
        
vasesBroken++;
        return;
    }
    
vasesBroken 1;
    for(
int i 1<= numberOfVasesi++)
    {
        if(!
GetEntityExists("vase_" i)) //This will create the non-existing vases.
        
{
            
CreateEntityAtArea("vase_" i"vase_file.ent""area_vase_" ifalse);
            
SetEntityCallbackFunc("vase_" i"BreakVase");
        }
        
ResetProp("vase_*"); //This will reset the existing vases & the newly created.
    
}

(This post was last modified: 03-10-2016, 08:42 AM by Spelos.)
03-10-2016, 07:19 AM
Find
sabrinagsoledad Offline
Junior Member

Posts: 32
Threads: 10
Joined: Feb 2016
Reputation: 0
#19
RE: Doubt about a puzzle idea (script)

Im sorry for the late response... My internet company failed in almost a whole week. Both codes looks nice, I try both just for test them, but both for some reason when the new vase appear you can touch it and instead of breaking up it disapear on the aire or gets trought doors/floor/cealing without breaking jhahaha is to strange. Im looking trough what is doing that.. maybe the entity file.

OK. This thing i Solved it...

But Now just for testing the code stop working after 3 or 4 chekpoints... if I force me to be killed (for testing the respawn of the vases) the vases stack in top of other vases, and then when i Break them again the stop runing..XD
(This post was last modified: 03-13-2016, 10:13 PM by sabrinagsoledad.)
03-13-2016, 09:07 PM
Find




Users browsing this thread: 1 Guest(s)