Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
5 years ago
Auto-translated
Comrades, I have a question. I need a trigger for a new day to count down 7 days from the current day and only then execute the function, but it counts down to the 7th day of the week and executes the function. --- Trigger(NEW_DAY_TRIGGER, "Training_camp1") function Training_camp1() if GetDate(DAY) == DAY+7 then MessageBox("/Maps/SingleMissions/No_Mans_Lands/Text_Training_Camp1_is_over.txt") Trigger(OBJECT_TOUCH_TRIGGER, "tower1", "camp_1quest_complete"); end; end;
User Avatar
5 years ago
Auto-translated
I don't understand your idea. If you need it to count down 7 days from a specific moment, store the date of that moment in a variable and compare it daily. If you simply need 7 days from the start of the game, use GetDate(DAY)==8.
In reply to }{0TT@6bI4
User Avatar
5 years ago
Auto-translated
}{0TT@6bI4
I don't understand your idea. If you need it to count down 7 days from a specific moment, then remember the date of that moment in a variable and compare it daily. If you just need 7 days from the start of the game, then use GetDate(DAY)==8.
The problem is that I don't know how to store the date in a variable.
User Avatar
5 years ago
Auto-translated
...Script event
Shift=GetDate(DAY)
...
function TrainingCamp_1() --I recommend naming it NewDay
if GetDate(DAY) == Shift+7 then
Code
end
end
In reply to }{0TT@6bI4
User Avatar
5 years ago
Auto-translated
}{0TT@6bI4
...Scripted event
Shift=GetDate(DAY)
...
function TrainingCamp_1() --I recommend naming it NewDay
if GetDate(DAY) == Shift+7 then
Code
end
end
I actually tried to do that, but I made a mistake by entering the variable in the wrong place, and it counted from the beginning of the game instead of from the event. Thank you very much!
In reply to }{0TT@6bI4
User Avatar
5 years ago
Auto-translated
}{0TT@6bI4
If you replace it with nil, does the error "Value was NIL when getting global with name false" still appear? Then the error isn't here.
No, a different error appears. Here's the script: (image 1)
function Mess()
SetObjectEnabled("z", nil);
SetMonsterSelectionType("z", 0);
end;
Trigger(REGION_ENTER_WITHOUT_STOP_TRIGGER, "podskazka", "Mess");

Another error was also found: (image 2)
function final()
TransformTown("pop", 0);
end;

I understand that I have many errors and requests for help, but I want to create a map that will be better than my previous ones, so please help me understand the scripts...
Attachments 2
2 files attached • Total size: 61.6 KB
In reply to Flame Crystal
User Avatar
5 years ago
Auto-translated
Flame Crystal
No, another error appears. Here's the script: (image 1)
function Mess()
SetObjectEnabled("z", nil);
SetMonsterSelectionType("z", 0);
end;
Trigger(REGION_ENTER_WITHOUT_STOP_TRIGGER, "podskazka", "Mess");

Another error was also found: (image 2)
function final()
TransformTown("pop", 0);
end;

I understand that I have many errors and requests for help, but I want to create a map that will be better than the previous ones, so please help me understand the scripts...

I know how to solve your problem from image 1. Put a pause between the two commands like this:
SetObjectEnabled("z", nil);
sleep(1)
SetMonsterSelectionType("z", 0);
end;
User Avatar
5 years ago
Auto-translated
Isn't it clear from the English text what the game wants?)) Error 1: the creature is not disabled. But the line exists. Just add a simple `sleep(1)`, and we can avoid the check. Also, I suggest giving more meaningful names than "z".
The second error clearly indicates that there is no city named "pop" suitable for transformation.
In reply to }{0TT@6bI4
User Avatar
5 years ago
Auto-translated
}{0TT@6bI4

The second error clearly hints that there is no "pop" town suitable for transformation.
The most interesting thing is that the town exists, but it doesn't want to transform.
User Avatar
5 years ago
Auto-translated
Make sure you have the script name spelled correctly. For example, 'p' and 'р', 'o' and 'о' are different letters! I mean, the keyboard layout. So, it's better to give the town a script name like "Town" or something similar.
In reply to }{0TT@6bI4
User Avatar
5 years ago
Auto-translated
}{0TT@6bI4
Make sure you have the script name written correctly. For example, p and р, o and о are different letters! I mean, the keyboard layout. So, it's better to give the city a script name like "Town" or something similar.
I have already fixed the error. Apparently, "destroyed" cities are not considered "cities." I replaced the "destroyed" human castle with a necromancer's castle, and it worked.
User Avatar
5 years ago
Auto-translated


Then I will gladly remind you that the type of objects is determined not by their appearance and location in the editor, but by the Shared type. I'm glad you figured out the problem.
In reply to inQizitOr
User Avatar
5 years ago
Auto-translated
I'm having trouble figuring out how to manage a player's resources if I don't know their quantity in advance. For example, a player approaches an object, and the object takes 500 gold from them. I only found scripts for determining the current amount of resources, but nothing more. Thank you in advance.
User Avatar
5 years ago
Auto-translated
Following the logic, it is very easy to write such a function.
function AddPlayerResource(pl, res, delta)
if GetPlayerResource(pl, res)+delta>=0 then
SetPlayerResource(pl, res, GetPlayerResource(pl, res)+delta)
else _ERRORMESSAGE("Resource quantity cannot be negative!")
end
end

In principle, you can write every time: set the resource to CurrentResourceAmount+Addition. This is obvious. But it is better to wrap it up and make it short: AddPlayerResource(1, GOLD, -5000)

There is also a function AddResource("HeroName", ResourceID, Delta)
Simulates a hero picking up a resource; the delta will be added to the current amount, and a message with an icon and the amount received will be displayed from the hero.
User Avatar
5 years ago
Auto-translated
Good day, I had an idea for its implementation: is it possible to close the fog of war in a specific location using scripts? I couldn't find anything similar in the documentation.

Statistics

Welcome our newest member: recijeb