Making the player do things.

Espera
19 May 2014, 21:16
I'm hoping it's possible in scripts to enter in strings that would be interpreted much like commands from the player? For instance, I could make them 'look' so that they would notice changes in the room more easily, or maybe I could make them use objects in their invnetory involuntarily? How do I go about this?

Keep in mind, I'm less of a code monkey, and more of a UI user.

HegemonKhan
20 May 2014, 00:05
you can do like 90% of any~all things with just these two super scripts:

1. in GUI~Editor: 'if' Script: run as script -> add a script -> scripts -> 'if' Script -> [EXPRESSION], or whatever [______] choice

2. in GUI~Editor: 'setting attributes' Script: run as script -> add a script -> variables -> set a variable or attribute -> Attribute: Object.Attribute = Expression_or_Value, or Variable: Attribute = Expression_or_Value

in code:

1.
if (_______) {
}

2.
Object.Attribute = Expression_or_Value

-------

examples:

(if you only got a single Player Object, than 'game.pov' is the same as, for example, your default 'player' Player Object, you can use either 'game.pov' or 'player', if you like using 'player' than use that, or if you like using 'game.pov' as I do below, then use that. But, there's nuances~differences when you got more than one Player Object, with using 'game.pov' vs a specific Player Object directly)

if (game.pov.alias = "HK") {
-> game.pov.strength_integer = 100
} else if (game.pov.alias = "espera") {
-> game.pov.intelligence_integer = 100
}

if (game.pov.hit_points_integer <= 0) {
-> msg ("You died.")
-> msg ("GAME OVER")
-> finish
}

if (orc.dead_boolean = false) {
-> orc.dead = true
-> msg ("you attack the orc, killing it")
} else if (orc.dead = true) {
-> game.pov.cash = game.pov.cash + orc.cash
-> orc.cash = 0
-> msg ("You loot the dead orc's body, finding and taking it's cash")
}

if (espera.tiredness >= 50 and espera.tiredness <= 100) {
-> msg ("She's really tired, her eyes are bloodshot, her hair is a disheavaled mess, and she can barely think straight, moving slugglishly out of bed.")
} else if (espera.tiredness >= 0 and espera.tiredness < 50) {
-> msg ("She got a good night's rest, and is ready to take on the day, her spirit's high and her energy overflowing, she bounds out of bed excitedly.")
}

----------

I have a feeling that this isn't what you're asking about... hmm... lol

if you mean, allowing your scripts to act upon something that the user types in during game play, then there's the 'get input' (in GUI~editor: run as script -> add a script -> output -> get input):

game (Object) -> scripts (tab) -> Start Script -> Add a script ->

msg ("What is your name?")
get input {
-> game.pov.alias = result
-> show menu ("What is your gender?", split ("male;female", ";"), false) {
->-> game.pov.gender_string = result
->-> show menu ("What is your race?", split ("human;dwarf;elf", ";"), false) {
->->-> game.pov.race_string = result
->->-> show menu ("What is your class?", split ("warrior;thief;cleric;mage", ";"), false) {
->->->-> game.pov.class_string = result
->->->-> msg (game.pov.alias + " is a " + game.pov.gender_string + " " + game.pov.race_string + " " + game.pov.class_string + ".")
->->-> }
->-> }
-> }
}
// if I chose: HK, male, human, warrior; the output is: HK is a male human warrior.
// if I chose: Espera, female, elf, mage; the output is: Espera is a female elf mage.

and further (in another script, such as a 'level_up_or_leveling' Script)...

if (game.pov.gender_string = "male") {
-> game.pov.strength_integer = game.pov.strength_integer + 1
} else if (game.pov.gender_string = "female") {
-> game.pov.intelligence_integer = game.pov.intelligence_integer + 1
}
if (game.pov.race_string = "human") {
-> game.pov.strength_integer = game.pov.strength_integer + 1
-> game.pov.intelligence_integer = game.pov.intelligence_integer + 1
} else if (game.pov.race_string = "dwarf") {
-> game.pov.strength_integer = game.pov.strength_integer + 2
} else if (game.pov.race_string = "elf") {
-> game.pov.intelligence_integer = game.pov.intelligence_integer + 2
}
if (game.pov.class_string = "warrior") {
// etc

jaynabonne
20 May 2014, 00:56
Espera, the function "HandleCommand" is what you're looking for. It's what's called whenever you enter a command at the input line. You can just call it yourself from your scripts.

To add it from the GUI, add a "Call Function" script command. Set the function name to HandleCommand. You then need to add two args.

The first argument is the command you want to execute. It will be a string, so you need to put it in quotes (e.g. "take apple").
The second argument to add is just null.

In Code View, it would look like:

HandleCommand("take apple", null)

It does everything that happens when you input a command, including echoing it to the screen like "> take apple".

Hope that helps!

HegemonKhan
20 May 2014, 01:00
oh wow, that's really cool (useful), thanks Jay and espera for asking the question ~ making the thread, hehe. I just learned something new, and it's something really useful too, awesome!

Espera
20 May 2014, 04:39
Yes, thank you very much, Jay, and glad you could learn along with me, HK.