Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
5 years ago
Auto-translated
And do you also have an asterisk in your script? Perhaps it was interpreted as some kind of pointer...
In reply to Ment
User Avatar
5 years ago
Auto-translated
Ment
Do you also have an asterisk in your script? Maybe it was interpreted as some kind of pointer...
There is no asterisk.
In reply to Navkratis
User Avatar
5 years ago
Auto-translated
Navkratis
Good afternoon, the console displays the following error: (Script) ERROR: "=" expected
The script itself looks like this:

void GiveArtefact("Brem", 13, nBindToHero=0);

What is the error here?
I suspect that this script is written incorrectly.

GiveArtefact(heroname, artefactID, [bindToHero = 0]);
As I understand it, the 3rd parameter can be left blank altogether. But in your case, it's written as nBindToHero.
In reply to Fallenru
User Avatar
5 years ago
Auto-translated
Fallenru
I suspect that this script is written incorrectly.

GiveArtefact(heroname, artefactID, [bindToHero = 0]);
As I understand it, the 3rd parameter can be left blank altogether. But you have written nBindToHero.
I wrote GiveArtefact("Brem", 13); and it worked, thank you :)
In reply to Navkratis
User Avatar
5 years ago
Auto-translated
Please help me with a script. I need peasants to join my hero, a quest to appear, and the quest to be completed by reaching a specific point with them, after which they should disappear from the party. If the peasants die in battle, the quest should fail. (I can more or less write the initial stages, but I don't know how to make the quest fail after the peasants die.)

Added 4 hours 52 minutes ago
Please help me figure out what the error is in the script:
function demon()
local p1 =GetObjectiveState ('qwert1',PLAYER_1);
local p =GetObjectiveState ('qwert2',PLAYER_1);
local opr = 9
local opr3 = 13
local p2 = GetObjectiveState ('qwert3', 1);
if p2 == OBJECTIVE_COMPLETED then opr= opr+1
if p2 == OBJECTIVE_COMPLETED then opr= opr3+1
if p1 ==OBJECTIVE_COMPLETED and GetDate(DAY_OF_WEEK ) == 6
then
AddObjectCreatures('gar_1', opr, 15);
AddObjectCreatures('gar_2', opr, 15);
AddObjectCreatures('gar_3', opr, 15);
AddObjectCreatures('gar_4', opr, 15);
elseif p ==OBJECTIVE_COMPLETED and GetDate(DAY_OF_WEEK ) == 5
then
AddObjectCreatures('gar_1', opr3, 3);
AddObjectCreatures('gar_2', opr3, 3);
AddObjectCreatures('gar_3', opr3, 3);
AddObjectCreatures('gar_4', opr3, 3);
end;
end;
Trigger(NEW_DAY_TRIGGER, 'demon');

It seems like I wrote everything correctly, but the quest is completed, the 5th day comes, the monks don't arrive, the 6th day comes, and the angels still don't appear.
User Avatar
5 years ago
Auto-translated
What does the console say?
P.S. Oh, these asterisks that the forum now automatically adds for some reason if there are more than one spaces.
In reply to Лоли Никита
User Avatar
5 years ago
Auto-translated
Lol Nikita
Please help me with a script. I need peasants to join my hero, a quest to appear, and the quest requires reaching a specific point with them and completing the quest there, after which they should disappear from the squad. If the peasants die in battle, the quest should fail. (I can more or less write the initial stages, but I don't know how to make the quest fail after the peasants die.)

Added 4 hours 52 minutes ago
Please help me figure out what the error is in the script:
function demon()
local p1 =GetObjectiveState ('qwert1',PLAYER_1);
local p =GetObjectiveState ('qwert2',PLAYER_1);
local opr = 9
local opr3 = 13
local p2 = GetObjectiveState ('qwert3', 1);
if p2 == OBJECTIVE_COMPLETED then
* opr= opr+1
* if p2 == OBJECTIVE_COMPLETED then
* * opr= opr3+1
* * if p1 ==OBJECTIVE_COMPLETED and GetDate(DAY_OF_WEEK ) == 6
* * * then
* * * AddObjectCreatures('gar_1', opr, 15);
* * * AddObjectCreatures('gar_2', opr, 15);
* * * AddObjectCreatures('gar_3', opr, 15);
* * * AddObjectCreatures('gar_4', opr, 15);
* * elseif p ==OBJECTIVE_COMPLETED and GetDate(DAY_OF_WEEK ) == 5
* * then
* * AddObjectCreatures('gar_1', opr3, 3);
* * AddObjectCreatures('gar_2', opr3, 3);
* * AddObjectCreatures('gar_3', opr3, 3);
* * AddObjectCreatures('gar_4', opr3, 3);
* * end;
end;
Trigger(NEW_DAY_TRIGGER, 'demon');


It seems like I wrote everything correctly, but the quest is completed, the 5th day comes, the monks don't appear, the 6th day comes, and the angels don't appear either.

Script to fail the quest if the peasants are missing:
function peas_surv()
while 1 do
if GetHeroCreatures("Hero Name", CREATURE_PEASANT)<4 then
SetObjectiveState("Scripted quest name", OBJECTIVE_FAILED, PLAYER_1);
break
end;
sleep(1)
end;
end;


And in the place where you need to start checking for the presence of peasants, insert the line
startThread(peas_surv)

Regarding the second question: can you explain what should happen according to the script? That is, what is being checked? Because it's not clear why there are 2 nested checks for the completion of the 'p2' quest in a row...

Another question: do you have other functions that are launched by the daily trigger?

The army should be added on the 5th day from the start of the game, or on the 5th (and 6th) day of the week?

What does the console complain about?

I won't be able to answer until I understand what and why should happen.
In reply to Лоли Никита
User Avatar
5 years ago
Auto-translated
Loli Nikita
Please help me with a script. I need peasants to join my hero, a quest to appear, and the goal is to lead them to a specific point and complete the quest there, after which they should disappear from the hero's party. If the peasants die in battle, the quest should fail. (I can more or less write the initial stages, but I don't know how to make the quest fail after the peasants die.)
First, place the peasants on the map.
Then, use this command:
SetObjectEnabled ('Peasant', nil);

On the map, draw a region to which the peasants must be led, and let's call it 'Region'.

---script for joining peasants---

function peasants()
---your code---
AddHeroCreatures ('hero_name', 1, 4);
SetObjectiveState ('quest_name', OBJECTIVE_ACTIVE, PLAYER_1);
RemoveObject ('Peasant');
end;

Trigger(OBJECT_TOUCH_TRIGGER, 'Peasant','peasants');

Now, the script for when you need to say goodbye to the peasants:

function RegionF()
---your code---
if GetObjectiveState ('quest_name', 1) == OBJECTIVE_ACTIVE then GetHeroCreatures('hero_name', 1)==4 then
RemoveHeroCreatures('hero_name', 1, 4);
SetObjectiveState ('quest_name',OBJECTIVE_COMPLETED, PLAYER_1);
Trigger (REGION_ENTER_AND_STOP_TRIGGER, 'Region', nil);
end;
end;

Trigger (REGION_ENTER_AND_STOP_TRIGGER, 'Region', 'RegionF');

Regarding the peasants dying in battle and the subsequent quest failure, I think combat scripts are needed, but unfortunately, I don't know them.

Above, }{0TT@6bI4 suggested a better version;)
User Avatar
5 years ago
Auto-translated
Actually, according to Loli, Nikita could have organized what you suggested himself. And it would be better to place the "farewell to peasants" script inside an additional data processing thread. Then it will be possible to simultaneously monitor the situation, whether peasants are present or whether peasants have died.
User Avatar
5 years ago
Auto-translated
Good evening, I'm trying to write a message containing an error that appears in the Map Script Editor program, but the forum keeps deleting one of the words in the message:confused:
In reply to Navkratis
User Avatar
5 years ago
Auto-translated
Navkratis
Good evening, I'm trying to post a message about an error that appears in the Map Script Editor program, but the forum keeps deleting one of the words in the message:confused:
Hmm... you could take a screenshot, or attach a file with the error...
In reply to Fallenru
User Avatar
5 years ago
Auto-translated
I'll try this: https://ibb.co/zfjrBSj

Without the script for the seventh day, everything works perfectly, but no matter how many times I try to reduce or add "end" to the scripts for the sixth and seventh days, the problem is not fixed.
User Avatar
5 years ago
Auto-translated
elseif can only be used within an if block. Count the number of if-then, elseif-then blocks – each should have only 1 end. At the end of the function block, there should also be an end; (eof) means 'end of function', so one end is missing. Look, the top elseif is terminated by the nearest end, the next end (second from the top) then belongs either to some if block outside this elseif, or it is the end of the function. Then try adding this end before the line that triggers the new day.

In principle, to avoid such confusion, you should, for example, put 2 spaces each time an if block starts. And in the content to be executed by the if, in addition to end, elseif, and then – also 2 spaces. Then the ends corresponding to the ifs will be on the same vertical line. This way, you can quickly determine where an end is missing.
In reply to }{0TT@6bI4
User Avatar
5 years ago
Auto-translated
Thank you for your help, but I haven't been able to make it work yet. I'll try again tomorrow. Or I'll just do without the trigger for the seventh day; everything works without it.

Added 10 hours and 37 minutes later
The situation is as follows: I replaced the "elseif" statements with more familiar "if" statements (based on one of my previous maps), and the program stopped complaining about errors, but the script for the seventh day still doesn't trigger. There are also no error messages in the console, and of course, this is not the only problem with the scripts. Thank you to the developers for making the map editor not for ordinary mortals, but for the chosen ones
In reply to Navkratis
User Avatar
5 years ago
Auto-translated
Navkratis
Added 10 hours 37 minutes ago
The situation is currently as follows: I replaced the elsafes with ifas that are more familiar to me (based on one of my previous maps), the program stopped complaining about errors, but the seventh-day script still doesn't trigger; no error messages appear in the console either, and of course, this isn't the only problem with the scripts. Thanks to the devs who made a map editor not for mere mortals, but for the chosen ones (crossed out) programmers :)
To help, it would be good to see a piece of code with these "elsafes" or "ifas" to understand what is happening and possibly spot the error and test it, but as they say, no one is forcing you to post your "code"* :)* This also applies to the other problems.

Statistics

Welcome our newest member: recijeb