Hello,
somehow my script does not ask to name the newly swapped hero.
And I've no idea why.
Could it be that the hero swapping is not noticed by the engine
or is there a mistake in my script that I just fail to see?
Me refers to the first hero in the team, right?
And that would be Mamoruko after swapping places, right?
No, the argument to renamehero should be the hero ID: "rename hero (hero:Mamoruko Yamada)". (If you have multiple copies that that hero in the party, it renames the first one).
"me" is a constant with the value zero. Using it is no different to writing 0.
I usually double-check the documentation for hero commands, because it's very easy to pass the wrong argument. There are three types of commands: ones that use hero IDs, ones that use party positions (from "find hero"), and ones that use caterpillar positions. "me" only makes sense as a caterpillar position.
Last edited by TMC on Thu Jul 06, 2017 9:48 am, edited 2 times in total.
Thanks a lot for the expaination!
I wasn't fully aware of the different methods to refer to heroes.
I added "hero by slot(0)" to find the first hero. It works.
(If the player renames it, does the hero keep it's name in the engine?
Could I still use hero:Mamoru if someone called him Peter?)
Actually, "rename hero(hero by slot (0))" is still wrong, although it will usually work. It doesn't work if the leader of the party isn't in slot 0, which might happen if you let the player access the Order/Team menu, or if you don't carefully swap a hero into slot 0 when you change the heroes in the party (your script appears to do that).
Instead, write "rename hero(leader)". 'leader' searches for the first party slot with a hero in it (which might be 0, 1, 2, or 3) and returns the ID of that hero.
Last edited by TMC on Sun Jul 09, 2017 2:35 am, edited 1 time in total.
marionline wrote:Thanks. :)
I'm a bit confused.What is the correct way to get the name of a hero by it's position?
The "rename hero" does not care where the hero is in the party, it only cares about their ID number. it will search for the hero no matter where they are currently located in the party.
You might also want to see the "rename hero by slot" command, which expects a party slot number, rather than a hero ID
plotscript, play_as_girl, begin
add hero (hero:Mamoruko Yamada)
swap by name (hero:Mamoruko Yamada, hero:Mamoru Yamada)
delete hero(hero:Mamoru Yamada)
#rename hero(hero by slot (0))
lock hero (hero:Mamoruko Yamada)
if (hero by slot(1)) then(delete hero( hero:Mamoruko Yamada))
# TODO: swap door link from empty room and Mamoru's room!
# TODO: Alter string variables!
end
For a reason the girl hero would be added to the team 2 times.
Now the renaming (it happens in another script) does not work:
show textbox(652) # HINT: This time you have to type an answer.
wait for textbox
wait(4)
rename hero(hero by slot (0))
wait(4)
"if (hero by slot(1)) then(delete hero( hero:Mamoruko Yamada))" is wrong. hero by slot returns -1 if there is no hero in that slot, because hero IDs count upwards from 0.
And that line doesn't make any sense anyway. Why are you deleting a hero immediately after adding it? I can't tell what your intention was.
As I said before, "rename hero(hero by slot (0))" won't work if there is no hero in the first slot. If you want to rename the first hero, write "rename hero(leader)"
Last edited by TMC on Mon Jul 17, 2017 12:00 am, edited 1 time in total.
Sorry, forgot about the "rename hero(Leader)" part.
The girl hero is added twice to the party. That's one too much.
But I can't figure out why and when there gets a second hero in the party.
I guess, I'll make use of the swap hero script you wrote in the other thread.
Maybe I can find the mistake, if I compare what I wrote with your script.