Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 I'm Making A Text Based RPG And I Seem To Be Stumped
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ProxyKaliber




PostPosted: Thu Jun 08, 2017 9:11 am   Post subject: I'm Making A Text Based RPG And I Seem To Be Stumped

What is it you are trying to achieve?

I am trying to get these functions working so that way I can make the combat system work more efficiently and when the story progresses I can just call upon the functions to make it easier to start the combat part.

What is the problem you are having?

I'm getting some errors that I'm not too sure about. It says that a "." is expected when I try to give a range for a Rand.Int or that I can only reference "Int" (when I try to use Rand.Int) in a post statement and I've never heard of Post statements...


Describe what you have tried to solve this problem

I have tried to move some functions around because maybe it's the order they'r in. I have a hunch that it could be my variables and the input that the function takes to make the output unless I'm missing something which I think I am... maybe it's right there (is it "result [something here]"?).


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

Turing:

% var character_class_num : string % (To ask for either "1", "2", or "3" as a simpler way for the user to select their class)
var character_name, name_of_character : string
var health_points, mana_points, gold_amount, defense_stat, attack_stat : int
var character_class, class_of_character : string
var health_new, mana_new, gold_new, defense_new, attack_new : int
var opp_health_points, opp_defense_stat, opp_attack_stat : int
var opp_health_new, opp_defense_new, opp_attack_new : int
var RNG_stat_select : int
var battle_start : boolean
var user_input : string

function generate_opp_stats (Rand.Int : int)
    if (battle_start = true) then
        opp_health_points := Rand.Int (85 .. 150)
        opp_defense_stat := Rand.Int (45 .. 65)
        opp_attack_stat := Rand.Int (30 .. 50)
    end if
end generate_opp_stats

function attack_option_1 (attack_stat : int)
    if (user_input = "Attack - Basic") then
        attack_new := attack_stat * 1
        opp_health_new := opp_health_points - ((attack_new / opp_health_points) * 100)
    end if
end attack_option_1

function attack_option_2 (attack_stat : int)
    if (user_input = "Attack - Heavy") then
        attack_new := attack_stat * 2
        opp_health_new := opp_health_points - ((attack_new / opp_health_points) * 100)
    end if
end attack_option_2

function heal_25_HP (health_points : int)
    if (user_input = "Item - Heal" and health_points < health_points - 25) then
        health_new := health_points + 25
    else
        put "Health is too full!"
    end if
end heal_25_HP

function debuff_opponent (user_input : int)
        RNG_stat_select : Rand.Int (1 .. 3)
    if (user_input = "Item - Debuff") then
        if (RNG_stat_select = 1) then
            opp_health_new := opp_health_points - 25
        elsif (RNG_stat_select = 2) then
            opp_attack_new := opp_attack_stat - 5
        elsif (RNG_stat_select = 3) then
            opp_defense_new := opp_defense_stat - 5)
        else
            put "***** ERROR *****"
        end if
    end if
end debuff_opponent

function defend_2_rounds (defense_stat : int)
    if (user_input = "Defend") then
        defense_new := defense_stat * 2
    end if
end defend_2_rounds

function battle_end (health_new : int)
    loop
        combat_input (user_input : string)
        exit when (health_new = 0 or opp_health_new = 0 or user_input = "Flee")
    end loop
end battle_end

function flee_in_shame (user_input : string)
    if (user_input = "Flee") then
        battle_end
    end if
end flee_in_shame

function combat_input (user_input : string)
    if (userInput = "Attack - Basic") then
        attack_option_1 (user_input)
    elsif (user_input = "Attack - Heavy") then
        attack_option_2 (user_input)
    elsif (user_input = "Item - Heal") then
        heal_25_HP (user_input)
    elsif (user_input = "Item - Debuff") then
        debuff_opponent (user_input)
    elsif (user_input = "Defend") then
        defend_2_rounds (user_input)
    elsif (user_input = "Flee") then
        flee_in_shame (user_input)
    else
        put "***** ERROR *****"
    end if
end combat_input


Please specify what version of Turing you are using

Turing 4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Thu Jun 08, 2017 10:17 am   Post subject: RE:I\'m Making A Text Based RPG And I Seem To Be Stumped

Rand.Int uses a comma, not periods.

Rand.Int (85, 150)

I can't test it right now but I have a feeling that fixing this might solve both of your error messages.
ProxyKaliber




PostPosted: Fri Jun 09, 2017 9:36 am   Post subject: Re: I'm Making A Text Based RPG And I Seem To Be Stumped

Thanks. I'm going to try that right now haha. I get tiny things like that confused.
ProxyKaliber




PostPosted: Mon Jun 12, 2017 8:17 am   Post subject: Re: I'm Making A Text Based RPG And I Seem To Be Stumped

Unfortunately that solved very little of the many errors I've been getting. I also logged on today for the second time to find that all of my progression has been deleted, either by computer error or my own it is too soon to assume because assuming makes an ass out ouf u and me. Anyways. I've got a lot to catch up with.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: