2019-01-08 01:41:54 -08:00
|
|
|
# World Action Script (was)
|
|
|
|
Version: 1
|
2019-01-08 04:17:35 -08:00
|
|
|
Licenses: code: LGPL-2.1, media: CC BY-SA-4.0
|
2019-01-07 13:07:54 -08:00
|
|
|
|
|
|
|
in game programing, not in lua
|
|
|
|
|
|
|
|
|
2019-01-08 01:41:54 -08:00
|
|
|
=====DATA TYPES=====
|
|
|
|
bool true false
|
2019-01-09 00:48:15 -08:00
|
|
|
number 0 123.456 -5
|
2019-01-08 01:41:54 -08:00
|
|
|
string "asd 134"
|
|
|
|
var string number function var bool
|
|
|
|
function pos(1 2 a)
|
|
|
|
symbol ! (nil) ? (username)
|
2019-01-07 13:07:54 -08:00
|
|
|
|
2019-01-08 01:41:54 -08:00
|
|
|
=====VARIABLE=====
|
|
|
|
a variable can only be set to 1 thing at time
|
2019-01-07 13:07:54 -08:00
|
|
|
|
2019-01-08 01:41:54 -08:00
|
|
|
varname a variable
|
|
|
|
varname = set variable value
|
|
|
|
example_var = "string" 123.54 false var function() symbol
|
2019-01-09 00:48:15 -08:00
|
|
|
global varname stored in user memory
|
|
|
|
|
|
|
|
a += 5 add 5 if
|
|
|
|
a -= 7.8 sub 7.8
|
|
|
|
a *= 98 multiply
|
|
|
|
a /= 2 divide
|
|
|
|
a != a = nil (used becaouse you can't set a=nnll )
|
2019-01-09 00:58:13 -08:00
|
|
|
note the character "-" can mess if it is written together another symbol
|
2019-01-09 00:48:15 -08:00
|
|
|
|
2019-01-09 00:58:13 -08:00
|
|
|
#### add a node, could be
|
|
|
|
node.add(pos( -1 2 34) "default:dirt")
|
2019-01-09 00:48:15 -08:00
|
|
|
|
2019-01-09 00:58:13 -08:00
|
|
|
#### and...
|
|
|
|
c = 34
|
|
|
|
a = pos(1 2 c)
|
|
|
|
dirt="default:dirt"
|
|
|
|
node.add(a dirt)
|
2019-01-07 13:07:54 -08:00
|
|
|
|
2019-01-09 00:58:13 -08:00
|
|
|
## ========IF=======
|
2019-01-07 13:07:54 -08:00
|
|
|
|
2019-01-08 01:41:54 -08:00
|
|
|
if(a==b)
|
|
|
|
..code..
|
|
|
|
endif
|
2019-01-07 13:07:54 -08:00
|
|
|
|
2019-01-08 01:41:54 -08:00
|
|
|
if(1=="asd" or a~=b and 87.3>=c nor a<=3 not "aasd"==!)
|
|
|
|
..code..
|
|
|
|
elseif(b==!)
|
|
|
|
..code..
|
|
|
|
elseif(b~=a not c<b)
|
|
|
|
..code..
|
|
|
|
else
|
|
|
|
..code..
|
|
|
|
endif
|
2019-01-07 13:07:54 -08:00
|
|
|
|
|
|
|
========REGISTRY=FUNCTIONS=======
|
|
|
|
|
2019-01-08 01:41:54 -08:00
|
|
|
was.register_function("name"{
|
|
|
|
info="", --function description
|
|
|
|
privs={}, --required privileges, eg (kick=true,server=true)
|
|
|
|
action=function(arg1,arg2...) --function
|
|
|
|
return result
|
|
|
|
end
|
|
|
|
})
|
|
|
|
was.register_function("name"{
|
|
|
|
packed=true, --inputs all args as table + usedata
|
|
|
|
action=function(args)
|
|
|
|
return result
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
========REGISTRY=SYMBOLS=======
|
|
|
|
a symbol are called while calling a function or setting a var
|
|
|
|
|
|
|
|
was.register_symbol("#",function(),"info"
|
|
|
|
return result
|
|
|
|
end
|
|
|
|
})
|
2019-01-07 13:07:54 -08:00
|
|
|
|
|
|
|
========USERDATA=======
|
|
|
|
|
2019-01-08 01:41:54 -08:00
|
|
|
The user's information are stored in the global variable "was.userdata"
|
|
|
|
but is only able while the function / variables are active.
|
|
|
|
|
|
|
|
was.iuserdata(index) --return indexed active data
|
|
|
|
was.ilastuserdata() --return last index
|
2019-01-07 13:07:54 -08:00
|
|
|
|
2019-01-08 01:41:54 -08:00
|
|
|
was.userdata.data --the active line
|
|
|
|
was.userdata.index --index of active line
|
|
|
|
was.userdata.function_name --name of active function
|
|
|
|
was.userdata.name --user's name
|
|
|
|
was.userdata.var --all active variabbles
|