Code-based Triggers

Give us your feedback about PB2.5! Or have an idea? Post it here!

Should this be added? (read post)

Yes - add it and replace triggers
1
5%
Yes - add it and replace triggers
1
5%
Make it a separate type of trigger
8
40%
Make it a separate type of trigger
8
40%
No - don't add it at all
1
5%
No - don't add it at all
1
5%
 
Total votes : 20

Code-based Triggers

Postby Captain Chickenoos » 23 April 2018, 16:15

I think PB2.5 should have Triggers that are written basically like code.
This way I'd say it'd be easier at least for me to write long triggers instead of waiting to browse the param-list functions.

This is how I think it should work:

Code: Select all
var newVar = getTextSaid;
if(newVar == "-hello"){
   printChar("A bot", 255, 255, 0, "Hello!");
   playSound("achievement");
}
if(newVar == "-colorz"){
   $players.#player*1.skin.color.body = "v";
   $players.#player*1.skin.color.legs = "m";
   $players.#player*1.skin.color.head = "a";
   $sky.model = SKY_NIGHT;
   $gamespeed = 10;
   $respawnspeed = 0;
}


Based on PB2, this is what I'd think the lists of things would look like:
Operators
Spoiler: Show More
[ = ] Set variable | Conditional strings: Contains | Conditional numbers: same as [ == ]
[ != ] Doesn't contain for strings | Same as [ !== ] for numbers
[ == ] Equals exactly
[ !== ] Doesn't equal exactly
[ ! ] Not
[ > ] Higher than
[ < ] Lower than
[ <= ] Lower than or equal to
[ >= ] Higher than or equal to
[ & ] And (All conditions must be true)
[ && ] Or (At least one condition must be true)
[ + ] - Addition (Add numbers together or add a string-value at the end)
[ - ] - Subtraction (Strings: find and remove (string-value), strip (number value))
[ * ] - Multiply (only numbers, string don't change)
[ / ] - Divide (only numbers)
[ ^ ] - Power
[ !^ ] - Root
[ << ] - Shift left (use the amount of times to shift)
[ >> ] - Shift right ^


Game variables start with $ and are things like game speed, respawn delay, gravity, zoom percentage, impact threshold, etc. Game variables also have game structs.
Some game structs and game variables I'd think would work
Spoiler: Show More
$sky.model, $sky.color.red, $sky.color.blue, $sky.color.green, $gamespeed, $impact.threshold, $impact.power, $water.name, $water.color.red, $water.color.green, $water.color.blue, $acid.name, $acid.color.red, $acid.color.green, $acid.color.blue, $gravity, $projectile.speed, $projectile.life, $despawn, $zoom, $spawngunslots, $spawngunamount, $spawnnades.he, $spawnnades.port, $spawnnades.shield, $psi, $casual, $noise, $errorreport, $shadowres


Object variables are the object's ID. I'd suggest putting the IDs as part of large game structs
#player*1 may actually also be a movable name, so $players.#player*1 selects player, while $doors.#player*1 selects the movable. (although that just seems nonsensical)
Game object structs
Spoiler: Show More
$players, $doors, $triggers, $timers, $lamps, $regions, $pushers, $actors, $vehicles, $decors


Functions examples
Spoiler: Show More
teleportAll([region_origin], [region_destination]) - Teleports all players from region_origin to region_destination
teleportInitiator([region_origin], [region_destination]) - Teleports only player initiator.
printColor([text], [red], [green], [blue]) - Prints text in chat in this exact color
printChar([charname], [red], [green], [blue], [text]) - Prints text in chat like above but with a white character name first
printHint([text]) - Generates hint. 0, "" or " " remove hints.
playSound([sound]) - Plays sound using name from string.


Extra
Spoiler: Show More
ndef([var]) - If not defined, return true. (use like if(ndef(variable)){ ... })
var [varname] - Creates new variable. Can set now.
([object-a], [object-b], ... ) - Object list.
if(condition){ dothis } - Condition, "if" - conditions are true, do once.
while(condition){ dothis } - Condition, "while" - conditions are true, repeat until they're not
for(variable; condition; changevariable){ dothis} - Condition, "for" - special "while"
do{ dothis }conditional(condition); - Do once, then repeat if conditional returns true
switch(variable){ cases } - Switch, basically a long "if equals this" with cases as "if this"
User avatar
Captain Chickenoos
 
Posts: 2
Joined: 12 March 2017, 14:42
Location: Somewhere in Space

Re: Code-based Triggers

Postby mrblake213 » 24 April 2018, 03:23

I believe this should be available to the ones who are willing to spend the time and effort learning it.
While the current easy UI triggers should stay for the ones who aren't.
[center] [/center]
User avatar
mrblake213
Proxy [700]
 
Posts: 773
Joined: 16 July 2013, 10:25
Location: Philippines

Re: Code-based Triggers

Postby Neutral » 27 April 2018, 17:15

Looks like Javascript :P

I like the idea, but as a seperate type of triggers because most people don't know how to code.
Have a great day sir/lady!
User avatar
Neutral
Cyber Grub [25]
 
Posts: 31
Joined: 5 June 2015, 21:17

Re: Code-based Triggers

Postby phsc » 29 June 2018, 02:44

even tho this is kinda old
its not really like what mr blake said, if someone knows any programming language at all, maybe not even that, the person can just go in and learn the syntax and do what he would do
but the syntax here is pretty weird, i think it should be something like php or c so its easier for most of the community, as i prefer || over && and && over &
also theres no real need for power, and things like ^ might not be as great as i think some keyboards dont have it, a simple standard function like... sqrt()! would be great enought, or pow
the rest is pretty great, its way easier to do something like $door over $doors, and like $door.x++; is way better than moving a region via triggers to then move the movable into it
but its not getting added anyway
User avatar
phsc
Noir Lime [600]
 
Posts: 694
Joined: 27 July 2013, 13:58
Location: Brazil


Return to Feedback and Insights

Who is online

Users browsing this forum: No registered users