[H5 EDITOR] Troubleshooting topic
-
- Pixie
- Posts: 100
- Joined: 23 May 2010
- Location: Texas
-
- Pixie
- Posts: 100
- Joined: 23 May 2010
- Location: Texas
A new puzzling problem. I have written some code with the gracious help of Franzy.
The problem that I am having is that the code DOES NOT WORK on one specfic hero, Findan, on one specific map(Amontillado). I spent several hours trying debug on my desk top, since I am unable to access the console on this lap top. The time was not well spent, as I entered the code with Findan on another map and THE CODE WORKS.
I then added another hero to the Amontillado map and ran the code again. Similar results, nothing altered with Findan, but the newly added hero was successfully altered.
Now why is Findan able to be altered one one map but not anther?
The problem that I am having is that the code DOES NOT WORK on one specfic hero, Findan, on one specific map(Amontillado). I spent several hours trying debug on my desk top, since I am unable to access the console on this lap top. The time was not well spent, as I entered the code with Findan on another map and THE CODE WORKS.
I then added another hero to the Amontillado map and ran the code again. Similar results, nothing altered with Findan, but the newly added hero was successfully altered.
Now why is Findan able to be altered one one map but not anther?
-
- Pixie
- Posts: 100
- Joined: 23 May 2010
- Location: Texas
Maybe I wasn't clear, but the code worked on ALL other heroes except Findan. The code worked on Findan on other maps, just not this one. Well I didn't solve the problem, but was able to get the code to work on Findan by making Findan as a town garrison hero instead of a field object.
I knew you would figure out the answer to my other question, checing the primary skill should work.
I knew you would figure out the answer to my other question, checing the primary skill should work.
-
- Pixie
- Posts: 100
- Joined: 23 May 2010
- Location: Texas
New question:
I have some code to execute when a town is captured
function towncapture(oldowner, newowner, herotowncapture)
print("Enter town capture funtion");
if GetCurrentPlayer() == numhumanplayer then
print(oldowner);
print(newowner);
print(herotowncapture);
GiveArtefact(herotowncapture, artefactID);
print("Leave town capture function");
end;
end;
Trigger(OBJECT_CAPTURE_TRIGGER, "townname", "towncapture");
The print statements "help" me through the debugging. Using the GetObjectOwner("townname"); before and after the town is captured indicates in this case 0 and 1---so the townname is captured. However, NONE of the print statements appear in the console. It seems like the function never activated.
The documentation indicates that:
One or more parameters can follow the even type, determining, the events of which of the ingame
objects have to be handled. The number and meaning of these parameters depend on the
even type:
for OBJECT_CAPTURE_TRIGGER and OBJECT_TOUCH_TRIGGER--the on-map object’s name
When the trigger works, the following parameters are sent to the handler function:
OBJECT_CAPTURE_TRIGGER--the old owner of the object, the new owner of the object, the name
of the hero who captured it (if any), and the name of the object itself
Any suggestins?
I have some code to execute when a town is captured
function towncapture(oldowner, newowner, herotowncapture)
print("Enter town capture funtion");
if GetCurrentPlayer() == numhumanplayer then
print(oldowner);
print(newowner);
print(herotowncapture);
GiveArtefact(herotowncapture, artefactID);
print("Leave town capture function");
end;
end;
Trigger(OBJECT_CAPTURE_TRIGGER, "townname", "towncapture");
The print statements "help" me through the debugging. Using the GetObjectOwner("townname"); before and after the town is captured indicates in this case 0 and 1---so the townname is captured. However, NONE of the print statements appear in the console. It seems like the function never activated.
The documentation indicates that:
One or more parameters can follow the even type, determining, the events of which of the ingame
objects have to be handled. The number and meaning of these parameters depend on the
even type:
for OBJECT_CAPTURE_TRIGGER and OBJECT_TOUCH_TRIGGER--the on-map object’s name
When the trigger works, the following parameters are sent to the handler function:
OBJECT_CAPTURE_TRIGGER--the old owner of the object, the new owner of the object, the name
of the hero who captured it (if any), and the name of the object itself
Any suggestins?
-
- Pixie
- Posts: 100
- Joined: 23 May 2010
- Location: Texas
I tried and succeded with an object other than a town--in this case a military fortressbkknight2602 wrote:New question:
I have some code to execute when a town is captured
function towncapture(oldowner, newowner, herotowncapture)
print("Enter town capture funtion");
if GetCurrentPlayer() == numhumanplayer then
print(oldowner);
print(newowner);
print(herotowncapture);
GiveArtefact(herotowncapture, artefactID);
print("Leave town capture function");
end;
end;
Trigger(OBJECT_CAPTURE_TRIGGER, "townname", "towncapture");
The print statements "help" me through the debugging. Using the GetObjectOwner("townname"); before and after the town is captured indicates in this case 0 and 1---so the townname is captured. However, NONE of the print statements appear in the console. It seems like the function never activated.
The documentation indicates that:
One or more parameters can follow the even type, determining, the events of which of the ingame
objects have to be handled. The number and meaning of these parameters depend on the
even type:
for OBJECT_CAPTURE_TRIGGER and OBJECT_TOUCH_TRIGGER--the on-map object’s name
When the trigger works, the following parameters are sent to the handler function:
OBJECT_CAPTURE_TRIGGER--the old owner of the object, the new owner of the object, the name
of the hero who captured it (if any), and the name of the object itself
Any suggestins?
function towncapture(oldowner, newowner, herotowncapture)
print("Enter town capture funtion");--Printed this time
if GetCurrentPlayer() == numhumanplayer then
print(oldowner);--Printed Nil (On a second attempt deleted oldowner parameter and function was entered but not executed properly)
print(newowner);--Printed 1
print(herotowncapture);--Printed Mardigo
GiveArtefact(herotowncapture, artefactID);--Artefact given to Mardigo
print("Leave town capture function");--Printed this time
end;
end;
Trigger(OBJECT_CAPTURE_TRIGGER, "havenfortress", "towncapture");
So the function does work, just not on a town.
Any other suggestions?
The trigger works with town alright, problem is elsewhere. You see, when a hero captures the town he automatically enters it. And when a hero enters a town, he is removed from the map and the list of currect objects. So you can not enteract with him, that's why giving him an artifact doesn't work . You need to find a workaround
-
- Pixie
- Posts: 100
- Joined: 23 May 2010
- Location: Texas
Well perhaps another Ubisoft glitch, as I continued the map and lo behold, the code worked on all towns, except two. I rechecked the names and spellings were correct, so I'm not sure what happened.
I thought about another piece of code and stumped for the time being:
HeroName = "True";
function deployhero()
for i = 0 to length(playernames) - 1 do
if GetPlayerStat(playernames, STAT_EXPERIENCE) >= 15000 then
GetObjectPosition(playernames);
if HeroName == "True" then
DeployReserveHero("Orrin", --I want to deploy 3 squares north and 3 squares east of playernames
HeroName = "False";
end;
end;
end;
end;
I tried putting x + 3, y + 3, z after the name:
DeployReserveHero("Orrin",x + 3, y + 3, z);
The thought woud be the handler would have the position as an x, y, z from the GetObjectPosition
That didn't work and the error message "trying to perform arithmetic on a Nil value".
Any thoughts on how to access the handlers "position" and use it in the DeployReserveHero function?
I thought about another piece of code and stumped for the time being:
HeroName = "True";
function deployhero()
for i = 0 to length(playernames) - 1 do
if GetPlayerStat(playernames, STAT_EXPERIENCE) >= 15000 then
GetObjectPosition(playernames);
if HeroName == "True" then
DeployReserveHero("Orrin", --I want to deploy 3 squares north and 3 squares east of playernames
HeroName = "False";
end;
end;
end;
end;
I tried putting x + 3, y + 3, z after the name:
DeployReserveHero("Orrin",x + 3, y + 3, z);
The thought woud be the handler would have the position as an x, y, z from the GetObjectPosition
That didn't work and the error message "trying to perform arithmetic on a Nil value".
Any thoughts on how to access the handlers "position" and use it in the DeployReserveHero function?
-
- Pixie
- Posts: 100
- Joined: 23 May 2010
- Location: Texas
Town turning to ruins
Hello,
working on my 3rd map I want to change a town into town ruins after its defeat.I'm sure I've seen it in some map but can't remember which one.
I suppose it is a scripting function but I suck when it comes down to that.
I also suppose it could be somewhere among the 40 pages of that thread, I tried looking, but failed miserably.
So any help would be great, thank you.
working on my 3rd map I want to change a town into town ruins after its defeat.I'm sure I've seen it in some map but can't remember which one.
I suppose it is a scripting function but I suck when it comes down to that.
I also suppose it could be somewhere among the 40 pages of that thread, I tried looking, but failed miserably.
So any help would be great, thank you.
-
- Pixie
- Posts: 100
- Joined: 23 May 2010
- Location: Texas
Random town code
Is there a way to code adding respective creatures to random towns(ie peasant to random generated Haven, familiar to to a random generated Inferno etc)? I have done this with specific towns but random???
Re: Random town code
Just use the custom Town name I believe.. I could be wrong thoughbkknight2602 wrote:Is there a way to code adding respective creatures to random towns(ie peasant to random generated Haven, familiar to to a random generated Inferno etc)? I have done this with specific towns but random???
-
- Pixie
- Posts: 100
- Joined: 23 May 2010
- Location: Texas
Re: Random town code
Thanks but that doesn't work.meows wrote:Just use the custom Town name I believe.. I could be wrong thoughbkknight2602 wrote:Is there a way to code adding respective creatures to random towns(ie peasant to random generated Haven, familiar to to a random generated Inferno etc)? I have done this with specific towns but random???
-
- Pixie
- Posts: 100
- Joined: 23 May 2010
- Location: Texas
Another coding issue
Ok, here is another coding issue.
I have some code relating to a TRIGGER_OBJECT_TOUCH and it can be visited many times, the code works great, but I want to write into the code that any hero may only visit it once per week (like a stable or fountain).
playernames = GetPlayerHeroes(numhumanplayer);--numhumanpalyer is the player number of the human
if mod(GetDate(DAY),7) == 0 then
for i = 0, length(playernames) do
herotouch(playernames) = false
end;
end;---To clear a visit flag
function object_touched(herotouch)
--Do some things
herotouch(heroname) = true--To add a visit flag
end;
Trigger(OBJECT_TOUCH_TRIGGER, "object_touched", "message_box_object_touched");
This does not work, I get an error last read "="--In the for loop expected ";"
Any ideas?
I have some code relating to a TRIGGER_OBJECT_TOUCH and it can be visited many times, the code works great, but I want to write into the code that any hero may only visit it once per week (like a stable or fountain).
playernames = GetPlayerHeroes(numhumanplayer);--numhumanpalyer is the player number of the human
if mod(GetDate(DAY),7) == 0 then
for i = 0, length(playernames) do
herotouch(playernames) = false
end;
end;---To clear a visit flag
function object_touched(herotouch)
--Do some things
herotouch(heroname) = true--To add a visit flag
end;
Trigger(OBJECT_TOUCH_TRIGGER, "object_touched", "message_box_object_touched");
This does not work, I get an error last read "="--In the for loop expected ";"
Any ideas?
-
- Pixie
- Posts: 100
- Joined: 23 May 2010
- Location: Texas
New coding question
I have a map in which the player has several faction choices, as with most games. I tried to tweak the game a bit by selecting a certain town and using the fllowing code (piece) to transform the town to the selected faction and then to transfer ownership to the selected faction. Here are the bits that are pertainent.
numhumanplayer = GetCurrentPlayer();
if numhumanplayer == 1 then
TransformTown("Town1", 5);
elseif numhumanplayer == 2 then
TransformTown("Town1", 0);
elseif numhumanplayer == 3 then
TransformTown("Town1", 1);
elseif numhumanplayer == 4 then
TransformTown("Town1", 6);
elseif numhumanplayer == 5 then TransformTown("Town1", 2);
elseif numhumanplayer == 6 then
TransformTown("Town1", 7);
elseif numhumanplayer ==7 then
TransformTown("Town1", 3);
SetObjectOwner("Town1", 7);
elseif numhumanplayer == 8 then
TransformTown("Town1", 4);
end;
I'm currently playing player 7, so that is why the code is more complete in that block. The question pertains to the set owner statement. The town is transformed but the code does not shift ownership. I tried it on some other towns(without transforming them) and that worked. So why does the set owner not work on the transformed town?
numhumanplayer = GetCurrentPlayer();
if numhumanplayer == 1 then
TransformTown("Town1", 5);
elseif numhumanplayer == 2 then
TransformTown("Town1", 0);
elseif numhumanplayer == 3 then
TransformTown("Town1", 1);
elseif numhumanplayer == 4 then
TransformTown("Town1", 6);
elseif numhumanplayer == 5 then TransformTown("Town1", 2);
elseif numhumanplayer == 6 then
TransformTown("Town1", 7);
elseif numhumanplayer ==7 then
TransformTown("Town1", 3);
SetObjectOwner("Town1", 7);
elseif numhumanplayer == 8 then
TransformTown("Town1", 4);
end;
I'm currently playing player 7, so that is why the code is more complete in that block. The question pertains to the set owner statement. The town is transformed but the code does not shift ownership. I tried it on some other towns(without transforming them) and that worked. So why does the set owner not work on the transformed town?
Who is online
Users browsing this forum: Semrush [Bot] and 0 guests