Hey all! I’m new to php and just ran into an issue.
Anyone know what could be going on here?
I’ve made a dialogue system, but the text I’ve echoed first never leaves the screen. The response text seems to update appropriately. I wrote a bit of code earlier and tested, the variable seem to be updating appropriately. Just to make it clear, I only want the intro text to appear until a button is pressed, then display the response text instead. Thanks for any help you might be able to give me!
[php]<?php
// set variables
$strength=25;
$constitution=25;
$dexterity=25;
$intelligence=25;
$willpower=25;
$charisma=25;
$speed=25;
//action info: 0 showstats 1 story
$action=1;
$dialogue=1;
$branch=0;
if ($action =0)
{
//show stats
print “
<font color=“red”>Your stats are as follows:
Strength: $strength
Constitution: $constitution
Dexterity: $dexterity
Intelligence: $intelligence
Willpower: $willpower
Charisma: $charisma
Speed: $speed
}
if ($action=1)
{
if ($dialogue=1)
{
print "We begin your story here, in the snowy hills of Alteberron, in the city of
Winter’s Hold. While on your way from the desert city of Shahazad, your caravan was
attacked by marauders, the caravan guard slaughtered before your eyes. You were forced to
watch as all of your goods you had worked so hard to acquire were ripped from you and taken
to god knows where. Beaten and malnourished, you were taken as a slave to be
ransomed to your family for a high price. One morning you awaken to hear fighting, the
clash of steel on steel. Jumping to your feet, you run to your cage door, screams and the
smell of smoke taking hold of your senses. A moment later, a man stands at your cell, his
armor glinting in the campfire light.
“Well, well, well… What have we here?”";
print"
Your response:
Plead for help
Scared\aggressive response ";
if(isset($_POST[‘1’])) {$dialogue=2; $branch=1; }
if(isset($_POST[‘2’])) {$dialogue=2; $branch=2; }
if(isset($_POST[‘3’])) {$dialogue=2; $branch=3; }
}
if (($dialogue==2) && ($branch==1))
{
print “You reply sarcastically, “Oh, look. If it isn’t my knight in shining armor.””;
}
if (($dialogue==2) && ($branch==2))
{
print “Gripping the bars, you stare at him earnestly.
“Look, I need your help. Let me out, they might be back at any moment!”
; Your voice comes out as a whispered hiss, afraid someone might overhear you.”;
}
if (($dialogue==2) && ($branch==3))
{
print "You lunge forward, grabbing him by the collar. "Ha! You’re mine! I swore I’d make
you scumsuckers pay if you ever touched me again!" He chokes for a moment before swatting
your hands away, sputtering. “I’m not one of them, you imbecile!” His eyes are wide as he
tries to catch his breath.";
}
}
?>[/php]