|
CraZyHanD
|
CraZyHanD
|
I heard that using variables for your RPG script can get very messy. If you Set certain attacks and defense as a variable you can later use it for battle. But if you write it in text how can you use it later on?
And how can you add to a text. Like if on the first line of the text it says 12, how can you add +1,2... or whatever to that?
|
|
|
|
Joined: Aug 2004
Posts: 7,168
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,168 |
You can always call up the information from your text (txt) file, put it into a variable, change it around, and then re-write the information to the text file again. Basically there are two types of text files, txt & ini, each has it's own advantages & disadvantages depending on what you're wanting to put in the file and how you want it stored. Likewise, there are two types of variables, global & local. Global variables, when set, stay set until they are modified, or unset. Local variables, are automatically emptied when the end of the script (that they were set in) is reached. Also please note that hash tables are an excellent way of storing information. Hash tables are, I believe, the fastest way of storing and accessing a lot of information. Per your example, the following would work var %a = $left($read(file.txt,t,1),1), %b = $right($read(file.txt,t,1),1), %c = $calc(%a + %b)
echo -a $read(file.txt,t,1) summed is %c
Please note that this is a very simple example, and if you'd like assistance in writing the code, I'll need more details. One reason that people have a hard time with variables in an RPG script, is the fact that most people (and I'm guilty of doing this myself) don't use variable names that are easily identifiable for the information that they hold. I suggest you read /help $read /help /write /help $readini /help /writeini /help $ini /help Hash tables
|
|
|
|
CraZyHanD
|
CraZyHanD
|
Where are Hash Tables stored?(I cant find any file) Can you play them for later use? This is what i have:
on Kanto:Text:!Starter *:#: {
var %a = $2
if (!$isfile($+(Pokemon_RPG\,$nick,.Party,.txt))) {
if (%a == Squirtle) {
hadd -smuN $nick Squirtle
hadd -smuN $nick 5
hadd -smuN $nick 24
hadd -smuN $nick 14
hadd -smuN $nick 16
hadd -smuN $nick 13
hadd -smuN $nick 14
}
}
And another problem.
on Kanto:Text:!Stat 1:#: {
play $chan $hget($nick)
}
This doesnt work... I want to show the person their stats but it doesnt work like that, and can you do something like this:
on Kanto:Text:!Stat 1:#: {
msg $chan $Read($+($Hget($nick,1)))
msg $chan $Read($+($Hget($nick,2)))
msg $chan $Read($+($Hget($nick,3)))
msg $chan $Read($+($Hget($nick,4)))
}
I have no idea how Hash Tables works but is it something like: Pokemon |_Squirtle_| |_5_| |_24_| etc.. On the help file it says:
$hget(name/N, item)
Returns the data associated with an item in the specified hash table.
I still dont know what N means. I want to make it so if I put $Hget(Pokemon/N?,Attack) - the number shows up. I cant really put it into words but if you understand what im saying please help.
Last edited by CraZyHanD; 19/11/05 07:00 PM.
|
|
|
|
Joined: Dec 2002
Posts: 3,534
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 3,534 |
You don't use $read() to get data from Hash Tables dude. Just stick with .txt. 
on Kanto:Text:!Starter *:#: {
if ($isfile($+(Pokemon_RPG\,$nick,.Party,.txt))) {
var %poke = write $+("Pokemon_RPG\,$nick,.Party,.txt")
if (!$read($+(Pokemon_RPG\,$nick,.Party,.txt),w,*Pokemon:*)) {
if ($2 == Squirtle) {
write -c $gettok(%poke,2-,32)
%poke Pokemon: $2
%poke Character: $2
%poke Level: 5
%poke Attack: Some_Attack
%poke Defence: Some_Defence
%poke Speed: Some_Speed
}
elseif ($2 == Bulbasaur) {
write -c $gettok(%poke,2-,32)
%poke Pokemon: $2
%poke Level: 5
%poke Attack: Some_Attack
%poke Defence: Some_Defence
%poke Speed: Some_Speed
}
elseif ($2 == Charmander) {
write -c $gettok(%poke,2-,32)
%poke Pokemon: $2
%poke Level: 5
%poke Attack: Some_Attack
%poke Defence: Some_Defence
%poke Speed: Some_Speed
}
else { msg $nick $2 is not a starter pokemon! }
}
else { msg $nick You already chose $gettok($read($+(Pokemon_RPG\,$nick,.Party,.txt),w,*Pokemon:*),2,32) as your character. }
}
else { msg $nick You aren't playing right now. }
}
-Andy
|
|
|
|
CraZyHanD
|
CraZyHanD
|
Lol, that was my original plan. Umm what does this mean?
[color:black] write [/color] [color:red] -c $gettok(%poke,2-,32)
[/color]
And How can you make a script like this work?
on Kanto:Text:!Stat 1:#: {
msg $chan Pokemon: $+($Read(Pokemon_RPG\,$nick,.Party,.txt,1))
}
|
|
|
|
Joined: Dec 2002
Posts: 3,534
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 3,534 |
Oh you can delete those instances of that. It was for your original RPG that if they chose a character and decided to choose a different one it'd clear the file and write to it again. But since we've checked if they have chose a pokemon or not we don't need it. By Stat 1 do you mean level or attack etc?
On *:Text:!Stat *:#: {
var %file = $+(Pokemon_RPG\,$nick,.Party,.txt)
if ($isfile(%file)) {
msg $chan $read(%file,w,$+(*,$2,*))
}
}
!Stat Pokemon !Stat Level !Stat Attack !Stat Speed Etc.. -Andy
|
|
|
|
CraZyHanD
|
CraZyHanD
|
Before you read what I wrote below, Can you Add numbers in certain lines in a text File. For example if a txt file had 14 on its second line can you put
write -c $Calc($read(file,2)+1)
Can this replace the 14 and 15 in its place? If so..... Im not going to Write " Attack : 14 ", instead im going to put just the numbers, so that when they level up i can add to their stats. That is why I need to know how to use a $read in the middle of a msg.
on Kanto:Text:!Stat 1:#: {
msg $chan Pokemon: $+($Read(Pokemon_RPG\,$nick,.Party,.txt,1))
}
And !Stat 1 is supposed to show the Stats of the pokemon on Slot 1 of your Group.
Last edited by CraZyHanD; 19/11/05 08:25 PM.
|
|
|
|
DaveC
|
DaveC
|
I dont mean this nastly, but i suggest you start with some simple type of game, and progress onto a RPG at a later time. I believe your out of your depth on some of the things your hoping to achieve, based on the level of understanding you have of mirc scripting.
Im sure you can get better, but a large project straight off the mark is likely to bog down and not progress. I look at some of the first things i ever did in mirc (and im a programmer by trade) and i think now WOW what crazy thing was i doing there!
|
|
|
|
|