ManiaScript Bug ? [solved]
Posted: 08 Sep 2011, 20:43
Here's my code, I'll explain line by line:
- 1) remove everything, then find the Base Coord:
- 2) Put a block on <3, BaseGround, 0>
- 3) Test where I've put the block: there should be something. Thus B should not be Null. Thus log(B == Null); should give at least once "False", but nope:
For the people who want to test and explain if it's a bug or if I'm wrong, here's the full code, just copy/paste it'll work:
Don't forget to launch the debugger with CTRL-G when in script mode!
- 1) remove everything, then find the Base Coord:
Code: Select all
declare CBlockModel BMArenaSimpleBase;
BMArenaSimpleBase <=> BlockModels["ArenaSimpleBase"];
RemoveAllBlocksAndTerrain();
declare CoordYBaseSol = GetBlockGroundHeight(
BMArenaSimpleBase, 19, 19, ::CardinalDirections::East);
Code: Select all
PlaceBlock(BlockModels["RoadRaceToArenaMirror"], <3, CoordYBaseSol, 0>, ::CardinalDirections::East);
Code: Select all
declare CGameCtnBlock B;
B = GetBlock(<3, CoordYBaseSol-2, 0>);
log(B == Null);
B = GetBlock(<3, CoordYBaseSol-1, 0>);
log(B == Null);
B = GetBlock(<3, CoordYBaseSol, 0>);
log(B == Null);
B = GetBlock(<3, CoordYBaseSol+1, 0>);
log(B == Null);
B = GetBlock(<3, CoordYBaseSol+2, 0>);
log(B == Null);
Code: Select all
#RequireContext CGameCtnEditorPluginScriptHandler
#Include "MapUnits" as MapUnits
#Include "MathLib" as MathLib
Text CreateManialink()
{
declare MLText =
"""
<script><!--
Void OnPlaceBlocks()
{
declare Boolean StartPlacing for Page;
if(!StartPlacing) {
StartPlacing = True;
}
}
main ()
{
while(True) {
yield;
foreach(Event in PendingEvents) {
if(Event.Type == CGameManialinkScriptEvent::Type::MouseClick) {
if (Event.ControlId == "PlaceQuad") {
OnPlaceBlocks();
}
}
}
}
}
--></script>
<frame>
<quad id="PluginTitleQuad" posn="-138 82 1" sizen="42 13" halign="center" valign="center" style="Bgs1InRace" substyle="BgTitle3_1"/>
<label id="PluginTitleLabel" text="Labyz" posn="-138 82 1" halign="center" valign="center" style="TextTitle3"/>
<quad id="PluginQuad" posn="-138 76 1" sizen="38 22" halign="center" valign="top" style="Bgs1" substyle="BgList" ScriptEvents="1"/>
<quad id="PlaceQuad" posn="-138 60 4" sizen="30 6" halign="center" valign="center" style="Bgs1InRace" substyle="BgCard" ScriptEvents="1"/>
<label id="PlaceLabel" text="Click me" posn="-138 60 4" halign="center" valign="center" style="TextButtonSmall" textsize="2"/>
</frame>
""";
return MLText;
}
Void PlaceBlocks()
{
declare CBlockModel BMArenaSimpleBase;
BMArenaSimpleBase <=> BlockModels["ArenaSimpleBase"];
RemoveAllBlocksAndTerrain();
declare CoordYBaseSol = GetBlockGroundHeight(
BMArenaSimpleBase, 19, 19, ::CardinalDirections::East);
declare CGameCtnBlock B;
PlaceBlock(BlockModels["RoadRaceToArenaMirror"], <3, CoordYBaseSol, 0>, ::CardinalDirections::East);
B = GetBlock(<3, CoordYBaseSol-2, 0>);
log(B == Null);
B = GetBlock(<3, CoordYBaseSol-1, 0>);
log(B == Null);
B = GetBlock(<3, CoordYBaseSol, 0>);
log(B == Null);
B = GetBlock(<3, CoordYBaseSol+1, 0>);
log(B == Null);
B = GetBlock(<3, CoordYBaseSol+2, 0>);
log(B == Null);
}
main()
{
declare Boolean StartPlacing for ManialinkPage;
ManialinkText = CreateManialink();
while(True) {
yield;
if(StartPlacing) {
PlaceBlocks();
StartPlacing = False;
}
}
}