Need help with script specifics
Lighnagain
23 Aug 2016, 00:52Let me begin by saying I am not a coder. There is a lot of probably basic conclusions that I'm struggling with -- but that's why I am having fun learning!
I am trying to make a 3 tier decision based point system. I used the example "Good, Evil, and Neutral" before, but I don't want a basic "Morality" counter, I want to be able to see how many of each decision was made. So right now I have created the attributes, but how can I make an action increase the counter for said attribute? I would also like to make a verb react differently based on the level of said attribute. ALA,
"Enter the church"
Good > 10 = you enter the church
Good < 10 = you start through the doors, but recoil in pain on the threshold and retreat.
Help! I've been working primarily in the quest editor, not actually writing scripts of code unless I am copy/pasting from something I've already worked out, so instructions on which tabs to use to create said circumstances would be most helpful!!
~L
XanMag
23 Aug 2016, 02:50I THINK...
- You should add an integer attribute to the player and call it 'MoralityCount'. Set it to 0
- Add a 'changedMoralityCount' attribute.
- For the changed script, add an 'If' attribute equal to or > 9, then set flag neutral.
- Add an 'Else If' script here and add 'Else If' attribute equal to < 10, then set flag good.
- Add an 'Else If' script here and add 'Else If' attribute equal to > 0, then set flag evil.
- Be sure to add to those scripts the unset flag options for each of the other two - i.e. if set good, unset neutral and evil.
Now you can check the morality setting with If scripts for any action that you want.
I'm not sure EXACTLY how to do it, but this makes sense to me and is what I would try. Of course, I'm Quest's greatest hack job GUI user on the planet, so... take it for what it is worth!
Lighnagain
23 Aug 2016, 06:16XanMag,
Problem being I am using the morality as an example, this isn't precisely what I am trying to do--and what I am trying to do isn't a sliding scale of three things on the same category plane, they're three different categories that can gain points based on decisions that are made independently. ALA, there are 3 ways to solve every problem, and based on how you decide to solve it, you get a point in that category.
The Pixie
23 Aug 2016, 06:58For morality, I would have two counters, "GoodCounter" and "Evilcounter", with neutral being both low. If you have played Mass Effect it uses a similar system. Entering the church could then depend on "Evilcounter" being low, but going into the inner sanctum requires "GoodCounter" to be high, say.
Sounds like you may need three counters in your system.
hegemonkhan
23 Aug 2016, 08:44this is a bit code heavy, but maybe you can still understand and follow it:
http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk (specifically scroll down a bit to the 'two super scripts' sections: 'attributes / attribute usage' section and the 'if script / if script usage' section, but you may want to read the content above it, as it gives a generally understanding of coding, quest, and quest's coding)
conceptually:
event/action (scripting/scripts such as via a Verb and its buttons/hyperlinks during game play) that happens and/or a choice made within the event/action: whatever combination of moralities you want available/resultant from what event/action/choice you make. for example:
where do you go to?
1. forest: +1 'good' morality/alignment // you can also be more complex, for example: +1 "good" morality/alignment and -1 "evil" morality/alignment, and it doesn't have to be '1' nor '+ (addition)', you can do: multiply ( * ) by 7
2. town: +1 'neutral' morality/alignment
3. mountains: +1 'evil' morlaity/alignment
'whatever' Element (Verb / Object's Script Attribute, Command, Function, Turnscript, etc) -> run as sript -> add new script -> 'variables' section/category -> 'set a variable or attribute' Script -> [EXPRESSION] -> (see below)
// doing a simple Expression (OPERATOR VALUE, for example: + 1, * 7, - 3, / 2, % 10 --- % is known as 'modulus' operation, which is just division, except you find/get the REMAINDER, not the normal getting/finding of the quotient - this has some very cool uses. Programming has to separate division into two operations, one operation '/' finds/gets the quotient and another '%' finds/gets the remainder):
// keeping these as a simple 'OPERATOR VALUE' usage examples:
in GUI~Editor: set variable OBJECT_NAME.ATTRIBUTE_NAME = [EXPRESSION] OBJECT_NAME.ATTRIBUTE_NAME OPERATOR VALUE
in Code: OBJECT_NAME.ATTRIBUTE_NAME = OBJECT_NAME.ATTRIBUTE_NAME OPERATOR VALUE
replace my 'OBJECT_NAME' with the name of your desired Object (which is containing the desired Attribute)
replace my 'ATTRIBUTE_NAME' with the name of your desired Attribute (which is contained/added-to/created-within your desired Object)
replace my 'OPERATOR' with the desired operator's symbol (+, -, *, /, &)
replace my 'VALUE' with some amount (some number)
so, some examples (in code):
OBJECT_NAME: player
ATTRIBUTE_NAME: good_alignment
OPERATOR: +
Value: 1
player.good_alignment = player.good_alignment + 1
OBJECT_NAME: player
ATTRIBUTE_NAME: good_alignment
OPERATOR: +
Value: 5
player.good_alignment = player.good_alignment + 5
OBJECT_NAME: player
ATTRIBUTE_NAME: evil_alignment
OPERATOR: +
Value: 1
player.evil_alignment = player.evil_alignment + 1
OBJECT_NAME: player
ATTRIBUTE_NAME: evil --- if you don't like my system of labeling/naming using underscores and being more descriptive, lol
OPERATOR: +
Value: 1
player.evil = player.evil + 1
etc etc etc... hopefully you get the idea...
----------------------
conceptually of how it works, using addition as example:
initial value: player.strength = 0
old value: player.strength = 0
player.strength = player.strength + 3
player.strength (new) = player.strength (old: 0) + 3
player.strength (new) = (0) + 3 = 3
new value: player.strength = 3
old value: player.strength = 3
player.strength = player.strength + 3
player.strength (new) = player.strength (old: 3) + 3
player.strength (new) = (3) + 3 = 6
new value: player.strength = 6
old value: player.strength = 6
player.strength = player.strength + 3
player.strength (new) = player.strength (old: 6) + 3
player.strength (new) = (6) + 3 = 9
new value: player.strength = 9
etc etc etc... hopefully you get how it works now.
-----------------
in code, syntax for simple examples:
Addition:
OBJECT_NAME.ATTRIBUTE_NAME = OBJECT_NAME.ATTRIBUTE_NAME + Value
Subtraction:
OBJECT_NAME.ATTRIBUTE_NAME = OBJECT_NAME.ATTRIBUTE_NAME - Value
Multiplication:
OBJECT_NAME.ATTRIBUTE_NAME = OBJECT_NAME.ATTRIBUTE_NAME * Value
Division (Division: quotient):
OBJECT_NAME.ATTRIBUTE_NAME = OBJECT_NAME.ATTRIBUTE_NAME / Value
Modulus (Division: remainder):
OBJECT_NAME.ATTRIBUTE_NAME = OBJECT_NAME.ATTRIBUTE_NAME % Value
--------------------
a quick simple 'if' Script usage + Attribute usage example (in code):
(using the special 'changed' Script Attribute using a Function for my example)
<object name="room">
</object>
<object name="player">
<attr name="parent" type="object">room</attr>
<attr name="changedstrength_integer" type="script">
example_function
</attr>
</object>
<function name="example_function">
if (player.strength_integer > 100) {
player.strength_integer = 100
} else if (player.strength_integer < 0) {
player.strength_integer = 0
}
if (player.strength_integer = 100) {
player.strength_string = "MAX"
} else if (player.strength_integer >= 67) {
player.strength_string = "strong"
} else if (player.strength_integer >= 34) {
player.strength_string = "average"
} else if (player.strength_integer > 0) {
player.strength_string = "weak"
} else { // conceptually/logically/effectively: if (player.strength_integer = 0) {
player.strength_string = "You are a puny wimp!"
}
</function>
read my link's contents, to see how to use the 'if' Script with Attributes, for the other half of this great comprehension, which let's you do 90% of everything that you want to do in your game.
Lighnagain
24 Aug 2016, 03:01I am working through this, and it is starting to make sense--I absolutely get how to make an action script add onto a player value... still not clear on where/how to set up the player value...
hegemonkhan
24 Aug 2016, 23:09for creating/adding an Attribute (and setting its initial Value) that is already created before the game begins, an example:
GUI~Editor:
'player' Player Object -> 'Attributes' Tab -> Attributes -> Add -> (see below example, repeat as needed)
(Object Name: player)
Attribute Name: good_alignment
Attribute Type: int // (integer)
Attribute Value: 0
(Object Name: player)
Attribute Name: neutral_alignment
Attribute Type: int // (integer)
Attribute Value: 0
(Object Name: player)
Attribute Name: evil_alignment
Attribute Type: int // (integer)
Attribute Value: 0
which produces this in code:
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="example">
<attr name="gameid" type="string">some randomly generated sequence of characters/symbols</attr>
<attr name="version" type="string">1.0</attr>
<attr name="firstpublished" type="string">2016</attr>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<attr name="good_alignment" type="int">0</attr>
<attr name="neutral_alignment" type="int">0</attr>
<attr name="evil_alignment" type="int">0</attr>
</object>
</object>
</asl>
if you want to add/create/set/re-set/change/alter/adjust/etc your Attributes and/or their Values, during game play, you use scripting, for an example (using a 'talk' Verb added to the 'npc1' Object, for the scripting):
<object name="data_object">
</object>
<object name="npc1">
<attr name="talk" type="script">
firsttime {
msg ("Save the princess from the evil dragon!")
data_object.is_princess_saved_from_dragon_quest_completed = false // this scripting creates/adds the 'is_princess_saved_from_dragon_quest_completed' Boolean Attribute to the 'data_object' Object
} otherwise {
if (data_object.is_princess_saved_from_dragon_quest_completed) { // if (data_object.is_princess_saved_from_dragon_quest_completed = true) {
player.good_alignment = player.good_alignment + 5 // you get +5 good alignment for doing this quest; we're altering/setting/re-setting your 'good_alignment' Integer Attribute's Value, by doing addition (of: +5) upon/with it.
data_object.is_princess_saved_from_dragon_quest_completed = true // we need to make the quest be completed, so you can't keep getting +5 good alignment, lol.
msg ("Thank you for saving the princess, you're making a good reputation for yourself, as a champion for good!")
} else {
msg ("The princess still needs rescuing... who knows how long she'll last in the dragon's lair... before it gets hungry and eats her up!")
}
}
</attr>
</object>
<verb>
<property>talk</property>
<pattern>talk</pattern>
<defaultexpression>You can't talk to that!</defaultexpression>
</verb>
lastly, if you want to display your morality/alignment Attributes in the pane on the right side for the person playing the game:
in the GUI~Editor:
'player' Player Object -> 'Attributes' Tab -> Status Attributes -> Add -> (see below, repeat as needs)
(Object Name: player)
Status Attribute Name: good_alignment
Status Attribute Value (field...something...): Good Alignment: !
(Object Name: player)
Status Attribute Name: neutral_alignment
Status Attribute Value (field...something...): Neutral Alignment: !
(Object Name: player)
Status Attribute Name: evil_alignment
Status Attribute Value (field...something...): Evil Alignment: !
// the '!' will be replaced (automatically by quest) with that Attribute's Value, so it's like this:
(status attribute name: what attribute do you want displayed? : good_alignment)
(status attribute value/field-something: display the string: "Good Alignment: ") + (display the Value: ! --- which will be replaced by quest with: 0)
which will (initially) display:
Good Alignment: 0
Neutral Alignment: 0
Evil Alignment: 0
hegemonkhan
24 Aug 2016, 23:13here's a step by step guide to creating a quick demo game that you can study and play, seeing it in action in what it does:
http://textadventures.co.uk/forum/quest/topic/5387/i-really-need-help#37375
let me know if you are having trouble with following/doing any part of it!