|
Thread: Simple Scripting problem ? :) | |
|
NecroRaise
Tavern Dweller
|
posted December 18, 2006 09:41 PM |
|
|
Simple Scripting problem ? :)
Hey Guyz
I've been trying for two days now and i can't figure what i'm doing wrong. The script is pretty simple, i want a message box to appear when player 1 pass in some regions, the message boxes containing text for the story. The name of the map is Last Stand.
My problem : When the hero comes in the regions, no window is appearing, and in the console i got the message : message text is empty! so i guess my script is good, the hero makes the script start, but the game can't find the .txt files i made. I tried to place the .txt files containing the story in different places, nothing worked..
Here's my script so far :
-- Starting Message
function Militia(Rolf)
if GetCurrentPlayer () == PLAYER_1 then
MessageBox("Maps/SingleMissions/Last Stand/militia.txt");
Trigger( REGION_ENTER_WITHOUT_STOP_TRIGGER, "militia", nil );
end;
end;
Trigger( REGION_ENTER_WITHOUT_STOP_TRIGGER, "militia", "Militia" );
-- Welcome message in Last Stand
function Welcome(Rolf)
if GetCurrentPlayer () == PLAYER_1 then
MessageBox("Maps/SingleMissions/Last Stand/welcome.txt");
Trigger( REGION_ENTER_WITHOUT_STOP_TRIGGER, "welcome", nil );
end;
end;
Trigger( REGION_ENTER_WITHOUT_STOP_TRIGGER, "welcome", "Welcome" );
-- Scouts message before the hut
function Scouts(Rolf)
if GetCurrentPlayer () == PLAYER_1 then
MessageBox("Maps/SingleMissions/Last Stand/scouts.txt");
Trigger( REGION_ENTER_WITHOUT_STOP_TRIGGER, "scouts", nil );
end;
end;
Trigger( REGION_ENTER_WITHOUT_STOP_TRIGGER, "scouts", "Scouts" );
-- Witch message before the hut
function Witch(Rolf)
if GetCurrentPlayer () == PLAYER_1 then
MessageBox("Maps/SingleMissions/Last Stand/witch.txt");
Trigger( REGION_ENTER_WITHOUT_STOP_TRIGGER, "witch", nil );
end;
end;
Trigger( REGION_ENTER_WITHOUT_STOP_TRIGGER, "witch", "Witch" );
--------------
Please help me ! if i could also have the confirmation that the .txt files must be placed in the folder :
..Gamedir/Maps/SingleMissions/Last Stand/xxxxx.txt
It would be great
Necro
____________
|
|
Kronos1000
Promising
Supreme Hero
Fryslân Boppe
|
posted December 19, 2006 08:49 PM |
|
|
There is a big mistake in your script in this line:
function Militia(Rolf)
if GetCurrentPlayer () == PLAYER_1 then
It should be like this:
function Militia(heroname)
if heroname == "Rolf" and GetCurrentPlayer () == PLAYER_1 then
If it still doesn't work then try this:
Click this button
Then you open the resources tab and add a new file: http://img218.imageshack.us/img218/8626/intrctns2gd9.jpg
Than you'll have to add a text. There you can make your message.
|
|
NecroRaise
Tavern Dweller
|
posted December 19, 2006 09:31 PM |
|
|
Thanks !!
i'm gonna try right now
[Edit] :
Ok i tried with your code, it didnt change anything, my Code was working same. I think the problem isn't here, it's more like the game can't find where i placed the .txt files conatining the story text.
I'm gona try with your 2nd strategy now
Thanks anyway for trying it's nice
And if anyone have the answer of my problem...
____________
|
|
NecroRaise
Tavern Dweller
|
posted December 19, 2006 10:24 PM |
|
|
Problem SOLVED !!
Thank you so much for pointing me to the right direction
i created the txt files directly in "ressources" like you said, and i deleted all the .txt files i made myself.
It works wonder, the map will soon be finished !!
Will you wanna play it ?
It's a story about a Dwarf leader surrounded by too many enemies, he has to shelter in a super fortress like helms deep and then kick the ass of the invaders ! but there are a few things he doesnt know at first ..
I designed the map to be fun to play, with some intense fights at crucial points of the story it will not be easy, i'm trying to make something even i don't know if i can beat it everytime
Anyway, thanks ! here's a c00kie !
____________
|
|
Kronos1000
Promising
Supreme Hero
Fryslân Boppe
|
posted December 20, 2006 04:16 PM |
|
|
You're welcome, once you release the map I will download and play it I promise!
|
|
Kronos1000
Promising
Supreme Hero
Fryslân Boppe
|
posted December 21, 2006 03:08 AM |
|
|
Hmm... I'm having a problem myself it's a bit more complex but here it is:
function NewDay()
peasant = GetHeroCreatures("RedHeavenHero01", 1)
militia = GetHeroCreatures("RedHeavenHero01", 2)
archer = GetHeroCreatures("RedHeavenHero01", 3)
marksman = GetHeroCreatures("RedHeavenHero01", 4)
footman = GetHeroCreatures("RedHeavenHero01", 5)
squire = GetHeroCreatures("RedHeavenHero01", 6)
griffin = GetHeroCreatures("RedHeavenHero01", 7)
impgriffin = GetHeroCreatures("RedHeavenHero01", 8)
priest = GetHeroCreatures("RedHeavenHero01", 9)
inquisistor = GetHeroCreatures("RedHeavenHero01", 10)
cavelier = GetHeroCreatures("RedHeavenHero01", 11)
paladin = GetHeroCreatures("RedHeavenHero01", 12)
angel = GetHeroCreatures("RedHeavenHero01", 13)
archangel = GetHeroCreatures("RedHeavenHero01", 14)
AddHeroCreatures("RedHeavenHero01", 106, peasant)
RemoveHeroCreatures("RedHeavenHero01", 1, peasant)
AddHeroCreatures("RedHeavenHero01", 106, militia)
RemoveHeroCreatures("RedHeavenHero01", 2, militia)
AddHeroCreatures("RedHeavenHero01", 107, archer)
RemoveHeroCreatures("RedHeavenHero01", 3, archer)
AddHeroCreatures("RedHeavenHero01", 107, marksman)
RemoveHeroCreatures("RedHeavenHero01", 4, marksman)
AddHeroCreatures("RedHeavenHero01", 108, footman)
RemoveHeroCreatures("RedHeavenHero01", 5, footman)
AddHeroCreatures("RedHeavenHero01", 108, squire)
RemoveHeroCreatures("RedHeavenHero01", 6, squire)
AddHeroCreatures("RedHeavenHero01", 109, griffin)
RemoveHeroCreatures("RedHeavenHero01", 7, griffin)
AddHeroCreatures("RedHeavenHero01", 109, impgriffin)
RemoveHeroCreatures("RedHeavenHero01", 8, impgriffin)
AddHeroCreatures("RedHeavenHero01", 110, priest)
RemoveHeroCreatures("RedHeavenHero01", 9, priest)
AddHeroCreatures("RedHeavenHero01", 110, inquisistor)
RemoveHeroCreatures("RedHeavenHero01", 10, inquisistor)
AddHeroCreatures("RedHeavenHero01", 111, cavelier)
RemoveHeroCreatures("RedHeavenHero01", 11, cavelier)
AddHeroCreatures("RedHeavenHero01", 111, paladin)
RemoveHeroCreatures("RedHeavenHero01", 12, paladin)
AddHeroCreatures("RedHeavenHero01", 112, angel)
RemoveHeroCreatures("RedHeavenHero01", 13, angel)
AddHeroCreatures("RedHeavenHero01", 112, archangel)
RemoveHeroCreatures("RedHeavenHero01", 14, archangel)
end;
Trigger(NEW_DAY_TRIGGER, "NewDay")
It replaces all creatures of Haven in Andreas's army with Renegades, but it only works with peasants.
|
|
NecroRaise
Tavern Dweller
|
posted December 21, 2006 06:43 AM |
|
|
Yo, I noticed you didnt place the " ; " at the end of each line, isn't it important ? maybe because of that the game considers that theres only one function, the first: peasants.. and thus doesnt play the rest of the script..
If it's not that, i dunno, are you sure you can chain that many lines in the same time ?
____________
|
|
Kronos1000
Promising
Supreme Hero
Fryslân Boppe
|
posted December 21, 2006 03:17 PM |
|
|
How could I not notice that, thank you.
Edit: That isn't the problem still, only peasants work.
|
|
sfidanza
Promising
Supreme Hero
|
posted December 28, 2006 12:36 PM |
|
|
Did you try removing first and then adding? Maybe the army is full when you add the troops, so they do not appear.
|
|
Kronos1000
Promising
Supreme Hero
Fryslân Boppe
|
posted December 28, 2006 11:06 AM |
|
|
That's not it but I allready solved it if's were needed like this:
function NewDay()
peasant = GetHeroCreatures("RedHeavenHero01", 1);
militia = GetHeroCreatures("RedHeavenHero01", 2);
archer = GetHeroCreatures("RedHeavenHero01", 3);
marksman = GetHeroCreatures("RedHeavenHero01", 4);
footman = GetHeroCreatures("RedHeavenHero01", 5);
squire = GetHeroCreatures("RedHeavenHero01", 6);
griffin = GetHeroCreatures("RedHeavenHero01", 7);
impgriffin = GetHeroCreatures("RedHeavenHero01", 8);
priest = GetHeroCreatures("RedHeavenHero01", 9);
inquisistor = GetHeroCreatures("RedHeavenHero01", 10);
cavelier = GetHeroCreatures("RedHeavenHero01", 11);
paladin = GetHeroCreatures("RedHeavenHero01", 12);
angel = GetHeroCreatures("RedHeavenHero01", 13);
archangel = GetHeroCreatures("RedHeavenHero01", 14);
if peasant > 0 then
AddHeroCreatures("RedHeavenHero01", 106, peasant);
RemoveHeroCreatures("RedHeavenHero01", 1, peasant);
end;
if militia > 0 then
AddHeroCreatures("RedHeavenHero01", 106, militia);
RemoveHeroCreatures("RedHeavenHero01", 2, militia);
end;
if archer > 0 then
AddHeroCreatures("RedHeavenHero01", 107, archer);
RemoveHeroCreatures("RedHeavenHero01", 3, archer);
end;
if marksman > 0 then
AddHeroCreatures("RedHeavenHero01", 107, marksman);
RemoveHeroCreatures("RedHeavenHero01", 4, marksman);
end;
if footman > 0 then
AddHeroCreatures("RedHeavenHero01", 108, footman);
RemoveHeroCreatures("RedHeavenHero01", 5, footman);
end;
if squire > 0 then
AddHeroCreatures("RedHeavenHero01", 108, squire);
RemoveHeroCreatures("RedHeavenHero01", 6, squire);
end;
if griffin > 0 then
AddHeroCreatures("RedHeavenHero01", 109, griffin);
RemoveHeroCreatures("RedHeavenHero01", 7, griffin);
end;
if impgriffin > 0 then
AddHeroCreatures("RedHeavenHero01", 109, impgriffin);
RemoveHeroCreatures("RedHeavenHero01", 8, impgriffin);
end;
if priest > 0 then
AddHeroCreatures("RedHeavenHero01", 110, priest);
RemoveHeroCreatures("RedHeavenHero01", 9, priest);
end;
if inquisistor > 0 then
AddHeroCreatures("RedHeavenHero01", 110, inquisistor);
RemoveHeroCreatures("RedHeavenHero01", 10, inquisistor);
end;
if cavelier > 0 then
AddHeroCreatures("RedHeavenHero01", 111, cavelier);
RemoveHeroCreatures("RedHeavenHero01", 11, cavelier);
end;
if paladin > 0 then
AddHeroCreatures("RedHeavenHero01", 111, paladin);
RemoveHeroCreatures("RedHeavenHero01", 12, paladin);
end;
if angel > 0 then
AddHeroCreatures("RedHeavenHero01", 112, angel);
RemoveHeroCreatures("RedHeavenHero01", 13, angel);
end;
if archangel > 0 then
AddHeroCreatures("RedHeavenHero01", 112, archangel);
RemoveHeroCreatures("RedHeavenHero01", 14, archangel);
end;
end;
Trigger(NEW_DAY_TRIGGER, "NewDay")
|
|
sfidanza
Promising
Supreme Hero
|
posted December 31, 2006 05:18 PM |
|
|
ok.
btw, here's a more compact way of doing the same with a for loop:
heroName = "RedHeavenHero01";
for i=1,14 do
creaturesCount = GetHeroCreatures(heroName, i);
if creaturesCount > 0 then
RemoveHeroCreatures(heroName, i, creaturesCount);
n = i;
if mod(i,2) ~= 0 then n = i + 1; end;
AddHeroCreatures(heroName, 105 + (n/2), creaturesCount);
end;
end;
|
|
Kronos1000
Promising
Supreme Hero
Fryslân Boppe
|
posted January 03, 2007 02:13 PM |
|
|
Quote: ok.
btw, here's a more compact way of doing the same with a for loop:
heroName = "RedHeavenHero01";
for i=1,14 do
creaturesCount = GetHeroCreatures(heroName, i);
if creaturesCount > 0 then
RemoveHeroCreatures(heroName, i, creaturesCount);
n = i;
if mod(i,2) ~= 0 then n = i + 1; end;
AddHeroCreatures(heroName, 105 + (n/2), creaturesCount);
end;
end;
I understand this script except this line
if mod(i,2) ~= 0 then n = i + 1; end;
|
|
sfidanza
Promising
Supreme Hero
|
posted January 03, 2007 03:47 PM |
|
|
~= is the "not equal" test in lua
The goal of the code bit is to map a Haven creature (internal number 1 to 14) into its renegade counterpart (internal number 106 to 112). But 2 Haven creatures correspond to the same renegade:
1, 2 -> 106 (peasant and conscript to enforcer)
...
What the code does is:
- from the Haven creature i, find its upgrade n
* if i is even, n=i
* if i is odd, n=i+1
- then the mapping is just: renegade = 105 + n/2
To test the parity of i, you just check if (i mod 2)=0.
To learn more about lua syntax:
http://www.lua.org/pil/
|
|
|
|