|
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
Master K Ex-Akatsuki Masked Ninja
Joined: 11 Jun 2011 Posts: 57 Location: Everywhere and Nowhere. Muahaha!
|
Posted: Thu Jul 14, 2011 8:47 pm Post subject: Variableized Classes? |
|
|
Alright, so, my new game project, Into The Mainframe, will have a class system. No, Grayscale is not dead, its just stifled until some problems get resolved.
Anyways, theres ${V}, which inserts a global plotscript variable. How would I make it so that a certain name can be displayed with that. Say, the hero selects Tech Warrior. ${V1} would be Tech Warrior in chat boxes. How will I do that? |
|
Back to top |
|
|
Rimudora Psychopath yandere Halloween 2006 Creativity Winner
Joined: 26 May 2005 Posts: 335
|
Posted: Fri Jul 15, 2011 4:06 am Post subject: |
|
|
You should use ${S1}, which inserts a string instead. Then you could just do something like this:
Code: | $1="Tech Warrior"
show text box |
|
|
Back to top |
|
|
Master K Ex-Akatsuki Masked Ninja
Joined: 11 Jun 2011 Posts: 57 Location: Everywhere and Nowhere. Muahaha!
|
Posted: Fri Jul 15, 2011 10:19 am Post subject: |
|
|
Yes, but I want to be able to have one variable, Class Name, to change. You see, there is going to be a class selection in this game. I want it so the variable changes depending on class selected, so I don't have to make three textbox copies every time I want an NPC to refer to the heroes class. |
|
Back to top |
|
|
Bob the Hamster OHRRPGCE Developer
Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Fri Jul 15, 2011 10:40 am Post subject: |
|
|
Master K wrote: | Yes, but I want to be able to have one variable, Class Name, to change. You see, there is going to be a class selection in this game. I want it so the variable changes depending on class selected, so I don't have to make three textbox copies every time I want an NPC to refer to the heroes class. |
That is exactly what Rimudora is suggesting. Put your class name in the plotstring number 1, then you only need one text box, where ${S1} will be replaced by your class name. |
|
Back to top |
|
|
Master K Ex-Akatsuki Masked Ninja
Joined: 11 Jun 2011 Posts: 57 Location: Everywhere and Nowhere. Muahaha!
|
Posted: Fri Jul 15, 2011 11:05 am Post subject: |
|
|
Ok, but how would it work for three classes, Tech Mage, Tech Warrior and Tech Rouge? |
|
Back to top |
|
|
mswguest Guest
|
Posted: Fri Jul 15, 2011 11:08 am Post subject: |
|
|
To expand on what the others are saying, you will need a logic branch:
[pseudocode]
if ( player chose class "Engineer" ), then
( $1:= "Engineer" )
if ( player chose class "Theoretical Physicist" ), then
( $1:= "Theoretical Physicist" )
if ...
[/pseudocode]
This script should run when the player chooses their class (not when you need the text), and then plotstring $1 should not be touched at any other time, so it remembers what class the player chose. It's helpful to document this somewhere; I have a text file where I keep the uses of all of my strings and global variables so I don't forget. |
|
Back to top |
|
|
Master K Ex-Akatsuki Masked Ninja
Joined: 11 Jun 2011 Posts: 57 Location: Everywhere and Nowhere. Muahaha!
|
Posted: Fri Jul 15, 2011 11:13 am Post subject: |
|
|
Ah. I have three tags that will be set on depending on the class, so I can use those for your idea as check tags. I would run the script on the final textbox of the class selection.
Code: | plotscript, what class am I, begin
if (check tag(tag(4, ON)) then
( $1:= Tech Warrior)
if (check tag(tag(5, ON)) then
( $1:= Tech Mage)
if (check tag(tag(6, ON)) then
( $1:= Tech Rouge)
end |
|
|
Back to top |
|
|
mswguest Guest
|
Posted: Fri Jul 15, 2011 11:16 am Post subject: |
|
|
Oh, that should work too. Excellent. |
|
Back to top |
|
|
Master K Ex-Akatsuki Masked Ninja
Joined: 11 Jun 2011 Posts: 57 Location: Everywhere and Nowhere. Muahaha!
|
Posted: Fri Jul 15, 2011 1:29 pm Post subject: |
|
|
Oh great, now my scripts won't compile. Heres the problem.
Code: | plotscript, New Game, begin
suspend player
fade screen out
set hero direction(me,up)
wait(55)
fade screen in
show text box(2)
wait for text box
set hero frame(1)
wait(1)
set hero frame(0)
wait(1)
set hero frame(1)
wait(1)
set hero frame(0)
wait(1)
set hero frame(0)
wait(1)
set hero frame(1)
wait(1)
set hero frame(0)
wait(1)
play sound(1, false)
set tag(tag(2, ON)
walk hero(me,down,1)
set hero direction(me,up)
wait for hero(me)
wait(25)
walk hero(me,up,1)
wait for hero(me)
show text box(5)
wait for text box
walk hero(me,down,1)
wait for hero(me)
show text box(7)
wait for text box
walk hero(me,left,1)
wait for hero(me)
walk hero(me,right,1)
wait for hero(me)
show text box(8)
wait for text box
walk hero(me,right,1)
wait for hero(me)
walk hero(me,left,1)
wait for hero(me)
show text box(8)
wait for text box
walk hero(me,left,1)
wait for hero(me)
walk hero(me,right,1)
wait for hero(me)
show text box(8)
wait for text box
set hero direction(me,up)
show text box(9)
wait for text box
walk hero(me,up,1)
wait for hero(me)
show text box(12)
wait for text box
fade screen out
wait(92)
fade screen in
wait(1)
show text box(13)
wait for text box
character creation
end
#---------------------
plotscript, character creation, begin
use door(0)
wait(35)
show text box(15)
wait for text box
use door(1)
end
#---------------------
plotscript, what class am I, begin
if (check tag(tag(4, ON)) then
( $1:= Tech Warrior)
if (check tag(tag(5, ON)) then
( $1:= Tech Mage)
if (check tag(tag(6, ON)) then
( $1:= Tech Rouge)
end |
Heres all my scripts, just incase you needed to see them all. Its rejecting the plotscript declaration in Character Creation. It says perhaps New Game has an extra begin or ). |
|
Back to top |
|
|
Bob the Hamster OHRRPGCE Developer
Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Fri Jul 15, 2011 1:43 pm Post subject: |
|
|
Can you copy and paste the exact error message?
EDIT: actually, I think the problem is this script:
Code: |
plotscript, what class am I, begin
if (check tag(tag(4, ON)) then
( $1:= Tech Warrior)
if (check tag(tag(5, ON)) then
( $1:= Tech Mage)
if (check tag(tag(6, ON)) then
( $1:= Tech Rouge)
end
|
Should be:
Code: |
plotscript, what class am I, begin
if (check tag(4, ON))) then
( $1:= Tech Warrior)
if (check tag(5, ON))) then
( $1:= Tech Mage)
if (check tag(6, ON))) then
( $1:= Tech Rouge)
end
|
|
|
Back to top |
|
|
Master K Ex-Akatsuki Masked Ninja
Joined: 11 Jun 2011 Posts: 57 Location: Everywhere and Nowhere. Muahaha!
|
Posted: Fri Jul 15, 2011 2:05 pm Post subject: |
|
|
Code: | plotscript, what class am I, begin
if (check tag(4, ON)
( $1="Tech Warrior")
)
if (check tag(5, ON)
( $1="Tech Mage")
)
if (check tag(6, ON)
( $1="Tech Rouge")
)
end |
I had to really chop at this one for the fickle compiler. One error I cannot solve that regards Tech Warrior line:
if statement has 2 conditions. It should only have one. Use and and or for complex conditions. |
|
Back to top |
|
|
Bob the Hamster OHRRPGCE Developer
Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Fri Jul 15, 2011 2:13 pm Post subject: |
|
|
You are probably being confused by the unfortunate flexibility of hamsterspeak's syntax.
Here are two valid ways to write it
Code: |
if (condition) then(
actions
)
|
Code: |
if (condition) then, begin
actions
end
|
remember that "begin" always means the same thing as ( and "end" always means the same thing as )
For my own scripts, I normally ONLY use begin/end for the entire script, and I use ( and ) absolutely everywhere else. Less confusing that way.
Quote: | if statement has 2 conditions. It should only have one. Use and and or for complex conditions. |
This error message is because you deleted the "then" |
|
Back to top |
|
|
Master K Ex-Akatsuki Masked Ninja
Joined: 11 Jun 2011 Posts: 57 Location: Everywhere and Nowhere. Muahaha!
|
Posted: Fri Jul 15, 2011 2:26 pm Post subject: |
|
|
Another error.
Code: | plotscript, what class am I, begin
if (check tag(4, ON) then(
$1="Tech Warrior"
)
if (check tag(5, ON) then(
$1="Tech Mage"
)
if (check tag(6, ON) then(
$1="Tech Rouge"
end |
Apparently im mising an end. |
|
Back to top |
|
|
mswguest Guest
|
Posted: Fri Jul 15, 2011 2:50 pm Post subject: |
|
|
Very simple:
Code: | if (check tag(4, ON) ) then(
|
Notice the extra ending parenthesis after "ON" in the check tag statement.
See, in general you need:
if ( condition ) then(
If your condition includes parentheses, they must open and close on their own, IN ADDITION TO the parentheses demanded by the if statement.
For your case, your 'condition' was:
check tag (4, ON)
This needs to put in place of the word "condition" in the general if statement, so:
if ( check tag (4, ON) ) then( |
|
Back to top |
|
|
Master K Ex-Akatsuki Masked Ninja
Joined: 11 Jun 2011 Posts: 57 Location: Everywhere and Nowhere. Muahaha!
|
Posted: Fri Jul 15, 2011 7:34 pm Post subject: |
|
|
Thank you. Now, I have a new problem. Heres the error message that deals with the line "if (check tag(4, ON)) then )":
hard coded function checktag takes at most 1 arguments but is being passed as 2 arguments. |
|
Back to top |
|
|
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|