was/README.md

164 lines
2.9 KiB
Markdown
Raw Normal View History

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-11 14:06:18 -08:00
2019-01-12 13:41:20 -08:00
# dont use this in public servers yet, it need to be practical tested first.
2019-01-11 14:10:56 -08:00
progress:
2019-01-11 14:17:32 -08:00
2019-01-12 13:38:43 -08:00
[ ] save / auto storage variable
2019-01-11 14:10:56 -08:00
2019-01-11 14:06:18 -08:00
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-12 13:46:19 -08:00
|Type|examples|examples|examples|examples|examples|
2019-01-09 01:18:12 -08:00
|---------------|-----------|-|-|-|
|bool |true |false
|number |0 |123.456 |-5
|string |"asd 134"
2019-01-12 13:46:19 -08:00
|var |string |number |function |var |booltable|
2019-01-09 01:18:12 -08:00
|function |pos(1 2 a)
2019-01-12 13:46:19 -08:00
|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|
|vara = varb |set to another var|
2019-01-12 13:50:08 -08:00
|vara.b = |set as table|
|event.msg.item |item from event message|
2019-01-09 03:53:24 -08:00
|a += 5 |add 5
2019-01-09 04:03:47 -08:00
|a -= 4 |sub 4
2019-01-09 03:53:24 -08:00
|a *= 98 |multiply
|a /= 2 |divide
2019-01-09 04:03:47 -08:00
|a != |a = nil (used becaouse you can't set a=nll )
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
2019-01-09 04:06:44 -08:00
start_n = 3
end_n = 100
for(start_n end_n)
2019-01-09 01:10:02 -08:00
..code...
next
```
2019-01-09 04:06:44 -08:00
max loops is 1000, dont use negative values
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"{
2019-01-09 04:10:58 -08:00
packed=true, --inputs all args as table
2019-01-08 01:41:54 -08:00
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.
2019-01-09 04:11:35 -08:00
|variable / function|description |
|-------------------|------------|
2019-01-09 04:10:58 -08:00
|was.iuserdata(index) |return indexed active data|
|was.ilastuserdata() |return last index|
|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:20:52 -08:00
|was.userdata.error |crach and send text message|
2019-01-09 04:02:17 -08:00
</details>