Hiding player attributes
luke01
27 Feb 2013, 02:30Is there a way to make a players attribute invisible unless they are in a certain room? So when you left the room the attribute would be invisible again?
Sora574
27 Feb 2013, 02:44That depends. What do you mean by attribute?
If you mean something like this:
then the way I would do it is, if you want them to have the same one later, just run this:
until you need it again, in which case you would use
...Or at least that's how I would do that. If that is what you're talking about. If not, please try to explain more
If you mean something like this:
player.attribute
then the way I would do it is, if you want them to have the same one later, just run this:
<!--Inside code for the room you want to leave-->
<onexit type="script">
player.placeholder = player.attribute
player.attribute = null
</onexit>
until you need it again, in which case you would use
<!--Inside code for the room you want to enter-->
<enter type="script>
player.attribute = player.placeholder
player.placeholder = null
</enter>
...Or at least that's how I would do that. If that is what you're talking about. If not, please try to explain more
luke01
27 Feb 2013, 02:54Okay, thanks I shall try what you've suggested.
Basically what I want is, if the player has a status attribute, let's say 'air' which has a value of any number - would it be possible to have it hidden from the panel when not in a particular room but still have the ability to increase/decrease the value when it isn't visible?
Basically what I want is, if the player has a status attribute, let's say 'air' which has a value of any number - would it be possible to have it hidden from the panel when not in a particular room but still have the ability to increase/decrease the value when it isn't visible?
Sora574
27 Feb 2013, 04:12Oh, yes definitely. I have created functions similar to that for use as a gun system.
But it's a bit complicated if you don't know what you're doing.
Basically, what you need to do is:
[list][*]Make the status attribute (go to your player, go to the attributes page, click "add" under status attributes)[/*:m]
[*]Name it air, don't set the value[/*:m]
[*]Click "add" under attributes[/*:m]
[*]Name it air, click the dropdown box that appears towards the bottom, choose "Integer"[/*:m]
[*]Set the integer to whatever you want the player to start out with[/*:m]
[*]Go to 'Functions'[/*:m]
[*]Click 'add', name it something like 'HideAir'[/*:m]
[*]Click the 'Code View' button above where it says 'add new script'[/*:m]
[*]In the box, use something like this:
[*]Go to 'Functions' again and click 'add', name it 'ShowAir'[/*:m]
[*]Again, go into the Code View (as it's much easier than explaining all the different buttons and gizmos you have to click)[/*:m]
[*]Use something along the lines of:
After that, to hide or show the air, use a script that calls the function 'HideAir' or 'ShowAir'.
To do this in Code View, simply use the function name. That's it. For example...
And if you want to change the air amount even when it's hidden, just use something like
Hope that helps.
EDIT: Changed the Ifs to ifs. Lowercase matters.
SECOND EDIT: Oops. I overcomplicated things. It's all good now though.
But it's a bit complicated if you don't know what you're doing.
Basically, what you need to do is:
[list][*]Make the status attribute (go to your player, go to the attributes page, click "add" under status attributes)[/*:m]
[*]Name it air, don't set the value[/*:m]
[*]Click "add" under attributes[/*:m]
[*]Name it air, click the dropdown box that appears towards the bottom, choose "Integer"[/*:m]
[*]Set the integer to whatever you want the player to start out with[/*:m]
[*]Go to 'Functions'[/*:m]
[*]Click 'add', name it something like 'HideAir'[/*:m]
[*]Click the 'Code View' button above where it says 'add new script'[/*:m]
[*]In the box, use something like this:
if (DictionaryContains(game.pov.statusattributes, "air")) {
dictionary remove (game.pov.statusattributes, "air")
}
[/*:m][*]Go to 'Functions' again and click 'add', name it 'ShowAir'[/*:m]
[*]Again, go into the Code View (as it's much easier than explaining all the different buttons and gizmos you have to click)[/*:m]
[*]Use something along the lines of:
if (not(DictionaryContains(game.pov.statusattributes, "air"))) {
dictionary add (game.pov.statusattributes, "air", "")
}
[/*:m][/list:u]After that, to hide or show the air, use a script that calls the function 'HideAir' or 'ShowAir'.
To do this in Code View, simply use the function name. That's it. For example...
HideAir
And if you want to change the air amount even when it's hidden, just use something like
game.pov.air = game.pov.air + 10
<!--Or to lower it-->
game.pov.air = game.pov.air - 10
Hope that helps.
EDIT: Changed the Ifs to ifs. Lowercase matters.
SECOND EDIT: Oops. I overcomplicated things. It's all good now though.
luke01
27 Feb 2013, 04:29Wow! Thanks again. Okay, regarding this:
In the box, use something like this:
if (DictionaryContains(game.pov.statusattributes, "air")) {
game.pov.whenshowair = game.pov.air
game.pov.air = null
dictionary remove (game.pov.statusattributes, "air")
}
I can't figure out where this code needs to go?
In the box, use something like this:
if (DictionaryContains(game.pov.statusattributes, "air")) {
game.pov.whenshowair = game.pov.air
game.pov.air = null
dictionary remove (game.pov.statusattributes, "air")
}
I can't figure out where this code needs to go?
Sora574
27 Feb 2013, 04:45luke01 wrote:I can't figure out where this code needs to go?
Oh... I seem to have completely forgotten...
That Code View is only in 5.4 ... sorry about that
I'm assuming you're using 5.3?
Then you need to go into the normal Code View (the one at the top of the screen), or you can open your game's .aslx file in a text editor
Search for HideAmmo, I believe it looks something like
<function name="HideAmmo">
<!--Insert code here-->
</function>
Do the same for the ShowAmmo code.
P.S. use the scripts that I edited into the first post, the old ones wont work the way you want them to
HegemonKhan
27 Feb 2013, 07:22.
For Quest Version 5.3
-----------
Attributes are hidden already, only STATUS ATTRIBUTES are displayed in the panel for the game player to see.
my use of the parenthesis, is either a note, or it identifies what you are to type in (but do NOT type in the parenthesis too!)
------------
GUI (noob friendly editor with the buttons and drop down menus) mode:
1. create your game turn attribute:
Game -> Attributes (Tab) -> Attributes (the box at the bottom) -> Add ->
name: turns
type: integer
value: 0
2. create your game turn status attribute:
Game -> Attributes (Tab) -> Status Attributes (the box at the top) -> Add ->
name: turns
format string: (leave blank, just click okay button without typing in anything)
3. create your air attribute:
Player -> Attributes (Tab) -> Attributes (the box at the bottom) -> Add ->
name: air
type: integer
value: 0
4. create your air flag:
Player -> Attributes (Tab) -> Attributes (the box at the bottom) -> Add ->
name: air_flag
type: boolean
value: false (leave it UNcheck marked, so that it equates 'false' !)
5. create your air function:
Function -> Function (Tab) -> Add ->
name: air_status_attribute_setter
return type: [NONE]
parameters: (none, do NOT add any parameters!)
Script -> Add New Script ->
Scripts -> If... -> If [OBJECT ATTRIBUTE EQUALS] Object [OBJECT] [PLAYER] (air_flag) = (true) -> Then ->
-> Add A New Script -> Variables -> Add A Value To A dictionary -> Add To Dictionary (player.statusattributes) Key [STRING] (air) value [EXPRESSION] ( ! )
Add Else If -> Scripts -> If... -> If [OBJECT ATTRIBUTE EQUALS] Object [OBJECT] [PLAYER] (air_flag) = (false) -> Then ->
-> Add A New Script -> Variables -> Remove A Value From A dictionary -> Remove From Dictionary (player.statusattributes) key [string] (air)
6. create your turns and air turnscript:
Game -> Script (Tab) -> Turns Script (box at the bottom) -> Add ->
Turns Script (Tab) ->
name: air_and_game_turns
enable when the game begins: yes (click so that the little box has now a green check mark showing!)
Script -> Add New Script -> Scripts -> Call Function -> Call Function (air_status_attribute_setter) with parameters (none, do NOT add any parameters!)
Add New Script -> Variables -> Set Variable Or Attribute -> Set variable (game.turns) = [EXPRESSION] (game.turns = game.turns + 1)
7. now, all you have to do, is to:
whenever you want to show or hide your air status attribute, all you got to do is add this to any part of your game through~via a script:
Add A Script -> Variables -> Set Variable Or Attribute -> Set variable (player.air_flag) = [EXPRESSION] (true)
*true = this means that it will now show your air amount status attribute
~OR~
Add A Script -> Variables -> Set Variable Or Attribute -> Set variable (player.air_flag) = [EXPRESSION] (false)
*false = this means that it will now hide your air amount status attribute
-----------
to change your air amount:
to increase your air amount:
Add A Script -> Variables -> Set Variable Or Attribute -> Set variable (player.air) = [EXPRESSION] (player.air + some_number)
to decrease your air amount:
Add A Script -> Variables -> Set Variable Or Attribute -> Set variable (player.air) = [EXPRESSION] (player.air + some_number)
------------
and here's a demo "game", for you to take a look at:
(this is what my demo game looks like in Code View mode)
1. click on the select all above, and then copy my code.
2. create and start up a new game.
3. click on the notepaper like button on the top, between the play and ? (help) buttons, to switch over to the Code View mode (this notepaper like button is a toggle button to switch back and forth between the GUI and Code View modes).
4. select all of the game code, and delete it.
5. now paste in my code.
6. save your game file.
7. now try and play it, see what you think, hehe
For Quest Version 5.3
-----------
Attributes are hidden already, only STATUS ATTRIBUTES are displayed in the panel for the game player to see.
my use of the parenthesis, is either a note, or it identifies what you are to type in (but do NOT type in the parenthesis too!)
------------
GUI (noob friendly editor with the buttons and drop down menus) mode:
1. create your game turn attribute:
Game -> Attributes (Tab) -> Attributes (the box at the bottom) -> Add ->
name: turns
type: integer
value: 0
2. create your game turn status attribute:
Game -> Attributes (Tab) -> Status Attributes (the box at the top) -> Add ->
name: turns
format string: (leave blank, just click okay button without typing in anything)
3. create your air attribute:
Player -> Attributes (Tab) -> Attributes (the box at the bottom) -> Add ->
name: air
type: integer
value: 0
4. create your air flag:
Player -> Attributes (Tab) -> Attributes (the box at the bottom) -> Add ->
name: air_flag
type: boolean
value: false (leave it UNcheck marked, so that it equates 'false' !)
5. create your air function:
Function -> Function (Tab) -> Add ->
name: air_status_attribute_setter
return type: [NONE]
parameters: (none, do NOT add any parameters!)
Script -> Add New Script ->
Scripts -> If... -> If [OBJECT ATTRIBUTE EQUALS] Object [OBJECT] [PLAYER] (air_flag) = (true) -> Then ->
-> Add A New Script -> Variables -> Add A Value To A dictionary -> Add To Dictionary (player.statusattributes) Key [STRING] (air) value [EXPRESSION] ( ! )
Add Else If -> Scripts -> If... -> If [OBJECT ATTRIBUTE EQUALS] Object [OBJECT] [PLAYER] (air_flag) = (false) -> Then ->
-> Add A New Script -> Variables -> Remove A Value From A dictionary -> Remove From Dictionary (player.statusattributes) key [string] (air)
6. create your turns and air turnscript:
Game -> Script (Tab) -> Turns Script (box at the bottom) -> Add ->
Turns Script (Tab) ->
name: air_and_game_turns
enable when the game begins: yes (click so that the little box has now a green check mark showing!)
Script -> Add New Script -> Scripts -> Call Function -> Call Function (air_status_attribute_setter) with parameters (none, do NOT add any parameters!)
Add New Script -> Variables -> Set Variable Or Attribute -> Set variable (game.turns) = [EXPRESSION] (game.turns = game.turns + 1)
7. now, all you have to do, is to:
whenever you want to show or hide your air status attribute, all you got to do is add this to any part of your game through~via a script:
Add A Script -> Variables -> Set Variable Or Attribute -> Set variable (player.air_flag) = [EXPRESSION] (true)
*true = this means that it will now show your air amount status attribute
~OR~
Add A Script -> Variables -> Set Variable Or Attribute -> Set variable (player.air_flag) = [EXPRESSION] (false)
*false = this means that it will now hide your air amount status attribute
-----------
to change your air amount:
to increase your air amount:
Add A Script -> Variables -> Set Variable Or Attribute -> Set variable (player.air) = [EXPRESSION] (player.air + some_number)
to decrease your air amount:
Add A Script -> Variables -> Set Variable Or Attribute -> Set variable (player.air) = [EXPRESSION] (player.air + some_number)
------------
and here's a demo "game", for you to take a look at:
(this is what my demo game looks like in Code View mode)
<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<statusattributes type="stringdictionary">turns = </statusattributes>
<turns type="int">0</turns>
<pov type="object">player</pov>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="editor_player" />
<air type="int">0</air>
<air_flag type="boolean">false</air_flag>
</object>
<object name="computer_terminal">
<inherit name="editor_object" />
<look>It has many buttons, but a big lever in particular stands out. Above the lever, reads: Push to show your air amount and Pull to hide your air amount.</look>
<push type="script">
player.air_flag = true
msg ("You can now see your air amount!")
</push>
<pull type="script">
player.air_flag = false
msg ("Your air amount is now hidden!")
</pull>
</object>
</object>
<turnscript name="air_and_game_turns">
<enabled />
<script>
air_status_attribute_setter
game.turns = game.turns + 1
</script>
</turnscript>
<function name="air_status_attribute_setter">
if (player.air_flag = true) {
dictionary add (player.statusattributes, "air", !)
}
else if (player.air_flag = false) {
dictionary remove (player.statusattributes, "air")
}
</function>
</asl>
1. click on the select all above, and then copy my code.
2. create and start up a new game.
3. click on the notepaper like button on the top, between the play and ? (help) buttons, to switch over to the Code View mode (this notepaper like button is a toggle button to switch back and forth between the GUI and Code View modes).
4. select all of the game code, and delete it.
5. now paste in my code.
6. save your game file.
7. now try and play it, see what you think, hehe
sonic102
27 Feb 2013, 07:46I did this simply by:
On enter room:
Add to dictionary 'player.statusattirbutes' key 'air' value 'Air:!'.
On exit room:
Remove from dictionary.
On enter room:
Add to dictionary 'player.statusattirbutes' key 'air' value 'Air:!'.
On exit room:
Remove from dictionary.
HegemonKhan
27 Feb 2013, 08:37finally figured out the trouble shooting that I needed, argh-lol, here's a working game code:
I needed a few extra coding lines in the function, "air_status_attribute_setter", to get it right, if you need me to explain how to do them on the GUI, let me know.
--------
my way allows the him~her, to simply add in, and set, the attribute boolean, air_flag, to true or false, to anywhere he~she wants to have his air status attribute to be displayed or not. Just some more coding stuff by me, to make it easier for him~her to plug in when to toggle the air display showing or hidden.
as all he~she needs to do (add, very easy via direct code work) is: player.air_flag = true/false
and, as I merely added in the turn script and applied the function to it, so that it automatically adjusts whether to show the air or not.
your way works fine too, I think we pretty much do the same thing, but just slightly differently, though still achieving the same result or effect.
-------------
err, final editing, final version, got all the "kinks" (got my strings~messages correctly displaying or not displaying at the right times, heh) worked out of it, lol:
<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<statusattributes type="stringdictionary">turns = </statusattributes>
<turns type="int">0</turns>
<pov type="object">player</pov>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="editor_player" />
<air type="int">0</air>
<air_flag type="boolean">false</air_flag>
<statusattributes type="stringdictionary"></statusattributes>
</object>
<object name="computer_terminal">
<inherit name="editor_object" />
<look>It has many buttons, but lever in particular stands out. Above the lever, reads, push to show your air amount and pull to hide your air amount.</look>
<push type="script">
player.air_flag = true
msg ("You can now see your air amount!")
</push>
<pull type="script">
player.air_flag = false
msg ("Your air amount is now hidden!")
</pull>
</object>
</object>
<turnscript name="air_and_game_turns">
<enabled />
<script>
air_status_attribute_setter
game.turns = game.turns + 1
</script>
</turnscript>
<function name="air_status_attribute_setter">
if (player.air_flag = true) {
if (not DictionaryContains (player.statusattributes, "air")) {
dictionary add (player.statusattributes, "air", "Air: !")
} else if (DictionaryContains (player.statusattributes, "air")) {
msg ("You can already see your air amount.")
}
} else if (player.air_flag = false) {
if (DictionaryContains (player.statusattributes, "air")) {
dictionary remove (player.statusattributes, "air")
}
}
</function>
</asl>
I needed a few extra coding lines in the function, "air_status_attribute_setter", to get it right, if you need me to explain how to do them on the GUI, let me know.
--------
my way allows the him~her, to simply add in, and set, the attribute boolean, air_flag, to true or false, to anywhere he~she wants to have his air status attribute to be displayed or not. Just some more coding stuff by me, to make it easier for him~her to plug in when to toggle the air display showing or hidden.
as all he~she needs to do (add, very easy via direct code work) is: player.air_flag = true/false
and, as I merely added in the turn script and applied the function to it, so that it automatically adjusts whether to show the air or not.
your way works fine too, I think we pretty much do the same thing, but just slightly differently, though still achieving the same result or effect.
-------------
err, final editing, final version, got all the "kinks" (got my strings~messages correctly displaying or not displaying at the right times, heh) worked out of it, lol:
<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<statusattributes type="stringdictionary">turns = </statusattributes>
<turns type="int">0</turns>
<pov type="object">player</pov>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="editor_player" />
<air type="int">0</air>
<air_flag type="boolean">false</air_flag>
<statusattributes type="stringdictionary"></statusattributes>
</object>
<object name="computer_terminal">
<inherit name="editor_object" />
<alias>computer terminal</alias>
<look>It has many buttons, but a big lever in particular stands out. Above the lever, reads, push to show your air amount and pull to hide your air amount.</look>
<push type="script">
player.air_flag = true
msg ("You pushed the lever.")
</push>
<pull type="script">
player.air_flag = false
msg ("You pulled the lever.")
</pull>
</object>
</object>
<turnscript name="air_and_game_turns">
<enabled />
<script>
air_status_attribute_setter
game.turns = game.turns + 1
</script>
</turnscript>
<function name="air_status_attribute_setter">
if (player.air_flag = true) {
if (not DictionaryContains (player.statusattributes, "air")) {
dictionary add (player.statusattributes, "air", "Air: !")
msg ("You can now see your air amount!")
}
} else if (player.air_flag = false) {
if (DictionaryContains (player.statusattributes, "air")) {
dictionary remove (player.statusattributes, "air")
msg ("Your air amount is now hidden!")
}
}
</function>
</asl>
luke01
28 Feb 2013, 20:09Excellent. that's great help.
I believe I've found what I needed thanks to your suggestions.
I believe I've found what I needed thanks to your suggestions.