SRL Archive - OSR Help

Cant assign DTM? o.O


m34tcode

2012-04-04 01:50:55

I cant seem to assign the result of DTMFromString to a variable for some reason. I assign the variable a number, assign a dtm over that variable and then recheck the variable, and it has the originally value i assigned it. Not the dtms value.

This is the code im using:


[LEFT][COLOR=#000000][B]function[/B][/COLOR] WithdrawTarget : Boolean;
[COLOR=#000000][B]var[/B][/COLOR]
ItemDTM : Integer;
TP, BankSlot : TPoint;
[COLOR=#000000][B]begin[/B][/COLOR]
Result := False;
DebugStr([COLOR=#000080]3[/COLOR],[COLOR=#0000FF]'In Func: WithdrawTarget'[/COLOR]);
DebugStr([COLOR=#000080]1[/COLOR],[COLOR=#0000FF]'Withdrawing'[/COLOR]);
[COLOR=#000000][B]if[/B][/COLOR] [COLOR=#000000][B]not[/B][/COLOR] BankScreen [COLOR=#000000][B]then[/B][/COLOR]
[COLOR=#000000][B]begin[/B][/COLOR]
DebugStr([COLOR=#000080]3[/COLOR],[COLOR=#0000FF]'Not in bank screen, exiting withdraw'[/COLOR]);
Exit;
[COLOR=#000000][B]end[/B][/COLOR];
ItemDTM := -[COLOR=#000080]3[/COLOR];

ItemDTM := GetDTM(MAPLE_LOG);[COLOR=#0000FF][B]{
case GetLogType of
MAPLE :
begin
writeln('found maple');
writeln(GetDTM(MAPLE_LOG));
case GetFletchMode of
CUT_BOWS, CUT_AND_STRING_BOWS :begin ItemDTM := GetDTM(MAPLE_LOG);end;
STRING_BOWS :
if GetSize = SIZE_LONG then
ItemDTM := GetDTM(MAPLE_UL)
else
ItemDTM := GetDTM(Maple_US);
end;
end;
end; }[/B][/COLOR]
[COLOR=#0000FF][B]// SetDTMName(ItemDTM,'ItemDTM');[/B][/COLOR]
writeln(ItemDTM);
[COLOR=#000000][B]if[/B][/COLOR] [COLOR=#000000][B]not[/B][/COLOR] FindDTM(ItemDTM,TP.x,TP.y,MBX1,MBY1,MBX2,MBY2) [COLOR=#000000][B]then[/B][/COLOR]
[COLOR=#000000][B]begin[/B][/COLOR]
DebugStr([COLOR=#000080]2[/COLOR],[COLOR=#0000FF]'Did not find your Logs/Unstrung bows in bank. You either ran'[/COLOR] +
[COLOR=#0000FF]' out, or did not have them at top of your bank.'[/COLOR]);
[COLOR=#0000FF][B]//Logout;[/B][/COLOR]
[COLOR=#0000FF][B]//NextPlayer(False);[/B][/COLOR]
[COLOR=#000000][B]end[/B][/COLOR] [COLOR=#000000][B]else[/B][/COLOR]
[COLOR=#000000][B]begin[/B][/COLOR]
DebugStr([COLOR=#000080]2[/COLOR],[COLOR=#0000FF]'Found the bankslot'[/COLOR]);
BankSlot := MSTPointToBankPoint(TP);
DebugStr([COLOR=#000080]5[/COLOR],[COLOR=#0000FF]'Var- BankSlot: '[/COLOR] + ToStr(BankSlot));
Result := Withdraw(BankSlot.x,BankSlot.y,[COLOR=#000080]0[/COLOR]);
[COLOR=#000000][B]end[/B][/COLOR];

FreeDTM(ItemDTM);
[COLOR=#000000][B]end[/B][/COLOR];
EDIT: of course i solved it the minute i posted… It was my getdtm not returning the dtm it generated.

Apparently if you attempt to assign an int a nil val, nothing happens… weird. didn't get a type mismatch either D=
[/LEFT]

ShawnjohnSJ

2012-04-04 02:08:43

Don't assign integers to nil, assign them to -1. Nil wasn't meant for that.

m34tcode

2012-04-04 07:44:18

No that's what I meant. Before result has a value, I rhink it is nil, beccause when I assibned itemdtm the result of getdtm nothing happened. That would only happen if getdtm returned nil, because item dtm would have a different value after the assignment otherwise.

Joe

2012-04-04 08:03:42

From: m34tcode
I cant seem to assign the result of DTMFromString to a variable for some reason. I assign the variable a number, assign a dtm over that variable and then recheck the variable, and it has the originally value i assigned it. Not the dtms value.

This is the code im using:


[LEFT][COLOR=#000000][B]function[/B][/COLOR] WithdrawTarget : Boolean;
[COLOR=#000000][B]var[/B][/COLOR]
ItemDTM : Integer;
TP, BankSlot : TPoint;
[COLOR=#000000][B]begin[/B][/COLOR]
Result := False;
DebugStr([COLOR=#000080]3[/COLOR],[COLOR=#0000FF]'In Func: WithdrawTarget'[/COLOR]);
DebugStr([COLOR=#000080]1[/COLOR],[COLOR=#0000FF]'Withdrawing'[/COLOR]);
[COLOR=#000000][B]if[/B][/COLOR] [COLOR=#000000][B]not[/B][/COLOR] BankScreen [COLOR=#000000][B]then[/B][/COLOR]
[COLOR=#000000][B]begin[/B][/COLOR]
DebugStr([COLOR=#000080]3[/COLOR],[COLOR=#0000FF]'Not in bank screen, exiting withdraw'[/COLOR]);
Exit;
[COLOR=#000000][B]end[/B][/COLOR];
ItemDTM := -[COLOR=#000080]3[/COLOR];

ItemDTM := GetDTM(MAPLE_LOG);[COLOR=#0000FF][B]{
case GetLogType of
MAPLE :
begin
writeln('found maple');
writeln(GetDTM(MAPLE_LOG));
case GetFletchMode of
CUT_BOWS, CUT_AND_STRING_BOWS :begin ItemDTM := GetDTM(MAPLE_LOG);end;
STRING_BOWS :
if GetSize = SIZE_LONG then
ItemDTM := GetDTM(MAPLE_UL)
else
ItemDTM := GetDTM(Maple_US);
end;
end;
end; }[/B][/COLOR]
[COLOR=#0000FF][B]// SetDTMName(ItemDTM,'ItemDTM');[/B][/COLOR]
writeln(ItemDTM);
[COLOR=#000000][B]if[/B][/COLOR] [COLOR=#000000][B]not[/B][/COLOR] FindDTM(ItemDTM,TP.x,TP.y,MBX1,MBY1,MBX2,MBY2) [COLOR=#000000][B]then[/B][/COLOR]
[COLOR=#000000][B]begin[/B][/COLOR]
DebugStr([COLOR=#000080]2[/COLOR],[COLOR=#0000FF]'Did not find your Logs/Unstrung bows in bank. You either ran'[/COLOR] +
[COLOR=#0000FF]' out, or did not have them at top of your bank.'[/COLOR]);
[COLOR=#0000FF][B]//Logout;[/B][/COLOR]
[COLOR=#0000FF][B]//NextPlayer(False);[/B][/COLOR]
[COLOR=#000000][B]end[/B][/COLOR] [COLOR=#000000][B]else[/B][/COLOR]
[COLOR=#000000][B]begin[/B][/COLOR]
DebugStr([COLOR=#000080]2[/COLOR],[COLOR=#0000FF]'Found the bankslot'[/COLOR]);
BankSlot := MSTPointToBankPoint(TP);
DebugStr([COLOR=#000080]5[/COLOR],[COLOR=#0000FF]'Var- BankSlot: '[/COLOR] + ToStr(BankSlot));
Result := Withdraw(BankSlot.x,BankSlot.y,[COLOR=#000080]0[/COLOR]);
[COLOR=#000000][B]end[/B][/COLOR];

FreeDTM(ItemDTM);
[COLOR=#000000][B]end[/B][/COLOR];
EDIT: of course i solved it the minute i posted… It was my getdtm not returning the dtm it generated.

Apparently if you attempt to assign an int a nil val, nothing happens… weird. didn't get a type mismatch either D=
[/LEFT]


whats with all the SRL tags on your script? (, ,[left])? you don't need these if you jsut put simba tags (or scar tags) on your script.
If i'm wrong then this is a learning moment for me.

m34tcode

2012-04-04 08:30:27

Its the crappy new reply system. Its a fail wysiwyg editor. If you edit you post you have to redo the post or it screws it all up. It removes simba tags and just styles the text =\