Majesty Gold HD

Majesty Gold HD

Customize Majesty!
Create and upload new Quests and Mods for Majesty HD!
Parameter Mismatch when passing non-agent paramenters in RunThread and NewThread
For example

Function Test (agent thisagent) declare integer number; string text; agent AIRootAgent; begin AIRootAgent = $RetrieveAGent ("GPLAIRoot"); number = 100; text = "Goblin_Fighter"; AIRootAgent's "SpecialSpawnScript" = $SpawnMonsters; $RunThread (AIRootAgent's "SpecialSpawnScript", 0, thisagent, number, text); end /////////////////////////////////////// Function SpawnMonsters (agent thisagent, integer number, string text) declare begin $SpawnUnit (thisagent, text, number); end

With the recent update, it always returns an error code of "Parameter Type Mismatch" when it shouldn't. This may be related to the bug with sign messages.
< >
Showing 1-7 of 7 comments
Enerril 16 28 Jan, 2022 @ 1:19am 
Try to recheck/narrow down the error. I have no problem running this code and it is similar to yours
function brt1(agent thisAgent,integer k) declare begin thisAgent's "AI_ActualBuildThread1"=$initb1; $RunThread( thisAgent's "AI_ActualBuildThread1", $rn(400),thisAgent, ($ListMember(thisAgent's "standart_buildings",k)), $cbuildSpot(thisAgent,$ListMember(thisAgent's "standart_buildings",k))); end function initb1(agent thisAgent,string b, coordinate c) declare begin if ($GetX(c) != 0 && $GetY(c) != 0) begin $SpawnUnit(thisAgent, b, c); $killthread(thisagent's "AI_ActualBuildThread1"); end end
Last edited by Enerril; 28 Jan, 2022 @ 1:22am
Enerril 16 28 Jan, 2022 @ 1:25am 
Actually if you get error with SpawnUnit function then I can't help you. I made code above for the reason that I also had problem with directly relaying parameters to SpawnUnit function.
Dracoceros 11 28 Jan, 2022 @ 12:35pm 
I'm not getting an error with the spawn unit function, it's simply the parameter mismatch
VikesRule 40 28 Jan, 2022 @ 3:20pm 
Just guessing here, but it might be because you're using the SpecialSpawnScript for this purpose, which is an existing function in AIRoot - try using a custom function that you add to AIRoot and see if that works.
Enerril 16 28 Jan, 2022 @ 4:54pm 
It appears to be a restriction to reuse function holders from prototype unit.

if you modify to use another function holder like this then code works okay AIRootAgent's "SpecialSpawnScript2" = $SpawnMonsters; //added 2 $RunThread (AIRootAgent's "SpecialSpawnScript2", 0, thisagent, number, text);

I assume you used "SpecialSpawnScript" in your code earlier and then reassigned it for function "Test". That is the reason it didn't work
Dracoceros 11 29 Jan, 2022 @ 12:34pm 
That can't be right because there already is a specialspawnscript2 in GPLMx
Enerril 16 29 Jan, 2022 @ 6:10pm 
When you start mod quest both prototype function holdfers exist but empty (SpecialSpawnScript1 and SpecialSpawnScript2). they are sorta like delegates.

You can assign any of your function to these prototype function holders. What I learned testing your code is that when once you assign your function to prototype function holder you can't reassign another your function to the same prototype function holder. Because that will cause that error: Parameter Type Mismatch

So simply creating new function holders in prototype for every your function should be enough to avoid this error. Didn't test extensively. Enough to know for me
< >
Showing 1-7 of 7 comments
Per page: 1530 50