GTA2 ScriptPad

Anything to do with GTA1/GTA2 modding (tools, scripts and more).
BenMillard
Immortal
Posts: 889
Joined: 16 May 2009, 06:14
GH nick: BenMillard
Location: London, UK
Contact:

Re: mispad

Post by BenMillard »

+1
User avatar
Gustavob
Immortal
Posts: 407
Joined: 18 May 2009, 21:40
GH nick: Gustavob
|Gustavob|
Location: Nowhere.
Contact:

Re: mispad

Post by Gustavob »

+2

seems unanimous for now

but maybe adding options on Tools > Settings or whatever would be nice for those who don't use that "method"
You just lost the game.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: mispad

Post by B-$hep »

OK. Thanks.


Well adding autocompletion and tooltips for most of the commands is not problem.
They work fine.


Problem arises with detecting and parsing commands like this (example):

Code: Select all

CAR_DATA  name  =   (  float X  ,  float Y  )  remap   rotation   model
There is CAR_DATA, then space then = then space again.
Then the open bracket, few floats, close bracket and few more commands separated with spaces.

Pretty difficult to detect and parse such stuff but i will do my best.
It will just take some more time. I will try to make some small test app with simple strings and the port it to MisPad code.

Solving problem piece by piece is easier.
Always wear safety glasses while programming.
BenMillard
Immortal
Posts: 889
Joined: 16 May 2009, 06:14
GH nick: BenMillard
Location: London, UK
Contact:

Re: mispad

Post by BenMillard »

Hmm, you are trying to make it context-sensitive. That's a noble goal but usually not necessary - just list everything starting with the given letters. Showing upon the 1st letter is fine - you've filtered the list by 26:1 already. (Approximately.)

If I want to write COLLECT_02 as a parameter value, I can write CO, press Down once and then Return or Space would autocomplete it. There won't be any commands or "litter" in the list since no commands start with CO.

Aliases would be good. Let me write ROCKET_LAUNCHER in my GENERATOR declares when I want a Rocket Launcher powerup, just like GIVE_WEAPON uses. It would be silently converted behind-the-scenes into COLLECT_02 at compile-time, so the .scr stayed valid. This breaks compatibility with MisPad, so maybe a "Use Old Constants" setting would be handy until your one becomes the best mission editor.

Have a look round people's .mis files to see what coding styles are popular, logical, internally consistent or reasonable in other ways. Support those ones as much as possible.

TM can help with parsing the script properly, I would think. His editor topic includes the lexical (sp?) syntax definition files which I found. Might have been bundled with DMA compiler or some other documentation they released?

My incomplete CFG Studio 2 parses and auto-detects nearly all text-based data files from 3D GTA editions. The byte-by-byte tokeniser for that was (very badly) written by me. It works. If I can do it... well... ;)
Last edited by BenMillard on 23 Mar 2011, 19:58, edited 1 time in total.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: mispad

Post by B-$hep »

Thanks Ben. Very useful post from you.
I downloaded your CFG Studio, very interesting parsing code in there.
When i will get back home from work, i will look at it more deeply.


I don't quite understand this part:
It would be silently converted behind-the-scenes into COLLECT_02 at compile-time, so the .scr stayed valid.
Can you explain a bit more?

You want Rocket Launcher to be converted into collectible?
Or something like that?


GTG to work soon.
Always wear safety glasses while programming.
User avatar
Gustavob
Immortal
Posts: 407
Joined: 18 May 2009, 21:40
GH nick: Gustavob
|Gustavob|
Location: Nowhere.
Contact:

Re: mispad

Post by Gustavob »

B-$hep wrote: I don't quite understand this part:
It would be silently converted behind-the-scenes into COLLECT_02 at compile-time, so the .scr stayed valid.
You want Rocket Launcher to be converted into collectible?
I guess he wants to be able to do:

Code: Select all

GENERATOR name = (12.34 , 56.78 , 90.12 ) 0 ROCKET_LAUNCHER 120 240
instead "[...]90.12 ) 0 COLLECT_02 120 240", because that would make things 100 times easier, then when saving/compiling, it would get changed into COLLECT_02, MACHINE_GUN into COLLECT_01 et cetera.

Or if thet gets confusing then maybe add notes on the auto-complete list, like:

Code: Select all

CO
  ____________________________
  |COLLECT_00 (pistol)         |
  |COLLECT_01 (machine gun)    |
  |COLLECT_02 (rocket launcher)|
  |COLLECT_03 (electrogun)     |
[...]
would also help ;)
You just lost the game.
BenMillard
Immortal
Posts: 889
Joined: 16 May 2009, 06:14
GH nick: BenMillard
Location: London, UK
Contact:

Re: mispad

Post by BenMillard »

Yeah, what Gus said! :D

We'd have to introduce new constants such as MULTIPLIER_PLUS_ONE and HEALTH. They don't already exist for GIVE_WEAPON or other commands.
User avatar
Pyro
Immortal
Posts: 414
Joined: 17 Mar 2010, 04:07
GH nick: Pyro
Location: Wales, UK

Re: mispad

Post by Pyro »

I think the core functions should be done first before anything clever/fancy is put in. While I agree it would be nicer putting something like ROCKET_LAUNCHER into a generator command compared to the un-helpful COLLECT_02, I do find Gustavob's idea quite useful as a middle-ground for both practicality and functionality.

Of course, if it was done Gustavob's way (saying what a COLLECT_02 is etc) then the colour for the description text should be a different colour so the person knows it's not actual code. The example below is an extension on Gustavobs idea, you start typing the first two letters of a command (in this case "CO") and shows up the list:
Awesome Auto-Complete Drop Down List wrote:CO

COLLECT_00 (pistol)
COLLECT_01 (machine gun)
COLLECT_02 (rocket launcher)
COLLECT_03 (electrogun)
[...]
Besides, any smart person would annotate their code to know what they are anyway ;) I group my weapons by type so it's extremely easy to find/understand. If you can get this to work, it'd be awesome in other places for code too 8-)
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: mispad

Post by T.M. »

ROCKET_LAUNCHER enum already exists.

I think best would be something like CL_RO... -> COLLECT_02 and CL_PI... -> COLLECT_00

But why do we need to do all this if we could just use my editor to actually see what and where they are? :roll: (assuming i had the object placing feature done and the ability to write code directly in my editor XD)
BenMillard wrote:TM can help with parsing the script properly, I would think.
Properly? sweet dreams. If you want to parse it properly, you have to do it exactly like mis compiler does it, and believe me.... it's not worth it... thats why i want to make mis2 format. I've told this many times...
BenMillard wrote:His editor topic includes the lexical (sp?) syntax definition files which I found. Might have been bundled with DMA compiler or some other documentation they released?
No, I made those syntax definition lists up myself from various sources.
User avatar
JernejL
Hitman
Hitman
Posts: 141
Joined: 21 Feb 2010, 22:03
GH nick: RedShirt

Re: mispad

Post by JernejL »

Can you name your project something else?

It's not the same program anymore, people shouldn't get confused.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: mispad

Post by B-$hep »

GTA2 MissEd?

Missed lol.
Always wear safety glasses while programming.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: mispad

Post by B-$hep »

I picked up new name for the tool: GTA2 ScriptPad.
If somebody can suggest better name, post it.

Also some more news:
I got the tooltips for commands like:

Code: Select all

PLAYER_PED Murdock = (15.5, 15.5, 1.0) 25 0
almost working.



There are some tricky moments after last closing bracket.
I worked on the current working stuff whole night yesterday but now i have to go to work again. And when i will get back i will continue messing with it.

Autocompletion also works for most of the commands, but i disabled it for the video.
Adding commands to autocompletion is easy but for tooltips like this it takes alot of time.
So not all of them are added atm.


Share your comments please.
Always wear safety glasses while programming.
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: mispad

Post by Sektor »

ScriptPad is a good name. Auto completion will be useful. mispad already has ctrl+space completion but would be better if I didn't have to push that and Windows defaults to stealing that key combination for switching language on some systems. I'll watch the video later.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: mispad

Post by B-$hep »

Thanks Sektor.

Yes, the autocompletion is automatic in ScriptPad. That's why it's called autocompletion.
MisPad completion actually was manual. You had to press Ctrl+Space to make it pop up.

Ok, good day.
Gotta drive to work now.
Always wear safety glasses while programming.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: mispad

Post by B-$hep »

Ok, tooltips for parameters with spaces are working now 8-)
Also small demo of autocompletion and folding.



Autocompletion of course (including tooltips) always could be improved.
But i have to go to sleep now. I will continue later.
Always wear safety glasses while programming.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: mispad

Post by B-$hep »

Sektor

I think it's time to rename this thread to GTA2 ScriptPad or make new topic and move all posts related to new mis editor to the new topic.
It's not mispad anymore. You decide.

EDIT: nvm, i didn't now that i can also change topic name.
So i changed.


Anyway, i decided to cleanup autocompletion items list. I only left the real commands that actually tell GTA2 to do something and declarations. This speeds up autocompletion.

I left out things like:

Code: Select all

BY_ANY_WEAPON
BY_ANY_FOOT_WEAPON
BY_CAR_MINE
BY_WATER_CANNON
BY_SHOTGUN
BY_ELECTRO_WEAPON
BY_ROCKET_LAUNCHER
BY_MOLOTOV
BY_GRENADE
BY_FLAMETHROWER
BY_FIRE
BY_CAR_BOMB
BY_GUN
BY_PUNCH
BY_UNKNOWN_WEAPON
BY_PUBLIC_TRANSPORT
BY_DUMMY_CAR
BY_POLICE
BY_DROWNING
BY_EXPLOSION
BY_OWN_VEHICLE
BY_TRAIN_TRACKS
BY_VEHICLE

NOT_DAMAGED
FREIGHT
PASSENGER
NO_CARRIAGE
KILL_BY_CAR
KILL_ANY_MEANS
CHAR
CAR
LOCKOUT_PLAYER
LOCKED_PERMANENTLY
UNLOCKED
LOCKOUT_THIEF
LOCKED
NO_LOCK
LET_ME_OUT
GARAGE_CLOSE
GARAGE_OPEN
TEMPLE_2
STRIP_CLUB
BAR_2
PRISON_YARD
SMUG_LAUGH
GANG_DUMPED
PRISON_ALARM
PRISON
CRICKETS
WATERFALL
PORTA_LOO
INDUSTRIAL_LOW
BANK_ALARM
FUNNY_FARM
HUMAN_ABATTOIR
INDUSTRIAL_HIGH
TEMPLE_CHANT
CHURCH_SINGING
VAT
WORKSHOP
GENERATOR_RUMBLE
BAR
NIGHT_CLUB
SKID
WIND
etc. Just some examples.

And the commands like the ones below are in the autocompletion currently:

Code: Select all

DOOR_DATA
IS_CHAR_FIRING_IN_AREA
CLEAR_CAR_NO_COLLIDE
SET_CAR_NO_COLLIDE
ORDER_CHAR_TO_BACKDOOR
GIVE_DRIVER_AND_BRAKE
ORDER_CAR_TO_BLOCK
ANSWER_PHONE
ORDER_CHAR_TO_DRIVE_CAR
ORDER_DRIVER_OUT_CAR
IS_CHAR_FIRING_ONSCREEN
ALTER_WANTED_LEVEL
CLEAR_WANTED_LEVEL
POINT_ARROW_AT
SET_POLICEPED_RATIO
SET_GANG_RATIO
SET_ELVIS_RATIO
SET_CARTHIEF_RATIO
SET_MUGGER_RATIO
SET_PEDDENSITY
SET_POLICECAR_RATIO
SET_BADCAR_RATIO
SET_GOODCAR_RATIO
SET_CAR_DENSITY
...
Etc.

Maybe i will add option to choose from: full autocompletion list or the minimal autocompletion.
What do you think guys?
Always wear safety glasses while programming.
User avatar
elypter
Immortal
Posts: 1120
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: GTA2 ScriptPad

Post by elypter »

those objects can be useful but most time you will have to look them up before anyway (Sounds for example). other things like doorlocks would be handy but its not easy to tell what is important and what not. i think the best way would be to allow the user to choose between full and limited autocompletion.
yur sa'nok ngeyä
BenMillard
Immortal
Posts: 889
Joined: 16 May 2009, 06:14
GH nick: BenMillard
Location: London, UK
Contact:

Re: GTA2 ScriptPad

Post by BenMillard »

Turning the natural name of constants into the GBHscript name of objects is the most useful thing autocompletion could do. And there's a relatively easy, lo-fi way to do this whilst keeping compatible with Mis Pad. Here's what I have in mind:
  1. Type "pistol" in the weapon name part of a GENERATOR.
  2. Press Ctrl+Space.
  3. It is replaced by COLLECT_01.
  4. A comment is added to the end if the line, which simply says // pistol.
  5. Now my command is valid and I can make sense of it thanks to the comment, without having to refer to a big list of numerical weapon constants, AND it's compatible with Mis Pad.
Here's a full example. This is what I've typed:

Code: Select all

GENERATOR pistol1 = (10.0,20.0) 090 pistol|
Now I press Ctrl+Space and it becomes:

Code: Select all

GENERATOR pistol1 = (10.0,20.0) 090 COLLECT_00 | // pistol
The vertical bar represents the text cursor (aka the insertion point). So I can continue typing the other parameters. If any of these later parameters get replaced, the comment just gets longer.

Predictive Code
A more sophisticated logic could be developed on this string-based searching and mapping. If I make a GENERATOR whose name includes "pistol", ScriptPad could suggest COLLECT_00 once I get to that part of the command. This would work with editing a command, so a new name would give new suggestions if I moved the insertion point to a parameter which didn't match that name.

Mappings would be many-to-one and use case-insensitive substring matching. The most popular 3 names for each GENERATOR type could be supported, as a maximum. Such as "rocket", "zooka" and "rpg" being mapped to COLLECT_02. Many would only need one of these pseudo-aliases. Such as "pistol" becoming COLLECT_00.

Syntax completio
A few ways to do this but how about I start with this:

Code: Select all

GENERATOR pistol1 |
Now I press Ctrl+Space and it becomes:

Code: Select all

GENERATOR pistol1 = (_x,y,z_) rotation COLLECT_00 delay1 delay2 ammo // pistol
The part between underscore characters would be selected text.

Other Applications
Car names are a prime candidate for this automated editing.

The tooltips will be very handy in gang zone setups, phone templates and other complex commands. The bonus lists for cranes spring to mind!

(EDIT) Ah, cannot underline within a code sample.
User avatar
Gustavob
Immortal
Posts: 407
Joined: 18 May 2009, 21:40
GH nick: Gustavob
|Gustavob|
Location: Nowhere.
Contact:

Re: GTA2 ScriptPad

Post by Gustavob »

I like Ben's suggestions but I would rather suggest Ctrl+Return instead Ctrl+space because it is already used as default key combination for other softwares and may eventually mess some things up. But something that would make it somewhat better for users would be the ability to choose their own key combinations like in Notepad++
You just lost the game.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: GTA2 ScriptPad

Post by B-$hep »

So you don't like automatic codecompletion?
You like pressing Ctrl+Space each time?

Or you just want that Ctrl+Space will display the autocompletion list whenever and whereever you want? Like Mispad ctrl+space does.

Correct?

I will try, to see how they work with each other.


EDIT: i wonder why forum didn't notified me about Ben and Gustavob new posts here.
Always wear safety glasses while programming.
Post Reply