SRL Archive - FAQ

Forms in simba


almost

2010-11-19 01:20:13

First off, hey everyone I haven't dropped by here in a very long time =)

I've been making a new script that I won't say anything about until it is released, but the calculations were getting huge and going slow using scar.
So I would like to give simba a shot.

My script runs off a form.
But how do you do a form in simba?
CreateForm is no longer a procedure and I don't know what to replace it with.
Also many other things are gone that I need such as CopyCanvas and GetBitmapCanvas.

Also I just downloaded what I thought was the newest version and it says on startup "Current version: -1. Latest version: 3"

TomTuff

2010-11-19 01:25:38

ALMOST!!! HI!!! I remember you, idk if you'll remember me.

Also, sorry, I can't really offer you help :(

almost

2010-11-19 01:26:38

Hey!!!!
Did you used to have a different name?

TomTuff

2010-11-19 01:28:37

No but i used to be in Lance's cc and my old acc might be on your friends list (check for hyenaslayer)

Runescape Pro

2010-11-19 01:31:10

I would also LOVE to see how a form in simba is done. Please and thank you. :)

almost

2010-11-19 01:38:34

Ohhhh yahhhh I definitely remember you now I used to talk to you in Rs hahaa

And I'm assuming forms can be made in simba just because the type TForm is still in it, along with all the other things like Labels and Edits.
Has no one made one?…

Also I'm a little disappointed after comparing the speed to SCAR.
Simba is actually a little slower for me.
But I'll have to see what I can do with writing extensions (I think those are like writing a plugin for scar right?)

mormonman

2010-11-19 01:40:21

Here you go, this is for the script I have been working on.

TomTuff

2010-11-19 01:41:01

From: almost
Ohhhh yahhhh I definitely remember you now I used to talk to you in Rs hahaa

And I'm assuming forms can be made in simba just because the type TForm is still in it, along with all the other things like Labels and Edits.
Has no one made one?…


Check out IceFire's runecrafter script. It uses a form (a rather complex form, at that). You may be able to derive how to do it from there.

Edit: Extensions aren't like plugins. plugins are plugins ;) extensions are used for custom add on features, like MSI's player remote, Nielsie95's CRov and dtm editer, the paster extension, etc.

Runescape Pro

2010-11-19 01:43:03

Thanks for that morman. This might be a little to much to ask but I'm wondering if you could do me a favor and comment most of the lines to tell me what they do. I never understood forms. Or just comment the lines that YOU think will help me the most in making a form with simba. Please and thank you. ;)

mormonman

2010-11-19 01:49:51

The most important part is this:

procedure doForm;
var
i, h: Integer;
begin
form := TForm.Create(nil);//creates the form
form.Position := poDesktopCenter;
form.Width := 375;
form.Height := 345;
form.Caption := 'Noob Powerfighter';
form.Color := clWhite;
form.BorderStyle := bsSingle;
form.ShowModal;//shows the form
form.Free;//frees the object so it doesn't rape your memory

procedure PlayerForm;
var
v : TVariantArray;
begin;
ThreadSafeCall('doForm', v);
//this function allows your form to run without
//throwing crazy errors and messing you over hardcore(not really).
//Its always smart to call something "safely".
end;

The rest is the same as forms in scar.

Runescape Pro

2010-11-19 01:59:45

Thank you sir. I'm going to attempt to make a form for my script now.

almost

2010-11-19 02:07:56

Awesome mormonman.
Now I really need some tutorials for how to make a plugin and what an extension is.
And in the mean time I would love to find a tutorial on writing a plugin for scar because I totally forgot how to.
Can't wait for this script, it's really amazing me even at low speeds =)

Gu3st...

2010-11-19 06:07:42

Almost!
I though you were gone forever! :D
Does this mean you're back?! :)

Oh, and I'm looking forward to this script! :D

EGM

2010-11-19 09:25:07

Tutorial on how to make a plugin in Simba: http://villavu.com/forum/showthread.php?t=58815

Writing extensions for Simba: http://wizzup.org/simbadoc/simbaref/extensions.html

Regarding forms… I learned from someone that if you want subsequent controls to show up on your form, you have to set the parent.

MyForm := TForm.Create(nil);
MyLabel := TLabel.Create(nil);
MyLabel.Parent := MyForm;

~EGM

Wizzup?

2010-11-19 09:28:59

Remember that the 'nil' you are passing there is already the parent, IIRC. :)

EGM

2010-11-19 10:18:45

From: Wizzup?
Remember that the 'nil' you are passing there is already the parent, IIRC. :)


And yet I find controls won't show without the .Parent being set. :p

MOST important thing to know IMHO is that you can always type in TFORM. and then [Ctrl]+[Spacebar] and it will list all the properties and methods for a form.

~EGM

almost

2010-11-19 12:35:15

Hey zyt3x!
I'm never fully gone, I just pop up in different forums that correspond with what I'm working on haha
I just joined fractalforums the other day and on that day I started working on this project all day every day since then.

EGM thanks a lot that should be what I'm looking for

Cstrike

2010-11-19 12:57:00

From: mormonman
Here you go, this is for the script I have been working on.


Now that is awesome :)

almost

2010-11-19 15:09:13

I made a plugin and it worked but something is wrong.
Somehow the function in the plugin gives different results than the exact same function I had before I put it in the plugin.
Which makes no sense.
I also tried using the plugin for scar instead of simba and I get "[Runtime Error] : Exception: Integer overflow in line 3 in script "

Here is my function I need to be made into a plugin-
function ColorPoint(px, py: extended; MaxIteration: integer): integer;
var
x, y, xtemp: extended;
Iteration: integer;
begin
x:= px;
y:= py;
while ((x*x + y*y <= (2*2)) and (Iteration < MaxIteration)) do
begin
xtemp:= x*x - y*y + px;
y:= 2*x*y + py;
x:= xtemp;
Iteration:= Iteration + 1;
end;
if (Iteration = MaxIteration) then
Result:= 0 else
Result:= Iteration;
end;


And here is my plugin
library Coloration;

{$mode objfpc}{$H+}

uses
Classes, sysutils
{ you can add units after this };

{$R *.res}

function Internal_Func: String;
begin
Result := 'Internal_Func';
end;

function ColorPoint(px, py: extended; MaxIteration: integer): integer;
var
x, y, xtemp: extended;
Iteration: integer;
begin
x:= px;
y:= py;
while ((x*x + y*y <= (2*2)) and (Iteration < MaxIteration)) do
begin
xtemp:= x*x - y*y + px;
y:= 2*x*y + py;
x:= xtemp;
Iteration:= Iteration + 1;
end;
if (Iteration = MaxIteration) then
Result:= 0 else
Result:= Iteration;
end;


function GetFunctionCount(): Integer; stdcall; export;
begin
Result := 1;
end;

function GetFunctionCallingConv(x : Integer) : Integer; stdcall; export;
begin
Result := 0;
case x of
0..0 : Result := 1;
end;
end;

function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; stdcall; export;
begin
case x of
0:
begin
ProcAddr := @ColorPoint;
StrPCopy(ProcDef, 'function ColorPoint(px, py: extended; MaxIteration: integer): integer;');
end;
else
x := -1;
end;
Result := x;
end;

exports GetFunctionCount;
exports GetFunctionInfo;
exports GetFunctionCallingConv;

begin
end.

Wizzup?

2010-11-19 15:18:27

What does this function do?

almost

2010-11-19 15:35:25

It takes an (x, y) and calculates if the coordinates will cycle into infinity or not.
If they do then the result is how many cycles it took to determine that the loop would be infinity.
If you give each coordinate a hue based on this result you get some incredible things when graphed, called fractals.

But I'm finding it strange that inside a plugin I get different numbers, even when the variables put into the function are the same.
Did I make the plugin right?…
When I compile it in Lazarus it says "Local variable Iteration does not seem to be initialized"
But it doesn't say anything about my other variables.
And the result is based off the variable "iteration" so maybe that could be a probelm?

almost

2010-11-19 19:04:37

Exit:
OMG 5 hours later I figured this out…
Apparently variables don't start out at 0 like in scar.
You have to set them.
Which is really dumb because if you don't the program just says "hey I'm going to give this variable a completely random value and screw everything up"
So I put "Iteration:= 0;" at the beginning and it fixed it up.
Very excited =)
\/ Old post for lol's \/

Well I am officially being driven mad by this.
That function loops through a maximum number of times that is set by "MaxIterations".
And the result of the function is how many times it was looped.
So the result can not be any number higher than MaxIterations.
When ran in scar or simba it works perfect.
When put in a plugin, the exact same coding, I get crazy numbers like 2304942039, and even NEGATIVE numbers which is impossible…
The result starts at 0 and can only increase from there…

I have now tried making the plugin with Delphi 7 and the same thing happens.
I get a warning in Delphi that the result "may not be defined" or something like that, even though it definitely is.

Gu3st...

2010-11-21 14:03:06

From: almost
Hey zyt3x!
I'm never fully gone, I just pop up in different forums that correspond with what I'm working on haha
I just joined fractalforums the other day and on that day I started working on this project all day every day since then.
Oh, cool :)
What is fractalforums aiming at? Is it just a programming forum or something?

almost

2010-11-21 14:13:51

Fractalforums is a forum for fractals.
And this project I'm working on draws fractals.
Most people probably haven't heard of a fractal but it's quite a bit to explain.
When I'm done with my script I'll post it and explain them the best I can.

EGM

2010-11-24 11:52:13

From: almost
Fractalforums is a forum for fractals.
And this project I'm working on draws fractals.
Most people probably haven't heard of a fractal but it's quite a bit to explain.
When I'm done with my script I'll post it and explain them the best I can.


That's okay, some of us can access Google. :D

A fractal is "a rough or fragmented geometric shape that can be split into parts, each of which is (at least approximately) a reduced-size copy of the whole,"[1] a property called self-similarity.
(from Wikipedia...)

I must say I'm not big into fractals, but the images will amaze.

~EGM

almost2

2010-11-25 18:53:28

Yup but there is a lot more to fractals that I might try to explain, like how they are found in nature.
And I'm almost done with my script but I can't log in to post it >.<

almost

2010-12-01 15:21:47

Yay I'm back!
And my project is complete
http://villavu.com/forum/showthread.php?t=60368