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-09 01:04:12 -08:00
|
|
|
---
|
2019-01-07 13:07:54 -08:00
|
|
|
|
2019-01-09 04:02:17 -08:00
|
|
|
|
|
|
|
|
|
|
|
<details><summary>DATA TYPES</summary>
|
|
|
|
|
2019-01-09 01:18:12 -08:00
|
|
|
|Type|examples|examples|examples|examples|
|
|
|
|
|---------------|-----------|-|-|-|
|
|
|
|
|bool |true |false
|
|
|
|
|number |0 |123.456 |-5
|
|
|
|
|string |"asd 134"
|
|
|
|
|var |string |number |function |var |bool
|
|
|
|
|function |pos(1 2 a)
|
|
|
|
|symbol |! |(nil) |? |(username)
|
2019-01-09 04:02:17 -08:00
|
|
|
</details>
|
2019-01-07 13:07:54 -08:00
|
|
|
|
2019-01-09 04:02:17 -08:00
|
|
|
<details><summary>VARIABLES</summary>
|
2019-01-09 03:53:24 -08:00
|
|
|
a variable can only be set to 1 thing at time
|
2019-01-07 13:07:54 -08:00
|
|
|
|
2019-01-09 03:53:24 -08:00
|
|
|
|example |-|-|-|-|-|-|
|
|
|
|
|---------------|-|-|-|-|-|-|
|
|
|
|
|varname |a variable|
|
|
|
|
|var_aa = |set variable value|
|
|
|
|
|another_var = |"string"| 123.54| false |var |function()| symbol|
|
|
|
|
|global varname |stored in user memory|
|
|
|
|
|vara = varb |set to another var|
|
|
|
|
|a += 5 |add 5
|
|
|
|
|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 04:02:17 -08:00
|
|
|
|
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 01:04:12 -08:00
|
|
|
**add a node, could be**
|
2019-01-09 01:10:02 -08:00
|
|
|
```lua
|
2019-01-09 00:58:13 -08:00
|
|
|
node.add(pos( -1 2 34) "default:dirt")
|
2019-01-09 01:10:02 -08:00
|
|
|
```
|
2019-01-09 01:04:12 -08:00
|
|
|
**and...**
|
2019-01-09 01:10:02 -08:00
|
|
|
```lua
|
2019-01-09 00:58:13 -08:00
|
|
|
c = 34
|
|
|
|
a = pos(1 2 c)
|
|
|
|
dirt="default:dirt"
|
|
|
|
node.add(a dirt)
|
2019-01-09 01:10:02 -08:00
|
|
|
```
|
2019-01-09 04:02:17 -08:00
|
|
|
</details>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<details><summary>IF</summary>
|
|
|
|
|
2019-01-09 01:10:02 -08:00
|
|
|
```lua
|
2019-01-08 01:41:54 -08:00
|
|
|
if(a==b)
|
|
|
|
..code..
|
|
|
|
endif
|
2019-01-09 01:10:02 -08:00
|
|
|
```
|
|
|
|
```lua
|
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-09 01:10:02 -08:00
|
|
|
```
|
2019-01-09 04:02:17 -08:00
|
|
|
</details>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<details><summary>FOR LOOP</summary>
|
|
|
|
|
2019-01-09 01:10:02 -08:00
|
|
|
```lua
|
|
|
|
start = 3
|
|
|
|
end = 100
|
|
|
|
for(start end)
|
|
|
|
..code...
|
|
|
|
next
|
|
|
|
```
|
2019-01-09 04:02:17 -08:00
|
|
|
</details>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<details><summary>REGISTRY FUNCTIONS</summary>
|
2019-01-09 01:10:02 -08:00
|
|
|
|
|
|
|
```lua
|
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
|
|
|
|
})
|
2019-01-09 01:10:02 -08:00
|
|
|
```
|
|
|
|
```lua
|
2019-01-08 01:41:54 -08:00
|
|
|
was.register_function("name"{
|
|
|
|
packed=true, --inputs all args as table + usedata
|
|
|
|
action=function(args)
|
|
|
|
return result
|
|
|
|
end
|
|
|
|
})
|
2019-01-09 01:10:02 -08:00
|
|
|
```
|
2019-01-09 04:02:17 -08:00
|
|
|
</details>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<details><summary>REGISTRY SYMBOLS</summary>
|
|
|
|
|
2019-01-08 01:41:54 -08:00
|
|
|
a symbol are called while calling a function or setting a var
|
2019-01-09 01:10:02 -08:00
|
|
|
```lua
|
2019-01-08 01:41:54 -08:00
|
|
|
was.register_symbol("#",function(),"info"
|
|
|
|
return result
|
|
|
|
end
|
|
|
|
})
|
2019-01-09 01:10:02 -08:00
|
|
|
```
|
2019-01-09 04:02:17 -08:00
|
|
|
</details>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<details><summary>USERDATA</summary>
|
2019-01-07 13:07:54 -08:00
|
|
|
|
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
|
2019-01-09 04:02:17 -08:00
|
|
|
</details>
|