Basic scripting resources
Basic scripting resources
Is there any tutorial or guide to learn the basics of scripting? I'm starting to learn about it but I can't find good info. Right now I don't know if I must make my map scripts in lua files, or just use the editor field called "script text" (or something like that), I don't know what are the fields of the map properties tree about new day trigger or war fog, and I have no idea of which triggers are available and how can I use them in my functions.
So any help would be welcome.
So any help would be welcome.
- Sir_Toejam
- Nightmare
- Posts: 1061
- Joined: 24 Jul 2006
- Grumpy Old Wizard
- Round Table Knight
- Posts: 2205
- Joined: 06 Jan 2006
- Location: Tower Grump
Re: Basic scripting resources
Click on start ->All Programs->Ubisoft->HOMM5. Then you will see Map Editor Manual, which is 4 parts. Go through the practical and theoretical guides.Vitirr wrote:Is there any tutorial or guide to learn the basics of scripting? I'm starting to learn about it but I can't find good info. Right now I don't know if I must make my map scripts in lua files, or just use the editor field called "script text" (or something like that), I don't know what are the fields of the map properties tree about new day trigger or war fog, and I have no idea of which triggers are available and how can I use them in my functions.
So any help would be welcome.
Also, look at the scripting of some of the user made maps that have been published. My map, "Seize The Throne" has over 1000 lines of scripting. The scripting is heavily commented so you can look at examples of what I did for various things and it might help you figure out how to do what you want to do.
https://www.celestialheavens.com/search ... ion=search
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."
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."
Re: Basic scripting resources
Yes, as if those have much info about scripts :pGrumpy Old Wizard wrote: Click on start ->All Programs->Ubisoft->HOMM5. Then you will see Map Editor Manual, which is 4 parts. Go through the practical and theoretical guides.
Ok since it looks like there are no guides or tutorials and the only way to learn is the hard way, I'll start with specific questions.
This is my code:
Some questions. If I don't specify "day1" as a function in the NewDayTrigger field of the map properties tree, the day 1 the function is not triggered, (the rest of days it works however). In fact, if I set that parameter in the map properties tree, there's no need to specify in the script Trigger( NEW_DAY_TRIGGER, 'day1' ); Is that normal?Trigger( NEW_DAY_TRIGGER, 'day1' );
Trigger( WAR_FOG_ENTER_TRIGGER, 'day2' );
function day1()
if GetDate(DAY) == 1 then
MoveCamera(69, 44, 0, 20, 0.05, -0.2, 0, 0);
sleep(20);
MessageBox ('Maps/SingleMissions/Nuevo_mapa_luces/mensaje1.txt');
elseif GetDate(DAY) == 3 then
SetAmbientLight(0, 'Lights/_(AmbientLight)/Prueba.(AmbientLight).xdb', false, 1);
end;
end;
function day2(hero_name)
if GetDate(DAY) == 2 then
MessageBox('Maps/SingleMissions/Nuevo_mapa_luces/mensaje2.txt');
print(hero_name);
end;
end;
SetAmbientLight doesn't work. It never finds the ambient file. I've tried with the name and route of the file (as it is now) and with a name that I set in the name field of the ambientlight object. No success. Any idea?
Anybody knows when exactly triggers the event WAR_FOG_ENTER_TRIGGER? I thought it was when the hero removes the fog of war but I was wrong, and it never triggers.
By the way, I've found undocumented functions like QuestionBox or MessageBoxInt. Any idea of what those do? Is there's a list of these functions documented anywhere?
- Sir_Toejam
- Nightmare
- Posts: 1061
- Joined: 24 Jul 2006
like i said:
http://elrath.com/forums/index.php?s=29 ... owforum=16
several folks playing with scripting there, in case you don't get the answers you need here.
http://elrath.com/forums/index.php?s=29 ... owforum=16
several folks playing with scripting there, in case you don't get the answers you need here.
Re: Basic scripting resources
Not sure whether normal or not, but it is a common case not anything specific to your editor. EDIT: day 1 events you can write to the script without any "if getdate(DAY)==1 then" or having them as a separate function.Vitirr wrote: Some questions. If I don't specify "day1" as a function in the NewDayTrigger field of the map properties tree, the day 1 the function is not triggered, (the rest of days it works however). In fact, if I set that parameter in the map properties tree, there's no need to specify in the script Trigger( NEW_DAY_TRIGGER, 'day1' ); Is that normal?
You can do like in C5M5. The light texture file has name/internal name reference fields in its body. Give them one and use the reference name in SetAmbientLight command. Additionally, it may be necessary to have appropriate pointes in the map.xdb file. I am afraid you may need to use a text editor, as the map editor didn't seem to do it correctly for me.SetAmbientLight doesn't work. It never finds the ambient file. I've tried with the name and route of the file (as it is now) and with a name that I set in the name field of the ambientlight object. No success. Any idea?
BTW, C5M5 uses texture from: Lights/_(AmbientLight)/AdvMap/C5M5/c4m4_wastes (2).xdb
Could successfully use the same texture in a test map of mine.
Sorry, no answer at the moment. Tried some combinations, but as it seem to ignore this trigger and not report any problems... hard to solve.Anybody knows when exactly triggers the event WAR_FOG_ENTER_TRIGGER? I thought it was when the hero removes the fog of war but I was wrong, and it never triggers.
Not tested lately, but questionbox gave a question box.By the way, I've found undocumented functions like QuestionBox or MessageBoxInt. Any idea of what those do? Is there's a list of these functions documented anywhere?
QuestionBox('/Maps/Scenario/C6M5/message-8.txt', "Info"); -- runs function info() only when player clicks yes.
There are some more undocumented commands that work fine AFAIK. GetPlayerState(PLAYER_#) or GiveBorderguardKey (PLAYER_#, key#) for example... But not seen a list anywhere
Avatar image credit: N Lüdimois
Re: Basic scripting resources
Stupid me, I only had to add a new ambientlight in the map properties tree. I only used one, so the other ambientlight to swap, though the file was there in the file structure of the map, was ignored by the game.Pitsu wrote:You can do like in C5M5. The light texture file has name/internal name reference fields in its body. Give them one and use the reference name in SetAmbientLight command.
Now I've been succesfull changing adventure map and combat ambientl ights, (thanks to examples in C5M5 scripts). The CombatMapLight function doesn't take the name of the ambient light but the name and route of the file (with the aditional #xpointer(/AmbientLight) at the end). Now my only complain is that I can't change the towns ambients, but I guess I can live with that :-p
What do you mean?, to add the ambient light in the map.xdb file? If so it works for me from the editor.Pitsu wrote:Additionally, it may be necessary to have appropriate pointes in the map.xdb file. I am afraid you may need to use a text editor, as the map editor didn't seem to do it correctly for me.
Ok, solved With this function SetWarfogBehaviour(0, 0); you set the fog or war unremovable (the hero can only move through the terrain already revealed). Now place a teleporter next to the hero, and another far away (in the darkness). When the hero goes through the teleporter the event triggers. What's the use of it? I have no idea, but at least it worksPitsu wrote:Sorry, no answer at the moment. Tried some combinations, but as it seem to ignore this trigger and not report any problems... hard to solve.Anybody knows when exactly triggers the event WAR_FOG_ENTER_TRIGGER? I thought it was when the hero removes the fog of war but I was wrong, and it never triggers.
Yes, I finally managed to find it out by myself after a lot of tests. By the way you can add a function (or more) to be executed first. Just like this:Pitsu wrote:Not tested lately, but questionbox gave a question box.
QuestionBox('/Maps/Scenario/C6M5/message-8.txt', "Info"); -- runs function info() only when player clicks yes.
QuestionBox('/Maps/Scenario/C6M5/message-8.txt', "Info", function1(), function2());
It might prove useful if you want to give a long explanation before asking the question, so function1 and function2 could be 2 messagebox functions.
It could be interesting to make a thread for that where people could add his new discovered functions.Pitsu wrote:There are some more undocumented commands that work fine AFAIK. GetPlayerState(PLAYER_#) or GiveBorderguardKey (PLAYER_#, key#) for example... But not seen a list anywhere
Thanks Pitsu.
OK, the nil value did not work (for me). But another solution did. It indeed adds to colours. Say you have originally the three channels as 0,1,1 (cyan). By SetObjectFlashlight with 1,0,0 (red) the summary outcome is 1,1,1 (white). Thus, to remove a colour, one has to use negative values. SetObjectFlashlight to the very same object a light defined with -1,-1,-1 channels removed the light around it.
Hope it helps anyone who had not figured it out yet...
Hope it helps anyone who had not figured it out yet...
Avatar image credit: N Lüdimois
3 months of constantly blinking light and the player will develop epilepsy. Hence changes in his/her performance are very likely.Vitirr wrote: I wonder what will happen though after 3 months of gameplay if you keep adding lights and "antilights" each day/week. I wonder if it will have any effect on performance.
Avatar image credit: N Lüdimois
It is under player properties. The same place where you define whether a colour is human playabe or who is the main hero etc...Vitirr wrote:Well, sometimes it helps yes
Others not, because I have no idea of how to make a hero appear on the map. I've been looking at DeployReserveHero but I don't know what are the reserved heroes, or how can I reserve them. Any help is welcome.
Avatar image credit: N Lüdimois
GetObjectiveState is only returning 1 or -1 to me if the quest is active or inactive (completed, failed or still not started). Has anybody experienced the same with this script?
I'd like to diferenciate if the quest has been completed or failed, so if this doesn't work I'll have to do it manually.
EDIT: nevermind, I was using actually GetObjectiveProgress
I'd like to diferenciate if the quest has been completed or failed, so if this doesn't work I'll have to do it manually.
EDIT: nevermind, I was using actually GetObjectiveProgress
Who is online
Users browsing this forum: No registered users and 4 guests