SRL Archive - OSR Help

2 Things at once?


ILikeSmoothHeads

2012-12-15 16:41:50

Hi, was just wondering how I would get a script to do say two things at once, such as talk (TypeSendEx) and also click somewhere or use an item in the inventory etc? But both at the same time as at the moment I have it talking then doing the action when it's sent the message?

JPHamlett

2012-12-15 16:51:09

I think this is known as multithreading and pascal cannot do that…..

may I ask why you need to type and click the mouse at the sametime.

ILikeSmoothHeads

2012-12-15 16:52:34

It's just to learn, but I was gonna type and dance/any emote at the same time, I'm learning pascal :)

JPHamlett

2012-12-15 16:53:46

I do not think this can be done.

Pascal is not an oop, it is linear.

The Killer

2012-12-15 16:58:57

From: ILikeSmoothHeads
It's just to learn, but I was gonna type and dance/any emote at the same time, I'm learning pascal :)


From: JPHamlett
I do not think this can be done.

Pascal is not an oop, it is linear.


yeah can't be done, atleast not to my knowledge.
You can however have a script click the emote then type
shouldn't be much delay. I'v already got a private one of these that works fine

Dgby714

2012-12-15 17:38:31

Stop saying Pascal.

Simba uses an interpreter called PascalScript, which doesn't support classes in the script.
Tho we do pass some classes to it, (Ex: TForm).
PascalScript is also not OOP. Except passed classes^

Pascal however is completely different, Simba was written in FreePascal which is OOP and supports threading.

Tho you are correct, in scripts you can only do this if you waste your time writing functions that do both at the same time, you can't thread in scripts.

John

2012-12-15 17:49:48

You can do this…

Just run through the "ClickEmote" function/procedure and then the type send.
It might not be exactly at the same time but He would still be dancing and saying stuff at the same time as long as you make it go through the functions fast.

xtrapsp

2012-12-17 08:13:41

Can while do not work?

DannyRS

2012-12-17 08:18:49

From: xtrapsp
Can while do not work?


still going to be going down the lines one at a time

Whatever simba uses (pascal, pascal script, free pascal, something?), like mentioned above, doesent support multi-threading, and is not OOP, meaning you cant do two things at once, you can simulate it, but you cant for example check a timer, while in another loop, you have to check the timer inside that loop

xtrapsp

2012-12-17 08:19:47

From: DannyRS
still going to be going down the lines one at a time


Do a function for one thing and another for something else then in the mainloop use it? or does that not work?

DannyRS

2012-12-17 08:23:24

From: xtrapsp
Do a function for one thing and another for something else then in the mainloop use it? or does that not work?


it will execute the lines from both functions one by one though,

for example, you cant run an eat handler, while using a fight handler,

because you have to like, run combat lines, check food stuff, run combat lines, check food stuff

the interpreter only reads linearly (correct word?), it cant run multiple functions at once

xtrapsp

2012-12-17 08:25:45

From: DannyRS
it will execute the lines from both functions one by one though,

for example, you cant run an eat handler, while using a fight handler,

because you have to like, run combat lines, check food stuff, run combat lines, check food stuff


Hmm, makes sense.

Does Simba allow the use of AND etc?

procedure mainloop;
begin
run; and eat;
end;

but I suppose that would still be doing it one after another.

DannyRS

2012-12-17 08:29:43

yea still going to go through run; then exit that and start eat;

OOP multithreading would allow you to fight in combat, and also cause an eat command to go off, without ever needing to call it in the fighting function

its helpful, but once you get into the linear style, checking for food and stuff at the end of a fight function or inside a loop waiting for combat to end, doesent really matter a great deal