[solved] Level Library (Pixie's)

HegemonKhan
I finally understand most of it (thanks to Jay+Silver explaining the 'text processor's command usage' and writing out the steps of the 'text processor' msg):

(this was stumping me for a long time, and getting it's syntax right~quasi-understood took a lot of trouble-shooting, not made easier due to me having errors~mistakes elsewhere in my code, thinking I had something wrong with the in-line command's syntax... when it wasn't the cause, but some stupid mistakes~errors else where in my code, ARGH!!! LOL)

foreach (att, game.pov.attlist) {
msg (att + ": {command:Dec " + att + ":<} {" + game.pov.name + "." + att + "} {command:Inc " + att + ":>}")
// HK notes // strength: {command:dec strength:<} {HK.strength} {command:inc strength:>}
// HK notes // strength: < 50 >
}


and I got everything working good in my own test game, but I've not yet coded~implemented in the 'hide command bar', nor the 'notarealturn', nor the 'done command'

Thus in my test game, my value in the 'attribute: < value >' doesn't change, as I increase~decrease the attribute's value (it's value is changing in the status attributes on~in the right pane), so...

-------

QUESTION:

I'd like to know what is enabling this (see above) to work in Pixie's Level Library? Is it the 'notarealturn' or is it the 'hide command bar' or is it due to the 'done command' or is it something else or just an unnoticed error~typo in my code... ???

Is the 'notarealturn' a boolean within the internal coding, dealing with how the engine determines turns, or is it jsut a custom attribute (and then how is it thus working ???) ???

as far as I understand, hiding the command bar, is just preventing turns due to or from the person playing the game from inputing something (which counts as a turn), or is there more to it than just this, and it does have something to do with the value updating in the 'attribute: < value >' msg script?

--------

thanks (in advance) for any help in understanding this aspect of Pixie's Level Library code!

(if you need code for Pixie's Level Library, if it can't be found, I can provide it, and also my own slightly variated code of Pixie's Level Library of my test game)

-------

HK Edit:

here's the codes (mine and Pixie's)

Pixie's Level Library:

<library>
<!--
LevelLib is a basic character creation and levelling library for Quest. See the Wiki How to guide for details.

Version 1.0
Quest version: 5.4
Written by: The Pixie
-->

<command name="IncCommand">
<pattern>Inc #text#</pattern>
<script><![CDATA[
if (TotalAttributes() < game.pov.maxpoints) {
value = GetAttribute(game.pov, text)
set (game.pov, text, value+1)
}
ChooseAttributes
]]></script>
</command>

<command name="DecCommand">
<pattern>Dec #text#</pattern>
<script><![CDATA[
value = GetAttribute(game.pov, text)
oldvalue = GetAttribute(game.pov, text+"_old")
if (value > oldvalue) {
set (game.pov, text, value-1)
}
ChooseAttributes
]]></script>
</command>

<command name="LevellingDoneCommand">
<pattern>Levelling Done</pattern>
<script>
ClearScreen
request (Show, "Command")
game.showdescriptiononenter = game.remembershowdescriptiononenter
ShowRoomDescription
game.notarealturn = true
</script>
</command>

<command name="LevellingCommand">
<pattern>level</pattern>
<script>
LevelUp
</script>
</command>


<function name="LevelUp"><![CDATA[
game.remembershowdescriptiononenter = game.showdescriptiononenter
game.showdescriptiononenter = false
request (Hide, "Command")
foreach (att, game.pov.attlist) {
if (not HasInt (game.pov, att)) {
set (game.pov, att, 0)
set (game.pov, att + "_old", GetInt (game.pov, att))
}
}
ChooseAttributes
]]></function>

<function name="ChooseAttributes"><![CDATA[
ClearScreen
msg ("Assign points to attributes (" + (game.pov.maxpoints - TotalAttributes()) + ")")
foreach (att, game.pov.attlist) {
msg (att + ": {command:Dec " + att + ":<} {" + game.pov.name + "." + att + "} {command:Inc " + att + ":>}")
// HK notes // strength: {command:dec strength:<} {hk.strength} {command:inc strength:>}
// HK notes // strength: < 50 >
}
msg ("{command:Levelling Done:Done}")
game.notarealturn = true
]]></function>

<function name="TotalAttributes" type="int">
total = 0
foreach (att, game.pov.attlist) {
total = total + GetInt (game.pov, att)
}
return (total)
</function>

<function name="PointsLeft" type="int">
return (game.pov.maxpoints - TotalAttributes())
</function>
</library>


Mine:

<asl version="550">
<include ref="English.aslx"/>
<include ref="Core.aslx"/>
<game name="Testing Game Stuff">
<gameid>b073bbfb-0e99-45d3-9786-bb395a6bc6b0</gameid>
<version>1.0</version>
<firstpublished>2015</firstpublished>
<pov type="object">player</pov>
<start type="script">
msg ("xxx")
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<inherit name="playable_character_object_type" />
</object>
</object>
<object name="potion_1">
<inherit name="editor_object" />
<alias>potion</alias>
<attr name="parent" type="object">player</attr>
<attr name="drink" type="script">
this.parent.experience_integer = this.parent.experience_integer + 100
</attr>
</object>
<object name="global_data_object">
<inherit name="editor_object" />
<attr name="primary_attribute_stringlist" type="simplestringlist">strength_integer;endurance_integer;dexterity_integer;agility_integer;speed_integer;luck_integer;piety_integer;intelligence_integer;spirituality_integer;mentality_integer;personality_integer;leadership_integer;charisma_integer;perception_integer;deception_integer;alignment_integer;creativity_integer;vitality_integer</attr>
</object>
<type name="playable_character_object_type">
<attr name="level_integer" type="int">0</attr>
<attr name="experience_integer" type="int">0</attr>
<attr name="cash_integer" type="int">0</attr>
<attr name="attribute_integer" type="int">0</attr>
<attr name="life_string" type="string">Life: 0/0</attr>
<attr name="mana_string" type="string">Mana: 0/0</attr>
<attr name="tech_string" type="string">Tech: 0/0</attr>
<attr name="current_life_integer" type="int">0</attr>
<attr name="maximum_life_integer" type="int">0</attr>
<attr name="current_mana_integer" type="int">0</attr>
<attr name="maximum_mana_integer" type="int">0</attr>
<attr name="current_tech_integer" type="int">0</attr>
<attr name="maximum_tech_integer" type="int">0</attr>
<attr name="strength_integer" type="int">0</attr>
<attr name="endurance_integer" type="int">0</attr>
<attr name="dexterity_integer" type="int">0</attr>
<attr name="agility_integer" type="int">0</attr>
<attr name="speed_integer" type="int">0</attr>
<attr name="luck_integer" type="int">0</attr>
<attr name="piety_integer" type="int">0</attr>
<attr name="intelligence_integer" type="int">0</attr>
<attr name="spirituality_integer" type="int">0</attr>
<attr name="mentality_integer" type="int">0</attr>
<attr name="personality_integer" type="int">0</attr>
<attr name="leadership_integer" type="int">0</attr>
<attr name="charisma_integer" type="int">0</attr>
<attr name="perception_integer" type="int">0</attr>
<attr name="deception_integer" type="int">0</attr>
<attr name="alignment_integer" type="int">0</attr>
<attr name="creativity_integer" type="int">0</attr>
<attr name="vitality_integer" type="int">0</attr>
<attr name="statusattributes" type="simplestringdictionary">level_integer = Level: !;experience_integer = Experience: !;attribute_integer = Attribute: !;cash_integer = Cash: !;life_string = !;mana_string = !;tech_string = !;strength_integer = Strength: !;endurance_integer = Endurance: !;dexterity_integer = Dexterity: !;agility_integer = Agility: !;vitality_integer = Vitality: !;speed_integer = Speed: !;luck_integer = Luck: !;piety_integer = Piety: !;alignment_integer = Alignment: !;intelligence_integer = Intelligence: !;spirituality_integer = Spirituality: !;mentality_integer = Mentality: !;personality_integer = Personality: !;leadership_integer = Leadership: !;charisma_integer = Charisma: !;creativity_integer = Creativity: !;perception_integer = Perception: !;deception_integer = Deception: !</attr>
<attr name="changedcurrent_life_integer" type="script">
this.life_string = "Life: " + this.current_life_integer + "/" + this.maximum_life_integer
</attr>
<attr name="changedmaximum_life_integer" type="script">
this.life_string = "Life: " + this.current_life_integer + "/" + this.maximum_life_integer
</attr>
<attr name="changedcurrent_mana_integer" type="script">
this.mana_string = "Mana: " + this.current_mana_integer + "/" + this.maximum_mana_integer
</attr>
<attr name="changedmaximum_mana_integer" type="script">
this.mana_string = "Mana: " + this.current_mana_integer + "/" + this.maximum_mana_integer
</attr>
<attr name="changedcurrent_tech_integer" type="script">
this.tech_string = "Tech: " + this.current_tech_integer + "/" + this.maximum_tech_integer
</attr>
<attr name="changedmaximum_tech_integer" type="script">
this.tech_string = "Tech: " + this.current_tech_integer + "/" + this.maximum_tech_integer
</attr>
</type>
<turnscript name="global_turnscript">
<enabled />
<script>
leveling_function (game.pov)
</script>
</turnscript>
<command name="increase_command">
<pattern>increase #text#</pattern>
<script><![CDATA[
if (game.pov.attribute_integer > 0) {
value_variable = GetInt (game.pov, text)
set (game.pov, text + "_old", value_variable)
set (game.pov, text, value_variable + 1)
game.pov.attribute_integer = game.pov.attribute_integer - 1
}
]]></script>
</command>
<command name="decrease_command">
<pattern>decrease #text#</pattern>
<script><![CDATA[
value_variable = GetInt (game.pov, text)
old_value_variable = GetInt (game.pov, text + "_old")
if (value_variable > old_value_variable) {
set (game.pov, text, value_variable - 1)
game.pov.attribute_integer = game.pov.attribute_integer + 1
}
]]></script>
</command>
<command name="leveling_command">
<pattern>leveling</pattern>
<script><![CDATA[
if (game.pov.attribute_integer > 0) {
foreach (attribute_variable, global_data_object.primary_attribute_stringlist) {
msg (attribute_variable + ": {command:decrease " + attribute_variable + ":<} {" + game.pov.name + "." + attribute_variable + "} {command:increase " + attribute_variable + ":>}")
}
} else {
msg ("You need more experience.")
}
]]></script>
</command>
<function name="leveling_function" parameters="character_parameter"><![CDATA[
if (character_parameter.experience_integer >= character_parameter.level_integer * 100 + 100) {
character_parameter.experience_integer = character_parameter.experience_integer - (character_parameter.level_integer * 100 + 100)
character_parameter.attribute_integer = character_parameter.attribute_integer + 5
character_parameter.level_integer = character_parameter.level_integer + 1
leveling_function (character_parameter)
}
]]></function>
</asl>

The Pixie
Credit where credit is due; that part of the code was by Jay.

Here is the code again:
foreach (att, game.pov.attlist) {
msg (att + ": {command:Dec " + att + ":<} {" + game.pov.name + "." + att + "} {command:Inc " + att + ":>}")
}

Let us say that att is "Strength" and game.pov.name is just "player"", and work out what is being sent to the msg function first.
  msg ("Strength: {command:Dec Strength:<} {player.Strength} {command:Inc Strength:>}")

So now it is easier to see that there are three text process commands.
{command:Dec Strength:<} This will display "<", as a hyperlink that will do the "Dec Strength" command
{player.Strength} This will display the value of player.Strength
{command:Inc Strength:>} This will display ">", as a hyperlink that will do the "Inc Strength" command

I'd like to know what is enabling this (see above) to work in Pixie's Level Library? Is it the 'notarealturn' or is it the 'hide command bar' or is it due to the 'done command' or is it something else or just an unnoticed error~typo in my code... ???


The system works on hyperlinks, so you need to stop the player typing in ATTACK ORC or whatever. Thus the command bar has to be temporarily hidden to prevent that.

The DONE command is how the player stops the levelling process. Clicking the link invokes the command, which finishes the levelling process.

Is the 'notarealturn' a boolean within the internal coding, dealing with how the engine determines turns, or is it jsut a custom attribute (and then how is it thus working ???) ???


The system tracks turns, and a turn is every time the player does something. Clicking the "<" hyperlink to lower a stat will invoke a command, "Dec Strength". But you do not really want that to count as a proper turn. The "notarealturn" attribute handles that, and is something I added for this system.

as far as I understand, hiding the command bar, is just preventing turns due to or from the person playing the game from inputing something (which counts as a turn), or is there more to it than just this, and it does have something to do with the value updating in the 'attribute: < value >' msg script?


That is right.

HegemonKhan
with my code (it's lacking the 'notarealturn' + 'done command' + 'hide command bar' ), the (example):

strength: < 0 >

doesn't update the value displayed in it when I increase it, but it does do so with the 'statusattributes', I got set up.

So, what is it that I'm missing which is what causes~enables the 'attribute: < 0 > to update to 'attribute: < 1 >' when I click on the increasing '>' button ??

--------------------------------------

my questions (2 of them, not answered as far as I am able to understand from my reading of your post):

1. I'd like to know what it is that is causing~enabling this*, and to understand how~why it does so, as right now, my code is not doing this for me (again, it is lacking the 'notarealturn' + 'done command' + 'hide command bar' ).

* So, what is it that I'm missing which is what causes~enables the 'attribute: < 0 > to update to 'attribute: < 1 >' when I click on the increasing '>' button ?? How do I get this display to update (what is causing~enabling this to work in your code and not mine, and how~why does it work, also)

HK Edit:

Pixie wrote:{command:Dec Strength:<} This will display "<", as a hyperlink that will do the "Dec Strength" command
{player.Strength} This will display the value of player.Strength
{command:Inc Strength:>} This will display ">", as a hyperlink that will do the "Inc Strength" command


okay... for some reason then, my code isn't adjusting the {game.pov.attribute} display, I'm pretty sure my syntax is the same as yours (no errors~mistakes~typos)... but maybe there is a mistake in my syntax... or it's some other reason... ??? This is my issue, which I can't figure out the cause and reason of.

-- you can play my test game code (though it is quest version 550 ~ the quest version 560 won't load the 'CefSharp.Core.dll', as in my trying to research it, it seems like I'm just missing whatever the needed files for it to work ~ I'm using an old xp OS ~ so I'd have to manually figure out the files I'm missing and find+download them as you know there's no automatic updating with the xp OS anymore ~ I will be getting a new pc soon finally ~ so no need to trouble anyone with figuring it out, as XP does need to get phased out, being ~15 years old), and see how it's not updating the 'attribute < value >', but it is updating the 'status attributes' display just fine.

2.
Pixie wrote:The system tracks turns, and a turn is every time the player does something. Clicking the "<" hyperlink to lower a stat will invoke a command, "Dec Strength". But you do not really want that to count as a proper turn. The "notarealturn" attribute handles that, and is something I added for this system.


So... how does this work, if it is just a custom boolean that you added (or is it linked to the internal coding of the turns), as wouldn't it require more coding than just merely being a boolean (if it doesn't connect to underlying code, which would be its needed extra coding for it to work) ??? how is it preventing the internal code of the turns, from counting a turn ???

----------

HK edit:

I just realized a test, I re-typed in the command, and it updated the display from 'strength: < 0 >' to 'strength: < 1 >', so I narrowed down the issue, but I still don't know (underlying) coding well enough to know what I'm missing or whatever is needed, which is what enables~causes the updating to 'strength: < 1 >', without me having to re-type in the command.

taking a guess, it's got to be something (or a combination of) from these things: 'notarealturn' + 'done command' + 'hide command bar', but I just don't understand them (and any underlying code and~or code functionality) well enough, to know which or what combination of them, is what enables~causes the updating of the display to 'strength < 1 >', which isn't happening in~with my code (without re-typing in the command). I'd like to understand it, not just identify it, as that doesn't help me with being able to craft my own code, should a different situation arises where I'd need something different from the setup of your library. If I'm just copying code, and not understanding it, then I'm not able to craft such code on my own for whatever new situation I may need such features, and~or be able to apply the code knowledge for doing other advanced~creative things~features.

------

HK edit:

... oh my gosh... I think I just found it... I just realized I didn't loop it the command... I think this is the 'mising link', in my code... laughs... let go see if this is it... !!! (so, I was completely searching in the wrong direction... laughs... argh... it had nothing to do with the 'notarealturn', nor 'done commmand' nor 'hide command', grr)

HK Edit:

yep, that was it... I just needed to loop the command... that was the 'missing link' in my code, for in why, the value in the 'attribute: < value >' wasn't updating, laughs.

okay, my main question is solved now, and I'll figure out your use of the 'notarealturn' on my own... as this isn't too important to me, at least not right now.

The Pixie
Yes, I think you got it. You need to clear the screen, then re-write the list of attributes each time one is updated. It looks like the number is modified, but in fact the whole screen is redone.

By the way, when debugging something like this, make it easy on yourself. Set attribute_integer to be 10, and set the command to trigger automatically in the start script ( do(leveling_command, "script") ).

HegemonKhan
thanks for the help, just stupid looping+clearscreen (lol) .... when I thought it was something with the underlying code functionality of turns and your use of the 'done command', 'notarealturn', and~or 'hide command'.

Ya, I should make debugging easier on myself... just lazy... so I often do things inefficiently, lol.

Silver
I had to do that clearscreen then print the same message again trick to disable hyperlinks when a command is clicked to do a jquery fadeout.

HegemonKhan
I hadn't done troubleshooting for awhile... I forgot how 'fun' (sarcasm) it is, laughs. For some reason, it's almost always something stupid of my own mistake, and not something with not understanding the coding, which is good (as it means that I'm getting the coding), but boy is it irritating, when it is asomething so simple.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums