how do i talk to shop keeper
BIG NANi
22 Aug 2019, 22:32so if shop keeper ask me do you want to answer some question, and if i say yes how do i print out the question and the answers.

Io
23 Aug 2019, 01:34There's two main ways of going about this: Get Input and Show Menu.
For something like this, I think you'll want Get Input. Get Input does exactly that; it has the player type something, and hit enter, and stores the result as a string variable called 'result'. So you can have code like this (Mind my psuedocode):
Get Input{
if result="Yes"{
print("You said yes to the shopkeeper")
}
else if result="Who are you?"{
print("You were confused by the shopkeeper)
}
etc.
}
jmnevil54
26 Aug 2019, 16:21Show Menu is the best for picking out pre-made options.
Start out with this.
options = Split("item 1; item 2", ";" )
Show Menu ("Shop", options, true) {
switch (result) {
case ("item 1" )
if (player.gold > 10) {
player.gold = player.gold - 10
msg ("You bought item 1.")
}
else {
msg ("You don't have enough gold." )
}
}
case ("item 2")
if (player.gold > 100) {
player.gold = player.gold -100
msg ("You bought item 2.")
}
else {
msg ("You don't have enough gold. ")
}
}
}
}
End up with this.
msg ("See something that catches your eye?")
options = Split("Potion (100);Hyper Potion (200);Pistol Fish (360);Ammo (40)", ";")
ShowMenu ("Shop", options, true) {
switch (result) {
case ("Potion (100)") {
if (player.gold >= 100) {
player.gold = player.gold - 100
player.potion = player.potion + 1
msg ("You bought a Potion.")
}
else {
msg ("You don't have enough gold.")
}
}
case ("Hyper Potion (200)") {
if (player.gold >= 200) {
player.gold = player.gold - 200
player.hyper_potion = player.hyper_potion + 1
msg ("You bought a Hyper Potion.")
}
else {
msg ("You don't have enough gold.")
}
}
case ("Pistol Fish (360)") {
if (player.gold >= 360) {
player.gold = player.gold - 360
AddToInventory (pistol)
}
else {
msg ("Either you don't have enough gold, or you already have it.")
}
}
case ("Ammo (40)") {
if (player.gold >= 40) {
player.gold = player.gold - 40
player.ammo = player.ammo + 20
}
else {
msg ("You don't have enough gold.")
}
}
}
}