I feel so dumb, sample map script not working!

Maps and the art of mapmaking.
meows
Peasant
Peasant
Posts: 75
Joined: 11 Oct 2006

I feel so dumb, sample map script not working!

Unread postby meows » 27 Oct 2006, 08:48

Ok after reading many posts here I think I am missing something small to get this to work properly. I made the sample map that came with the map editor. However I can't get the Meeting to work..
In the Region i named it Meeting and the code from the editor sample is thus.

GiveExp ("Isabell", 2000);

function Meeting(heroname)
if heroname=="Christian" then
SetPlayerResource(PLAYER_1,6,10000);
AddHeroCreatures("Christian", 14, 5)
Trigger(REGION_ENTER_AND_STOP_TRIGGER,"meeting","Meeting"nil);
end;
end;

I also tried this script that looks so cool but it will not display either!
O do get the Function errors but read in posts here they do not matter/

What is missing? What am I doing wrong please?

MessageBox("Maps\SingleMissions\Go for first map\First Day text.txt");
-- only do this the first day

function NewDayTrigger()
if GetDate(DAY_OF_WEEK) == 1 then
-- do this first day of every week.

end;
end;
Trigger(NEW_DAY_TRIGGER, "NewDayTrigger");

User avatar
Pitsu
Round Table Hero
Round Table Hero
Posts: 1830
Joined: 22 Nov 2005

Re: I feel so dumb, sample map script not working!

Unread postby Pitsu » 27 Oct 2006, 09:02

I'd say the meeting scripts should look like

Code: Select all

function Meeting(heroname)
	if heroname=="Christian" then
		SetPlayerResource(PLAYER_1,6,10000);
		AddHeroCreatures("Christian", 14, 5);
	Trigger(REGION_ENTER_AND_STOP_TRIGGER,"meeting",nil);
  end;
end;

Trigger(REGION_ENTER_AND_STOP_TRIGGER, "meeting", "Meeting");
What do the errormessages tell you?

User avatar
alavris
Scout
Scout
Posts: 164
Joined: 06 Jan 2006
Location: Poland
Contact:

Unread postby alavris » 27 Oct 2006, 09:08

Pitsu's code will work for sure. Error was in this line:

Code: Select all

 Trigger(REGION_ENTER_AND_STOP_TRIGGER,"meeting","Meeting"nil);
Just too many arguments given to function Trigger().
.

meows
Peasant
Peasant
Posts: 75
Joined: 11 Oct 2006

Unread postby meows » 27 Oct 2006, 09:41

Well shoot I gave up on trying to get the Region code working for now.. and just Put this in. But the message box is not opening at all.
Could it be too long a Directory name? And If so can I change it in the Map properties?

MessageBox("Maps\SingleMissions\Go for first map\Firs.txt");
-- only do this the first day

function NewDayTrigger()
if GetDate(DAY_OF_WEEK) == 1 then
-- do this first day of every week.
Trigger(NEW_DAY_TRIGGER, "NewDayTrigger");
end;
end;
Trigger(NEW_DAY_TRIGGER, "NewDayTrigger");
ChangeHeroStat("Isabell",0, 2000);

User avatar
Pitsu
Round Table Hero
Round Table Hero
Posts: 1830
Joined: 22 Nov 2005

Unread postby Pitsu » 27 Oct 2006, 10:01

Most common problems with not appearing messages is either wrong path (yours seems OK), missing file (make sure that there is "Firs.txt" file) and finally an error somewhere else in the script that makes the game ignore the rest of the script file/function. You could try:

Code: Select all

function NewDayTrigger() 
    if GetDate(DAY) == 1 then 
           MessageBox("Maps\SingleMissions\Go for first map\Firs.txt"); 
    end;
   if GetDate(DAY_OF_WEEK) == 1 then 
        --Add the commands what need to be done first day each week
   end; 
end; 

Trigger(NEW_DAY_TRIGGER, "NewDayTrigger");

meows
Peasant
Peasant
Posts: 75
Joined: 11 Oct 2006

Unread postby meows » 27 Oct 2006, 11:10

Hummm.. getting very flustrated..
here is your code, I only changed the day.
function NewDayTrigger()
if GetDate(DAY) == 3 then
MessageBox("Maps\SingleMissions\Go for first map\firs.txt");
end;
if GetDate(DAY_OF_WEEK) == 3 then
AddHeroCreatures("Christian", 14, 5)
end;

Trigger(NEW_DAY_TRIGGER, "NewDayTrigger");

Now I copied the map first map.h5m to another directory and extracted it and yes firs.txt is in the file. and no monsters were added to the Hero. I even ran the game 2 full weeks.. Are we supposed to add the Hero's name to the properties under object Properties Tree?? I only see one Hero and thats Player 2 the computer.. Vittorio is shown under Map Objects. However under Object Properties Tree he is shown as Main Hero Christian. So Confusing.. Much Thanks for any help!

User avatar
Pitsu
Round Table Hero
Round Table Hero
Posts: 1830
Joined: 22 Nov 2005

Unread postby Pitsu » 27 Oct 2006, 11:33

I did not understand now whether there is anything that is working or not. In case of message path definition, try / instead of \. Maybe that does the trick.

User avatar
alavris
Scout
Scout
Posts: 164
Joined: 06 Jan 2006
Location: Poland
Contact:

Unread postby alavris » 27 Oct 2006, 12:10

Meows, could you copy here whole code text from script tag? There must be some mistake in other part of code, but I must see the whole text to tell where's the problem.
.

User avatar
Grumpy Old Wizard
Round Table Knight
Round Table Knight
Posts: 2205
Joined: 06 Jan 2006
Location: Tower Grump

Unread postby Grumpy Old Wizard » 27 Oct 2006, 12:39

meows wrote:Hummm.. getting very flustrated..
here is your code, I only changed the day.
function NewDayTrigger()
if GetDate(DAY) == 3 then
MessageBox("Maps\SingleMissions\Go for first map\firs.txt");
end;
if GetDate(DAY_OF_WEEK) == 3 then
AddHeroCreatures("Christian", 14, 5)
end;

Trigger(NEW_DAY_TRIGGER, "NewDayTrigger");

Now I copied the map first map.h5m to another directory and extracted it and yes firs.txt is in the file. and no monsters were added to the Hero.
You are missing an "end;" Put it after the AddHeroCreatures statement. Also you need a semicolon after AddHeroCreatures("Christian", 14, 5) like so:
function NewDayTrigger()
if GetDate(DAY) == 3 then
MessageBox("Maps\SingleMissions\Go for first map\firs.txt");
end;
if GetDate(DAY_OF_WEEK) == 3 then
AddHeroCreatures("Christian", 14, 5);
end;
end;

Trigger(NEW_DAY_TRIGGER, "NewDayTrigger");
Frodo: "I wish the ring had never come to me. I wish none of this had happened."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."

User avatar
alavris
Scout
Scout
Posts: 164
Joined: 06 Jan 2006
Location: Poland
Contact:

Unread postby alavris » 27 Oct 2006, 13:11

Grumpy Old Wizard wrote:You are missing an "end;"
That's why using "tab" is useful ;)
.

User avatar
theLuckyDragon
Round Table Knight
Round Table Knight
Posts: 4883
Joined: 06 Jan 2006

Unread postby theLuckyDragon » 27 Oct 2006, 13:19

I prefer C++ style braces { }. Never liked those Pascalish begins and ends.
"Not all those who wander are lost." -- JRRT

meows
Peasant
Peasant
Posts: 75
Joined: 11 Oct 2006

Unread postby meows » 27 Oct 2006, 20:09

Thank you Pitsu, Grumpy old Wizard and alavris! It's working!

here is the code. It seems it took adding the (( end; )) and reversing the slashes to make this beast work!
I have a question if you don't mind gentlemen,
1. How do you know how many (( end; )) you need?
2.When adding more than one function do you need anything between them?
3. Does anyone have any working region code? Simular to the region in the manual? That will not work either. I did change the code to reflect the
1.3 verson of the cheat codes but alas that was not enough.

Working and it really did put a smile on my face.. Thank you so much!
function NewDayTrigger()
if GetDate(DAY) == 3 then
MessageBox("Maps/SingleMissions/Go for first map/firs.txt");
end;
if GetDate(DAY_OF_WEEK) == 3 then
AddHeroCreatures("Christian", 14, 5);
end;
end;

Trigger(NEW_DAY_TRIGGER, "NewDayTrigger");

User avatar
alavris
Scout
Scout
Posts: 164
Joined: 06 Jan 2006
Location: Poland
Contact:

Unread postby alavris » 27 Oct 2006, 20:23

meows wrote:1. How do you know how many (( end; )) you need?
2.When adding more than one function do you need anything between them?
3. Does anyone have any working region code? Simular to the region in the manual? That will not work either. I did change the code to reflect the
1.3 verson of the cheat codes but alas that was not enough.
1) "end" must be placed for exmple after:
-function
-if ...
-for ...
-do while ...

So if you used in function an "if" you have to write two "end"s.

2) You don't need anything between them.

3) I'll search for for some good example in my map and will post here.
.

User avatar
alavris
Scout
Scout
Posts: 164
Joined: 06 Jan 2006
Location: Poland
Contact:

Unread postby alavris » 27 Oct 2006, 20:58

Ok, I've found in my map an example of working region script:

Code: Select all

function f_archers1(hero_name)
	AddHeroCreatures(hero_name, CREATURE_ARCHER, 6);
	if GetCurrentPlayer() == PLAYER_1 then
		MessageBox("Maps/Multiplayer/Alavris 2/mess16.txt");
	end;
	Trigger(REGION_ENTER_AND_STOP_TRIGGER, "archers1", nil);
end;

Trigger(REGION_ENTER_AND_STOP_TRIGGER, "archers1", "f_archers1");
The region must be named archers1 and you also have to change path inside MessageBox() function. This script will work only when RED player comes into the region.
.

meows
Peasant
Peasant
Posts: 75
Joined: 11 Oct 2006

Unread postby meows » 28 Oct 2006, 08:41

Oh thank you so much! I actually have 2 working scripts now.. WOOT..

Now on to getting to learn this much better.

Thank you guys!

User avatar
Grumpy Old Wizard
Round Table Knight
Round Table Knight
Posts: 2205
Joined: 06 Jan 2006
Location: Tower Grump

Unread postby Grumpy Old Wizard » 28 Oct 2006, 14:58

meows wrote:Oh thank you so much! I actually have 2 working scripts now.. WOOT..

Now on to getting to learn this much better.

Thank you guys!
If you are looking for example scripts feel free to download my map "Seize The Throne" in the maptesting section. The scripting is heavily commented so you should be able to see what I have done there.

All scripts are working and there are over 1000 lines of code. It is version 0.91. I am waiting for a couple of playtesters to finish their playthroughs to update to 1.0.

GOW
Frodo: "I wish the ring had never come to me. I wish none of this had happened."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 2 guests