Create a free account to remove all ad content.

Author Topic: [Scripts] Considering adding a return value to scripts  (Read 3190 times)

0 Members and 1 Guest are viewing this topic.

Craig

  • Developer
  • Extreme Member
  • *
  • Posts: 6655
  • Dig Deep
    • View Profile
    • Twitter
  • Steam: tota1miner
Considering adding a return value to scripts
« on: May 12, 2015, 09:32:24 AM »
I'm considering adding input parameters and return values to scripts.

This would help modularize certain functions.

e.g. Some scripts utilizing return values

script: Validate Something
return [bool]
if
   has..
   has..
   is..
then
   return [true];
else
   return [false];

script: Script1
if
   script [validate something]
then
   validate returned true
else
   validate returned false


script: Script2
if
   script [validate something]
then
   validate returned true
else
   validate returned false

Script1 and Script2 are able to use the same validation without having to write it twice.

Another example:

Script: GetRandomMobType
return [mobtype]
if
   israndom [1,3]
then
   return [sheep]
elseif
   israndom [1,3]
then
   return [duck]
else
   return [highlandcow]

script: SpawnRandomMob
spawnmob [x,y,z] [script:GetRandomMobType]


e.g. Some scripts utilizing input parameters

script: SpawnMob
input [point] point
input [mobtype] mobtype
spawnmob [point] [mobtype]

script:SpawnRandomMob
if
   israndom [1,3]
then
   script [SpawnMob] [100,200,100] [sheep]
elseif
   israndom [1,3]
then
   script [SpawnMob] [200,200,100] [duck]
else
   script [SpawnMob] [100,200,200] [diablo]


possible input/return types would be something like:
Bool (true or false)
Value (a number)
Point (x,y,z)
Color
MobType
BlockID
ItemID
and probably several others

My thinking with this is still undeveloped and there may well be problems that could make it infeasible, but so far i think it could be done.

Thoughts?
« Last Edit: May 12, 2015, 09:35:43 AM by Craig »

FatbFFA

  • Supreme Member
  • *
  • Posts: 2103
    • View Profile
    • ::)
  • Xbox: ETTP & Mr Zincy
Re: Considering adding a return value to scripts
« Reply #1 on: May 12, 2015, 10:20:41 AM »
I think this can open the minds of many also this will make scripts more open to a lot with these new options



TheDestinedCrab

  • Legendary Member
  • *
  • Posts: 1400
  • Did you see that? Me neither.
    • View Profile
Re: Considering adding a return value to scripts
« Reply #2 on: May 12, 2015, 10:21:43 AM »
This sounds good, I can imagine it being good in scripting, very useful. Great idea
Thanks Gold Knight for the amazing sig!

Dryym

  • Supreme Member
  • *
  • Posts: 4336
  • What's yours is mine. ~TM's Resident Master Thief~
    • View Profile
  • Xbox: dryym
Re: Considering adding a return value to scripts
« Reply #3 on: May 12, 2015, 08:09:01 PM »
This, Combined with Relative to Players/Mobs, Would open up so many doors for many people.


Just a thought. This could theoretically be used for coordinate specific history, That could be used for repastable one use per player systems, With little or no editing of scripts, Each time you use a new one.
« Last Edit: May 12, 2015, 08:27:55 PM by Dryym »

Creator of the term "Deathmine "
Jared [19|Oct 07:12 PM]: "It changes everything" Dryym

muD

  • Legendary Member
  • *
  • Posts: 1177
    • View Profile
Re: Considering adding a return value to scripts
« Reply #4 on: May 14, 2015, 10:52:04 AM »
this sounds interesting..
Could you give another example of utilizing input parameters, and an example of how Value can be used pl0x?

muD

  • Legendary Member
  • *
  • Posts: 1177
    • View Profile
Re: Considering adding a return value to scripts
« Reply #5 on: May 20, 2015, 07:23:11 PM »
I'm intrigued to know if this will allow a method of returning the value of history marks, items in inventory ect in a way which can be directly used by other scripts.

ie. being able to count an entity such as the players history record, then use that value in another script.

eg. player runs a script which counts their mobkill count - they have 7,215 history marks from mob kills. that value 7215 can be accessed by another script to notify the player of their kill count.

Is that something that can be done with this?

Jaz

  • Supreme Member
  • *
  • Posts: 3024
  • - Jaz
    • View Profile
    • The Useless Web
  • Xbox: Jaz the MAN 2
  • PSN: Jaz_the_MAN_2
  • Steam: Jaz the MAN 2
Re: Considering adding a return value to scripts
« Reply #6 on: July 27, 2015, 06:00:39 AM »
I'm intrigued to know if this will allow a method of returning the value of history marks, items in inventory ect in a way which can be directly used by other scripts.

ie. being able to count an entity such as the players history record, then use that value in another script.

eg. player runs a script which counts their mobkill count - they have 7,215 history marks from mob kills. that value 7215 can be accessed by another script to notify the player of their kill count.

Is that something that can be done with this?
If so, it is something I have always tried to do with scripts ::)

Dryym

  • Supreme Member
  • *
  • Posts: 4336
  • What's yours is mine. ~TM's Resident Master Thief~
    • View Profile
  • Xbox: dryym
Re: Considering adding a return value to scripts
« Reply #7 on: November 30, 2015, 08:42:07 AM »
I just thought of another way the return value could be used with 2.43 scripts.

"If
   Intersect [Sphere] [vrel:15,0,0] [12] [Players]
Then
   Context [Player] [Target]
   Script [ReturnPoint]
EndIf

If
   Intersect [Ray] [vrel:15,0,0] [ReturnedPoint] [Players]
Then
   Context [Player] [Target]
   Dostuff..."

This tests if there is a player intersecting the bounding box of a sphere, If they are, It runs a script on them that returns their current location, The script then tests if they intersect with a ray from the centre of the sphere, The purpose of this is to determine if there are any blocks in between the centre of the sphere, And the player.

Creator of the term "Deathmine "
Jared [19|Oct 07:12 PM]: "It changes everything" Dryym

PWRBTTN

  • Legendary Member
  • *
  • Posts: 1172
  • Professional Expert, Comrade
    • View Profile
  • Xbox: PWRBTTN
  • Steam: PWRBTTN
Re: Considering adding a return value to scripts
« Reply #8 on: July 20, 2016, 12:56:54 PM »
Hey, Craig. I know we could jury rig something like this using variables in 2.44, but I feel like this in itself could have a use alongside, or even seperate from variables. So... have you fiddled with this much? It'd be nice to see this.
/snail       /snail    /snail         /snail /snail      /snail   /snail                /snail        

Craig

  • Developer
  • Extreme Member
  • *
  • Posts: 6655
  • Dig Deep
    • View Profile
    • Twitter
  • Steam: tota1miner
Re: Considering adding a return value to scripts
« Reply #9 on: December 30, 2016, 07:09:27 AM »
This is no longer needed as variables can be returned.