SRL Archive - Research & Development Lounge

Practical application of Lape pointers in RuneScape scripts


TomTuff

2014-10-20 05:31:52

First, for the uninitiated on pointers in Simba, here's an excerpt from the Lape documentation on wizzup.org:
Pointer Operators

  • @
  • ^

The @ operator returns the memory address of a variable, whereas the ^ operator retrieves the value from a memory address:

var
ip: ^Integer;
i: Integer;

begin
i := 41;
ip := @i;
ip^ := ip^ + 1;
writeln(i);
end;


While I can see how this could be useful, I don't see how they could be used in RS scripts.

Justin

2014-10-20 05:43:47

An example: https://villavu.com/forum/showthread.php?t=110607&p=1313618#post1313618

bonsai

2014-10-20 06:17:39

I found use for them in a progress tracking module that handed pointers back to the people who wanted to track things.

I need them for my fighter coloring due to the need for large lists of sorted information. I wrote some [URL="https://villavu.com/forum/showthread.php?t=110326]binary tree functions[/URL] so I could rewrite it but have not made it that far yet.

Read through some of Brandon's posts, he regularly shows some ways to use them.

They pretty much have the same value as in other languages. Most simple scripts won't need them.

Kevin

2014-10-20 08:38:50

Examples and use cases (written in Pascalscript, but there's not that much difference):

https://villavu.com/forum/showthread.php?t=102800
https://villavu.com/forum/showthread.php?t=104249

TomTuff

2014-10-20 13:22:09

In past scripts where I've needed functions similar to your rotate check, I would have whatever function (EnterTunnel(): Boolean), and then create another function (EnterTunnelRotate(Degrees: Integer): Boolean). It seems like pointers are a much cleaner way to do that.

@Bonsai, those binary tree functions look really interesting. Maybe some day I'll try to make a script complicated enough to need to use them.

arclight

2014-10-20 17:40:45

Do the pointers also work with functions? I've been doing some C programming and you can do some pretty cool things with function pointers.

Edit: found an answer to my question https://villavu.com/forum/showthread.php?t=102800

Pretty cool for data structures though, you can essentially make the comparison function passed in via a pointer and do stuff with the data regardless of what the actual data is.

CynicRus

2014-10-22 13:45:24

For more depth understanding about pointers I recommend: http://delphi.about.com/od/objectpascalide/a/pointers.htm

N1234

2014-11-17 15:36:08

very interesting, thanks for sharing!