I am helpless

Hello!

I have this code

Just to explain planet1tile attribute is T
And newobject is Grid

X1 = newobject
X3 = X1.planet1tile
Log ("" +X1+ "." + X3)

Now this is what comes out in LOG: Grid2.T =

This is what I want the game to put out of the code instead Grid2.planet1tile instead of the actual content of the planet1tile attribute, I want the name of the attribute itself.
I know there is a GetAttribute function but it somehow refuses to work with my code... Maybe I am doing something wrong again.

Maybe someone could try to make this work so that the output is actually Grid2.planet1tile and show me how he did it?

EDIT: And when I actually use the GetAttribute function to define what planet1tile is, it throws nothing, just empty, nothing.
EDIT: Ehmm... I think I just found out solution anyway?... ("whateverattribute") seems to be the way to do it...?
EDIT: Well, turns out that it works in LOG but in practice it still leave blank string.


This depends on Grid2 being an object and the variable newobject being set as the Grid2 object.

X1 = newobject
Log (X1.name+ ".planet1tile")

That should output the text you want, but I'm not certain I'm grasping what you're attempting to do.

If Grid2 is an object, this will put Grid2.planet1tile in the log.


If planet1tile is an attribute, it's a variable. If you print a variable like "+variable+", Quest will use its value.


This is the first way I did it, before I saw I could just lose the entire second line.

Here is the entire script I used:

//======================================================================
// You don't need this bit.  I needed to set this all up to test it.

create ("Grid2")  // Created a Grid2 object
Grid2.planet1tile = "T"  // Assigned the attribute with string value "T"
newobject = Grid2  // Set newobject variable to Grid2

// END OF BIT YOU DON'T NEED
//---------------------------------------------------------------------

// The following is the first line from your script
X1 = newobject

// I altered the next line to set the Object name followed by the string we want.
X3 = X1.name+".planet1tile"

//Removed unnecessary things
Log (X3)

This is what I get in my log:

10/24/2017 3:22:35 PM Grid2.planet1tile


I hope that helps.


This does not help, because when I want the Quest to use that, it will understand it as a string, not actually as the attribute of the object.

I am sorry that I am not able to describe what I am trying to do.
I am non-native English speaker who self-taught this language so that may be an issue...


Do you just want it to print "T"?

// ======================================================================
// You don't need this bit.  I needed to set this all up to test it.
create ("Grid2")
Grid2.planet1tile = "T"
newobject = Grid2
// END OF BIT YOU DON'T NEED
// ---------------------------------------------------------------------
// The following is the first line from your script
X1 = newobject
// I altered the next line again.
X3 = X1.planet1tile

Log (X3)

10/25/2017 10:00:23 AM T


The log is not important here at all, it needs to be able to assign a real string to a variable attribute...

I have set up a test and I think this will help you understand my issue bit more?

X2 = (planet1tile) 
//This (ABOVE) is the critical point of the code. This needs to be changed to work properly.
X4 = Grid+X2
msg (X4) 
// usually this prints out Q, which is alright because I set it to be Q in other parts of code.
msg (Grid.planet1tile) 
// This is a final check to see if it REALLY works, it does not because it prints out T which is default string of planet1tile

If this doesn´t explain what I am trying to do, I am just going to throwup a whole demo of my game to let you see everything.

EDIT: yes adding X2.planet1tile does it... only if you have one variable, which is X2 but what if I want to have another variable the attribute itself?


Different methods:

// ======================================================================
// You don't need this bit.  I needed to set this all up to test it.
create ("Grid2")
Grid2.planet1tile = "T"
newobject = Grid2
// END OF BIT YOU DON'T NEED
// ---------------------------------------------------------------------
//
//
// The following is the first line from your script
X1 = newobject
X3 = X1.name+".planet1tile"
X3alt1 = X1.name+"."+X1.planet1tile
X3alt2 = X1.planet1tile

msg ("X1 is: "+X1)
msg ("X3 is: "+X3)
msg ("X3alt1 is: "+X3alt1)
msg ("X3alt2 is: "+X3alt2)

X1 is: Object: Grid2
X3 is: Grid2.planet1tile
X3alt1 is: Grid2.T
X3alt2 is: T


Wait! I think I see what you want to do!

Check out X3alt3:

// ======================================================================
// You don't need this bit.  I needed to set this all up to test it.
create ("Grid2")
Grid2.planet1tile = "T"
newobject = Grid2
// END OF BIT YOU DON'T NEED
// ---------------------------------------------------------------------
//
//
// Altered again

X1 = newobject
X2 = "planet1tile"
X3 = X1.name+".planet1tile"
X3alt1 = X1.name+"."+X1.planet1tile
X3alt2 = X1.planet1tile
X3alt3 = GetAttribute(X1, X2)

msg ("X1 is: "+X1)
msg ("X3 is: "+X3)
msg ("X3alt1 is: "+X3alt1)
msg ("X3alt2 is: "+X3alt2)
msg ("X3alt3 is: "+X3alt3)

X1 is: Object: Grid2
X3 is: Grid2.planet1tile
X3alt1 is: Grid2.T
X3alt2 is: T
X3alt3 is: T


Yes but the problem is this, in X3 = X1.name+".planet1tile" the planet1tile is a string, not a variable that can be changed...
EDIT: Arrtgghghghgg!!! Hold on I am onto something...
EDIT: Lol, I give up.


// ======================================================================
// You don't need this bit.  I needed to set this all up to test it.
create ("Grid2")
Grid2.planet1tile = "T"
newobject = Grid2
// END OF BIT YOU DON'T NEED
// ---------------------------------------------------------------------
//
//
// Altered again

X1 = newobject
X2 = "planet1tile"
X3 = X1.name+".planet1tile"
X3alt1 = X1.name+"."+X1.planet1tile
X3alt2 = X1.planet1tile
X3alt3 = GetAttribute(X1, X2)

msg ("X1 is: "+X1)
msg ("X3 is: "+X3)
msg ("X3alt1 is: "+X3alt1)
msg ("X3alt2 is: "+X3alt2)
msg ("X3alt3 is: "+X3alt3)

//To change the attribute:
X4 = "newAttributeValue"
X1.planet1tile = X4

X3alt4 = GetAttribute(X1, X2)
msg ("X3alt4 is: "+X3alt4)

EDIT:

//To change the attribute:
X4 = "newAttributeValue"
set (X1, X2, X4)

X3alt4 = GetAttribute(X1, X2)
msg ("X3alt4 is: "+X3alt4)

It seems like it works... but I am not going to celebrate until I fully implement it into my game, still thanks because you gave me ideas for other options in case this does not work out.

And I really mean, thank you for your patience.


No problem, Sebastian. I'm happy to help, and I'm learning stuff right along with you!


I played with it a little more, it may help with something:

// ======================================================================
// You don't need this bit.  I needed to set this all up to test it.
create ("Grid2")
Grid2.planet1tile = "T"
newobject = Grid2
// END OF BIT YOU DON'T NEED
// ---------------------------------------------------------------------
//
//
// Altered from here on out

X1 = newobject
X2 = "planet1tile"
X3 = X1.name+".planet1tile"
X3alt1 = X1.name+"."+X1.planet1tile
X3alt2 = X1.planet1tile
X3alt3 = GetAttribute(X1, X2)

msg ("X1 is: "+X1)
msg ("X3 is: "+X3)
msg ("X3alt1 is: "+X3alt1)
msg ("X3alt2 is: "+X3alt2)
msg ("X3alt3 is: "+X3alt3)

//To change the attribute:
X4 = "newAttributeValue"
set (X1, X2, X4)

//Resetting the different ways to do X3
X3 = X1.name+".planet1tile"
X3alt1 = X1.name+"."+X1.planet1tile
X3alt2 = X1.planet1tile
X3alt3 = GetAttribute(X1, X2)

//Print after change
msg ("X1 is still: "+X1)
msg ("X3 is still: "+X3)
msg ("X3alt1 is now: "+X3alt1)
msg ("X3alt2 is now: "+X3alt2)
msg ("X3alt3 is now: "+X3alt3)

X1 is: Object: Grid2
X3 is: Grid2.planet1tile
X3alt1 is: Grid2.T
X3alt2 is: T
X3alt3 is: T
X1 is still: Object: Grid2
X3 is still: Grid2.planet1tile
X3alt1 is now: Grid2.newAttributeValue
X3alt2 is now: newAttributeValue
X3alt3 is now: newAttributeValue


Wow, just wow, it works.

The SET function perceives strings differently than everything else and that caused it to work.


Hurray!


Log in to post a reply.

Support

Forums